Makefile 3.2 KB

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