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