自动工具:强制make不重新构建configure/Makefile

9
我有一个使用autotools(automake、autoconf)的项目。
我想禁止make重新生成configureMakefile.in等文件,只进行编译工作。
其中一些文件是手动编辑的,我知道不应该这样做。(或者项目从CVS更新,所有生成的文件都存储在CVS中)。但目前我没有正确版本的autotools安装。
这些文件的修改时间应该如何修改(哪些文件应该更新/旧一些):
aclocal.m4
configure.in
confdb/ax_prefix_config_h.m4
Makefile.am
Makefile.in
Makefile
configure
config.status

或者说,我需要执行哪些touch命令序列才能实现我的目标?
3个回答

12

首先,如果您直接编辑一个生成的文件,它将不会被重新构建,因为它比其前提更新。

然后,这里有两个独立的事情正在进行:在构建期间创建了config.statusMakefile。除非您使它们的时间戳更新,否则很难防止它们在构建期间被重建。

其他文件是由各种 Autotools 生成的。最新版本的 Automake 默认情况下不会创建自动重新生成这些文件的规则。根据您的包,您可能需要使用configure选项--disable-maintainer-mode。Automake 文档包含有关该选项的更多有趣信息。

我有时会在不太了解或具有相当混乱的构建系统的软件包上运行以下命令:

make all AUTOCONF=: AUTOHEADER=: AUTOMAKE=: ACLOCAL=:

这样,如果这些程序被调用,将会替换为无操作。


我手动编辑了 configure 文件,也编辑了 configure.in 文件。但是我没有所需的 autotools 版本,因此对 configure 的编辑就像使用正确的工具重新生成一样。我不想使用不同的 autotools,因为该项目在 cvs 下,并且存储了所有创建的脚本(configure、*.m4、*.in)。 - osgx
哦,--disable-maintainer-mode - 谢谢。不幸的是,该项目使用的不是 automake,而是简单的 Makefile.sm(Makefile),它没有 --disable-maintainer-mode - osgx
项目的新版本中有几个“configure”脚本。顶层的configure带有“--disable-maintainer-mode”选项,并且可以正常工作,但是一些内部的configure没有“--disable-maintainer-mode”选项。 - osgx

4
touch confdb/*.m4
touch configure.in
touch *.m4
touch *.am
touch Makefile.in */Makefile.in
touch *config.h.in */*config.h.in
touch configure
touch config.status
touch config.h
touch Makefile

这里描述了自动化构建工具 automake 和版本控制系统 CVS 的问题,请参阅 http://www.gnu.org/s/hello/manual/automake/CVS.html


记得接受自己的答案,这样问题就不会看起来没有回答。 - Jack Kelly

2
尝试通过命令行明确告诉make这些文件不应该重新生成。
$ make -o configure -o Makefile.in

或者通过使用MAKEFLAGS

$ MAKEFLAGS="-o configure -o Makefile.in" make

来自GNU make手册的摘录

‘-o file’
‘--old-file=file’
‘--assume-old=file’
Do not remake the file file even if it is older than its prerequisites, and do not remake
anything on account of changes in file. Essentially the file is treated as very old and
its rules are ignored. See Avoiding Recompilation of Some Files.

如果您的autotools模板正确使用$(MAKE)进行子目录,那么就不会有问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接