1 # SPDX-License-Identifier: GPL-2.0-only
2 include ../../scripts/Makefile.include
3 include ../../scripts/Makefile.arch
5 srctree := $(abspath $(CURDIR)/../../../)
15 msg = @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))";
17 MAKEFLAGS=--no-print-directory
20 # always use the host compiler
27 OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
29 LIBBPF_SRC := $(srctree)/tools/lib/bpf/
30 SUBCMD_SRC := $(srctree)/tools/lib/subcmd/
32 BPFOBJ := $(OUTPUT)/libbpf/libbpf.a
33 SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a
35 BINARY := $(OUTPUT)/resolve_btfids
36 BINARY_IN := $(BINARY)-in.o
40 $(OUTPUT) $(OUTPUT)/libbpf $(OUTPUT)/libsubcmd:
44 $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
45 $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
47 $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)/libbpf
48 $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
51 -I$(srctree)/tools/include \
52 -I$(srctree)/tools/include/uapi \
58 export srctree OUTPUT CFLAGS Q
59 include $(srctree)/tools/build/Makefile.include
61 $(BINARY_IN): fixdep FORCE | $(OUTPUT)
62 $(Q)$(MAKE) $(build)=resolve_btfids
64 $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
66 $(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
68 clean_objects := $(wildcard $(OUTPUT)/*.o \
73 $(OUTPUT)/resolve_btfids)
75 ifneq ($(clean_objects),)
77 $(call msg,CLEAN,$(BINARY))
78 $(Q)$(RM) -rf $(clean_objects)
85 $(Q)ctags -R . $(LIBBPF_SRC) $(SUBCMD_SRC)
89 .PHONY: all FORCE clean tags