diff options
-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 | ||