[lttng-dev] [PATCH lttng-ust] Pass the CC variable to the example Makefiles

Jérémie Galarneau jeremie.galarneau at efficios.com
Fri Jan 10 16:38:05 EST 2014


Cross-compilation fails when using the --host configure option
since the cross-compiler is not invoked by the hand-made Makefiles
in doc/examples.

The CC variable must be passed explicitly to ensure the host's
default compiler is not invoked.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau at efficios.com>
---
 doc/examples/Makefile.am               | 2 +-
 doc/examples/demo/Makefile             | 5 ++++-
 doc/examples/easy-ust/Makefile         | 5 ++++-
 doc/examples/gen-tp/Makefile           | 5 ++++-
 doc/examples/hello-static-lib/Makefile | 5 ++++-
 5 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index 725806d..d5d1682 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -54,7 +54,7 @@ all-local:
 		done; \
 	fi
 	for subdir in $(SUBDIRS_PROXY); do \
-		(cd $$subdir && $(MAKE) AM_CPPFLAGS="$(CPPFLAGS) -I../../../include/" AM_CFLAGS='$(CFLAGS)' AM_LDFLAGS='$(LDFLAGS) -L../../../liblttng-ust/.libs/ -Wl,-rpath="$(PWD)/../../liblttng-ust/.libs/"' LTTNG_GEN_TP_PATH="../../../tools/" $(AM_MAKEFLAGS) all && cd ..) || exit 1; \
+		(cd $$subdir && AM_CC="$(CC)" $(MAKE) AM_CPPFLAGS="$(CPPFLAGS) -I../../../include/" AM_CFLAGS='$(CFLAGS)' AM_LDFLAGS='$(LDFLAGS) -L../../../liblttng-ust/.libs/ -Wl,-rpath="$(PWD)/../../liblttng-ust/.libs/"' LTTNG_GEN_TP_PATH="../../../tools/" $(AM_MAKEFLAGS) all && cd ..) || exit 1; \
 	done
 	@if [ x"$(SUBDIRS_JUL)" != x"" ]; then \
 		for subdir in $(SUBDIRS_JUL); do \
diff --git a/doc/examples/demo/Makefile b/doc/examples/demo/Makefile
index 27e4146..9c847b1 100644
--- a/doc/examples/demo/Makefile
+++ b/doc/examples/demo/Makefile
@@ -14,7 +14,10 @@
 #
 # This makefile is purposefully kept simple to support GNU and BSD make.
 
-CC = gcc
+ifdef AM_CC
+	CC = $(AM_CC)
+endif
+
 LIBS = -ldl	# On Linux
 #LIBS = -lc	# On BSD
 LOCAL_CPPFLAGS += -I.
diff --git a/doc/examples/easy-ust/Makefile b/doc/examples/easy-ust/Makefile
index 966c474..723780f 100644
--- a/doc/examples/easy-ust/Makefile
+++ b/doc/examples/easy-ust/Makefile
@@ -16,7 +16,10 @@
 #
 # This makefile is purposefully kept simple to support GNU and BSD make.
 
-CC = gcc
+ifdef AM_CC
+	CC = $(AM_CC)
+endif
+
 LIBS = -ldl -llttng-ust		# On Linux
 #LIBS = -lc -llttng-ust		# On BSD
 LOCAL_CPPFLAGS += -I.
diff --git a/doc/examples/gen-tp/Makefile b/doc/examples/gen-tp/Makefile
index bc979d9..0fa757c 100644
--- a/doc/examples/gen-tp/Makefile
+++ b/doc/examples/gen-tp/Makefile
@@ -17,7 +17,9 @@
 #
 # This makefile is purposefully kept simple to support GNU and BSD make.
 
-CC = gcc
+ifdef AM_CC
+	CC = $(AM_CC)
+endif
 
 LIBS = -ldl -llttng-ust		#On Linux
 #LIBS = -lc -llttng-ust		#On BSD
@@ -43,6 +45,7 @@ sample.o: sample.c sample_tracepoint.h
 	CPPFLAGS="$(CPPFLAGS) $(AM_CPPFLAGS)" \
 	CFLAGS="$(CFLAGS) $(AM_CFLAGS)" \
 	LDFLAGS="$(LDFLAGS) $(AM_LDFLAGS)" \
+	CC=$(CC) \
 	$(LTTNG_GEN_TP_PATH)lttng-gen-tp -o $@ $<
 
 # The following rule can be used to generate all files instead of having one
diff --git a/doc/examples/hello-static-lib/Makefile b/doc/examples/hello-static-lib/Makefile
index 9a079ec..ec185c1 100644
--- a/doc/examples/hello-static-lib/Makefile
+++ b/doc/examples/hello-static-lib/Makefile
@@ -14,7 +14,10 @@
 #
 # This makefile is purposefully kept simple to support GNU and BSD make.
 
-CC = gcc
+ifdef AM_CC
+	CC = $(AM_CC)
+endif
+
 LOCAL_CPPFLAGS += -I.
 LIBS = -ldl -llttng-ust	# On Linux
 #LIBS = -lc -llttng-ust	# On BSD
-- 
1.8.5.2




More information about the lttng-dev mailing list