blob: 1a29859053f02374063981a3e3b1442ec4c0bc6b [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#
2# (C) Copyright 2004-2006, Texas Instruments, <www.ti.com>
3# Jian Zhang <jzhang@ti.com>
4#
5# (C) Copyright 2000-2004
6# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7#
8# See file CREDITS for list of people who contributed to this
9# project.
10#
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.
15#
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.
20#
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,
24# MA 02111-1307 USA
25#
26VERSION = 1
27PATCHLEVEL = 3
28SUBLEVEL = 4
29EXTRAVERSION =
30ORGANIZATION="ZTE Inc"
31Z_LOADER_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
32VERSION_FILE = include/version_autogenerated.h
33
34HOSTARCH := $(shell uname -m | \
35 sed -e s/i.86/i386/ \
36 -e s/sun4u/sparc64/ \
37 -e s/arm.*/arm/ \
38 -e s/sa110/arm/ \
39 -e s/powerpc/ppc/ \
40 -e s/macppc/ppc/)
41
42HOSTOS := $(shell uname -s | tr A-Z a-z | \
43 sed -e 's/\(cygwin\).*/cygwin/')
44
45export HOSTARCH
46
47# Deal with colliding definitions from tcsh etc.
48VENDOR=
49
50#########################################################################
51
52TOPDIR_ := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
53TOPDIR := $(shell echo "$(TOPDIR_)"| sed -e "s/\:/\\\:/g")
54export TOPDIR
55
56ifndef CROSS_COMPILE
57ARCH = arm
58CROSS_COMPILE = $(TOPDIR)/../../../../build/compiler/gcc-4.9.4_thumb_linux/usr/bin/arm-buildroot-linux-uclibcgnueabi-
59export CROSS_COMPILE
60endif
61
62ifeq (include/config.mk,$(wildcard include/config.mk))
63# load ARCH, BOARD, and CPU configuration
64include include/config.mk
65export ARCH CPU BOARD VENDOR
66# load other configuration
67include $(TOPDIR)/config.mk
68
69
70#########################################################################
71# Z-LOAD objects....order is important (i.e. start must be first)
72
73OBJS = cpu/$(CPU)/start.o
74
75
76LIBS += board/$(BOARDDIR)/lib$(BOARD).a
77LIBS += cpu/$(CPU)/lib$(CPU).a
78LIBS += lib/lib$(ARCH).a
79LIBS += drivers/libdrivers.a
80.PHONY : $(LIBS)
81
82# Add GCC lib
83PLATFORM_LIBS += -nostdlib
84#PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`)/thumb2 -lgcc
85
86SUBDIRS =
87#########################################################################
88#########################################################################
89
90platform: version $(OBJS) $(LIBS) $(LDSCRIPT)
91 @echo "--Finished build [ Platform_Design ] ..."
92 @echo "...............................................OK...."
93 @echo ""
94
95together: z-load.bin
96
97
98z-load.bin: z-load
99 $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
100
101z-load:
102 UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
103 $(LD) $(LDFLAGS) $$UNDEF_SYM $(OBJS) \
104 --start-group $(LIBS) --end-group $(PLATFORM_LIBS) \
105 -Map z-load.map -o z-load
106
107$(LIBS):
108 $(MAKE) -C `dirname $@`
109
110System.map: z-load
111 @$(NM) $< | \
112 grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
113 sort > System.map
114
115version:
116 @echo -n "#define Z_LOADER_VERSION \""$(ORGANIZATION)" Z-Loader " > $(VERSION_FILE); \
117 echo -n "$(Z_LOADER_VERSION)" >> $(VERSION_FILE); \
118 echo "\"" >> $(VERSION_FILE)
119
120#########################################################################
121else
122all install z-load z-load.srec depend dep:
123 @echo "System not configured - see README" >&2
124 @ exit 1
125endif
126
127#########################################################################
128
129unconfig:
130 rm -f include/config.h include/config.mk
131
132
133#########################################################################
134## ZX297520v3 (ARM-Cortex M0) Systems
135#########################################################################
136zx297520v3_tloader_config : unconfig
137 @./mkconfig $(@:_config=) arm m0 zx297520v3
138######## ARCH CPU BOARD
139 echo "/* Automatically generated - do not edit */" >./include/config.h; \
140 echo "/* Automatically generated - do not edit */" >./include/board.h; \
141 echo "#define CPU_SHIFT 0" >./include/board.h; \
142 echo "#include <configs/zx297520v3.h>" >>./include/config.h; \
143 echo "#define CFG_TLOAD 1" >./include/load_mode.h; \
144 echo "TEXT_BASE = 0x82000" >./board/zx297520v3/config.mk;
145
146zx297520v3_zloader_dlon_config : unconfig
147 @./mkconfig $(@:_config=) arm m0 zx297520v3
148######## ARCH CPU BOARD
149 echo "/* Automatically generated - do not edit */" >./include/config.h; \
150 echo "/* Automatically generated - do not edit */" >./include/board.h; \
151 echo "#define CPU_SHIFT 0" >./include/board.h; \
152 echo "#define CONFIG_DL_DISABLE 0" >>./include/board.h; \
153 echo "#include <configs/zx297520v3.h>" >>./include/config.h; \
154 echo "#define CFG_ZLOAD 1" >./include/load_mode.h;\
155 echo "TEXT_BASE = 0x100000" >./board/zx297520v3/config.mk;
156
157zx297520v3_zloader_dloff_config : unconfig
158 @./mkconfig $(@:_config=) arm m0 zx297520v3
159######## ARCH CPU BOARD
160 echo "/* Automatically generated - do not edit */" >./include/config.h; \
161 echo "/* Automatically generated - do not edit */" >./include/board.h; \
162 echo "#define CPU_SHIFT 0" >./include/board.h; \
163 echo "#define CONFIG_DL_DISABLE 1" >>./include/board.h; \
164 echo "#include <configs/zx297520v3.h>" >>./include/config.h; \
165 echo "#define CFG_ZLOAD 1" >./include/load_mode.h;\
166 echo "TEXT_BASE = 0x100000" >./board/zx297520v3/config.mk;
167
168
169####################################################################
170### clean
171####################################################################
172clean:
173 find . -type f \
174 \( -name 'core' -o -name '*.bak' -o -name '*~' \
175 -o -name '*.o' -o -name '*.a' \) -print \
176 | xargs rm -f
177
178clobber: clean
179 find . -type f \
180 \( -name .depend -o -name '*.srec' -o -name '*.bin' \) \
181 -print \
182 | xargs rm -f
183 rm -f $(OBJS) *.bak tags TAGS
184 rm -fr *.*~
185 rm -f z-load z-load.map $(ALL)
186 rm -fr include/asm/proc include/asm/arch $(VERSION_FILE)
187
188mrproper \
189distclean: clobber unconfig
190
191backup:
192 F=`basename $(TOPDIR)` ; cd .. ; \
193 gtar --force-local -zcvf `date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
194
195#########################################################################