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