summaryrefslogtreecommitdiff
path: root/tools/tracing/latency/Makefile
blob: 6518b03e05c71b4fa84498f9628adf81a38c9f56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# SPDX-License-Identifier: GPL-2.0-only

ifeq ($(srctree),)
  srctree	:= $(patsubst %/,%,$(dir $(CURDIR)))
  srctree	:= $(patsubst %/,%,$(dir $(srctree)))
  srctree	:= $(patsubst %/,%,$(dir $(srctree)))
endif

include $(srctree)/tools/scripts/Makefile.include

# O is an alias for OUTPUT
OUTPUT		:= $(O)

ifeq ($(OUTPUT),)
  OUTPUT	:= $(CURDIR)
else
  # subdir is used by the ../Makefile in $(call descend,)
  ifneq ($(subdir),)
    OUTPUT	:= $(OUTPUT)/$(subdir)
  endif
endif

ifneq ($(patsubst %/,,$(lastword $(OUTPUT))),)
  OUTPUT	:= $(OUTPUT)/
endif

LATENCY-COLLECTOR	:= $(OUTPUT)latency-collector
LATENCY-COLLECTOR_IN	:= $(LATENCY-COLLECTOR)-in.o

export CC	:= gcc
export LD	:= ld
export AR	:= ar
export PKG_CONFIG := pkg-config

FEATURE_TESTS	:= libtraceevent
FEATURE_TESTS	+= libtracefs
FEATURE_DISPLAY	:= libtraceevent
FEATURE_DISPLAY	+= libtracefs

ifeq ($(V),1)
  Q 		=
else
  Q 		= @
endif

all: $(LATENCY-COLLECTOR)

include $(srctree)/tools/build/Makefile.include

# check for dependencies only on required targets
NON_CONFIG_TARGETS := clean install

config		:= 1
ifdef MAKECMDGOALS
ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
 config		:= 0
endif
endif

ifeq ($(config),1)
  include $(srctree)/tools/build/Makefile.feature
  include Makefile.config
endif

CFLAGS		+= $(INCLUDES) $(LIB_INCLUDES)

export CFLAGS OUTPUT srctree

$(LATENCY-COLLECTOR): $(LATENCY-COLLECTOR_IN)
	$(QUIET_LINK)$(CC) $(LDFLAGS) -o $(LATENCY-COLLECTOR) $(LATENCY-COLLECTOR_IN) $(EXTLIBS)

latency-collector.%: fixdep FORCE
	make -f $(srctree)/tools/build/Makefile.build dir=. $@

$(LATENCY-COLLECTOR_IN): fixdep FORCE
	make $(build)=latency-collector

INSTALL		:= install
MKDIR		:= mkdir
STRIP		:= strip
BINDIR		:= /usr/bin

install:
	@$(MKDIR) -p $(DESTDIR)$(BINDIR)
	$(call QUIET_INSTALL,latency-collector)$(INSTALL) $(LATENCY-COLLECTOR) -m 755 $(DESTDIR)$(BINDIR)
	@$(STRIP) $(DESTDIR)$(BINDIR)/latency-collector

clean:
	$(call QUIET_CLEAN, latency-collector)
	$(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
	$(Q)@rm -f latency-collector fixdep FEATURE-DUMP
	$(Q)rm -rf feature
.PHONY: FORCE clean install