2006-06-27 03:35:46 +03:00
|
|
|
#
|
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
2006-06-21 06:13:25 +03:00
|
|
|
include $(TOPDIR)/rules.mk
|
2006-06-21 05:32:39 +03:00
|
|
|
include $(INCLUDE_DIR)/image.mk
|
2005-07-25 18:40:23 +03:00
|
|
|
|
2006-11-18 23:14:45 +02:00
|
|
|
export PATH=$(TARGET_PATH):/sbin
|
2007-02-28 03:10:10 +02:00
|
|
|
BOOTOPTS=$(strip $(subst ",, $(CONFIG_X86_GRUB_BOOTOPTS)))
|
2006-11-01 00:49:02 +02:00
|
|
|
ROOTPART=$(strip $(subst ",, $(CONFIG_X86_GRUB_ROOTPART)))
|
2007-02-28 03:10:10 +02:00
|
|
|
#"))")) # fix vim's broken syntax highlighting
|
2006-11-01 00:49:02 +02:00
|
|
|
|
|
|
|
|
2006-10-08 18:48:56 +03:00
|
|
|
ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
|
2008-06-28 20:54:44 +03:00
|
|
|
ifneq ($(HOST_OS),Darwin)
|
2007-03-02 03:23:36 +02:00
|
|
|
define Image/cmdline/squashfs
|
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs init=/etc/preinit
|
|
|
|
endef
|
|
|
|
|
2006-10-08 18:48:56 +03:00
|
|
|
define Image/cmdline/jffs2-64k
|
2007-03-05 02:38:37 +02:00
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 init=/etc/preinit
|
2006-10-08 18:48:56 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/cmdline/jffs2-128k
|
2007-03-05 02:38:37 +02:00
|
|
|
block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 init=/etc/preinit
|
2006-10-08 18:48:56 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/cmdline/ext2
|
2007-03-11 02:04:17 +02:00
|
|
|
root=$(ROOTPART) rootfstype=ext2 init=/etc/preinit
|
2006-10-08 18:48:56 +03:00
|
|
|
endef
|
2007-03-02 03:23:36 +02:00
|
|
|
|
2006-10-08 18:48:56 +03:00
|
|
|
define Image/Build/grub
|
2007-02-01 03:07:26 +02:00
|
|
|
# left here because the image builder doesnt need these
|
|
|
|
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
|
2006-10-08 18:48:56 +03:00
|
|
|
$(CP) \
|
2007-01-15 00:59:51 +02:00
|
|
|
$(KDIR)/*stage* \
|
2006-10-08 18:48:56 +03:00
|
|
|
$(KDIR)/root.grub/boot/grub/
|
2007-01-15 00:59:51 +02:00
|
|
|
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
|
2006-10-08 18:48:56 +03:00
|
|
|
sed \
|
2007-02-28 03:10:10 +02:00
|
|
|
-e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
|
2006-10-08 18:48:56 +03:00
|
|
|
-e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
|
2007-10-09 19:57:12 +03:00
|
|
|
./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
|
2007-11-11 01:08:11 +02:00
|
|
|
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)
|
2007-03-02 03:23:36 +02:00
|
|
|
$(call Image/Build/grub/$(1))
|
2006-10-08 18:48:56 +03:00
|
|
|
endef
|
|
|
|
|
2007-02-01 03:07:26 +02:00
|
|
|
define Image/Prepare/grub
|
2007-01-15 00:59:51 +02:00
|
|
|
# for the image builder
|
|
|
|
$(CP) \
|
2007-08-07 03:04:25 +03:00
|
|
|
$(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage1 \
|
|
|
|
$(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage2 \
|
|
|
|
$(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/e2fs_stage1_5 \
|
2007-01-15 00:59:51 +02:00
|
|
|
$(KDIR)/
|
2007-02-01 03:07:26 +02:00
|
|
|
endef
|
2008-06-28 20:54:44 +03:00
|
|
|
else
|
|
|
|
define Image/Build/grub
|
|
|
|
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)
|
|
|
|
endef
|
|
|
|
endif
|
2007-02-01 03:07:26 +02:00
|
|
|
endif
|
|
|
|
|
2008-05-30 19:50:37 +03:00
|
|
|
ifeq ($(CONFIG_X86_VDI_IMAGES),y)
|
|
|
|
define Image/Build/vdi
|
|
|
|
# left here because the image builder doesnt need these
|
|
|
|
ifeq ($(1),ext2)
|
|
|
|
rm $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi || true
|
|
|
|
vditool DD $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi $(BIN_DIR)/openwrt-$(BOARD)-ext2.image
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2008-11-09 19:39:09 +02:00
|
|
|
ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
|
|
|
|
define Image/Build/vmdk
|
|
|
|
# left here because the image builder doesnt need these
|
|
|
|
ifeq ($(1),ext2)
|
|
|
|
rm $(BIN_DIR)/openwrt-$(BOARD)-ext2.vmdk || true
|
|
|
|
qemu-img convert -f raw $(BIN_DIR)/openwrt-$(BOARD)-ext2.image \
|
|
|
|
-O vmdk $(BIN_DIR)/openwrt-$(BOARD)-ext2.vmdk
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
endif
|
2008-05-30 19:50:37 +03:00
|
|
|
|
2007-02-01 03:07:26 +02:00
|
|
|
define Image/Prepare
|
2008-03-17 14:37:52 +02:00
|
|
|
$(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
|
2007-02-01 03:07:26 +02:00
|
|
|
$(call Image/Prepare/grub)
|
2007-01-10 23:52:28 +02:00
|
|
|
endef
|
2007-03-02 03:23:36 +02:00
|
|
|
|
|
|
|
define Image/Build/squashfs
|
|
|
|
$(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
|
|
|
|
endef
|
2007-01-10 23:52:28 +02:00
|
|
|
|
2007-10-08 21:53:19 +03:00
|
|
|
define Image/Build/iso
|
|
|
|
$(CP) \
|
|
|
|
$(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage2_eltorito \
|
|
|
|
$(KDIR)/root.grub/boot/grub/stage2_eltorito
|
|
|
|
sed -i \
|
|
|
|
-e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
|
|
|
|
-e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
|
|
|
|
-e 's#(hd0,0)#(cd)#g' \
|
|
|
|
$(KDIR)/root.grub/boot/grub/menu.lst
|
|
|
|
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
|
|
|
|
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
|
|
|
|
-o $(KDIR)/root.iso $(KDIR)/root.grub
|
|
|
|
endef
|
|
|
|
|
2007-03-02 19:12:23 +02:00
|
|
|
define Image/BuildKernel
|
2007-11-11 01:08:11 +02:00
|
|
|
$(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
|
2007-03-02 19:12:23 +02:00
|
|
|
endef
|
|
|
|
|
2006-06-05 00:57:59 +03:00
|
|
|
define Image/Build
|
2008-06-05 00:55:25 +03:00
|
|
|
$(call Image/Build/$(1))
|
2006-10-08 18:48:56 +03:00
|
|
|
$(call Image/Build/grub,$(1))
|
2008-05-30 19:50:37 +03:00
|
|
|
$(call Image/Build/vdi,$(1))
|
2008-11-09 19:39:09 +02:00
|
|
|
$(call Image/Build/vmdk,$(1))
|
2007-11-11 01:08:11 +02:00
|
|
|
$(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1).fs
|
|
|
|
$(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
|
2006-06-05 00:57:59 +03:00
|
|
|
endef
|
2005-07-25 18:40:23 +03:00
|
|
|
|
2006-06-05 00:57:59 +03:00
|
|
|
$(eval $(call BuildImage))
|
2007-10-08 21:53:19 +03:00
|
|
|
|
2008-05-30 19:50:37 +03:00
|
|
|
ifeq ($(CONFIG_X86_VDI_IMAGES),y)
|
|
|
|
$(eval $(call RequireCommand,vditool, \
|
|
|
|
You need vditool to generate VirtualBox images. \
|
|
|
|
))
|
|
|
|
endif
|
|
|
|
|
2008-11-09 19:39:09 +02:00
|
|
|
ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
|
|
|
|
$(eval $(call RequireCommand,qemu-img, \
|
|
|
|
You need qemu-img to generate VMware images. \
|
|
|
|
))
|
|
|
|
endif
|