Commit 35eaa1e9 authored by Sam Ravnborg's avatar Sam Ravnborg Committed by Ralf Baechle

MIPS: Refactor arch/mips/boot/compressed/Makefile

- use hostprogs-y for the elf2ecoff
- list all *.o file in targets
- renamed obj-y to vmlinuzobjs-y (it was confusing to re-use a kbuild variable)
- fix all uses of if_changed/cmd
- use kbuild rules to beautify output
- update clean-file to clean vmlinuz.* in top-level directory

- simplied logic in arch/mips/Makefile for compressed targets

The net result is a more kbuild conformant Makefile but
readability did not increase.
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
To: linux-mips <linux-mips@linux-mips.org>
To: Wu Zhangjin <wuzhangjin@gmail.com>
Patchwork: https://patchwork.linux-mips.org/patch/1304/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 961e196c
...@@ -266,26 +266,18 @@ vmlinux.32: vmlinux ...@@ -266,26 +266,18 @@ vmlinux.32: vmlinux
vmlinux.64: vmlinux vmlinux.64: vmlinux
$(OBJCOPY) -O $(64bit-bfd) $(OBJCOPYFLAGS) $< $@ $(OBJCOPY) -O $(64bit-bfd) $(OBJCOPYFLAGS) $< $@
makezboot =$(Q)$(MAKE) $(build)=arch/mips/boot/compressed \
VMLINUX_LOAD_ADDRESS=$(load-y) 32bit-bfd=$(32bit-bfd) $(1)
all: $(all-y) all: $(all-y)
vmlinuz: vmlinux FORCE # boot
+@$(call makezboot,$@)
vmlinuz.bin: vmlinux
+@$(call makezboot,$@)
vmlinuz.ecoff: vmlinux
+@$(call makezboot,$@)
vmlinuz.srec: vmlinux
+@$(call makezboot,$@)
vmlinux.bin vmlinux.ecoff vmlinux.srec: $(vmlinux-32) FORCE vmlinux.bin vmlinux.ecoff vmlinux.srec: $(vmlinux-32) FORCE
$(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) arch/mips/boot/$@ $(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) arch/mips/boot/$@
# boot/compressed
vmlinuz vmlinuz.bin vmlinuz.ecoff vmlinuz.srec: $(vmlinux-32) FORCE
$(Q)$(MAKE) $(build)=arch/mips/boot/compressed \
VMLINUX_LOAD_ADDRESS=$(load-y) 32bit-bfd=$(32bit-bfd) $@
CLEAN_FILES += vmlinux.ecoff \ CLEAN_FILES += vmlinux.ecoff \
vmlinux.srec vmlinux.srec
......
...@@ -33,15 +33,19 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ ...@@ -33,15 +33,19 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
-DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ ) -DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ )
obj-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o targets := head.o decompress.o dbg.o uart-16550.o uart-alchemy.o
# decompressor objects (linked with vmlinuz)
vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o
ifdef CONFIG_DEBUG_ZBOOT ifdef CONFIG_DEBUG_ZBOOT
obj-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
obj-$(CONFIG_MACH_ALCHEMY) += $(obj)/uart-alchemy.o vmlinuzobjs-$(CONFIG_MACH_ALCHEMY) += $(obj)/uart-alchemy.o
endif endif
targets += vmlinux.bin
OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
$(obj)/vmlinux.bin: $(KBUILD_IMAGE) $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
$(call if_changed,objcopy) $(call if_changed,objcopy)
suffix_$(CONFIG_KERNEL_GZIP) = gz suffix_$(CONFIG_KERNEL_GZIP) = gz
...@@ -52,30 +56,31 @@ tool_$(CONFIG_KERNEL_GZIP) = gzip ...@@ -52,30 +56,31 @@ tool_$(CONFIG_KERNEL_GZIP) = gzip
tool_$(CONFIG_KERNEL_BZIP2) = bzip2 tool_$(CONFIG_KERNEL_BZIP2) = bzip2
tool_$(CONFIG_KERNEL_LZMA) = lzma tool_$(CONFIG_KERNEL_LZMA) = lzma
tool_$(CONFIG_KERNEL_LZO) = lzo tool_$(CONFIG_KERNEL_LZO) = lzo
$(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin
targets += vmlinux.gz vmlinux.bz2 vmlinux.lzma vmlinux.lzo
$(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin FORCE
$(call if_changed,$(tool_y)) $(call if_changed,$(tool_y))
$(obj)/piggy.o: $(obj)/vmlinux.$(suffix_y) $(obj)/dummy.o targets += piggy.o
$(Q)$(OBJCOPY) $(OBJCOPYFLAGS) \ OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.$(suffix_y) \
--add-section=.image=$< \ --set-section-flags=.image=contents,alloc,load,readonly,data
--set-section-flags=.image=contents,alloc,load,readonly,data \ $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.$(suffix_y) FORCE
$(obj)/dummy.o $@ $(call if_changed,objcopy)
LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T
vmlinuz: $(src)/ld.script $(obj-y) $(obj)/piggy.o vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/piggy.o
$(call if_changed,ld) $(call cmd,ld)
$(Q)$(OBJCOPY) $(OBJCOPYFLAGS) $@ $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) $@
# #
# Some DECstations need all possible sections of an ECOFF executable # Some DECstations need all possible sections of an ECOFF executable
# #
ifdef CONFIG_MACH_DECSTATION ifdef CONFIG_MACH_DECSTATION
E2EFLAGS = -a e2eflag := -a
else
E2EFLAGS =
endif endif
# elf2ecoff can only handle 32bit image # elf2ecoff can only handle 32bit image
hostprogs-y := ../elf2ecoff
ifdef CONFIG_32BIT ifdef CONFIG_32BIT
VMLINUZ = vmlinuz VMLINUZ = vmlinuz
...@@ -83,23 +88,22 @@ else ...@@ -83,23 +88,22 @@ else
VMLINUZ = vmlinuz.32 VMLINUZ = vmlinuz.32
endif endif
quiet_cmd_32 = OBJCOPY $@
cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
vmlinuz.32: vmlinuz vmlinuz.32: vmlinuz
$(Q)$(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ $(call cmd,32)
quiet_cmd_ecoff = ECOFF $@
cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
$(Q)$(obj)/../elf2ecoff $(VMLINUZ) vmlinuz.ecoff $(E2EFLAGS) $(call cmd,ecoff)
$(obj)/../elf2ecoff: $(src)/../elf2ecoff.c
$(Q)$(HOSTCC) -o $@ $^
OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
vmlinuz.bin: vmlinuz vmlinuz.bin: vmlinuz
$(call if_changed,objcopy) $(call cmd,objcopy)
OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
vmlinuz.srec: vmlinuz vmlinuz.srec: vmlinuz
$(call if_changed,objcopy) $(call cmd,objcopy)
clean: clean-files := $(objtree)/vmlinuz.*
clean-files += *.o \
vmlinu*
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment