@@ -159,8 +159,8 @@ generated-files-$(CONFIG_TRACE_UST) += trace-ust-all.c
159159
160160generated-files-y += module_block.h
161161
162- TRACE_HEADERS = trace-root.h $( trace-events-subdirs:%=%/trace.h )
163- TRACE_SOURCES = trace-root.c $( trace-events-subdirs:%=%/trace.c )
162+ TRACE_HEADERS = trace/trace -root.h
163+ TRACE_SOURCES = trace/trace -root.c
164164TRACE_DTRACE =
165165ifdef CONFIG_TRACE_DTRACE
166166TRACE_HEADERS += trace-dtrace-root.h $(trace-events-subdirs:%=%/trace-dtrace.h )
@@ -170,33 +170,37 @@ ifdef CONFIG_TRACE_UST
170170TRACE_HEADERS += trace-ust-root.h $(trace-events-subdirs:%=%/trace-ust.h )
171171endif
172172
173- generated-files-y += $(TRACE_HEADERS )
174- generated-files-y += $(TRACE_SOURCES )
175173generated-files-y += $(BUILD_DIR ) /trace-events-all
176174generated-files-y += .git-submodule-status
177175
178176trace-group-name = $(shell dirname $1 | sed -e 's/[^a-zA-Z0-9]/_/g')
177+ trace-group-suffix = $(shell echo $1 | sed -e 's/[^a-zA-Z0-9]/_/g')
179178
180179tracetool-y = $(SRC_PATH ) /scripts/tracetool.py
181180tracetool-y += $(shell find $(SRC_PATH ) /scripts/tracetool -name "* .py")
182181
183- % /trace.h : % /trace.h-timestamp
184- @cmp $< $@ > /dev/null 2>&1 || cp $< $@
185- % /trace.h-timestamp : $(SRC_PATH ) /% /trace-events $(tracetool-y ) $(BUILD_DIR ) /config-host.mak
182+ define __trace_rules
183+ TRACE_HEADERS += trace/trace-$2.h
184+ TRACE_SOURCES += trace/trace-$2.c
185+ trace-obj-y += trace/trace-$2.o
186+ trace/trace-$2.h: trace/trace-$2.h-timestamp
187+ @cmp $$< $$@ >/dev/null 2>&1 || cp $$< $$@
188+ trace/trace-$2.h-timestamp: $(SRC_PATH ) /$1/trace-events $(tracetool-y ) $(BUILD_DIR ) /config-host.mak
186189 $(call quiet-command,$(TRACETOOL ) \
187- --group=$( call trace-group-name, $@ ) \
190+ --group=$2 \
188191 --format=h \
189192 --backends=$(TRACE_BACKENDS ) \
190- $< > $@ ," GEN" ," $( @:%-timestamp=%) " )
193+ $$ < > $$ @ ,"GEN","$ $(@:%-timestamp=% ) ")
191194
192- % /trace.c : % /trace.c-timestamp
193- @cmp $< $@ > /dev/null 2>&1 || cp $< $@
194- % /trace.c-timestamp : $(SRC_PATH ) /% /trace-events $(tracetool-y ) $(BUILD_DIR ) /config-host.mak
195+ trace /trace-$2 .c: trace /trace-$2 .c-timestamp
196+ @cmp $$ < $$ @ >/dev/null 2>&1 || cp $$< $ $@
197+ trace /trace-$2 .c-timestamp: $(SRC_PATH ) /$1 /trace-events $(tracetool-y ) $(BUILD_DIR ) /config-host.mak
195198 $(call quiet-command,$(TRACETOOL ) \
196- --group=$( call trace-group-name, $@ ) \
199+ --group=$2 \
197200 --format=c \
198201 --backends=$(TRACE_BACKENDS ) \
199- $< > $@ ," GEN" ," $( @:%-timestamp=%) " )
202+ $$< > $$@ ,"GEN","$$(@:%-timestamp=% ) ")
203+ endef
200204
201205% /trace-ust.h : % /trace-ust.h-timestamp
202206 @cmp $< $@ > /dev/null 2>&1 || cp $< $@
@@ -222,18 +226,18 @@ tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
222226% /trace-dtrace.o : % /trace-dtrace.dtrace $(tracetool-y )
223227
224228
225- trace-root.h : trace-root.h-timestamp
229+ trace/trace -root.h : trace/ trace-root.h-timestamp
226230 @cmp $< $@ > /dev/null 2>&1 || cp $< $@
227- trace-root.h-timestamp : $(SRC_PATH ) /trace-events $(tracetool-y ) $(BUILD_DIR ) /config-host.mak
231+ trace/trace -root.h-timestamp : $(SRC_PATH ) /trace-events $(tracetool-y ) $(BUILD_DIR ) /config-host.mak
228232 $(call quiet-command,$(TRACETOOL ) \
229233 --group=root \
230234 --format=h \
231235 --backends=$(TRACE_BACKENDS ) \
232236 $< > $@ ," GEN" ," $( @:%-timestamp=%) " )
233237
234- trace-root.c : trace-root.c-timestamp
238+ trace/trace -root.c : trace/ trace-root.c-timestamp
235239 @cmp $< $@ > /dev/null 2>&1 || cp $< $@
236- trace-root.c-timestamp : $(SRC_PATH ) /trace-events $(tracetool-y ) $(BUILD_DIR ) /config-host.mak
240+ trace/trace -root.c-timestamp : $(SRC_PATH ) /trace-events $(tracetool-y ) $(BUILD_DIR ) /config-host.mak
237241 $(call quiet-command,$(TRACETOOL ) \
238242 --group=root \
239243 --format=c \
@@ -477,6 +481,12 @@ dummy := $(call unnest-vars,, \
477481 common-obj-m \
478482 trace-obj-y)
479483
484+ dummy := $(foreach DIR,$(trace-events-subdirs ) ,$(eval $(call __trace_rules,$(DIR ) ,$(call trace-group-suffix,$(DIR ) ) ) ) )
485+
486+ generated-files-y += $(TRACE_HEADERS )
487+ generated-files-y += $(TRACE_SOURCES )
488+
489+
480490include $(SRC_PATH ) /tests/Makefile.include
481491
482492all : $(DOCS ) $(if $(BUILD_DOCS ) ,sphinxdocs) $(TOOLS ) $(HELPERS-y ) recurse-all modules $(vhost-user-json-y )
0 commit comments