diff options
author | Lucas De Marchi <lucas.de.marchi@gmail.com> | 2012-05-09 09:06:17 -0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-05-16 11:18:31 +0300 |
commit | afb0ab3a451a2ae15759e62485d71aca76bc873c (patch) | |
tree | 307fd786d76db4a5a976741bd250aaae51af8275 /acinclude.m4 | |
parent | 99fe325ad2b0a8f3247e522820f9aa4c7e9663b0 (diff) | |
download | bluez-afb0ab3a451a2ae15759e62485d71aca76bc873c.tar.gz |
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
Diffstat (limited to 'acinclude.m4')
-rw-r--r-- | acinclude.m4 | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index dcf9a482d..6505ad3a3 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -11,19 +11,19 @@ AC_DEFUN([AC_PROG_CC_PIE], [ ]) AC_DEFUN([COMPILER_FLAGS], [ - if (test "${CFLAGS}" = ""); then - CFLAGS="-Wall -O2" - fi + with_cflags="" if (test "$USE_MAINTAINER_MODE" = "yes"); then - CFLAGS="$CFLAGS -Werror -Wextra" - CFLAGS="$CFLAGS -Wno-unused-parameter" - CFLAGS="$CFLAGS -Wno-missing-field-initializers" - CFLAGS="$CFLAGS -Wdeclaration-after-statement" - CFLAGS="$CFLAGS -Wmissing-declarations" - CFLAGS="$CFLAGS -Wredundant-decls" - CFLAGS="$CFLAGS -Wcast-align" - CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED" + with_cflags="$with_cflags -Wall -Werror -Wextra" + with_cflags="$with_cflags -Wno-unused-parameter" + with_cflags="$with_cflags -Wno-missing-field-initializers" + with_cflags="$with_cflags -Wdeclaration-after-statement" + with_cflags="$with_cflags -Wmissing-declarations" + with_cflags="$with_cflags -Wredundant-decls" + with_cflags="$with_cflags -Wcast-align" + with_cflags="$with_cflags -DG_DISABLE_DEPRECATED" fi + + AC_SUBST([WARNING_CFLAGS], $with_cflags) ]) AC_DEFUN([AC_FUNC_PPOLL], [ @@ -339,23 +339,29 @@ AC_DEFUN([AC_ARG_BLUEZ], [ gatt_enable=${enableval} ]) + misc_cflags="" + misc_ldflags="" + if (test "${fortify_enable}" = "yes"); then - CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2" + misc_cflags="$misc_cflags -D_FORTIFY_SOURCE=2" fi if (test "${pie_enable}" = "yes" && test "${ac_cv_prog_cc_pie}" = "yes"); then - CFLAGS="$CFLAGS -fPIC" - LDFLAGS="$LDFLAGS -pie" + misc_cflags="$misc_cflags -fPIC" + misc_ldflags="$misc_ldflags -pie" fi if (test "${debug_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then - CFLAGS="$CFLAGS -g" + misc_cflags="$misc_cflags -g" fi if (test "${optimization_enable}" = "no"); then - CFLAGS="$CFLAGS -O0" + misc_cflags="$misc_cflags -O0" fi + AC_SUBST([MISC_CFLAGS], $misc_cflags) + AC_SUBST([MISC_LDLAGS], $misc_ldlags) + if (test "${usb_enable}" = "yes" && test "${usb_found}" = "yes"); then AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 if you have USB library.]) fi |