xref: /openbmc/linux/arch/x86/boot/compressed/Makefile (revision 099e1377)
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
300530bf37SThomas Gleixnerifeq ($(CONFIG_X86_32),y)
31db569afaSSam Ravnborgtargets += vmlinux.bin.all vmlinux.relocs
32db569afaSSam Ravnborghostprogs-y := 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
46db569afaSSam Ravnborgifdef CONFIG_RELOCATABLE
47db569afaSSam Ravnborg$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE
48db569afaSSam Ravnborg	$(call if_changed,gzip)
490530bf37SThomas Gleixnerelse
50db569afaSSam Ravnborg$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
51db569afaSSam Ravnborg	$(call if_changed,gzip)
520530bf37SThomas Gleixnerendif
53db569afaSSam RavnborgLDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
54db569afaSSam Ravnborg
55db569afaSSam Ravnborgelse
56db569afaSSam Ravnborg$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
57db569afaSSam Ravnborg	$(call if_changed,gzip)
58db569afaSSam Ravnborg
59db569afaSSam RavnborgLDFLAGS_piggy.o := -r --format binary --oformat elf64-x86-64 -T
60db569afaSSam Ravnborgendif
61db569afaSSam Ravnborg
62db569afaSSam Ravnborg
63f18c0e79SIan Campbell$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
64db569afaSSam Ravnborg	$(call if_changed,ld)
65