OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | # |
2 | # Makefile for the LZMA compressed kernel loader for |
||
3 | # Atheros AR7XXX/AR9XXX based boards |
||
4 | # |
||
5 | # Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org> |
||
6 | # |
||
7 | # Some parts of this file was based on the OpenWrt specific lzma-loader |
||
8 | # for the BCM47xx and ADM5120 based boards: |
||
9 | # Copyright (C) 2004 Manuel Novoa III (mjn3@codepoet.org) |
||
10 | # Copyright (C) 2005 Mineharu Takahara <mtakahar@yahoo.com> |
||
11 | # Copyright (C) 2005 by Oleg I. Vdovikin <oleg@cs.msu.su> |
||
12 | # |
||
13 | # This program is free software; you can redistribute it and/or modify it |
||
14 | # under the terms of the GNU General Public License version 2 as published |
||
15 | # by the Free Software Foundation. |
||
16 | # |
||
17 | |||
18 | LOADADDR := |
||
19 | LZMA_TEXT_START := 0x80a00000 |
||
20 | LOADER_DATA := |
||
21 | |||
22 | CC := $(CROSS_COMPILE)gcc |
||
23 | LD := $(CROSS_COMPILE)ld |
||
24 | OBJCOPY := $(CROSS_COMPILE)objcopy |
||
25 | OBJDUMP := $(CROSS_COMPILE)objdump |
||
26 | |||
27 | BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug \ |
||
28 | -R .MIPS.abiflags -S |
||
29 | |||
30 | CFLAGS = -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \ |
||
31 | -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 \ |
||
32 | -mno-abicalls -fno-pic -ffunction-sections -pipe \ |
||
33 | -ffreestanding -fhonour-copts \ |
||
34 | -mabi=32 -march=mips32 \ |
||
35 | -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap |
||
36 | CFLAGS += -D_LZMA_PROB32 |
||
37 | |||
38 | ASFLAGS = $(CFLAGS) -D__ASSEMBLY__ |
||
39 | |||
40 | LDFLAGS = -static --gc-sections -no-warn-mismatch |
||
41 | LDFLAGS += -e startup -T loader.lds -Ttext $(LZMA_TEXT_START) |
||
42 | |||
43 | O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32) |
||
44 | |||
45 | OBJECTS := head.o loader.o cache.o board.o printf.o LzmaDecode.o |
||
46 | |||
47 | ifneq ($(strip $(LOADER_DATA)),) |
||
48 | OBJECTS += data.o |
||
49 | CFLAGS += -DLZMA_WRAPPER=1 -DLOADADDR=$(LOADADDR) |
||
50 | endif |
||
51 | |||
52 | |||
53 | all: loader.elf |
||
54 | |||
55 | # Don't build dependencies, this may die if $(CC) isn't gcc |
||
56 | dep: |
||
57 | |||
58 | install: |
||
59 | |||
60 | %.o : %.c |
||
61 | $(CC) $(CFLAGS) -c -o $@ $< |
||
62 | |||
63 | %.o : %.S |
||
64 | $(CC) $(ASFLAGS) -c -o $@ $< |
||
65 | |||
66 | data.o: $(LOADER_DATA) |
||
67 | $(LD) -r -b binary --oformat $(O_FORMAT) -T lzma-data.lds -o $@ $< |
||
68 | |||
69 | loader: $(OBJECTS) |
||
70 | $(LD) $(LDFLAGS) -o $@ $(OBJECTS) |
||
71 | |||
72 | loader.bin: loader |
||
73 | $(OBJCOPY) $(BIN_FLAGS) $< $@ |
||
74 | |||
75 | loader2.o: loader.bin |
||
76 | $(LD) -r -b binary --oformat $(O_FORMAT) -o $@ $< |
||
77 | |||
78 | loader.elf: loader2.o |
||
79 | $(LD) -e startup -T loader2.lds -Ttext $(LOADADDR) -o $@ $< |
||
80 | |||
81 | mrproper: clean |
||
82 | |||
83 | clean: |
||
84 | rm -f loader *.elf *.bin *.o |
||
85 | |||
86 | |||
87 |