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