brcm47xx: relocate loader to higher address
[openwrt/openwrt.git] / target / linux / brcm47xx / image / lzma-loader / src / Makefile
1 #
2 # Makefile for Broadcom BCM947XX boards
3 #
4 # Copyright 2001-2003, Broadcom Corporation
5 # All Rights Reserved.
6 #
7 # THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 # KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 # SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 # FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11 #
12 # Copyright 2004 Manuel Novoa III <mjn3@codepoet.org>
13 # Modified to support bzip'd kernels.
14 # Of course, it would be better to integrate bunzip capability into CFE.
15 #
16 # Copyright 2005 Oleg I. Vdovikin <oleg@cs.msu.su>
17 # Cleaned up, modified for lzma support, removed from kernel
18 #
19
20 TEXT_START := 0x80001000
21 BZ_TEXT_START := 0x80600000
22
23 OBJCOPY := $(CROSS_COMPILE)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
24
25 CFLAGS = -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
26 -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic \
27 -ffunction-sections -pipe -mlong-calls -fno-common \
28 -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap
29 CFLAGS += -DLOADADDR=$(TEXT_START) -D_LZMA_IN_CB
30
31 ASFLAGS = $(CFLAGS) -D__ASSEMBLY__ -DBZ_TEXT_START=$(BZ_TEXT_START)
32
33 SEDFLAGS := s/BZ_TEXT_START/$(BZ_TEXT_START)/;s/TEXT_START/$(TEXT_START)/
34
35 OBJECTS := head.o data.o
36
37 all: loader.gz loader.elf
38
39 # Don't build dependencies, this may die if $(CC) isn't gcc
40 dep:
41
42 install:
43
44 loader.gz: loader
45 gzip -nc9 $< > $@
46
47 loader.elf: loader.o
48 cp $< $@
49
50 loader: loader.o
51 $(OBJCOPY) $< $@
52
53 loader.o: loader.lds $(OBJECTS)
54 $(LD) -static --gc-sections -no-warn-mismatch -T loader.lds -o $@ $(OBJECTS)
55
56 loader.lds: loader.lds.in Makefile
57 @sed "$(SEDFLAGS)" < $< > $@
58
59 data.o: data.lds decompress.image
60 $(LD) -no-warn-mismatch -T data.lds -r -o $@ -b binary decompress.image -b elf32-tradlittlemips
61
62 data.lds:
63 @echo "SECTIONS { .data : { code_start = .; *(.data) code_stop = .; }}" > $@
64
65 decompress.image: decompress
66 $(OBJCOPY) $< $@
67
68 decompress: decompress.lds decompress.o LzmaDecode.o
69 $(LD) -static --gc-sections -no-warn-mismatch -T decompress.lds -o $@ decompress.o LzmaDecode.o
70
71 decompress.lds: decompress.lds.in Makefile
72 @sed "$(SEDFLAGS)" < $< > $@
73
74 mrproper: clean
75
76 clean:
77 rm -f loader.gz loader decompress *.lds *.o *.image