build-sys: don't set CFLAGS and LDFLAGS
These variables are supposed to be set by user. What we can do in
configure is to set another variable and AC_SUBST() it. Then in
Makefile.am we assign it to AM_{CFLAGS,LDFLAGS}. This way user can
always override their values, in configure or make phase.
Reference: http://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html
diff --git a/configure.ac b/configure.ac
index 72df628..21d7f22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,54 +113,56 @@
# Default CFLAGS and LDFLAGS
#####################################################################
-CC_CHECK_CFLAGS_APPEND([ \
- -pipe \
- -DANOTHER_BRICK_IN_THE \
- -Wall \
- -W \
- -Wextra \
- -Wno-inline \
- -Wvla \
- -Wundef \
- -Wformat=2 \
- -Wlogical-op \
- -Wsign-compare \
- -Wformat-security \
- -Wmissing-include-dirs \
- -Wformat-nonliteral \
- -Wold-style-definition \
- -Wpointer-arith \
- -Winit-self \
- -Wdeclaration-after-statement \
- -Wfloat-equal \
- -Wmissing-prototypes \
- -Wstrict-prototypes \
- -Wredundant-decls \
- -Wmissing-declarations \
- -Wmissing-noreturn \
- -Wshadow \
- -Wendif-labels \
- -Wstrict-aliasing=2 \
- -Wwrite-strings \
- -Wno-long-long \
- -Wno-overlength-strings \
- -Wno-unused-parameter \
- -Wno-missing-field-initializers \
- -Wno-unused-result \
- -Wnested-externs \
- -Wchar-subscripts \
- -Wtype-limits \
- -Wuninitialized \
- -fno-common \
- -fdiagnostics-show-option \
- -fvisibility=hidden \
- -ffunction-sections \
- -fdata-sections])
+CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
+ -pipe \
+ -DANOTHER_BRICK_IN_THE \
+ -Wall \
+ -W \
+ -Wextra \
+ -Wno-inline \
+ -Wvla \
+ -Wundef \
+ -Wformat=2 \
+ -Wlogical-op \
+ -Wsign-compare \
+ -Wformat-security \
+ -Wmissing-include-dirs \
+ -Wformat-nonliteral \
+ -Wold-style-definition \
+ -Wpointer-arith \
+ -Winit-self \
+ -Wdeclaration-after-statement \
+ -Wfloat-equal \
+ -Wmissing-prototypes \
+ -Wstrict-prototypes \
+ -Wredundant-decls \
+ -Wmissing-declarations \
+ -Wmissing-noreturn \
+ -Wshadow \
+ -Wendif-labels \
+ -Wstrict-aliasing=2 \
+ -Wwrite-strings \
+ -Wno-long-long \
+ -Wno-overlength-strings \
+ -Wno-unused-parameter \
+ -Wno-missing-field-initializers \
+ -Wno-unused-result \
+ -Wnested-externs \
+ -Wchar-subscripts \
+ -Wtype-limits \
+ -Wuninitialized \
+ -fno-common \
+ -fdiagnostics-show-option \
+ -fvisibility=hidden \
+ -ffunction-sections \
+ -fdata-sections])
+AC_SUBST([WARNINGFLAGS], $with_cflags)
-CC_CHECK_LDFLAGS_APPEND([ \
- -Wl,--as-needed \
- -Wl,--gc-sections])
+CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
+ -Wl,--as-needed \
+ -Wl,--gc-sections])
+AC_SUBST([GCLDFLAGS], $with_ldflags)
#####################################################################
# Generate files from *.in
@@ -191,8 +193,8 @@
bindir: ${bindir}
compiler: ${CC}
- cflags: ${CFLAGS}
- ldflags: ${LDFLAGS}
+ cflags: ${with_cflags} ${CFLAGS}
+ ldflags: ${with_ldflags} ${LDFLAGS}
tools: ${enable_tools}
logging: ${enable_logging}