cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

Makefile (2601B)


      1# SPDX-License-Identifier: GPL-2.0-only
      2include ../../scripts/Makefile.include
      3include ../../scripts/Makefile.arch
      4
      5srctree := $(abspath $(CURDIR)/../../../)
      6
      7ifeq ($(V),1)
      8  Q =
      9  msg =
     10else
     11  Q = @
     12  ifeq ($(silent),1)
     13    msg =
     14  else
     15    msg = @printf '  %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))";
     16  endif
     17  MAKEFLAGS=--no-print-directory
     18endif
     19
     20# always use the host compiler
     21AR       = $(HOSTAR)
     22CC       = $(HOSTCC)
     23LD       = $(HOSTLD)
     24ARCH     = $(HOSTARCH)
     25RM      ?= rm
     26CROSS_COMPILE =
     27CFLAGS  := $(KBUILD_HOSTCFLAGS)
     28LDFLAGS := $(KBUILD_HOSTLDFLAGS)
     29
     30OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
     31
     32LIBBPF_SRC := $(srctree)/tools/lib/bpf/
     33SUBCMD_SRC := $(srctree)/tools/lib/subcmd/
     34
     35BPFOBJ     := $(OUTPUT)/libbpf/libbpf.a
     36LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/
     37SUBCMDOBJ  := $(OUTPUT)/libsubcmd/libsubcmd.a
     38
     39LIBBPF_DESTDIR := $(LIBBPF_OUT)
     40LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include
     41
     42BINARY     := $(OUTPUT)/resolve_btfids
     43BINARY_IN  := $(BINARY)-in.o
     44
     45all: $(BINARY)
     46
     47$(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT):
     48	$(call msg,MKDIR,,$@)
     49	$(Q)mkdir -p $(@)
     50
     51$(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
     52	$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
     53
     54$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT)
     55	$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT)    \
     56		    DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \
     57		    $(abspath $@) install_headers
     58
     59CFLAGS += -g \
     60          -I$(srctree)/tools/include \
     61          -I$(srctree)/tools/include/uapi \
     62          -I$(LIBBPF_INCLUDE) \
     63          -I$(SUBCMD_SRC)
     64
     65LIBS = -lelf -lz
     66
     67export srctree OUTPUT CFLAGS Q
     68include $(srctree)/tools/build/Makefile.include
     69
     70$(BINARY_IN): $(BPFOBJ) fixdep FORCE | $(OUTPUT)
     71	$(Q)$(MAKE) $(build)=resolve_btfids
     72
     73$(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
     74	$(call msg,LINK,$@)
     75	$(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
     76
     77clean_objects := $(wildcard $(OUTPUT)/*.o                \
     78                            $(OUTPUT)/.*.o.cmd           \
     79                            $(OUTPUT)/.*.o.d             \
     80                            $(LIBBPF_OUT)                \
     81                            $(LIBBPF_DESTDIR)            \
     82                            $(OUTPUT)/libsubcmd          \
     83                            $(OUTPUT)/resolve_btfids)
     84
     85ifneq ($(clean_objects),)
     86clean: fixdep-clean
     87	$(call msg,CLEAN,$(BINARY))
     88	$(Q)$(RM) -rf $(clean_objects)
     89else
     90clean:
     91endif
     92
     93tags:
     94	$(call msg,GEN,,tags)
     95	$(Q)ctags -R . $(LIBBPF_SRC) $(SUBCMD_SRC)
     96
     97FORCE:
     98
     99.PHONY: all FORCE clean tags