Makefile 1.9 KB

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