[lttng-dev] [PATCH urcu] Fix: Don't use CFLAGS in configure script

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Mon Apr 24 22:19:02 UTC 2017


----- On Apr 19, 2017, at 4:47 PM, Michael Jeanson mjeanson at efficios.com wrote:

> Instead use the appropriatly prefixed AM_CFLAGS as to not interfere when
> CFLAGS 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

This patch seems to work fine for a use case of:

./configure
make CFLAGS=-O3 V=1

but not for:

CFLAGS=-O3 ./configure
make V=1

In the latter case, all the subdirectories under doc/examples/ don't get
the -O3 (they still get a -O2 -g here).

Can you investigate ?

Thanks,

Mathieu

> 
> Fixes #1095
> 
> Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
> ---
> configure.ac                 | 7 +++----
> doc/examples/Makefile.am     | 2 +-
> src/Makefile.am              | 6 +++---
> tests/benchmark/Makefile.am  | 2 +-
> tests/regression/Makefile.am | 2 +-
> tests/unit/Makefile.am       | 2 +-
> tests/utils/Makefile.am      | 2 +-
> 7 files changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index dcbb61f..5f61bdb 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -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,6 +364,8 @@ AC_CHECK_FUNCS([sched_setaffinity],[
> DEFAULT_INCLUDES="-include config.h"
> AC_SUBST(DEFAULT_INCLUDES)
> 
> +AC_SUBST(AM_CFLAGS)
> +
> AC_CONFIG_LINKS([
> 	include/urcu/arch.h:$ARCHSRC
> 	include/urcu/uatomic.h:$UATOMICSRC
> diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
> index 88f8968..2340666 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)/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 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='$(AM_CFLAGS)
> $(PTHREAD_CFLAGS)' 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; \
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 6a2fd7a..4e68656 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -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)
> diff --git a/tests/benchmark/Makefile.am b/tests/benchmark/Makefile.am
> index 0c3fd77..9899f54 100644
> --- a/tests/benchmark/Makefile.am
> +++ b/tests/benchmark/Makefile.am
> @@ -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 \
> diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am
> index aa7a00c..328dcf4 100644
> --- a/tests/regression/Makefile.am
> +++ b/tests/regression/Makefile.am
> @@ -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
> 
> diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
> index 54eb9f3..ce9d1b2 100644
> --- a/tests/unit/Makefile.am
> +++ b/tests/unit/Makefile.am
> @@ -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
> 
> diff --git a/tests/utils/Makefile.am b/tests/utils/Makefile.am
> index 440ac38..31d7913 100644
> --- a/tests/utils/Makefile.am
> +++ b/tests/utils/Makefile.am
> @@ -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
> --
> 2.7.4

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


More information about the lttng-dev mailing list