1# SPDX-License-Identifier: GPL-2.0
2include ../../../scripts/Makefile.include
3
4top_srcdir = $(abspath ../../../..)
5APIDIR := $(top_scrdir)/include/uapi
6TEST_GEN_FILES = action.o
7
8KSFT_KHDR_INSTALL := 1
9include ../lib.mk
10
11PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1)
12
13ifeq ($(PROBE),)
14  CPU ?= probe
15else
16  CPU ?= generic
17endif
18
19CLANG_SYS_INCLUDES := $(shell $(CLANG) -v -E - </dev/null 2>&1 \
20	| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }')
21
22CLANG_FLAGS = -I. -I$(APIDIR) \
23	      $(CLANG_SYS_INCLUDES) \
24	      -Wno-compare-distinct-pointer-types
25
26$(OUTPUT)/%.o: %.c
27	$(CLANG) $(CLANG_FLAGS) \
28		 -O2 -target bpf -emit-llvm -c $< -o - |      \
29	$(LLC) -march=bpf -mcpu=$(CPU) $(LLC_FLAGS) -filetype=obj -o $@
30
31TEST_PROGS += ./tdc.sh
32TEST_FILES := tdc*.py Tdc*.py plugins plugin-lib tc-tests
33