xref: /openbmc/u-boot/config.mk (revision 5c1a7ea6)
1e2211743Swdenk#
2f9328639SMarian Balakowicz# (C) Copyright 2000-2006
3e2211743Swdenk# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4e2211743Swdenk#
5e2211743Swdenk# See file CREDITS for list of people who contributed to this
6e2211743Swdenk# project.
7e2211743Swdenk#
8e2211743Swdenk# This program is free software; you can redistribute it and/or
9e2211743Swdenk# modify it under the terms of the GNU General Public License as
10e2211743Swdenk# published by the Free Software Foundation; either version 2 of
11e2211743Swdenk# the License, or (at your option) any later version.
12e2211743Swdenk#
13e2211743Swdenk# This program is distributed in the hope that it will be useful,
14e2211743Swdenk# but WITHOUT ANY WARRANTY; without even the implied warranty of
15e2211743Swdenk# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
16e2211743Swdenk# GNU General Public License for more details.
17e2211743Swdenk#
18e2211743Swdenk# You should have received a copy of the GNU General Public License
19e2211743Swdenk# along with this program; if not, write to the Free Software
20e2211743Swdenk# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21e2211743Swdenk# MA 02111-1307 USA
22e2211743Swdenk#
23e2211743Swdenk
24e2211743Swdenk#########################################################################
25e2211743Swdenk
2697b24d3dSMarek Vasutinclude $(TOPDIR)/helper.mk
2797b24d3dSMarek Vasut
28f9328639SMarian Balakowiczifeq ($(CURDIR),$(SRCTREE))
29f9328639SMarian Balakowiczdir :=
30f9328639SMarian Balakowiczelse
31f9328639SMarian Balakowiczdir := $(subst $(SRCTREE)/,,$(CURDIR))
32f9328639SMarian Balakowiczendif
33f9328639SMarian Balakowicz
34c8f9c302SDaniel Schwierzeckifneq ($(OBJTREE),$(SRCTREE))
35c8f9c302SDaniel Schwierzeck# Create object files for SPL in a separate directory
36c8f9c302SDaniel Schwierzeckifeq ($(CONFIG_SPL_BUILD),y)
37c8f9c302SDaniel Schwierzeckobj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
38c8f9c302SDaniel Schwierzeckelse
39f9328639SMarian Balakowiczobj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
40c8f9c302SDaniel Schwierzeckendif
41f9328639SMarian Balakowiczsrc := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
42f9328639SMarian Balakowicz
43f9328639SMarian Balakowicz$(shell mkdir -p $(obj))
44f9328639SMarian Balakowiczelse
45c8f9c302SDaniel Schwierzeck# Create object files for SPL in a separate directory
46c8f9c302SDaniel Schwierzeckifeq ($(CONFIG_SPL_BUILD),y)
47c8f9c302SDaniel Schwierzeckobj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
48c8f9c302SDaniel Schwierzeck
49c8f9c302SDaniel Schwierzeck$(shell mkdir -p $(obj))
50c8f9c302SDaniel Schwierzeckelse
51f9328639SMarian Balakowiczobj :=
52c8f9c302SDaniel Schwierzeckendif
53f9328639SMarian Balakowiczsrc :=
54f9328639SMarian Balakowiczendif
55f9328639SMarian Balakowicz
56592c5cabSwdenk# clean the slate ...
57592c5cabSwdenkPLATFORM_RELFLAGS =
58592c5cabSwdenkPLATFORM_CPPFLAGS =
59592c5cabSwdenkPLATFORM_LDFLAGS =
60592c5cabSwdenk
61e2211743Swdenk#########################################################################
62e2211743Swdenk
63d984fed0SScott WoodHOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
64d984fed0SScott Wood		  $(HOSTCPPFLAGS)
65d984fed0SScott WoodHOSTSTRIP	= strip
66d984fed0SScott Wood
67d984fed0SScott Wood#
68d984fed0SScott Wood# Mac OS X / Darwin's C preprocessor is Apple specific.  It
69d984fed0SScott Wood# generates numerous errors and warnings.  We want to bypass it
70d984fed0SScott Wood# and use GNU C's cpp.	To do this we pass the -traditional-cpp
71d984fed0SScott Wood# option to the compiler.  Note that the -traditional-cpp flag
72d984fed0SScott Wood# DOES NOT have the same semantics as GNU C's flag, all it does
73d984fed0SScott Wood# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
74d984fed0SScott Wood#
75d984fed0SScott Wood# Apple's linker is similar, thanks to the new 2 stage linking
76d984fed0SScott Wood# multiple symbol definitions are treated as errors, hence the
77d984fed0SScott Wood# -multiply_defined suppress option to turn off this error.
78d984fed0SScott Wood#
79d984fed0SScott Wood
804cda4378SMike Frysingerifeq ($(HOSTOS),darwin)
81c7da8c19SAndreas Biessmann# get major and minor product version (e.g. '10' and '6' for Snow Leopard)
82c7da8c19SAndreas BiessmannDARWIN_MAJOR_VERSION	= $(shell sw_vers -productVersion | cut -f 1 -d '.')
83c7da8c19SAndreas BiessmannDARWIN_MINOR_VERSION	= $(shell sw_vers -productVersion | cut -f 2 -d '.')
84c7da8c19SAndreas Biessmann
85f534c7cdSMike Frysingeros_x_before	= $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
86f534c7cdSMike Frysinger	$(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
87c7da8c19SAndreas Biessmann
88c7da8c19SAndreas Biessmann# Snow Leopards build environment has no longer restrictions as described above
89f534c7cdSMike FrysingerHOSTCC		 = $(call os_x_before, 10, 5, "cc", "gcc")
90f534c7cdSMike FrysingerHOSTCFLAGS	+= $(call os_x_before, 10, 4, "-traditional-cpp")
91f534c7cdSMike FrysingerHOSTLDFLAGS	+= $(call os_x_before, 10, 5, "-multiply_defined suppress")
92e2211743Swdenkelse
93e2211743SwdenkHOSTCC		= gcc
94e2211743Swdenkendif
95d984fed0SScott Wood
96d984fed0SScott Woodifeq ($(HOSTOS),cygwin)
97d984fed0SScott WoodHOSTCFLAGS	+= -ansi
98d984fed0SScott Woodendif
99d984fed0SScott Wood
100d984fed0SScott Wood# We build some files with extra pedantic flags to try to minimize things
101d984fed0SScott Wood# that won't build on some weird host compiler -- though there are lots of
102d984fed0SScott Wood# exceptions for files that aren't complaint.
103d984fed0SScott Wood
104d984fed0SScott WoodHOSTCFLAGS_NOPED = $(filter-out -pedantic,$(HOSTCFLAGS))
105d984fed0SScott WoodHOSTCFLAGS	+= -pedantic
106e2211743Swdenk
107e2211743Swdenk#########################################################################
1081820d4c7SWolfgang Denk#
10919a695f8STom Rini# Option checker, gcc version (courtesy linux kernel) to ensure
1101820d4c7SWolfgang Denk# only supported compiler options are used
1111820d4c7SWolfgang Denk#
112b6a467d7SDaniel SchwierzeckCC_OPTIONS_CACHE_FILE := $(OBJTREE)/include/generated/cc_options.mk
1136f4acc17STom RiniCC_TEST_OFILE := $(OBJTREE)/include/generated/cc_test_file.o
114b6a467d7SDaniel Schwierzeck
115b6a467d7SDaniel Schwierzeck-include $(CC_OPTIONS_CACHE_FILE)
116b6a467d7SDaniel Schwierzeck
1176f4acc17STom Rinicc-option-sys = $(shell mkdir -p $(dir $(CC_TEST_OFILE)); \
1186f4acc17STom Rini		if $(CC) $(CFLAGS) $(1) -S -xc /dev/null -o $(CC_TEST_OFILE) \
119b6a467d7SDaniel Schwierzeck		> /dev/null 2>&1; then \
120b6a467d7SDaniel Schwierzeck		echo 'CC_OPTIONS += $(strip $1)' >> $(CC_OPTIONS_CACHE_FILE); \
121b6a467d7SDaniel Schwierzeck		echo "$(1)"; fi)
122b6a467d7SDaniel Schwierzeck
123b6a467d7SDaniel Schwierzeckifeq ($(CONFIG_CC_OPT_CACHE_DISABLE),y)
124b6a467d7SDaniel Schwierzeckcc-option = $(strip $(if $(call cc-option-sys,$1),$1,$2))
125b6a467d7SDaniel Schwierzeckelse
126b6a467d7SDaniel Schwierzeckcc-option = $(strip $(if $(findstring $1,$(CC_OPTIONS)),$1,\
127b6a467d7SDaniel Schwierzeck		$(if $(call cc-option-sys,$1),$1,$2)))
128b6a467d7SDaniel Schwierzeckendif
129e2211743Swdenk
13019a695f8STom Rini# cc-version
13119a695f8STom Rini# Usage gcc-ver := $(call cc-version)
13219a695f8STom Rinicc-version = $(shell $(SHELL) $(SRCTREE)/tools/gcc-version.sh $(CC))
1332051ff34SAllen Martinbinutils-version = $(shell $(SHELL) $(SRCTREE)/tools/binutils-version.sh $(AS))
13419a695f8STom Rini
135e2211743Swdenk#
136e2211743Swdenk# Include the make variables (CC, etc...)
137e2211743Swdenk#
138e2211743SwdenkAS	= $(CROSS_COMPILE)as
1397cb714a5SKhem Raj
1407cb714a5SKhem Raj# Always use GNU ld
1417cb714a5SKhem RajLD	= $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \
1427cb714a5SKhem Raj		then echo "$(CROSS_COMPILE)ld.bfd"; else echo "$(CROSS_COMPILE)ld"; fi;)
1437cb714a5SKhem Raj
144e2211743SwdenkCC	= $(CROSS_COMPILE)gcc
145e2211743SwdenkCPP	= $(CC) -E
146e2211743SwdenkAR	= $(CROSS_COMPILE)ar
147e2211743SwdenkNM	= $(CROSS_COMPILE)nm
14894a91e24SMike FrysingerLDR	= $(CROSS_COMPILE)ldr
149e2211743SwdenkSTRIP	= $(CROSS_COMPILE)strip
150e2211743SwdenkOBJCOPY = $(CROSS_COMPILE)objcopy
151e2211743SwdenkOBJDUMP = $(CROSS_COMPILE)objdump
152e2211743SwdenkRANLIB	= $(CROSS_COMPILE)RANLIB
153bbb0b128SSimon GlassDTC	= dtc
1544ab64933SKim PhillipsCHECK	= sparse
155e2211743Swdenk
156c4e5f52aSWolfgang Denk#########################################################################
157c4e5f52aSWolfgang Denk
158c4e5f52aSWolfgang Denk# Load generated board configuration
159c4e5f52aSWolfgang Denksinclude $(OBJTREE)/include/autoconf.mk
1605e987ddfSJoakim Tjernlundsinclude $(OBJTREE)/include/config.mk
161c4e5f52aSWolfgang Denk
16203b7004dSPeter Tyser# Some architecture config.mk files need to know what CPUDIR is set to,
16303b7004dSPeter Tyser# so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.
1648d1f2682SPeter Tyser# Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains
1658d1f2682SPeter Tyser# CPU-specific code.
1668d1f2682SPeter TyserCPUDIR=arch/$(ARCH)/cpu/$(CPU)
1678d1f2682SPeter Tyserifneq ($(SRCTREE)/$(CPUDIR),$(wildcard $(SRCTREE)/$(CPUDIR)))
1688d1f2682SPeter TyserCPUDIR=arch/$(ARCH)/cpu
1698d1f2682SPeter Tyserendif
17003b7004dSPeter Tyser
171ea0364f1SPeter Tysersinclude $(TOPDIR)/arch/$(ARCH)/config.mk	# include architecture dependend rules
17203b7004dSPeter Tysersinclude $(TOPDIR)/$(CPUDIR)/config.mk		# include  CPU	specific rules
17303b7004dSPeter Tyser
174c4e5f52aSWolfgang Denkifdef	SOC
17503b7004dSPeter Tysersinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk	# include  SoC	specific rules
176c4e5f52aSWolfgang Denkendif
177c4e5f52aSWolfgang Denkifdef	VENDOR
178c4e5f52aSWolfgang DenkBOARDDIR = $(VENDOR)/$(BOARD)
179c4e5f52aSWolfgang Denkelse
180c4e5f52aSWolfgang DenkBOARDDIR = $(BOARD)
181c4e5f52aSWolfgang Denkendif
182c4e5f52aSWolfgang Denkifdef	BOARD
183c4e5f52aSWolfgang Denksinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk	# include board specific rules
184c4e5f52aSWolfgang Denkendif
185c4e5f52aSWolfgang Denk
186c4e5f52aSWolfgang Denk#########################################################################
187c4e5f52aSWolfgang Denk
1885968adc4SMike Frysinger# We don't actually use $(ARFLAGS) anywhere anymore, so catch people
1895968adc4SMike Frysinger# who are porting old code to latest mainline but not updating $(AR).
1905968adc4SMike FrysingerARFLAGS = $(error update your Makefile to use cmd_link_o_target and not AR)
191e2211743SwdenkRELFLAGS= $(PLATFORM_RELFLAGS)
192e2211743SwdenkDBGFLAGS= -g # -DDEBUG
193e2211743SwdenkOPTFLAGS= -Os #-fomit-frame-pointer
19483b7e2a7SScott Wood
1956dd652faSwdenkOBJCFLAGS += --gap-fill=0xff
196e2211743Swdenk
197b783edaeSwdenkgccincdir := $(shell $(CC) -print-file-name=include)
198b783edaeSwdenk
199e2211743SwdenkCPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)		\
200c1f5805aSMarek Vasut	-D__KERNEL__
201c8f9c302SDaniel Schwierzeck
202c8f9c302SDaniel Schwierzeck# Enable garbage collection of un-used sections for SPL
203c8f9c302SDaniel Schwierzeckifeq ($(CONFIG_SPL_BUILD),y)
204c8f9c302SDaniel SchwierzeckCPPFLAGS += -ffunction-sections -fdata-sections
205c8f9c302SDaniel SchwierzeckLDFLAGS_FINAL += --gc-sections
206c8f9c302SDaniel Schwierzeckendif
207c8f9c302SDaniel Schwierzeck
20814d0a02aSWolfgang Denkifneq ($(CONFIG_SYS_TEXT_BASE),)
20914d0a02aSWolfgang DenkCPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
210161b2af4SMike Frysingerendif
211f9328639SMarian Balakowicz
212c8f9c302SDaniel Schwierzeckifneq ($(CONFIG_SPL_TEXT_BASE),)
213c8f9c302SDaniel SchwierzeckCPPFLAGS += -DCONFIG_SPL_TEXT_BASE=$(CONFIG_SPL_TEXT_BASE)
214c8f9c302SDaniel Schwierzeckendif
215c8f9c302SDaniel Schwierzeck
21694aebe6cSStefan Roeseifneq ($(CONFIG_SPL_PAD_TO),)
21794aebe6cSStefan RoeseCPPFLAGS += -DCONFIG_SPL_PAD_TO=$(CONFIG_SPL_PAD_TO)
21894aebe6cSStefan Roeseendif
21994aebe6cSStefan Roese
220c8f9c302SDaniel Schwierzeckifeq ($(CONFIG_SPL_BUILD),y)
221c8f9c302SDaniel SchwierzeckCPPFLAGS += -DCONFIG_SPL_BUILD
222c8f9c302SDaniel Schwierzeckendif
223c8f9c302SDaniel Schwierzeck
224*5c1a7ea6SSimon Glass# Does this architecture support generic board init?
225*5c1a7ea6SSimon Glassifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
226*5c1a7ea6SSimon Glassifneq ($(CONFIG_SYS_GENERIC_BOARD),)
227*5c1a7ea6SSimon Glass$(error Your architecture does not support generic board. Please undefined \
228*5c1a7ea6SSimon GlassCONFIG_SYS_GENERIC_BOARD in your board config file)
229*5c1a7ea6SSimon Glassendif
230*5c1a7ea6SSimon Glassendif
231*5c1a7ea6SSimon Glass
2326c97a20dSKumar Galaifneq ($(RESET_VECTOR_ADDRESS),)
2336c97a20dSKumar GalaCPPFLAGS += -DRESET_VECTOR_ADDRESS=$(RESET_VECTOR_ADDRESS)
2346c97a20dSKumar Galaendif
2356c97a20dSKumar Gala
236f9328639SMarian Balakowiczifneq ($(OBJTREE),$(SRCTREE))
237f9328639SMarian BalakowiczCPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
238f9328639SMarian Balakowiczendif
239f9328639SMarian Balakowicz
240f9328639SMarian BalakowiczCPPFLAGS += -I$(TOPDIR)/include
241f9328639SMarian BalakowiczCPPFLAGS += -fno-builtin -ffreestanding -nostdinc	\
242f9328639SMarian Balakowicz	-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
243e2211743Swdenk
244e2211743Swdenkifdef BUILD_TAG
245e2211743SwdenkCFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
246e2211743Swdenk	-DBUILD_TAG='"$(BUILD_TAG)"'
247e2211743Swdenkelse
248e2211743SwdenkCFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
249e2211743Swdenkendif
250e2211743Swdenk
251cca4e4aeSWolfgang DenkCFLAGS_SSP := $(call cc-option,-fno-stack-protector)
252cca4e4aeSWolfgang DenkCFLAGS += $(CFLAGS_SSP)
2536262e4e7SMike Frysinger# Some toolchains enable security related warning flags by default,
2546262e4e7SMike Frysinger# but they don't make much sense in the u-boot world, so disable them.
255cca4e4aeSWolfgang DenkCFLAGS_WARN := $(call cc-option,-Wno-format-nonliteral) \
256cca4e4aeSWolfgang Denk	       $(call cc-option,-Wno-format-security)
257cca4e4aeSWolfgang DenkCFLAGS += $(CFLAGS_WARN)
25828eab0d7SHaavard Skinnemoen
2594a30f1e8STom Rini# Report stack usage if supported
2604a30f1e8STom RiniCFLAGS_STACK := $(call cc-option,-fstack-usage)
2614a30f1e8STom RiniCFLAGS += $(CFLAGS_STACK)
2624a30f1e8STom Rini
263e11887a7SHaavard Skinnemoen# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
264e11887a7SHaavard Skinnemoen# option to the assembler.
265e11887a7SHaavard SkinnemoenAFLAGS_DEBUG :=
266b62fa913SMarian Balakowicz
267483a0cf8SMarian Balakowicz# turn jbsr into jsr for m68k
268483a0cf8SMarian Balakowiczifeq ($(ARCH),m68k)
269483a0cf8SMarian Balakowiczifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
270483a0cf8SMarian BalakowiczAFLAGS_DEBUG := -Wa,-gstabs,-S
271483a0cf8SMarian Balakowiczendif
272483a0cf8SMarian Balakowiczendif
273b62fa913SMarian Balakowicz
274e2211743SwdenkAFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
275e2211743Swdenk
2768aba9dceSNobuhiro IwamatsuLDFLAGS += $(PLATFORM_LDFLAGS)
2776dc1ecebSHaiying WangLDFLAGS_FINAL += -Bstatic
2788aba9dceSNobuhiro Iwamatsu
2796dc1ecebSHaiying WangLDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
28014d0a02aSWolfgang Denkifneq ($(CONFIG_SYS_TEXT_BASE),)
2818aba9dceSNobuhiro IwamatsuLDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
282161b2af4SMike Frysingerendif
283e2211743Swdenk
284c8f9c302SDaniel SchwierzeckLDFLAGS_u-boot-spl += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
285c8f9c302SDaniel Schwierzeckifneq ($(CONFIG_SPL_TEXT_BASE),)
286c8f9c302SDaniel SchwierzeckLDFLAGS_u-boot-spl += -Ttext $(CONFIG_SPL_TEXT_BASE)
287c8f9c302SDaniel Schwierzeckendif
288c8f9c302SDaniel Schwierzeck
2894ab64933SKim Phillips# Linus' kernel sanity checking tool
2904ab64933SKim PhillipsCHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
2914ab64933SKim Phillips                  -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
2924ab64933SKim Phillips
293e2211743Swdenk# Location of a usable BFD library, where we define "usable" as
294e2211743Swdenk# "built for ${HOST}, supports ${TARGET}".  Sensible values are
295e2211743Swdenk# - When cross-compiling: the root of the cross-environment
296e2211743Swdenk# - Linux/ppc (native): /usr
297e2211743Swdenk# - NetBSD/ppc (native): you lose ... (must extract these from the
298e2211743Swdenk#   binutils build directory, plus the native and U-Boot include
299e2211743Swdenk#   files don't like each other)
300e2211743Swdenk#
301e2211743Swdenk# So far, this is used only by tools/gdb/Makefile.
302e2211743Swdenk
3034cda4378SMike Frysingerifeq ($(HOSTOS),darwin)
304e2211743SwdenkBFD_ROOT_DIR =		/usr/local/tools
305e2211743Swdenkelse
306ea909b76Swdenkifeq ($(HOSTARCH),$(ARCH))
307ea909b76Swdenk# native
308ea909b76SwdenkBFD_ROOT_DIR =		/usr
309ea909b76Swdenkelse
310e2211743Swdenk#BFD_ROOT_DIR =		/LinuxPPC/CDK		# Linux/i386
311e2211743Swdenk#BFD_ROOT_DIR =		/usr/pkg/cross		# NetBSD/i386
312e2211743SwdenkBFD_ROOT_DIR =		/opt/powerpc
313e2211743Swdenkendif
314ea909b76Swdenkendif
315e2211743Swdenk
316e2211743Swdenk#########################################################################
317e2211743Swdenk
318d984fed0SScott Woodexport	HOSTCC HOSTCFLAGS HOSTLDFLAGS PEDCFLAGS HOSTSTRIP CROSS_COMPILE \
319434c51a5SPeter Tyser	AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
32014d0a02aSWolfgang Denkexport	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
321e2211743Swdenk
322e2211743Swdenk#########################################################################
323e2211743Swdenk
3245ec5529bSMike Frysinger# Allow boards to use custom optimize flags on a per dir/file basis
32589f39e17SPeter TyserBCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
326326a6945SMike FrysingerALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
327326a6945SMike FrysingerALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
32847508843SSimon GlassEXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR))
32947508843SSimon GlassALL_CFLAGS += $(EXTRA_CPPFLAGS)
33047508843SSimon Glass
33147508843SSimon Glass# The _DEP version uses the $< file target (for dependency generation)
33247508843SSimon Glass# See rules.mk
33347508843SSimon GlassEXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \
33447508843SSimon Glass		$(CPPFLAGS_$(BCURDIR))
335f9328639SMarian Balakowicz$(obj)%.s:	%.S
336326a6945SMike Frysinger	$(CPP) $(ALL_AFLAGS) -o $@ $<
337f9328639SMarian Balakowicz$(obj)%.o:	%.S
338326a6945SMike Frysinger	$(CC)  $(ALL_AFLAGS) -o $@ $< -c
339f9328639SMarian Balakowicz$(obj)%.o:	%.c
3404ab64933SKim Phillipsifneq ($(CHECKSRC),0)
3414ab64933SKim Phillips	$(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $<
3424ab64933SKim Phillipsendif
343326a6945SMike Frysinger	$(CC)  $(ALL_CFLAGS) -o $@ $< -c
34431f30c9eSMike Frysinger$(obj)%.i:	%.c
345326a6945SMike Frysinger	$(CPP) $(ALL_CFLAGS) -o $@ $< -c
34631f30c9eSMike Frysinger$(obj)%.s:	%.c
347326a6945SMike Frysinger	$(CC)  $(ALL_CFLAGS) -o $@ $< -c -S
348f9328639SMarian Balakowicz
349e2211743Swdenk#########################################################################
3506d8962e8SSebastien Carlier
3516d8962e8SSebastien Carlier# If the list of objects to link is empty, just create an empty built-in.o
3526d8962e8SSebastien Carliercmd_link_o_target = $(if $(strip $1),\
3538aba9dceSNobuhiro Iwamatsu		      $(LD) $(LDFLAGS) -r -o $@ $1,\
3546d8962e8SSebastien Carlier		      rm -f $@; $(AR) rcs $@ )
3556d8962e8SSebastien Carlier
3566d8962e8SSebastien Carlier#########################################################################
357