Andi Kleen | 80eeb67 | 2016-09-19 17:39:33 -0300 | [diff] [blame] | 1 | pmu-events-y += pmu-events.o |
Jiada Wang | 7a759cd | 2017-04-09 20:02:37 -0700 | [diff] [blame] | 2 | JDIR = pmu-events/arch/$(SRCARCH) |
Andi Kleen | 80eeb67 | 2016-09-19 17:39:33 -0300 | [diff] [blame] | 3 | JSON = $(shell [ -d $(JDIR) ] && \ |
| 4 | find $(JDIR) -name '*.json' -o -name 'mapfile.csv') |
John Garry | 517db3b | 2021-08-03 08:44:09 +0100 | [diff] [blame] | 5 | JDIR_TEST = pmu-events/arch/test |
| 6 | JSON_TEST = $(shell [ -d $(JDIR_TEST) ] && \ |
| 7 | find $(JDIR_TEST) -name '*.json') |
Ian Rogers | 00facc7 | 2022-06-29 11:25:04 -0700 | [diff] [blame] | 8 | JEVENTS_PY = pmu-events/jevents.py |
Ian Rogers | b777b3d | 2023-01-26 15:36:45 -0800 | [diff] [blame] | 9 | METRIC_PY = pmu-events/metric.py |
| 10 | METRIC_TEST_PY = pmu-events/metric_test.py |
| 11 | EMPTY_PMU_EVENTS_C = pmu-events/empty-pmu-events.c |
| 12 | PMU_EVENTS_C = $(OUTPUT)pmu-events/pmu-events.c |
| 13 | METRIC_TEST_LOG = $(OUTPUT)pmu-events/metric_test.log |
John Garry | e9d32c1 | 2018-03-08 18:58:32 +0800 | [diff] [blame] | 14 | |
Ian Rogers | b4f0466 | 2022-08-04 15:18:02 -0700 | [diff] [blame] | 15 | ifeq ($(JEVENTS_ARCH),) |
| 16 | JEVENTS_ARCH=$(SRCARCH) |
| 17 | endif |
Ian Rogers | 5a09b1f | 2023-01-26 15:36:41 -0800 | [diff] [blame] | 18 | JEVENTS_MODEL ?= all |
Ian Rogers | b4f0466 | 2022-08-04 15:18:02 -0700 | [diff] [blame] | 19 | |
Andi Kleen | 80eeb67 | 2016-09-19 17:39:33 -0300 | [diff] [blame] | 20 | # |
| 21 | # Locate/process JSON files in pmu-events/arch/ |
| 22 | # directory and create tables in pmu-events.c. |
| 23 | # |
Ian Rogers | 00facc7 | 2022-06-29 11:25:04 -0700 | [diff] [blame] | 24 | |
| 25 | ifeq ($(NO_JEVENTS),1) |
Ian Rogers | b777b3d | 2023-01-26 15:36:45 -0800 | [diff] [blame] | 26 | $(PMU_EVENTS_C): $(EMPTY_PMU_EVENTS_C) |
Ian Rogers | 00facc7 | 2022-06-29 11:25:04 -0700 | [diff] [blame] | 27 | $(call rule_mkdir) |
| 28 | $(Q)$(call echo-cmd,gen)cp $< $@ |
| 29 | else |
Ian Rogers | b777b3d | 2023-01-26 15:36:45 -0800 | [diff] [blame] | 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) |
Ian Rogers | 00facc7 | 2022-06-29 11:25:04 -0700 | [diff] [blame] | 35 | $(call rule_mkdir) |
Ian Rogers | 5a09b1f | 2023-01-26 15:36:41 -0800 | [diff] [blame] | 36 | $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) pmu-events/arch $@ |
Ian Rogers | 00facc7 | 2022-06-29 11:25:04 -0700 | [diff] [blame] | 37 | endif |
Namhyung Kim | 7822a89 | 2023-07-27 19:24:46 -0700 | [diff] [blame] | 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) |