xref: /openbmc/linux/arch/x86/boot/compressed/Makefile (revision 7f16a339)
1db569afaSSam Ravnborg#
2db569afaSSam Ravnborg# linux/arch/x86/boot/compressed/Makefile
3db569afaSSam Ravnborg#
4db569afaSSam Ravnborg# create a compressed vmlinux image from the original vmlinux
5db569afaSSam Ravnborg#
6db569afaSSam Ravnborg
7778cb929SIan Campbelltargets := vmlinux vmlinux.bin vmlinux.bin.gz head_$(BITS).o misc.o piggy.o
8db569afaSSam Ravnborg
9db569afaSSam RavnborgKBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
10db569afaSSam RavnborgKBUILD_CFLAGS += -fno-strict-aliasing -fPIC
11db569afaSSam Ravnborgcflags-$(CONFIG_X86_64) := -mcmodel=small
12db569afaSSam RavnborgKBUILD_CFLAGS += $(cflags-y)
13db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-ffreestanding)
14db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
15db569afaSSam Ravnborg
16db569afaSSam RavnborgKBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
17db569afaSSam Ravnborg
18db569afaSSam RavnborgLDFLAGS := -m elf_$(UTS_MACHINE)
19db569afaSSam RavnborgLDFLAGS_vmlinux := -T
20db569afaSSam Ravnborg
21778cb929SIan Campbell$(obj)/vmlinux: $(src)/vmlinux_$(BITS).lds $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/piggy.o FORCE
22db569afaSSam Ravnborg	$(call if_changed,ld)
23db569afaSSam Ravnborg	@:
24db569afaSSam Ravnborg
25099e1377SIan CampbellOBJCOPYFLAGS_vmlinux.bin :=  -R .comment -S
26db569afaSSam Ravnborg$(obj)/vmlinux.bin: vmlinux FORCE
27db569afaSSam Ravnborg	$(call if_changed,objcopy)
28db569afaSSam Ravnborg
29db569afaSSam Ravnborg
307f16a339SH. Peter Anvintargets += vmlinux.bin.all vmlinux.relocs relocs
317f16a339SH. Peter Anvinhostprogs-$(CONFIG_X86_32) += relocs
32db569afaSSam Ravnborg
33db569afaSSam Ravnborgquiet_cmd_relocs = RELOCS  $@
34db569afaSSam Ravnborg      cmd_relocs = $(obj)/relocs $< > $@;$(obj)/relocs --abs-relocs $<
35db569afaSSam Ravnborg$(obj)/vmlinux.relocs: vmlinux $(obj)/relocs FORCE
36db569afaSSam Ravnborg	$(call if_changed,relocs)
37db569afaSSam Ravnborg
38db569afaSSam Ravnborgvmlinux.bin.all-y := $(obj)/vmlinux.bin
39db569afaSSam Ravnborgvmlinux.bin.all-$(CONFIG_RELOCATABLE) += $(obj)/vmlinux.relocs
40db569afaSSam Ravnborgquiet_cmd_relocbin = BUILD   $@
41db569afaSSam Ravnborg      cmd_relocbin = cat $(filter-out FORCE,$^) > $@
42db569afaSSam Ravnborg$(obj)/vmlinux.bin.all: $(vmlinux.bin.all-y) FORCE
43db569afaSSam Ravnborg	$(call if_changed,relocbin)
44db569afaSSam Ravnborg
457f16a339SH. Peter Anvinifeq ($(CONFIG_X86_32),y)
467f16a339SH. Peter Anvin
47db569afaSSam Ravnborgifdef CONFIG_RELOCATABLE
48db569afaSSam Ravnborg$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE
49db569afaSSam Ravnborg	$(call if_changed,gzip)
500530bf37SThomas Gleixnerelse
51db569afaSSam Ravnborg$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
52db569afaSSam Ravnborg	$(call if_changed,gzip)
530530bf37SThomas Gleixnerendif
54db569afaSSam RavnborgLDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
55db569afaSSam Ravnborg
56db569afaSSam Ravnborgelse
57db569afaSSam Ravnborg$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
58db569afaSSam Ravnborg	$(call if_changed,gzip)
59db569afaSSam Ravnborg
60db569afaSSam RavnborgLDFLAGS_piggy.o := -r --format binary --oformat elf64-x86-64 -T
61db569afaSSam Ravnborgendif
62db569afaSSam Ravnborg
63f18c0e79SIan Campbell$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
64db569afaSSam Ravnborg	$(call if_changed,ld)
65