github.com/cilium/cilium@v1.16.2/bpf/custom/Makefile (about) 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 # Copyright Authors of Cilium 3 4 include ../../Makefile.defs 5 6 .PHONY: all clean 7 8 BASE_PROG := bpf_custom.c 9 10 ifneq ("$(BPF_CUSTOM_PROG_FILE)", "") 11 PROGS = $(patsubst %.h,%.o,$(BPF_CUSTOM_PROG_FILE)) 12 else 13 # If no header file was passed, compile for all header files found in the 14 # directory. 15 PROGS = $(patsubst %.h,%.o,$(wildcard *.h)) 16 endif 17 18 ifneq ("$(BPF_CUSTOM_PROG_NAME)","") 19 sec_name = $(BPF_CUSTOM_PROG_NAME) 20 else 21 sec_name = $(basename $(1)) 22 endif 23 24 include ../Makefile.bpf 25 26 all: $(PROGS) 27 28 %.o: %.h $(BASE_PROG) $(LIB) 29 @$(ECHO_CC) 30 $(QUIET) ${CLANG} ${CLANG_FLAGS} \ 31 -DBPF_CUSTOM_PROG_FILE=$< \ 32 -DBPF_CUSTOM_PROG_NAME=$(call sec_name,$<) \ 33 -c $(BASE_PROG) -o $@ 34 35 clean: 36 @$(ECHO_CLEAN) 37 $(QUIET)rm -fr *.o *.ll *.i