xref: /linux/arch/x86/boot/Makefile (revision 06b31bdbf84990c60adba7185fe4a340473120cb)
196ae6ea0SThomas Gleixner#
296ae6ea0SThomas Gleixner# arch/x86/boot/Makefile
396ae6ea0SThomas Gleixner#
496ae6ea0SThomas Gleixner# This file is subject to the terms and conditions of the GNU General Public
596ae6ea0SThomas Gleixner# License.  See the file "COPYING" in the main directory of this archive
696ae6ea0SThomas Gleixner# for more details.
796ae6ea0SThomas Gleixner#
896ae6ea0SThomas Gleixner# Copyright (C) 1994 by Linus Torvalds
95e47c478SH. Peter Anvin# Changed by many, many contributors over the years.
1096ae6ea0SThomas Gleixner#
1196ae6ea0SThomas Gleixner
1296ae6ea0SThomas Gleixner# If you want to preset the SVGA mode, uncomment the next line and
1396ae6ea0SThomas Gleixner# set SVGA_MODE to whatever number you want.
1496ae6ea0SThomas Gleixner# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
1596ae6ea0SThomas Gleixner# The number is the same as you would ordinarily press at bootup.
1696ae6ea0SThomas Gleixner
1796ae6ea0SThomas GleixnerSVGA_MODE	:= -DSVGA_MODE=NORMAL_VGA
1896ae6ea0SThomas Gleixner
195e47c478SH. Peter Anvintargets		:= vmlinux.bin setup.bin setup.elf bzImage
20f279b49fSH. Peter Anvin (Intel)targets		+= fdimage fdimage144 fdimage288 image.iso hdimage
2196ae6ea0SThomas Gleixnersubdir-		:= compressed
2296ae6ea0SThomas Gleixner
23dd78b973SKees Cooksetup-y		+= a20.o bioscall.o cmdline.o copy.o cpu.o cpuflags.o cpucheck.o
2494916301SPaolo Pisatisetup-y		+= early_serial_console.o edd.o header.o main.o memory.o
25f4ed2877SYinghai Lusetup-y		+= pm.o pmjump.o printf.o regs.o string.o tty.o video.o
26f4ed2877SYinghai Lusetup-y		+= video-mode.o version.o
27a6b68076SAndi Kleensetup-$(CONFIG_X86_APM_BOOT) += apm.o
2896ae6ea0SThomas Gleixner
2996ae6ea0SThomas Gleixner# The link order of the video-*.o modules can matter.  In particular,
3096ae6ea0SThomas Gleixner# video-vga.o *must* be listed first, followed by video-vesa.o.
3196ae6ea0SThomas Gleixner# Hardware-specific drivers should follow in the order they should be
3296ae6ea0SThomas Gleixner# probed, and video-bios.o should typically be last.
3396ae6ea0SThomas Gleixnersetup-y		+= video-vga.o
3496ae6ea0SThomas Gleixnersetup-y		+= video-vesa.o
3596ae6ea0SThomas Gleixnersetup-y		+= video-bios.o
3630c82645SH. Peter Anvin
3796ae6ea0SThomas Gleixnertargets		+= $(setup-y)
385f2fb52fSMasahiro Yamadahostprogs	+= mkcpustr
3996ae6ea0SThomas Gleixner
40b6eea87fSMatt FlemingHOST_EXTRACFLAGS += -I$(srctree)/tools/include \
41b6eea87fSMatt Fleming		    -include include/generated/autoconf.h \
42446e1c86SH. Peter Anvin	            -D__EXPORTED_HEADERS__
43446e1c86SH. Peter Anvin
44f0be6c6aSH. Peter Anvin$(obj)/cpu.o: $(obj)/cpustr.h
45f0be6c6aSH. Peter Anvin
46f0be6c6aSH. Peter Anvinquiet_cmd_cpustr = CPUSTR  $@
47f0be6c6aSH. Peter Anvin      cmd_cpustr = $(obj)/mkcpustr > $@
48f0be6c6aSH. Peter Anvin$(obj)/cpustr.h: $(obj)/mkcpustr FORCE
49f0be6c6aSH. Peter Anvin	$(call if_changed,cpustr)
50e3c7c105SMasahiro Yamadatargets += cpustr.h
5196ae6ea0SThomas Gleixner
5296ae6ea0SThomas Gleixner# ---------------------------------------------------------------------------
5396ae6ea0SThomas Gleixner
540acba3f9SPaul BolleKBUILD_CFLAGS	:= $(REALMODE_CFLAGS) -D_SETUP
55222d394dSSam RavnborgKBUILD_AFLAGS	:= $(KBUILD_CFLAGS) -D__ASSEMBLY__
56003602adSArvind SankarKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables
57dd0716c2SBorislav PetkovKBUILD_CFLAGS	+= $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
5896ae6ea0SThomas Gleixner
595e47c478SH. Peter Anvin$(obj)/bzImage: asflags-y  := $(SVGA_MODE)
6096ae6ea0SThomas Gleixner
6196ae6ea0SThomas Gleixnerquiet_cmd_image = BUILD   $@
62*032ce1eaSArd Biesheuvel      cmd_image = (dd if=$< bs=4k conv=sync status=none; cat $(filter-out $<,$(real-prereqs))) >$@
6396ae6ea0SThomas Gleixner
649c54baabSArd Biesheuvel$(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin FORCE
6596ae6ea0SThomas Gleixner	$(call if_changed,image)
66083cad78SMasahiro Yamada	@$(kecho) 'Kernel: $@ is ready' ' (#'$(or $(KBUILD_BUILD_VERSION),`cat .version`)')'
6796ae6ea0SThomas Gleixner
681622ac23SIan CampbellOBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
6996ae6ea0SThomas Gleixner$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
7096ae6ea0SThomas Gleixner	$(call if_changed,objcopy)
7196ae6ea0SThomas Gleixner
7296ae6ea0SThomas GleixnerSETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
7396ae6ea0SThomas Gleixner
7434951f3cSArd Biesheuvelsed-zoffset := -e 's/^\([0-9a-fA-F]*\) [a-zA-Z] \(startup_32\|efi.._stub_entry\|efi\(32\)\?_pe_entry\|input_data\|kernel_info\|_end\|_ehead\|_text\|_e\?data\|z_.*\)$$/\#define ZO_\2 0x\1/p'
7577d1a499SH. Peter Anvin
7677d1a499SH. Peter Anvinquiet_cmd_zoffset = ZOFFSET $@
7777d1a499SH. Peter Anvin      cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
7877d1a499SH. Peter Anvin
7977d1a499SH. Peter Anvintargets += zoffset.h
8077d1a499SH. Peter Anvin$(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
8177d1a499SH. Peter Anvin	$(call if_changed,zoffset)
8277d1a499SH. Peter Anvin
83099e1377SIan Campbell
8458ab5e0cSArnd BergmannAFLAGS_header.o += -I$(objtree)/$(obj)
8567b66625SYinghai Lu$(obj)/header.o: $(obj)/zoffset.h
86099e1377SIan Campbell
87ffcf9c57SNick DesaulniersLDFLAGS_setup.elf	:= -m elf_i386 -z noexecstack -T
8896ae6ea0SThomas Gleixner$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
8996ae6ea0SThomas Gleixner	$(call if_changed,ld)
9096ae6ea0SThomas Gleixner
9196ae6ea0SThomas GleixnerOBJCOPYFLAGS_setup.bin	:= -O binary
9296ae6ea0SThomas Gleixner$(obj)/setup.bin: $(obj)/setup.elf FORCE
9396ae6ea0SThomas Gleixner	$(call if_changed,objcopy)
9496ae6ea0SThomas Gleixner
9596ae6ea0SThomas Gleixner$(obj)/compressed/vmlinux: FORCE
96d960c9ceSPaul Bolle	$(Q)$(MAKE) $(build)=$(obj)/compressed $@
9796ae6ea0SThomas Gleixner
98f9c5107cSH. Peter Anvin# Set this if you want to pass append arguments to the
99f279b49fSH. Peter Anvin (Intel)# bzdisk/fdimage/hdimage/isoimage kernel
10096ae6ea0SThomas GleixnerFDARGS =
101f279b49fSH. Peter Anvin (Intel)# Set this if you want one or more initrds included in the image
10296ae6ea0SThomas GleixnerFDINITRD =
10396ae6ea0SThomas Gleixner
104f279b49fSH. Peter Anvin (Intel)imgdeps = $(obj)/bzImage $(obj)/mtools.conf $(src)/genimage.sh
10596ae6ea0SThomas Gleixner
10696ae6ea0SThomas Gleixner$(obj)/mtools.conf: $(src)/mtools.conf.in
10796ae6ea0SThomas Gleixner	sed -e 's|@OBJ@|$(obj)|g' < $< > $@
10896ae6ea0SThomas Gleixner
109f279b49fSH. Peter Anvin (Intel)targets += mtools.conf
1104366d57aSChangbin Du
111f279b49fSH. Peter Anvin (Intel)# genimage.sh requires bash, but it also has a bunch of other
112f279b49fSH. Peter Anvin (Intel)# external dependencies.
113f279b49fSH. Peter Anvin (Intel)quiet_cmd_genimage = GENIMAGE $3
114b1992c37SMasahiro Yamada      cmd_genimage = $(BASH) $(src)/genimage.sh $2 $3 $(obj)/bzImage \
115f279b49fSH. Peter Anvin (Intel)		$(obj)/mtools.conf '$(FDARGS)' $(FDINITRD)
116f279b49fSH. Peter Anvin (Intel)
11708155126SMasahiro YamadaPHONY += bzdisk fdimage fdimage144 fdimage288 hdimage isoimage
118675a59b7SMasahiro Yamada
11996ae6ea0SThomas Gleixner# This requires write access to /dev/fd0
120f279b49fSH. Peter Anvin (Intel)# All images require syslinux to be installed; hdimage also requires
121f279b49fSH. Peter Anvin (Intel)# EDK2/OVMF if the kernel is compiled with the EFI stub.
122f279b49fSH. Peter Anvin (Intel)bzdisk: $(imgdeps)
1234366d57aSChangbin Du	$(call cmd,genimage,bzdisk,/dev/fd0)
12496ae6ea0SThomas Gleixner
125f279b49fSH. Peter Anvin (Intel)fdimage fdimage144: $(imgdeps)
1264366d57aSChangbin Du	$(call cmd,genimage,fdimage144,$(obj)/fdimage)
1274366d57aSChangbin Du	@$(kecho) 'Kernel: $(obj)/fdimage is ready'
12896ae6ea0SThomas Gleixner
129f279b49fSH. Peter Anvin (Intel)fdimage288: $(imgdeps)
1304366d57aSChangbin Du	$(call cmd,genimage,fdimage288,$(obj)/fdimage)
1314366d57aSChangbin Du	@$(kecho) 'Kernel: $(obj)/fdimage is ready'
13296ae6ea0SThomas Gleixner
133f279b49fSH. Peter Anvin (Intel)hdimage: $(imgdeps)
134f279b49fSH. Peter Anvin (Intel)	$(call cmd,genimage,hdimage,$(obj)/hdimage)
135f279b49fSH. Peter Anvin (Intel)	@$(kecho) 'Kernel: $(obj)/hdimage is ready'
136f279b49fSH. Peter Anvin (Intel)
137f279b49fSH. Peter Anvin (Intel)isoimage: $(imgdeps)
1384366d57aSChangbin Du	$(call cmd,genimage,isoimage,$(obj)/image.iso)
1394366d57aSChangbin Du	@$(kecho) 'Kernel: $(obj)/image.iso is ready'
140