aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sharp <dhsharp@google.com>2011-03-10 16:11:31 -0500
committerSteven Rostedt <rostedt@goodmis.org>2011-03-10 16:23:21 -0500
commitf8726fadc1849cdb65b7257eadaf50b89f5decef (patch)
tree2fd152d66f5c8770bd36b11263b744b907f90d65
parent025c5a6e6f8348ea8742b306ca9d05feee17ed5e (diff)
trace-cmd: Allow setting CC and AR, or CROSS_COMPILE from command line
Makefiles suck: Use some makefile magic to get the best of all worlds for CC and AR: Sane defaults and the ability to override CC, and AR, or use CROSS_COMPILE to set a prefix. Signed-off-by: David Sharp <dhsharp@google.com> LKML-Reference: <1299791491-1805-1-git-send-email-dhsharp@google.com> Cc: Darren Hart <dvhart@linux.intel.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--Makefile18
1 files changed, 16 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 169fcbc..c4cd926 100644
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,22 @@ FILE_VERSION = 6
13 13
14MAKEFLAGS += --no-print-directory 14MAKEFLAGS += --no-print-directory
15 15
16CC ?= $(CROSS_COMPILE)gcc 16
17AR ?= $(CROSS_COMPILE)ar 17# Makefiles suck: This macro sets a default value of $(2) for the
18# variable named by $(1), unless the variable has been set by
19# environment or command line. This is necessary for CC and AR
20# because make sets default values, so the simpler ?= approach
21# won't work as expected.
22define allow-override
23 $(if $(or $(findstring environment,$(origin $(1))),\
24 $(findstring command line,$(origin $(1)))),,\
25 $(eval $(1) = $(2)))
26endef
27
28# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
29$(call allow-override,CC,$(CROSS_COMPILE)gcc)
30$(call allow-override,AR,$(CROSS_COMPILE)ar)
31
18EXT = -std=gnu99 32EXT = -std=gnu99
19INSTALL = install 33INSTALL = install
20 34