Hi, For the GStreamer project (http://www.gstreamer.net/) I've got a Makefile.am which uses target specific CFLAGS, and also has an automake conditional to determine the source files to use. This is generating a functioning makefile, but each of the rules for generating a specific target from a source file appears twice in the makefile, causing make to emit warnings such as: Makefile:1344: warning: overriding commands for target `libgst_la-gstparse.lo' Makefile:966: warning: ignoring old commands for target `libgst_la-gstparse.lo' If the conditional is removed, there is no longer any problem. I've got a minimal example, in the form of a test case, which I attach to this message. PS: thanks for adding the _CFLAGS support: we've had some very nasty hacks in place to do this. We need specific _CFLAGS so that we can specify that -O2 should be used for a particular target rather than -O6: the code is a bit hairy (a cothreads implementation) and -O6 breaks it... We want -O6 elsewhere though. PPS: It would also be helpful if we could add specific flags _after_ the standard CFLAGS - the current implementation adds them before. We need the -O2 to be at the end of the flags line, and I have therefore to clear the default CFLAGS and set specific ones for both of my targets, viz: libcothreads_la_CFLAGS = $(CFLAGS) -O2 libgst_la_CFLAGS = $(CFLAGS) CFLAGS = Being able to do: libcothreads_la_POSTCFLAGS = -O2 would be neater (though the name is bad)... -- Richard
#! /bin/sh # Regression test for multiple rules being generated for each target when # conditionals are present. # From Richard Boulton . $srcdir/defs || exit 1 cat >> configure.in << 'END' AC_PROG_CC AM_CONDITIONAL(BAR, true) END cat > Makefile.am << 'END' if BAR BAR_SRCS = bar.c endif bin_PROGRAMS = foo foo_CFLAGS = -DFOO foo_SOURCES = foo.c END : > compile $AUTOMAKE || exit 1 uncondval=`fgrep 'foo-foo.o: foo.c' Makefile.in` cat >> Makefile.am << 'END' foo_SOURCES += $(BAR_SRCS) END $AUTOMAKE || exit 1 condval=`fgrep 'foo-foo.o: foo.c' Makefile.in` test "x$uncondval" == "x$condval"