Makefile 743 B

1234567891011121314151617181920212223242526272829
  1. # SPDX-License-Identifier: GPL-2.0
  2. APIDIR := ../../../../include/uapi
  3. TEST_GEN_FILES = action.o
  4. top_srcdir = ../../../../..
  5. include ../../lib.mk
  6. CLANG ?= clang
  7. LLC ?= llc
  8. PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1)
  9. ifeq ($(PROBE),)
  10. CPU ?= probe
  11. else
  12. CPU ?= generic
  13. endif
  14. CLANG_SYS_INCLUDES := $(shell $(CLANG) -v -E - </dev/null 2>&1 \
  15. | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }')
  16. CLANG_FLAGS = -I. -I$(APIDIR) \
  17. $(CLANG_SYS_INCLUDES) \
  18. -Wno-compare-distinct-pointer-types
  19. $(OUTPUT)/%.o: %.c
  20. $(CLANG) $(CLANG_FLAGS) \
  21. -O2 -target bpf -emit-llvm -c $< -o - | \
  22. $(LLC) -march=bpf -mcpu=$(CPU) $(LLC_FLAGS) -filetype=obj -o $@