【发布时间】:2016-09-07 15:20:28
【问题描述】:
我已遵循此link 并调整了其步骤以使其适用于我的项目。
我的目标是创建一个libfile.a 以作为静态库分发。项目树如下:
project
|
+-src
+- <some cpp and hpp files>
|
+ containers
|
+- <other cpp and hpp files>
我轻松创建了configure.ac 文件和Makefile.ams。树结构是这样改变的:
project
|
+- configure.ac
+- Makefile.am
+-src
+- <some cpp and hpp files>
+ Makefile.am
|
+ containers
|
+- <other cpp and hpp files>
现在,我去的时候:(*)
aclocal; autoreconf --install; autoconf; ./configure
make
为src 中包含的所有.*pp files 生成.o files,但是当它开始在src/containers 中生成这些目标时它会失败。所以Makefile 没有正确生成。我究竟做错了什么?有人可以帮我吗?
PS 这里涉及到文件:
# --- configure.ac ---
AC_PREREQ([2.68])
AC_INIT([filea], [1.0], [dev@host.net])
AM_INIT_AUTOMAKE([filea], [1.0])
AC_CONFIG_SRCDIR([src/HashFunctions.cpp])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CXX
AC_PROG_RANLIB
AC_CHECK_HEADERS([stddef.h stdint.h string.h])
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_CHECK_FUNCS([memset])
AC_OUTPUT([Makefile src/Makefile])
# --- Makefile.am ---
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src
# --- src/Makefile.am ---
lib_LIBRARIES = libfile.a
libfile_a_SOURCES = \
ConfigLib.hpp \
ConfigLib.cpp \
HashFunctions.cpp \
HashFunctions.hpp \
Logger.hpp \
Logger.cpp \
Queue.hpp
libfile_a_SOURCES += \
containers/SafeContainer.cpp \
containers/SafeInterger.cpp \
containers/SafeMap.cpp
编辑 1
根据Brett Hale 的建议,标有(*) 的命令已替换为以下命令:
autoreconf -fvi
输出:
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
autoreconf: Leaving directory `.'
搭配时:
./configure
make
仍然没有找到在子目录中生成目标的规则。
EDIT 2 我切换到非递归方法(感谢Karel Zak's blog),最后我可以makemy lib。
【问题讨论】:
-
您可以尝试使用:
autoreconf -fvi代替aclocal; ....;命令吗? -
@JesperJuhl - 是的,cmake 最初是出于纯粹的意图......只是发现这是一个 hard 问题,并且在没有 20 年经验的情况下有效地重新发明了轮子与 bash / m4 不同,自动工具 - 以及其他地方都没有使用的语法。
-
@BrettHale 感谢您的回答。请查看问题中的 EDIT 1;
-
@JesperJuhl Ty 回答。我更喜欢对 autoconf / automake 进行更多调查,希望不久或稍后在一些帮助下,我会弄清楚它是如何完成的。
标签: c++ makefile autotools autoconf automake