Makefile 6.7 KB

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