Makefile 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. # Changed by many, many contributors over the years.
  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. ROOT_DEV := CURRENT
  15. # If you want to preset the SVGA mode, uncomment the next line and
  16. # set SVGA_MODE to whatever number you want.
  17. # Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
  18. # The number is the same as you would ordinarily press at bootup.
  19. SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
  20. targets := vmlinux.bin setup.bin setup.elf bzImage
  21. targets += fdimage fdimage144 fdimage288 image.iso mtools.conf
  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. # The link order of the video-*.o modules can matter. In particular,
  28. # video-vga.o *must* be listed first, followed by video-vesa.o.
  29. # Hardware-specific drivers should follow in the order they should be
  30. # probed, and video-bios.o should typically be last.
  31. setup-y += video-vga.o
  32. setup-y += video-vesa.o
  33. setup-y += video-bios.o
  34. targets += $(setup-y)
  35. hostprogs-y := mkcpustr tools/build
  36. HOST_EXTRACFLAGS += $(LINUXINCLUDE)
  37. $(obj)/cpu.o: $(obj)/cpustr.h
  38. quiet_cmd_cpustr = CPUSTR $@
  39. cmd_cpustr = $(obj)/mkcpustr > $@
  40. targets += cpustr.h
  41. $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
  42. $(call if_changed,cpustr)
  43. # ---------------------------------------------------------------------------
  44. # How to compile the 16-bit code. Note we always compile for -march=i386,
  45. # that way we can complain to the user if the CPU is insufficient.
  46. KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
  47. -DDISABLE_BRANCH_PROFILING \
  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)/bzImage: asflags-y := $(SVGA_MODE)
  60. quiet_cmd_image = BUILD $@
  61. cmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \
  62. $(ROOT_DEV) > $@
  63. $(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE
  64. $(call if_changed,image)
  65. @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
  66. OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
  67. $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
  68. $(call if_changed,objcopy)
  69. SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
  70. sed-voffset := -e 's/^\([0-9a-fA-F]*\) . \(_text\|_end\)$$/\#define VO_\2 0x\1/p'
  71. quiet_cmd_voffset = VOFFSET $@
  72. cmd_voffset = $(NM) $< | sed -n $(sed-voffset) > $@
  73. targets += voffset.h
  74. $(obj)/voffset.h: vmlinux FORCE
  75. $(call if_changed,voffset)
  76. sed-zoffset := -e 's/^\([0-9a-fA-F]*\) . \(startup_32\|input_data\|_end\|z_.*\)$$/\#define ZO_\2 0x\1/p'
  77. quiet_cmd_zoffset = ZOFFSET $@
  78. cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
  79. targets += zoffset.h
  80. $(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
  81. $(call if_changed,zoffset)
  82. AFLAGS_header.o += -I$(obj)
  83. $(obj)/header.o: $(obj)/voffset.h $(obj)/zoffset.h
  84. LDFLAGS_setup.elf := -T
  85. $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
  86. $(call if_changed,ld)
  87. OBJCOPYFLAGS_setup.bin := -O binary
  88. $(obj)/setup.bin: $(obj)/setup.elf FORCE
  89. $(call if_changed,objcopy)
  90. $(obj)/compressed/vmlinux: FORCE
  91. $(Q)$(MAKE) $(build)=$(obj)/compressed $@
  92. # Set this if you want to pass append arguments to the
  93. # bzdisk/fdimage/isoimage kernel
  94. FDARGS =
  95. # Set this if you want an initrd included with the
  96. # bzdisk/fdimage/isoimage kernel
  97. FDINITRD =
  98. image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
  99. $(obj)/mtools.conf: $(src)/mtools.conf.in
  100. sed -e 's|@OBJ@|$(obj)|g' < $< > $@
  101. # This requires write access to /dev/fd0
  102. bzdisk: $(obj)/bzImage $(obj)/mtools.conf
  103. MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
  104. syslinux /dev/fd0 ; sync
  105. echo '$(image_cmdline)' | \
  106. MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
  107. if [ -f '$(FDINITRD)' ] ; then \
  108. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
  109. fi
  110. MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage a:linux ; sync
  111. # These require being root or having syslinux 2.02 or higher installed
  112. fdimage fdimage144: $(obj)/bzImage $(obj)/mtools.conf
  113. dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
  114. MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
  115. syslinux $(obj)/fdimage ; sync
  116. echo '$(image_cmdline)' | \
  117. MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
  118. if [ -f '$(FDINITRD)' ] ; then \
  119. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
  120. fi
  121. MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage v:linux ; sync
  122. fdimage288: $(obj)/bzImage $(obj)/mtools.conf
  123. dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
  124. MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
  125. syslinux $(obj)/fdimage ; sync
  126. echo '$(image_cmdline)' | \
  127. MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
  128. if [ -f '$(FDINITRD)' ] ; then \
  129. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
  130. fi
  131. MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage w:linux ; sync
  132. isoimage: $(obj)/bzImage
  133. -rm -rf $(obj)/isoimage
  134. mkdir $(obj)/isoimage
  135. for i in lib lib64 share end ; do \
  136. if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
  137. cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
  138. break ; \
  139. fi ; \
  140. if [ $$i = end ] ; then exit 1 ; fi ; \
  141. done
  142. cp $(obj)/bzImage $(obj)/isoimage/linux
  143. echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
  144. if [ -f '$(FDINITRD)' ] ; then \
  145. cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
  146. fi
  147. mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
  148. -no-emul-boot -boot-load-size 4 -boot-info-table \
  149. $(obj)/isoimage
  150. isohybrid $(obj)/image.iso 2>/dev/null || true
  151. rm -rf $(obj)/isoimage
  152. bzlilo: $(obj)/bzImage
  153. if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
  154. if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
  155. cat $(obj)/bzImage > $(INSTALL_PATH)/vmlinuz
  156. cp System.map $(INSTALL_PATH)/
  157. if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
  158. install:
  159. sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
  160. System.map "$(INSTALL_PATH)"