14bedea94SChris Zankel#
24bedea94SChris Zankel# This file is subject to the terms and conditions of the GNU General Public
34bedea94SChris Zankel# License.  See the file "COPYING" in the main directory of this archive
44bedea94SChris Zankel# for more details.
54bedea94SChris Zankel#
64bedea94SChris Zankel
74bedea94SChris ZankelGZIP = gzip
84bedea94SChris ZankelGZIP_FLAGS = -v9fc
94bedea94SChris Zankelifeq ($(BIG_ENDIAN),1)
104bedea94SChris ZankelOBJCOPY_ARGS 	:= -O elf32-xtensa-be
114bedea94SChris Zankelelse
124bedea94SChris ZankelOBJCOPY_ARGS 	:= -O elf32-xtensa-le
134bedea94SChris Zankelendif
144bedea94SChris Zankel
15e7d163f7SChris ZankelLD_ARGS	= -T $(srctree)/$(obj)/boot.ld
164bedea94SChris Zankel
174bedea94SChris Zankelboot-y	:= bootstrap.o
184bedea94SChris Zankel
194bedea94SChris ZankelOBJS	:= $(addprefix $(obj)/,$(boot-y))
20e7d163f7SChris ZankelLIBS	:= arch/xtensa/boot/lib/lib.a arch/xtensa/lib/lib.a
214bedea94SChris Zankel
224bedea94SChris ZankelLIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
234bedea94SChris Zankel
244bedea94SChris ZankelzImage: vmlinux $(OBJS) $(LIBS)
254bedea94SChris Zankel	$(OBJCOPY) --strip-all -R .comment -R .xt.insn -O binary \
26e7d163f7SChris Zankel		vmlinux vmlinux.tmp
274bedea94SChris Zankel	gzip -vf9 vmlinux.tmp
284bedea94SChris Zankel	$(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \
294bedea94SChris Zankel		--add-section image=vmlinux.tmp.gz \
304bedea94SChris Zankel		--set-section-flags image=contents,alloc,load,load,data \
314bedea94SChris Zankel		$(OBJS) $@.tmp
324bedea94SChris Zankel	$(LD) $(LD_ARGS) -o $@.elf $@.tmp $(LIBS) -L/xtensa-elf/lib $(LIBGCC)
33e7d163f7SChris Zankel	$(OBJCOPY) -S -O binary $@.elf arch/$(ARCH)/boot/$@.redboot
34e7d163f7SChris Zankel	rm -f $@.tmp $@.elf vmlinux.tmp.gz
354bedea94SChris Zankel
36