aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada2014-02-04 02:24:15 -0600
committerTom Rini2014-02-19 10:07:50 -0600
commitf6322eb7af6a0fafe44f30577c828e175e6c662e (patch)
treee83c811ce29ef306ba9f3e6f84ca21136c749b28 /config.mk
parent5651ccffa4aa8ac36961f376927df253b7d0c035 (diff)
downloadu-boot-f6322eb7af6a0fafe44f30577c828e175e6c662e.tar.gz
u-boot-f6322eb7af6a0fafe44f30577c828e175e6c662e.tar.xz
u-boot-f6322eb7af6a0fafe44f30577c828e175e6c662e.zip
Makefile: move some variable definitions to the top Makefile
This commit moves some variable definitions from config.mk to the top Makefile: - HOSTCC, HOSTCFLAGS, HOSTLDFLAGS - AS, LD, CC, CPP, etc. - SHELL (renamed to CONFIG_SHELL) I'd like to slim down config.mk file because it is included from all recursive make. It is redundant to re-define the variables every time descending into sub directories. We should rather define them at the top Makefile and export them. U-Boot makefiles has been used "SHELL" variable to store shell chosen for the user, whereas Linux Kernel uses "CONFIG_SHELL". We should never use "SHELL" variable because it is a special variable for GNU Make. Changing SHELL may cause unpredictable side effects whose root cause is usually difficult to find. We should use a generic variable name "CONFIG_SHELL". We should not use the syntax as follows either: rm -f $(obj)tools/env/{fw_printenv,fw_setenv} This depends on "bash" although GNU Make generally invokes "sh" to run the each rule. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Diffstat (limited to 'config.mk')
-rw-r--r--config.mk78
1 files changed, 3 insertions, 75 deletions
diff --git a/config.mk b/config.mk
index b08be7a858..74617d33b7 100644
--- a/config.mk
+++ b/config.mk
@@ -6,13 +6,6 @@
6# 6#
7######################################################################### 7#########################################################################
8 8
9# Set shell to bash if possible, otherwise fall back to sh
10SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
11 else if [ -x /bin/bash ]; then echo /bin/bash; \
12 else echo sh; fi; fi)
13
14export SHELL
15
16ifeq ($(CURDIR),$(SRCTREE)) 9ifeq ($(CURDIR),$(SRCTREE))
17dir := 10dir :=
18else 11else
@@ -55,44 +48,6 @@ PLATFORM_CPPFLAGS =
55PLATFORM_LDFLAGS = 48PLATFORM_LDFLAGS =
56 49
57######################################################################### 50#########################################################################
58
59HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
60 $(HOSTCPPFLAGS)
61
62#
63# Mac OS X / Darwin's C preprocessor is Apple specific. It
64# generates numerous errors and warnings. We want to bypass it
65# and use GNU C's cpp. To do this we pass the -traditional-cpp
66# option to the compiler. Note that the -traditional-cpp flag
67# DOES NOT have the same semantics as GNU C's flag, all it does
68# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
69#
70# Apple's linker is similar, thanks to the new 2 stage linking
71# multiple symbol definitions are treated as errors, hence the
72# -multiply_defined suppress option to turn off this error.
73#
74
75ifeq ($(HOSTOS),darwin)
76# get major and minor product version (e.g. '10' and '6' for Snow Leopard)
77DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.')
78DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.')
79
80os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
81 $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
82
83# Snow Leopards build environment has no longer restrictions as described above
84HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc")
85HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp")
86HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
87else
88HOSTCC = gcc
89endif
90
91ifeq ($(HOSTOS),cygwin)
92HOSTCFLAGS += -ansi
93endif
94
95#########################################################################
96# 51#
97# Option checker, gcc version (courtesy linux kernel) to ensure 52# Option checker, gcc version (courtesy linux kernel) to ensure
98# only supported compiler options are used 53# only supported compiler options are used
@@ -117,30 +72,9 @@ endif
117 72
118# cc-version 73# cc-version
119# Usage gcc-ver := $(call cc-version) 74# Usage gcc-ver := $(call cc-version)
120cc-version = $(shell $(SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC)) 75cc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC))
121binutils-version = $(shell $(SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS)) 76binutils-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS))
122dtc-version = $(shell $(SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC)) 77dtc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC))
123
124#
125# Include the make variables (CC, etc...)
126#
127AS = $(CROSS_COMPILE)as
128
129# Always use GNU ld
130LD = $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \
131 then echo "$(CROSS_COMPILE)ld.bfd"; else echo "$(CROSS_COMPILE)ld"; fi;)
132
133CC = $(CROSS_COMPILE)gcc
134CPP = $(CC) -E
135AR = $(CROSS_COMPILE)ar
136NM = $(CROSS_COMPILE)nm
137LDR = $(CROSS_COMPILE)ldr
138STRIP = $(CROSS_COMPILE)strip
139OBJCOPY = $(CROSS_COMPILE)objcopy
140OBJDUMP = $(CROSS_COMPILE)objdump
141RANLIB = $(CROSS_COMPILE)RANLIB
142DTC = dtc
143CHECK = sparse
144 78
145######################################################################### 79#########################################################################
146 80
@@ -286,10 +220,6 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),)
286LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) 220LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
287endif 221endif
288 222
289# Linus' kernel sanity checking tool
290CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
291 -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
292
293# Location of a usable BFD library, where we define "usable" as 223# Location of a usable BFD library, where we define "usable" as
294# "built for ${HOST}, supports ${TARGET}". Sensible values are 224# "built for ${HOST}, supports ${TARGET}". Sensible values are
295# - When cross-compiling: the root of the cross-environment 225# - When cross-compiling: the root of the cross-environment
@@ -315,6 +245,4 @@ endif
315 245
316######################################################################### 246#########################################################################
317 247
318export HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE \
319 AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
320export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS 248export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS