1 year ago

#14918

test-img

Peter Hull

How to unconditionally recompile with automake's Makefiles

I have a project using autoconf/automake. Sometimes I want to remake part of it even though make (correctly) believes all dependencies are up-to-date. For other projects I can use make -W some-file.c to ask make to pretend that some-file.c is new and rebuild accordingly. (Option -W is also called --what-if, --new-file and --assume-new.) However this doesn't work with automake's Makefiles - nothing happens, as if the option is ignored. Is there any way to get this feature working?

I am using automake (GNU automake) 1.16.2 and autoconf (GNU Autoconf) 2.69

Example configure.ac

#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([zot.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_PROG_CC
AC_OUTPUT

Example Makefile.am

bin_PROGRAMS=zot
zot_SOURCES=zot.c

Example zot.c file

int main() { return 0;}

Example session

$ ./configure && make
checking for a BSD-compatible install... /usr/bin/install -c

(autoconf output omitted)

config.status: executing depfiles commands
make  all-am
make[1]: Entering directory '/tmp/meo'
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT zot.o -MD -MP -MF .deps/zot.Tpo -c -o zot.o zot.c
mv -f .deps/zot.Tpo .deps/zot.Po
gcc  -g -O2   -o zot zot.o  
make[1]: Leaving directory '/tmp/meo'
$ make
make  all-am
make[1]: Entering directory '/tmp/meo'
make[1]: Leaving directory '/tmp/meo'

I would expect the following command to re-compile zot.c and re-link

$ make -W zot.c
make  all-am
make[1]: Entering directory '/tmp/meo'
make[1]: Leaving directory '/tmp/meo'

however make does not do anything as everything were up to date.

makefile

automake

0 Answers

Your Answer

Accepted video resources