xref: /openbmc/linux/arch/x86/boot/compressed/Makefile (revision 95a38f34)
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
7ae03c499SAlain Knafftargets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma 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
1195a38f34SH. Peter AnvinKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
12db569afaSSam Ravnborgcflags-$(CONFIG_X86_64) := -mcmodel=small
13db569afaSSam RavnborgKBUILD_CFLAGS += $(cflags-y)
14db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-ffreestanding)
15db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
16db569afaSSam Ravnborg
17db569afaSSam RavnborgKBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
18db569afaSSam Ravnborg
19db569afaSSam RavnborgLDFLAGS := -m elf_$(UTS_MACHINE)
20db569afaSSam RavnborgLDFLAGS_vmlinux := -T
21db569afaSSam Ravnborg
22778cb929SIan Campbell$(obj)/vmlinux: $(src)/vmlinux_$(BITS).lds $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/piggy.o FORCE
23db569afaSSam Ravnborg	$(call if_changed,ld)
24db569afaSSam Ravnborg	@:
25db569afaSSam Ravnborg
26099e1377SIan CampbellOBJCOPYFLAGS_vmlinux.bin :=  -R .comment -S
27db569afaSSam Ravnborg$(obj)/vmlinux.bin: vmlinux FORCE
28db569afaSSam Ravnborg	$(call if_changed,objcopy)
29db569afaSSam Ravnborg
30db569afaSSam Ravnborg
317f16a339SH. Peter Anvintargets += vmlinux.bin.all vmlinux.relocs relocs
327f16a339SH. Peter Anvinhostprogs-$(CONFIG_X86_32) += relocs
33db569afaSSam Ravnborg
34db569afaSSam Ravnborgquiet_cmd_relocs = RELOCS  $@
35db569afaSSam Ravnborg      cmd_relocs = $(obj)/relocs $< > $@;$(obj)/relocs --abs-relocs $<
36db569afaSSam Ravnborg$(obj)/vmlinux.relocs: vmlinux $(obj)/relocs FORCE
37db569afaSSam Ravnborg	$(call if_changed,relocs)
38db569afaSSam Ravnborg
39db569afaSSam Ravnborgvmlinux.bin.all-y := $(obj)/vmlinux.bin
40db569afaSSam Ravnborgvmlinux.bin.all-$(CONFIG_RELOCATABLE) += $(obj)/vmlinux.relocs
41db569afaSSam Ravnborgquiet_cmd_relocbin = BUILD   $@
42db569afaSSam Ravnborg      cmd_relocbin = cat $(filter-out FORCE,$^) > $@
43db569afaSSam Ravnborg$(obj)/vmlinux.bin.all: $(vmlinux.bin.all-y) FORCE
44db569afaSSam Ravnborg	$(call if_changed,relocbin)
45db569afaSSam Ravnborg
467f16a339SH. Peter Anvinifeq ($(CONFIG_X86_32),y)
477f16a339SH. Peter Anvin
48db569afaSSam Ravnborgifdef CONFIG_RELOCATABLE
49db569afaSSam Ravnborg$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE
50db569afaSSam Ravnborg	$(call if_changed,gzip)
51ae03c499SAlain Knaff$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin.all FORCE
52ae03c499SAlain Knaff	$(call if_changed,bzip2)
53ae03c499SAlain Knaff$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin.all FORCE
54ae03c499SAlain Knaff	$(call if_changed,lzma)
550530bf37SThomas Gleixnerelse
56db569afaSSam Ravnborg$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
57db569afaSSam Ravnborg	$(call if_changed,gzip)
58ae03c499SAlain Knaff$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
59ae03c499SAlain Knaff	$(call if_changed,bzip2)
60ae03c499SAlain Knaff$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
61ae03c499SAlain Knaff	$(call if_changed,lzma)
620530bf37SThomas Gleixnerendif
63db569afaSSam RavnborgLDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
64db569afaSSam Ravnborg
65db569afaSSam Ravnborgelse
66ae03c499SAlain Knaff
67db569afaSSam Ravnborg$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
68db569afaSSam Ravnborg	$(call if_changed,gzip)
69ae03c499SAlain Knaff$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
70ae03c499SAlain Knaff	$(call if_changed,bzip2)
71ae03c499SAlain Knaff$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
72ae03c499SAlain Knaff	$(call if_changed,lzma)
73db569afaSSam Ravnborg
74db569afaSSam RavnborgLDFLAGS_piggy.o := -r --format binary --oformat elf64-x86-64 -T
75db569afaSSam Ravnborgendif
76db569afaSSam Ravnborg
77ae03c499SAlain Knaffsuffix_$(CONFIG_KERNEL_GZIP)  = gz
78ae03c499SAlain Knaffsuffix_$(CONFIG_KERNEL_BZIP2) = bz2
79ae03c499SAlain Knaffsuffix_$(CONFIG_KERNEL_LZMA)  = lzma
80ae03c499SAlain Knaff
81ae03c499SAlain Knaff$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix_y) FORCE
82db569afaSSam Ravnborg	$(call if_changed,ld)
83