Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 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 |
Wu Zhangjin | f7a904d | 2010-01-04 17:16:51 +0800 | [diff] [blame] | 12 | # Author: Wu Zhangjin <wuzhangjin@gmail.com> |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 13 | # |
| 14 | |
Andrew Bresticker | b76a4c1 | 2015-03-16 14:43:08 -0700 | [diff] [blame] | 15 | include $(srctree)/arch/mips/Kbuild.platforms |
| 16 | |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 17 | # set the default size of the mallocing area for decompressing |
| 18 | BOOT_HEAP_SIZE := 0x400000 |
| 19 | |
| 20 | # Disable Function Tracer |
| 21 | KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//") |
| 22 | |
Markos Chandras | 23df341 | 2013-07-01 09:38:30 +0000 | [diff] [blame] | 23 | KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS)) |
| 24 | |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 25 | KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \ |
Wu Zhangjin | dac2965 | 2010-01-26 17:04:02 +0800 | [diff] [blame] | 26 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 27 | |
| 28 | KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ |
Wu Zhangjin | dac2965 | 2010-01-26 17:04:02 +0800 | [diff] [blame] | 29 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ |
James Hogan | 3185557 | 2013-08-30 16:42:41 +0100 | [diff] [blame] | 30 | -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 31 | |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 32 | # decompressor objects (linked with vmlinuz) |
Wu Zhangjin | 7ae7ef3 | 2010-12-25 23:11:49 +0800 | [diff] [blame] | 33 | vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 34 | |
Wu Zhangjin | f86a69b | 2010-01-31 20:39:40 +0800 | [diff] [blame] | 35 | ifdef CONFIG_DEBUG_ZBOOT |
Wu Zhangjin | 7ae7ef3 | 2010-12-25 23:11:49 +0800 | [diff] [blame] | 36 | vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 37 | vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o |
Alban Bedel | dbb9831 | 2015-12-10 10:57:21 +0100 | [diff] [blame] | 38 | vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o |
Manuel Lauss | 42a4f17 | 2010-07-15 21:45:04 +0200 | [diff] [blame] | 39 | vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o |
Wu Zhangjin | f86a69b | 2010-01-31 20:39:40 +0800 | [diff] [blame] | 40 | endif |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 41 | |
Alban Bedel | 25f6609 | 2015-12-10 10:57:20 +0100 | [diff] [blame] | 42 | vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o |
| 43 | |
| 44 | $(obj)/ashldi3.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib |
| 45 | $(obj)/ashldi3.c: $(srctree)/arch/mips/lib/ashldi3.c |
| 46 | $(call cmd,shipped) |
| 47 | |
| 48 | targets := $(notdir $(vmlinuzobjs-y)) |
Florian Fainelli | 4e23eb6 | 2013-09-11 11:51:41 +0100 | [diff] [blame] | 49 | |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 50 | targets += vmlinux.bin |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 51 | OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 52 | $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 53 | $(call if_changed,objcopy) |
| 54 | |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 55 | tool_$(CONFIG_KERNEL_GZIP) = gzip |
| 56 | tool_$(CONFIG_KERNEL_BZIP2) = bzip2 |
Florian Fainelli | 31c4867 | 2013-09-16 16:55:20 +0100 | [diff] [blame] | 57 | tool_$(CONFIG_KERNEL_LZ4) = lz4 |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 58 | tool_$(CONFIG_KERNEL_LZMA) = lzma |
Wu Zhangjin | fe1d45e | 2010-01-15 20:34:46 +0800 | [diff] [blame] | 59 | tool_$(CONFIG_KERNEL_LZO) = lzo |
Florian Fainelli | 4e23eb6 | 2013-09-11 11:51:41 +0100 | [diff] [blame] | 60 | tool_$(CONFIG_KERNEL_XZ) = xzkern |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 61 | |
Wu Zhangjin | c853d94 | 2010-06-02 16:35:24 +0800 | [diff] [blame] | 62 | targets += vmlinux.bin.z |
| 63 | $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 64 | $(call if_changed,$(tool_y)) |
| 65 | |
Alban Bedel | 25f6609 | 2015-12-10 10:57:20 +0100 | [diff] [blame] | 66 | targets += piggy.o dummy.o |
Wu Zhangjin | c853d94 | 2010-06-02 16:35:24 +0800 | [diff] [blame] | 67 | OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 68 | --set-section-flags=.image=contents,alloc,load,readonly,data |
Wu Zhangjin | c853d94 | 2010-06-02 16:35:24 +0800 | [diff] [blame] | 69 | $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 70 | $(call if_changed,objcopy) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 71 | |
Wu Zhangjin | 3c4b7fd | 2010-06-02 16:35:25 +0800 | [diff] [blame] | 72 | # Calculate the load address of the compressed kernel image |
| 73 | hostprogs-y := calc_vmlinuz_load_addr |
| 74 | |
Andrew Bresticker | b76a4c1 | 2015-03-16 14:43:08 -0700 | [diff] [blame] | 75 | ifneq ($(zload-y),) |
| 76 | VMLINUZ_LOAD_ADDRESS := $(zload-y) |
Lluís Batlle i Rossell | f9c9aff | 2012-03-30 16:48:05 +0200 | [diff] [blame] | 77 | else |
Wu Zhangjin | 3c4b7fd | 2010-06-02 16:35:25 +0800 | [diff] [blame] | 78 | VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ |
Shmulik Ladkani | 2ccc5b1 | 2010-08-31 13:24:19 +0300 | [diff] [blame] | 79 | $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS)) |
Lluís Batlle i Rossell | f9c9aff | 2012-03-30 16:48:05 +0200 | [diff] [blame] | 80 | endif |
Wu Zhangjin | 3c4b7fd | 2010-06-02 16:35:25 +0800 | [diff] [blame] | 81 | |
| 82 | vmlinuzobjs-y += $(obj)/piggy.o |
| 83 | |
Alex Smith | fb2646a | 2015-08-18 15:03:10 +0100 | [diff] [blame] | 84 | quiet_cmd_zld = LD $@ |
Wu Zhangjin | 3c4b7fd | 2010-06-02 16:35:25 +0800 | [diff] [blame] | 85 | cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 86 | quiet_cmd_strip = STRIP $@ |
Wu Zhangjin | 5089ca9 | 2010-06-16 15:52:21 +0800 | [diff] [blame] | 87 | cmd_strip = $(STRIP) -s $@ |
Wu Zhangjin | 3c4b7fd | 2010-06-02 16:35:25 +0800 | [diff] [blame] | 88 | vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr |
| 89 | $(call cmd,zld) |
Wu Zhangjin | 5089ca9 | 2010-06-16 15:52:21 +0800 | [diff] [blame] | 90 | $(call cmd,strip) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 91 | |
| 92 | # |
| 93 | # Some DECstations need all possible sections of an ECOFF executable |
| 94 | # |
| 95 | ifdef CONFIG_MACH_DECSTATION |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 96 | e2eflag := -a |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 97 | endif |
| 98 | |
| 99 | # elf2ecoff can only handle 32bit image |
Wu Zhangjin | 3c4b7fd | 2010-06-02 16:35:25 +0800 | [diff] [blame] | 100 | hostprogs-y += ../elf2ecoff |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 101 | |
| 102 | ifdef CONFIG_32BIT |
| 103 | VMLINUZ = vmlinuz |
| 104 | else |
| 105 | VMLINUZ = vmlinuz.32 |
| 106 | endif |
| 107 | |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 108 | quiet_cmd_32 = OBJCOPY $@ |
| 109 | cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 110 | vmlinuz.32: vmlinuz |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 111 | $(call cmd,32) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 112 | |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 113 | quiet_cmd_ecoff = ECOFF $@ |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 114 | cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 115 | vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 116 | $(call cmd,ecoff) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 117 | |
Wu Zhangjin | d4d9a55 | 2009-12-10 22:55:13 +0800 | [diff] [blame] | 118 | OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 119 | vmlinuz.bin: vmlinuz |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 120 | $(call cmd,objcopy) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 121 | |
Wu Zhangjin | d4d9a55 | 2009-12-10 22:55:13 +0800 | [diff] [blame] | 122 | OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 123 | vmlinuz.srec: vmlinuz |
Sam Ravnborg | 35eaa1e | 2010-05-30 16:28:03 +0200 | [diff] [blame] | 124 | $(call cmd,objcopy) |
Wu Zhangjin | 1b93b3c | 2009-10-14 18:12:16 +0800 | [diff] [blame] | 125 | |
Wu Zhangjin | ec33529 | 2010-09-22 14:03:57 +0800 | [diff] [blame] | 126 | clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec} |