在 automake 中,您可以使用变量添加测试TESTS,但这些测试必须是独立的测试。我需要一种方法来调用提供参数的标准测试驱动程序。有什么方法可以做到这一点,或者在测试期间调用标准 makefile 目标?
例如,我的目标之一需要运行:
driver.sh suite-a
Run Code Online (Sandbox Code Playgroud)
还有一次我需要运行:
driver.sh suite-b
Run Code Online (Sandbox Code Playgroud)
每次都必须添加另一个 bash 脚本包装器才能分配给TESTS. 因此,要么我需要添加TESTS命令行选项,要么我需要一种方法来添加 make 目标作为测试本身。
我怎样才能做到这一点?
我正在修改一个与Automake / libtool文档提供的示例非常相似的项目。摘录:
顶级configure.ac:
LT_INIT
Run Code Online (Sandbox Code Playgroud)
顶级 Makefile.am:
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src doc
Run Code Online (Sandbox Code Playgroud)
./src 生成文件.am:
lib_LTLIBRARIES = libname.la
libname_la_SOURCES = <my cc file list>
libname_la_LDFLAGS = -no-undefined -version-info $(GENERIC_LIBRARY_VERSION)
include_HEADERS = <my h file list>
bin_PROGRAMS = progname
progname_SOURCES = <my cc file list>
progname_LDADD = libname.la
progname_LDFLAGS = -static
Run Code Online (Sandbox Code Playgroud)
在我的包创建软件提供的fakeroot环境中,我执行以下命令
$ autogen.sh # contains the usual calls to aclocal, libtoolize, automake, autoconf.
$ ./configure --prefix="/usr" --disable-static
$ make
...
/bin/sh ../libtool --tag=CXX --mode=link g++ -Wall …Run Code Online (Sandbox Code Playgroud) 当我运行automake --foreign --add-missing我的 C 程序编译时,我收到以下消息 。
mylib/Makefile.am:1: error: Libtool library used but 'LIBTOOL' is undefined
mylib/Makefile.am:1: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
mylib/Makefile.am:1: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
mylib/Makefile.am:1: If 'LT_INIT' is in 'configure.ac', make sure
mylib/Makefile.am:1: its definition is in aclocal's search path.
Run Code Online (Sandbox Code Playgroud)
这是我的configure.acwhitch 包括 LT_INIT。
AC_PREREQ([2.69])
AC_INIT([drive], [1], [admin@local])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/drive.c])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
LT_INIT
AC_CONFIG_FILES([Makefile
src/Makefile
mylib/Makefile])
AC_OUTPUT
Run Code Online (Sandbox Code Playgroud)
mylib/Makefile.am 也在这里
lib_LTLIBRARIES = libmylib.la …Run Code Online (Sandbox Code Playgroud) 我正在尝试弄清楚如何为多个版本的 Python 构建我的项目。我正在 Debian wheezy 上测试这个,Python 的默认版本是 2.7。但也支持并安装 2.6。但是,automake 仅针对 Python 2.7 进行安装和编译。我希望它也能编译 2.6。
这是configure.ac 和Makefile.am。如有必要,我可以提供更多详细信息,但希望这些就足够了。
我是 Autotools 的初学者,所以可能有一些明显的解决方案。
这似乎是一个愿望清单错误: RFE: build against multiple python stacks。这里也有类似的讨论:RFC: (automake) add support for Dual python 2 / python 3 builds。
还有一个建议的解决方案(看起来很复杂),在 CDBS + Autotools + Python中给出
这是configure.ac。
##################################################################################
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([corrmodel], [0.1], [faheem@faheem.info])
AM_INIT_AUTOMAKE([foreign -Wall -Werror -Wno-extra-portability parallel-tests])
AM_MAINTAINER_MODE
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
# Checks for programs. …Run Code Online (Sandbox Code Playgroud) 我正在构建支票框架示例“check_money”,但它不是在我的机器上构建的。错误是:
configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下方法安装它:
libtoolize --force
aclocal
autoheader
automake --force-missing --add-missing
autoconf
./configure
Run Code Online (Sandbox Code Playgroud)
它仍然给我同样的错误。
因此,我将同一目录复制到另一个目录并运行:
autoreconf --install
./configure
Run Code Online (Sandbox Code Playgroud)
它仍然给我同样的错误。我不知道还能尝试什么。
我在 Mac OS X Mavericks (10.9) 上
我正在尝试设置我的项目以使用 autotools 构建系统进行分发。但是,当涉及到包含一些额外的库时,我遇到了问题。
我的代码依赖于几个库:
我写的一个(我会叫 libfoo)
一个是第三方(我将称之为 libbar)
Eigen3(这只是头文件)
这些都已经编译并安装在我的 $HOME 目录中。我不需要将它们构建为这个项目的一部分。
我需要的标志是
-std=c++11 (Got this taken care of)
Run Code Online (Sandbox Code Playgroud)
和
-I/path/to/include/libfoo (or libbar, or Eigen3)
Run Code Online (Sandbox Code Playgroud)
和
-L/path/to/lib/ (Where libfoo and libbar reside)
Run Code Online (Sandbox Code Playgroud)
和
-lfoo
Run Code Online (Sandbox Code Playgroud)
编译和链接 libfoo 和 libbar
问题是我想设置检查 libfoo 和 libbar 及其标头的存在(我已经检查了 Eigen3 设置)。问题是像 AC_CHECK_HEADERS 和 AC_CHECK_LIB 这样的宏似乎不想包含所需的 CPPFLAGS 或 LDFLAGS,无论我如何尝试定义它们,因此配置步骤失败。
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([libfoo/foo.h], , [echo "Did not find libfoo headers"; exit -1])
AC_LANG_POP([C++])
Run Code Online (Sandbox Code Playgroud)
阅读 config.log 显示 configure 正在尝试使用
g++ -std=c++11 (other flags...)
Run Code Online (Sandbox Code Playgroud)
但由于缺少上述标志而失败(错误是“找不到 Eigen3/dense”或类似的,表明缺少 -I 标志)
我是 autotools 的新手,所以我可能会遗漏一些明显的东西,但我已经阅读了大量的帮助和手册,但到目前为止还没有弄清楚我需要做什么来设置它。 …
假设我想CFLAGS在我的configure脚本中添加一个特定的标志,它应该传播到所有子项目的configure脚本:
CFLAGS+=" -Dfoobar"
export CFLAGS
AC_CONFIG_SUBDIRS([sub])
Run Code Online (Sandbox Code Playgroud)
这在configure被简单调用时有效。一旦发生以下情况之一:
CFLAGSconfigure调用时在环境中导出CFLAGS在configure命令行上设置configure -C)这种方法不再有效。在前两种情况下,exportedCFLAGS被简单地忽略了;在最后一个中,configure失败了
配置:错误:上次运行中未设置“CFLAGS”
我设法通过以下方式使其可靠地工作:
AM_CFLAGS+=" -Dfoobar"
export AM_CFLAGS
AC_SUBST([AM_CFLAGS]) # repeat this line in every configure.ac for each *FLAGS
AC_CONFIG_SUBDIRS([sub])
Run Code Online (Sandbox Code Playgroud)
考虑到有多个子项目,并且*FLAGS可能需要像这样设置多个变量,这虽然半途而废,但仍然是次优的。有没有办法通过只破解顶级来完成这项工作configure.ac?
my autotools project has a couple of unit-tests.
one of these tests (filereader) needs to read a file (data/test1.bin)
Here's my filesystem layout: - libfoo/tests/filereader.c - libfoo/tests/data/test1.bin
and my libfoo/tests/Makefile.am:
AUTOMAKE_OPTIONS = foreign
AM_CPPFLAGS = -I$(top_srcdir)/foo
LDADD = $(top_builddir)/src/libfoo.la
EXTRA_DIST = data/file1.bin
TESTS = filereader
check_PROGRAMS= filereader
filereader_SOURCES = filereader.c
Run Code Online (Sandbox Code Playgroud)
this works great, as long as i do in-tree builds.
However, when running the test-suite out-of-tree (e.g. make distcheck), the filereader test cannot find the …
我正在尝试使用 google test 测试我的 C 库,但在使用框架模拟函数时遇到问题fff.h。这是我的文件结构:
.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Makefile.am\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 configure.ac\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 include\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Makefile.am\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 public_header.h\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 libmylib\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Makefile.am\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 private_functions.c\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 private_functions.h\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 libmylib.la\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 libmylib.c\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 libmylib_test\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Makefile.am\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 fff.h\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test.cc\nRun Code Online (Sandbox Code Playgroud)\n\n我想从标头模拟一个函数,该函数在使用框架private_functions.h的函数中使用。public_header.hfff.h
public_function()\n{\n private_function(); //This function is the one I want to mock.\n}\nRun Code Online (Sandbox Code Playgroud)\n\n我的测试如下所示:
\n\n#include "gtest/gtest.h"\n#include "public_header.h"\n#include "fff.h"\n\nextern "C" {\n #include "private_functions.h"\n}\n\nDEFINE_FFF_GLOBALS;\n\nFAKE_VALUE_FUNC(int, function, char *, char *);\n\nclass libtest : public testing::Test\n{\npublic: \n virtual void …Run Code Online (Sandbox Code Playgroud)