From: David Sharp <dhsharp@google.com>
To: linux-kernel@vger.kernel.org, rostedt@goodmis.org
Cc: mrubin@google.com, David Sharp <dhsharp@google.com>,
Darren Hart <dvhart@linux.intel.com>
Subject: [PATCH trace-cmd v2] trace-cmd: allow setting CC and AR, or CROSS_COMPILE from command line
Date: Thu, 10 Mar 2011 13:11:31 -0800 [thread overview]
Message-ID: <1299791491-1805-1-git-send-email-dhsharp@google.com> (raw)
In-Reply-To: <1299780664.15854.399.camel@gandalf.stny.rr.com>
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>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Darren Hart <dvhart@linux.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
next prev parent reply other threads:[~2011-03-10 21:12 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-09 23:58 [PATCH trace-cmd 1/3] parse-events: Add support for printing short fields David Sharp
2011-03-09 23:58 ` [PATCH trace-cmd 2/3] parse-events: support additional operators: '!', '~', and '!=' David Sharp
2011-03-09 23:58 ` [PATCH trace-cmd 3/3] Revert "trace-cmd: Use conditional assignment of CC and AR" David Sharp
2011-03-10 1:21 ` Steven Rostedt
2011-03-10 1:28 ` Steven Rostedt
2011-03-10 1:29 ` Darren Hart
2011-03-10 1:27 ` Darren Hart
2011-03-10 1:36 ` Steven Rostedt
2011-03-10 1:58 ` Darren Hart
2011-03-10 2:27 ` David Sharp
2011-03-10 2:51 ` Steven Rostedt
2011-03-10 3:26 ` Steven Rostedt
2011-03-10 5:25 ` David Sharp
2011-03-10 6:46 ` Darren Hart
2011-03-10 13:02 ` Steven Rostedt
2011-03-10 6:41 ` Darren Hart
2011-03-10 13:07 ` Steven Rostedt
2011-03-10 6:34 ` Darren Hart
2011-03-10 6:32 ` Darren Hart
2011-03-10 6:43 ` Darren Hart
2011-03-10 13:11 ` Steven Rostedt
2011-03-10 17:50 ` Darren Hart
2011-03-10 18:11 ` Steven Rostedt
2011-03-10 21:11 ` David Sharp [this message]
2011-03-10 21:30 ` [PATCH trace-cmd v2] trace-cmd: allow setting CC and AR, or CROSS_COMPILE from command line Steven Rostedt
2011-03-10 2:42 ` [PATCH trace-cmd 3/3] Revert "trace-cmd: Use conditional assignment of CC and AR" Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1299791491-1805-1-git-send-email-dhsharp@google.com \
--to=dhsharp@google.com \
--cc=dvhart@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mrubin@google.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox