2 # arch/x86/boot/Makefile
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
8 # Copyright (C) 1994 by Linus Torvalds
11 # ROOT_DEV specifies the default root-device when making the image.
12 # This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case
13 # the default of FLOPPY is used by 'build'.
17 # If you want to preset the SVGA mode, uncomment the next line and
18 # set SVGA_MODE to whatever number you want.
19 # Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
20 # The number is the same as you would ordinarily press at bootup.
22 SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
24 # If you want the RAM disk device, define this to be the size in blocks.
26 #RAMDISK := -DRAMDISK=512
28 targets := vmlinux.bin setup.bin setup.elf zImage bzImage
31 setup-y += a20.o cmdline.o copy.o cpu.o cpucheck.o edd.o
32 setup-y += header.o main.o mca.o memory.o pm.o pmjump.o
33 setup-y += printf.o string.o tty.o video.o video-mode.o version.o
34 setup-$(CONFIG_X86_APM_BOOT) += apm.o
35 setup-$(CONFIG_X86_VOYAGER) += voyager.o
37 # The link order of the video-*.o modules can matter. In particular,
38 # video-vga.o *must* be listed first, followed by video-vesa.o.
39 # Hardware-specific drivers should follow in the order they should be
40 # probed, and video-bios.o should typically be last.
41 setup-y += video-vga.o
42 setup-y += video-vesa.o
43 setup-y += video-bios.o
46 hostprogs-y := mkcpustr tools/build
48 HOST_EXTRACFLAGS += $(LINUXINCLUDE)
50 $(obj)/cpu.o: $(obj)/cpustr.h
52 quiet_cmd_cpustr = CPUSTR $@
53 cmd_cpustr = $(obj)/mkcpustr > $@
55 $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
56 $(call if_changed,cpustr)
58 # ---------------------------------------------------------------------------
60 # How to compile the 16-bit code. Note we always compile for -march=i386,
61 # that way we can complain to the user if the CPU is insufficient.
62 KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
63 -Wall -Wstrict-prototypes \
64 -march=i386 -mregparm=3 \
65 -include $(srctree)/$(src)/code16gcc.h \
66 -fno-strict-aliasing -fomit-frame-pointer \
67 $(call cc-option, -ffreestanding) \
68 $(call cc-option, -fno-toplevel-reorder,\
69 $(call cc-option, -fno-unit-at-a-time)) \
70 $(call cc-option, -fno-stack-protector) \
71 $(call cc-option, -mpreferred-stack-boundary=2)
72 KBUILD_CFLAGS += $(call cc-option,-m32)
73 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
75 $(obj)/zImage: IMAGE_OFFSET := 0x1000
76 $(obj)/zImage: asflags-y := $(SVGA_MODE) $(RAMDISK)
77 $(obj)/bzImage: IMAGE_OFFSET := 0x100000
78 $(obj)/bzImage: ccflags-y := -D__BIG_KERNEL__
79 $(obj)/bzImage: asflags-y := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
80 $(obj)/bzImage: BUILDFLAGS := -b
82 quiet_cmd_image = BUILD $@
83 cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
84 $(obj)/vmlinux.bin $(ROOT_DEV) > $@
86 $(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
87 $(obj)/vmlinux.bin $(obj)/tools/build FORCE
88 $(call if_changed,image)
89 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
91 OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
92 $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
93 $(call if_changed,objcopy)
95 SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
97 sed-offsets := -e 's/^00*/0/' \
98 -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/\#define \2 0x\1/p'
100 quiet_cmd_offsets = OFFSETS $@
101 cmd_offsets = $(NM) $< | sed -n $(sed-offsets) > $@
103 $(obj)/offsets.h: $(obj)/compressed/vmlinux FORCE
104 $(call if_changed,offsets)
108 AFLAGS_header.o += -I$(obj)
109 $(obj)/header.o: $(obj)/offsets.h
111 LDFLAGS_setup.elf := -T
112 $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
113 $(call if_changed,ld)
115 OBJCOPYFLAGS_setup.bin := -O binary
116 $(obj)/setup.bin: $(obj)/setup.elf FORCE
117 $(call if_changed,objcopy)
119 $(obj)/compressed/vmlinux: FORCE
120 $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
122 # Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
124 # Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
127 image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
129 $(obj)/mtools.conf: $(src)/mtools.conf.in
130 sed -e 's|@OBJ@|$(obj)|g' < $< > $@
132 # This requires write access to /dev/fd0
133 zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
134 MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
135 syslinux /dev/fd0 ; sync
136 echo '$(image_cmdline)' | \
137 MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
138 if [ -f '$(FDINITRD)' ] ; then \
139 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
141 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
143 # These require being root or having syslinux 2.02 or higher installed
144 fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
145 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
146 MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
147 syslinux $(obj)/fdimage ; sync
148 echo '$(image_cmdline)' | \
149 MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
150 if [ -f '$(FDINITRD)' ] ; then \
151 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
153 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
155 fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
156 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
157 MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
158 syslinux $(obj)/fdimage ; sync
159 echo '$(image_cmdline)' | \
160 MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
161 if [ -f '$(FDINITRD)' ] ; then \
162 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
164 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
166 isoimage: $(BOOTIMAGE)
167 -rm -rf $(obj)/isoimage
168 mkdir $(obj)/isoimage
169 for i in lib lib64 share end ; do \
170 if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
171 cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
174 if [ $$i = end ] ; then exit 1 ; fi ; \
176 cp $(BOOTIMAGE) $(obj)/isoimage/linux
177 echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
178 if [ -f '$(FDINITRD)' ] ; then \
179 cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
181 mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
182 -no-emul-boot -boot-load-size 4 -boot-info-table \
184 isohybrid $(obj)/image.iso 2>/dev/null || true
185 rm -rf $(obj)/isoimage
188 if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
189 if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
190 cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
191 cp System.map $(INSTALL_PATH)/
192 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
195 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"