aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2013-03-24 19:40:48 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-05-28 09:24:06 -0400
commit362493f0d63e25698018f6f36b2e02201342dbee (patch)
tree1aeb6f9c1580d480cf81ccae9052bc9715708f64 /tools
parenta32f4936bc022fd82b08a350a5587bd5a7e500d1 (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/Makefile110
-rw-r--r--tools/perf/config/Makefile66
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
55ifeq ($(srctree),)
56srctree := $(patsubst %/,%,$(dir $(shell pwd)))
57srctree := $(patsubst %/,%,$(dir $(srctree)))
58#$(info Determined 'srctree' to be $(srctree))
59endif
60
61ifneq ($(objtree),)
62#$(info Determined 'objtree' to be $(objtree))
63endif
64
65ifneq ($(OUTPUT),)
66#$(info Determined 'OUTPUT' to be $(OUTPUT))
67endif
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
66BISON = bison 80BISON = bison
67STRIP ?= strip 81STRIP ?= strip
68 82
83LK_DIR = ../lib/lk/
84TRACE_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
71config := 1 88config := 1
@@ -82,33 +99,10 @@ ifeq ($(config),1)
82include config/Makefile 99include config/Makefile
83endif 100endif
84 101
85# Treat warnings as errors unless directed not to
86ifneq ($(WERROR),0)
87 CFLAGS_WERROR := -Werror
88endif
89
90ifeq ("$(origin DEBUG)", "command line")
91 PERF_DEBUG = $(DEBUG)
92endif
93ifndef PERF_DEBUG
94 CFLAGS_OPTIMIZE = -O6
95endif
96
97ifdef PARSER_DEBUG
98 PARSER_DEBUG_BISON := -t
99 PARSER_DEBUG_FLEX := -d
100 PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG
101endif
102
103ifdef NO_NEWT 102ifdef NO_NEWT
104 NO_SLANG=1 103 NO_SLANG=1
105endif 104endif
106 105
107CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS)
108EXTLIBS = -lpthread -lrt -lelf -lm
109ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
110ALL_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..
149SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ 143SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
150 144
151ifneq ($(MAKECMDGOALS),clean)
152ifneq ($(MAKECMDGOALS),tags)
153-include config/feature-tests.mak
154
155ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y)
156 CFLAGS := $(CFLAGS) -fstack-protector-all
157endif
158
159ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y)
160 CFLAGS := $(CFLAGS) -Wstack-protector
161endif
162
163ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y)
164 CFLAGS := $(CFLAGS) -Wvolatile-register-var
165endif
166
167ifndef 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
171endif
172
173### --- END CONFIGURATION SECTION ---
174
175ifeq ($(srctree),)
176srctree := $(patsubst %/,%,$(dir $(shell pwd)))
177srctree := $(patsubst %/,%,$(dir $(srctree)))
178#$(info Determined 'srctree' to be $(srctree))
179endif
180
181ifneq ($(objtree),)
182#$(info Determined 'objtree' to be $(objtree))
183endif
184
185ifneq ($(OUTPUT),)
186#$(info Determined 'OUTPUT' to be $(OUTPUT))
187endif
188
189BASIC_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
205BASIC_LDFLAGS =
206
207ifeq ($(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.
212endif
213endif # MAKECMDGOALS != tags
214endif # MAKECMDGOALS != clean
215
216# Guard against environment variables 145# Guard against environment variables
217BUILTIN_OBJS = 146BUILTIN_OBJS =
218LIB_H = 147LIB_H =
@@ -225,9 +154,6 @@ SCRIPT_SH += perf-archive.sh
225grep-libs = $(filter -l%,$(1)) 154grep-libs = $(filter -l%,$(1))
226strip-libs = $(filter-out -l%,$(1)) 155strip-libs = $(filter-out -l%,$(1))
227 156
228LK_DIR = ../lib/lk/
229TRACE_EVENT_DIR = ../lib/traceevent/
230
231LK_PATH=$(LK_DIR) 157LK_PATH=$(LK_DIR)
232 158
233ifneq ($(OUTPUT),) 159ifneq ($(OUTPUT),)
@@ -541,6 +467,8 @@ PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT)
541ifneq ($(MAKECMDGOALS),clean) 467ifneq ($(MAKECMDGOALS),clean)
542ifneq ($(MAKECMDGOALS),tags) 468ifneq ($(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
42ifeq ($(call get-executable,$(BISON)),) 42ifeq ($(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)
44endif 44endif
45
46# Treat warnings as errors unless directed not to
47ifneq ($(WERROR),0)
48 CFLAGS_WERROR := -Werror
49endif
50
51ifeq ("$(origin DEBUG)", "command line")
52 PERF_DEBUG = $(DEBUG)
53endif
54ifndef PERF_DEBUG
55 CFLAGS_OPTIMIZE = -O6
56endif
57
58ifdef PARSER_DEBUG
59 PARSER_DEBUG_BISON := -t
60 PARSER_DEBUG_FLEX := -d
61 PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG
62endif
63
64CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS)
65EXTLIBS = -lpthread -lrt -lelf -lm
66ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
67ALL_LDFLAGS = $(LDFLAGS)
68
69ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y)
70 CFLAGS := $(CFLAGS) -fstack-protector-all
71endif
72
73ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y)
74 CFLAGS := $(CFLAGS) -Wstack-protector
75endif
76
77ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y)
78 CFLAGS := $(CFLAGS) -Wvolatile-register-var
79endif
80
81ifndef 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
85endif
86
87BASIC_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
103BASIC_LDFLAGS =
104
105ifeq ($(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.
110endif