Fix: Don't override user variables within the build system
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 8 May 2017 20:05:46 +0000 (16:05 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 8 May 2017 20:09:17 +0000 (16:09 -0400)
Instead use the appropriatly prefixed AM_* variables as to not interfere
when a user variable is passed to a make command. The proper use of flag
variables is documented at :

https://www.gnu.org/software/automake/manual/automake.html#Flag-Variables-Ordering

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Makefile.am
configure.ac
doc/examples/Makefile.am
doc/examples/Makefile.examples.template
tests/benchmark/Makefile.am
tests/regression/Makefile.am
tests/unit/Makefile.am

index 8e25fd966769a3cffc7313babb8d3dfb16e04818..529a99ab514def7ad0210ef1aeb68274e6d779b1 100644 (file)
@@ -11,7 +11,7 @@ endif
 if USE_CYGWIN
 AM_LDFLAGS+=-no-undefined
 endif
-AM_CFLAGS=-Wall
+AM_CFLAGS+=-Wall
 
 SUBDIRS = . doc tests
 
@@ -67,11 +67,11 @@ liburcu_qsbr_la_SOURCES = urcu-qsbr.c urcu-pointer.c $(COMPAT)
 liburcu_qsbr_la_LIBADD = liburcu-common.la
 
 liburcu_mb_la_SOURCES = urcu.c urcu-pointer.c $(COMPAT)
-liburcu_mb_la_CFLAGS = -DRCU_MB
+liburcu_mb_la_CFLAGS = -DRCU_MB $(AM_CFLAGS)
 liburcu_mb_la_LIBADD = liburcu-common.la
 
 liburcu_signal_la_SOURCES = urcu.c urcu-pointer.c $(COMPAT)
-liburcu_signal_la_CFLAGS = -DRCU_SIGNAL
+liburcu_signal_la_CFLAGS = -DRCU_SIGNAL $(AM_CFLAGS)
 liburcu_signal_la_LIBADD = liburcu-common.la
 
 liburcu_bp_la_SOURCES = urcu-bp.c urcu-pointer.c $(COMPAT)
index eebed56894e34a366a6cc55ed672158fc211064c..e56eb06e55d67b97f09bb44a7dbb349523a6cfd3 100644 (file)
@@ -80,9 +80,8 @@ AS_IF([test "x$ax_cv___attribute__" = "xyes"],
        [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])])
 
 AX_PTHREAD(,[AC_MSG_ERROR([Could not configure pthreads support])])
-LIBS="$PTHREAD_LIBS $LIBS"
-CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-CC="$PTHREAD_CC"
+
+AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
 
 # Checks for library functions.
 AC_FUNC_MMAP
@@ -162,7 +161,7 @@ AS_IF([test "x$SUBARCHTYPE" = xx86compat],[
 ])
 
 AS_IF([test "$host_cpu" = "armv7l"],[
-       CFLAGS="$CFLAGS -mcpu=cortex-a9 -mtune=cortex-a9 -O1"
+       AM_CFLAGS="$AM_CFLAGS -mcpu=cortex-a9 -mtune=cortex-a9 -O1"
 ])
 
 # ARM-specific checks
@@ -287,8 +286,8 @@ AS_IF([test "x$def_smp_support" = "xyes"], [AC_DEFINE([CONFIG_RCU_SMP], [1])])
 # Since we define _GNU_SOURCE in the sources, must do so too in the
 # autoconf tests, as defining _GNU_SOURCE or not exposes
 # sched_setaffinity bits differently.
-saved_CFLAGS=$CFLAGS
-CFLAGS="$CFLAGS -D_GNU_SOURCE"
+saved_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $AM_CFLAGS -D_GNU_SOURCE"
 
 AC_CHECK_TYPES([cpu_set_t],
        [have_cpu_set_t="yes"],
@@ -369,6 +368,7 @@ AC_CHECK_FUNCS([sched_setaffinity],[
 ])
 
 CFLAGS=$saved_CFLAGS
+AC_SUBST(AM_CFLAGS)
 
 AC_CONFIG_LINKS([
        urcu/arch.h:$ARCHSRC
index 6828eee1e9c2b96c38676fd49c9e7f8720633abc..8dae95b0c4e2a4d5cca1d4eb66d7c82a4b8fd522 100644 (file)
@@ -145,7 +145,7 @@ all-local:
                echo "Examples: relative top_builddir path $(top_builddir)"; \
                rel_build_subdir="../"; \
        fi; \
-       $(MAKE) -f dist-files/Makefile AM_CC="$(CC)" AM_CPPFLAGS="$(CPPFLAGS) -I$$rel_src_subdir/$(top_srcdir)/ -I$$rel_build_subdir$(top_builddir)/" AM_CFLAGS='$(CFLAGS)' AM_LDFLAGS='$(LDFLAGS) -L../../../.libs/ -Wl,-rpath "$(PWD)/../../.libs/"' $(AM_MAKEFLAGS) all;
+       $(MAKE) -f dist-files/Makefile CC="$(CC)" CPPFLAGS="$(CPPLAGS)" AM_CPPFLAGS="$(AM_CPPFLAGS) -I$$rel_src_subdir/$(top_srcdir)/ -I$$rel_build_subdir$(top_builddir)/" CFLAGS="$(CFLAGS)" AM_CFLAGS="$(AM_CFLAGS)" LDFLAGS="$(LDFLAGS)" AM_LDFLAGS='$(AM_LDFLAGS) -L../../../.libs/ -Wl,-rpath "$(PWD)/../../.libs/"' $(AM_MAKEFLAGS) all;
 
 clean-local:
        @$(MAKE) -f dist-files/Makefile $(AM_MAKEFLAGS) clean; \
index 6dd2baca623174da315f8b9d2a5b4064e302323a..4b2378ea7b01e9d5d13baa0d156961255360d7f4 100644 (file)
 #
 # This makefile is purposefully kept simple to support GNU and BSD make.
 
-ifdef AM_CC
-CC = $(AM_CC)
-endif
-CFLAGS = -g -O2 -Wall
+LOCAL_CFLAGS := -g -O2 -Wall
 
 all: $(BINARY)
 
 $(BINARY): $(OBJECTS)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \
+       $(CC) $(LOCAL_CFLAGS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
                -o $@ $(OBJECTS) $(LIBS)
 
 $(OBJECTS): $(SOURCES) $(DEPS)
-       $(CC) $(CPPFLAGS) $(CFLAGS) $(AM_CPPFLAGS) $(AM_CFLAGS) \
+       $(CC) $(LOCAL_CFLAGS) $(AM_CFLAGS) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) \
                -c -o $@ $(SOURCES)
 
 .PHONY: clean
index 2326721ac4577aae8420da955d147b19363fb2ad..2b2e6a746ebbaa3a6d54a5687cc3e076ef9328ad 100644 (file)
@@ -1,7 +1,7 @@
 if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS=-lpthread
 endif
-AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
+AM_CFLAGS+=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
 
 SCRIPT_LIST = common.sh \
        run.sh \
index 2376edc847ed595fe44810b4b1bbf356feeef92a..c330db228274ee674e63deb803cb220393818f30 100644 (file)
@@ -1,7 +1,7 @@
 if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS=-lpthread
 endif
-AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/utils -I$(top_srcdir)/tests/common -g
+AM_CFLAGS+=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/utils -I$(top_srcdir)/tests/common -g
 
 SCRIPT_LIST = run.sh
 
index 08a3cba6f40c03d92e49b4e13e91101b52ee2e5f..9bebeabe09b7bd0353fd131f5ff40cb91d5b9e94 100644 (file)
@@ -1,7 +1,7 @@
 if !LIBC_INCLUDES_PTHREAD
 AM_LDFLAGS=-lpthread
 endif
-AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/utils -I$(top_srcdir)/tests/common -g
+AM_CFLAGS+=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/utils -I$(top_srcdir)/tests/common -g
 
 SCRIPT_LIST = test_loop run.sh unit_tests
 
This page took 0.030657 seconds and 4 git commands to generate.