Move include directive from CFLAGS to LOCAL_CPPFLAGS in examples' Makefiles
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 30 May 2013 14:32:12 +0000 (10:32 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 30 May 2013 14:32:41 +0000 (10:32 -0400)
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@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
doc/examples/demo/Makefile
doc/examples/easy-ust/Makefile
doc/examples/hello-static-lib/Makefile

index bbc8ccb7e6aae5821acf44236403a9865c195f07..27ca92b6704b32795e0259bb756ab8d8978b5063 100644 (file)
 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)
index e20e53a959074da42c701a1b497f39bd5b6a3bf3..e3546e11a63c3675e35c2edb78d308aeaba085fe 100644 (file)
 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
 
index dd246f70a5c274dd465f18cf025e57b5bc678e17..85c64c1b7cb4a848dc9a275273cb3a94105165db 100644 (file)
 # 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)
This page took 0.031763 seconds and 4 git commands to generate.