Makefile 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. # 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 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 video-mode.o version.o
  26. setup-$(CONFIG_X86_APM_BOOT) += apm.o
  27. setup-$(CONFIG_X86_VOYAGER) += voyager.o
  28. # The link order of the video-*.o modules can matter. In particular,
  29. # video-vga.o *must* be listed first, followed by video-vesa.o.
  30. # Hardware-specific drivers should follow in the order they should be
  31. # probed, and video-bios.o should typically be last.
  32. setup-y += video-vga.o
  33. setup-y += video-vesa.o
  34. setup-y += video-bios.o
  35. targets += $(setup-y)
  36. hostprogs-y := mkcpustr tools/build
  37. HOST_EXTRACFLAGS += $(LINUXINCLUDE)
  38. $(obj)/cpu.o: $(obj)/cpustr.h
  39. quiet_cmd_cpustr = CPUSTR $@
  40. cmd_cpustr = $(obj)/mkcpustr > $@
  41. targets += cpustr.h
  42. $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
  43. $(call if_changed,cpustr)
  44. # ---------------------------------------------------------------------------
  45. # How to compile the 16-bit code. Note we always compile for -march=i386,
  46. # that way we can complain to the user if the CPU is insufficient.
  47. KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
  48. -Wall -Wstrict-prototypes \
  49. -march=i386 -mregparm=3 \
  50. -include $(srctree)/$(src)/code16gcc.h \
  51. -fno-strict-aliasing -fomit-frame-pointer \
  52. $(call cc-option, -ffreestanding) \
  53. $(call cc-option, -fno-toplevel-reorder,\
  54. $(call cc-option, -fno-unit-at-a-time)) \
  55. $(call cc-option, -fno-stack-protector) \
  56. $(call cc-option, -mpreferred-stack-boundary=2)
  57. KBUILD_CFLAGS += $(call cc-option,-m32)
  58. KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
  59. $(obj)/zImage: asflags-y := $(SVGA_MODE) $(RAMDISK)
  60. $(obj)/bzImage: ccflags-y := -D__BIG_KERNEL__
  61. $(obj)/bzImage: asflags-y := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
  62. $(obj)/bzImage: BUILDFLAGS := -b
  63. quiet_cmd_image = BUILD $@
  64. cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
  65. $(obj)/vmlinux.bin $(ROOT_DEV) > $@
  66. $(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
  67. $(obj)/vmlinux.bin $(obj)/tools/build FORCE
  68. $(call if_changed,image)
  69. @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
  70. OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
  71. $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
  72. $(call if_changed,objcopy)
  73. SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
  74. sed-offsets := -e 's/^00*/0/' \
  75. -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/\#define \2 0x\1/p'
  76. quiet_cmd_offsets = OFFSETS $@
  77. cmd_offsets = $(NM) $< | sed -n $(sed-offsets) > $@
  78. $(obj)/offsets.h: $(obj)/compressed/vmlinux FORCE
  79. $(call if_changed,offsets)
  80. targets += offsets.h
  81. AFLAGS_header.o += -I$(obj)
  82. $(obj)/header.o: $(obj)/offsets.h
  83. LDFLAGS_setup.elf := -T
  84. $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
  85. $(call if_changed,ld)
  86. OBJCOPYFLAGS_setup.bin := -O binary
  87. $(obj)/setup.bin: $(obj)/setup.elf FORCE
  88. $(call if_changed,objcopy)
  89. $(obj)/compressed/vmlinux: FORCE
  90. $(Q)$(MAKE) $(build)=$(obj)/compressed $@
  91. # Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
  92. FDARGS =
  93. # Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
  94. FDINITRD =
  95. image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
  96. $(obj)/mtools.conf: $(src)/mtools.conf.in
  97. sed -e 's|@OBJ@|$(obj)|g' < $< > $@
  98. # This requires write access to /dev/fd0
  99. zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
  100. MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
  101. syslinux /dev/fd0 ; sync
  102. echo '$(image_cmdline)' | \
  103. MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
  104. if [ -f '$(FDINITRD)' ] ; then \
  105. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
  106. fi
  107. MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
  108. # These require being root or having syslinux 2.02 or higher installed
  109. fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
  110. dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
  111. MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
  112. syslinux $(obj)/fdimage ; sync
  113. echo '$(image_cmdline)' | \
  114. MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
  115. if [ -f '$(FDINITRD)' ] ; then \
  116. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
  117. fi
  118. MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
  119. fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
  120. dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
  121. MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
  122. syslinux $(obj)/fdimage ; sync
  123. echo '$(image_cmdline)' | \
  124. MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
  125. if [ -f '$(FDINITRD)' ] ; then \
  126. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
  127. fi
  128. MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
  129. isoimage: $(BOOTIMAGE)
  130. -rm -rf $(obj)/isoimage
  131. mkdir $(obj)/isoimage
  132. for i in lib lib64 share end ; do \
  133. if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
  134. cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
  135. break ; \
  136. fi ; \
  137. if [ $$i = end ] ; then exit 1 ; fi ; \
  138. done
  139. cp $(BOOTIMAGE) $(obj)/isoimage/linux
  140. echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
  141. if [ -f '$(FDINITRD)' ] ; then \
  142. cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
  143. fi
  144. mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
  145. -no-emul-boot -boot-load-size 4 -boot-info-table \
  146. $(obj)/isoimage
  147. isohybrid $(obj)/image.iso 2>/dev/null || true
  148. rm -rf $(obj)/isoimage
  149. zlilo: $(BOOTIMAGE)
  150. if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
  151. if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
  152. cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
  153. cp System.map $(INSTALL_PATH)/
  154. if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
  155. install:
  156. sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"