xref: /linux/tools/perf/pmu-events/Build (revision e7d759f31ca295d589f7420719c311870bb3166f)
1pmu-events-y	+= pmu-events.o
2JDIR		=  pmu-events/arch/$(SRCARCH)
3JSON		=  $(shell [ -d $(JDIR) ] &&				\
4			find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
5JDIR_TEST	=  pmu-events/arch/test
6JSON_TEST	=  $(shell [ -d $(JDIR_TEST) ] &&			\
7			find $(JDIR_TEST) -name '*.json')
8JEVENTS_PY	=  pmu-events/jevents.py
9METRIC_PY	=  pmu-events/metric.py
10METRIC_TEST_PY	=  pmu-events/metric_test.py
11EMPTY_PMU_EVENTS_C = pmu-events/empty-pmu-events.c
12PMU_EVENTS_C	=  $(OUTPUT)pmu-events/pmu-events.c
13METRIC_TEST_LOG	=  $(OUTPUT)pmu-events/metric_test.log
14
15ifeq ($(JEVENTS_ARCH),)
16JEVENTS_ARCH=$(SRCARCH)
17endif
18JEVENTS_MODEL ?= all
19
20#
21# Locate/process JSON files in pmu-events/arch/
22# directory and create tables in pmu-events.c.
23#
24
25ifeq ($(NO_JEVENTS),1)
26$(PMU_EVENTS_C): $(EMPTY_PMU_EVENTS_C)
27	$(call rule_mkdir)
28	$(Q)$(call echo-cmd,gen)cp $< $@
29else
30$(METRIC_TEST_LOG): $(METRIC_TEST_PY) $(METRIC_PY)
31	$(call rule_mkdir)
32	$(Q)$(call echo-cmd,test)$(PYTHON) $< 2> $@ || (cat $@ && false)
33
34$(PMU_EVENTS_C): $(JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_TEST_LOG)
35	$(call rule_mkdir)
36	$(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) pmu-events/arch $@
37endif
38
39# pmu-events.c file is generated in the OUTPUT directory so it needs a
40# separate rule to depend on it properly
41$(OUTPUT)pmu-events/pmu-events.o: $(PMU_EVENTS_C)
42	$(call rule_mkdir)
43	$(call if_changed_dep,cc_o_c)
44