[csw-maintainers] setting *FLAGS?
Dagobert Michelsen
dam at opencsw.org
Thu Apr 19 16:17:47 CEST 2012
Hi Daniel,
Am 19.04.2012 um 16:06 schrieb Daniel Pocock:
> I notice there are many ways people set CXXFLAGS, LDFLAGS, etc from
> within mgar Makefiles
>
> Let's say I want to use bdb, I notice several versions are available:
>
> daniel at login [login]:~/opencsw/resiprocate/trunk > ls -d /opt/csw/bdb*
> /opt/csw/bdb4
> /opt/csw/bdb42
> /opt/csw/bdb44
> /opt/csw/bdb47
> /opt/csw/bdb48
>
> Should I just do something like this?
The correct solution is
BDB_HOME = $(prefix)/bdb48
EXTRA_LIB = $(BDB_HOME)/lib
EXTRA_INC = $(BDB_HOME)/include
The main difference is that EXTRA_LIB propapages correctly to -L and -R
during LDFLAGS and LD_OPTIONS and additionally gets the 64 bit subdir
appended on 64 bit ISAs.
See here for an example:
https://sourceforge.net/apps/trac/gar/browser/csw/mgar/pkg/openldap/trunk/Makefile#L132
> BDB_HOME = /opt/csw/bdb48
> BDB_INC = $(BDB_HOME)/include
> BDB_LIB = $(BDB_HOME)/lib
>
> EXTRA_CFLAGS += -I$(BDB_INC)
> EXTRA_CXXFLAGS += -I$(BDB_INC)
> EXTRA_LINKER_FLAGS += -L$(BDB_LIB)
Usually you set the preprocessor flags
EXTRA_CPPFLAGS += -I$(BDB_INC)
but CFLAGS and CXXFLAGS is also fine.
LINKER_FLAGS is essentially ok as it propagates to LDFLAGS and LD_OPTIONS:
https://sourceforge.net/apps/trac/gar/browser/csw/mgar/gar/v2/gar.conf.mk#L693
However, it does not append 64 bit subdirectory and hence will fail if 64 bit
build is requested.
> Or should I set LDFLAGS directly?
>
> LDFLAGS += -L$(BDB_LIB)
Setting LDFLAGS overwrites all flags regardless of the +=. If you want to add
something please always use
EXTRA_LDFLAGS += -L$(BDB_LIB)
This is a general design principle of GAR: If you set <VAR> you overwrite it,
EXTRA_<VAR> adds the value to the default.
Best regards
-- Dago
--
"You don't become great by trying to be great, you become great by wanting to do something,
and then doing it so hard that you become great in the process." - xkcd #896
More information about the maintainers
mailing list