xref: /openbmc/linux/arch/x86/boot/compressed/Makefile (revision f9b493ac)
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
7f9b493acSKyungsik Leetargets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
8f9b493acSKyungsik Lee	vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
9db569afaSSam Ravnborg
10db569afaSSam RavnborgKBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
11db569afaSSam RavnborgKBUILD_CFLAGS += -fno-strict-aliasing -fPIC
1295a38f34SH. Peter AnvinKBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
1317a2a9b5SH. Peter Anvincflags-$(CONFIG_X86_32) := -march=i386
14db569afaSSam Ravnborgcflags-$(CONFIG_X86_64) := -mcmodel=small
15db569afaSSam RavnborgKBUILD_CFLAGS += $(cflags-y)
16db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-ffreestanding)
17db569afaSSam RavnborgKBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
18db569afaSSam Ravnborg
19db569afaSSam RavnborgKBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
207bf99fb6SPeter OberparleiterGCOV_PROFILE := n
21db569afaSSam Ravnborg
22db569afaSSam RavnborgLDFLAGS := -m elf_$(UTS_MACHINE)
23db569afaSSam RavnborgLDFLAGS_vmlinux := -T
24db569afaSSam Ravnborg
2502a884c0SH. Peter Anvinhostprogs-y	:= mkpiggy
2612871c56SMatt FlemingHOST_EXTRACFLAGS += -I$(srctree)/tools/include
2702a884c0SH. Peter Anvin
28291f3632SMatt FlemingVMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
29291f3632SMatt Fleming	$(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o \
30291f3632SMatt Fleming	$(obj)/piggy.o
31291f3632SMatt Fleming
329dead5bbSMatthew Garrett$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
339dead5bbSMatthew Garrett
34291f3632SMatt Flemingifeq ($(CONFIG_EFI_STUB), y)
35291f3632SMatt Fleming	VMLINUX_OBJS += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o
36291f3632SMatt Flemingendif
37291f3632SMatt Fleming
38291f3632SMatt Fleming$(obj)/vmlinux: $(VMLINUX_OBJS) FORCE
39db569afaSSam Ravnborg	$(call if_changed,ld)
40db569afaSSam Ravnborg	@:
41db569afaSSam Ravnborg
42099e1377SIan CampbellOBJCOPYFLAGS_vmlinux.bin :=  -R .comment -S
43db569afaSSam Ravnborg$(obj)/vmlinux.bin: vmlinux FORCE
44db569afaSSam Ravnborg	$(call if_changed,objcopy)
45db569afaSSam Ravnborg
4691870824SJan Beulichtargets += $(patsubst $(obj)/%,%,$(VMLINUX_OBJS)) vmlinux.bin.all vmlinux.relocs
47db569afaSSam Ravnborg
486520fe55SH. Peter AnvinCMD_RELOCS = arch/x86/tools/relocs
49db569afaSSam Ravnborgquiet_cmd_relocs = RELOCS  $@
506520fe55SH. Peter Anvin      cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
516520fe55SH. Peter Anvin$(obj)/vmlinux.relocs: vmlinux FORCE
52db569afaSSam Ravnborg	$(call if_changed,relocs)
53db569afaSSam Ravnborg
54db569afaSSam Ravnborgvmlinux.bin.all-y := $(obj)/vmlinux.bin
555f11e020SH. Peter Anvinvmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
56db569afaSSam Ravnborg
575f11e020SH. Peter Anvin$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE
58db569afaSSam Ravnborg	$(call if_changed,gzip)
595f11e020SH. Peter Anvin$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
60ae03c499SAlain Knaff	$(call if_changed,bzip2)
615f11e020SH. Peter Anvin$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
62ae03c499SAlain Knaff	$(call if_changed,lzma)
6330314804SLasse Collin$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
6430314804SLasse Collin	$(call if_changed,xzkern)
6513510997SAlbin Tonnerre$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
6613510997SAlbin Tonnerre	$(call if_changed,lzo)
67f9b493acSKyungsik Lee$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
68f9b493acSKyungsik Lee	$(call if_changed,lz4)
69db569afaSSam Ravnborg
70283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_GZIP)	:= gz
71283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_BZIP2)	:= bz2
72283ab1c0SH. Peter Anvinsuffix-$(CONFIG_KERNEL_LZMA)	:= lzma
7330314804SLasse Collinsuffix-$(CONFIG_KERNEL_XZ)	:= xz
7413510997SAlbin Tonnerresuffix-$(CONFIG_KERNEL_LZO) 	:= lzo
75f9b493acSKyungsik Leesuffix-$(CONFIG_KERNEL_LZ4) 	:= lz4
76ae03c499SAlain Knaff
7702a884c0SH. Peter Anvinquiet_cmd_mkpiggy = MKPIGGY $@
7802a884c0SH. Peter Anvin      cmd_mkpiggy = $(obj)/mkpiggy $< > $@ || ( rm -f $@ ; false )
7902a884c0SH. Peter Anvin
8002a884c0SH. Peter Anvintargets += piggy.S
8102a884c0SH. Peter Anvin$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
8202a884c0SH. Peter Anvin	$(call if_changed,mkpiggy)
83