Root/target/linux/ar71xx/image/lzma-loader/src/Makefile

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
18LOADADDR :=
19LZMA_TEXT_START := 0x80a00000
20LOADER_DATA :=
21CONFIG_BOARD :=
22FLASH_OFFS :=
23FLASH_MAX :=
24
25CC := $(CROSS_COMPILE)gcc
26LD := $(CROSS_COMPILE)ld
27OBJCOPY := $(CROSS_COMPILE)objcopy
28OBJDUMP := $(CROSS_COMPILE)objdump
29
30BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
31
32CFLAGS = -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
33          -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 \
34          -mno-abicalls -fno-pic -ffunction-sections -pipe -mlong-calls \
35          -fno-common -ffreestanding -fhonour-copts \
36          -mabi=32 -march=mips32r2 \
37          -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap
38CFLAGS += -D_LZMA_PROB32
39
40ASFLAGS = $(CFLAGS) -D__ASSEMBLY__
41
42LDFLAGS = -static --gc-sections -no-warn-mismatch
43LDFLAGS += -e startup -T loader.lds -Ttext $(LZMA_TEXT_START)
44
45O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32)
46
47OBJECTS := head.o loader.o cache.o board.o printf.o LzmaDecode.o
48
49ifneq ($(strip $(LOADER_DATA)),)
50OBJECTS += data.o
51CFLAGS += -DLZMA_WRAPPER=1 -DLOADADDR=$(LOADADDR)
52endif
53
54ifneq ($(strip $(KERNEL_CMDLINE)),)
55CFLAGS += -DCONFIG_KERNEL_CMDLINE='"$(KERNEL_CMDLINE)"'
56endif
57
58ifneq ($(strip $(FLASH_OFFS)),)
59CFLAGS += -DCONFIG_FLASH_OFFS=$(FLASH_OFFS)
60endif
61
62ifneq ($(strip $(FLASH_MAX)),)
63CFLAGS += -DCONFIG_FLASH_MAX=$(FLASH_MAX)
64endif
65
66all: loader.bin
67
68# Don't build dependencies, this may die if $(CC) isn't gcc
69dep:
70
71install:
72
73%.o : %.c
74    $(CC) $(CFLAGS) -c -o $@ $<
75
76%.o : %.S
77    $(CC) $(ASFLAGS) -c -o $@ $<
78
79data.o: $(LOADER_DATA)
80    $(LD) -r -b binary --oformat $(O_FORMAT) -T lzma-data.lds -o $@ $<
81
82loader.bin: loader.elf
83    $(OBJCOPY) $(BIN_FLAGS) $< $@
84
85loader.elf: $(OBJECTS)
86    $(LD) $(LDFLAGS) -o $@ $(OBJECTS)
87
88mrproper: clean
89
90clean:
91    rm -f *.elf *.bin *.o
92
93
94
95

Archive Download this file



interactive