Makefile 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #
  2. # arch/i386/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. # ROOT_DEV specifies the default root-device when making the image.
  11. # This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case
  12. # the default of FLOPPY is used by 'build'.
  13. ROOT_DEV := CURRENT
  14. # If you want to preset the SVGA mode, uncomment the next line and
  15. # set SVGA_MODE to whatever number you want.
  16. # Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
  17. # The number is the same as you would ordinarily press at bootup.
  18. SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
  19. # If you want the RAM disk device, define this to be the size in blocks.
  20. #RAMDISK := -DRAMDISK=512
  21. targets := vmlinux.bin setup.bin setup.elf zImage bzImage
  22. subdir- := compressed
  23. setup-y += a20.o apm.o cmdline.o copy.o cpu.o cpucheck.o edd.o
  24. setup-y += header.o main.o mca.o memory.o pm.o pmjump.o
  25. setup-y += printf.o string.o tty.o video.o version.o voyager.o
  26. # The link order of the video-*.o modules can matter. In particular,
  27. # video-vga.o *must* be listed first, followed by video-vesa.o.
  28. # Hardware-specific drivers should follow in the order they should be
  29. # probed, and video-bios.o should typically be last.
  30. setup-y += video-vga.o
  31. setup-y += video-vesa.o
  32. setup-y += video-bios.o
  33. targets += $(setup-y)
  34. hostprogs-y := tools/build
  35. HOSTCFLAGS_build.o := $(LINUXINCLUDE)
  36. # ---------------------------------------------------------------------------
  37. # How to compile the 16-bit code. Note we always compile for -march=i386,
  38. # that way we can complain to the user if the CPU is insufficient.
  39. cflags-i386 :=
  40. cflags-x86_64 := -m32
  41. CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
  42. $(cflags-$(ARCH)) \
  43. -Wall -Wstrict-prototypes \
  44. -march=i386 -mregparm=3 \
  45. -include $(srctree)/$(src)/code16gcc.h \
  46. -fno-strict-aliasing -fomit-frame-pointer \
  47. $(call cc-option, -ffreestanding) \
  48. $(call cc-option, -fno-toplevel-reorder,\
  49. $(call cc-option, -fno-unit-at-a-time)) \
  50. $(call cc-option, -fno-stack-protector) \
  51. $(call cc-option, -mpreferred-stack-boundary=2)
  52. AFLAGS := $(CFLAGS) -D__ASSEMBLY__
  53. $(obj)/zImage: IMAGE_OFFSET := 0x1000
  54. $(obj)/zImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK)
  55. $(obj)/bzImage: IMAGE_OFFSET := 0x100000
  56. $(obj)/bzImage: EXTRA_CFLAGS := -D__BIG_KERNEL__
  57. $(obj)/bzImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
  58. $(obj)/bzImage: BUILDFLAGS := -b
  59. quiet_cmd_image = BUILD $@
  60. cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
  61. $(obj)/vmlinux.bin $(ROOT_DEV) > $@
  62. $(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
  63. $(obj)/vmlinux.bin $(obj)/tools/build FORCE
  64. $(call if_changed,image)
  65. @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
  66. $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
  67. $(call if_changed,objcopy)
  68. SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
  69. LDFLAGS_setup.elf := -T
  70. $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
  71. $(call if_changed,ld)
  72. OBJCOPYFLAGS_setup.bin := -O binary
  73. $(obj)/setup.bin: $(obj)/setup.elf FORCE
  74. $(call if_changed,objcopy)
  75. $(obj)/compressed/vmlinux: FORCE
  76. $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
  77. # Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
  78. FDARGS =
  79. # Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
  80. FDINITRD =
  81. image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
  82. $(obj)/mtools.conf: $(src)/mtools.conf.in
  83. sed -e 's|@OBJ@|$(obj)|g' < $< > $@
  84. # This requires write access to /dev/fd0
  85. zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
  86. MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
  87. syslinux /dev/fd0 ; sync
  88. echo '$(image_cmdline)' | \
  89. MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
  90. if [ -f '$(FDINITRD)' ] ; then \
  91. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
  92. fi
  93. MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
  94. # These require being root or having syslinux 2.02 or higher installed
  95. fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
  96. dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
  97. MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
  98. syslinux $(obj)/fdimage ; sync
  99. echo '$(image_cmdline)' | \
  100. MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
  101. if [ -f '$(FDINITRD)' ] ; then \
  102. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
  103. fi
  104. MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
  105. fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
  106. dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
  107. MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
  108. syslinux $(obj)/fdimage ; sync
  109. echo '$(image_cmdline)' | \
  110. MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
  111. if [ -f '$(FDINITRD)' ] ; then \
  112. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
  113. fi
  114. MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
  115. isoimage: $(BOOTIMAGE)
  116. -rm -rf $(obj)/isoimage
  117. mkdir $(obj)/isoimage
  118. for i in lib lib64 share end ; do \
  119. if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
  120. cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
  121. break ; \
  122. fi ; \
  123. if [ $$i = end ] ; then exit 1 ; fi ; \
  124. done
  125. cp $(BOOTIMAGE) $(obj)/isoimage/linux
  126. echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
  127. if [ -f '$(FDINITRD)' ] ; then \
  128. cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
  129. fi
  130. mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
  131. -no-emul-boot -boot-load-size 4 -boot-info-table \
  132. $(obj)/isoimage
  133. rm -rf $(obj)/isoimage
  134. zlilo: $(BOOTIMAGE)
  135. if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
  136. if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
  137. cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
  138. cp System.map $(INSTALL_PATH)/
  139. if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
  140. install:
  141. sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"