blob: 89dbf970e058c845e676f8b2be9efc65dcbdfe84 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#
Thomas Gleixner96ae6ea2007-10-11 11:16:45 +02002# arch/x86/boot/Makefile
Linus Torvalds1da177e2005-04-16 15:20:36 -07003#
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#
10
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'.
14
15ROOT_DEV := CURRENT
16
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.
21
22SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
23
24# If you want the RAM disk device, define this to be the size in blocks.
25
26#RAMDISK := -DRAMDISK=512
27
H. Peter Anvin4fd06962007-07-11 12:18:56 -070028targets := vmlinux.bin setup.bin setup.elf zImage bzImage
Linus Torvalds1da177e2005-04-16 15:20:36 -070029subdir- := compressed
30
H. Peter Anvin4fd06962007-07-11 12:18:56 -070031setup-y += a20.o apm.o cmdline.o copy.o cpu.o cpucheck.o edd.o
32setup-y += header.o main.o mca.o memory.o pm.o pmjump.o
33setup-y += printf.o string.o tty.o video.o version.o voyager.o
34
35# The link order of the video-*.o modules can matter. In particular,
36# video-vga.o *must* be listed first, followed by video-vesa.o.
37# Hardware-specific drivers should follow in the order they should be
38# probed, and video-bios.o should typically be last.
39setup-y += video-vga.o
40setup-y += video-vesa.o
41setup-y += video-bios.o
H. Peter Anvin30c82642007-10-15 17:13:22 -070042
Sam Ravnborg3fbc5412007-07-17 22:27:22 +020043targets += $(setup-y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044hostprogs-y := tools/build
45
46HOSTCFLAGS_build.o := $(LINUXINCLUDE)
47
48# ---------------------------------------------------------------------------
49
H. Peter Anvin4fd06962007-07-11 12:18:56 -070050# How to compile the 16-bit code. Note we always compile for -march=i386,
51# that way we can complain to the user if the CPU is insufficient.
52cflags-i386 :=
53cflags-x86_64 := -m32
Sam Ravnborga0f97e02007-10-14 22:21:35 +020054KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
H. Peter Anvin4fd06962007-07-11 12:18:56 -070055 $(cflags-$(ARCH)) \
56 -Wall -Wstrict-prototypes \
57 -march=i386 -mregparm=3 \
58 -include $(srctree)/$(src)/code16gcc.h \
59 -fno-strict-aliasing -fomit-frame-pointer \
60 $(call cc-option, -ffreestanding) \
61 $(call cc-option, -fno-toplevel-reorder,\
62 $(call cc-option, -fno-unit-at-a-time)) \
63 $(call cc-option, -fno-stack-protector) \
64 $(call cc-option, -mpreferred-stack-boundary=2)
Sam Ravnborg222d3942007-10-15 21:59:31 +020065KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
H. Peter Anvin4fd06962007-07-11 12:18:56 -070066
Linus Torvalds1da177e2005-04-16 15:20:36 -070067$(obj)/zImage: IMAGE_OFFSET := 0x1000
Sam Ravnborg7eebb932007-10-16 23:50:33 +020068$(obj)/zImage: asflags-y := $(SVGA_MODE) $(RAMDISK)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069$(obj)/bzImage: IMAGE_OFFSET := 0x100000
Sam Ravnborg7eebb932007-10-16 23:50:33 +020070$(obj)/bzImage: ccflags-y := -D__BIG_KERNEL__
71$(obj)/bzImage: asflags-y := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -070072$(obj)/bzImage: BUILDFLAGS := -b
73
74quiet_cmd_image = BUILD $@
H. Peter Anvin4fd06962007-07-11 12:18:56 -070075cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 $(obj)/vmlinux.bin $(ROOT_DEV) > $@
77
H. Peter Anvin4fd06962007-07-11 12:18:56 -070078$(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 $(obj)/vmlinux.bin $(obj)/tools/build FORCE
80 $(call if_changed,image)
Coywolf Qi Hunt28948012005-06-21 17:15:15 -070081 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
84 $(call if_changed,objcopy)
85
H. Peter Anvin4fd06962007-07-11 12:18:56 -070086SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
H. Peter Anvin4fd06962007-07-11 12:18:56 -070088LDFLAGS_setup.elf := -T
89$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 $(call if_changed,ld)
91
H. Peter Anvin4fd06962007-07-11 12:18:56 -070092OBJCOPYFLAGS_setup.bin := -O binary
93
94$(obj)/setup.bin: $(obj)/setup.elf FORCE
95 $(call if_changed,objcopy)
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097$(obj)/compressed/vmlinux: FORCE
98 $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
99
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800100# Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101FDARGS =
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800102# Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
103FDINITRD =
104
105image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
107$(obj)/mtools.conf: $(src)/mtools.conf.in
108 sed -e 's|@OBJ@|$(obj)|g' < $< > $@
109
110# This requires write access to /dev/fd0
111zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
112 MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
113 syslinux /dev/fd0 ; sync
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800114 echo '$(image_cmdline)' | \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800116 if [ -f '$(FDINITRD)' ] ; then \
117 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
118 fi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
120
121# These require being root or having syslinux 2.02 or higher installed
122fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
123 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
124 MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
125 syslinux $(obj)/fdimage ; sync
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800126 echo '$(image_cmdline)' | \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800128 if [ -f '$(FDINITRD)' ] ; then \
129 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
130 fi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
132
133fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
134 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
135 MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
136 syslinux $(obj)/fdimage ; sync
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800137 echo '$(image_cmdline)' | \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800139 if [ -f '$(FDINITRD)' ] ; then \
140 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
141 fi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
143
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800144isoimage: $(BOOTIMAGE)
145 -rm -rf $(obj)/isoimage
146 mkdir $(obj)/isoimage
Andi Kleenbf660252006-06-26 13:58:41 +0200147 for i in lib lib64 share end ; do \
148 if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
149 cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
150 break ; \
151 fi ; \
152 if [ $$i = end ] ; then exit 1 ; fi ; \
153 done
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800154 cp $(BOOTIMAGE) $(obj)/isoimage/linux
155 echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
156 if [ -f '$(FDINITRD)' ] ; then \
157 cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
158 fi
159 mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
160 -no-emul-boot -boot-load-size 4 -boot-info-table \
161 $(obj)/isoimage
162 rm -rf $(obj)/isoimage
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164zlilo: $(BOOTIMAGE)
165 if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
166 if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
167 cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
168 cp System.map $(INSTALL_PATH)/
169 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
170
H. Peter Anvin0d20bab2006-01-07 17:38:39 -0800171install:
Linus Torvaldsd274ba22006-01-10 21:09:19 -0800172 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"