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
7ifeq ($(BIG_ENDIAN),1)
8OBJCOPY_ARGS 	:= -O elf32-xtensa-be
9else
10OBJCOPY_ARGS 	:= -O elf32-xtensa-le
11endif
12
13LD_ARGS	= -T $(srctree)/$(obj)/boot.ld
14
15boot-y	:= bootstrap.o
16targets	+= $(boot-y)
17
18OBJS	:= $(addprefix $(obj)/,$(boot-y))
19LIBS	:= arch/xtensa/boot/lib/lib.a arch/xtensa/lib/lib.a
20
21LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
22
23$(obj)/zImage.o: $(obj)/../vmlinux.bin.gz $(OBJS)
24	$(Q)$(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \
25		--add-section image=$< \
26		--set-section-flags image=contents,alloc,load,load,data \
27		$(OBJS) $@
28
29$(obj)/zImage.elf: $(obj)/zImage.o $(LIBS)
30	$(Q)$(LD) $(LD_ARGS) -o $@ $^ -L/xtensa-elf/lib $(LIBGCC)
31
32$(obj)/../zImage.redboot: $(obj)/zImage.elf
33	$(Q)$(OBJCOPY) -S -O binary $< $@
34	$(Q)$(kecho) '  Kernel: $@ is ready'
35
36all zImage: $(obj)/../zImage.redboot
37