[lttng-dev] [PATCH lttng-ust v2] Move include directive from CFLAGS to LOCAL_CPPFLAGS in examples' Makefiles
Jérémie Galarneau
jeremie.galarneau at efficios.com
Tue May 28 18:19:18 EDT 2013
The use of LOCAL_* flags and override directives ensures that the build
succeeds even if the user explicitly overrides CFLAGS/CPPFLAGS/LDFLAGS.
Fixes #537
Signed-off-by: Jérémie Galarneau <jeremie.galarneau at efficios.com>
---
doc/examples/demo/Makefile | 14 +++++++-------
doc/examples/easy-ust/Makefile | 10 +++++-----
doc/examples/hello-static-lib/Makefile | 10 +++++-----
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/doc/examples/demo/Makefile b/doc/examples/demo/Makefile
index bbc8ccb..27ca92b 100644
--- a/doc/examples/demo/Makefile
+++ b/doc/examples/demo/Makefile
@@ -15,14 +15,14 @@
CC = gcc
LIBS = -ldl # On Linux
#LIBS = -lc # On BSD
-CFLAGS += -I.
+LOCAL_CPPFLAGS += -I.
# Only necessary when building from the source tree and lttng-ust is not
# installed
ifdef BUILD_EXAMPLES_FROM_TREE
-CFLAGS += -I../../../include/
+LOCAL_CPPFLAGS += -I../../../include/
LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/
-LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)'
+override LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)'
# Third-party Makefiles have to define these targets to integrate with an
# automake project
@@ -37,22 +37,22 @@ endif
all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so
tp.o: tp.c ust_tests_demo.h
- $(CC) $(CPPFLAGS) $(CFLAGS) -fpic -c -o $@ $<
+ $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(CFLAGS) -fpic -c -o $@ $<
tp2.o: tp2.c ust_tests_demo2.h
- $(CC) $(CPPFLAGS) $(CFLAGS) -fpic -c -o $@ $<
+ $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(CFLAGS) -fpic -c -o $@ $<
lttng-ust-provider-ust-tests-demo.so: tp.o tp2.o
$(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $^
tp3.o: tp3.c ust_tests_demo3.h
- $(CC) $(CPPFLAGS) $(CFLAGS) -fpic -c -o $@ $<
+ $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(CFLAGS) -fpic -c -o $@ $<
lttng-ust-provider-ust-tests-demo3.so: tp3.o
$(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $^
demo.o: demo.c
- $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
demo: demo.o
$(CC) -o $@ $^ $(LIBS)
diff --git a/doc/examples/easy-ust/Makefile b/doc/examples/easy-ust/Makefile
index e20e53a..e3546e1 100644
--- a/doc/examples/easy-ust/Makefile
+++ b/doc/examples/easy-ust/Makefile
@@ -17,14 +17,14 @@
CC = gcc
LIBS = -ldl -llttng-ust # On Linux
#LIBS = -lc -llttng-ust # On BSD
-CFLAGS += -I.
+LOCAL_CPPFLAGS += -I.
# Only necessary when building from the source tree and lttng-ust is not
# installed
ifdef BUILD_EXAMPLES_FROM_TREE
-CFLAGS += -I../../../include/
+LOCAL_CPPFLAGS += -I../../../include/
LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/
-LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)'
+override LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)'
# Third-party Makefiles have to define these targets to integrate with an
# automake project
@@ -42,10 +42,10 @@ sample: sample.o tp.o
$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
sample.o: sample.c sample_component_provider.h
- $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
tp.o: tp.c sample_component_provider.h
- $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
html: sample_component_provider.html sample.html tp.html
diff --git a/doc/examples/hello-static-lib/Makefile b/doc/examples/hello-static-lib/Makefile
index dd246f7..85c64c1 100644
--- a/doc/examples/hello-static-lib/Makefile
+++ b/doc/examples/hello-static-lib/Makefile
@@ -13,16 +13,16 @@
# a program with tracepoint provider probes compiled as static libraries.
CC = gcc
-CFLAGS += -I.
+LOCAL_CPPFLAGS += -I.
LIBS = -ldl -llttng-ust # On Linux
#LIBS = -lc -llttng-ust # On BSD
# Only necessary when building from the source tree and lttng-ust is not
# installed
ifdef BUILD_EXAMPLES_FROM_TREE
-CFLAGS += -I../../../include/
+LOCAL_CPPFLAGS += -I../../../include/
LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/
-LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)'
+override LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)'
# Third-party Makefiles have to define these targets to integrate with an
# automake project
@@ -37,13 +37,13 @@ endif
all: hello
lttng-ust-provider-hello.o: tp.c ust_tests_hello.h
- $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
lttng-ust-provider-hello.a: lttng-ust-provider-hello.o
ar -rc $@ $^
hello.o: hello.c
- $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
hello: hello.o lttng-ust-provider-hello.a
$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
--
1.8.2.3
More information about the lttng-dev
mailing list