Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #
  2. # Copyright (C) 2006 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/image.mk
  9. export PATH=$(TARGET_PATH):/sbin
  10. BOOTOPTS=$(strip $(subst ",, $(CONFIG_X86_GRUB_BOOTOPTS)))
  11. ROOTPART=$(strip $(subst ",, $(CONFIG_X86_GRUB_ROOTPART)))
  12. #"))")) # fix vim's broken syntax highlighting
  13. ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
  14. ifneq ($(HOST_OS),Darwin)
  15. define Image/cmdline/squashfs
  16. block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs init=/etc/preinit
  17. endef
  18. define Image/cmdline/jffs2-64k
  19. block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 init=/etc/preinit
  20. endef
  21. define Image/cmdline/jffs2-128k
  22. block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 init=/etc/preinit
  23. endef
  24. define Image/cmdline/ext2
  25. root=$(ROOTPART) rootfstype=ext2 init=/etc/preinit
  26. endef
  27. define Image/Build/grub
  28. # left here because the image builder doesnt need these
  29. $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
  30. $(CP) \
  31. $(KDIR)/*stage* \
  32. $(KDIR)/root.grub/boot/grub/
  33. $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
  34. sed \
  35. -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
  36. -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
  37. ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
  38. PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) $(KDIR)/root.grub $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
  39. $(call Image/Build/grub/$(1))
  40. endef
  41. define Image/Prepare/grub
  42. # for the image builder
  43. $(CP) \
  44. $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage1 \
  45. $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage2 \
  46. $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/e2fs_stage1_5 \
  47. $(KDIR)/
  48. endef
  49. else
  50. define Image/Build/grub
  51. PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" NOGRUB=1 ./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) "" $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
  52. endef
  53. endif
  54. endif
  55. ifeq ($(CONFIG_X86_VDI_IMAGES),y)
  56. define Image/Build/vdi
  57. # left here because the image builder doesnt need these
  58. ifeq ($(1),ext2)
  59. rm $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi || true
  60. vditool DD $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi $(BIN_DIR)/openwrt-$(BOARD)-ext2.image
  61. endif
  62. endef
  63. endif
  64. define Image/Prepare
  65. $(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
  66. $(call Image/Prepare/grub)
  67. endef
  68. define Image/Build/squashfs
  69. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  70. endef
  71. define Image/Build/iso
  72. $(CP) \
  73. $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage2_eltorito \
  74. $(KDIR)/root.grub/boot/grub/stage2_eltorito
  75. sed -i \
  76. -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
  77. -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
  78. -e 's#(hd0,0)#(cd)#g' \
  79. $(KDIR)/root.grub/boot/grub/menu.lst
  80. $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
  81. mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
  82. -o $(KDIR)/root.iso $(KDIR)/root.grub
  83. endef
  84. define Image/BuildKernel
  85. $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
  86. endef
  87. define Image/Build
  88. $(call Image/Build/$(1))
  89. $(call Image/Build/grub,$(1))
  90. $(call Image/Build/vdi,$(1))
  91. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1).fs
  92. $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
  93. endef
  94. $(eval $(call BuildImage))
  95. ifeq ($(CONFIG_X86_VDI_IMAGES),y)
  96. $(eval $(call RequireCommand,vditool, \
  97. You need vditool to generate VirtualBox images. \
  98. ))
  99. endif