Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 hdimage
  18. subdir- := compressed
  19. setup-y += a20.o bioscall.o cmdline.o copy.o cpu.o cpuflags.o cpucheck.o
  20. setup-y += early_serial_console.o edd.o header.o main.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 := tools/build
  33. hostprogs += mkcpustr
  34. HOST_EXTRACFLAGS += -I$(srctree)/tools/include \
  35. -include include/generated/autoconf.h \
  36. -D__EXPORTED_HEADERS__
  37. $(obj)/cpu.o: $(obj)/cpustr.h
  38. quiet_cmd_cpustr = CPUSTR $@
  39. cmd_cpustr = $(obj)/mkcpustr > $@
  40. $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
  41. $(call if_changed,cpustr)
  42. targets += cpustr.h
  43. # ---------------------------------------------------------------------------
  44. KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP
  45. KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
  46. KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
  47. KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
  48. KBUILD_CFLAGS += $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
  49. $(obj)/bzImage: asflags-y := $(SVGA_MODE)
  50. quiet_cmd_image = BUILD $@
  51. silent_redirect_image = >/dev/null
  52. cmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \
  53. $(obj)/zoffset.h $@ $($(quiet)redirect_image)
  54. $(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE
  55. $(call if_changed,image)
  56. @$(kecho) 'Kernel: $@ is ready' ' (#'$(or $(KBUILD_BUILD_VERSION),`cat .version`)')'
  57. OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
  58. $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
  59. $(call if_changed,objcopy)
  60. SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
  61. sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [a-zA-Z] \(startup_32\|efi.._stub_entry\|efi\(32\)\?_pe_entry\|input_data\|kernel_info\|_end\|_ehead\|_text\|_e\?data\|z_.*\)$$/\#define ZO_\2 0x\1/p'
  62. quiet_cmd_zoffset = ZOFFSET $@
  63. cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
  64. targets += zoffset.h
  65. $(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
  66. $(call if_changed,zoffset)
  67. AFLAGS_header.o += -I$(objtree)/$(obj)
  68. $(obj)/header.o: $(obj)/zoffset.h
  69. LDFLAGS_setup.elf := -m elf_i386 -z noexecstack -T
  70. $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
  71. $(call if_changed,ld)
  72. OBJCOPYFLAGS_setup.bin := -O binary
  73. $(obj)/setup.bin: $(obj)/setup.elf FORCE
  74. $(call if_changed,objcopy)
  75. $(obj)/compressed/vmlinux: FORCE
  76. $(Q)$(MAKE) $(build)=$(obj)/compressed $@
  77. # Set this if you want to pass append arguments to the
  78. # bzdisk/fdimage/hdimage/isoimage kernel
  79. FDARGS =
  80. # Set this if you want one or more initrds included in the image
  81. FDINITRD =
  82. imgdeps = $(obj)/bzImage $(obj)/mtools.conf $(src)/genimage.sh
  83. $(obj)/mtools.conf: $(src)/mtools.conf.in
  84. sed -e 's|@OBJ@|$(obj)|g' < $< > $@
  85. targets += mtools.conf
  86. # genimage.sh requires bash, but it also has a bunch of other
  87. # external dependencies.
  88. quiet_cmd_genimage = GENIMAGE $3
  89. cmd_genimage = $(BASH) $(src)/genimage.sh $2 $3 $(obj)/bzImage \
  90. $(obj)/mtools.conf '$(FDARGS)' $(FDINITRD)
  91. PHONY += bzdisk fdimage fdimage144 fdimage288 hdimage isoimage
  92. # This requires write access to /dev/fd0
  93. # All images require syslinux to be installed; hdimage also requires
  94. # EDK2/OVMF if the kernel is compiled with the EFI stub.
  95. bzdisk: $(imgdeps)
  96. $(call cmd,genimage,bzdisk,/dev/fd0)
  97. fdimage fdimage144: $(imgdeps)
  98. $(call cmd,genimage,fdimage144,$(obj)/fdimage)
  99. @$(kecho) 'Kernel: $(obj)/fdimage is ready'
  100. fdimage288: $(imgdeps)
  101. $(call cmd,genimage,fdimage288,$(obj)/fdimage)
  102. @$(kecho) 'Kernel: $(obj)/fdimage is ready'
  103. hdimage: $(imgdeps)
  104. $(call cmd,genimage,hdimage,$(obj)/hdimage)
  105. @$(kecho) 'Kernel: $(obj)/hdimage is ready'
  106. isoimage: $(imgdeps)
  107. $(call cmd,genimage,isoimage,$(obj)/image.iso)
  108. @$(kecho) 'Kernel: $(obj)/image.iso is ready'