[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1299791491-1805-1-git-send-email-dhsharp@google.com>
Date: Thu, 10 Mar 2011 13:11:31 -0800
From: David Sharp <dhsharp@...gle.com>
To: linux-kernel@...r.kernel.org, rostedt@...dmis.org
Cc: mrubin@...gle.com, David Sharp <dhsharp@...gle.com>,
Darren Hart <dvhart@...ux.intel.com>
Subject: [PATCH trace-cmd v2] 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@...gle.com>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Darren Hart <dvhart@...ux.intel.com>
---
Makefile | 18 ++++++++++++++++--
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
MAKEFLAGS += --no-print-directory
-CC ?= $(CROSS_COMPILE)gcc
-AR ?= $(CROSS_COMPILE)ar
+
+# Makefiles suck: This macro sets a default value of $(2) for the
+# variable named by $(1), unless the variable has been set by
+# environment or command line. This is necessary for CC and AR
+# because make sets default values, so the simpler ?= approach
+# won't work as expected.
+define allow-override
+ $(if $(or $(findstring environment,$(origin $(1))),\
+ $(findstring command line,$(origin $(1)))),,\
+ $(eval $(1) = $(2)))
+endef
+
+# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
+$(call allow-override,CC,$(CROSS_COMPILE)gcc)
+$(call allow-override,AR,$(CROSS_COMPILE)ar)
+
EXT = -std=gnu99
INSTALL = install
--
1.7.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists