Merge tag 'block-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / tools / bpf / resolve_btfids / Makefile
blobbf656432ad736fede7bc2e42c5edbd95dfb8fa46
1 # SPDX-License-Identifier: GPL-2.0-only
2 include ../../scripts/Makefile.include
3 include ../../scripts/Makefile.arch
5 ifeq ($(srctree),)
6 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
7 srctree := $(patsubst %/,%,$(dir $(srctree)))
8 srctree := $(patsubst %/,%,$(dir $(srctree)))
9 endif
11 ifeq ($(V),1)
12 Q =
13 msg =
14 else
15 Q = @
16 msg = @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))";
17 MAKEFLAGS=--no-print-directory
18 endif
20 # always use the host compiler
21 AR = $(HOSTAR)
22 CC = $(HOSTCC)
23 LD = $(HOSTLD)
24 ARCH = $(HOSTARCH)
26 OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
28 LIBBPF_SRC := $(srctree)/tools/lib/bpf/
29 SUBCMD_SRC := $(srctree)/tools/lib/subcmd/
31 BPFOBJ := $(OUTPUT)/libbpf.a
32 SUBCMDOBJ := $(OUTPUT)/libsubcmd.a
34 BINARY := $(OUTPUT)/resolve_btfids
35 BINARY_IN := $(BINARY)-in.o
37 all: $(BINARY)
39 $(OUTPUT):
40 $(call msg,MKDIR,,$@)
41 $(Q)mkdir -p $(OUTPUT)
43 $(SUBCMDOBJ): fixdep FORCE
44 $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(OUTPUT)
46 $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)
47 $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
49 CFLAGS := -g \
50 -I$(srctree)/tools/include \
51 -I$(srctree)/tools/include/uapi \
52 -I$(LIBBPF_SRC) \
53 -I$(SUBCMD_SRC)
55 LIBS = -lelf -lz
57 export srctree OUTPUT CFLAGS Q
58 include $(srctree)/tools/build/Makefile.include
60 $(BINARY_IN): fixdep FORCE
61 $(Q)$(MAKE) $(build)=resolve_btfids
63 $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
64 $(call msg,LINK,$@)
65 $(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
67 libsubcmd-clean:
68 $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(OUTPUT) clean
70 libbpf-clean:
71 $(Q)$(MAKE) -C $(LIBBPF_SRC) OUTPUT=$(OUTPUT) clean
73 clean: libsubcmd-clean libbpf-clean fixdep-clean
74 $(call msg,CLEAN,$(BINARY))
75 $(Q)$(RM) -f $(BINARY); \
76 $(RM) -rf $(if $(OUTPUT),$(OUTPUT),.)/feature; \
77 find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
79 tags:
80 $(call msg,GEN,,tags)
81 $(Q)ctags -R . $(LIBBPF_SRC) $(SUBCMD_SRC)
83 FORCE:
85 .PHONY: all FORCE clean tags