Commit 1925459b authored by Josh Poimboeuf's avatar Josh Poimboeuf Committed by Arnaldo Carvalho de Melo

tools build: Fix feature Makefile issues with 'O='

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: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/113bd01530e9761778c60a75a96c65fc59860f68.1450193761.git.jpoimboe@redhat.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 7a29c087
...@@ -7,7 +7,7 @@ endif ...@@ -7,7 +7,7 @@ endif
feature_check = $(eval $(feature_check_code)) feature_check = $(eval $(feature_check_code))
define 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 endef
feature_set = $(eval $(feature_set_code)) feature_set = $(eval $(feature_set_code))
......
FILES= \ FILES= \
test-all.bin \ test-all.bin \
test-backtrace.bin \ test-backtrace.bin \
...@@ -38,38 +37,40 @@ FILES= \ ...@@ -38,38 +37,40 @@ FILES= \
test-bpf.bin \ test-bpf.bin \
test-get_cpuid.bin test-get_cpuid.bin
FILES := $(addprefix $(OUTPUT),$(FILES))
CC := $(CROSS_COMPILE)gcc -MD CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config PKG_CONFIG := $(CROSS_COMPILE)pkg-config
all: $(FILES) all: $(FILES)
__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS) __BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
BUILD = $(__BUILD) > $(OUTPUT)$(@:.bin=.make.output) 2>&1 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 $(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) $(BUILD)
test-pthread-attr-setaffinity-np.bin: $(OUTPUT)test-pthread-attr-setaffinity-np.bin:
$(BUILD) -D_GNU_SOURCE -lpthread $(BUILD) -D_GNU_SOURCE -lpthread
test-stackprotector-all.bin: $(OUTPUT)test-stackprotector-all.bin:
$(BUILD) -fstack-protector-all $(BUILD) -fstack-protector-all
test-fortify-source.bin: $(OUTPUT)test-fortify-source.bin:
$(BUILD) -O2 -D_FORTIFY_SOURCE=2 $(BUILD) -O2 -D_FORTIFY_SOURCE=2
test-bionic.bin: $(OUTPUT)test-bionic.bin:
$(BUILD) $(BUILD)
test-libelf.bin: $(OUTPUT)test-libelf.bin:
$(BUILD) -lelf $(BUILD) -lelf
test-glibc.bin: $(OUTPUT)test-glibc.bin:
$(BUILD) $(BUILD)
DWARFLIBS := -ldw DWARFLIBS := -ldw
...@@ -77,37 +78,37 @@ ifeq ($(findstring -static,${LDFLAGS}),-static) ...@@ -77,37 +78,37 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
endif endif
test-dwarf.bin: $(OUTPUT)test-dwarf.bin:
$(BUILD) $(DWARFLIBS) $(BUILD) $(DWARFLIBS)
test-libelf-mmap.bin: $(OUTPUT)test-libelf-mmap.bin:
$(BUILD) -lelf $(BUILD) -lelf
test-libelf-getphdrnum.bin: $(OUTPUT)test-libelf-getphdrnum.bin:
$(BUILD) -lelf $(BUILD) -lelf
test-libnuma.bin: $(OUTPUT)test-libnuma.bin:
$(BUILD) -lnuma $(BUILD) -lnuma
test-numa_num_possible_cpus.bin: $(OUTPUT)test-numa_num_possible_cpus.bin:
$(BUILD) -lnuma $(BUILD) -lnuma
test-libunwind.bin: $(OUTPUT)test-libunwind.bin:
$(BUILD) -lelf $(BUILD) -lelf
test-libunwind-debug-frame.bin: $(OUTPUT)test-libunwind-debug-frame.bin:
$(BUILD) -lelf $(BUILD) -lelf
test-libaudit.bin: $(OUTPUT)test-libaudit.bin:
$(BUILD) -laudit $(BUILD) -laudit
test-libslang.bin: $(OUTPUT)test-libslang.bin:
$(BUILD) -I/usr/include/slang -lslang $(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) $(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) $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
grep-libs = $(filter -l%,$(1)) grep-libs = $(filter -l%,$(1))
...@@ -119,63 +120,63 @@ PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) ...@@ -119,63 +120,63 @@ PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
test-libperl.bin: $(OUTPUT)test-libperl.bin:
$(BUILD) $(FLAGS_PERL_EMBED) $(BUILD) $(FLAGS_PERL_EMBED)
test-libpython.bin: $(OUTPUT)test-libpython.bin:
$(BUILD) $(BUILD)
test-libpython-version.bin: $(OUTPUT)test-libpython-version.bin:
$(BUILD) $(BUILD)
test-libbfd.bin: $(OUTPUT)test-libbfd.bin:
$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
test-liberty.bin: $(OUTPUT)test-liberty.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
test-liberty-z.bin: $(OUTPUT)test-liberty-z.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz $(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 $(BUILD) -liberty
test-backtrace.bin: $(OUTPUT)test-backtrace.bin:
$(BUILD) $(BUILD)
test-timerfd.bin: $(OUTPUT)test-timerfd.bin:
$(BUILD) $(BUILD)
test-libdw-dwarf-unwind.bin: $(OUTPUT)test-libdw-dwarf-unwind.bin:
$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind) $(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) $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
test-sync-compare-and-swap.bin: $(OUTPUT)test-sync-compare-and-swap.bin:
$(BUILD) $(BUILD)
test-compile-32.bin: $(OUTPUT)test-compile-32.bin:
$(CC) -m32 -o $(OUTPUT)$@ test-compile.c $(CC) -m32 -o $@ test-compile.c
test-compile-x32.bin: $(OUTPUT)test-compile-x32.bin:
$(CC) -mx32 -o $(OUTPUT)$@ test-compile.c $(CC) -mx32 -o $@ test-compile.c
test-zlib.bin: $(OUTPUT)test-zlib.bin:
$(BUILD) -lz $(BUILD) -lz
test-lzma.bin: $(OUTPUT)test-lzma.bin:
$(BUILD) -llzma $(BUILD) -llzma
test-get_cpuid.bin: $(OUTPUT)test-get_cpuid.bin:
$(BUILD) $(BUILD)
test-bpf.bin: $(OUTPUT)test-bpf.bin:
$(BUILD) $(BUILD)
-include *.d -include $(OUTPUT)*.d
############################### ###############################
clean: clean:
rm -f $(FILES) *.d $(FILES:.bin=.make.output) rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment