mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-15 21:23:23 +00:00
1478994aad
API headers from libbpf should not be accessed directly from the library's source directory. Instead, they should be exported with "make install_headers". Let's make sure that resolve_btfids installs the headers properly when building. When descending from a parent Makefile, the specific output directories for building the library and exporting the headers are configurable with LIBBPF_OUT and LIBBPF_DESTDIR, respectively. This is in addition to OUTPUT, on top of which those variables are constructed by default. Also adjust the Makefile for the BPF selftests in order to point to the (target) libbpf shared with other tools, instead of building a version specific to resolve_btfids. Remove libbpf's order-only dependencies on the include directories (they are created by libbpf and don't need to exist beforehand). Signed-off-by: Quentin Monnet <quentin@isovalent.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211007194438.34443-5-quentin@isovalent.com
93 lines
2.4 KiB
Makefile
93 lines
2.4 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0-only
|
|
include ../../scripts/Makefile.include
|
|
include ../../scripts/Makefile.arch
|
|
|
|
srctree := $(abspath $(CURDIR)/../../../)
|
|
|
|
ifeq ($(V),1)
|
|
Q =
|
|
msg =
|
|
else
|
|
Q = @
|
|
msg = @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))";
|
|
MAKEFLAGS=--no-print-directory
|
|
endif
|
|
|
|
# always use the host compiler
|
|
AR = $(HOSTAR)
|
|
CC = $(HOSTCC)
|
|
LD = $(HOSTLD)
|
|
ARCH = $(HOSTARCH)
|
|
RM ?= rm
|
|
|
|
OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
|
|
|
|
LIBBPF_SRC := $(srctree)/tools/lib/bpf/
|
|
SUBCMD_SRC := $(srctree)/tools/lib/subcmd/
|
|
|
|
BPFOBJ := $(OUTPUT)/libbpf/libbpf.a
|
|
LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/
|
|
SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a
|
|
|
|
LIBBPF_DESTDIR := $(LIBBPF_OUT)
|
|
LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include
|
|
|
|
BINARY := $(OUTPUT)/resolve_btfids
|
|
BINARY_IN := $(BINARY)-in.o
|
|
|
|
all: $(BINARY)
|
|
|
|
$(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT):
|
|
$(call msg,MKDIR,,$@)
|
|
$(Q)mkdir -p $(@)
|
|
|
|
$(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
|
|
$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
|
|
|
|
$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT)
|
|
$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \
|
|
DESTDIR=$(LIBBPF_DESTDIR) prefix= \
|
|
$(abspath $@) install_headers
|
|
|
|
CFLAGS := -g \
|
|
-I$(srctree)/tools/include \
|
|
-I$(srctree)/tools/include/uapi \
|
|
-I$(LIBBPF_INCLUDE) \
|
|
-I$(SUBCMD_SRC)
|
|
|
|
LIBS = -lelf -lz
|
|
|
|
export srctree OUTPUT CFLAGS Q
|
|
include $(srctree)/tools/build/Makefile.include
|
|
|
|
$(BINARY_IN): $(BPFOBJ) 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)
|
|
|
|
clean_objects := $(wildcard $(OUTPUT)/*.o \
|
|
$(OUTPUT)/.*.o.cmd \
|
|
$(OUTPUT)/.*.o.d \
|
|
$(LIBBPF_OUT) \
|
|
$(LIBBPF_DESTDIR) \
|
|
$(OUTPUT)/libsubcmd \
|
|
$(OUTPUT)/resolve_btfids)
|
|
|
|
ifneq ($(clean_objects),)
|
|
clean: fixdep-clean
|
|
$(call msg,CLEAN,$(BINARY))
|
|
$(Q)$(RM) -rf $(clean_objects)
|
|
else
|
|
clean:
|
|
endif
|
|
|
|
tags:
|
|
$(call msg,GEN,,tags)
|
|
$(Q)ctags -R . $(LIBBPF_SRC) $(SUBCMD_SRC)
|
|
|
|
FORCE:
|
|
|
|
.PHONY: all FORCE clean tags
|