Target-specific CFLAGS

2004-02-24 Thread Drummonds, Scott B
Hi, everyone,

A couple of weeks back I posted my problems with getting an ancient
version of Automake to build two libraries.  Each was to use the same
source but one should have it's objects compiled with -DFEATURE.  I
attempted to use the following setup:

quote
noinst_LIBRARIES = normal.a normal-feature.a

normal_a_SOURCES = [bunch of files]
normal_feature_a_SOURCES = $(normal_a_SOURCES)
normal_feature_a_CFLAGS = -DFEATURE
/quote

While this didn't work on my old version of Automake, I was told that
upgrading to the most recent version (1.8.2) would fix this problem.  It
doesn't.  The second library is compiled using the object files created
for the first library.  In other words, -DFEATURE is never specified
in the compilation of the objects needed for the extra library and I get
two copies of the same library (with different names).

Where have I gone wrong?

Thanks,
Scott




RE: Target-specific CFLAGS

2004-02-24 Thread Drummonds, Scott B
From: [EMAIL PROTECTED] 
 quote
 noinst_LIBRARIES = normal.a normal-feature.a
 
 normal_a_SOURCES = [bunch of files]
 normal_feature_a_SOURCES = $(normal_a_SOURCES)
 normal_feature_a_CFLAGS = -DFEATURE
 /quote
...
 Where have I gone wrong?

Of course, when my source files are C++ files the _CFLAGS extension does
nothing.  Changing this to _CPPFLAGS fixed the problem.  Duh.

Sorry for the mails, all.

Scott





Re: Target-specific CFLAGS

2004-02-24 Thread Ben Pfaff
Drummonds, Scott B [EMAIL PROTECTED] writes:

 From: [EMAIL PROTECTED] 
 quote
 noinst_LIBRARIES = normal.a normal-feature.a
 
 normal_a_SOURCES = [bunch of files]
 normal_feature_a_SOURCES = $(normal_a_SOURCES)
 normal_feature_a_CFLAGS = -DFEATURE
 /quote
 ...
 Where have I gone wrong?

 Of course, when my source files are C++ files the _CFLAGS extension does
 nothing.  Changing this to _CPPFLAGS fixed the problem.  Duh.

You know that CPPFLAGS is for the C preprocessor and CXXFLAGS is
for the C++ compiler, right?
-- 
Ben Pfaff 
email: [EMAIL PROTECTED]
web: http://benpfaff.org





RE: Target-specific CFLAGS

2004-02-24 Thread Drummonds, Scott B
I didn't.  But I do now.

Thanks,
Scott

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] 
 On Behalf Of Ben Pfaff
 Sent: Tuesday, February 24, 2004 1:43 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Target-specific CFLAGS
 
 
 Drummonds, Scott B [EMAIL PROTECTED] writes:
 
  From: [EMAIL PROTECTED] 
  quote
  noinst_LIBRARIES = normal.a normal-feature.a
  
  normal_a_SOURCES = [bunch of files]
  normal_feature_a_SOURCES = $(normal_a_SOURCES)
  normal_feature_a_CFLAGS = -DFEATURE
  /quote
  ...
  Where have I gone wrong?
 
  Of course, when my source files are C++ files the _CFLAGS 
 extension does
  nothing.  Changing this to _CPPFLAGS fixed the problem.  Duh.
 
 You know that CPPFLAGS is for the C preprocessor and CXXFLAGS is
 for the C++ compiler, right?
 -- 
 Ben Pfaff 
 email: [EMAIL PROTECTED]
 web: http://benpfaff.org
 
 
 
 




Re: Target-specific CFLAGS

2004-02-24 Thread Bob Friesenhahn
On Tue, 24 Feb 2004, Ben Pfaff wrote:
 
  Of course, when my source files are C++ files the _CFLAGS extension does
  nothing.  Changing this to _CPPFLAGS fixed the problem.  Duh.

 You know that CPPFLAGS is for the C preprocessor and CXXFLAGS is
 for the C++ compiler, right?

This distinction is not entirely correct since CPPFLAGS is normally
supplied to the C++ compiler as well.  CFLAGS is for the C compiler
and CXXFLAGS is for the C++ compiler.

Bob
==
Bob Friesenhahn
[EMAIL PROTECTED]
http://www.simplesystems.org/users/bfriesen





Re: Target-specific CFLAGS

2004-02-24 Thread Ben Pfaff
Bob Friesenhahn [EMAIL PROTECTED] writes:

 On Tue, 24 Feb 2004, Ben Pfaff wrote:
 
  Of course, when my source files are C++ files the _CFLAGS extension does
  nothing.  Changing this to _CPPFLAGS fixed the problem.  Duh.

 You know that CPPFLAGS is for the C preprocessor and CXXFLAGS is
 for the C++ compiler, right?

 This distinction is not entirely correct since CPPFLAGS is normally
 supplied to the C++ compiler as well.  CFLAGS is for the C compiler
 and CXXFLAGS is for the C++ compiler.

Well, yes: C++ uses the C preprocessor.
-- 
Ben Pfaff 
email: [EMAIL PROTECTED]
web: http://benpfaff.org





Re: Target-specific CFLAGS

2004-02-24 Thread Bob Friesenhahn
On Tue, 24 Feb 2004, Ben Pfaff wrote:

 Bob Friesenhahn [EMAIL PROTECTED] writes:

  On Tue, 24 Feb 2004, Ben Pfaff wrote:
  
   Of course, when my source files are C++ files the _CFLAGS extension does
   nothing.  Changing this to _CPPFLAGS fixed the problem.  Duh.
 
  You know that CPPFLAGS is for the C preprocessor and CXXFLAGS is
  for the C++ compiler, right?
 
  This distinction is not entirely correct since CPPFLAGS is normally
  supplied to the C++ compiler as well.  CFLAGS is for the C compiler
  and CXXFLAGS is for the C++ compiler.

 Well, yes: C++ uses the C preprocessor.

Which is not really a great assumption since C++ is a different
language and the C++ compiler vendor may not be the same as the C
compiler vendor.  The behavior of the C++ preprocessing may behave
differently.  Autoconf and Automake make a lot of assumptions when it
comes to C++.  Luckily the assumptions are correct more often than
not.

Bob
==
Bob Friesenhahn
[EMAIL PROTECTED]
http://www.simplesystems.org/users/bfriesen





Bug with target specific CFLAGS

2001-02-14 Thread Richard Boulton

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"



Re: Bug with target specific CFLAGS

2001-02-14 Thread Tom Tromey

 "Richard" == Richard Boulton [EMAIL PROTECTED] writes:

Richard Makefile:1344: warning: overriding commands for target
Richard `libgst_la-gstparse.lo'
Richard Makefile:966: warning: ignoring old commands for target
Richard `libgst_la-gstparse.lo'

Thanks for the report.

Richard I've got a minimal example, in the form of a test case, which
Richard I attach to this message.

Thanks.  I'm checking this in.

Richard PPS: It would also be helpful if we could add specific flags
Richard _after_ the standard CFLAGS - the current implementation adds
Richard them before.  We need the -O2 to be at the end of the flags
Richard line, and I have therefore to clear the default CFLAGS and
Richard set specific ones for both of my targets, viz:

For some reason I thought the intent was to let the per-file CFLAGS
override the default CFLAGS.  But maybe I misremember.

Ok, I remember now.  CFLAGS is a *user* variable so we have to support
it everywhere.  AM_CFLAGS is what you should use via configure or
whatever.  AM_CFLAGS isn't passed to a compilation that has per-target
CFLAGS.

Tom