1 LOADADDR
= 0x80400000 # RAM start + 4M
2 KERNEL_ENTRY
= 0x80001000
3 RAMSIZE
= 0x00100000 # 1MB
6 CROSS_COMPILE
= mips-linux-
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
15 $(CPP
) $(CFLAGS
) $< -o
$*.s
17 $(CC
) $(CFLAGS
) -c
$< -o
$*.o
19 $(CC
) $(CFLAGS
) -c
$< -o
$*.o
21 CC
= $(CROSS_COMPILE
)gcc
22 LD
= $(CROSS_COMPILE
)ld
23 OBJDUMP
= $(CROSS_COMPILE
)objdump
25 O_FORMAT
= $(shell $(OBJDUMP
) -i | head
-2 | grep elf32
)
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
))
35 sed
-e
's,@LOADADDR@,$(LOADADDR),g' -e
's,@ENTRY@,_start,g' $< >$@
37 kernel.o
: vmlinux.lzma lzma.lds
38 $(LD
) -r
-b binary
--oformat
$(O_FORMAT
) -o
$@
$<
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
)
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
$@
$^
52 lzma.elf
: start.o decompress.o LzmaDecode.o kernel.o
53 $(LD
) -s
-Tlzma.lds
-o
$@
$^
57 rm -f
*.o lzma.elf
*.tmp
*.lds