Hello Daniel, * Daniel Haude wrote on Fri, Jun 09, 2006 at 09:30:28AM CEST: > > I'm trying to get automake to set a compiler flag when compiling a > specific binary. My Makefile.am looks (in part) like this:
> CFLAGS = -W -Wall -ansi -pedantic -g CFLAGS are supposed to be reserved for the user; AM_CFLAGS is for the developer. > gen_gui_data_CFLAGS = -DCODE_GENERATOR Preprocessor defines are better put in *CPPFLAGS, not *CFLAGS. > Well, this just doesn't work. The -DCODE_GENERATOR option isn't set > when compiling the sources for gen_gui_data. I looked at the resulting > Makefile, and sure enough at some point it contains the line > > gen_gui_data_CFLAGS = -DCODE_GENERATOR > > but the gen_gui_data_CFLAGS variable isn't used at any point. > So why doesn't it work? I tried it in both versions 1.4-p6 and 1.9.5. > The situation is the same if I use CPPFLAGS insead of CFLAGS. This is weird, because I cannot reproduce your problem with 1.9.2 nor 1.9.6 (please dump 1.4-p6 in the trash bin quickly). See below for how I tried. So, what's different in your setup so that this doesn't work for you? Cheers, Ralf $ cat configure.ac AC_INIT([per-target-flags], [1], [devnull]) AM_INIT_AUTOMAKE([foreign 1.9]) AC_CONFIG_FILES([Makefile]) AC_PROG_CC AC_OUTPUT $ cat Makefile.am AM_CFLAGS = -W -Wall -ansi -pedantic -g bin_PROGRAMS = ctops-gui gen_gui_data gen_gui_data_SOURCES = gen_gui_data.c ctops_gui_SOURCES = main.c gen_gui_data_CPPFLAGS = -DCODE_GENERATOR gui_data.c gui_data.h: gen_gui_data ./gen_gui_data $ autoreconf -vi [...] $ egrep 'generated|gen_gui_data_CPPFLAGS' Makefile.in # Makefile.in generated by automake 1.9.6 from Makefile.am. gen_gui_data_CPPFLAGS = -DCODE_GENERATOR @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gen_gui_data_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gen_gui_data-gen_gui_data.o -MD -MP -MF "$(DEPDIR)/gen_gui_data-gen_gui_data.Tpo" -c -o gen_gui_data-gen_gui_data.o `test -f 'gen_gui_data.c' || echo '$(srcdir)/'`gen_gui_data.c; \ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gen_gui_data_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gen_gui_data-gen_gui_data.o `test -f 'gen_gui_data.c' || echo '$(srcdir)/'`gen_gui_data.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gen_gui_data_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gen_gui_data-gen_gui_data.obj -MD -MP -MF "$(DEPDIR)/gen_gui_data-gen_gui_data.Tpo" -c -o gen_gui_data-gen_gui_data.obj `if test -f 'gen_gui_data.c'; then $(CYGPATH_W) 'gen_gui_data.c'; else $(CYGPATH_W) '$(srcdir)/gen_gui_data.c'; fi`; \ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gen_gui_data_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gen_gui_data-gen_gui_data.obj `if test -f 'gen_gui_data.c'; then $(CYGPATH_W) 'gen_gui_data.c'; else $(CYGPATH_W) '$(srcdir)/gen_gui_data.c'; fi`