1#
2# This file is subject to the terms and conditions of the GNU General Public
3# License.  See the file "COPYING" in the main directory of this archive
4# for more details.
5#
6
7OBJCOPY_ARGS := -O $(if $(CONFIG_CPU_BIG_ENDIAN),elf32-xtensa-be,elf32-xtensa-le)
8
9LD_ARGS	= -T $(srctree)/$(obj)/boot.ld
10
11boot-y	:= bootstrap.o
12targets	+= $(boot-y)
13
14OBJS	:= $(addprefix $(obj)/,$(boot-y))
15LIBS	:= arch/xtensa/boot/lib/lib.a arch/xtensa/lib/lib.a
16
17LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
18
19$(obj)/zImage.o: $(obj)/../vmlinux.bin.gz $(OBJS)
20	$(Q)$(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \
21		--add-section image=$< \
22		--set-section-flags image=contents,alloc,load,load,data \
23		$(OBJS) $@
24
25$(obj)/zImage.elf: $(obj)/zImage.o $(LIBS)
26	$(Q)$(LD) $(LD_ARGS) -o $@ $^ -L/xtensa-elf/lib $(LIBGCC)
27
28$(obj)/../zImage.redboot: $(obj)/zImage.elf
29	$(Q)$(OBJCOPY) -S -O binary $< $@
30	$(Q)$(kecho) '  Kernel: $@ is ready'
31
32all zImage: $(obj)/../zImage.redboot
33