[lttng-dev] [PATCH urcu stable-0.8 v2] Fix: Don't override user variables within the build system

Michael Jeanson mjeanson at efficios.com
Mon May 8 20:07:54 UTC 2017


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 at efficios.com>
---
 Makefile.am                             | 6 +++---
 configure.ac                            | 7 ++++---
 doc/examples/Makefile.am                | 2 +-
 doc/examples/Makefile.examples.template | 9 +++------
 tests/benchmark/Makefile.am             | 2 +-
 tests/regression/Makefile.am            | 2 +-
 tests/unit/Makefile.am                  | 2 +-
 7 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 2c971d7..5901732 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ AM_CPPFLAGS = -I$(top_builddir)/urcu
 #Add the -version-info directly here since we are only building
 # library that use the version-info
 AM_LDFLAGS=-lpthread -version-info $(URCU_LIBRARY_VERSION)
-AM_CFLAGS=-Wall
+AM_CFLAGS+=-Wall
 
 SUBDIRS = . doc tests
 
@@ -60,11 +60,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)
diff --git a/configure.ac b/configure.ac
index 1f41cf3..1634962 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,7 +97,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
@@ -205,8 +205,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"],
@@ -287,6 +287,7 @@ AC_CHECK_FUNCS([sched_setaffinity],[
 ])
 
 CFLAGS=$saved_CFLAGS
+AC_SUBST(AM_CFLAGS)
 
 AC_CONFIG_LINKS([
 	urcu/arch.h:$ARCHSRC
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index 84ed049..fe03668 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -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; \
diff --git a/doc/examples/Makefile.examples.template b/doc/examples/Makefile.examples.template
index 6dd2bac..4b2378e 100644
--- a/doc/examples/Makefile.examples.template
+++ b/doc/examples/Makefile.examples.template
@@ -11,19 +11,16 @@
 #
 # 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
diff --git a/tests/benchmark/Makefile.am b/tests/benchmark/Makefile.am
index 88416ee..2a6afe1 100644
--- a/tests/benchmark/Makefile.am
+++ b/tests/benchmark/Makefile.am
@@ -1,5 +1,5 @@
 AM_LDFLAGS=-lpthread
-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 \
 	runall.sh \
diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am
index f81836f..4b09581 100644
--- a/tests/regression/Makefile.am
+++ b/tests/regression/Makefile.am
@@ -1,5 +1,5 @@
 AM_LDFLAGS=-lpthread
-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
 
 noinst_PROGRAMS = test_urcu_fork \
 	rcutorture_urcu \
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index 17ae312..dde86f9 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -1,5 +1,5 @@
 AM_LDFLAGS=-lpthread
-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
 
 noinst_PROGRAMS = test_uatomic \
 	test_urcu_multiflavor \
-- 
2.7.4



More information about the lttng-dev mailing list