[<prev] [next>] [day] [month] [year] [list]
Message-Id: <4FAA3CBA02000078000826DD@nat28.tlf.novell.com>
Date: Wed, 09 May 2012 08:45:30 +0100
From: "Jan Beulich" <JBeulich@...e.com>
To: <a.p.zijlstra@...llo.nl>, <mingo@...e.hu>,
<acme@...stprotocols.net>, <paulus@...ba.org>
Cc: <linux-kernel@...r.kernel.org>
Subject: [PATCH] perf: generalize makefile
As indicated before, in order to be able to consistently build
individual object, pre-processed, or assembly files under tools/perf/,
the make logic needs to be adjusted: Commands should only come from
pattern rules, and individual targets should merely override compiler
flags. This requires the introduction of a single additional stub
source file (so the pattern rules would cover the respective object or
intermediate file generation).
Further, adjust some dependencies to actually have the intended effect
of re-building in case of them having got touched, also requiring some
re-ordering within the file.
Additionally omit the (redundant and confusing) $(OUTPUT)/ portion of
the build progress messages (just like the normal kernel build does).
Signed-off-by: Jan Beulich <jbeulich@...e.com>
---
tools/perf/Makefile | 135 ++++++++++++++++++++++-------------------------
tools/perf/util/rbtree.c | 1
2 files changed, 65 insertions(+), 71 deletions(-)
--- 3.4-rc6/tools/perf/Makefile
+++ 3.4-rc6-perf-makefile-generalize/tools/perf/Makefile
@@ -189,7 +189,7 @@ BASIC_LDFLAGS =
BUILTIN_OBJS =
LIB_H =
LIB_OBJS =
-PYRF_OBJS =
+PYRF_SRC =
SCRIPT_SH =
SCRIPT_SH += perf-archive.sh
@@ -200,16 +200,11 @@ strip-libs = $(filter-out -l%,$(1))
PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py
-$(OUTPUT)python/perf.so: $(PYRF_OBJS) $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
- $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \
- --quiet build_ext; \
- mkdir -p $(OUTPUT)python && \
- cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
#
# No Perl scripts right now:
#
-SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
+SCRIPTS = $(patsubst %.sh,$(OUTPUT)%,$(SCRIPT_SH))
#
# Single 'perf' binary right now:
@@ -436,14 +431,14 @@ PERFLIBS = $(LIB_FILE)
# This has to be in sync with what is in the 'sources' variable in
# tools/perf/util/setup.py
-PYRF_OBJS += $(OUTPUT)util/cpumap.o
-PYRF_OBJS += $(OUTPUT)util/ctype.o
-PYRF_OBJS += $(OUTPUT)util/evlist.o
-PYRF_OBJS += $(OUTPUT)util/evsel.o
-PYRF_OBJS += $(OUTPUT)util/python.o
-PYRF_OBJS += $(OUTPUT)util/thread_map.o
-PYRF_OBJS += $(OUTPUT)util/util.o
-PYRF_OBJS += $(OUTPUT)util/xyarray.o
+PYRF_SRC += util/cpumap.c
+PYRF_SRC += util/ctype.c
+PYRF_SRC += util/evlist.c
+PYRF_SRC += util/evsel.c
+PYRF_SRC += util/python.c
+PYRF_SRC += util/thread_map.c
+PYRF_SRC += util/util.c
+PYRF_SRC += util/xyarray.c
#
# Platform specific tweaks
@@ -680,13 +675,13 @@ endif
ifneq ($(findstring $(MAKEFLAGS),s),s)
ifndef V
- QUIET_CC = @echo ' ' CC $@;
- QUIET_AR = @echo ' ' AR $@;
- QUIET_LINK = @echo ' ' LINK $@;
- QUIET_MKDIR = @echo ' ' MKDIR $@;
- QUIET_GEN = @echo ' ' GEN $@;
- QUIET_FLEX = @echo ' ' FLEX $@;
- QUIET_BISON = @echo ' ' BISON $@;
+ QUIET_CC = @echo ' ' CC $(patsubst $(OUTPUT)%,%,$@);
+ QUIET_AR = @echo ' ' AR $(patsubst $(OUTPUT)%,%,$@);
+ QUIET_LINK = @echo ' ' LINK $(patsubst $(OUTPUT)%,%,$@);
+ QUIET_MKDIR = @echo ' ' MKDIR $(patsubst $(OUTPUT)%,%,$@);
+ QUIET_GEN = @echo ' ' GEN $(patsubst $(OUTPUT)%,%,$@);
+ QUIET_FLEX = @echo ' ' FLEX $(patsubst $(OUTPUT)%,%,$@);
+ QUIET_BISON = @echo ' ' BISON $(patsubst $(OUTPUT)%,%,$@);
endif
endif
@@ -733,39 +728,22 @@ shell_compatibility_test: please_set_SHE
strip: $(PROGRAMS) $(OUTPUT)perf
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
-$(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -DPERF_VERSION='"$(PERF_VERSION)"' \
- '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
- $(ALL_CFLAGS) -c $(filter %.c,$^) -o $@
-
$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \
$(BUILTIN_OBJS) $(LIBS) -o $@
-$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
- '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
- '-DPERF_MAN_PATH="$(mandir_SQ)"' \
- '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
-
-$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
- '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
- '-DPERF_MAN_PATH="$(mandir_SQ)"' \
- '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
+$(OUTPUT)python/perf.so: $(PYRF_SRC) $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
+ $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \
+ --$(if $(V),verbose,quiet) build_ext; \
+ mkdir -p $(@D) && mv $(PYTHON_EXTBUILD_LIB)perf.so $(@D)/
$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
-$(SCRIPTS) : % : %.sh
- $(QUIET_GEN)$(INSTALL) '$@...' '$(OUTPUT)$@'
-
-# These can record PERF_VERSION
-$(OUTPUT)perf.o perf.spec \
- $(SCRIPTS) \
- : $(OUTPUT)PERF-VERSION-FILE
+$(SCRIPTS) : $(OUTPUT)% : %.sh
+ $(QUIET_GEN)$(INSTALL) '$<' '$@'
.SUFFIXES:
.SUFFIXES: .o .c .S .s
@@ -790,42 +768,57 @@ $(OUTPUT)%.o: %.S
$(OUTPUT)%.s: %.S
$(QUIET_CC)$(CC) -o $@ -E $(ALL_CFLAGS) $<
-$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \
- '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
- '-DBINDIR="$(bindir_relative_SQ)"' \
- '-DPREFIX="$(prefix_SQ)"' \
- $<
+ifneq ($(OUTPUT),)
+PHONY_ALL := $(filter (OUTPUT)%,$(ALL_PROGRAMS) $(LANG_BINDINGS))
+PHONY_OBJS := $(patsubst $(OUTPUT)%,%,$(BUILTIN_OBJS) $(LIB_OBJS))
+PHONY_ASMS := $(patsubst %.o,%.s,$(PHONY_OBJS))
+PHONY_CPPS := $(patsubst %.o,%.i,$(PHONY_OBJS))
+PHONY_ALL += $(PHONY_OBJS) $(PHONY_ASMS) $(PHONY_CPPS)
+.PHONY: $(PHONY_ALL)
+$(PHONY_ALL): %: $(OUTPUT)%
+endif
+
+output = $(foreach ext,o i s,$(OUTPUT)$(1).$(ext))
+
+# These can record PERF_VERSION
+$(call output,perf) $(SCRIPTS): $(OUTPUT)PERF-VERSION-FILE
-$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
+$(call output,perf) $(call output,builtin-help): $(OUTPUT)common-cmds.h
-$(OUTPUT)util/ui/browser.o: util/ui/browser.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
+$(call output,perf): ALL_CFLAGS += '-DPERF_VERSION="$(PERF_VERSION)"' \
+ '-DPERF_HTML_PATH="$(htmldir_SQ)"'
-$(OUTPUT)util/ui/browsers/annotate.o: util/ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
+$(call output,builtin-help) $(call output,builtin-timechart): ALL_CFLAGS += \
+ '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
+ '-DPERF_MAN_PATH="$(mandir_SQ)"' \
+ '-DPERF_INFO_PATH="$(infodir_SQ)"'
+
+$(call output,util/exec_cmd): ALL_CFLAGS += \
+ '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
+ '-DBINDIR="$(bindir_relative_SQ)"' \
+ '-DPREFIX="$(prefix_SQ)"'
-$(OUTPUT)util/ui/browsers/hists.o: util/ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
+$(call output,util/config) $(call output,util/rbtree): ALL_CFLAGS += \
+ '-DETC_PERFCONFIG="$(ETC_PERFCONFIG_SQ)"'
-$(OUTPUT)util/ui/browsers/map.o: util/ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<
+$(call output,util/rbtree): ../../lib/rbtree.c
-$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
+$(call output,util/ui/browser) $(call output,util/ui/browsers/annotate) \
+ $(call output,util/ui/browsers/hists) \
+ $(call output,util/ui/browsers/map): ALL_CFLAGS += \
+ -DENABLE_SLFUTURE_CONST
-$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
+$(call output,util/scripting-engines/trace-event-perl): ALL_CFLAGS += \
+ $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow
-$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
+$(call output,scripts/perl/Perf-Trace-Util/Context): ALL_CFLAGS += \
+ $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs
-$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
+$(call output,util/scripting-engines/trace-event-python): ALL_CFLAGS += \
+ $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow
-$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
+$(call output,scripts/python/Perf-Trace-Util/Context): ALL_CFLAGS += \
+ $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs
$(OUTPUT)perf-%: %.o $(PERFLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
--- /home/jbeulich/tmp/linux-3.4-rc6/tools/perf/util/rbtree.c 1970-01-01 01:00:00.000000000 +0100
+++ 3.4-rc6-perf-makefile-generalize/tools/perf/util/rbtree.c
@@ -0,0 +1 @@
+#include "../../../lib/rbtree.c"
View attachment "linux-3.4-rc6-perf-makefile-generalize.patch" of type "text/plain" (9899 bytes)
Powered by blists - more mailing lists