1#
2# linux/arch/shmedia/boot/compressed/Makefile
3#
4# This file is subject to the terms and conditions of the GNU General Public
5# License.  See the file "COPYING" in the main directory of this archive
6# for more details.
7#
8# Copyright (C) 2002 Stuart Menefy
9#
10# create a compressed vmlinux image from the original vmlinux
11#
12
13
14# This is a temporary work around for a problem with the Linux ld.
15# We can't use the Linux linker, because it doesn't work with binary
16# files, so we use the bard machine linker instead...
17PIGGYLD=sh64-superh-elf-ld -EL # -m shlelf64
18# ...which has the knock on that we need this when doing the final link.
19EXTRAFLAGS=--no-warn-mismatch
20
21HEAD = head.o
22SYSTEM = $(TOPDIR)/vmlinux
23
24OBJECTS = $(HEAD) misc.o cache.o
25
26ZLDFLAGS = -e startup -T vmlinux.lds
27
28#
29# ZIMAGE_OFFSET is the load offset of the compression loader
30# (4M for the kernel plus 64K for this loader)
31#
32ZIMAGE_OFFSET = $(shell printf "0x%8x" $$[0x$(CONFIG_MEMORY_START)+0x400000+0x10000])
33
34ZLINKFLAGS = -Ttext $(ZIMAGE_OFFSET) $(ZLDFLAGS)
35
36all: vmlinux
37
38vmlinux.lds: vmlinux.lds.S
39	$(CPP) -traditional -C -P -I$(HPATH) -Ush vmlinux.lds.S >vmlinux.lds
40
41vmlinux: piggy.o $(OBJECTS) vmlinux.lds
42	$(LD) $(ZLINKFLAGS) $(EXTRAFLAGS) -o vmlinux $(OBJECTS) piggy.o
43
44head.o: head.S
45	$(CC) $(AFLAGS) -traditional -c head.S
46
47piggy.o:	$(SYSTEM)
48	tmppiggy=_tmp_$$$$piggy; \
49	rm -f $$tmppiggy $$tmppiggy.gz $$tmppiggy.lnk; \
50	$(OBJCOPY) -R .empty_zero_page $(SYSTEM) $$tmppiggy; \
51	gzip -f -9 < $$tmppiggy > $$tmppiggy.gz; \
52	echo "SECTIONS { .image : { input_len = .; LONG(input_data_end - input_data) input_data = .; *(.data) input_data_end = .; }}" > $$tmppiggy.lnk; \
53	$(PIGGYLD) -r -o piggy.o -b binary $$tmppiggy.gz -b elf32-sh64 -T $$tmppiggy.lnk; \
54	rm -f $$tmppiggy $$tmppiggy.gz $$tmppiggy.lnk
55
56clean:
57	rm -f vmlinux _tmp_*
58