1# SPDX-License-Identifier: GPL-2.0
2#
3# linux/arch/sh/boot/compressed/Makefile
4#
5# create a compressed vmlinux image from the original vmlinux
6#
7
8targets		:= vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
9
10OBJECTS = $(obj)/head.o $(obj)/misc.o
11
12#
13# IMAGE_OFFSET is the load offset of the compression loader
14# Assign dummy values if these 2 variables are not defined,
15# in order to suppress error message.
16#
17CONFIG_MEMORY_START     ?= 0x00400000
18CONFIG_BOOT_LINK_OFFSET ?= 0x00280000
19IMAGE_OFFSET := $(shell printf "0x%08x" $$(($(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET))))
20
21LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name 2>/dev/null)
22LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -estartup -T $(obj)/vmlinux.lds \
23	--defsym output=$(CONFIG_MEMORY_START)
24
25$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE
26	$(call if_changed,ld)
27
28$(obj)/vmlinux.bin: vmlinux FORCE
29	$(call if_changed,objcopy)
30
31suffix-$(CONFIG_KERNEL_GZIP)    := gzip
32suffix-$(CONFIG_KERNEL_LZO)     := lzo
33
34$(obj)/vmlinux.bin.$(suffix-y): $(obj)/vmlinux.bin FORCE
35	$(call if_changed,$(suffix-y))
36
37LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T
38OBJCOPYFLAGS := -O binary
39
40$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
41	$(call if_changed,ld)
42
43CFLAGS_misc.o = -O0
44