2 # linux/arch/x86/boot/compressed/Makefile
4 # create a compressed vmlinux image from the original vmlinux
7 # decompression code (*.o)
8 # asm globals (piggy.S), including:
9 # vmlinux.bin.(gz|bz2|lzma|...)
12 # vmlinux stripped of debugging and comments
14 # vmlinux.bin + vmlinux.relocs
15 # vmlinux.bin.(gz|bz2|lzma|...) is:
16 # (see scripts/Makefile.lib size_append)
17 # compressed vmlinux.bin.all + u32 size of vmlinux.bin.all
21 targets
:= vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
22 vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
24 KBUILD_CFLAGS
:= -m
$(BITS
) -D__KERNEL__
$(LINUX_INCLUDE
) -O2
25 KBUILD_CFLAGS
+= -fno-strict-aliasing
-fPIC
26 KBUILD_CFLAGS
+= -DDISABLE_BRANCH_PROFILING
27 cflags-
$(CONFIG_X86_32
) := -march
=i386
28 cflags-
$(CONFIG_X86_64
) := -mcmodel
=small
29 KBUILD_CFLAGS
+= $(cflags-y
)
30 KBUILD_CFLAGS
+= -mno-mmx
-mno-sse
31 KBUILD_CFLAGS
+= $(call cc-option
,-ffreestanding
)
32 KBUILD_CFLAGS
+= $(call cc-option
,-fno-stack-protector
)
34 KBUILD_AFLAGS
:= $(KBUILD_CFLAGS
) -D__ASSEMBLY__
37 LDFLAGS
:= -m elf_
$(UTS_MACHINE
)
40 hostprogs-y
:= mkpiggy
41 HOST_EXTRACFLAGS
+= -I
$(srctree
)/tools
/include
43 vmlinux-objs-y
:= $(obj
)/vmlinux.lds
$(obj
)/head_
$(BITS
).o
$(obj
)/misc.o \
44 $(obj
)/string.o
$(obj
)/cmdline.o \
45 $(obj
)/piggy.o
$(obj
)/cpuflags.o
47 vmlinux-objs-
$(CONFIG_EARLY_PRINTK
) += $(obj
)/early_serial_console.o
48 vmlinux-objs-
$(CONFIG_RANDOMIZE_BASE
) += $(obj
)/aslr.o
50 $(obj
)/eboot.o
: KBUILD_CFLAGS
+= -fshort-wchar
-mno-red-zone
52 vmlinux-objs-
$(CONFIG_EFI_STUB
) += $(obj
)/eboot.o
$(obj
)/efi_stub_
$(BITS
).o \
53 $(objtree
)/drivers
/firmware
/efi
/libstub
/lib.a
54 vmlinux-objs-
$(CONFIG_EFI_MIXED
) += $(obj
)/efi_thunk_
$(BITS
).o
56 $(obj
)/vmlinux
: $(vmlinux-objs-y
) FORCE
60 OBJCOPYFLAGS_vmlinux.bin
:= -R .comment
-S
61 $(obj
)/vmlinux.bin
: vmlinux FORCE
62 $(call if_changed
,objcopy
)
64 targets
+= $(patsubst $(obj
)/%,%,$(vmlinux-objs-y
)) vmlinux.bin.
all vmlinux.relocs
66 CMD_RELOCS
= arch
/x86
/tools
/relocs
67 quiet_cmd_relocs
= RELOCS
$@
68 cmd_relocs
= $(CMD_RELOCS
) $< > $@
;$(CMD_RELOCS
) --abs-relocs
$<
69 $(obj
)/vmlinux.relocs
: vmlinux FORCE
70 $(call if_changed
,relocs
)
72 vmlinux.bin.all-y
:= $(obj
)/vmlinux.bin
73 vmlinux.bin.all-
$(CONFIG_X86_NEED_RELOCS
) += $(obj
)/vmlinux.relocs
75 $(obj
)/vmlinux.bin.gz
: $(vmlinux.bin.all-y
) FORCE
76 $(call if_changed
,gzip
)
77 $(obj
)/vmlinux.bin.bz2
: $(vmlinux.bin.all-y
) FORCE
78 $(call if_changed
,bzip2
)
79 $(obj
)/vmlinux.bin.lzma
: $(vmlinux.bin.all-y
) FORCE
80 $(call if_changed
,lzma
)
81 $(obj
)/vmlinux.bin.xz
: $(vmlinux.bin.all-y
) FORCE
82 $(call if_changed
,xzkern
)
83 $(obj
)/vmlinux.bin.lzo
: $(vmlinux.bin.all-y
) FORCE
84 $(call if_changed
,lzo
)
85 $(obj
)/vmlinux.bin.lz4
: $(vmlinux.bin.all-y
) FORCE
86 $(call if_changed
,lz4
)
88 suffix-
$(CONFIG_KERNEL_GZIP
) := gz
89 suffix-
$(CONFIG_KERNEL_BZIP2
) := bz2
90 suffix-
$(CONFIG_KERNEL_LZMA
) := lzma
91 suffix-
$(CONFIG_KERNEL_XZ
) := xz
92 suffix-
$(CONFIG_KERNEL_LZO
) := lzo
93 suffix-
$(CONFIG_KERNEL_LZ4
) := lz4
95 RUN_SIZE
= $(shell $(OBJDUMP
) -h vmlinux | \
96 $(CONFIG_SHELL
) $(srctree
)/arch
/x86
/tools
/calc_run_size.sh
)
97 quiet_cmd_mkpiggy
= MKPIGGY
$@
98 cmd_mkpiggy
= $(obj
)/mkpiggy
$< $(RUN_SIZE
) > $@ ||
( rm -f
$@
; false
)
101 $(obj
)/piggy.S
: $(obj
)/vmlinux.bin.
$(suffix-y
) $(obj
)/mkpiggy FORCE
102 $(call if_changed
,mkpiggy
)