xref: /kernel/linux/linux-5.10/arch/x86/boot/Makefile (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci#
28c2ecf20Sopenharmony_ci# arch/x86/boot/Makefile
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci# This file is subject to the terms and conditions of the GNU General Public
58c2ecf20Sopenharmony_ci# License.  See the file "COPYING" in the main directory of this archive
68c2ecf20Sopenharmony_ci# for more details.
78c2ecf20Sopenharmony_ci#
88c2ecf20Sopenharmony_ci# Copyright (C) 1994 by Linus Torvalds
98c2ecf20Sopenharmony_ci# Changed by many, many contributors over the years.
108c2ecf20Sopenharmony_ci#
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci# Sanitizer runtimes are unavailable and cannot be linked for early boot code.
138c2ecf20Sopenharmony_ciKASAN_SANITIZE			:= n
148c2ecf20Sopenharmony_ciKCSAN_SANITIZE			:= n
158c2ecf20Sopenharmony_ciOBJECT_FILES_NON_STANDARD	:= y
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci# Kernel does not boot with kcov instrumentation here.
188c2ecf20Sopenharmony_ci# One of the problems observed was insertion of __sanitizer_cov_trace_pc()
198c2ecf20Sopenharmony_ci# callback into middle of per-cpu data enabling code. Thus the callback observed
208c2ecf20Sopenharmony_ci# inconsistent state and crashed. We are interested mostly in syscall coverage,
218c2ecf20Sopenharmony_ci# so boot code is not interesting anyway.
228c2ecf20Sopenharmony_ciKCOV_INSTRUMENT		:= n
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci# If you want to preset the SVGA mode, uncomment the next line and
258c2ecf20Sopenharmony_ci# set SVGA_MODE to whatever number you want.
268c2ecf20Sopenharmony_ci# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
278c2ecf20Sopenharmony_ci# The number is the same as you would ordinarily press at bootup.
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ciSVGA_MODE	:= -DSVGA_MODE=NORMAL_VGA
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_citargets		:= vmlinux.bin setup.bin setup.elf bzImage
328c2ecf20Sopenharmony_citargets		+= fdimage fdimage144 fdimage288 image.iso mtools.conf
338c2ecf20Sopenharmony_cisubdir-		:= compressed
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cisetup-y		+= a20.o bioscall.o cmdline.o copy.o cpu.o cpuflags.o cpucheck.o
368c2ecf20Sopenharmony_cisetup-y		+= early_serial_console.o edd.o header.o main.o memory.o
378c2ecf20Sopenharmony_cisetup-y		+= pm.o pmjump.o printf.o regs.o string.o tty.o video.o
388c2ecf20Sopenharmony_cisetup-y		+= video-mode.o version.o
398c2ecf20Sopenharmony_cisetup-$(CONFIG_X86_APM_BOOT) += apm.o
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci# The link order of the video-*.o modules can matter.  In particular,
428c2ecf20Sopenharmony_ci# video-vga.o *must* be listed first, followed by video-vesa.o.
438c2ecf20Sopenharmony_ci# Hardware-specific drivers should follow in the order they should be
448c2ecf20Sopenharmony_ci# probed, and video-bios.o should typically be last.
458c2ecf20Sopenharmony_cisetup-y		+= video-vga.o
468c2ecf20Sopenharmony_cisetup-y		+= video-vesa.o
478c2ecf20Sopenharmony_cisetup-y		+= video-bios.o
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_citargets		+= $(setup-y)
508c2ecf20Sopenharmony_cihostprogs	:= tools/build
518c2ecf20Sopenharmony_cihostprogs	+= mkcpustr
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ciHOST_EXTRACFLAGS += -I$(srctree)/tools/include \
548c2ecf20Sopenharmony_ci		    -include include/generated/autoconf.h \
558c2ecf20Sopenharmony_ci	            -D__EXPORTED_HEADERS__
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ciifdef CONFIG_X86_FEATURE_NAMES
588c2ecf20Sopenharmony_ci$(obj)/cpu.o: $(obj)/cpustr.h
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ciquiet_cmd_cpustr = CPUSTR  $@
618c2ecf20Sopenharmony_ci      cmd_cpustr = $(obj)/mkcpustr > $@
628c2ecf20Sopenharmony_ci$(obj)/cpustr.h: $(obj)/mkcpustr FORCE
638c2ecf20Sopenharmony_ci	$(call if_changed,cpustr)
648c2ecf20Sopenharmony_ciendif
658c2ecf20Sopenharmony_citargets += cpustr.h
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ciKBUILD_CFLAGS	:= $(REALMODE_CFLAGS) -D_SETUP
708c2ecf20Sopenharmony_ciKBUILD_AFLAGS	:= $(KBUILD_CFLAGS) -D__ASSEMBLY__
718c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
728c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables
738c2ecf20Sopenharmony_ciGCOV_PROFILE := n
748c2ecf20Sopenharmony_ciUBSAN_SANITIZE := n
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci$(obj)/bzImage: asflags-y  := $(SVGA_MODE)
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciquiet_cmd_image = BUILD   $@
798c2ecf20Sopenharmony_cisilent_redirect_image = >/dev/null
808c2ecf20Sopenharmony_cicmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \
818c2ecf20Sopenharmony_ci			       $(obj)/zoffset.h $@ $($(quiet)redirect_image)
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci$(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE
848c2ecf20Sopenharmony_ci	$(call if_changed,image)
858c2ecf20Sopenharmony_ci	@$(kecho) 'Kernel: $@ is ready' ' (#'`cat .version`')'
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ciOBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
888c2ecf20Sopenharmony_ci$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
898c2ecf20Sopenharmony_ci	$(call if_changed,objcopy)
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ciSETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cised-zoffset := -e 's/^\([0-9a-fA-F]*\) [a-zA-Z] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|efi32_pe_entry\|input_data\|kernel_info\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ciquiet_cmd_zoffset = ZOFFSET $@
968c2ecf20Sopenharmony_ci      cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_citargets += zoffset.h
998c2ecf20Sopenharmony_ci$(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
1008c2ecf20Sopenharmony_ci	$(call if_changed,zoffset)
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ciAFLAGS_header.o += -I$(objtree)/$(obj)
1048c2ecf20Sopenharmony_ci$(obj)/header.o: $(obj)/zoffset.h
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ciLDFLAGS_setup.elf	:= -m elf_i386 -z noexecstack -T
1078c2ecf20Sopenharmony_ci$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
1088c2ecf20Sopenharmony_ci	$(call if_changed,ld)
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ciOBJCOPYFLAGS_setup.bin	:= -O binary
1118c2ecf20Sopenharmony_ci$(obj)/setup.bin: $(obj)/setup.elf FORCE
1128c2ecf20Sopenharmony_ci	$(call if_changed,objcopy)
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci$(obj)/compressed/vmlinux: FORCE
1158c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(obj)/compressed $@
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci# Set this if you want to pass append arguments to the
1188c2ecf20Sopenharmony_ci# bzdisk/fdimage/isoimage kernel
1198c2ecf20Sopenharmony_ciFDARGS =
1208c2ecf20Sopenharmony_ci# Set this if you want an initrd included with the
1218c2ecf20Sopenharmony_ci# bzdisk/fdimage/isoimage kernel
1228c2ecf20Sopenharmony_ciFDINITRD =
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ciimage_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci$(obj)/mtools.conf: $(src)/mtools.conf.in
1278c2ecf20Sopenharmony_ci	sed -e 's|@OBJ@|$(obj)|g' < $< > $@
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ciquiet_cmd_genimage = GENIMAGE $3
1308c2ecf20Sopenharmony_cicmd_genimage = sh $(srctree)/$(src)/genimage.sh $2 $3 $(obj)/bzImage \
1318c2ecf20Sopenharmony_ci			$(obj)/mtools.conf '$(image_cmdline)' $(FDINITRD)
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ciPHONY += bzdisk fdimage fdimage144 fdimage288 isoimage bzlilo install
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci# This requires write access to /dev/fd0
1368c2ecf20Sopenharmony_cibzdisk: $(obj)/bzImage $(obj)/mtools.conf
1378c2ecf20Sopenharmony_ci	$(call cmd,genimage,bzdisk,/dev/fd0)
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci# These require being root or having syslinux 2.02 or higher installed
1408c2ecf20Sopenharmony_cifdimage fdimage144: $(obj)/bzImage $(obj)/mtools.conf
1418c2ecf20Sopenharmony_ci	$(call cmd,genimage,fdimage144,$(obj)/fdimage)
1428c2ecf20Sopenharmony_ci	@$(kecho) 'Kernel: $(obj)/fdimage is ready'
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cifdimage288: $(obj)/bzImage $(obj)/mtools.conf
1458c2ecf20Sopenharmony_ci	$(call cmd,genimage,fdimage288,$(obj)/fdimage)
1468c2ecf20Sopenharmony_ci	@$(kecho) 'Kernel: $(obj)/fdimage is ready'
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ciisoimage: $(obj)/bzImage
1498c2ecf20Sopenharmony_ci	$(call cmd,genimage,isoimage,$(obj)/image.iso)
1508c2ecf20Sopenharmony_ci	@$(kecho) 'Kernel: $(obj)/image.iso is ready'
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cibzlilo:
1538c2ecf20Sopenharmony_ci	if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
1548c2ecf20Sopenharmony_ci	if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
1558c2ecf20Sopenharmony_ci	cat $(obj)/bzImage > $(INSTALL_PATH)/vmlinuz
1568c2ecf20Sopenharmony_ci	cp System.map $(INSTALL_PATH)/
1578c2ecf20Sopenharmony_ci	if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ciinstall:
1608c2ecf20Sopenharmony_ci	sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
1618c2ecf20Sopenharmony_ci		System.map "$(INSTALL_PATH)"
162