move target/linux/image to target/image
[openwrt.git] / target / image / generic / lzma-loader / src / Makefile
1 LOADADDR = 0x80400000 # RAM start + 4M
2 KERNEL_ENTRY = 0x80001000
3 RAMSIZE = 0x00100000 # 1MB
4 IMAGE_COPY:=0
5
6 CROSS_COMPILE = mips-linux-
7
8 OBJCOPY:= $(CROSS_COMPILE)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
9 CFLAGS := -fno-builtin -Os -G 0 -ffunction-sections -mno-abicalls -fno-pic -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap -Wall -DRAMSIZE=${RAMSIZE} -DKERNEL_ENTRY=${KERNEL_ENTRY} -D_LZMA_IN_CB
10 ifeq ($(IMAGE_COPY),1)
11 CFLAGS += -DLOADADDR=${LOADADDR} -DIMAGE_COPY=1
12 endif
13
14 .S.s:
15 $(CPP) $(CFLAGS) $< -o $*.s
16 .S.o:
17 $(CC) $(CFLAGS) -c $< -o $*.o
18 .c.o:
19 $(CC) $(CFLAGS) -c $< -o $*.o
20
21 CC = $(CROSS_COMPILE)gcc
22 LD = $(CROSS_COMPILE)ld
23 OBJDUMP = $(CROSS_COMPILE)objdump
24
25 O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32)
26
27 # Drop some uninteresting sections in the kernel.
28 # This is only relevant for ELF kernels but doesn't hurt a.out
29 drop-sections = .reginfo .mdebug .comment
30 strip-flags = $(addprefix --remove-section=,$(drop-sections))
31
32 all : lzma.elf
33
34 lzma.lds: lzma.lds.in
35 sed -e 's,@LOADADDR@,$(LOADADDR),g' -e 's,@ENTRY@,_start,g' $< >$@
36
37 kernel.o: vmlinux.lzma lzma.lds
38 $(LD) -r -b binary --oformat $(O_FORMAT) -o $@ $<
39
40 ifeq ($(IMAGE_COPY),1)
41 lzma.o: decompress.o LzmaDecode.o kernel.o
42 sed -e 's,@LOADADDR@,$(LOADADDR),g' -e 's,@ENTRY@,entry,g' lzma.lds.in >lzma-stage2.lds
43 $(LD) -static --no-warn-mismatch -e entry -Tlzma-stage2.lds -o temp-$@ $^
44 $(OBJCOPY) temp-$@ lzma.tmp
45 @echo "SECTIONS { .data : { code_start = .; *(.data) code_stop = .; }}" > lzma-data.lds
46 $(LD) -no-warn-mismatch -T lzma-data.lds -r -o $@ -b binary lzma.tmp --oformat $(O_FORMAT)
47
48 lzma.elf: start.o lzma.o
49 sed -e 's,@LOADADDR@,$(KERNEL_ENTRY),g' lzma-copy.lds.in >lzma-copy.lds
50 $(LD) -s -Tlzma-copy.lds -o $@ $^
51 else
52 lzma.elf: start.o decompress.o LzmaDecode.o kernel.o
53 $(LD) -s -Tlzma.lds -o $@ $^
54 endif
55
56 clean:
57 rm -f *.o lzma.elf *.tmp *.lds
This page took 0.047268 seconds and 5 git commands to generate.