Fix: Don't override user variables within the build system
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 2 May 2017 21:40:45 +0000 (17:40 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 8 May 2017 17:52:33 +0000 (13:52 -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

Fixes #1095

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

index ba7538dbfca5cf33d4ae1b95deb2963f8a9ef08f..5aa343353ae806de28c22b024a6961fd2e73ab88 100644 (file)
@@ -89,9 +89,6 @@ 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"
 
 # Checks for library functions.
 AC_FUNC_MMAP
@@ -168,7 +165,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
@@ -367,8 +364,10 @@ AC_CHECK_FUNCS([sched_setaffinity],[
        ])
 ])
 
-DEFAULT_INCLUDES="-include config.h"
-AC_SUBST(DEFAULT_INCLUDES)
+AM_CPPFLAGS="-include config.h"
+AC_SUBST(AM_CPPFLAGS)
+
+AC_SUBST(AM_CFLAGS)
 
 AC_CONFIG_LINKS([
        include/urcu/arch.h:$ARCHSRC
index 88f8968d6cece535391f4106ecba4ea5300cf097..734582a0852af209af94ed4045714500df11a12a 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)/include/ -I$$rel_src_subdir/$(top_srcdir)/src/ -I$$rel_build_subdir$(top_builddir)/include/ -I$$rel_build_subdir$(top_builddir)/include/src/" AM_CFLAGS='$(CFLAGS)' AM_LDFLAGS='$(LDFLAGS) -L../../../src/.libs/ -Wl,-rpath "$(PWD)/../../src/.libs/"' $(AM_MAKEFLAGS) all;
+       $(MAKE) -f dist-files/Makefile CC="$(CC)" CPPFLAGS="$(CPPLAGS)" AM_CPPFLAGS="$(AM_CPPFLAGS) -I"$${rel_src_subdir}/$(top_srcdir)/include/" -I"$${rel_src_subdir}/$(top_srcdir)/src/" -I"$${rel_build_subdir}$(top_builddir)/include/" -I"$${rel_build_subdir}$(top_builddir)/include/src/"" CFLAGS="$(CFLAGS)" AM_CFLAGS="$(AM_CFLAGS) $(PTHREAD_CFLAGS)" LDFLAGS="$(LDFLAGS)" AM_LDFLAGS="$(AM_LDFLAGS) -L../../../src/.libs/ -Wl,-rpath "$(PWD)/../../src/.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 6a2fd7a54a7646e8e496b1280c09d03766311f1b..776c2a3812fe04c33e102b435452332b23496e99 100644 (file)
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src
+AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src
 
 #Add the -version-info directly here since we are only building
 # library that use the version-info
@@ -6,7 +6,7 @@ AM_LDFLAGS=-version-info $(URCU_LIBRARY_VERSION)
 if USE_CYGWIN
 AM_LDFLAGS+=-no-undefined
 endif
-AM_CFLAGS=-Wall
+AM_CFLAGS+=-Wall
 
 include_HEADERS = urcu.h urcu-bp.h urcu-call-rcu.h urcu-defer.h \
                urcu-pointer.h urcu-qsbr.h urcu-flavor.h
@@ -44,11 +44,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 0c3fd77d04481a965a3c58fdde296f793dcec986..9899f547f05c25ab7c034e7671551f0efcb2794e 100644 (file)
@@ -1,4 +1,4 @@
-AM_CFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/common -g
+AM_CFLAGS += $(PTHREAD_CFLAGS) -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/common -g
 
 SCRIPT_LIST = common.sh \
        run.sh \
index d919ca19af591d869a092d51f56dcd35664e8aa5..5935098f1d8b9dfb6b21fa5bc9ed1a12209f884d 100644 (file)
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src
+AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src
 
 noinst_HEADERS = cpuset.h thread-id.h
 
index aa7a00c2171262fe324c1a4169f9b605018225d0..328dcf423be1e663d746c7ce45d423da4edecfb4 100644 (file)
@@ -1,4 +1,4 @@
-AM_CFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils -I$(top_srcdir)/tests/common -g
+AM_CFLAGS += $(PTHREAD_CFLAGS) -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils -I$(top_srcdir)/tests/common -g
 
 SCRIPT_LIST = run.sh
 
index 54eb9f36e99015024872a662afd1da1b7a549b7e..ce9d1b23069964a735a5092e76e71435e0247b89 100644 (file)
@@ -1,4 +1,4 @@
-AM_CFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils -I$(top_srcdir)/tests/common -g
+AM_CFLAGS += $(PTHREAD_CFLAGS) -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils -I$(top_srcdir)/tests/common -g
 
 SCRIPT_LIST = test_loop run.sh unit_tests
 
index 440ac382a8412e738971869bf5dfdc0ef06f98d9..31d7913e2d4864b2f04443e6afaf613e288192ca 100644 (file)
@@ -1,4 +1,4 @@
-AM_CFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src
+AM_CFLAGS += -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src
 
 noinst_LIBRARIES = libtap.a
 libtap_a_SOURCES = tap.c tap.h
This page took 0.030036 seconds and 4 git commands to generate.