2019-07-21 11:24:10 +00:00
|
|
|
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
|
|
|
|
# Most of this file is copied from tools/lib/bpf/Makefile
|
|
|
|
|
2019-07-21 11:24:11 +00:00
|
|
|
LIBPERF_VERSION = 0
|
|
|
|
LIBPERF_PATCHLEVEL = 0
|
|
|
|
LIBPERF_EXTRAVERSION = 1
|
|
|
|
|
2019-07-21 11:24:10 +00:00
|
|
|
MAKEFLAGS += --no-print-directory
|
|
|
|
|
|
|
|
ifeq ($(srctree),)
|
|
|
|
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
|
|
|
|
srctree := $(patsubst %/,%,$(dir $(srctree)))
|
|
|
|
srctree := $(patsubst %/,%,$(dir $(srctree)))
|
|
|
|
#$(info Determined 'srctree' to be $(srctree))
|
|
|
|
endif
|
|
|
|
|
2019-07-21 11:24:58 +00:00
|
|
|
INSTALL = install
|
|
|
|
|
|
|
|
# Use DESTDIR for installing into a different root directory.
|
|
|
|
# This is useful for building a package. The program will be
|
|
|
|
# installed in this directory as if it was the root directory.
|
|
|
|
# Then the build tool can move it later.
|
|
|
|
DESTDIR ?=
|
|
|
|
DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
|
|
|
|
|
2019-07-21 11:24:10 +00:00
|
|
|
include $(srctree)/tools/scripts/Makefile.include
|
|
|
|
include $(srctree)/tools/scripts/Makefile.arch
|
|
|
|
|
2019-07-21 11:24:58 +00:00
|
|
|
ifeq ($(LP64), 1)
|
|
|
|
libdir_relative = lib64
|
|
|
|
else
|
|
|
|
libdir_relative = lib
|
|
|
|
endif
|
|
|
|
|
|
|
|
prefix ?=
|
|
|
|
libdir = $(prefix)/$(libdir_relative)
|
|
|
|
|
|
|
|
# Shell quotes
|
|
|
|
libdir_SQ = $(subst ','\'',$(libdir))
|
|
|
|
libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
|
|
|
|
|
2019-07-21 11:24:10 +00:00
|
|
|
ifeq ("$(origin V)", "command line")
|
|
|
|
VERBOSE = $(V)
|
|
|
|
endif
|
|
|
|
ifndef VERBOSE
|
|
|
|
VERBOSE = 0
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(VERBOSE),1)
|
|
|
|
Q =
|
|
|
|
else
|
|
|
|
Q = @
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Set compile option CFLAGS
|
|
|
|
ifdef EXTRA_CFLAGS
|
|
|
|
CFLAGS := $(EXTRA_CFLAGS)
|
|
|
|
else
|
|
|
|
CFLAGS := -g -Wall
|
|
|
|
endif
|
|
|
|
|
2019-08-20 12:46:24 +00:00
|
|
|
INCLUDES = -I$(srctree)/tools/perf/lib/include -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/ -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
|
2019-07-21 11:24:10 +00:00
|
|
|
|
|
|
|
# Append required CFLAGS
|
|
|
|
override CFLAGS += $(EXTRA_WARNINGS)
|
|
|
|
override CFLAGS += -Werror -Wall
|
|
|
|
override CFLAGS += -fPIC
|
|
|
|
override CFLAGS += $(INCLUDES)
|
|
|
|
override CFLAGS += -fvisibility=hidden
|
|
|
|
|
|
|
|
all:
|
|
|
|
|
|
|
|
export srctree OUTPUT CC LD CFLAGS V
|
2019-07-21 11:24:58 +00:00
|
|
|
export DESTDIR DESTDIR_SQ
|
|
|
|
|
2019-07-21 11:24:10 +00:00
|
|
|
include $(srctree)/tools/build/Makefile.include
|
|
|
|
|
2019-07-21 11:24:11 +00:00
|
|
|
VERSION_SCRIPT := libperf.map
|
|
|
|
|
|
|
|
PATCHLEVEL = $(LIBPERF_PATCHLEVEL)
|
|
|
|
EXTRAVERSION = $(LIBPERF_EXTRAVERSION)
|
|
|
|
VERSION = $(LIBPERF_VERSION).$(LIBPERF_PATCHLEVEL).$(LIBPERF_EXTRAVERSION)
|
|
|
|
|
|
|
|
LIBPERF_SO := $(OUTPUT)libperf.so.$(VERSION)
|
2019-07-21 11:24:10 +00:00
|
|
|
LIBPERF_A := $(OUTPUT)libperf.a
|
|
|
|
LIBPERF_IN := $(OUTPUT)libperf-in.o
|
2019-07-21 11:24:58 +00:00
|
|
|
LIBPERF_PC := $(OUTPUT)libperf.pc
|
|
|
|
|
|
|
|
LIBPERF_ALL := $(LIBPERF_A) $(OUTPUT)libperf.so*
|
2019-07-21 11:24:10 +00:00
|
|
|
|
|
|
|
$(LIBPERF_IN): FORCE
|
|
|
|
$(Q)$(MAKE) $(build)=libperf
|
|
|
|
|
|
|
|
$(LIBPERF_A): $(LIBPERF_IN)
|
|
|
|
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN)
|
|
|
|
|
|
|
|
$(LIBPERF_SO): $(LIBPERF_IN)
|
2019-07-21 11:24:11 +00:00
|
|
|
$(QUIET_LINK)$(CC) --shared -Wl,-soname,libperf.so \
|
|
|
|
-Wl,--version-script=$(VERSION_SCRIPT) $^ -o $@
|
|
|
|
@ln -sf $(@F) $(OUTPUT)libperf.so
|
|
|
|
@ln -sf $(@F) $(OUTPUT)libperf.so.$(LIBPERF_VERSION)
|
|
|
|
|
2019-07-21 11:24:10 +00:00
|
|
|
|
2019-07-21 11:24:58 +00:00
|
|
|
libs: $(LIBPERF_A) $(LIBPERF_SO) $(LIBPERF_PC)
|
2019-07-21 11:24:10 +00:00
|
|
|
|
|
|
|
all: fixdep
|
|
|
|
$(Q)$(MAKE) libs
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \
|
2019-07-21 11:24:58 +00:00
|
|
|
*.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS $(LIBPERF_PC)
|
2019-07-21 11:24:59 +00:00
|
|
|
$(Q)$(MAKE) -C tests clean
|
|
|
|
|
|
|
|
tests:
|
|
|
|
$(Q)$(MAKE) -C tests
|
|
|
|
$(Q)$(MAKE) -C tests run
|
2019-07-21 11:24:58 +00:00
|
|
|
|
|
|
|
$(LIBPERF_PC):
|
|
|
|
$(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \
|
|
|
|
-e "s|@LIBDIR@|$(libdir_SQ)|" \
|
|
|
|
-e "s|@VERSION@|$(VERSION)|" \
|
|
|
|
< libperf.pc.template > $@
|
|
|
|
|
|
|
|
define do_install_mkdir
|
|
|
|
if [ ! -d '$(DESTDIR_SQ)$1' ]; then \
|
|
|
|
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
|
|
|
define do_install
|
|
|
|
if [ ! -d '$(DESTDIR_SQ)$2' ]; then \
|
|
|
|
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \
|
|
|
|
fi; \
|
|
|
|
$(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2'
|
|
|
|
endef
|
|
|
|
|
|
|
|
install_lib: libs
|
|
|
|
$(call QUIET_INSTALL, $(LIBPERF_ALL)) \
|
|
|
|
$(call do_install_mkdir,$(libdir_SQ)); \
|
|
|
|
cp -fpR $(LIBPERF_ALL) $(DESTDIR)$(libdir_SQ)
|
|
|
|
|
|
|
|
install_headers:
|
|
|
|
$(call QUIET_INSTALL, headers) \
|
|
|
|
$(call do_install,include/perf/core.h,$(prefix)/include/perf,644); \
|
|
|
|
$(call do_install,include/perf/cpumap.h,$(prefix)/include/perf,644); \
|
|
|
|
$(call do_install,include/perf/threadmap.h,$(prefix)/include/perf,644); \
|
|
|
|
$(call do_install,include/perf/evlist.h,$(prefix)/include/perf,644); \
|
|
|
|
$(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644);
|
2019-09-01 12:48:22 +00:00
|
|
|
$(call do_install,include/perf/event.h,$(prefix)/include/perf,644);
|
2019-07-21 11:24:58 +00:00
|
|
|
|
|
|
|
install_pkgconfig: $(LIBPERF_PC)
|
|
|
|
$(call QUIET_INSTALL, $(LIBPERF_PC)) \
|
|
|
|
$(call do_install,$(LIBPERF_PC),$(libdir_SQ)/pkgconfig,644)
|
|
|
|
|
|
|
|
install: install_lib install_headers install_pkgconfig
|
2019-07-21 11:24:10 +00:00
|
|
|
|
|
|
|
FORCE:
|
|
|
|
|
2019-07-21 11:24:59 +00:00
|
|
|
.PHONY: all install clean tests FORCE
|