Commit f6322eb7af6a0fafe44f30577c828e175e6c662e
Committed by
Tom Rini
1 parent
5651ccffa4
Exists in
master
and in
49 other branches
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>
Showing 2 changed files with 84 additions and 88 deletions Side-by-side Diff
Makefile
... | ... | @@ -161,6 +161,73 @@ |
161 | 161 | CROSS_COMPILE ?= |
162 | 162 | endif |
163 | 163 | |
164 | +# SHELL used by kbuild | |
165 | +CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ | |
166 | + else if [ -x /bin/bash ]; then echo /bin/bash; \ | |
167 | + else echo sh; fi ; fi) | |
168 | + | |
169 | +HOSTCC = gcc | |
170 | +HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer | |
171 | + | |
172 | +ifeq ($(HOSTOS),cygwin) | |
173 | +HOSTCFLAGS += -ansi | |
174 | +endif | |
175 | + | |
176 | +# Mac OS X / Darwin's C preprocessor is Apple specific. It | |
177 | +# generates numerous errors and warnings. We want to bypass it | |
178 | +# and use GNU C's cpp. To do this we pass the -traditional-cpp | |
179 | +# option to the compiler. Note that the -traditional-cpp flag | |
180 | +# DOES NOT have the same semantics as GNU C's flag, all it does | |
181 | +# is invoke the GNU preprocessor in stock ANSI/ISO C fashion. | |
182 | +# | |
183 | +# Apple's linker is similar, thanks to the new 2 stage linking | |
184 | +# multiple symbol definitions are treated as errors, hence the | |
185 | +# -multiply_defined suppress option to turn off this error. | |
186 | +# | |
187 | +ifeq ($(HOSTOS),darwin) | |
188 | +# get major and minor product version (e.g. '10' and '6' for Snow Leopard) | |
189 | +DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.') | |
190 | +DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.') | |
191 | + | |
192 | +os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \ | |
193 | + $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;) | |
194 | + | |
195 | +# Snow Leopards build environment has no longer restrictions as described above | |
196 | +HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc") | |
197 | +HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp") | |
198 | +HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress") | |
199 | +endif | |
200 | + | |
201 | +# Make variables (CC, etc...) | |
202 | + | |
203 | +AS = $(CROSS_COMPILE)as | |
204 | +# Always use GNU ld | |
205 | +ifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),) | |
206 | +LD = $(CROSS_COMPILE)ld.bfd | |
207 | +else | |
208 | +LD = $(CROSS_COMPILE)ld | |
209 | +endif | |
210 | +CC = $(CROSS_COMPILE)gcc | |
211 | +CPP = $(CC) -E | |
212 | +AR = $(CROSS_COMPILE)ar | |
213 | +NM = $(CROSS_COMPILE)nm | |
214 | +LDR = $(CROSS_COMPILE)ldr | |
215 | +STRIP = $(CROSS_COMPILE)strip | |
216 | +OBJCOPY = $(CROSS_COMPILE)objcopy | |
217 | +OBJDUMP = $(CROSS_COMPILE)objdump | |
218 | +AWK = awk | |
219 | +RANLIB = $(CROSS_COMPILE)RANLIB | |
220 | +DTC = dtc | |
221 | +CHECK = sparse | |
222 | + | |
223 | +CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ | |
224 | + -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF) | |
225 | + | |
226 | +export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC | |
227 | +export CPP AR NM LDR STRIP OBJCOPY OBJDUMP | |
228 | +export MAKE AWK | |
229 | +export DTC CHECK CHECKFLAGS | |
230 | + | |
164 | 231 | # load other configuration |
165 | 232 | include $(TOPDIR)/config.mk |
166 | 233 | |
167 | 234 | |
168 | 235 | |
169 | 236 | |
170 | 237 | |
171 | 238 | |
... | ... | @@ -788,27 +855,28 @@ |
788 | 855 | $(obj)examples/standalone/interrupt \ |
789 | 856 | $(obj)examples/standalone/mem_to_mem_idma2intr \ |
790 | 857 | $(obj)examples/standalone/sched \ |
791 | - $(obj)examples/standalone/smc911{11,x}_eeprom \ | |
858 | + $(addprefix $(obj)examples/standalone/, smc91111_eeprom smc911x_eeprom) \ | |
792 | 859 | $(obj)examples/standalone/test_burst \ |
793 | 860 | $(obj)examples/standalone/timer |
794 | - @rm -f $(obj)examples/api/demo{,.bin} | |
861 | + @rm -f $(addprefix $(obj)examples/api/, demo demo.bin) | |
795 | 862 | @rm -f $(obj)tools/bmp_logo $(obj)tools/easylogo/easylogo \ |
796 | 863 | $(obj)tools/env/fw_printenv \ |
797 | 864 | $(obj)tools/envcrc \ |
798 | - $(obj)tools/gdb/{gdbcont,gdbsend} \ | |
865 | + $(addprefix $(obj)tools/gdb/, gdbcont gdbsend) \ | |
799 | 866 | $(obj)tools/gen_eth_addr $(obj)tools/img2srec \ |
800 | - $(obj)tools/dump{env,}image \ | |
801 | - $(obj)tools/mk{env,}image $(obj)tools/mpc86x_clk \ | |
802 | - $(obj)tools/mk{$(BOARD),exynos}spl \ | |
867 | + $(obj)tools/dumpimage \ | |
868 | + $(addprefix $(obj)tools/, mkenvimage mkimage) \ | |
869 | + $(obj)tools/mpc86x_clk \ | |
870 | + $(addprefix $(obj)tools/, mk$(BOARD)spl mkexynosspl) \ | |
803 | 871 | $(obj)tools/mxsboot \ |
804 | 872 | $(obj)tools/ncb $(obj)tools/ubsha1 \ |
805 | 873 | $(obj)tools/kernel-doc/docproc \ |
806 | 874 | $(obj)tools/proftool |
807 | - @rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image} \ | |
875 | + @rm -f $(addprefix $(obj)board/cray/L1/, bootscript.c bootscript.image) \ | |
808 | 876 | $(obj)board/matrix_vision/*/bootscript.img \ |
809 | 877 | $(obj)spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl \ |
810 | 878 | $(obj)u-boot.lds \ |
811 | - $(obj)arch/blackfin/cpu/init.{lds,elf} | |
879 | + $(addprefix $(obj)arch/blackfin/cpu/, init.lds init.elf) | |
812 | 880 | @rm -f $(obj)include/bmp_logo.h |
813 | 881 | @rm -f $(obj)include/bmp_logo_data.h |
814 | 882 | @rm -f $(obj)lib/asm-offsets.s |
815 | 883 | |
... | ... | @@ -843,11 +911,11 @@ |
843 | 911 | @rm -f $(obj)u-boot.dtb |
844 | 912 | @rm -f $(obj)u-boot.sb |
845 | 913 | @rm -f $(obj)u-boot.spr |
846 | - @rm -f $(obj)nand_spl/{u-boot.{lds,lst},System.map} | |
847 | - @rm -f $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map} | |
848 | - @rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.map} | |
914 | + @rm -f $(addprefix $(obj)nand_spl/, u-boot.lds u-boot.lst System.map) | |
915 | + @rm -f $(addprefix $(obj)nand_spl/, u-boot-nand_spl.lds u-boot-spl u-boot-spl.map) | |
916 | + @rm -f $(addprefix $(obj)spl/, u-boot-spl u-boot-spl.bin u-boot-spl.map) | |
849 | 917 | @rm -f $(obj)spl/u-boot-spl.lds |
850 | - @rm -f $(obj)tpl/{u-boot-tpl,u-boot-tpl.bin,u-boot-tpl.map} | |
918 | + @rm -f $(addprefix $(obj)tpl/, u-boot-tpl u-boot-tpl.bin u-boot-tpl.map) | |
851 | 919 | @rm -f $(obj)tpl/u-boot-spl.lds |
852 | 920 | @rm -f $(obj)MLO MLO.byteswap |
853 | 921 | @rm -f $(obj)SPL |
... | ... | @@ -856,7 +924,7 @@ |
856 | 924 | @rm -fr $(obj)include/generated |
857 | 925 | @[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f |
858 | 926 | @rm -f $(obj)dts/*.tmp |
859 | - @rm -f $(obj)spl/u-boot-spl{,-pad}.ais | |
927 | + @rm -f $(addprefix $(obj)spl/, u-boot-spl.ais, u-boot-spl-pad.ais) | |
860 | 928 | |
861 | 929 | mrproper \ |
862 | 930 | distclean: clobber unconfig |
config.mk
... | ... | @@ -6,13 +6,6 @@ |
6 | 6 | # |
7 | 7 | ######################################################################### |
8 | 8 | |
9 | -# Set shell to bash if possible, otherwise fall back to sh | |
10 | -SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ | |
11 | - else if [ -x /bin/bash ]; then echo /bin/bash; \ | |
12 | - else echo sh; fi; fi) | |
13 | - | |
14 | -export SHELL | |
15 | - | |
16 | 9 | ifeq ($(CURDIR),$(SRCTREE)) |
17 | 10 | dir := |
18 | 11 | else |
19 | 12 | |
... | ... | @@ -55,45 +48,7 @@ |
55 | 48 | PLATFORM_LDFLAGS = |
56 | 49 | |
57 | 50 | ######################################################################### |
58 | - | |
59 | -HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ | |
60 | - $(HOSTCPPFLAGS) | |
61 | - | |
62 | 51 | # |
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 | - | |
75 | -ifeq ($(HOSTOS),darwin) | |
76 | -# get major and minor product version (e.g. '10' and '6' for Snow Leopard) | |
77 | -DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.') | |
78 | -DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.') | |
79 | - | |
80 | -os_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 | |
84 | -HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc") | |
85 | -HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp") | |
86 | -HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress") | |
87 | -else | |
88 | -HOSTCC = gcc | |
89 | -endif | |
90 | - | |
91 | -ifeq ($(HOSTOS),cygwin) | |
92 | -HOSTCFLAGS += -ansi | |
93 | -endif | |
94 | - | |
95 | -######################################################################### | |
96 | -# | |
97 | 52 | # Option checker, gcc version (courtesy linux kernel) to ensure |
98 | 53 | # only supported compiler options are used |
99 | 54 | # |
100 | 55 | |
... | ... | @@ -117,31 +72,10 @@ |
117 | 72 | |
118 | 73 | # cc-version |
119 | 74 | # Usage gcc-ver := $(call cc-version) |
120 | -cc-version = $(shell $(SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC)) | |
121 | -binutils-version = $(shell $(SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS)) | |
122 | -dtc-version = $(shell $(SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC)) | |
75 | +cc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC)) | |
76 | +binutils-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS)) | |
77 | +dtc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC)) | |
123 | 78 | |
124 | -# | |
125 | -# Include the make variables (CC, etc...) | |
126 | -# | |
127 | -AS = $(CROSS_COMPILE)as | |
128 | - | |
129 | -# Always use GNU ld | |
130 | -LD = $(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 | - | |
133 | -CC = $(CROSS_COMPILE)gcc | |
134 | -CPP = $(CC) -E | |
135 | -AR = $(CROSS_COMPILE)ar | |
136 | -NM = $(CROSS_COMPILE)nm | |
137 | -LDR = $(CROSS_COMPILE)ldr | |
138 | -STRIP = $(CROSS_COMPILE)strip | |
139 | -OBJCOPY = $(CROSS_COMPILE)objcopy | |
140 | -OBJDUMP = $(CROSS_COMPILE)objdump | |
141 | -RANLIB = $(CROSS_COMPILE)RANLIB | |
142 | -DTC = dtc | |
143 | -CHECK = sparse | |
144 | - | |
145 | 79 | ######################################################################### |
146 | 80 | |
147 | 81 | # Load generated board configuration |
... | ... | @@ -286,10 +220,6 @@ |
286 | 220 | LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) |
287 | 221 | endif |
288 | 222 | |
289 | -# Linus' kernel sanity checking tool | |
290 | -CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ | |
291 | - -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF) | |
292 | - | |
293 | 223 | # Location of a usable BFD library, where we define "usable" as |
294 | 224 | # "built for ${HOST}, supports ${TARGET}". Sensible values are |
295 | 225 | # - When cross-compiling: the root of the cross-environment |
... | ... | @@ -315,7 +245,5 @@ |
315 | 245 | |
316 | 246 | ######################################################################### |
317 | 247 | |
318 | -export HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE \ | |
319 | - AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE | |
320 | 248 | export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS |