blob: 1d18bb89402e62cfc86b4e680fbb0c1eaff35551 [file] [log] [blame]
Andi Kleen80eeb672016-09-19 17:39:33 -03001pmu-events-y += pmu-events.o
Jiada Wang7a759cd2017-04-09 20:02:37 -07002JDIR = pmu-events/arch/$(SRCARCH)
Andi Kleen80eeb672016-09-19 17:39:33 -03003JSON = $(shell [ -d $(JDIR) ] && \
4 find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
John Garry517db3b2021-08-03 08:44:09 +01005JDIR_TEST = pmu-events/arch/test
6JSON_TEST = $(shell [ -d $(JDIR_TEST) ] && \
7 find $(JDIR_TEST) -name '*.json')
Ian Rogers00facc72022-06-29 11:25:04 -07008JEVENTS_PY = pmu-events/jevents.py
Ian Rogersb777b3d2023-01-26 15:36:45 -08009METRIC_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
John Garrye9d32c12018-03-08 18:58:32 +080014
Ian Rogersb4f04662022-08-04 15:18:02 -070015ifeq ($(JEVENTS_ARCH),)
16JEVENTS_ARCH=$(SRCARCH)
17endif
Ian Rogers5a09b1f2023-01-26 15:36:41 -080018JEVENTS_MODEL ?= all
Ian Rogersb4f04662022-08-04 15:18:02 -070019
Andi Kleen80eeb672016-09-19 17:39:33 -030020#
21# Locate/process JSON files in pmu-events/arch/
22# directory and create tables in pmu-events.c.
23#
Ian Rogers00facc72022-06-29 11:25:04 -070024
25ifeq ($(NO_JEVENTS),1)
Ian Rogersb777b3d2023-01-26 15:36:45 -080026$(PMU_EVENTS_C): $(EMPTY_PMU_EVENTS_C)
Ian Rogers00facc72022-06-29 11:25:04 -070027 $(call rule_mkdir)
28 $(Q)$(call echo-cmd,gen)cp $< $@
29else
Ian Rogersb777b3d2023-01-26 15:36:45 -080030$(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)
Ian Rogers00facc72022-06-29 11:25:04 -070035 $(call rule_mkdir)
Ian Rogers5a09b1f2023-01-26 15:36:41 -080036 $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) pmu-events/arch $@
Ian Rogers00facc72022-06-29 11:25:04 -070037endif
Namhyung Kim7822a892023-07-27 19:24:46 -070038
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)