• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# arch/x86/boot/Makefile
3#
4# This file is subject to the terms and conditions of the GNU General Public
5# License.  See the file "COPYING" in the main directory of this archive
6# for more details.
7#
8# Copyright (C) 1994 by Linus Torvalds
9# Changed by many, many contributors over the years.
10#
11
12KASAN_SANITIZE := n
13
14# Kernel does not boot with kcov instrumentation here.
15# One of the problems observed was insertion of __sanitizer_cov_trace_pc()
16# callback into middle of per-cpu data enabling code. Thus the callback observed
17# inconsistent state and crashed. We are interested mostly in syscall coverage,
18# so boot code is not interesting anyway.
19KCOV_INSTRUMENT		:= n
20
21# If you want to preset the SVGA mode, uncomment the next line and
22# set SVGA_MODE to whatever number you want.
23# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
24# The number is the same as you would ordinarily press at bootup.
25
26SVGA_MODE	:= -DSVGA_MODE=NORMAL_VGA
27
28targets		:= vmlinux.bin setup.bin setup.elf bzImage
29targets		+= fdimage fdimage144 fdimage288 image.iso mtools.conf
30subdir-		:= compressed
31
32setup-y		+= a20.o bioscall.o cmdline.o copy.o cpu.o cpuflags.o cpucheck.o
33setup-y		+= early_serial_console.o edd.o header.o main.o memory.o
34setup-y		+= pm.o pmjump.o printf.o regs.o string.o tty.o video.o
35setup-y		+= video-mode.o version.o
36setup-$(CONFIG_X86_APM_BOOT) += apm.o
37
38# The link order of the video-*.o modules can matter.  In particular,
39# video-vga.o *must* be listed first, followed by video-vesa.o.
40# Hardware-specific drivers should follow in the order they should be
41# probed, and video-bios.o should typically be last.
42setup-y		+= video-vga.o
43setup-y		+= video-vesa.o
44setup-y		+= video-bios.o
45
46targets		+= $(setup-y)
47hostprogs-y	:= tools/build
48hostprogs-$(CONFIG_X86_FEATURE_NAMES) += mkcpustr
49
50HOST_EXTRACFLAGS += -I$(srctree)/tools/include \
51		    -include include/generated/autoconf.h \
52	            -D__EXPORTED_HEADERS__
53
54ifdef CONFIG_X86_FEATURE_NAMES
55$(obj)/cpu.o: $(obj)/cpustr.h
56
57quiet_cmd_cpustr = CPUSTR  $@
58      cmd_cpustr = $(obj)/mkcpustr > $@
59targets += cpustr.h
60$(obj)/cpustr.h: $(obj)/mkcpustr FORCE
61	$(call if_changed,cpustr)
62endif
63clean-files += cpustr.h
64
65# ---------------------------------------------------------------------------
66
67KBUILD_CFLAGS	:= $(USERINCLUDE) $(REALMODE_CFLAGS) -D_SETUP
68KBUILD_AFLAGS	:= $(KBUILD_CFLAGS) -D__ASSEMBLY__
69GCOV_PROFILE := n
70
71$(obj)/bzImage: asflags-y  := $(SVGA_MODE)
72
73quiet_cmd_image = BUILD   $@
74silent_redirect_image = >/dev/null
75cmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \
76			       $(obj)/zoffset.h $@ $($(quiet)redirect_image)
77
78$(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE
79	$(call if_changed,image)
80	@$(kecho) 'Kernel: $@ is ready' ' (#'`cat .version`')'
81
82OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
83$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
84	$(call if_changed,objcopy)
85
86SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
87
88sed-voffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|_end\)$$/\#define VO_\2 0x\1/p'
89
90quiet_cmd_voffset = VOFFSET $@
91      cmd_voffset = $(NM) $< | sed -n $(sed-voffset) > $@
92
93targets += voffset.h
94$(obj)/voffset.h: vmlinux FORCE
95	$(call if_changed,voffset)
96
97sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|z_.*\)$$/\#define ZO_\2 0x\1/p'
98
99quiet_cmd_zoffset = ZOFFSET $@
100      cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
101
102targets += zoffset.h
103$(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
104	$(call if_changed,zoffset)
105
106
107AFLAGS_header.o += -I$(obj)
108$(obj)/header.o: $(obj)/voffset.h $(obj)/zoffset.h
109
110LDFLAGS_setup.elf	:= -m elf_i386 -T
111$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
112	$(call if_changed,ld)
113
114OBJCOPYFLAGS_setup.bin	:= -O binary
115$(obj)/setup.bin: $(obj)/setup.elf FORCE
116	$(call if_changed,objcopy)
117
118$(obj)/compressed/vmlinux: FORCE
119	$(Q)$(MAKE) $(build)=$(obj)/compressed $@
120
121# Set this if you want to pass append arguments to the
122# bzdisk/fdimage/isoimage kernel
123FDARGS =
124# Set this if you want an initrd included with the
125# bzdisk/fdimage/isoimage kernel
126FDINITRD =
127
128image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
129
130$(obj)/mtools.conf: $(src)/mtools.conf.in
131	sed -e 's|@OBJ@|$(obj)|g' < $< > $@
132
133# This requires write access to /dev/fd0
134bzdisk: $(obj)/bzImage $(obj)/mtools.conf
135	MTOOLSRC=$(obj)/mtools.conf mformat a:			; sync
136	syslinux /dev/fd0					; sync
137	echo '$(image_cmdline)' | \
138		MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
139	if [ -f '$(FDINITRD)' ] ; then \
140		MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
141	fi
142	MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage a:linux	; sync
143
144# These require being root or having syslinux 2.02 or higher installed
145fdimage fdimage144: $(obj)/bzImage $(obj)/mtools.conf
146	dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
147	MTOOLSRC=$(obj)/mtools.conf mformat v:			; sync
148	syslinux $(obj)/fdimage					; sync
149	echo '$(image_cmdline)' | \
150		MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
151	if [ -f '$(FDINITRD)' ] ; then \
152		MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
153	fi
154	MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage v:linux	; sync
155
156fdimage288: $(obj)/bzImage $(obj)/mtools.conf
157	dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
158	MTOOLSRC=$(obj)/mtools.conf mformat w:			; sync
159	syslinux $(obj)/fdimage					; sync
160	echo '$(image_cmdline)' | \
161		MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
162	if [ -f '$(FDINITRD)' ] ; then \
163		MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
164	fi
165	MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage w:linux	; sync
166
167isoimage: $(obj)/bzImage
168	-rm -rf $(obj)/isoimage
169	mkdir $(obj)/isoimage
170	for i in lib lib64 share end ; do \
171		if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
172			cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
173			if [ -f /usr/$$i/syslinux/ldlinux.c32 ]; then \
174				cp /usr/$$i/syslinux/ldlinux.c32 $(obj)/isoimage ; \
175			fi ; \
176			break ; \
177		fi ; \
178		if [ $$i = end ] ; then exit 1 ; fi ; \
179	done
180	cp $(obj)/bzImage $(obj)/isoimage/linux
181	echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
182	if [ -f '$(FDINITRD)' ] ; then \
183		cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
184	fi
185	mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
186		-no-emul-boot -boot-load-size 4 -boot-info-table \
187		$(obj)/isoimage
188	isohybrid $(obj)/image.iso 2>/dev/null || true
189	rm -rf $(obj)/isoimage
190
191bzlilo: $(obj)/bzImage
192	if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
193	if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
194	cat $(obj)/bzImage > $(INSTALL_PATH)/vmlinuz
195	cp System.map $(INSTALL_PATH)/
196	if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
197
198install:
199	sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
200		System.map "$(INSTALL_PATH)"
201