Debian Codegraph @

tools/tracing/rtla/Makefile

raw
1 # SPDX-License-Identifier: GPL-2.0-only
2
3 ifeq ($(srctree),)
4 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
5 srctree := $(patsubst %/,%,$(dir $(srctree)))
6 srctree := $(patsubst %/,%,$(dir $(srctree)))
7 endif
8
9 include $(srctree)/tools/scripts/Makefile.include
10
11 # O is an alias for OUTPUT
12 OUTPUT := $(O)
13
14 ifeq ($(OUTPUT),)
15 OUTPUT := $(CURDIR)
16 else
17 # subdir is used by the ../Makefile in $(call descend,)
18 ifneq ($(subdir),)
19 OUTPUT := $(OUTPUT)/$(subdir)
20 endif
21 endif
22
23 ifneq ($(patsubst %/,,$(lastword $(OUTPUT))),)
24 OUTPUT := $(OUTPUT)/
25 endif
26
27 RTLA := $(OUTPUT)rtla
28 RTLA_IN := $(RTLA)-in.o
29
30 VERSION := $(shell sh -c "make -sC ../../.. kernelversion | grep -v make")
31 DOCSRC := ../../../Documentation/tools/rtla/
32
33 FEATURE_TESTS := libtraceevent
34 FEATURE_TESTS += libtracefs
35 FEATURE_TESTS += libcpupower
36 FEATURE_TESTS += libbpf
37 FEATURE_TESTS += clang-bpf-co-re
38 FEATURE_TESTS += bpftool-skeletons
39 FEATURE_DISPLAY := libtraceevent
40 FEATURE_DISPLAY += libtracefs
41 FEATURE_DISPLAY += libcpupower
42 FEATURE_DISPLAY += libbpf
43 FEATURE_DISPLAY += clang-bpf-co-re
44 FEATURE_DISPLAY += bpftool-skeletons
45
46 all: $(RTLA)
47
48 include $(srctree)/tools/build/Makefile.include
49 include Makefile.rtla
50
51 # check for dependencies only on required targets
52 NON_CONFIG_TARGETS := clean install tarball doc doc_clean doc_install
53
54 config := 1
55 ifdef MAKECMDGOALS
56 ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
57 config := 0
58 endif
59 endif
60
61 ifeq ($(config),1)
62 include $(srctree)/tools/build/Makefile.feature
63 include Makefile.config
64 endif
65
66 CFLAGS += $(INCLUDES) $(LIB_INCLUDES)
67
68 export CFLAGS OUTPUT srctree
69
70 ifeq ($(BUILD_BPF_SKEL),1)
71 src/timerlat.bpf.o: src/timerlat.bpf.c
72 $(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -c $(filter %.c,$^) -o $@
73
74 src/timerlat.skel.h: src/timerlat.bpf.o
75 $(QUIET_GENSKEL)$(SYSTEM_BPFTOOL) gen skeleton $< > $@
76
77 example/timerlat_bpf_action.o: example/timerlat_bpf_action.c
78 $(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -c $(filter %.c,$^) -o $@
79
80 tests/bpf/bpf_action_map.o: tests/bpf/bpf_action_map.c
81 $(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -c $(filter %.c,$^) -o $@
82 else
83 src/timerlat.skel.h:
84 $(Q)echo '/* BPF skeleton is disabled */' > src/timerlat.skel.h
85
86 example/timerlat_bpf_action.o: example/timerlat_bpf_action.c
87 $(Q)echo "BPF skeleton support is disabled, skipping example/timerlat_bpf_action.o"
88
89 tests/bpf/bpf_action_map.o: tests/bpf/bpf_action_map.c
90 $(Q)echo "BPF skeleton support is disabled, skipping tests/bpf/bpf_action_map.o"
91 endif
92
93 $(RTLA): $(RTLA_IN)
94 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $(RTLA) $(RTLA_IN) $(EXTLIBS)
95
96 static: $(RTLA_IN)
97 $(eval LDFLAGS += -static)
98 $(QUIET_LINK)$(CC) -static $(LDFLAGS) -o $(RTLA)-static $(RTLA_IN) $(EXTLIBS)
99
100 rtla.%: fixdep FORCE
101 make -f $(srctree)/tools/build/Makefile.build dir=. $@
102
103 $(RTLA_IN): fixdep FORCE src/timerlat.skel.h
104 make $(build)=rtla
105
106 clean: doc_clean fixdep-clean
107 $(call QUIET_CLEAN, rtla)
108 $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
109 $(Q)rm -f rtla rtla-static fixdep FEATURE-DUMP rtla-*
110 $(Q)rm -rf feature
111 $(Q)rm -f src/timerlat.bpf.o src/timerlat.skel.h example/timerlat_bpf_action.o
112 check: $(RTLA) tests/bpf/bpf_action_map.o
113 RTLA=$(RTLA) BPFTOOL=$(SYSTEM_BPFTOOL) prove -o -f -v tests/
114 examples: example/timerlat_bpf_action.o
115 .PHONY: FORCE clean check