linux/arch/x86/boot/Makefile
<<
>>
Prefs
   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#
  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
  28targets         := vmlinux.bin setup.bin setup.elf zImage bzImage
  29subdir-         := compressed
  30
  31setup-y         += a20.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 video-mode.o version.o
  34setup-$(CONFIG_X86_APM_BOOT) += apm.o
  35setup-$(CONFIG_X86_VOYAGER) += voyager.o
  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.
  41setup-y         += video-vga.o
  42setup-y         += video-vesa.o
  43setup-y         += video-bios.o
  44
  45targets         += $(setup-y)
  46hostprogs-y     := mkcpustr tools/build
  47
  48HOST_EXTRACFLAGS += $(LINUXINCLUDE)
  49
  50$(obj)/cpu.o: $(obj)/cpustr.h
  51
  52quiet_cmd_cpustr = CPUSTR  $@
  53      cmd_cpustr = $(obj)/mkcpustr > $@
  54targets         += cpustr.h
  55$(obj)/cpustr.h: $(obj)/mkcpustr FORCE
  56        $(call if_changed,cpustr)
  57
  58# ---------------------------------------------------------------------------
  59
  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.
  62KBUILD_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)
  72KBUILD_CFLAGS +=   $(call cc-option,-m32)
  73KBUILD_AFLAGS   := $(KBUILD_CFLAGS) -D__ASSEMBLY__
  74
  75$(obj)/zImage:  asflags-y := $(SVGA_MODE) $(RAMDISK)
  76$(obj)/bzImage: ccflags-y := -D__BIG_KERNEL__
  77$(obj)/bzImage: asflags-y := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
  78$(obj)/bzImage: BUILDFLAGS   := -b
  79
  80quiet_cmd_image = BUILD   $@
  81cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
  82            $(obj)/vmlinux.bin $(ROOT_DEV) > $@
  83
  84$(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
  85                              $(obj)/vmlinux.bin $(obj)/tools/build FORCE
  86        $(call if_changed,image)
  87        @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
  88
  89OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
  90$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
  91        $(call if_changed,objcopy)
  92
  93SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
  94
  95sed-offsets := -e 's/^00*/0/' \
  96        -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/\#define \2 0x\1/p'
  97
  98quiet_cmd_offsets = OFFSETS $@
  99      cmd_offsets = $(NM) $< | sed -n $(sed-offsets) > $@
 100
 101$(obj)/offsets.h: $(obj)/compressed/vmlinux FORCE
 102        $(call if_changed,offsets)
 103
 104targets += offsets.h
 105
 106AFLAGS_header.o += -I$(obj)
 107$(obj)/header.o: $(obj)/offsets.h
 108
 109LDFLAGS_setup.elf       := -T
 110$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
 111        $(call if_changed,ld)
 112
 113OBJCOPYFLAGS_setup.bin  := -O binary
 114$(obj)/setup.bin: $(obj)/setup.elf FORCE
 115        $(call if_changed,objcopy)
 116
 117$(obj)/compressed/vmlinux: FORCE
 118        $(Q)$(MAKE) $(build)=$(obj)/compressed $@
 119
 120# Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
 121FDARGS =
 122# Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
 123FDINITRD =
 124
 125image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
 126
 127$(obj)/mtools.conf: $(src)/mtools.conf.in
 128        sed -e 's|@OBJ@|$(obj)|g' < $< > $@
 129
 130# This requires write access to /dev/fd0
 131zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
 132        MTOOLSRC=$(obj)/mtools.conf mformat a:                  ; sync
 133        syslinux /dev/fd0                                       ; sync
 134        echo '$(image_cmdline)' | \
 135                MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
 136        if [ -f '$(FDINITRD)' ] ; then \
 137                MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
 138        fi
 139        MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux  ; sync
 140
 141# These require being root or having syslinux 2.02 or higher installed
 142fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
 143        dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
 144        MTOOLSRC=$(obj)/mtools.conf mformat v:                  ; sync
 145        syslinux $(obj)/fdimage                                 ; sync
 146        echo '$(image_cmdline)' | \
 147                MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
 148        if [ -f '$(FDINITRD)' ] ; then \
 149                MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
 150        fi
 151        MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux  ; sync
 152
 153fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
 154        dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
 155        MTOOLSRC=$(obj)/mtools.conf mformat w:                  ; sync
 156        syslinux $(obj)/fdimage                                 ; sync
 157        echo '$(image_cmdline)' | \
 158                MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
 159        if [ -f '$(FDINITRD)' ] ; then \
 160                MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
 161        fi
 162        MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux  ; sync
 163
 164isoimage: $(BOOTIMAGE)
 165        -rm -rf $(obj)/isoimage
 166        mkdir $(obj)/isoimage
 167        for i in lib lib64 share end ; do \
 168                if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
 169                        cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
 170                        break ; \
 171                fi ; \
 172                if [ $$i = end ] ; then exit 1 ; fi ; \
 173        done
 174        cp $(BOOTIMAGE) $(obj)/isoimage/linux
 175        echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
 176        if [ -f '$(FDINITRD)' ] ; then \
 177                cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
 178        fi
 179        mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
 180                -no-emul-boot -boot-load-size 4 -boot-info-table \
 181                $(obj)/isoimage
 182        isohybrid $(obj)/image.iso 2>/dev/null || true
 183        rm -rf $(obj)/isoimage
 184
 185zlilo: $(BOOTIMAGE)
 186        if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
 187        if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
 188        cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
 189        cp System.map $(INSTALL_PATH)/
 190        if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
 191
 192install:
 193        sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
 194