xref: /openbmc/linux/arch/x86/boot/compressed/Makefile (revision 6774def6)
1#
2# linux/arch/x86/boot/compressed/Makefile
3#
4# create a compressed vmlinux image from the original vmlinux
5#
6
7targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
8	vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
9
10KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
11KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
12KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
13cflags-$(CONFIG_X86_32) := -march=i386
14cflags-$(CONFIG_X86_64) := -mcmodel=small
15KBUILD_CFLAGS += $(cflags-y)
16KBUILD_CFLAGS += -mno-mmx -mno-sse
17KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
18KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
19
20KBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
21GCOV_PROFILE := n
22
23LDFLAGS := -m elf_$(UTS_MACHINE)
24LDFLAGS_vmlinux := -T
25
26hostprogs-y	:= mkpiggy
27HOST_EXTRACFLAGS += -I$(srctree)/tools/include
28
29vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
30	$(obj)/string.o $(obj)/cmdline.o \
31	$(obj)/piggy.o $(obj)/cpuflags.o
32
33vmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o
34vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/aslr.o
35
36$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
37
38vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o
39
40$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
41	$(call if_changed,ld)
42	@:
43
44OBJCOPYFLAGS_vmlinux.bin :=  -R .comment -S
45$(obj)/vmlinux.bin: vmlinux FORCE
46	$(call if_changed,objcopy)
47
48targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs
49
50CMD_RELOCS = arch/x86/tools/relocs
51quiet_cmd_relocs = RELOCS  $@
52      cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
53$(obj)/vmlinux.relocs: vmlinux FORCE
54	$(call if_changed,relocs)
55
56vmlinux.bin.all-y := $(obj)/vmlinux.bin
57vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
58
59$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE
60	$(call if_changed,gzip)
61$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
62	$(call if_changed,bzip2)
63$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
64	$(call if_changed,lzma)
65$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
66	$(call if_changed,xzkern)
67$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
68	$(call if_changed,lzo)
69$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
70	$(call if_changed,lz4)
71
72suffix-$(CONFIG_KERNEL_GZIP)	:= gz
73suffix-$(CONFIG_KERNEL_BZIP2)	:= bz2
74suffix-$(CONFIG_KERNEL_LZMA)	:= lzma
75suffix-$(CONFIG_KERNEL_XZ)	:= xz
76suffix-$(CONFIG_KERNEL_LZO) 	:= lzo
77suffix-$(CONFIG_KERNEL_LZ4) 	:= lz4
78
79RUN_SIZE = $(shell objdump -h vmlinux | \
80	     perl $(srctree)/arch/x86/tools/calc_run_size.pl)
81quiet_cmd_mkpiggy = MKPIGGY $@
82      cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
83
84targets += piggy.S
85$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
86	$(call if_changed,mkpiggy)
87