提交 1999307b 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

perf build: Add single target build framework support

Add support to build single targets, like:

 $ make util/map.o    # objects
 $ make util/map.i    # preprocessor
 $ make util/map.s    # assembly
Signed-off-by: NJiri Olsa <jolsa@kernel.org>
Tested-by: NSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Tested-by: NWill Deacon <will.deacon@arm.com>
Cc: Alexis Berlemont <alexis.berlemont@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-tt10y0dmweq6rjaod937rpb4@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 6d8e62c3
...@@ -49,6 +49,12 @@ quiet_cmd_mkdir = MKDIR $(dir $@) ...@@ -49,6 +49,12 @@ quiet_cmd_mkdir = MKDIR $(dir $@)
quiet_cmd_cc_o_c = CC $@ quiet_cmd_cc_o_c = CC $@
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
quiet_cmd_cc_i_c = CPP $@
cmd_cc_i_c = $(CC) $(c_flags) -E -o $@ $<
quiet_cmd_cc_s_c = AS $@
cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $<
# Link agregate command # Link agregate command
# If there's nothing to link, create empty $@ object. # If there's nothing to link, create empty $@ object.
quiet_cmd_ld_multi = LD $@ quiet_cmd_ld_multi = LD $@
...@@ -64,6 +70,18 @@ $(OUTPUT)%.o: %.S FORCE ...@@ -64,6 +70,18 @@ $(OUTPUT)%.o: %.S FORCE
$(call rule_mkdir) $(call rule_mkdir)
$(call if_changed_dep,cc_o_c) $(call if_changed_dep,cc_o_c)
$(OUTPUT)%.i: %.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_i_c)
$(OUTPUT)%.i: %.S FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_i_c)
$(OUTPUT)%.s: %.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_s_c)
# Gather build data: # Gather build data:
# obj-y - list of build objects # obj-y - list of build objects
# subdir-y - list of directories to nest # subdir-y - list of directories to nest
...@@ -100,7 +118,7 @@ FORCE: ...@@ -100,7 +118,7 @@ FORCE:
# Include all cmd files to get all the dependency rules # Include all cmd files to get all the dependency rules
# for all objects included # for all objects included
targets := $(wildcard $(sort $(obj-y) $(in-target))) targets := $(wildcard $(sort $(obj-y) $(in-target) $(MAKECMDGOALS)))
cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
ifneq ($(cmd_files),) ifneq ($(cmd_files),)
......
...@@ -421,16 +421,33 @@ endif ...@@ -421,16 +421,33 @@ endif
# These two need to be here so that when O= is not used they take precedence # These two need to be here so that when O= is not used they take precedence
# over the general rule for .o # over the general rule for .o
$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS # get relative building directory (to $(OUTPUT))
$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $< # and '.' if it's $(OUTPUT) itself
$(OUTPUT)%.i: %.c $(OUTPUT)PERF-CFLAGS __build-dir = $(subst $(OUTPUT),,$(dir $@))
$(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $< build-dir = $(if $(__build-dir),$(__build-dir),.)
$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -S $(CFLAGS) $< single_dep: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
$(OUTPUT)%.o: %.S
$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $< $(OUTPUT)%.o: %.c single_dep FORCE
$(OUTPUT)%.s: %.S @$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
$(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $<
$(OUTPUT)%.i: %.c single_dep FORCE
@$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
$(OUTPUT)%.s: %.c single_dep FORCE
@$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
$(OUTPUT)%-bison.o: %.c single_dep FORCE
@$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
$(OUTPUT)%-flex.o: %.c single_dep FORCE
@$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
$(OUTPUT)%.o: %.S single_dep FORCE
@$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
$(OUTPUT)%.i: %.S single_dep FORCE
@$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
$(OUTPUT)perf-%: %.o $(PERFLIBS) $(OUTPUT)perf-%: %.o $(PERFLIBS)
$(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS) $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
...@@ -675,5 +692,5 @@ FORCE: ...@@ -675,5 +692,5 @@ FORCE:
.PHONY: all install clean config-clean strip install-gtk .PHONY: all install clean config-clean strip install-gtk
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
.PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope .FORCE-PERF-CFLAGS FORCE .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope .FORCE-PERF-CFLAGS FORCE single_dep
...@@ -97,15 +97,19 @@ CFLAGS_config.o += -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" ...@@ -97,15 +97,19 @@ CFLAGS_config.o += -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
CFLAGS_exec_cmd.o += -DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))" -DPREFIX="BUILD_STR($(prefix_SQ))" CFLAGS_exec_cmd.o += -DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))" -DPREFIX="BUILD_STR($(prefix_SQ))"
$(OUTPUT)util/parse-events-flex.c: util/parse-events.l $(OUTPUT)util/parse-events-bison.c $(OUTPUT)util/parse-events-flex.c: util/parse-events.l $(OUTPUT)util/parse-events-bison.c
$(call rule_mkdir)
@$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) util/parse-events.l @$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) util/parse-events.l
$(OUTPUT)util/parse-events-bison.c: util/parse-events.y $(OUTPUT)util/parse-events-bison.c: util/parse-events.y
$(call rule_mkdir)
@$(call echo-cmd,bison)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $@ -p parse_events_ @$(call echo-cmd,bison)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $@ -p parse_events_
$(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c $(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c
$(call rule_mkdir)
@$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/pmu-flex.h util/pmu.l @$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/pmu-flex.h util/pmu.l
$(OUTPUT)util/pmu-bison.c: util/pmu.y $(OUTPUT)util/pmu-bison.c: util/pmu.y
$(call rule_mkdir)
@$(call echo-cmd,bison)$(BISON) -v util/pmu.y -d -o $@ -p perf_pmu_ @$(call echo-cmd,bison)$(BISON) -v util/pmu.y -d -o $@ -p perf_pmu_
CFLAGS_parse-events-flex.o += -w CFLAGS_parse-events-flex.o += -w
...@@ -122,13 +126,17 @@ CFLAGS_hweight.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ET ...@@ -122,13 +126,17 @@ CFLAGS_hweight.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ET
CFLAGS_parse-events.o += -Wno-redundant-decls CFLAGS_parse-events.o += -Wno-redundant-decls
$(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c) $(call if_changed_dep,cc_o_c)
$(OUTPUT)util/find_next_bit.o: ../lib/util/find_next_bit.c FORCE $(OUTPUT)util/find_next_bit.o: ../lib/util/find_next_bit.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c) $(call if_changed_dep,cc_o_c)
$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c FORCE $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c) $(call if_changed_dep,cc_o_c)
$(OUTPUT)util/hweight.o: ../../lib/hweight.c FORCE $(OUTPUT)util/hweight.o: ../../lib/hweight.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c) $(call if_changed_dep,cc_o_c)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册