1# SPDX-License-Identifier: GPL-2.0-only 2 3ifeq ($(srctree),) 4 srctree := $(patsubst %/,%,$(dir $(CURDIR))) 5 srctree := $(patsubst %/,%,$(dir $(srctree))) 6 srctree := $(patsubst %/,%,$(dir $(srctree))) 7endif 8 9include $(srctree)/tools/scripts/Makefile.include 10 11# O is an alias for OUTPUT 12OUTPUT := $(O) 13 14ifeq ($(OUTPUT),) 15 OUTPUT := $(CURDIR) 16else 17 # subdir is used by the ../Makefile in $(call descend,) 18 ifneq ($(subdir),) 19 OUTPUT := $(OUTPUT)/$(subdir) 20 endif 21endif 22 23ifneq ($(patsubst %/,,$(lastword $(OUTPUT))),) 24 OUTPUT := $(OUTPUT)/ 25endif 26 27LATENCY-COLLECTOR := $(OUTPUT)latency-collector 28LATENCY-COLLECTOR_IN := $(LATENCY-COLLECTOR)-in.o 29 30export CC := gcc 31export LD := ld 32export AR := ar 33export PKG_CONFIG := pkg-config 34 35FEATURE_TESTS := libtraceevent 36FEATURE_TESTS += libtracefs 37FEATURE_DISPLAY := libtraceevent 38FEATURE_DISPLAY += libtracefs 39 40ifeq ($(V),1) 41 Q = 42else 43 Q = @ 44endif 45 46all: $(LATENCY-COLLECTOR) 47 48include $(srctree)/tools/build/Makefile.include 49 50# check for dependencies only on required targets 51NON_CONFIG_TARGETS := clean install 52 53config := 1 54ifdef MAKECMDGOALS 55ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),) 56 config := 0 57endif 58endif 59 60ifeq ($(config),1) 61 include $(srctree)/tools/build/Makefile.feature 62 include Makefile.config 63endif 64 65CFLAGS += $(INCLUDES) $(LIB_INCLUDES) 66 67export CFLAGS OUTPUT srctree 68 69$(LATENCY-COLLECTOR): $(LATENCY-COLLECTOR_IN) 70 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $(LATENCY-COLLECTOR) $(LATENCY-COLLECTOR_IN) $(EXTLIBS) 71 72latency-collector.%: fixdep FORCE 73 make -f $(srctree)/tools/build/Makefile.build dir=. $@ 74 75$(LATENCY-COLLECTOR_IN): fixdep FORCE 76 make $(build)=latency-collector 77 78INSTALL := install 79MKDIR := mkdir 80STRIP := strip 81BINDIR := /usr/bin 82 83install: 84 @$(MKDIR) -p $(DESTDIR)$(BINDIR) 85 $(call QUIET_INSTALL,latency-collector)$(INSTALL) $(LATENCY-COLLECTOR) -m 755 $(DESTDIR)$(BINDIR) 86 @$(STRIP) $(DESTDIR)$(BINDIR)/latency-collector 87 88clean: 89 $(call QUIET_CLEAN, latency-collector) 90 $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete 91 $(Q)@rm -f latency-collector fixdep FEATURE-DUMP 92 $(Q)rm -rf feature 93.PHONY: FORCE clean install 94