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