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