diff options
author | Jiri Olsa <jolsa@redhat.com> | 2013-03-24 19:40:48 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-05-28 09:24:06 -0400 |
commit | 362493f0d63e25698018f6f36b2e02201342dbee (patch) | |
tree | 1aeb6f9c1580d480cf81ccae9052bc9715708f64 /tools | |
parent | a32f4936bc022fd82b08a350a5587bd5a7e500d1 (diff) |
perf tools: Move compiler and linker flags check into config/Makefile
Moving compiler and linker flags check into config/Makefile.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1369398928-9809-5-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Makefile | 110 | ||||
-rw-r--r-- | tools/perf/config/Makefile | 66 |
2 files changed, 85 insertions, 91 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 2a7547673c6b..aa6f93389c55 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -52,6 +52,20 @@ include config/utilities.mak | |||
52 | # | 52 | # |
53 | # Define NO_LIBNUMA if you do not want numa perf benchmark | 53 | # Define NO_LIBNUMA if you do not want numa perf benchmark |
54 | 54 | ||
55 | ifeq ($(srctree),) | ||
56 | srctree := $(patsubst %/,%,$(dir $(shell pwd))) | ||
57 | srctree := $(patsubst %/,%,$(dir $(srctree))) | ||
58 | #$(info Determined 'srctree' to be $(srctree)) | ||
59 | endif | ||
60 | |||
61 | ifneq ($(objtree),) | ||
62 | #$(info Determined 'objtree' to be $(objtree)) | ||
63 | endif | ||
64 | |||
65 | ifneq ($(OUTPUT),) | ||
66 | #$(info Determined 'OUTPUT' to be $(OUTPUT)) | ||
67 | endif | ||
68 | |||
55 | $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE | 69 | $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE |
56 | @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) | 70 | @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) |
57 | 71 | ||
@@ -66,6 +80,9 @@ FLEX = flex | |||
66 | BISON = bison | 80 | BISON = bison |
67 | STRIP ?= strip | 81 | STRIP ?= strip |
68 | 82 | ||
83 | LK_DIR = ../lib/lk/ | ||
84 | TRACE_EVENT_DIR = ../lib/traceevent/ | ||
85 | |||
69 | # include config/Makefile by default and rule out | 86 | # include config/Makefile by default and rule out |
70 | # non-config cases | 87 | # non-config cases |
71 | config := 1 | 88 | config := 1 |
@@ -82,33 +99,10 @@ ifeq ($(config),1) | |||
82 | include config/Makefile | 99 | include config/Makefile |
83 | endif | 100 | endif |
84 | 101 | ||
85 | # Treat warnings as errors unless directed not to | ||
86 | ifneq ($(WERROR),0) | ||
87 | CFLAGS_WERROR := -Werror | ||
88 | endif | ||
89 | |||
90 | ifeq ("$(origin DEBUG)", "command line") | ||
91 | PERF_DEBUG = $(DEBUG) | ||
92 | endif | ||
93 | ifndef PERF_DEBUG | ||
94 | CFLAGS_OPTIMIZE = -O6 | ||
95 | endif | ||
96 | |||
97 | ifdef PARSER_DEBUG | ||
98 | PARSER_DEBUG_BISON := -t | ||
99 | PARSER_DEBUG_FLEX := -d | ||
100 | PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG | ||
101 | endif | ||
102 | |||
103 | ifdef NO_NEWT | 102 | ifdef NO_NEWT |
104 | NO_SLANG=1 | 103 | NO_SLANG=1 |
105 | endif | 104 | endif |
106 | 105 | ||
107 | CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS) | ||
108 | EXTLIBS = -lpthread -lrt -lelf -lm | ||
109 | ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE | ||
110 | ALL_LDFLAGS = $(LDFLAGS) | ||
111 | |||
112 | # Among the variables below, these: | 106 | # Among the variables below, these: |
113 | # perfexecdir | 107 | # perfexecdir |
114 | # template_dir | 108 | # template_dir |
@@ -148,71 +142,6 @@ export prefix bindir sharedir sysconfdir | |||
148 | # explicitly what architecture to check for. Fix this up for yours.. | 142 | # explicitly what architecture to check for. Fix this up for yours.. |
149 | SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ | 143 | SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ |
150 | 144 | ||
151 | ifneq ($(MAKECMDGOALS),clean) | ||
152 | ifneq ($(MAKECMDGOALS),tags) | ||
153 | -include config/feature-tests.mak | ||
154 | |||
155 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) | ||
156 | CFLAGS := $(CFLAGS) -fstack-protector-all | ||
157 | endif | ||
158 | |||
159 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) | ||
160 | CFLAGS := $(CFLAGS) -Wstack-protector | ||
161 | endif | ||
162 | |||
163 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y) | ||
164 | CFLAGS := $(CFLAGS) -Wvolatile-register-var | ||
165 | endif | ||
166 | |||
167 | ifndef PERF_DEBUG | ||
168 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y) | ||
169 | CFLAGS := $(CFLAGS) -D_FORTIFY_SOURCE=2 | ||
170 | endif | ||
171 | endif | ||
172 | |||
173 | ### --- END CONFIGURATION SECTION --- | ||
174 | |||
175 | ifeq ($(srctree),) | ||
176 | srctree := $(patsubst %/,%,$(dir $(shell pwd))) | ||
177 | srctree := $(patsubst %/,%,$(dir $(srctree))) | ||
178 | #$(info Determined 'srctree' to be $(srctree)) | ||
179 | endif | ||
180 | |||
181 | ifneq ($(objtree),) | ||
182 | #$(info Determined 'objtree' to be $(objtree)) | ||
183 | endif | ||
184 | |||
185 | ifneq ($(OUTPUT),) | ||
186 | #$(info Determined 'OUTPUT' to be $(OUTPUT)) | ||
187 | endif | ||
188 | |||
189 | BASIC_CFLAGS += \ | ||
190 | -Iutil/include \ | ||
191 | -Iarch/$(ARCH)/include \ | ||
192 | $(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \ | ||
193 | -I$(srctree)/arch/$(ARCH)/include/uapi \ | ||
194 | -I$(srctree)/arch/$(ARCH)/include \ | ||
195 | $(if $(objtree),-I$(objtree)/include/generated/uapi) \ | ||
196 | -I$(srctree)/include/uapi \ | ||
197 | -I$(srctree)/include \ | ||
198 | -I$(OUTPUT)util \ | ||
199 | -Iutil \ | ||
200 | -I. \ | ||
201 | -I$(TRACE_EVENT_DIR) \ | ||
202 | -I../lib/ \ | ||
203 | -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE | ||
204 | |||
205 | BASIC_LDFLAGS = | ||
206 | |||
207 | ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) | ||
208 | BIONIC := 1 | ||
209 | EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) | ||
210 | EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) | ||
211 | BASIC_CFLAGS += -I. | ||
212 | endif | ||
213 | endif # MAKECMDGOALS != tags | ||
214 | endif # MAKECMDGOALS != clean | ||
215 | |||
216 | # Guard against environment variables | 145 | # Guard against environment variables |
217 | BUILTIN_OBJS = | 146 | BUILTIN_OBJS = |
218 | LIB_H = | 147 | LIB_H = |
@@ -225,9 +154,6 @@ SCRIPT_SH += perf-archive.sh | |||
225 | grep-libs = $(filter -l%,$(1)) | 154 | grep-libs = $(filter -l%,$(1)) |
226 | strip-libs = $(filter-out -l%,$(1)) | 155 | strip-libs = $(filter-out -l%,$(1)) |
227 | 156 | ||
228 | LK_DIR = ../lib/lk/ | ||
229 | TRACE_EVENT_DIR = ../lib/traceevent/ | ||
230 | |||
231 | LK_PATH=$(LK_DIR) | 157 | LK_PATH=$(LK_DIR) |
232 | 158 | ||
233 | ifneq ($(OUTPUT),) | 159 | ifneq ($(OUTPUT),) |
@@ -541,6 +467,8 @@ PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT) | |||
541 | ifneq ($(MAKECMDGOALS),clean) | 467 | ifneq ($(MAKECMDGOALS),clean) |
542 | ifneq ($(MAKECMDGOALS),tags) | 468 | ifneq ($(MAKECMDGOALS),tags) |
543 | 469 | ||
470 | -include config/feature-tests.mak | ||
471 | |||
544 | # We choose to avoid "if .. else if .. else .. endif endif" | 472 | # We choose to avoid "if .. else if .. else .. endif endif" |
545 | # because maintaining the nesting to match is a pain. If | 473 | # because maintaining the nesting to match is a pain. If |
546 | # we had "elif" things would have been much nicer... | 474 | # we had "elif" things would have been much nicer... |
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 04bf8aceea5a..8acbcfec93f1 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile | |||
@@ -42,3 +42,69 @@ endif | |||
42 | ifeq ($(call get-executable,$(BISON)),) | 42 | ifeq ($(call get-executable,$(BISON)),) |
43 | dummy := $(error Error: $(BISON) is missing on this system, please install it) | 43 | dummy := $(error Error: $(BISON) is missing on this system, please install it) |
44 | endif | 44 | endif |
45 | |||
46 | # Treat warnings as errors unless directed not to | ||
47 | ifneq ($(WERROR),0) | ||
48 | CFLAGS_WERROR := -Werror | ||
49 | endif | ||
50 | |||
51 | ifeq ("$(origin DEBUG)", "command line") | ||
52 | PERF_DEBUG = $(DEBUG) | ||
53 | endif | ||
54 | ifndef PERF_DEBUG | ||
55 | CFLAGS_OPTIMIZE = -O6 | ||
56 | endif | ||
57 | |||
58 | ifdef PARSER_DEBUG | ||
59 | PARSER_DEBUG_BISON := -t | ||
60 | PARSER_DEBUG_FLEX := -d | ||
61 | PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG | ||
62 | endif | ||
63 | |||
64 | CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS) | ||
65 | EXTLIBS = -lpthread -lrt -lelf -lm | ||
66 | ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE | ||
67 | ALL_LDFLAGS = $(LDFLAGS) | ||
68 | |||
69 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) | ||
70 | CFLAGS := $(CFLAGS) -fstack-protector-all | ||
71 | endif | ||
72 | |||
73 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) | ||
74 | CFLAGS := $(CFLAGS) -Wstack-protector | ||
75 | endif | ||
76 | |||
77 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y) | ||
78 | CFLAGS := $(CFLAGS) -Wvolatile-register-var | ||
79 | endif | ||
80 | |||
81 | ifndef PERF_DEBUG | ||
82 | ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y) | ||
83 | CFLAGS := $(CFLAGS) -D_FORTIFY_SOURCE=2 | ||
84 | endif | ||
85 | endif | ||
86 | |||
87 | BASIC_CFLAGS += \ | ||
88 | -Iutil/include \ | ||
89 | -Iarch/$(ARCH)/include \ | ||
90 | $(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \ | ||
91 | -I$(srctree)/arch/$(ARCH)/include/uapi \ | ||
92 | -I$(srctree)/arch/$(ARCH)/include \ | ||
93 | $(if $(objtree),-I$(objtree)/include/generated/uapi) \ | ||
94 | -I$(srctree)/include/uapi \ | ||
95 | -I$(srctree)/include \ | ||
96 | -I$(OUTPUT)util \ | ||
97 | -Iutil \ | ||
98 | -I. \ | ||
99 | -I$(TRACE_EVENT_DIR) \ | ||
100 | -I../lib/ \ | ||
101 | -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE | ||
102 | |||
103 | BASIC_LDFLAGS = | ||
104 | |||
105 | ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) | ||
106 | BIONIC := 1 | ||
107 | EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) | ||
108 | EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) | ||
109 | BASIC_CFLAGS += -I. | ||
110 | endif | ||