]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - Makefile
Remove unused definition IOMUX_SION
[karo-tx-uboot.git] / Makefile
1 #
2 # (C) Copyright 2000-2012
3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 #
5 # See file CREDITS for list of people who contributed to this
6 # project.
7 #
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundatio; either version 2 of
11 # the License, or (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 # MA 02111-1307 USA
22 #
23
24 VERSION = 2012
25 PATCHLEVEL = 04
26 SUBLEVEL = 01
27 EXTRAVERSION =
28 ifneq "$(SUBLEVEL)" ""
29 U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
30 else
31 U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION)
32 endif
33
34 HOSTARCH := $(shell uname -m | \
35         sed -e s/i.86/x86/ \
36             -e s/sun4u/sparc64/ \
37             -e s/arm.*/arm/ \
38             -e s/sa110/arm/ \
39             -e s/ppc64/powerpc/ \
40             -e s/ppc/powerpc/ \
41             -e s/macppc/powerpc/\
42             -e s/sh.*/sh/)
43
44 HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
45             sed -e 's/\(cygwin\).*/cygwin/')
46
47 # Set shell to bash if possible, otherwise fall back to sh
48 SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
49         else if [ -x /bin/bash ]; then echo /bin/bash; \
50         else echo sh; fi; fi)
51
52 export  HOSTARCH HOSTOS SHELL
53
54 # Deal with colliding definitions from tcsh etc.
55 VENDOR=
56
57 #########################################################################
58 # Allow for silent builds
59 ifeq (,$(findstring s,$(MAKEFLAGS)))
60 XECHO = echo
61 else
62 XECHO = :
63 endif
64
65 #########################################################################
66 #
67 # U-boot build supports producing a object files to the separate external
68 # directory. Two use cases are supported:
69 #
70 # 1) Add O= to the make command line
71 # 'make O=/tmp/build all'
72 #
73 # 2) Set environement variable BUILD_DIR to point to the desired location
74 # 'export BUILD_DIR=/tmp/build'
75 # 'make'
76 #
77 # The second approach can also be used with a MAKEALL script
78 # 'export BUILD_DIR=/tmp/build'
79 # './MAKEALL'
80 #
81 # Command line 'O=' setting overrides BUILD_DIR environent variable.
82 #
83 # When none of the above methods is used the local build is performed and
84 # the object files are placed in the source directory.
85 #
86
87 ifdef O
88 ifeq ("$(origin O)", "command line")
89 BUILD_DIR := $(O)
90 endif
91 endif
92
93 ifneq ($(BUILD_DIR),)
94 saved-output := $(BUILD_DIR)
95
96 # Attempt to create a output directory.
97 $(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
98
99 # Verify if it was successful.
100 BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
101 $(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
102 endif # ifneq ($(BUILD_DIR),)
103
104 OBJTREE         := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
105 SPLTREE         := $(OBJTREE)/spl
106 SRCTREE         := $(CURDIR)
107 TOPDIR          := $(SRCTREE)
108 LNDIR           := $(OBJTREE)
109 export  TOPDIR SRCTREE OBJTREE SPLTREE
110
111 MKCONFIG        := $(SRCTREE)/mkconfig
112 export MKCONFIG
113
114 ifneq ($(OBJTREE),$(SRCTREE))
115 REMOTE_BUILD    := 1
116 export REMOTE_BUILD
117 endif
118
119 # $(obj) and (src) are defined in config.mk but here in main Makefile
120 # we also need them before config.mk is included which is the case for
121 # some targets like unconfig, clean, clobber, distclean, etc.
122 ifneq ($(OBJTREE),$(SRCTREE))
123 obj := $(OBJTREE)/
124 src := $(SRCTREE)/
125 else
126 obj :=
127 src :=
128 endif
129 export obj src
130
131 TIMESTAMP_FILE = $(obj)include/generated/timestamp_autogenerated.h
132 VERSION_FILE = $(obj)include/generated/version_autogenerated.h
133
134 # Make sure CDPATH settings don't interfere
135 unexport CDPATH
136
137 #########################################################################
138
139 # The "tools" are needed early, so put this first
140 # Don't include stuff already done in $(LIBS)
141 # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
142 # is "yes"), so compile examples after U-Boot is compiled.
143 SUBDIR_TOOLS = tools
144 SUBDIR_EXAMPLES = examples/standalone examples/api
145 SUBDIRS = $(SUBDIR_TOOLS)
146
147 .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
148
149 ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))
150
151 # Include autoconf.mk before config.mk so that the config options are available
152 # to all top level build files.  We need the dummy all: target to prevent the
153 # dependency target in autoconf.mk.dep from being the default.
154 all:
155 sinclude $(obj)include/autoconf.mk.dep
156 sinclude $(obj)include/autoconf.mk
157
158 ifndef CONFIG_SANDBOX
159 SUBDIRS += $(SUBDIR_EXAMPLES)
160 endif
161
162 # load ARCH, BOARD, and CPU configuration
163 include $(obj)include/config.mk
164 export  ARCH CPU BOARD VENDOR SOC
165
166 # set default to nothing for native builds
167 ifeq ($(HOSTARCH),$(ARCH))
168 CROSS_COMPILE ?=
169 endif
170
171 # load other configuration
172 include $(TOPDIR)/config.mk
173
174 # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
175 # that (or fail if absent).  Otherwise, search for a linker script in a
176 # standard location.
177
178 LDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT))
179
180 ifndef LDSCRIPT
181         #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
182         ifdef CONFIG_SYS_LDSCRIPT
183                 # need to strip off double quotes
184                 LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT))
185         endif
186 endif
187
188 # If there is no specified link script, we look in a number of places for it
189 ifndef LDSCRIPT
190         ifeq ($(CONFIG_NAND_U_BOOT),y)
191                 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
192                 ifeq ($(wildcard $(LDSCRIPT)),)
193                         LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
194                 endif
195         endif
196         ifeq ($(wildcard $(LDSCRIPT)),)
197                 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
198         endif
199         ifeq ($(wildcard $(LDSCRIPT)),)
200                 LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
201         endif
202         ifeq ($(wildcard $(LDSCRIPT)),)
203                 LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds
204                 # We don't expect a Makefile here
205                 LDSCRIPT_MAKEFILE_DIR =
206         endif
207         ifeq ($(wildcard $(LDSCRIPT)),)
208 $(error could not find linker script)
209         endif
210 endif
211
212 #########################################################################
213 # U-Boot objects....order is important (i.e. start must be first)
214
215 OBJS  = $(CPUDIR)/start.o
216 ifeq ($(CPU),x86)
217 OBJS += $(CPUDIR)/start16.o
218 OBJS += $(CPUDIR)/resetvec.o
219 endif
220 ifeq ($(CPU),ppc4xx)
221 OBJS += $(CPUDIR)/resetvec.o
222 endif
223 ifeq ($(CPU),mpc85xx)
224 OBJS += $(CPUDIR)/resetvec.o
225 endif
226
227 OBJS := $(addprefix $(obj),$(OBJS))
228
229 LIBS  = lib/libgeneric.o
230 LIBS += lib/lzma/liblzma.o
231 LIBS += lib/lzo/liblzo.o
232 LIBS += lib/zlib/libz.o
233 LIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \
234         "board/$(VENDOR)/common/lib$(VENDOR).o"; fi)
235 LIBS += $(CPUDIR)/lib$(CPU).o
236 ifdef SOC
237 LIBS += $(CPUDIR)/$(SOC)/lib$(SOC).o
238 endif
239 ifeq ($(CPU),ixp)
240 LIBS += arch/arm/cpu/ixp/npe/libnpe.o
241 endif
242 ifeq ($(CONFIG_OF_EMBED),y)
243 LIBS += dts/libdts.o
244 endif
245 LIBS += arch/$(ARCH)/lib/lib$(ARCH).o
246 LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o \
247         fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o \
248         fs/ubifs/libubifs.o
249 LIBS += net/libnet.o
250 LIBS += disk/libdisk.o
251 LIBS += drivers/bios_emulator/libatibiosemu.o
252 LIBS += drivers/block/libblock.o
253 LIBS += drivers/dma/libdma.o
254 LIBS += drivers/fpga/libfpga.o
255 LIBS += drivers/gpio/libgpio.o
256 LIBS += drivers/hwmon/libhwmon.o
257 LIBS += drivers/i2c/libi2c.o
258 LIBS += drivers/input/libinput.o
259 LIBS += drivers/misc/libmisc.o
260 LIBS += drivers/mmc/libmmc.o
261 LIBS += drivers/mtd/libmtd.o
262 LIBS += drivers/mtd/nand/libnand.o
263 LIBS += drivers/mtd/onenand/libonenand.o
264 LIBS += drivers/mtd/ubi/libubi.o
265 LIBS += drivers/mtd/spi/libspi_flash.o
266 LIBS += drivers/net/libnet.o
267 LIBS += drivers/net/phy/libphy.o
268 LIBS += drivers/pci/libpci.o
269 LIBS += drivers/pcmcia/libpcmcia.o
270 LIBS += drivers/power/libpower.o
271 LIBS += drivers/spi/libspi.o
272 ifeq ($(CPU),mpc83xx)
273 LIBS += drivers/qe/libqe.o
274 LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
275 LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
276 endif
277 ifeq ($(CPU),mpc85xx)
278 LIBS += drivers/qe/libqe.o
279 LIBS += drivers/net/fm/libfm.o
280 LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
281 LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
282 endif
283 ifeq ($(CPU),mpc86xx)
284 LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
285 LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
286 endif
287 LIBS += drivers/rtc/librtc.o
288 LIBS += drivers/serial/libserial.o
289 ifeq ($(CONFIG_GENERIC_LPC_TPM),y)
290 LIBS += drivers/tpm/libtpm.o
291 endif
292 LIBS += drivers/twserial/libtws.o
293 LIBS += drivers/usb/eth/libusb_eth.o
294 LIBS += drivers/usb/gadget/libusb_gadget.o
295 LIBS += drivers/usb/host/libusb_host.o
296 LIBS += drivers/usb/musb/libusb_musb.o
297 LIBS += drivers/usb/phy/libusb_phy.o
298 LIBS += drivers/usb/ulpi/libusb_ulpi.o
299 LIBS += drivers/video/libvideo.o
300 LIBS += drivers/watchdog/libwatchdog.o
301 LIBS += common/libcommon.o
302 LIBS += lib/libfdt/libfdt.o
303 LIBS += api/libapi.o
304 LIBS += post/libpost.o
305
306 ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
307 LIBS += $(CPUDIR)/omap-common/libomap-common.o
308 endif
309
310 ifeq ($(SOC),mx5)
311 LIBS += $(CPUDIR)/imx-common/libimx-common.o
312 endif
313 ifeq ($(SOC),mx6)
314 LIBS += $(CPUDIR)/imx-common/libimx-common.o
315 endif
316
317 ifeq ($(SOC),s5pc1xx)
318 LIBS += $(CPUDIR)/s5p-common/libs5p-common.o
319 endif
320 ifeq ($(SOC),exynos)
321 LIBS += $(CPUDIR)/s5p-common/libs5p-common.o
322 endif
323
324 LIBS := $(addprefix $(obj),$(sort $(LIBS)))
325 .PHONY : $(LIBS)
326
327 LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).o
328 LIBBOARD := $(addprefix $(obj),$(LIBBOARD))
329
330 # Add GCC lib
331 ifdef USE_PRIVATE_LIBGCC
332 ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
333 PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o
334 else
335 PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
336 endif
337 else
338 PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
339 endif
340 PLATFORM_LIBS += $(PLATFORM_LIBGCC)
341 export PLATFORM_LIBS
342
343 # Special flags for CPP when processing the linker script.
344 # Pass the version down so we can handle backwards compatibility
345 # on the fly.
346 LDPPFLAGS += \
347         -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
348         -DCPUDIR=$(CPUDIR) \
349         $(shell $(LD) --version | \
350           sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
351
352 __OBJS := $(subst $(obj),,$(OBJS))
353 __LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))
354
355 #########################################################################
356 #########################################################################
357
358 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
359 BOARD_SIZE_CHECK = \
360         @actual=`wc -c $@ | awk '{print $$1}'`; \
361         limit=$(CONFIG_BOARD_SIZE_LIMIT); \
362         if test $$actual -gt $$limit; then \
363                 echo "$@ exceeds file size limit:"; \
364                 echo "  limit:  $$limit bytes"; \
365                 echo "  actual: $$actual bytes"; \
366                 echo "  excess: $$((actual - limit)) bytes"; \
367                 exit 1; \
368         fi
369 else
370 BOARD_SIZE_CHECK =
371 endif
372
373 # Always append ALL so that arch config.mk's can add custom ones
374 ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
375
376 ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin
377 ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin
378 ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin
379 ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
380 ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
381
382 all:            $(ALL-y) $(SUBDIR_EXAMPLES)
383
384 $(obj)u-boot.dtb:       $(obj)u-boot
385                 $(MAKE) -C dts binary
386                 mv $(obj)dts/dt.dtb $@
387
388 $(obj)u-boot-dtb.bin:   $(obj)u-boot.bin $(obj)u-boot.dtb
389                 cat $^ >$@
390
391 $(obj)u-boot.hex:       $(obj)u-boot
392                 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
393
394 $(obj)u-boot.srec:      $(obj)u-boot
395                 $(OBJCOPY) -O srec $< $@
396
397 $(obj)u-boot.bin:       $(obj)u-boot
398                 $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
399                 $(BOARD_SIZE_CHECK)
400
401 $(obj)u-boot.ldr:       $(obj)u-boot
402                 $(CREATE_LDR_ENV)
403                 $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
404                 $(BOARD_SIZE_CHECK)
405
406 $(obj)u-boot.ldr.hex:   $(obj)u-boot.ldr
407                 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
408
409 $(obj)u-boot.ldr.srec:  $(obj)u-boot.ldr
410                 $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
411
412 $(obj)u-boot.img:       $(obj)u-boot.bin
413                 $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
414                 -O u-boot -a $(CONFIG_SYS_TEXT_BASE) -e 0 \
415                 -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
416                         sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
417                 -d $< $@
418
419 $(obj)u-boot.imx:       $(obj)u-boot.bin
420                 $(obj)tools/mkimage -n  $(CONFIG_IMX_CONFIG) -T imximage \
421                 -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
422
423 $(obj)u-boot.kwb:       $(obj)u-boot.bin
424                 $(obj)tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
425                 -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
426
427 $(obj)u-boot.sha1:      $(obj)u-boot.bin
428                 $(obj)tools/ubsha1 $(obj)u-boot.bin
429
430 $(obj)u-boot.dis:       $(obj)u-boot
431                 $(OBJDUMP) -d $< > $@
432
433 $(obj)u-boot.ubl:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
434                 $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
435                 cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $(obj)u-boot-ubl.bin
436                 $(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
437                 -e $(CONFIG_SYS_TEXT_BASE) -d $(obj)u-boot-ubl.bin $(obj)u-boot.ubl
438                 rm $(obj)u-boot-ubl.bin
439                 rm $(obj)spl/u-boot-spl-pad.bin
440
441 $(obj)u-boot.ais:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
442                 $(obj)tools/mkimage -s -n /dev/null -T aisimage \
443                         -e $(CONFIG_SPL_TEXT_BASE) \
444                         -d $(obj)spl/u-boot-spl.bin \
445                         $(obj)spl/u-boot-spl.ais
446                 $(OBJCOPY) ${OBJCFLAGS} -I binary \
447                         --pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
448                         $(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais
449                 cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.bin > \
450                         $(obj)u-boot.ais
451                 rm $(obj)spl/u-boot-spl{,-pad}.ais
452
453 $(obj)u-boot.bd:       $(TOPDIR)/board/$(BOARDDIR)/u-boot.bd
454                 sed "s:@@BUILD_DIR@@:$(obj):g" $< > $@
455
456 $(obj)u-boot.sb:       $(obj)u-boot.bd elftosb $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
457                 $(TOPDIR)/tools/elftosb/bld/linux/elftosb -zdf imx28 -c $< -o $@
458
459 ifeq ($(CONFIG_SANDBOX),y)
460 GEN_UBOOT = \
461                 cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
462                         -Wl,--start-group $(__LIBS) -Wl,--end-group \
463                         $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
464 else
465 GEN_UBOOT = \
466                 UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
467                 sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
468                 cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__OBJS) \
469                         --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
470                         -Map u-boot.map -o u-boot
471 endif
472
473 $(obj)u-boot:   depend \
474                 $(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
475                 $(GEN_UBOOT)
476 ifeq ($(CONFIG_KALLSYMS),y)
477                 smap=`$(call SYSTEM_MAP,u-boot) | \
478                         awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
479                 $(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \
480                         -c common/system_map.c -o $(obj)common/system_map.o
481                 $(GEN_UBOOT) $(obj)common/system_map.o
482 endif
483
484 $(OBJS):        depend
485                 $(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
486
487 $(LIBS):        depend $(SUBDIR_TOOLS)
488                 $(MAKE) -C $(dir $(subst $(obj),,$@))
489
490 $(LIBBOARD):    depend $(LIBS)
491                 $(MAKE) -C $(dir $(subst $(obj),,$@))
492
493 $(SUBDIRS):     depend
494                 $(MAKE) -C $@ all
495
496 $(SUBDIR_EXAMPLES): $(obj)u-boot
497
498 $(LDSCRIPT):    depend
499                 $(MAKE) -C $(dir $@) $(notdir $@)
500
501 $(obj)u-boot.lds: $(LDSCRIPT)
502                 $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
503
504 nand_spl:       $(TIMESTAMP_FILE) $(VERSION_FILE) depend
505                 $(MAKE) -C nand_spl/board/$(BOARDDIR) all
506
507 $(obj)u-boot-nand.bin:  nand_spl $(obj)u-boot.bin
508                 cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
509
510 onenand_ipl:    $(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk
511                 $(MAKE) -C onenand_ipl/board/$(BOARDDIR) all
512
513 $(obj)u-boot-onenand.bin:       onenand_ipl $(obj)u-boot.bin
514                 cat $(ONENAND_BIN) $(obj)u-boot.bin > $(obj)u-boot-onenand.bin
515
516 $(obj)spl/u-boot-spl.bin:       $(SUBDIR_TOOLS) depend
517                 $(MAKE) -C spl all
518
519 updater:
520                 $(MAKE) -C tools/updater all
521 elftosb:
522                 $(MAKE) -C $(SUBDIR_TOOLS)/elftosb all
523
524 # Explicitly make _depend in subdirs containing multiple targets to prevent
525 # parallel sub-makes creating .depend files simultaneously.
526 depend dep:     $(TIMESTAMP_FILE) $(VERSION_FILE) \
527                 $(obj)include/autoconf.mk \
528                 $(obj)include/generated/generic-asm-offsets.h \
529                 $(obj)include/generated/asm-offsets.h
530                 for dir in $(SUBDIRS) $(CPUDIR) $(LDSCRIPT_MAKEFILE_DIR) ; do \
531                         $(MAKE) -C $$dir _depend ; done
532
533 TAG_SUBDIRS = $(SUBDIRS)
534 TAG_SUBDIRS += $(dir $(__LIBS))
535 TAG_SUBDIRS += include
536
537 FIND := find
538 FINDFLAGS := -L
539
540 checkstack:
541                 $(CROSS_COMPILE)objdump -d $(obj)u-boot \
542                         `$(FIND) $(obj) -name u-boot-spl -print` | \
543                         perl $(src)tools/checkstack.pl $(ARCH)
544
545 tags ctags:
546                 ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
547                                                 -name '*.[chS]' -print`
548
549 etags:
550                 etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
551                                                 -name '*.[chS]' -print`
552 cscope:
553                 $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
554                                                 cscope.files
555                 cscope -b -q -k
556
557 SYSTEM_MAP = \
558                 $(NM) $1 | \
559                 grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
560                 LC_ALL=C sort
561 $(obj)System.map:       $(obj)u-boot
562                 @$(call SYSTEM_MAP,$<) > $(obj)System.map
563
564 checkthumb:
565         @if test $(call cc-version) -lt 0404; then \
566                 echo -n '*** Your GCC does not produce working '; \
567                 echo 'binaries in THUMB mode.'; \
568                 echo '*** Your board is configured for THUMB mode.'; \
569                 false; \
570         fi
571 #
572 # Auto-generate the autoconf.mk file (which is included by all makefiles)
573 #
574 # This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
575 # the dep file is only include in this top level makefile to determine when
576 # to regenerate the autoconf.mk file.
577 $(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
578         @$(XECHO) Generating $@ ; \
579         set -e ; \
580         : Generate the dependancies ; \
581         $(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \
582                 -MQ $(obj)include/autoconf.mk include/common.h > $@
583
584 $(obj)include/autoconf.mk: $(obj)include/config.h
585         @$(XECHO) Generating $@ ; \
586         set -e ; \
587         : Extract the config macros ; \
588         $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \
589                 sed -n -f tools/scripts/define2mk.sed > $@.tmp && \
590         mv $@.tmp $@
591
592 $(obj)include/generated/generic-asm-offsets.h:  $(obj)include/autoconf.mk.dep \
593         $(obj)lib/asm-offsets.s
594         @$(XECHO) Generating $@
595         tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@
596
597 $(obj)lib/asm-offsets.s:        $(obj)include/autoconf.mk.dep \
598         $(src)lib/asm-offsets.c
599         @mkdir -p $(obj)lib
600         $(CC) -DDO_DEPS_ONLY \
601                 $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
602                 -o $@ $(src)lib/asm-offsets.c -c -S
603
604 $(obj)include/generated/asm-offsets.h:  $(obj)include/autoconf.mk.dep \
605         $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
606         @echo Generating $@
607         tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@
608
609 $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s:   $(obj)include/autoconf.mk.dep
610         @mkdir -p $(obj)$(CPUDIR)/$(SOC)
611         if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
612                 $(CC) -DDO_DEPS_ONLY \
613                 $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
614                         -o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
615         else \
616                 touch $@; \
617         fi
618
619 #########################################################################
620 else    # !config.mk
621 all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
622 $(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \
623 $(filter-out tools,$(SUBDIRS)) \
624 updater depend dep tags ctags etags cscope $(obj)System.map:
625         @echo "System not configured - see README" >&2
626         @ exit 1
627
628 tools: $(VERSION_FILE) $(TIMESTAMP_FILE)
629         $(MAKE) -C $@ all
630 endif   # config.mk
631
632 $(VERSION_FILE):
633                 @mkdir -p $(dir $(VERSION_FILE))
634                 @( localvers='$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ; \
635                    printf '#define PLAIN_VERSION "%s%s"\n' \
636                         "$(U_BOOT_VERSION)" "$${localvers}" ; \
637                    printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
638                         "$(U_BOOT_VERSION)" "$${localvers}" ; \
639                 ) > $@.tmp
640                 @( printf '#define CC_VERSION_STRING "%s"\n' \
641                  '$(shell $(CC) --version | head -n 1)' )>>  $@.tmp
642                 @( printf '#define LD_VERSION_STRING "%s"\n' \
643                  '$(shell $(LD) -v | head -n 1)' )>>  $@.tmp
644                 @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
645
646 $(TIMESTAMP_FILE):
647                 @mkdir -p $(dir $(TIMESTAMP_FILE))
648                 @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp
649                 @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
650                 @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
651
652 easylogo env gdb:
653         $(MAKE) -C tools/$@ all MTD_VERSION=${MTD_VERSION}
654 gdbtools: gdb
655
656 tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
657         $(MAKE) -C tools HOST_TOOLS_ALL=y
658
659 .PHONY : CHANGELOG
660 CHANGELOG:
661         git log --no-merges U-Boot-1_1_5.. | \
662         unexpand -a | sed -e 's/\s\s*$$//' > $@
663
664 include/license.h: tools/bin2header COPYING
665         cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
666 #########################################################################
667
668 unconfig:
669         @rm -f $(obj)include/config.h $(obj)include/config.mk \
670                 $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
671                 $(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep
672
673 %_config::      unconfig
674         @$(MKCONFIG) -A $(@:_config=)
675
676 sinclude $(obj).boards.depend
677 $(obj).boards.depend:   boards.cfg
678         @awk '(NF && $$1 !~ /^#/) { print $$1 ": " $$1 "_config; $$(MAKE)" }' $< > $@
679
680 #
681 # Functions to generate common board directory names
682 #
683 lcname  = $(shell echo $(1) | sed -e 's/\(.*\)_config/\L\1/')
684 ucname  = $(shell echo $(1) | sed -e 's/\(.*\)_config/\U\1/')
685
686 #========================================================================
687 # ARM
688 #========================================================================
689
690 SX1_stdout_serial_config \
691 SX1_config:             unconfig
692         @mkdir -p $(obj)include
693         @if [ "$(findstring _stdout_serial_, $@)" ] ; then \
694                 echo "#undef CONFIG_STDOUT_USBTTY" >> $(obj)include/config.h ; \
695         else \
696                 echo "#define CONFIG_STDOUT_USBTTY" >> $(obj)include/config.h ; \
697         fi;
698         @$(MKCONFIG) -n $@ SX1 arm arm925t sx1
699
700 #########################################################################
701 ## ARM1176 Systems
702 #########################################################################
703 smdk6400_noUSB_config   \
704 smdk6400_config :       unconfig
705         @mkdir -p $(obj)include $(obj)board/samsung/smdk6400
706         @mkdir -p $(obj)nand_spl/board/samsung/smdk6400
707         @echo "#define CONFIG_NAND_U_BOOT" > $(obj)include/config.h
708         @echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
709         @if [ -z "$(findstring smdk6400_noUSB_config,$@)" ]; then                       \
710                 echo "RAM_TEXT = 0x57e00000" >> $(obj)board/samsung/smdk6400/config.tmp;\
711         else                                                                            \
712                 echo "RAM_TEXT = 0xc7e00000" >> $(obj)board/samsung/smdk6400/config.tmp;\
713         fi
714         @$(MKCONFIG) smdk6400 arm arm1176 smdk6400 samsung s3c64xx
715         @echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
716
717 #########################################################################
718 #########################################################################
719
720 clean:
721         @rm -f $(obj)examples/standalone/82559_eeprom                     \
722                $(obj)examples/standalone/atmel_df_pow2                    \
723                $(obj)examples/standalone/eepro100_eeprom                  \
724                $(obj)examples/standalone/hello_world                      \
725                $(obj)examples/standalone/interrupt                        \
726                $(obj)examples/standalone/mem_to_mem_idma2intr             \
727                $(obj)examples/standalone/sched                            \
728                $(obj)examples/standalone/smc911{11,x}_eeprom              \
729                $(obj)examples/standalone/test_burst                       \
730                $(obj)examples/standalone/timer
731         @rm -f $(obj)examples/api/demo{,.bin}
732         @rm -f $(obj)tools/bmp_logo        $(obj)tools/easylogo/easylogo  \
733                $(obj)tools/env/{fw_printenv,fw_setenv}                    \
734                $(obj)tools/envcrc                                         \
735                $(obj)tools/gdb/{astest,gdbcont,gdbsend}                   \
736                $(obj)tools/gen_eth_addr    $(obj)tools/img2srec           \
737                $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk         \
738                $(obj)tools/mk{smdk5250,}spl                               \
739                $(obj)tools/ncb             $(obj)tools/ubsha1
740         @rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image}        \
741                $(obj)board/matrix_vision/*/bootscript.img                 \
742                $(obj)board/voiceblue/eeprom                               \
743                $(obj)u-boot.lds                                           \
744                $(obj)arch/blackfin/cpu/bootrom-asm-offsets.[chs]          \
745                $(obj)arch/blackfin/cpu/init.{lds,elf}
746         @rm -f $(obj)include/bmp_logo.h
747         @rm -f $(obj)include/bmp_logo_data.h
748         @rm -f $(obj)lib/asm-offsets.s
749         @rm -f $(obj)include/generated/asm-offsets.h
750         @rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
751         @rm -f $(obj)nand_spl/{u-boot.lds,u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map,System.map}
752         @rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl.map}
753         @rm -f $(ONENAND_BIN)
754         @rm -f $(obj)onenand_ipl/u-boot.lds
755         @rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.lds,u-boot-spl.map}
756         @rm -f $(obj)MLO
757         @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
758         @find $(OBJTREE) -type f \
759                 \( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
760                 -o -name '*.o'  -o -name '*.a' -o -name '*.exe' \) -print \
761                 | xargs rm -f
762
763 # Removes everything not needed for testing u-boot
764 tidy:   clean
765         @find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f
766
767 clobber:        tidy
768         @find $(OBJTREE) -type f \( -name '*.srec' \
769                 -o -name '*.bin' -o -name u-boot.img \) \
770                 -print0 | xargs -0 rm -f
771         @rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
772                 $(obj)cscope.* $(obj)*.*~
773         @rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y)
774         @rm -f $(obj)u-boot.kwb
775         @rm -f $(obj)u-boot.imx
776         @rm -f $(obj)u-boot.ubl
777         @rm -f $(obj)u-boot.ais
778         @rm -f $(obj)u-boot.dtb
779         @rm -f $(obj)u-boot.sb
780         @rm -f $(obj)tools/inca-swap-bytes
781         @rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c
782         @rm -f $(obj)arch/powerpc/cpu/mpc83xx/ddr-gen?.c
783         @rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
784         @rm -fr $(obj)include/generated
785         @[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
786         @[ ! -d $(obj)onenand_ipl ] || find $(obj)onenand_ipl -name "*" -type l -print | xargs rm -f
787         @rm -f $(obj)dts/*.tmp
788
789 mrproper \
790 distclean:      clobber unconfig
791 ifneq ($(OBJTREE),$(SRCTREE))
792         rm -rf $(obj)*
793 endif
794
795 backup:
796         F=`basename $(TOPDIR)` ; cd .. ; \
797         gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
798
799 #########################################################################