Makefile 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. define Image/cmdline/squashfs
  15. block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs init=/etc/preinit
  16. endef
  17. define Image/cmdline/jffs2-64k
  18. block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 init=/etc/preinit
  19. endef
  20. define Image/cmdline/jffs2-128k
  21. block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 init=/etc/preinit
  22. endef
  23. define Image/cmdline/ext2
  24. root=$(ROOTPART) rootfstype=ext2 init=/etc/preinit
  25. endef
  26. define Image/Build/grub
  27. # left here because the image builder doesnt need these
  28. $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
  29. $(CP) \
  30. $(KDIR)/*stage* \
  31. $(KDIR)/root.grub/boot/grub/
  32. $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
  33. sed \
  34. -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
  35. -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
  36. ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
  37. 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)
  38. $(call Image/Build/grub/$(1))
  39. endef
  40. endif
  41. ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
  42. define Image/Prepare/grub
  43. # for the image builder
  44. $(CP) \
  45. $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage1 \
  46. $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage2 \
  47. $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/e2fs_stage1_5 \
  48. $(KDIR)/
  49. endef
  50. endif
  51. define Image/Prepare
  52. $(CP) $(LINUX_DIR)/arch/i386/boot/bzImage $(KDIR)/bzImage
  53. $(call Image/Prepare/grub)
  54. endef
  55. define Image/Build/squashfs
  56. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  57. endef
  58. define Image/Build/iso
  59. $(CP) \
  60. $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage2_eltorito \
  61. $(KDIR)/root.grub/boot/grub/stage2_eltorito
  62. sed -i \
  63. -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
  64. -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
  65. -e 's#(hd0,0)#(cd)#g' \
  66. $(KDIR)/root.grub/boot/grub/menu.lst
  67. $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
  68. mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
  69. -o $(KDIR)/root.iso $(KDIR)/root.grub
  70. endef
  71. define Image/BuildKernel
  72. $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
  73. endef
  74. define Image/Build
  75. $(call Image/Build/grub,$(1))
  76. $(call Image/Build/$(1))
  77. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1).fs
  78. $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
  79. endef
  80. $(eval $(call BuildImage))