Makefile 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. OBJECT_FILES_NON_STANDARD := y
  13. # Kernel does not boot with kcov instrumentation here.
  14. # One of the problems observed was insertion of __sanitizer_cov_trace_pc()
  15. # callback into middle of per-cpu data enabling code. Thus the callback observed
  16. # inconsistent state and crashed. We are interested mostly in syscall coverage,
  17. # so boot code is not interesting anyway.
  18. KCOV_INSTRUMENT := n
  19. # If you want to preset the SVGA mode, uncomment the next line and
  20. # set SVGA_MODE to whatever number you want.
  21. # Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
  22. # The number is the same as you would ordinarily press at bootup.
  23. SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
  24. targets := vmlinux.bin setup.bin setup.elf bzImage
  25. targets += fdimage fdimage144 fdimage288 image.iso mtools.conf
  26. subdir- := compressed
  27. setup-y += a20.o bioscall.o cmdline.o copy.o cpu.o cpuflags.o cpucheck.o
  28. setup-y += early_serial_console.o edd.o header.o main.o memory.o
  29. setup-y += pm.o pmjump.o printf.o regs.o string.o tty.o video.o
  30. setup-y += video-mode.o version.o
  31. setup-$(CONFIG_X86_APM_BOOT) += apm.o
  32. # The link order of the video-*.o modules can matter. In particular,
  33. # video-vga.o *must* be listed first, followed by video-vesa.o.
  34. # Hardware-specific drivers should follow in the order they should be
  35. # probed, and video-bios.o should typically be last.
  36. setup-y += video-vga.o
  37. setup-y += video-vesa.o
  38. setup-y += video-bios.o
  39. targets += $(setup-y)
  40. hostprogs-y := tools/build
  41. hostprogs-$(CONFIG_X86_FEATURE_NAMES) += mkcpustr
  42. HOST_EXTRACFLAGS += -I$(srctree)/tools/include \
  43. -include include/generated/autoconf.h \
  44. -D__EXPORTED_HEADERS__
  45. ifdef CONFIG_X86_FEATURE_NAMES
  46. $(obj)/cpu.o: $(obj)/cpustr.h
  47. quiet_cmd_cpustr = CPUSTR $@
  48. cmd_cpustr = $(obj)/mkcpustr > $@
  49. targets += cpustr.h
  50. $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
  51. $(call if_changed,cpustr)
  52. endif
  53. clean-files += cpustr.h
  54. # ---------------------------------------------------------------------------
  55. KBUILD_CFLAGS := $(USERINCLUDE) $(REALMODE_CFLAGS) -D_SETUP
  56. KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
  57. GCOV_PROFILE := n
  58. UBSAN_SANITIZE := n
  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. $(obj)/zoffset.h $@
  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-zoffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
  71. quiet_cmd_zoffset = ZOFFSET $@
  72. cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
  73. targets += zoffset.h
  74. $(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
  75. $(call if_changed,zoffset)
  76. AFLAGS_header.o += -I$(objtree)/$(obj)
  77. $(obj)/header.o: $(obj)/zoffset.h
  78. LDFLAGS_setup.elf := -T
  79. $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
  80. $(call if_changed,ld)
  81. OBJCOPYFLAGS_setup.bin := -O binary
  82. $(obj)/setup.bin: $(obj)/setup.elf FORCE
  83. $(call if_changed,objcopy)
  84. $(obj)/compressed/vmlinux: FORCE
  85. $(Q)$(MAKE) $(build)=$(obj)/compressed $@
  86. # Set this if you want to pass append arguments to the
  87. # bzdisk/fdimage/isoimage kernel
  88. FDARGS =
  89. # Set this if you want an initrd included with the
  90. # bzdisk/fdimage/isoimage kernel
  91. FDINITRD =
  92. image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
  93. $(obj)/mtools.conf: $(src)/mtools.conf.in
  94. sed -e 's|@OBJ@|$(obj)|g' < $< > $@
  95. # This requires write access to /dev/fd0
  96. bzdisk: $(obj)/bzImage $(obj)/mtools.conf
  97. MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
  98. syslinux /dev/fd0 ; sync
  99. echo '$(image_cmdline)' | \
  100. MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
  101. if [ -f '$(FDINITRD)' ] ; then \
  102. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
  103. fi
  104. MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage a:linux ; sync
  105. # These require being root or having syslinux 2.02 or higher installed
  106. fdimage fdimage144: $(obj)/bzImage $(obj)/mtools.conf
  107. dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
  108. MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
  109. syslinux $(obj)/fdimage ; sync
  110. echo '$(image_cmdline)' | \
  111. MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
  112. if [ -f '$(FDINITRD)' ] ; then \
  113. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
  114. fi
  115. MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage v:linux ; sync
  116. fdimage288: $(obj)/bzImage $(obj)/mtools.conf
  117. dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
  118. MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
  119. syslinux $(obj)/fdimage ; sync
  120. echo '$(image_cmdline)' | \
  121. MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
  122. if [ -f '$(FDINITRD)' ] ; then \
  123. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
  124. fi
  125. MTOOLSRC=$(obj)/mtools.conf mcopy $(obj)/bzImage w:linux ; sync
  126. isoimage: $(obj)/bzImage
  127. -rm -rf $(obj)/isoimage
  128. mkdir $(obj)/isoimage
  129. for i in lib lib64 share end ; do \
  130. if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
  131. cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
  132. if [ -f /usr/$$i/syslinux/ldlinux.c32 ]; then \
  133. cp /usr/$$i/syslinux/ldlinux.c32 $(obj)/isoimage ; \
  134. fi ; \
  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)"