OSDN Git Service

build: Do not set CFLAGS/LDFLAGS directly
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 9 May 2012 12:06:17 +0000 (09:06 -0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Wed, 16 May 2012 08:18:31 +0000 (11:18 +0300)
commitafb0ab3a451a2ae15759e62485d71aca76bc873c
tree307fd786d76db4a5a976741bd250aaae51af8275
parent99fe325ad2b0a8f3247e522820f9aa4c7e9663b0
build: Do not set CFLAGS/LDFLAGS directly

Set a separate variable for adding warning flags, optimization, etc.
Build systems are not supposed to change CFLAGS and LDFLAGS, these are
user variables.

Doing so we guarantee CFLAGS and LDFLAGS from environment is appended
to the flags used during build. One useful use-case is to temporarily
disable -Werror when using --enable-maintainer-mode, without completely
loosing the warning flags and other parameters in CFLAGS (like -fPIC).

Without this patch, fiddling with CFLAGS/LDFLAGS after configure may
result in errors like below:

/usr/bin/ld: tools/rfcomm.o: relocation R_X86_64_32 against `.bss' can
not be used when making a shared object; recompile with -fPIC
tools/rfcomm.o: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[1]: *** [tools/rfcomm] Error 1
make: *** [all] Error 2

Reference: http://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html
Makefile.am
acinclude.m4