2 # Copyright (C) 2010 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 RAMSIZE
= 0x00800000 # 8MB
9 LOADADDR
= 0x80400000 # RAM start + 4M
10 KERNEL_ENTRY
= 0x80002000
12 CROSS_COMPILE
= mipsel-openwrt-linux-
14 OBJCOPY
:= $(CROSS_COMPILE
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
15 CFLAGS
:= -I.
/include -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
-DRAMSTART
=${RAMSTART} -DRAMSIZE
=${RAMSIZE} -DKERNEL_ENTRY
=${KERNEL_ENTRY}
18 $(CC
) $(CFLAGS
) -c
$< -o
$*.o
20 CC
= $(CROSS_COMPILE
)gcc
21 LD
= $(CROSS_COMPILE
)ld
22 OBJDUMP
= $(CROSS_COMPILE
)objdump
24 O_FORMAT
= $(shell $(OBJDUMP
) -i | head
-2 | grep elf32
)
26 # Drop some uninteresting sections in the kernel.
27 # This is only relevant for ELF kernels but doesn't hurt a.out
28 drop-sections
= .reginfo .mdebug .comment
29 strip-flags
= $(addprefix --remove-section
=,$(drop-sections
))
31 all : lzma.elf lzma.bin
34 sed
-e
's,@LOADADDR@,$(LOADADDR),g' $< >$@
36 kernel.o
: vmlinux.lzma lzma.lds
37 $(LD
) -r
-b binary
--oformat
$(O_FORMAT
) -o
$@
$<
42 lzma.elf
: decompress.o stubs.o LzmaDecode.o kernel.o lzma.lds
43 $(LD
) -T lzma.lds
-o
$@
$^
47 rm -f
*.o lzma.elf lzma.bin
*.tmp
*.lds