GNU bug report logs - #14396
AM_CPPFLAGS not respected when using subdir-objects

Previous Next

Package: automake;

Reported by: Mike Frysinger <vapier <at> gentoo.org>

Date: Tue, 14 May 2013 03:09:02 UTC

Severity: normal

Tags: notabug

Done: Stefano Lattarini <stefano.lattarini <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14396 in the body.
You can then email your comments to 14396 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-automake <at> gnu.org:
bug#14396; Package automake. (Tue, 14 May 2013 03:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mike Frysinger <vapier <at> gentoo.org>:
New bug report received and forwarded. Copy sent to bug-automake <at> gnu.org. (Tue, 14 May 2013 03:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mike Frysinger <vapier <at> gentoo.org>
To: bug-automake <at> gnu.org
Subject: AM_CPPFLAGS not respected when using subdir-objects
Date: Mon, 13 May 2013 23:07:42 -0400
[Message part 1 (text/plain, inline)]
i've been playing around with subdir-objects and noticed that sub-compiles 
don't respect AM_CPPFLAGS :(.  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
include src/Makemodule.am

$ cat src/Makemodule.am
noinst_PROGRAMS += src/x
src_x_SOURCES = src/x.c
src_x_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.

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.  all the other good stuff 
(including the deprecated vars) though ...
-mike
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-automake <at> gnu.org:
bug#14396; Package automake. (Tue, 14 May 2013 07:32:03 GMT) Full text and rfc822 format available.

Message #8 received at 14396 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Mike Frysinger <vapier <at> gentoo.org>
Cc: 14396 <at> debbugs.gnu.org
Subject: Re: 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




Added tag(s) notabug. Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 14 May 2013 07:32:04 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 14396 <at> debbugs.gnu.org and Mike Frysinger <vapier <at> gentoo.org> Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 14 May 2013 07:32:04 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 11 Jun 2013 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 15 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.