blob: 20db5b3609de54f594b2039abf82d17d27ab1737 [file] [log] [blame]
Sam Ravnborgdb569af2008-01-30 13:32:30 +01001#
2# linux/arch/x86/boot/compressed/Makefile
3#
4# create a compressed vmlinux image from the original vmlinux
5#
6
Kyungsik Leef9b493a2013-07-08 16:01:48 -07007targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
8 vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
Sam Ravnborgdb569af2008-01-30 13:32:30 +01009
10KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
11KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
H. Peter Anvin95a38f32009-04-01 17:35:00 -070012KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
H. Peter Anvin17a2a9b2009-12-25 15:40:38 -080013cflags-$(CONFIG_X86_32) := -march=i386
Sam Ravnborgdb569af2008-01-30 13:32:30 +010014cflags-$(CONFIG_X86_64) := -mcmodel=small
15KBUILD_CFLAGS += $(cflags-y)
H. Peter Anvin8b3b0052013-12-09 15:43:38 -080016KBUILD_CFLAGS += -mno-mmx -mno-sse
Sam Ravnborgdb569af2008-01-30 13:32:30 +010017KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
18KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
19
20KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
Peter Oberparleiter7bf99fb2009-06-17 16:28:09 -070021GCOV_PROFILE := n
Sam Ravnborgdb569af2008-01-30 13:32:30 +010022
23LDFLAGS := -m elf_$(UTS_MACHINE)
24LDFLAGS_vmlinux := -T
25
H. Peter Anvin02a884c2009-05-08 17:42:16 -070026hostprogs-y := mkpiggy
Matt Fleming12871c52012-02-28 13:37:22 +000027HOST_EXTRACFLAGS += -I$(srctree)/tools/include
H. Peter Anvin02a884c2009-05-08 17:42:16 -070028
Josh Triplett9a1cb472014-03-10 13:03:10 -070029vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
Josh Triplett3afed062014-03-10 13:26:10 -070030 $(obj)/string.o $(obj)/cmdline.o \
Josh Triplett9e6abd22014-03-10 13:11:26 -070031 $(obj)/piggy.o $(obj)/cpuflags.o
32
Josh Triplett3afed062014-03-10 13:26:10 -070033vmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o
Josh Triplett9e6abd22014-03-10 13:11:26 -070034vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/aslr.o
Matt Fleming291f3632011-12-12 21:27:52 +000035
Matthew Garrett9dead5b2012-07-26 18:00:00 -040036$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
Matthew Garrett9dead5b2012-07-26 18:00:00 -040037
Josh Triplett9a1cb472014-03-10 13:03:10 -070038vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \
39 $(objtree)/drivers/firmware/efi/libstub/lib.a
Matt Fleming291f3632011-12-12 21:27:52 +000040
Josh Triplett9a1cb472014-03-10 13:03:10 -070041$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
Sam Ravnborgdb569af2008-01-30 13:32:30 +010042 $(call if_changed,ld)
43 @:
44
Ian Campbell099e1372008-02-13 20:54:58 +000045OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
Sam Ravnborgdb569af2008-01-30 13:32:30 +010046$(obj)/vmlinux.bin: vmlinux FORCE
47 $(call if_changed,objcopy)
48
Josh Triplett9a1cb472014-03-10 13:03:10 -070049targets += $(patsubst $(obj)/%,%,$(vmlinux-objs-y)) vmlinux.bin.all vmlinux.relocs
Sam Ravnborgdb569af2008-01-30 13:32:30 +010050
H. Peter Anvin6520fe52012-05-08 21:22:24 +030051CMD_RELOCS = arch/x86/tools/relocs
Sam Ravnborgdb569af2008-01-30 13:32:30 +010052quiet_cmd_relocs = RELOCS $@
H. Peter Anvin6520fe52012-05-08 21:22:24 +030053 cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
54$(obj)/vmlinux.relocs: vmlinux FORCE
Sam Ravnborgdb569af2008-01-30 13:32:30 +010055 $(call if_changed,relocs)
56
57vmlinux.bin.all-y := $(obj)/vmlinux.bin
H. Peter Anvin5f11e022009-05-05 22:53:11 -070058vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
Sam Ravnborgdb569af2008-01-30 13:32:30 +010059
H. Peter Anvin5f11e022009-05-05 22:53:11 -070060$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE
Sam Ravnborgdb569af2008-01-30 13:32:30 +010061 $(call if_changed,gzip)
H. Peter Anvin5f11e022009-05-05 22:53:11 -070062$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
Alain Knaffae03c492009-01-04 22:46:17 +010063 $(call if_changed,bzip2)
H. Peter Anvin5f11e022009-05-05 22:53:11 -070064$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
Alain Knaffae03c492009-01-04 22:46:17 +010065 $(call if_changed,lzma)
Lasse Collin30314802011-01-12 17:01:24 -080066$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
67 $(call if_changed,xzkern)
Albin Tonnerre13510992010-01-08 14:42:45 -080068$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
69 $(call if_changed,lzo)
Kyungsik Leef9b493a2013-07-08 16:01:48 -070070$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
71 $(call if_changed,lz4)
Sam Ravnborgdb569af2008-01-30 13:32:30 +010072
H. Peter Anvin283ab1c2009-05-08 15:32:47 -070073suffix-$(CONFIG_KERNEL_GZIP) := gz
74suffix-$(CONFIG_KERNEL_BZIP2) := bz2
75suffix-$(CONFIG_KERNEL_LZMA) := lzma
Lasse Collin30314802011-01-12 17:01:24 -080076suffix-$(CONFIG_KERNEL_XZ) := xz
Albin Tonnerre13510992010-01-08 14:42:45 -080077suffix-$(CONFIG_KERNEL_LZO) := lzo
Kyungsik Leef9b493a2013-07-08 16:01:48 -070078suffix-$(CONFIG_KERNEL_LZ4) := lz4
Alain Knaffae03c492009-01-04 22:46:17 +010079
H. Peter Anvin02a884c2009-05-08 17:42:16 -070080quiet_cmd_mkpiggy = MKPIGGY $@
81 cmd_mkpiggy = $(obj)/mkpiggy $< > $@ || ( rm -f $@ ; false )
82
83targets += piggy.S
84$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
85 $(call if_changed,mkpiggy)