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. # Changed by many, many contributors over the years.
  10. #
  11. # If you want to preset the SVGA mode, uncomment the next line and
  12. # set SVGA_MODE to whatever number you want.
  13. # Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
  14. # The number is the same as you would ordinarily press at bootup.
  15. SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
  16. targets := vmlinux.bin setup.bin setup.elf bzImage
  17. targets += fdimage fdimage144 fdimage288 image.iso mtools.conf
  18. subdir- := compressed
  19. setup-y += a20.o bioscall.o cmdline.o copy.o cpu.o cpucheck.o
  20. setup-y += early_serial_console.o edd.o header.o main.o mca.o memory.o
  21. setup-y += pm.o pmjump.o printf.o regs.o string.o tty.o video.o
  22. setup-y += video-mode.o version.o
  23. setup-$(CONFIG_X86_APM_BOOT) += apm.o
  24. # The link order of the video-*.o modules can matter. In particular,
  25. # video-vga.o *must* be listed first, followed by video-vesa.o.
  26. # Hardware-specific drivers should follow in the order they should be
  27. # probed, and video-bios.o should typically be last.
  28. setup-y += video-vga.o
  29. setup-y += video-vesa.o
  30. setup-y += video-bios.o
  31. targets += $(setup-y)
  32. hostprogs-y := mkcpustr tools/build
  33. HOST_EXTRACFLAGS += $(LINUXINCLUDE)
  34. $(obj)/cpu.o: $(obj)/cpustr.h
  35. quiet_cmd_cpustr = CPUSTR $@
  36. cmd_cpustr = $(obj)/mkcpustr > $@
  37. targets += cpustr.h
  38. $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
  39. $(call if_changed,cpustr)
  40. # ---------------------------------------------------------------------------
  41. # How to compile the 16-bit code. Note we always compile for -march=i386,
  42. # that way we can complain to the user if the CPU is insufficient.
  43. KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
  44. -DDISABLE_BRANCH_PROFILING \
  45. -Wall -Wstrict-prototypes \
  46. -march=i386 -mregparm=3 \
  47. -include $(srctree)/$(src)/code16gcc.h \
  48. -fno-strict-aliasing -fomit-frame-pointer \
  49. $(call cc-option, -ffreestanding) \
  50. $(call cc-option, -fno-toplevel-reorder,\
  51. $(call cc-option, -fno-unit-at-a-time)) \
  52. $(call cc-option, -fno-stack-protector) \
  53. $(call cc-option, -mpreferred-stack-boundary=2)
  54. KBUILD_CFLAGS += $(call cc-option, -m32)
  55. KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
  56. GCOV_PROFILE := n
  57. $(obj)/bzImage: asflags-y := $(SVGA_MODE)
  58. quiet_cmd_image = BUILD $@
  59. cmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin > $@
  60. $(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE
  61. $(call if_changed,image)
  62. @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
  63. OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
  64. $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
  65. $(call if_changed,objcopy)
  66. SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
  67. sed-voffset := -e 's/^\([0-9a-fA-F]*\) . \(_text\|_end\)$$/\#define VO_\2 0x\1/p'
  68. quiet_cmd_voffset = VOFFSET $@
  69. cmd_voffset = $(NM) $< | sed -n $(sed-voffset) > $@
  70. targets += voffset.h
  71. $(obj)/voffset.h: vmlinux FORCE
  72. $(call if_changed,voffset)
  73. sed-zoffset := -e 's/^\([0-9a-fA-F]*\) . \(startup_32\|input_data\|_end\|z_.*\)$$/\#define ZO_\2 0x\1/p'
  74. quiet_cmd_zoffset = ZOFFSET $@
  75. cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
  76. targets += zoffset.h
  77. $(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
  78. $(call if_changed,zoffset)
  79. AFLAGS_header.o += -I$(obj)
  80. $(obj)/header.o: $(obj)/voffset.h $(obj)/zoffset.h
  81. LDFLAGS_setup.elf := -T
  82. $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
  83. $(call if_changed,ld)
  84. OBJCOPYFLAGS_setup.bin := -O binary
  85. $(obj)/setup.bin: $(obj)/setup.elf FORCE
  86. $(call if_changed,objcopy)
  87. $(obj)/compressed/vmlinux: FORCE
  88. $(Q)$(MAKE) $(build)=$(obj)/compressed $@
  89. # Set this if you want to pass append arguments to the
  90. # bzdisk/fdimage/isoimage kernel
  91. FDARGS =
  92. # Set this if you want an initrd included with the
  93. # bzdisk/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. bzdisk: $(obj)/bzImage $(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 $(obj)/bzImage a:linux ; sync
  108. # These require being root or having syslinux 2.02 or higher installed
  109. fdimage fdimage144: $(obj)/bzImage $(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 $(obj)/bzImage v:linux ; sync
  119. fdimage288: $(obj)/bzImage $(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 $(obj)/bzImage w:linux ; sync
  129. isoimage: $(obj)/bzImage
  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 $(obj)/bzImage $(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. bzlilo: $(obj)/bzImage
  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 $(obj)/bzImage > $(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) $(obj)/bzImage \
  157. System.map "$(INSTALL_PATH)"