Skip to content

Commit

Permalink
tools/resolve_btfids: Build libbpf and libsubcmd in separate directories
Browse files Browse the repository at this point in the history
Setting up separate build directories for libbpf and libpsubcmd,
so it's separated from other objects and we don't get them mixed
in the future.

It also simplifies cleaning, which is now simple rm -rf.

Also there's no need for FEATURE-DUMP.libbpf and bpf_helper_defs.h
files in .gitignore anymore.

Signed-off-by: Jiri Olsa <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Acked-by: Song Liu <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
olsajiri authored and anakryiko committed Feb 9, 2021
1 parent 0a1b0fd commit fc6b48f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
2 changes: 0 additions & 2 deletions tools/bpf/resolve_btfids/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
/FEATURE-DUMP.libbpf
/bpf_helper_defs.h
/fixdep
/resolve_btfids
26 changes: 11 additions & 15 deletions tools/bpf/resolve_btfids/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
LIBBPF_SRC := $(srctree)/tools/lib/bpf/
SUBCMD_SRC := $(srctree)/tools/lib/subcmd/

BPFOBJ := $(OUTPUT)/libbpf.a
SUBCMDOBJ := $(OUTPUT)/libsubcmd.a
BPFOBJ := $(OUTPUT)/libbpf/libbpf.a
SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a

BINARY := $(OUTPUT)/resolve_btfids
BINARY_IN := $(BINARY)-in.o

all: $(BINARY)

$(OUTPUT):
$(OUTPUT) $(OUTPUT)/libbpf $(OUTPUT)/libsubcmd:
$(call msg,MKDIR,,$@)
$(Q)mkdir -p $(OUTPUT)
$(Q)mkdir -p $(@)

$(SUBCMDOBJ): fixdep FORCE
$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(OUTPUT)
$(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)

$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)
$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)/libbpf
$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)

CFLAGS := -g \
Expand All @@ -57,23 +57,19 @@ LIBS = -lelf -lz
export srctree OUTPUT CFLAGS Q
include $(srctree)/tools/build/Makefile.include

$(BINARY_IN): fixdep FORCE
$(BINARY_IN): fixdep FORCE | $(OUTPUT)
$(Q)$(MAKE) $(build)=resolve_btfids

$(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
$(call msg,LINK,$@)
$(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)

libsubcmd-clean:
$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(OUTPUT) clean

libbpf-clean:
$(Q)$(MAKE) -C $(LIBBPF_SRC) OUTPUT=$(OUTPUT) clean

clean: libsubcmd-clean libbpf-clean fixdep-clean
clean: fixdep-clean
$(call msg,CLEAN,$(BINARY))
$(Q)$(RM) -f $(BINARY); \
$(RM) -rf $(if $(OUTPUT),$(OUTPUT),.)/feature; \
$(RM) -rf $(OUTPUT)/libbpf; \
$(RM) -rf $(OUTPUT)/libsubcmd; \
find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)

tags:
Expand Down

0 comments on commit fc6b48f

Please sign in to comment.