Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | # |
Thomas Gleixner | 96ae6ea | 2007-10-11 11:16:45 +0200 | [diff] [blame] | 2 | # arch/x86/boot/Makefile |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | # |
| 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 | |
| 15 | ROOT_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 | |
| 22 | SVGA_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 Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 28 | targets := vmlinux.bin setup.bin setup.elf zImage bzImage |
H. Peter Anvin | f0be6c6 | 2008-02-04 16:48:00 +0100 | [diff] [blame^] | 29 | subdir- := compressed |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Andi Kleen | a6b6807 | 2008-01-30 13:32:49 +0100 | [diff] [blame] | 31 | setup-y += a20.o cmdline.o copy.o cpu.o cpucheck.o edd.o |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 32 | setup-y += header.o main.o mca.o memory.o pm.o pmjump.o |
Andi Kleen | a6b6807 | 2008-01-30 13:32:49 +0100 | [diff] [blame] | 33 | setup-y += printf.o string.o tty.o video.o version.o |
| 34 | setup-$(CONFIG_X86_APM_BOOT) += apm.o |
| 35 | setup-$(CONFIG_X86_VOYAGER) += voyager.o |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 36 | |
| 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 |
H. Peter Anvin | 30c8264 | 2007-10-15 17:13:22 -0700 | [diff] [blame] | 44 | |
Sam Ravnborg | 3fbc541 | 2007-07-17 22:27:22 +0200 | [diff] [blame] | 45 | targets += $(setup-y) |
H. Peter Anvin | f0be6c6 | 2008-02-04 16:48:00 +0100 | [diff] [blame^] | 46 | hostprogs-y := mkcpustr tools/build |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
H. Peter Anvin | f0be6c6 | 2008-02-04 16:48:00 +0100 | [diff] [blame^] | 48 | HOST_EXTRACFLAGS += $(LINUXINCLUDE) |
| 49 | |
| 50 | $(obj)/cpu.o: $(obj)/cpustr.h |
| 51 | |
| 52 | quiet_cmd_cpustr = CPUSTR $@ |
| 53 | cmd_cpustr = $(obj)/mkcpustr > $@ |
| 54 | targets += cpustr.h |
| 55 | $(obj)/cpustr.h: $(obj)/mkcpustr FORCE |
| 56 | $(call if_changed,cpustr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | # --------------------------------------------------------------------------- |
| 59 | |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 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. |
Sam Ravnborg | a0f97e0 | 2007-10-14 22:21:35 +0200 | [diff] [blame] | 62 | KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \ |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 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) |
Sam Ravnborg | 4ba7e5c | 2008-01-30 13:32:23 +0100 | [diff] [blame] | 72 | KBUILD_CFLAGS += $(call cc-option,-m32) |
Sam Ravnborg | 222d394 | 2007-10-15 21:59:31 +0200 | [diff] [blame] | 73 | KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | $(obj)/zImage: IMAGE_OFFSET := 0x1000 |
Sam Ravnborg | 7eebb93 | 2007-10-16 23:50:33 +0200 | [diff] [blame] | 76 | $(obj)/zImage: asflags-y := $(SVGA_MODE) $(RAMDISK) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | $(obj)/bzImage: IMAGE_OFFSET := 0x100000 |
Sam Ravnborg | 7eebb93 | 2007-10-16 23:50:33 +0200 | [diff] [blame] | 78 | $(obj)/bzImage: ccflags-y := -D__BIG_KERNEL__ |
| 79 | $(obj)/bzImage: asflags-y := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | $(obj)/bzImage: BUILDFLAGS := -b |
| 81 | |
| 82 | quiet_cmd_image = BUILD $@ |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 83 | cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | $(obj)/vmlinux.bin $(ROOT_DEV) > $@ |
| 85 | |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 86 | $(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | $(obj)/vmlinux.bin $(obj)/tools/build FORCE |
| 88 | $(call if_changed,image) |
Coywolf Qi Hunt | 2894801 | 2005-06-21 17:15:15 -0700 | [diff] [blame] | 89 | @echo 'Kernel: $@ is ready' ' (#'`cat .version`')' |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
Ian Campbell | 1622ac2 | 2008-02-04 16:47:56 +0100 | [diff] [blame] | 91 | OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE |
| 93 | $(call if_changed,objcopy) |
| 94 | |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 95 | SETUP_OBJS = $(addprefix $(obj)/,$(setup-y)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 97 | LDFLAGS_setup.elf := -T |
| 98 | $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | $(call if_changed,ld) |
| 100 | |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 101 | OBJCOPYFLAGS_setup.bin := -O binary |
H. Peter Anvin | 4fd0696 | 2007-07-11 12:18:56 -0700 | [diff] [blame] | 102 | $(obj)/setup.bin: $(obj)/setup.elf FORCE |
| 103 | $(call if_changed,objcopy) |
| 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | $(obj)/compressed/vmlinux: FORCE |
| 106 | $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@ |
| 107 | |
H. Peter Anvin | 841b8a4 | 2006-03-26 01:36:59 -0800 | [diff] [blame] | 108 | # Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel |
H. Peter Anvin | f0be6c6 | 2008-02-04 16:48:00 +0100 | [diff] [blame^] | 109 | FDARGS = |
H. Peter Anvin | 841b8a4 | 2006-03-26 01:36:59 -0800 | [diff] [blame] | 110 | # Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel |
| 111 | FDINITRD = |
| 112 | |
| 113 | image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | $(obj)/mtools.conf: $(src)/mtools.conf.in |
| 116 | sed -e 's|@OBJ@|$(obj)|g' < $< > $@ |
| 117 | |
| 118 | # This requires write access to /dev/fd0 |
| 119 | zdisk: $(BOOTIMAGE) $(obj)/mtools.conf |
| 120 | MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync |
| 121 | syslinux /dev/fd0 ; sync |
H. Peter Anvin | 841b8a4 | 2006-03-26 01:36:59 -0800 | [diff] [blame] | 122 | echo '$(image_cmdline)' | \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg |
H. Peter Anvin | 841b8a4 | 2006-03-26 01:36:59 -0800 | [diff] [blame] | 124 | if [ -f '$(FDINITRD)' ] ; then \ |
| 125 | MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \ |
| 126 | fi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync |
| 128 | |
| 129 | # These require being root or having syslinux 2.02 or higher installed |
| 130 | fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf |
| 131 | dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440 |
| 132 | MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync |
| 133 | syslinux $(obj)/fdimage ; sync |
H. Peter Anvin | 841b8a4 | 2006-03-26 01:36:59 -0800 | [diff] [blame] | 134 | echo '$(image_cmdline)' | \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg |
H. Peter Anvin | 841b8a4 | 2006-03-26 01:36:59 -0800 | [diff] [blame] | 136 | if [ -f '$(FDINITRD)' ] ; then \ |
| 137 | MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \ |
| 138 | fi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync |
| 140 | |
| 141 | fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf |
| 142 | dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880 |
| 143 | MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync |
| 144 | syslinux $(obj)/fdimage ; sync |
H. Peter Anvin | 841b8a4 | 2006-03-26 01:36:59 -0800 | [diff] [blame] | 145 | echo '$(image_cmdline)' | \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg |
H. Peter Anvin | 841b8a4 | 2006-03-26 01:36:59 -0800 | [diff] [blame] | 147 | if [ -f '$(FDINITRD)' ] ; then \ |
| 148 | MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \ |
| 149 | fi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync |
| 151 | |
H. Peter Anvin | 841b8a4 | 2006-03-26 01:36:59 -0800 | [diff] [blame] | 152 | isoimage: $(BOOTIMAGE) |
| 153 | -rm -rf $(obj)/isoimage |
| 154 | mkdir $(obj)/isoimage |
Andi Kleen | bf66025 | 2006-06-26 13:58:41 +0200 | [diff] [blame] | 155 | for i in lib lib64 share end ; do \ |
| 156 | if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \ |
| 157 | cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \ |
| 158 | break ; \ |
| 159 | fi ; \ |
| 160 | if [ $$i = end ] ; then exit 1 ; fi ; \ |
| 161 | done |
H. Peter Anvin | 841b8a4 | 2006-03-26 01:36:59 -0800 | [diff] [blame] | 162 | cp $(BOOTIMAGE) $(obj)/isoimage/linux |
| 163 | echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg |
| 164 | if [ -f '$(FDINITRD)' ] ; then \ |
| 165 | cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \ |
| 166 | fi |
| 167 | mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \ |
| 168 | -no-emul-boot -boot-load-size 4 -boot-info-table \ |
| 169 | $(obj)/isoimage |
| 170 | rm -rf $(obj)/isoimage |
| 171 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | zlilo: $(BOOTIMAGE) |
| 173 | if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi |
| 174 | if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi |
| 175 | cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz |
| 176 | cp System.map $(INSTALL_PATH)/ |
| 177 | if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi |
| 178 | |
H. Peter Anvin | 0d20bab | 2006-01-07 17:38:39 -0800 | [diff] [blame] | 179 | install: |
Linus Torvalds | d274ba2 | 2006-01-10 21:09:19 -0800 | [diff] [blame] | 180 | sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)" |