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

Re: Problem with implicit rule for .o files and overriding of CXXFLAGS.



В Wed, 25 Jun 2008 13:24:17 +0900, Charles Plessy написа:

[ I had not looked at the `proda' package, sorry. ]
 
> OTHERFLAGS = -DVERSION="\"1.00\""
> CXXFLAGS = -g -W -Wall -pedantic $(OTHERFLAGS)

Use CPPFLAGS for this -- of course the recipes should be properly written 
in order to have some effect.

> The Debian build system overrides CXXFLAGS and $(OTHERFLAGS) is never
> passed to the compiler.

Yes and no, see '(make)Environment'.

If you define (or inherit from the environment) CXXFLAGS in debian/rules, 
and you do in the build target `$(MAKE) CXXFLAGS="$(CXXFLAGS)"', and 
upstream's makefile defines it to something different, then of course 
your CXXFLAGS will be used as it is passed to all sub-`make' invocations 
and all assignments in the upstream makefile(s) are ignored.

> authoritative documentation that explains that CXXFLAGS (and others)
> should be expected to be changed to local values by the user.

The Automake manual, or the GNU Coding Standards.  CFLAGS, CXXFLAGS, 
CPPFLAGS, LDFLAGS, etc. are "user" variables so any build system that 
does not respect the user's choice is kind of buggy.  At least for 
packages using the GNU build system.  IOW, you should be able to define 
all of these variables from within debian/rules and upstream's build 
system should obey your choice.

See '(automake-1.10)Flag Variables Ordering'.

> My problem is that I do not know the contents of the implicit rule
> building the .o files from the .h files,

You can use `make -p' and examine make's internal database.

> nor how I can tell to make to
> add $(OTHERFLAGS) to this implicite rule.

You cannot if the built-in make rules are used, since make doesn't know 
anything about that variable and it's not in the recipe.

But you can do ut with CPPFLAGS.  Something like this:

CPPFLAGS = -DVERSION="\"1.00\""
CXXFLAGS = -g -W -Wall -pedantic

proda : $(OBJECTS)
        $(CXX) $(CXXFLAGS) $(CPPFLAGS) -lm $(OBJECTS) -o proda

Even if you don't put $(CPPFLAGS) in the recipe, all the individual 
objects will be built with -DVERSION=..., which is probably what you want.

Hope that helps.


Reply to: