[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:

> BDB_HOME = /opt/csw/bdb48
> BDB_INC = $(BDB_HOME)/include
> BDB_LIB = $(BDB_HOME)/lib

Usually you set the preprocessor flags
but CFLAGS and CXXFLAGS is also fine.

LINKER_FLAGS is essentially ok as it propagates to LDFLAGS and LD_OPTIONS:
However, it does not append 64 bit subdirectory and hence will fail if 64 bit
build is requested.

> Or should I set LDFLAGS directly?

Setting LDFLAGS overwrites all flags regardless of the +=. If you want to add
something please always use

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