diff options
| author | Josh Poimboeuf <jpoimboe@redhat.com> | 2015-12-15 10:39:32 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-12-16 13:31:33 -0500 |
| commit | 1925459b4d92d92e62d67ddc763cda650d2aa79c (patch) | |
| tree | aceb17bc00a469f16704fccd8c8fbc4eb7c0fe27 | |
| parent | 7a29c087ff80f5d534bd6729c852099fc572c8d0 (diff) | |
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: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Jiri 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.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | tools/build/Makefile.feature | 2 | ||||
| -rw-r--r-- | 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 b8c31ece2d96..6c0519de765d 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature | |||
| @@ -7,7 +7,7 @@ endif | |||
| 7 | 7 | ||
| 8 | feature_check = $(eval $(feature_check_code)) | 8 | feature_check = $(eval $(feature_check_code)) |
| 9 | define feature_check_code | 9 | define feature_check_code |
| 10 | 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) | 10 | 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) |
| 11 | endef | 11 | endef |
| 12 | 12 | ||
| 13 | feature_set = $(eval $(feature_set_code)) | 13 | feature_set = $(eval $(feature_set_code)) |
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index cea04ce9f35c..bf8f0352264d 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile | |||
| @@ -1,4 +1,3 @@ | |||
| 1 | |||
| 2 | FILES= \ | 1 | FILES= \ |
| 3 | test-all.bin \ | 2 | test-all.bin \ |
| 4 | test-backtrace.bin \ | 3 | test-backtrace.bin \ |
| @@ -38,38 +37,40 @@ FILES= \ | |||
| 38 | test-bpf.bin \ | 37 | test-bpf.bin \ |
| 39 | test-get_cpuid.bin | 38 | test-get_cpuid.bin |
| 40 | 39 | ||
| 40 | FILES := $(addprefix $(OUTPUT),$(FILES)) | ||
| 41 | |||
| 41 | CC := $(CROSS_COMPILE)gcc -MD | 42 | CC := $(CROSS_COMPILE)gcc -MD |
| 42 | PKG_CONFIG := $(CROSS_COMPILE)pkg-config | 43 | PKG_CONFIG := $(CROSS_COMPILE)pkg-config |
| 43 | 44 | ||
| 44 | all: $(FILES) | 45 | all: $(FILES) |
| 45 | 46 | ||
| 46 | __BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS) | 47 | __BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS) |
| 47 | BUILD = $(__BUILD) > $(OUTPUT)$(@:.bin=.make.output) 2>&1 | 48 | BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1 |
| 48 | 49 | ||
| 49 | ############################### | 50 | ############################### |
| 50 | 51 | ||
| 51 | test-all.bin: | 52 | $(OUTPUT)test-all.bin: |
| 52 | $(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 | 53 | $(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 |
| 53 | 54 | ||
| 54 | test-hello.bin: | 55 | $(OUTPUT)test-hello.bin: |
| 55 | $(BUILD) | 56 | $(BUILD) |
| 56 | 57 | ||
| 57 | test-pthread-attr-setaffinity-np.bin: | 58 | $(OUTPUT)test-pthread-attr-setaffinity-np.bin: |
| 58 | $(BUILD) -D_GNU_SOURCE -lpthread | 59 | $(BUILD) -D_GNU_SOURCE -lpthread |
| 59 | 60 | ||
| 60 | test-stackprotector-all.bin: | 61 | $(OUTPUT)test-stackprotector-all.bin: |
| 61 | $(BUILD) -fstack-protector-all | 62 | $(BUILD) -fstack-protector-all |
| 62 | 63 | ||
| 63 | test-fortify-source.bin: | 64 | $(OUTPUT)test-fortify-source.bin: |
| 64 | $(BUILD) -O2 -D_FORTIFY_SOURCE=2 | 65 | $(BUILD) -O2 -D_FORTIFY_SOURCE=2 |
| 65 | 66 | ||
| 66 | test-bionic.bin: | 67 | $(OUTPUT)test-bionic.bin: |
| 67 | $(BUILD) | 68 | $(BUILD) |
| 68 | 69 | ||
| 69 | test-libelf.bin: | 70 | $(OUTPUT)test-libelf.bin: |
| 70 | $(BUILD) -lelf | 71 | $(BUILD) -lelf |
| 71 | 72 | ||
| 72 | test-glibc.bin: | 73 | $(OUTPUT)test-glibc.bin: |
| 73 | $(BUILD) | 74 | $(BUILD) |
| 74 | 75 | ||
| 75 | DWARFLIBS := -ldw | 76 | DWARFLIBS := -ldw |
| @@ -77,37 +78,37 @@ ifeq ($(findstring -static,${LDFLAGS}),-static) | |||
| 77 | DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 | 78 | DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 |
| 78 | endif | 79 | endif |
| 79 | 80 | ||
| 80 | test-dwarf.bin: | 81 | $(OUTPUT)test-dwarf.bin: |
| 81 | $(BUILD) $(DWARFLIBS) | 82 | $(BUILD) $(DWARFLIBS) |
| 82 | 83 | ||
| 83 | test-libelf-mmap.bin: | 84 | $(OUTPUT)test-libelf-mmap.bin: |
| 84 | $(BUILD) -lelf | 85 | $(BUILD) -lelf |
| 85 | 86 | ||
| 86 | test-libelf-getphdrnum.bin: | 87 | $(OUTPUT)test-libelf-getphdrnum.bin: |
| 87 | $(BUILD) -lelf | 88 | $(BUILD) -lelf |
| 88 | 89 | ||
| 89 | test-libnuma.bin: | 90 | $(OUTPUT)test-libnuma.bin: |
| 90 | $(BUILD) -lnuma | 91 | $(BUILD) -lnuma |
| 91 | 92 | ||
| 92 | test-numa_num_possible_cpus.bin: | 93 | $(OUTPUT)test-numa_num_possible_cpus.bin: |
| 93 | $(BUILD) -lnuma | 94 | $(BUILD) -lnuma |
| 94 | 95 | ||
| 95 | test-libunwind.bin: | 96 | $(OUTPUT)test-libunwind.bin: |
| 96 | $(BUILD) -lelf | 97 | $(BUILD) -lelf |
| 97 | 98 | ||
| 98 | test-libunwind-debug-frame.bin: | 99 | $(OUTPUT)test-libunwind-debug-frame.bin: |
| 99 | $(BUILD) -lelf | 100 | $(BUILD) -lelf |
| 100 | 101 | ||
| 101 | test-libaudit.bin: | 102 | $(OUTPUT)test-libaudit.bin: |
| 102 | $(BUILD) -laudit | 103 | $(BUILD) -laudit |
| 103 | 104 | ||
| 104 | test-libslang.bin: | 105 | $(OUTPUT)test-libslang.bin: |
| 105 | $(BUILD) -I/usr/include/slang -lslang | 106 | $(BUILD) -I/usr/include/slang -lslang |
| 106 | 107 | ||
| 107 | test-gtk2.bin: | 108 | $(OUTPUT)test-gtk2.bin: |
| 108 | $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) | 109 | $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) |
| 109 | 110 | ||
| 110 | test-gtk2-infobar.bin: | 111 | $(OUTPUT)test-gtk2-infobar.bin: |
| 111 | $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) | 112 | $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) |
| 112 | 113 | ||
| 113 | grep-libs = $(filter -l%,$(1)) | 114 | grep-libs = $(filter -l%,$(1)) |
| @@ -119,63 +120,63 @@ PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) | |||
| 119 | PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` | 120 | PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` |
| 120 | FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) | 121 | FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) |
| 121 | 122 | ||
| 122 | test-libperl.bin: | 123 | $(OUTPUT)test-libperl.bin: |
| 123 | $(BUILD) $(FLAGS_PERL_EMBED) | 124 | $(BUILD) $(FLAGS_PERL_EMBED) |
| 124 | 125 | ||
| 125 | test-libpython.bin: | 126 | $(OUTPUT)test-libpython.bin: |
| 126 | $(BUILD) | 127 | $(BUILD) |
| 127 | 128 | ||
| 128 | test-libpython-version.bin: | 129 | $(OUTPUT)test-libpython-version.bin: |
| 129 | $(BUILD) | 130 | $(BUILD) |
| 130 | 131 | ||
| 131 | test-libbfd.bin: | 132 | $(OUTPUT)test-libbfd.bin: |
| 132 | $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl | 133 | $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl |
| 133 | 134 | ||
| 134 | test-liberty.bin: | 135 | $(OUTPUT)test-liberty.bin: |
| 135 | $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty | 136 | $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty |
| 136 | 137 | ||
| 137 | test-liberty-z.bin: | 138 | $(OUTPUT)test-liberty-z.bin: |
| 138 | $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz | 139 | $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz |
| 139 | 140 | ||
| 140 | test-cplus-demangle.bin: | 141 | $(OUTPUT)test-cplus-demangle.bin: |
| 141 | $(BUILD) -liberty | 142 | $(BUILD) -liberty |
| 142 | 143 | ||
| 143 | test-backtrace.bin: | 144 | $(OUTPUT)test-backtrace.bin: |
| 144 | $(BUILD) | 145 | $(BUILD) |
| 145 | 146 | ||
| 146 | test-timerfd.bin: | 147 | $(OUTPUT)test-timerfd.bin: |
| 147 | $(BUILD) | 148 | $(BUILD) |
| 148 | 149 | ||
| 149 | test-libdw-dwarf-unwind.bin: | 150 | $(OUTPUT)test-libdw-dwarf-unwind.bin: |
| 150 | $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind) | 151 | $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind) |
| 151 | 152 | ||
| 152 | test-libbabeltrace.bin: | 153 | $(OUTPUT)test-libbabeltrace.bin: |
| 153 | $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace) | 154 | $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace) |
| 154 | 155 | ||
| 155 | test-sync-compare-and-swap.bin: | 156 | $(OUTPUT)test-sync-compare-and-swap.bin: |
| 156 | $(BUILD) | 157 | $(BUILD) |
| 157 | 158 | ||
| 158 | test-compile-32.bin: | 159 | $(OUTPUT)test-compile-32.bin: |
| 159 | $(CC) -m32 -o $(OUTPUT)$@ test-compile.c | 160 | $(CC) -m32 -o $@ test-compile.c |
| 160 | |||
