Pass the CC variable to the example Makefiles
[lttng-ust.git] / doc / examples / gen-tp / Makefile
1 # Copyright (C) 2011-2012 Matthew Khouzam <matthew.khouzam@ericsson.com>
2 # Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 # Copyright (C) 2012 Yannick Brosseau <yannick.brosseau@gmail.com>
4 #
5 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6 # OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
7 #
8 # Permission is hereby granted to use or copy this program for any
9 # purpose, provided the above notices are retained on all copies.
10 # Permission to modify the code and to distribute modified code is
11 # granted, provided the above notices are retained, and a notice that
12 # the code was modified is included with the above copyright notice.
13 #
14 # This makefile is not using automake so that people can see how to make
15 # simply. It builds a program with a statically embedded tracepoint
16 # provider probe.
17 #
18 # This makefile is purposefully kept simple to support GNU and BSD make.
19
20 ifdef AM_CC
21 CC = $(AM_CC)
22 endif
23
24 LIBS = -ldl -llttng-ust #On Linux
25 #LIBS = -lc -llttng-ust #On BSD
26
27 all: sample
28
29 sample: sample.o sample_tracepoint.o
30 $(CC) $(LDFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(AM_CFLAGS) \
31 -o $@ sample.o sample_tracepoint.o $(LIBS)
32
33 sample.o: sample.c sample_tracepoint.h
34 $(CC) $(CPPFLAGS) $(CFLAGS) $(AM_CPPFLAGS) $(AM_CFLAGS) \
35 -c -o $@ $<
36
37 # Use this command to compile the .c manually
38 #sample_tracepoint.o: sample_tracepoint.c sample_tracepoint.h
39 # $(CC) $(CPPFLAGS) $(CFLAGS) $(AM_CPPFLAGS) $(AM_CFLAGS) \
40 # -I. -c -o $@ $<
41
42 # This rule generate .o only and depends on rules for generating
43 # the .h and .c
44 %.o: %.tp %.c %.h
45 CPPFLAGS="$(CPPFLAGS) $(AM_CPPFLAGS)" \
46 CFLAGS="$(CFLAGS) $(AM_CFLAGS)" \
47 LDFLAGS="$(LDFLAGS) $(AM_LDFLAGS)" \
48 CC=$(CC) \
49 $(LTTNG_GEN_TP_PATH)lttng-gen-tp -o $@ $<
50
51 # The following rule can be used to generate all files instead of having one
52 # for each file type. Note that the sample.o has a dependency on the
53 # .h, so you need to change that if you remove the %.h rule.
54 #%.o: %.tp
55 # lttng-gen-tp $<
56
57 %.h: %.tp
58 $(LTTNG_GEN_TP_PATH)lttng-gen-tp -o $@ $<
59
60 %.c: %.tp
61 $(LTTNG_GEN_TP_PATH)lttng-gen-tp -o $@ $<
62
63 .PHONY: clean
64 clean:
65 rm -f *.o sample
66 rm -f sample_tracepoint.h sample_tracepoint.c
This page took 0.031567 seconds and 4 git commands to generate.