diff options
| author | David Sharp <dhsharp@google.com> | 2011-03-10 16:11:31 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2011-03-10 16:23:21 -0500 |
| commit | f8726fadc1849cdb65b7257eadaf50b89f5decef (patch) | |
| tree | 2fd152d66f5c8770bd36b11263b744b907f90d65 /Makefile | |
| parent | 025c5a6e6f8348ea8742b306ca9d05feee17ed5e (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>
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 18 |
1 files changed, 16 insertions, 2 deletions
| @@ -13,8 +13,22 @@ FILE_VERSION = 6 | |||
| 13 | 13 | ||
| 14 | MAKEFLAGS += --no-print-directory | 14 | MAKEFLAGS += --no-print-directory |
| 15 | 15 | ||
| 16 | CC ?= $(CROSS_COMPILE)gcc | 16 | |
| 17 | AR ?= $(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. | ||
| 22 | define allow-override | ||
| 23 | $(if $(or $(findstring environment,$(origin $(1))),\ | ||
| 24 | $(findstring command line,$(origin $(1)))),,\ | ||
| 25 | $(eval $(1) = $(2))) | ||
| 26 | endef | ||
| 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 | |||
| 18 | EXT = -std=gnu99 | 32 | EXT = -std=gnu99 |
| 19 | INSTALL = install | 33 | INSTALL = install |
| 20 | 34 | ||
