Makefile 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. subdir- := compressed
  22. setup-y += a20.o cmdline.o copy.o cpu.o cpucheck.o edd.o
  23. setup-y += header.o main.o mca.o memory.o pm.o pmjump.o
  24. setup-y += printf.o string.o tty.o video.o video-mode.o version.o
  25. setup-$(CONFIG_X86_APM_BOOT) += apm.o
  26. # The link order of the video-*.o modules can matter. In particular,
  27. # video-vga.o *must* be listed first, followed by video-vesa.o.
  28. # Hardware-specific drivers should follow in the order they should be
  29. # probed, and video-bios.o should typically be last.
  30. setup-y += video-vga.o
  31. setup-y += video-vesa.o
  32. setup-y += video-bios.o
  33. targets += $(setup-y)
  34. hostprogs-y := mkcpustr tools/build
  35. HOST_EXTRACFLAGS += $(LINUXINCLUDE)
  36. $(obj)/cpu.o: $(obj)/cpustr.h
  37. quiet_cmd_cpustr = CPUSTR $@
  38. cmd_cpustr = $(obj)/mkcpustr > $@
  39. targets += cpustr.h
  40. $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
  41. $(call if_changed,cpustr)
  42. # ---------------------------------------------------------------------------
  43. # How to compile the 16-bit code. Note we always compile for -march=i386,
  44. # that way we can complain to the user if the CPU is insufficient.
  45. KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
  46. -Wall -Wstrict-prototypes \
  47. -march=i386 -mregparm=3 \
  48. -include $(srctree)/$(src)/code16gcc.h \
  49. -fno-strict-aliasing -fomit-frame-pointer \
  50. $(call cc-option, -ffreestanding) \
  51. $(call cc-option, -fno-toplevel-reorder,\
  52. $(call cc-option, -fno-unit-at-a-time)) \
  53. $(call cc-option, -fno-stack-protector) \
  54. $(call cc-option, -mpreferred-stack-boundary=2)
  55. KBUILD_CFLAGS += $(call cc-option,-m32)
  56. KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
  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. $(ROOT_DEV) > $@
  61. $(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE
  62. $(call if_changed,image)
  63. @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
  64. OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
  65. $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
  66. $(call if_changed,objcopy)
  67. SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
  68. sed-offsets := -e 's/^00*/0/' \
  69. -e 's/^\([0-9a-fA-F]*\) . \(input_data\|input_data_end\)$$/\#define \2 0x\1/p'
  70. quiet_cmd_offsets = OFFSETS $@
  71. cmd_offsets = $(NM) $< | sed -n $(sed-offsets) > $@
  72. $(obj)/offsets.h: $(obj)/compressed/vmlinux FORCE
  73. $(call if_changed,offsets)
  74. targets += offsets.h
  75. AFLAGS_header.o += -I$(obj)
  76. $(obj)/header.o: $(obj)/offsets.h
  77. LDFLAGS_setup.elf := -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 zdisk/fdimage/isoimage kernel
  86. FDARGS =
  87. # Set this if you want an initrd included with the zdisk/fdimage/isoimage kernel
  88. FDINITRD =
  89. image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
  90. $(obj)/mtools.conf: $(src)/mtools.conf.in
  91. sed -e 's|@OBJ@|$(obj)|g' < $< > $@
  92. # This requires write access to /dev/fd0
  93. zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
  94. MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
  95. syslinux /dev/fd0 ; sync
  96. echo '$(image_cmdline)' | \
  97. MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
  98. if [ -f '$(FDINITRD)' ] ; then \
  99. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' a:initrd.img ; \
  100. fi
  101. MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
  102. # These require being root or having syslinux 2.02 or higher installed
  103. fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
  104. dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
  105. MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
  106. syslinux $(obj)/fdimage ; sync
  107. echo '$(image_cmdline)' | \
  108. MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
  109. if [ -f '$(FDINITRD)' ] ; then \
  110. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' v:initrd.img ; \
  111. fi
  112. MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
  113. fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
  114. dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
  115. MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
  116. syslinux $(obj)/fdimage ; sync
  117. echo '$(image_cmdline)' | \
  118. MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
  119. if [ -f '$(FDINITRD)' ] ; then \
  120. MTOOLSRC=$(obj)/mtools.conf mcopy '$(FDINITRD)' w:initrd.img ; \
  121. fi
  122. MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
  123. isoimage: $(BOOTIMAGE)
  124. -rm -rf $(obj)/isoimage
  125. mkdir $(obj)/isoimage
  126. for i in lib lib64 share end ; do \
  127. if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
  128. cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
  129. break ; \
  130. fi ; \
  131. if [ $$i = end ] ; then exit 1 ; fi ; \
  132. done
  133. cp $(BOOTIMAGE) $(obj)/isoimage/linux
  134. echo '$(image_cmdline)' > $(obj)/isoimage/isolinux.cfg
  135. if [ -f '$(FDINITRD)' ] ; then \
  136. cp '$(FDINITRD)' $(obj)/isoimage/initrd.img ; \
  137. fi
  138. mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
  139. -no-emul-boot -boot-load-size 4 -boot-info-table \
  140. $(obj)/isoimage
  141. isohybrid $(obj)/image.iso 2>/dev/null || true
  142. rm -rf $(obj)/isoimage
  143. zlilo: $(BOOTIMAGE)
  144. if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
  145. if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
  146. cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
  147. cp System.map $(INSTALL_PATH)/
  148. if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
  149. install:
  150. sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"