Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #
  2. # This file is subject to the terms and conditions of the GNU General Public
  3. # License.
  4. #
  5. # Adapted for MIPS Pete Popov, Dan Malek
  6. #
  7. # Copyright (C) 1994 by Linus Torvalds
  8. # Adapted for PowerPC by Gary Thomas
  9. # modified by Cort (cort@cs.nmt.edu)
  10. #
  11. # Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University
  12. # Author: Wu Zhangjin <wuzhangjin@gmail.com>
  13. #
  14. include $(srctree)/arch/mips/Kbuild.platforms
  15. # set the default size of the mallocing area for decompressing
  16. BOOT_HEAP_SIZE := 0x400000
  17. # Disable Function Tracer
  18. KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//")
  19. KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))
  20. KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \
  21. -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
  22. KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
  23. -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
  24. -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
  25. # decompressor objects (linked with vmlinuz)
  26. vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
  27. ifdef CONFIG_DEBUG_ZBOOT
  28. vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o
  29. vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
  30. vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o
  31. vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o
  32. vmlinuzobjs-$(CONFIG_ATH79) += $(obj)/uart-ath79.o
  33. endif
  34. extra-y += uart-ath79.c
  35. $(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c
  36. $(call cmd,shipped)
  37. vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o
  38. extra-y += ashldi3.c bswapsi.c
  39. $(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib
  40. $(obj)/ashldi3.c $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c
  41. $(call cmd,shipped)
  42. targets := $(notdir $(vmlinuzobjs-y))
  43. targets += vmlinux.bin
  44. OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
  45. $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
  46. $(call if_changed,objcopy)
  47. tool_$(CONFIG_KERNEL_GZIP) = gzip
  48. tool_$(CONFIG_KERNEL_BZIP2) = bzip2
  49. tool_$(CONFIG_KERNEL_LZ4) = lz4
  50. tool_$(CONFIG_KERNEL_LZMA) = lzma
  51. tool_$(CONFIG_KERNEL_LZO) = lzo
  52. tool_$(CONFIG_KERNEL_XZ) = xzkern
  53. targets += vmlinux.bin.z
  54. $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
  55. $(call if_changed,$(tool_y))
  56. targets += piggy.o dummy.o
  57. OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
  58. --set-section-flags=.image=contents,alloc,load,readonly,data
  59. $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
  60. $(call if_changed,objcopy)
  61. # Calculate the load address of the compressed kernel image
  62. hostprogs-y := calc_vmlinuz_load_addr
  63. ifneq ($(zload-y),)
  64. VMLINUZ_LOAD_ADDRESS := $(zload-y)
  65. else
  66. VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
  67. $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
  68. endif
  69. vmlinuzobjs-y += $(obj)/piggy.o
  70. quiet_cmd_zld = LD $@
  71. cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
  72. quiet_cmd_strip = STRIP $@
  73. cmd_strip = $(STRIP) -s $@
  74. vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
  75. $(call cmd,zld)
  76. $(call cmd,strip)
  77. #
  78. # Some DECstations need all possible sections of an ECOFF executable
  79. #
  80. ifdef CONFIG_MACH_DECSTATION
  81. e2eflag := -a
  82. endif
  83. # elf2ecoff can only handle 32bit image
  84. hostprogs-y += ../elf2ecoff
  85. ifdef CONFIG_32BIT
  86. VMLINUZ = vmlinuz
  87. else
  88. VMLINUZ = vmlinuz.32
  89. endif
  90. quiet_cmd_32 = OBJCOPY $@
  91. cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
  92. vmlinuz.32: vmlinuz
  93. $(call cmd,32)
  94. quiet_cmd_ecoff = ECOFF $@
  95. cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
  96. vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
  97. $(call cmd,ecoff)
  98. OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
  99. vmlinuz.bin: vmlinuz
  100. $(call cmd,objcopy)
  101. OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
  102. vmlinuz.srec: vmlinuz
  103. $(call cmd,objcopy)
  104. clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}