2 # (C) Copyright 2004-2006, Texas Instruments, <www.ti.com>
3 # Jian Zhang <jzhang@ti.com>
5 # (C) Copyright 2000-2004
6 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 # See file CREDITS for list of people who contributed to this
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation; either version 2 of
14 # the License, or (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 HOSTARCH := $(shell uname -m | \
35 HOSTOS := $(shell uname -s | tr A-Z a-z | \
36 sed -e 's/\(cygwin\).*/cygwin/')
40 # Deal with colliding definitions from tcsh etc.
43 #########################################################################
45 # X-loader build supports producing a object files to the separate external
46 # directory. Two use cases are supported:
48 # 1) Add O= to the make command line
49 # 'make O=/tmp/build all'
51 # 2) Set environement variable BUILD_DIR to point to the desired location
52 # 'export BUILD_DIR=/tmp/build'
55 # Command line 'O=' setting overrides BUILD_DIR environent variable.
57 # When none of the above methods is used the local build is performed and
58 # the object files are placed in the source directory.
62 ifeq ("$(origin O)", "command line")
68 saved-output := $(BUILD_DIR)
70 # Attempt to create a output directory.
71 $(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
73 # Verify if it was successful.
74 BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
75 $(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
76 endif # ifneq ($(BUILD_DIR),)
78 OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
82 export TOPDIR SRCTREE OBJTREE
84 MKCONFIG := $(SRCTREE)/mkconfig
87 ifneq ($(OBJTREE),$(SRCTREE))
92 # $(obj) and (src) are defined in config.mk but here in main Makefile
93 # we also need them before config.mk is included which is the case for
94 # some targets like unconfig, clean, clobber, distclean, etc.
95 ifneq ($(OBJTREE),$(SRCTREE))
104 # Make sure CDPATH settings don't interfere
107 #########################################################################
109 ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))
110 # load ARCH, BOARD, and CPU configuration
111 include $(obj)include/config.mk
112 export ARCH CPU BOARD VENDOR
113 # load other configuration
114 include $(TOPDIR)/config.mk
117 CROSS_COMPILE = arm-none-linux-gnueabi-
118 #CROSS_COMPILE = arm-linux-
122 #########################################################################
123 # X-LOAD objects....order is important (i.e. start must be first)
125 OBJS = cpu/$(CPU)/start.o
127 OBJS := $(addprefix $(obj),$(OBJS))
129 LIBS += board/$(BOARDDIR)/lib$(BOARD).a
130 LIBS += cpu/$(CPU)/lib$(CPU).a
131 LIBS += lib/lib$(ARCH).a
132 LIBS += fs/fat/libfat.a
133 LIBS += disk/libdisk.a
134 LIBS += drivers/libdrivers.a
135 LIBS += common/libcommon.a
137 LIBS := $(addprefix $(obj),$(sort $(LIBS)))
141 PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
145 __OBJS := $(subst $(obj),,$(OBJS))
146 __LIBS := $(subst $(obj),,$(LIBS))
148 #########################################################################
149 #########################################################################
151 ALL = $(obj)x-load.bin.ift $(obj)System.map
155 $(obj)x-load.bin.ift: $(obj)signGP $(obj)System.map $(obj)x-load.bin
156 $(obj)./signGP $(obj)x-load.bin $(TEXT_BASE) $(CONFIG_HEADER)
157 cp $(obj)x-load.bin.ift $(obj)MLO
159 $(obj)x-load.bin: $(obj)x-load
160 $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
162 $(obj)x-load: $(OBJS) $(LIBS) $(LDSCRIPT)
163 UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
164 cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
165 --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
166 -Map x-load.map -o x-load
169 $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
172 $(MAKE) -C $(dir $(subst $(obj),,$@))
174 $(obj)System.map: $(obj)x-load
176 grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
177 sort > $(obj)System.map
179 oneboot: $(obj)x-load.bin
182 $(obj)signGP: scripts/signGP.c
183 $(HOSTCC) $(HOSTCFLAGS) -o $(obj)signGP $<
185 #########################################################################
187 all $(obj)x-load $(obj)x-load.bin oneboot depend dep $(obj)System.map:
188 @echo "System not configured - see README" >&2
192 #########################################################################
195 rm -f $(obj)include/config.h $(obj)include/config.mk
197 #========================================================================
199 #========================================================================
200 #########################################################################
201 ## OMAP2 (ARM1136) Systems
202 #########################################################################
204 #########################################################################
205 ## OMAP3 (ARM-CortexA8) Systems
206 #########################################################################
207 omap3430sdp_config : unconfig
208 @$(MKCONFIG) $(@:_config=) arm omap3 omap3430sdp
210 omap3430labrador_config : unconfig
211 @$(MKCONFIG) $(@:_config=) arm omap3 omap3430labrador
213 omap3evm_config : unconfig
214 @$(MKCONFIG) $(@:_config=) arm omap3 omap3evm
216 overo_config : unconfig
217 @$(MKCONFIG) $(@:_config=) arm omap3 overo
219 omap3530beagle_config : unconfig
220 @$(MKCONFIG) $(@:_config=) arm omap3 omap3530beagle
222 igep00x0_config : unconfig
223 @$(MKCONFIG) $(@:_config=) arm omap3 igep00x0
225 tam3517_config : unconfig
226 @$(MKCONFIG) $(@:_config=) arm omap3 tam3517
228 tao3530_config : unconfig
229 @$(MKCONFIG) $(@:_config=) arm omap3 tao3530
231 tdm3730_config : unconfig
232 @$(MKCONFIG) $(@:_config=) arm omap3 tdm3730
234 #########################################################################
235 ## OMAP4 (ARM-CortexA9) Systems
236 #########################################################################
237 omap4430panda_config : unconfig
238 @$(MKCONFIG) $(@:_config=) arm omap4 omap4430panda 1
240 #########################################################################
243 find $(OBJTREE) -type f \
244 \( -name 'core' -o -name '*.bak' -o -name '*~' \
245 -o -name '*.o' -o -name '*.a' \) -print \
249 find $(OBJTREE) -type f \
250 \( -name .depend -o -name '*.srec' -o -name '*.bin' \) \
253 rm -f $(OBJS) $(obj)*.bak $(obj)tags $(obj)TAGS
255 rm -f $(obj)x-load $(obj)x-load.map $(ALL) $(obj)x-load.bin.ift $(obj)signGP $(obj)MLO
256 rm -f $(obj)include/asm/proc $(obj)include/asm/arch
258 ifeq ($(OBJTREE),$(SRCTREE))
260 distclean: clobber unconfig
263 distclean: clobber unconfig
268 F=`basename $(TOPDIR)` ; cd .. ; \
269 gtar --force-local -zcvf `date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
271 #########################################################################