我只想用自动生成的 auto(make/conf/...) 东西在 linux 中开发一个 C 应用程序。我尝试用 ede 和 anjuta 生成它,但它似乎没有生成 Makefile.am。所以,我尝试运行 automake,它说找不到“ltmain.sh”。是否有一些易于为 linux C/C++ 应用程序生成基本构建文件的方法。什么是标准做法?大多数人自己编写这些文件吗?
谁能告诉我是否有办法向 Makefile.am 插入条件块,以便将其进一步传递给由 autotools 创建的 Makfile?
下面是一个例子:
ifeq "$(SOMEVAR)" ""
SOMEVAR="default_value"
endif
Run Code Online (Sandbox Code Playgroud)
这似乎是做有条件的事情的常见 Makefile 方式。Automake 切断 endif 行并最终失败并显示如下消息:
Makefile:390: *缺少‘endif’。停止。
有什么想法吗?
如何告诉 Automake 构建一个不需要安装的动态模块?
pkglib_LTLIBRARIES = mywrapper.la
mywrapper_la_LDFLAGS = -no-undefined -module -avoid-version
Run Code Online (Sandbox Code Playgroud)
导致 mywrapper.so 安装到pkglibdir.
noinst_LTLIBRARIES = mywrapper.la
mywrapper_la_LDFLAGS = -no-undefined -module -avoid-version
Run Code Online (Sandbox Code Playgroud)
导致改为构建静态便利库。
有问题的动态模块仅用于运行测试套件,因此不能分发。
在 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使用名称中带有空格的文件?这似乎不起作用.
bin_PROGRAMS = prog
prog_SOURCES = "a file.c" "another file.c"
Run Code Online (Sandbox Code Playgroud) 我在https://github.com/Habbie/autoyacc-problem上发布了一个存储库来演示我的问题。
在 automake 1.11 及以下版本中,AC_PROG_YACC在 configure.ac 和AM_YFLAGS=-dMakefile.am 中使用,parser.yy 将变成 parser.cc 和 parser.h。使用 automake 1.12,我得到 parser.cc 和 parser.hh。因为 mybin.cc 有include "parser.h",这意味着 1.12 破坏了我的构建。
我感觉这是一个向后不兼容的更改,但我觉得应该有一种理智的方法来处理这个问题。
展示:
git clone https://github.com/Habbie/autoyacc-problem.git
cd autoyacc-problem/
autoreconf -i
./configure
make
Run Code Online (Sandbox Code Playgroud)
automake 1.11 的结果:mybin 被构建。automake 1.12 的结果:
mybin.cc:1:20: error: parser.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
帮助!
注意:本示例中没有实际的 C++ 代码,但对于我的实际问题,我确实需要 g++。
我正在修改一个与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) 首先,我只是想说,我是Autotools的新手.
我有一个具有以下结构的项目:
+-src
+-commands
Makefile.am
+-copy
Makefile.am
copy.h
copy.cpp
+-delete
Makefile.am
delete.h
delete.cpp
main.cpp
Makefile.am
Makefile.am
Run Code Online (Sandbox Code Playgroud)
Makefile.am有SUBDIRS = src
src/Makefile.am有SUBDIRS =命令.
src/commands/Makefile.am有SUBDIRS = $(AUTODIRS)
当我在root中运行automake时,它会生成Makefile.in和src/Makefile.in,但不会生成命令和副本.
我究竟做错了什么?
我目前正在开发一个依赖于递归automake进行构建的C++项目.我想构建一个共享库,并Makefile.am在库的src目录中看起来像
# ...
# Library name
lib_LTLIBRARIES = libadapter-@MY_API_VERSION@.la
# Sources
libadapter_@MY_API_VERSION@_la_SOURCES = \
$(top_builddir)/src/sourceA.cpp \
$(top_builddir)/src/sourceB.cpp
# ...
Run Code Online (Sandbox Code Playgroud)
自1.14版本,automake的问题时,警告subdir-objects未指定的选项AM_INIT_AUTOMAKE中configure.ac.但是,添加该subdir-objects选项似乎打破了构建过程,make抱怨丢失的.Plo文件.我已经在网上搜索了遇到类似问题的人,但没有找到任何合理的提示,如何在不将项目更改为非递归项的情况下解决问题.任何帮助是极大的赞赏.
编辑:
更深入地探讨这个问题,我注意到./configure创建了一个目录,名称$(top_builddir)在库的当前源目录下面,该目录包含.Plo构建库所需的所有文件.在Makefile,但是,我发现.Plo我的库源当量(sourceA.cpp和sourceB.cpp在本例中)由前缀include $(top_builddir)/src/$(DEPDIR)/和$(top_builddir)被定义为一个变量的相对(即,路径../../../src/.deps/).现在很清楚为什么make找不到.Plo文件,因为它搜索错误的目录.这看起来像bug #16375的可能重复.任何解决方法?
编辑2:
在网络上进一步挖掘,揭示了另外两个线程来解决这个问题:#1327和automake-bug.一个已知的解决方法似乎是将--disable-dependency-tracking选项传递给./configure.至少对我来说它有效.
我正在尝试使用 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)