From 2e3906003540b455b473ce06fdde4ba38208e4b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 30 May 2013 10:32:12 -0400 Subject: [PATCH] Move include directive from CFLAGS to LOCAL_CPPFLAGS in examples' Makefiles MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Mathieu Desnoyers --- 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 bbc8ccb7..27ca92b6 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 e20e53a9..e3546e11 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 dd246f70..85c64c1b 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) -- 2.34.1