Skip to contentSkip to conversation

Fix: Don't override user variables within the build system

PATCH Mathieu Desnoyers 1 participant 1 message May 8, 2017 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Mathieu Desnoyers

author Applied
#1 lore raw

merged, thanks!

Mathieu

Quoted 183 lines · ----- On May 8, 2017, at 4:05 PM, Michael Jeanson [email protected] wrote:

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

---

Makefile.am                             |  6 +++---
configure.ac                            | 12 ++++++------
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, 16 insertions(+), 19 deletions(-)
Makefile.am +0 -0
index 8e25fd9..529a99a 100644
@@ -11,7 +11,7 @@ endif

if USE_CYGWIN
AM_LDFLAGS+=-no-undefined
endif

Makefile.am +1 -1
-AM_CFLAGS=-Wall
+AM_CFLAGS+=-Wall

SUBDIRS = . doc tests

Makefile.am +0 -0
@@ -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)

Makefile.am +1 -1
-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)

Makefile.am +1 -1
-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)

configure.ac +2 -3
index eebed56..e56eb06 100644
@@ -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

configure.ac +0 -0
@@ -162,7 +161,7 @@ AS_IF([test "x$SUBARCHTYPE" = xx86compat],[
 ])
 

AS_IF([test "$host_cpu" = "armv7l"],[

configure.ac +1 -1
-	CFLAGS="$CFLAGS -mcpu=cortex-a9 -mtune=cortex-a9 -O1"
+	AM_CFLAGS="$AM_CFLAGS -mcpu=cortex-a9 -mtune=cortex-a9 -O1"

])

# ARM-specific checks

configure.ac +2 -2
@@ -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"],
configure.ac +0 -0
@@ -369,6 +368,7 @@ AC_CHECK_FUNCS([sched_setaffinity],[
 ])
 

CFLAGS=$saved_CFLAGS
+AC_SUBST(AM_CFLAGS)

AC_CONFIG_LINKS([
urcu/arch.h:$ARCHSRC

doc/examples/Makefile.am +0 -2
index 6828eee..8dae95b 100644
@@ -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;

doc/examples/Makefile.am +1 -0
+	$(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; \
doc/examples/Makefile.examples.template +3 -6
index 6dd2bac..4b2378e 100644
@@ -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

tests/benchmark/Makefile.am +0 -0
index 2326721..2b2e6a7 100644
@@ -1,7 +1,7 @@

if !LIBC_INCLUDES_PTHREAD
AM_LDFLAGS=-lpthread
endif

tests/benchmark/Makefile.am +1 -1
-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 \
tests/regression/Makefile.am +0 -0
index 2376edc..c330db2 100644
@@ -1,7 +1,7 @@

if !LIBC_INCLUDES_PTHREAD
AM_LDFLAGS=-lpthread
endif

tests/regression/Makefile.am +1 -3
-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

tests/unit/Makefile.am +0 -0
index 08a3cba..9bebeab 100644
@@ -1,7 +1,7 @@

if !LIBC_INCLUDES_PTHREAD
AM_LDFLAGS=-lpthread
endif

tests/unit/Makefile.am +1 -3
-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

--
2.7.4

Signature · 7 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev