^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # trace-cmd version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) EP_VERSION = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) EP_PATCHLEVEL = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) EP_EXTRAVERSION = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # file format version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) FILE_VERSION = 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) MAKEFLAGS += --no-print-directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) # Makefiles suck: This macro sets a default value of $(2) for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) # variable named by $(1), unless the variable has been set by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) # environment or command line. This is necessary for CC and AR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) # because make sets default values, so the simpler ?= approach
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) # won't work as expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) define allow-override
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) $(if $(or $(findstring environment,$(origin $(1))),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) $(findstring command line,$(origin $(1)))),,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) $(eval $(1) = $(2)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) # Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) $(call allow-override,CC,$(CROSS_COMPILE)gcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) $(call allow-override,AR,$(CROSS_COMPILE)ar)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) $(call allow-override,NM,$(CROSS_COMPILE)nm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) $(call allow-override,PKG_CONFIG,pkg-config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) EXT = -std=gnu99
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) INSTALL = install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) # Use DESTDIR for installing into a different root directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) # This is useful for building a package. The program will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) # installed in this directory as if it was the root directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) # Then the build tool can move it later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) DESTDIR ?=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) ifeq ($(LP64), 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) libdir_relative_temp = lib64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) libdir_relative_temp = lib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) libdir_relative ?= $(libdir_relative_temp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) prefix ?= /usr/local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) libdir = $(prefix)/$(libdir_relative)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) man_dir = $(prefix)/share/man
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) man_dir_SQ = '$(subst ','\'',$(man_dir))'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) --variable pc_path pkg-config | tr ":" " "))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) includedir_relative = traceevent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) includedir = $(prefix)/include/$(includedir_relative)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) includedir_SQ = '$(subst ','\'',$(includedir))'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) export man_dir man_dir_SQ INSTALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) export DESTDIR DESTDIR_SQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) export EVENT_PARSE_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) include ../../scripts/Makefile.include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) # copy a bit from Linux kbuild
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ifeq ("$(origin V)", "command line")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) VERBOSE = $(V)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) ifndef VERBOSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) VERBOSE = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) ifeq ($(srctree),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) srctree := $(patsubst %/,%,$(dir $(CURDIR)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) srctree := $(patsubst %/,%,$(dir $(srctree)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) srctree := $(patsubst %/,%,$(dir $(srctree)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #$(info Determined 'srctree' to be $(srctree))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) export prefix libdir src obj
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) # Shell quotes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) libdir_SQ = $(subst ','\'',$(libdir))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) CONFIG_INCLUDES =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) CONFIG_LIBS =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) CONFIG_FLAGS =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) VERSION = $(EP_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) PATCHLEVEL = $(EP_PATCHLEVEL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) EXTRAVERSION = $(EP_EXTRAVERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) OBJ = $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) N =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) EVENT_PARSE_VERSION = $(EP_VERSION).$(EP_PATCHLEVEL).$(EP_EXTRAVERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) LIB_TARGET = libtraceevent.a libtraceevent.so.$(EVENT_PARSE_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) LIB_INSTALL = libtraceevent.a libtraceevent.so*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) LIB_INSTALL := $(addprefix $(OUTPUT),$(LIB_INSTALL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) INCLUDES = -I. -I $(srctree)/tools/include $(CONFIG_INCLUDES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) # Set compile option CFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) ifdef EXTRA_CFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) CFLAGS := $(EXTRA_CFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) CFLAGS := -g -Wall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) # Append required CFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) override CFLAGS += -fPIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) override CFLAGS += $(udis86-flags) -D_GNU_SOURCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) ifeq ($(VERBOSE),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) Q =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) Q = @
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) # Disable command line variables (CFLAGS) override from top
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) # level Makefile (perf), otherwise build Makefile will get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) # the same command line setup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) MAKEOVERRIDES=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) export srctree OUTPUT CC LD CFLAGS V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) build := -f $(srctree)/tools/build/Makefile.build dir=. obj
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) TE_IN := $(OUTPUT)libtraceevent-in.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) LIB_TARGET := $(addprefix $(OUTPUT),$(LIB_TARGET))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) CMD_TARGETS = $(LIB_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) TARGETS = $(CMD_TARGETS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) all: all_cmd plugins
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) all_cmd: $(CMD_TARGETS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) $(TE_IN): force
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) $(Q)$(MAKE) $(build)=libtraceevent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) $(OUTPUT)libtraceevent.so.$(EVENT_PARSE_VERSION): $(TE_IN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) $(QUIET_LINK)$(CC) --shared $(LDFLAGS) $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) @ln -sf $(@F) $(OUTPUT)libtraceevent.so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) @ln -sf $(@F) $(OUTPUT)libtraceevent.so.$(EP_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) $(OUTPUT)libtraceevent.a: $(TE_IN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) $(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) $(OUTPUT)%.so: $(OUTPUT)%-in.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) $(QUIET_LINK)$(CC) $(CFLAGS) -shared $(LDFLAGS) -nostartfiles -o $@ $^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) define make_version.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) (echo '/* This file is automatically generated. Do not modify. */'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) echo \#define VERSION_CODE $(shell \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) expr $(VERSION) \* 256 + $(PATCHLEVEL)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) echo '#define EXTRAVERSION ' $(EXTRAVERSION); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) echo '#define VERSION_STRING "'$(VERSION).$(PATCHLEVEL).$(EXTRAVERSION)'"'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) echo '#define FILE_VERSION '$(FILE_VERSION); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) ) > $1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) define update_version.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) ($(call make_version.h, $@.tmp); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if [ -r $@ ] && cmp -s $@ $@.tmp; then \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) rm -f $@.tmp; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) echo ' UPDATE $@'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) mv -f $@.tmp $@; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) fi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ep_version.h: force
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) $(Q)$(N)$(call update_version.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) VERSION_FILES = ep_version.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) define update_dir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) (echo $1 > $@.tmp; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) if [ -r $@ ] && cmp -s $@ $@.tmp; then \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) rm -f $@.tmp; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) echo ' UPDATE $@'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) mv -f $@.tmp $@; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) fi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) tags: force
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) $(RM) tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) --regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) TAGS: force
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) $(RM) TAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) find . -name '*.[ch]' | xargs etags \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) --regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) define do_install_mkdir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if [ ! -d '$(DESTDIR_SQ)$1' ]; then \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) define do_install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) $(call do_install_mkdir,$2); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) $(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) PKG_CONFIG_SOURCE_FILE = libtraceevent.pc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) PKG_CONFIG_FILE := $(addprefix $(OUTPUT),$(PKG_CONFIG_SOURCE_FILE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) define do_install_pkgconfig_file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if [ -n "${pkgconfig_dir}" ]; then \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) cp -f ${PKG_CONFIG_SOURCE_FILE}.template ${PKG_CONFIG_FILE}; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) sed -i "s|LIB_VERSION|${EVENT_PARSE_VERSION}|g" ${PKG_CONFIG_FILE}; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) sed -i "s|LIB_DIR|${libdir}|g" ${PKG_CONFIG_FILE}; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) sed -i "s|HEADER_DIR|$(includedir)|g" ${PKG_CONFIG_FILE}; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) $(call do_install,$(PKG_CONFIG_FILE),$(pkgconfig_dir),644); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) (echo Failed to locate pkg-config directory) 1>&2; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) install_lib: all_cmd install_plugins install_headers install_pkgconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) $(call QUIET_INSTALL, $(LIB_TARGET)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) $(call do_install_mkdir,$(libdir_SQ)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) install_pkgconfig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) $(call QUIET_INSTALL, $(PKG_CONFIG_FILE)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) $(call do_install_pkgconfig_file,$(prefix))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) install_headers:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) $(call QUIET_INSTALL, headers) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) $(call do_install,event-parse.h,$(includedir_SQ),644); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) $(call do_install,event-utils.h,$(includedir_SQ),644); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) $(call do_install,trace-seq.h,$(includedir_SQ),644); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) $(call do_install,kbuffer.h,$(includedir_SQ),644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) install: install_lib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) clean: clean_plugins
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) $(call QUIET_CLEAN, libtraceevent) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) $(RM) TRACEEVENT-CFLAGS tags TAGS; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) $(RM) $(PKG_CONFIG_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) PHONY += doc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) doc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) $(call descend,Documentation)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) PHONY += doc-clean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) doc-clean:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) $(call descend,Documentation,clean)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) PHONY += doc-install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) doc-install:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) $(call descend,Documentation,install)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) PHONY += doc-uninstall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) doc-uninstall:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) $(call descend,Documentation,uninstall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) PHONY += help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) help:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) @echo 'Possible targets:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) @echo''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) @echo ' all - default, compile the library and the'\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 'plugins'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) @echo ' plugins - compile the plugins'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) @echo ' install - install the library, the plugins,'\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 'the header and pkgconfig files'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) @echo ' clean - clean the library and the plugins object files'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) @echo ' doc - compile the documentation files - man'\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 'and html pages, in the Documentation directory'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) @echo ' doc-clean - clean the documentation files'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) @echo ' doc-install - install the man pages'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) @echo ' doc-uninstall - uninstall the man pages'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) @echo''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) PHONY += plugins
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) plugins:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) $(call descend,plugins)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) PHONY += install_plugins
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) install_plugins:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) $(call descend,plugins,install)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) PHONY += clean_plugins
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) clean_plugins:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) $(call descend,plugins,clean)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) force:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) # Declare the contents of the .PHONY variable as phony. We keep that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) # information in a variable so we can use it in if_changed and friends.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) .PHONY: $(PHONY)