| 1 | # SPDX-License-Identifier: MIT |
| 2 | # |
| 3 | # Copyright (C) 2011-2012 Matthew Khouzam <matthew.khouzam@ericsson.com> |
| 4 | # Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 5 | # Copyright (C) 2012 Yannick Brosseau <yannick.brosseau@gmail.com> |
| 6 | # |
| 7 | # This makefile is not using automake so that people can see how to make |
| 8 | # simply. It builds a program with a statically embedded tracepoint |
| 9 | # provider probe. |
| 10 | # |
| 11 | # This makefile is purposefully kept simple to support GNU and BSD make. |
| 12 | |
| 13 | PYTHON := python |
| 14 | |
| 15 | LIBS = -ldl -llttng-ust #On Linux |
| 16 | #LIBS = -lc -llttng-ust #On BSD |
| 17 | AM_V_P := : |
| 18 | |
| 19 | all: sample |
| 20 | |
| 21 | sample: sample.o sample_tracepoint.o |
| 22 | @if $(AM_V_P); then set -x; else echo " CCLD $@"; fi; \ |
| 23 | $(CC) $(LDFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) $(CFLAGS) \ |
| 24 | -o $@ sample.o sample_tracepoint.o $(LIBS) |
| 25 | |
| 26 | sample.o: sample.c sample_tracepoint.h |
| 27 | @if $(AM_V_P); then set -x; else echo " CC $@"; fi; \ |
| 28 | $(CC) $(CPPFLAGS) $(AM_CFLAGS) $(AM_CPPFLAGS) $(CFLAGS) \ |
| 29 | -c -o $@ $< |
| 30 | |
| 31 | # Use this command to compile the .c manually |
| 32 | #sample_tracepoint.o: sample_tracepoint.c sample_tracepoint.h |
| 33 | # $(CC) $(CPPFLAGS) $(AM_CFLAGS) $(AM_CPPFLAGS) $(CFLAGS) \ |
| 34 | # -I. -c -o $@ $< |
| 35 | |
| 36 | # This rule generate .o only and depends on rules for generating |
| 37 | # the .h and .c |
| 38 | %.o: %.tp %.c %.h |
| 39 | @if $(AM_V_P); then set -x; else echo " CC $@"; fi; \ |
| 40 | CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS)" \ |
| 41 | CFLAGS="$(AM_CFLAGS) $(CFLAGS)" \ |
| 42 | LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS)" \ |
| 43 | CC="$(CC)" \ |
| 44 | $(PYTHON) $(LTTNG_GEN_TP_PATH)lttng-gen-tp -o $@ $< |
| 45 | |
| 46 | # The following rule can be used to generate all files instead of having one |
| 47 | # for each file type. Note that the sample.o has a dependency on the |
| 48 | # .h, so you need to change that if you remove the %.h rule. |
| 49 | #%.o: %.tp |
| 50 | # lttng-gen-tp $< |
| 51 | |
| 52 | %.h: %.tp |
| 53 | @if $(AM_V_P); then set -x; else echo " GEN $@"; fi; \ |
| 54 | $(PYTHON) $(LTTNG_GEN_TP_PATH)lttng-gen-tp -o $@ $< |
| 55 | |
| 56 | %.c: %.tp |
| 57 | @if $(AM_V_P); then set -x; else echo " GEN $@"; fi; \ |
| 58 | $(PYTHON) $(LTTNG_GEN_TP_PATH)lttng-gen-tp -o $@ $< |
| 59 | |
| 60 | .PHONY: clean |
| 61 | clean: |
| 62 | rm -f *.o sample |
| 63 | rm -f sample_tracepoint.h sample_tracepoint.c |