generic: relocate: make the cacheline size configurable
[openwrt/openwrt.git] / target / linux / generic / image / relocate / Makefile
1 #
2 # Makefile for the kernel relocation stub for MIPS devices
3 #
4 # Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
5 # Copyright (C) 2015 Felix Fietkau <nbd@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 := 0x81000000
20 LOADER_DATA :=
21 BOARD :=
22 FLASH_OFFS :=
23 FLASH_MAX :=
24 PLATFORM :=
25 CACHELINE_SIZE := 32
26
27 CC := $(CROSS_COMPILE)gcc
28 LD := $(CROSS_COMPILE)ld
29 OBJCOPY := $(CROSS_COMPILE)objcopy
30 OBJDUMP := $(CROSS_COMPILE)objdump
31
32 BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
33
34 CFLAGS = -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
35 -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 \
36 -mno-abicalls -fno-pic -ffunction-sections -pipe -mlong-calls \
37 -fno-common -ffreestanding -fhonour-copts \
38 -mabi=32 -march=mips32r2 \
39 -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap \
40 -DCONFIG_CACHELINE_SIZE=$(CACHELINE_SIZE) \
41 -DKERNEL_ADDR=$(KERNEL_ADDR)
42
43 ASFLAGS = $(CFLAGS) -D__ASSEMBLY__
44
45 LDFLAGS = -static --gc-sections -no-warn-mismatch
46 LDFLAGS += -e startup -T loader.lds -Ttext $(LZMA_TEXT_START)
47
48 O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32)
49
50 OBJECTS := head.o
51
52 all: head.o loader.bin
53
54 # Don't build dependencies, this may die if $(CC) isn't gcc
55 dep:
56
57 install:
58
59 %.o : %.c
60 $(CC) $(CFLAGS) -c -o $@ $<
61
62 %.o : %.S
63 $(CC) $(ASFLAGS) -c -o $@ $<
64
65 loader: $(OBJECTS)
66 $(LD) $(LDFLAGS) -o $@ $(OBJECTS)
67
68 loader.bin: loader
69 $(OBJCOPY) $(BIN_FLAGS) $< $@
70
71 mrproper: clean
72
73 clean:
74 rm -f loader *.elf *.bin *.o