linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-kernel@vger.kernel.org, Namhyung Kim <namhyung@kernel.org>
Subject: [PATCH v3.2] tools build: Fix feature Makefile issues with 'O='
Date: Mon, 14 Dec 2015 12:32:09 -0600	[thread overview]
Message-ID: <20151214183209.GH11552@treble.redhat.com> (raw)
In-Reply-To: <20151214155528.GA1696@krava.brq.redhat.com>

When building perf binaries outside the source tree with 'make O=<dir>',
the auto-detected features get re-tested for every build, which is
unnecessary and inconsistent with the behavior seen when building
directly in the source tree.

Another issue is that 'make O=<dir> clean' doesn't remove the feature
files from the object tree.

Fix these problems by looking for the binaries in the $(OUTPUT)
directory.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
---
v3.2: add changelog

 tools/build/Makefile.feature |  2 +-
 tools/build/feature/Makefile | 93 ++++++++++++++++++++++----------------------
 2 files changed, 48 insertions(+), 47 deletions(-)

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index b8c31ec..6c0519d 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -7,7 +7,7 @@ endif
 
 feature_check = $(eval $(feature_check_code))
 define feature_check_code
-  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
+  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
 endef
 
 feature_set = $(eval $(feature_set_code))
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index cea04ce9..bf8f035 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -1,4 +1,3 @@
-
 FILES=					\
 	test-all.bin			\
 	test-backtrace.bin		\
@@ -38,38 +37,40 @@ FILES=					\
 	test-bpf.bin			\
 	test-get_cpuid.bin
 
+FILES := $(addprefix $(OUTPUT),$(FILES))
+
 CC := $(CROSS_COMPILE)gcc -MD
 PKG_CONFIG := $(CROSS_COMPILE)pkg-config
 
 all: $(FILES)
 
-__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
-  BUILD = $(__BUILD) > $(OUTPUT)$(@:.bin=.make.output) 2>&1
+__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
+  BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
 
 ###############################
 
-test-all.bin:
+$(OUTPUT)test-all.bin:
 	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma
 
-test-hello.bin:
+$(OUTPUT)test-hello.bin:
 	$(BUILD)
 
-test-pthread-attr-setaffinity-np.bin:
+$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
 	$(BUILD) -D_GNU_SOURCE -lpthread
 
-test-stackprotector-all.bin:
+$(OUTPUT)test-stackprotector-all.bin:
 	$(BUILD) -fstack-protector-all
 
-test-fortify-source.bin:
+$(OUTPUT)test-fortify-source.bin:
 	$(BUILD) -O2 -D_FORTIFY_SOURCE=2
 
-test-bionic.bin:
+$(OUTPUT)test-bionic.bin:
 	$(BUILD)
 
-test-libelf.bin:
+$(OUTPUT)test-libelf.bin:
 	$(BUILD) -lelf
 
-test-glibc.bin:
+$(OUTPUT)test-glibc.bin:
 	$(BUILD)
 
 DWARFLIBS := -ldw
@@ -77,37 +78,37 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
 DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
 endif
 
-test-dwarf.bin:
+$(OUTPUT)test-dwarf.bin:
 	$(BUILD) $(DWARFLIBS)
 
-test-libelf-mmap.bin:
+$(OUTPUT)test-libelf-mmap.bin:
 	$(BUILD) -lelf
 
-test-libelf-getphdrnum.bin:
+$(OUTPUT)test-libelf-getphdrnum.bin:
 	$(BUILD) -lelf
 
-test-libnuma.bin:
+$(OUTPUT)test-libnuma.bin:
 	$(BUILD) -lnuma
 
-test-numa_num_possible_cpus.bin:
+$(OUTPUT)test-numa_num_possible_cpus.bin:
 	$(BUILD) -lnuma
 
-test-libunwind.bin:
+$(OUTPUT)test-libunwind.bin:
 	$(BUILD) -lelf
 
-test-libunwind-debug-frame.bin:
+$(OUTPUT)test-libunwind-debug-frame.bin:
 	$(BUILD) -lelf
 
-test-libaudit.bin:
+$(OUTPUT)test-libaudit.bin:
 	$(BUILD) -laudit
 
-test-libslang.bin:
+$(OUTPUT)test-libslang.bin:
 	$(BUILD) -I/usr/include/slang -lslang
 
-test-gtk2.bin:
+$(OUTPUT)test-gtk2.bin:
 	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
 
-test-gtk2-infobar.bin:
+$(OUTPUT)test-gtk2-infobar.bin:
 	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
 
 grep-libs  = $(filter -l%,$(1))
@@ -119,63 +120,63 @@ PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
 PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
 
-test-libperl.bin:
+$(OUTPUT)test-libperl.bin:
 	$(BUILD) $(FLAGS_PERL_EMBED)
 
-test-libpython.bin:
+$(OUTPUT)test-libpython.bin:
 	$(BUILD)
 
-test-libpython-version.bin:
+$(OUTPUT)test-libpython-version.bin:
 	$(BUILD)
 
-test-libbfd.bin:
+$(OUTPUT)test-libbfd.bin:
 	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
 
-test-liberty.bin:
-	$(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
+$(OUTPUT)test-liberty.bin:
+	$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
 
-test-liberty-z.bin:
-	$(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
+$(OUTPUT)test-liberty-z.bin:
+	$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
 
-test-cplus-demangle.bin:
+$(OUTPUT)test-cplus-demangle.bin:
 	$(BUILD) -liberty
 
-test-backtrace.bin:
+$(OUTPUT)test-backtrace.bin:
 	$(BUILD)
 
-test-timerfd.bin:
+$(OUTPUT)test-timerfd.bin:
 	$(BUILD)
 
-test-libdw-dwarf-unwind.bin:
+$(OUTPUT)test-libdw-dwarf-unwind.bin:
 	$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
 
-test-libbabeltrace.bin:
+$(OUTPUT)test-libbabeltrace.bin:
 	$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
 
-test-sync-compare-and-swap.bin:
+$(OUTPUT)test-sync-compare-and-swap.bin:
 	$(BUILD)
 
-test-compile-32.bin:
-	$(CC) -m32 -o $(OUTPUT)$@ test-compile.c
+$(OUTPUT)test-compile-32.bin:
+	$(CC) -m32 -o $@ test-compile.c
 
-test-compile-x32.bin:
-	$(CC) -mx32 -o $(OUTPUT)$@ test-compile.c
+$(OUTPUT)test-compile-x32.bin:
+	$(CC) -mx32 -o $@ test-compile.c
 
-test-zlib.bin:
+$(OUTPUT)test-zlib.bin:
 	$(BUILD) -lz
 
-test-lzma.bin:
+$(OUTPUT)test-lzma.bin:
 	$(BUILD) -llzma
 
-test-get_cpuid.bin:
+$(OUTPUT)test-get_cpuid.bin:
 	$(BUILD)
 
-test-bpf.bin:
+$(OUTPUT)test-bpf.bin:
 	$(BUILD)
 
--include *.d
+-include $(OUTPUT)*.d
 
 ###############################
 
 clean:
-	rm -f $(FILES) *.d $(FILES:.bin=.make.output)
+	rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)
-- 
2.4.3


  parent reply	other threads:[~2015-12-14 18:32 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-14  4:18 [PATCH v3 00/17] perf tools: Move perf subcommand framework to a library Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 01/17] perf build: Remove unnecessary line in Makefile.feature Josh Poimboeuf
2015-12-14 10:05   ` Jiri Olsa
2015-12-14 15:16     ` Arnaldo Carvalho de Melo
2015-12-18  8:47   ` [tip:perf/core] " tip-bot for Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 02/17] tools build: Fix feature Makefile dependencies for 'O=' Josh Poimboeuf
2015-12-14 10:08   ` Jiri Olsa
2015-12-14 14:02     ` Josh Poimboeuf
2015-12-14 14:29       ` [PATCH v3.1 " Josh Poimboeuf
2015-12-14 15:16         ` Arnaldo Carvalho de Melo
2015-12-14 15:29         ` Jiri Olsa
2015-12-14 15:38           ` Josh Poimboeuf
2015-12-14 15:55             ` Jiri Olsa
2015-12-14 16:03               ` Josh Poimboeuf
2015-12-14 18:32               ` Josh Poimboeuf [this message]
2015-12-14  4:18 ` [PATCH v3 03/17] perf test: Add Build file to dependencies for llvm-src-*.c Josh Poimboeuf
2015-12-14 10:10   ` Jiri Olsa
2015-12-14 15:17     ` Arnaldo Carvalho de Melo
2015-12-18  8:47   ` [tip:perf/core] " tip-bot for Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 04/17] perf test: remove tarpkg at end of test Josh Poimboeuf
2015-12-18  8:48   ` [tip:perf/core] perf test: Remove " tip-bot for Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 05/17] perf build: Fix 'make clean' Josh Poimboeuf
2015-12-14 10:14   ` Jiri Olsa
2015-12-14 15:18     ` Arnaldo Carvalho de Melo
2015-12-18  8:48   ` [tip:perf/core] " tip-bot for Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 06/17] perf build: Rename LIB_PATH -> API_PATH Josh Poimboeuf
2015-12-14 10:34   ` Jiri Olsa
2015-12-14 15:19     ` Arnaldo Carvalho de Melo
2015-12-18  8:49   ` [tip:perf/core] " tip-bot for Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 07/17] perf: Create pager.h Josh Poimboeuf
2015-12-18  8:49   ` [tip:perf/core] perf tools: " tip-bot for Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 08/17] perf: Remove check for unused PERF_PAGER_IN_USE Josh Poimboeuf
2015-12-18  8:49   ` [tip:perf/core] perf tools: " tip-bot for Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 09/17] perf: Move help_unknown_cmd() to its own file Josh Poimboeuf
2015-12-18  8:50   ` [tip:perf/core] perf tools: " tip-bot for Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 10/17] perf: Provide subcmd configuration at runtime Josh Poimboeuf
2015-12-14 10:33   ` Jiri Olsa
2015-12-14 14:06     ` Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 11/17] perf: Remove 'perf' from subcmd function and variable names Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 12/17] perf: Convert parse-options.c internal functions to static Josh Poimboeuf
2015-12-18  8:50   ` [tip:perf/core] perf tools: " tip-bot for Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 13/17] perf: Document the fact that parse_options*() may exit Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 14/17] perf: Remove subcmd dependencies on strbuf Josh Poimboeuf
2015-12-14 10:25   ` Jiri Olsa
2015-12-14 14:11     ` Josh Poimboeuf
2015-12-14 15:44   ` Arnaldo Carvalho de Melo
2015-12-14 16:05     ` Josh Poimboeuf
2015-12-14 17:50       ` Arnaldo Carvalho de Melo
2015-12-14 18:04         ` Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 15/17] perf: Finalize subcmd independence Josh Poimboeuf
2015-12-14 10:32   ` Jiri Olsa
2015-12-14 14:13     ` Josh Poimboeuf
2015-12-14 15:27       ` Jiri Olsa
2015-12-14 15:51       ` Arnaldo Carvalho de Melo
2015-12-14  4:18 ` [PATCH v3 16/17] perf subcmd: Create subcmd library Josh Poimboeuf
2015-12-14  4:18 ` [PATCH v3 17/17] tools subcmd: Rename subcmd header include guards Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151214183209.GH11552@treble.redhat.com \
    --to=jpoimboe@redhat.com \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).