bug-automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14396: AM_CPPFLAGS not respected when using subdir-objects


From: Stefano Lattarini
Subject: bug#14396: AM_CPPFLAGS not respected when using subdir-objects
Date: Tue, 14 May 2013 09:31:11 +0200

tags 14396 notabug
close 14396
thanks

On 05/14/2013 05:07 AM, Mike Frysinger wrote:
> i've been playing around with subdir-objects and noticed that sub-compiles 
> don't respect AM_CPPFLAGS :(
>
The failure you're seeing is due to a user error.  See below.  I'm thus
closing this report as "not a bug".  We are however free to continue our
discussion here anyway (it should still be registered in the tracker).

> happens with automake 1.13.1 and the latest 
> 1.13.1d test release.  also using autoconf-2.69 if it matters.
> 
> $ cat configure.ac
> AC_INIT([pkg], [0])
> AM_INIT_AUTOMAKE([subdir-objects])
> AC_PROG_CC
> AM_PROG_CC_C_O
> AC_CONFIG_FILES([Makefile])
> AC_OUTPUT
> 
> $ cat Makefile.am
> noinst_PROGRAMS =
> AM_CPPFLAGS = -DXXX
>
OK, but ...

> include src/Makemodule.am
> 
> $ cat src/Makemodule.am
> noinst_PROGRAMS += src/x
> src_x_SOURCES = src/x.c
> src_x_CPPFLAGS = -DYYY
> 
>
... here you define per-program CPPFLAGS for src/x, and that
*completely overrides* global AM_CPPFLAGS.  That is by design.
If you want the flags in AM_CPPFLAGS to be used also when
compiling the objects of src/x, you need to add those flags
*explicitly* to src_x_CPPFLAGS:

  src_x_CPPFLAGS = $(AM_CPPFLAGS) -DYYY

> $ cat src/x.c
> main(){}
> 
> $ touch NEWS README AUTHORS ChangeLog COPYING
> $ autoreconf -f -i
> $ ./configure
> $ make
> gcc -DPACKAGE_NAME=\"pkg\" -DPACKAGE_TARNAME=\"pkg\" -DPACKAGE_VERSION=\"0\" -
> DPACKAGE_STRING=\"pkg\ 0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -
> DPACKAGE=\"pkg\" -DVERSION=\"0\" -I.  -DYYY   -g -O2 -MT src/src_x-x.o -MD 
> -MP 
> -MF src/.deps/src_x-x.Tpo -c -o src/src_x-x.o `test -f 'src/x.c' || echo 
> './'`src/x.c
> 
> there is no -DXXX there :(.  i know the var is set correctly because if i 
> manually add $(AM_CPPFLAGS) to the src_x_CPPFLAGS line, it shows up.
>
And that is what you're supposed to do :-)  If something in the documentation
doesn't make that clear, feel free to provide a patch to improve the situation.

> reading the generated Makefile i see:
> COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
>       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
> and this is good.  but that var isn't used to compile things.  instead, 
> there's this rule:
>       $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
> $(src_x_CPPFLAGS) 
> $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_x-x.o -MD -MP -MF 
> src/$(DEPDIR)/src_x-x.Tpo -c -o src/src_x-x.o `test -f 'src/x.c' || echo 
> '$(srcdir)/'`src/x.c
> 
> and indeed, there's no AM_CPPFLAGS in there.
>
Again, that is by design.

>  all the other good stuff (including the deprecated vars) though ...
> -mike

HTH,
  Stefano





reply via email to

[Prev in Thread] Current Thread [Next in Thread]