【发布时间】:2016-04-14 15:05:08
【问题描述】:
我有以下makefile.am:
AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS = prog
DEFS =
CFLAGS =
prog_SOURCES := $(wildcard src/GUI_dialogs.cpp) src/GUI_main_win.cpp
$(info **$(prog_SOURCES)**)
如果我生成 makefile (autoreconf && ./configure) 然后运行 make
我得到以下输出:
**src/GUI_dialogs.cpp src/GUI_main_win.cpp**
g++ -I. -g -O2 -MT GUI_main_win.o -MD -MP -MF .deps/GUI_main_win.Tpo -c -o GUI_main_win.o `test -f 'src/GUI_main_win.cpp' || echo './'`src/GUI_main_win.cpp
src/GUI_main_win.cpp:1:24: fatal error: ...Header not found as expected...
第一行显示 prog_SOURCES 变量设置正确,但它错过了首先编译 GUI_dialogs 对象。
如果我将 prog_SOURCES 更改为:
prog_SOURCES := src/GUI_dialogs.cpp src/GUI_main_win.cpp
然后 GUI_dialogs 对象按预期首先编译。
我知道订单可能没有定义。但如果我只有通配符:
prog_SOURCES := $(wildcard src/GUI_dialogs.cpp)
然后我得到:
**src/GUI_dialogs.cpp**
gcc -o prog
gcc: fatal error: no input files
compilation terminated.
为什么它只是跳过通配符文件?即使它显然在变量中?
【问题讨论】:
-
这样做你违反了 autotools 的源代码政策,并且显然会破坏源代码构建。这是故意的吗?
-
我并不关心如何,但我真的不想管理源文件列表。是的,因为那个网页说我是一个懒惰的开发人员。如果我不懒惰,我会手动编写makefile,而不是使用自动工具。我正在使用的当前系统有一个 shell 脚本,它生成 Makefile.am,然后使用 autotools 生成 makefile。我想删除那个 shell 脚本。
-
是否可以直接编写 makefile 而不必手动管理依赖项(或直接在 makefile 中使用难看、几乎无法辨认的代码)?
-
@user3159253,我不明白为什么 automake 工具需要知道正在编译的文件?