treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / lib / perf / Makefile
blob3718d65cffac79ffbbf74917c14cc6b37073768e
1 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
2 # Most of this file is copied from tools/lib/bpf/Makefile
4 LIBPERF_VERSION = 0
5 LIBPERF_PATCHLEVEL = 0
6 LIBPERF_EXTRAVERSION = 1
8 MAKEFLAGS += --no-print-directory
10 ifeq ($(srctree),)
11 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
12 srctree := $(patsubst %/,%,$(dir $(srctree)))
13 srctree := $(patsubst %/,%,$(dir $(srctree)))
14 #$(info Determined 'srctree' to be $(srctree))
15 endif
17 INSTALL = install
19 # Use DESTDIR for installing into a different root directory.
20 # This is useful for building a package. The program will be
21 # installed in this directory as if it was the root directory.
22 # Then the build tool can move it later.
23 DESTDIR ?=
24 DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
26 include $(srctree)/tools/scripts/Makefile.include
27 include $(srctree)/tools/scripts/Makefile.arch
29 ifeq ($(LP64), 1)
30 libdir_relative = lib64
31 else
32 libdir_relative = lib
33 endif
35 prefix ?=
36 libdir = $(prefix)/$(libdir_relative)
38 # Shell quotes
39 libdir_SQ = $(subst ','\'',$(libdir))
40 libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
42 ifeq ("$(origin V)", "command line")
43 VERBOSE = $(V)
44 endif
45 ifndef VERBOSE
46 VERBOSE = 0
47 endif
49 ifeq ($(VERBOSE),1)
50 Q =
51 else
52 Q = @
53 endif
55 # Set compile option CFLAGS
56 ifdef EXTRA_CFLAGS
57 CFLAGS := $(EXTRA_CFLAGS)
58 else
59 CFLAGS := -g -Wall
60 endif
62 INCLUDES = \
63 -I$(srctree)/tools/lib/perf/include \
64 -I$(srctree)/tools/lib/ \
65 -I$(srctree)/tools/include \
66 -I$(srctree)/tools/arch/$(SRCARCH)/include/ \
67 -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi \
68 -I$(srctree)/tools/include/uapi
70 # Append required CFLAGS
71 override CFLAGS += $(EXTRA_WARNINGS)
72 override CFLAGS += -Werror -Wall
73 override CFLAGS += -fPIC
74 override CFLAGS += $(INCLUDES)
75 override CFLAGS += -fvisibility=hidden
77 all:
79 export srctree OUTPUT CC LD CFLAGS V
80 export DESTDIR DESTDIR_SQ
82 include $(srctree)/tools/build/Makefile.include
84 VERSION_SCRIPT := libperf.map
86 PATCHLEVEL = $(LIBPERF_PATCHLEVEL)
87 EXTRAVERSION = $(LIBPERF_EXTRAVERSION)
88 VERSION = $(LIBPERF_VERSION).$(LIBPERF_PATCHLEVEL).$(LIBPERF_EXTRAVERSION)
90 LIBPERF_SO := $(OUTPUT)libperf.so.$(VERSION)
91 LIBPERF_A := $(OUTPUT)libperf.a
92 LIBPERF_IN := $(OUTPUT)libperf-in.o
93 LIBPERF_PC := $(OUTPUT)libperf.pc
95 LIBPERF_ALL := $(LIBPERF_A) $(OUTPUT)libperf.so*
97 LIB_DIR := $(srctree)/tools/lib/api/
99 ifneq ($(OUTPUT),)
100 ifneq ($(subdir),)
101 API_PATH=$(OUTPUT)/../lib/api/
102 else
103 API_PATH=$(OUTPUT)
104 endif
105 else
106 API_PATH=$(LIB_DIR)
107 endif
109 LIBAPI = $(API_PATH)libapi.a
110 export LIBAPI
112 $(LIBAPI): FORCE
113 $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a
115 $(LIBAPI)-clean:
116 $(call QUIET_CLEAN, libapi)
117 $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
119 $(LIBPERF_IN): FORCE
120 $(Q)$(MAKE) $(build)=libperf
122 $(LIBPERF_A): $(LIBPERF_IN)
123 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN)
125 $(LIBPERF_SO): $(LIBPERF_IN) $(LIBAPI)
126 $(QUIET_LINK)$(CC) --shared -Wl,-soname,libperf.so \
127 -Wl,--version-script=$(VERSION_SCRIPT) $^ -o $@
128 @ln -sf $(@F) $(OUTPUT)libperf.so
129 @ln -sf $(@F) $(OUTPUT)libperf.so.$(LIBPERF_VERSION)
132 libs: $(LIBPERF_A) $(LIBPERF_SO) $(LIBPERF_PC)
134 all: fixdep
135 $(Q)$(MAKE) libs
137 clean: $(LIBAPI)-clean
138 $(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \
139 *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS $(LIBPERF_PC)
140 $(Q)$(MAKE) -C tests clean
142 tests: libs
143 $(Q)$(MAKE) -C tests
144 $(Q)$(MAKE) -C tests run
146 $(LIBPERF_PC):
147 $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \
148 -e "s|@LIBDIR@|$(libdir_SQ)|" \
149 -e "s|@VERSION@|$(VERSION)|" \
150 < libperf.pc.template > $@
152 define do_install_mkdir
153 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \
154 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \
156 endef
158 define do_install
159 if [ ! -d '$(DESTDIR_SQ)$2' ]; then \
160 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \
161 fi; \
162 $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2'
163 endef
165 install_lib: libs
166 $(call QUIET_INSTALL, $(LIBPERF_ALL)) \
167 $(call do_install_mkdir,$(libdir_SQ)); \
168 cp -fpR $(LIBPERF_ALL) $(DESTDIR)$(libdir_SQ)
170 install_headers:
171 $(call QUIET_INSTALL, headers) \
172 $(call do_install,include/perf/core.h,$(prefix)/include/perf,644); \
173 $(call do_install,include/perf/cpumap.h,$(prefix)/include/perf,644); \
174 $(call do_install,include/perf/threadmap.h,$(prefix)/include/perf,644); \
175 $(call do_install,include/perf/evlist.h,$(prefix)/include/perf,644); \
176 $(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644); \
177 $(call do_install,include/perf/event.h,$(prefix)/include/perf,644); \
178 $(call do_install,include/perf/mmap.h,$(prefix)/include/perf,644);
180 install_pkgconfig: $(LIBPERF_PC)
181 $(call QUIET_INSTALL, $(LIBPERF_PC)) \
182 $(call do_install,$(LIBPERF_PC),$(libdir_SQ)/pkgconfig,644)
184 install_doc:
185 $(Q)$(MAKE) -C Documentation install-man install-html install-examples
187 install: install_lib install_headers install_pkgconfig install_doc
189 FORCE:
191 .PHONY: all install clean tests FORCE