blob: c70eff69a1fb7b6a8708c5acd193a2f1a8a163e4 [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
H. Peter Anvinf0be6c62008-02-04 16:48:00 +010029subdir- := compressed
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Andi Kleena6b68072008-01-30 13:32:49 +010031setup-y += a20.o cmdline.o copy.o cpu.o cpucheck.o edd.o
H. Peter Anvin4fd06962007-07-11 12:18:56 -070032setup-y += header.o main.o mca.o memory.o pm.o pmjump.o
Pavel Macheke44b7b72008-04-10 23:28:10 +020033setup-y += printf.o string.o tty.o video.o video-mode.o version.o
Andi Kleena6b68072008-01-30 13:32:49 +010034setup-$(CONFIG_X86_APM_BOOT) += apm.o
H. Peter Anvin4fd06962007-07-11 12:18:56 -070035
36# The link order of the video-*.o modules can matter. In particular,
37# video-vga.o *must* be listed first, followed by video-vesa.o.
38# Hardware-specific drivers should follow in the order they should be
39# probed, and video-bios.o should typically be last.
40setup-y += video-vga.o
41setup-y += video-vesa.o
42setup-y += video-bios.o
H. Peter Anvin30c82642007-10-15 17:13:22 -070043
Sam Ravnborg3fbc5412007-07-17 22:27:22 +020044targets += $(setup-y)
H. Peter Anvinf0be6c62008-02-04 16:48:00 +010045hostprogs-y := mkcpustr tools/build
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
H. Peter Anvinf0be6c62008-02-04 16:48:00 +010047HOST_EXTRACFLAGS += $(LINUXINCLUDE)
48
49$(obj)/cpu.o: $(obj)/cpustr.h
50
51quiet_cmd_cpustr = CPUSTR $@
52 cmd_cpustr = $(obj)/mkcpustr > $@
53targets += cpustr.h
54$(obj)/cpustr.h: $(obj)/mkcpustr FORCE
55 $(call if_changed,cpustr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57# ---------------------------------------------------------------------------
58
H. Peter Anvin4fd06962007-07-11 12:18:56 -070059# How to compile the 16-bit code. Note we always compile for -march=i386,
60# that way we can complain to the user if the CPU is insufficient.
Sam Ravnborga0f97e02007-10-14 22:21:35 +020061KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
H. Peter Anvin4fd06962007-07-11 12:18:56 -070062 -Wall -Wstrict-prototypes \
63 -march=i386 -mregparm=3 \
64 -include $(srctree)/$(src)/code16gcc.h \
65 -fno-strict-aliasing -fomit-frame-pointer \
66 $(call cc-option, -ffreestanding) \
67 $(call cc-option, -fno-toplevel-reorder,\
68 $(call cc-option, -fno-unit-at-a-time)) \
69 $(call cc-option, -fno-stack-protector) \
70 $(call cc-option, -mpreferred-stack-boundary=2)
Sam Ravnborg4ba7e5c2008-01-30 13:32:23 +010071KBUILD_CFLAGS += $(call cc-option,-m32)
Sam Ravnborg222d3942007-10-15 21:59:31 +020072KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
H. Peter Anvin4fd06962007-07-11 12:18:56 -070073
Sam Ravnborg7eebb932007-10-16 23:50:33 +020074$(obj)/zImage: asflags-y := $(SVGA_MODE) $(RAMDISK)
Sam Ravnborg7eebb932007-10-16 23:50:33 +020075$(obj)/bzImage: ccflags-y := -D__BIG_KERNEL__
76$(obj)/bzImage: asflags-y := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -070077$(obj)/bzImage: BUILDFLAGS := -b
78
79quiet_cmd_image = BUILD $@
H. Peter Anvin4fd06962007-07-11 12:18:56 -070080cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 $(obj)/vmlinux.bin $(ROOT_DEV) > $@
82
H. Peter Anvin4fd06962007-07-11 12:18:56 -070083$(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 $(obj)/vmlinux.bin $(obj)/tools/build FORCE
85 $(call if_changed,image)
Coywolf Qi Hunt28948012005-06-21 17:15:15 -070086 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Ian Campbell1622ac22008-02-04 16:47:56 +010088OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
Linus Torvalds1da177e2005-04-16 15:20:36 -070089$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
90 $(call if_changed,objcopy)
91
H. Peter Anvin4fd06962007-07-11 12:18:56 -070092SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
Ian Campbell099e1372008-02-13 20:54:58 +000094sed-offsets := -e 's/^00*/0/' \
95 -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/\#define \2 0x\1/p'
96
97quiet_cmd_offsets = OFFSETS $@
98 cmd_offsets = $(NM) $< | sed -n $(sed-offsets) > $@
99
100$(obj)/offsets.h: $(obj)/compressed/vmlinux FORCE
101 $(call if_changed,offsets)
102
103targets += offsets.h
104
105AFLAGS_header.o += -I$(obj)
106$(obj)/header.o: $(obj)/offsets.h
107
H. Peter Anvin4fd06962007-07-11 12:18:56 -0700108LDFLAGS_setup.elf := -T
109$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 $(call if_changed,ld)
111
H. Peter Anvin4fd06962007-07-11 12:18:56 -0700112OBJCOPYFLAGS_setup.bin := -O binary
H. Peter Anvin4fd06962007-07-11 12:18:56 -0700113$(obj)/setup.bin: $(obj)/setup.elf FORCE
114 $(call if_changed,objcopy)
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116$(obj)/compressed/vmlinux: FORCE
Paul Bolled960c9c2008-10-04 21:18:51 +0200117 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800119# Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
H. Peter Anvinf0be6c62008-02-04 16:48:00 +0100120FDARGS =
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800121# Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
122FDINITRD =
123
124image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
126$(obj)/mtools.conf: $(src)/mtools.conf.in
127 sed -e 's|@OBJ@|$(obj)|g' < $< > $@
128
129# This requires write access to /dev/fd0
130zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
131 MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
132 syslinux /dev/fd0 ; sync
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800133 echo '$(image_cmdline)' | \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800135 if [ -f '$(FDINITRD)' ] ; then \
136 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
137 fi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
139
140# These require being root or having syslinux 2.02 or higher installed
141fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
142 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
143 MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
144 syslinux $(obj)/fdimage ; sync
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800145 echo '$(image_cmdline)' | \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800147 if [ -f '$(FDINITRD)' ] ; then \
148 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
149 fi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
151
152fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
153 dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
154 MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
155 syslinux $(obj)/fdimage ; sync
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800156 echo '$(image_cmdline)' | \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800158 if [ -f '$(FDINITRD)' ] ; then \
159 MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
160 fi
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
162
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800163isoimage: $(BOOTIMAGE)
164 -rm -rf $(obj)/isoimage
165 mkdir $(obj)/isoimage
Andi Kleenbf660252006-06-26 13:58:41 +0200166 for i in lib lib64 share end ; do \
167 if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
168 cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
169 break ; \
170 fi ; \
171 if [ $$i = end ] ; then exit 1 ; fi ; \
172 done
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800173 cp $(BOOTIMAGE) $(obj)/isoimage/linux
174 echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
175 if [ -f '$(FDINITRD)' ] ; then \
176 cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
177 fi
178 mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
179 -no-emul-boot -boot-load-size 4 -boot-info-table \
180 $(obj)/isoimage
H. Peter Anvind2f37382008-09-05 21:28:27 -0700181 isohybrid $(obj)/image.iso 2>/dev/null || true
H. Peter Anvin841b8a42006-03-26 01:36:59 -0800182 rm -rf $(obj)/isoimage
183
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184zlilo: $(BOOTIMAGE)
185 if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
186 if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
187 cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
188 cp System.map $(INSTALL_PATH)/
189 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
190
H. Peter Anvin0d20bab2006-01-07 17:38:39 -0800191install:
Linus Torvaldsd274ba22006-01-10 21:09:19 -0800192 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"