2006-06-27 00:35:46 +00:00
|
|
|
#
|
2010-02-12 19:04:12 +00:00
|
|
|
# Copyright (C) 2006-2010 OpenWrt.org
|
2006-06-27 00:35:46 +00:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
2006-06-21 03:13:25 +00:00
|
|
|
include $(TOPDIR)/rules.mk
|
2006-06-21 02:32:39 +00:00
|
|
|
include $(INCLUDE_DIR)/image.mk
|
2005-07-25 15:40:23 +00:00
|
|
|
|
2006-11-18 21:14:45 +00:00
|
|
|
export PATH=$(TARGET_PATH):/sbin
|
2009-11-03 01:02:39 +00:00
|
|
|
|
2009-11-17 19:49:25 +00:00
|
|
|
ifneq ($(CONFIG_TARGET_x86_olpc),y)
|
2007-02-28 01:10:10 +00:00
|
|
|
BOOTOPTS=$(strip $(subst ",, $(CONFIG_X86_GRUB_BOOTOPTS)))
|
2006-10-31 22:49:02 +00:00
|
|
|
ROOTPART=$(strip $(subst ",, $(CONFIG_X86_GRUB_ROOTPART)))
|
2007-02-28 01:10:10 +00:00
|
|
|
#"))")) # fix vim's broken syntax highlighting
|
2009-11-03 01:02:39 +00:00
|
|
|
endif
|
2006-10-31 22:49:02 +00:00
|
|
|
|
2009-11-03 01:02:39 +00:00
|
|
|
ifeq ($(CONFIG_TARGET_x86_olpc),y)
|
|
|
|
ROOTPART=$(strip $(subst ",, $(CONFIG_OLPC_BOOTSCRIPT_ROOTPART)))
|
|
|
|
endif
|
|
|
|
#"))")) # fix vim's broken syntax highlighting
|
2006-10-31 22:49:02 +00:00
|
|
|
|
2010-02-17 00:59:41 +00:00
|
|
|
GRUB_TERMINALS =
|
|
|
|
GRUB_SERIAL_CONFIG =
|
|
|
|
GRUB_TERMINAL_CONFIG =
|
|
|
|
GRUB_CONSOLE_CMDLINE =
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_X86_GRUB_CONSOLE),y)
|
|
|
|
GRUB_CONSOLE_CMDLINE += console=tty0
|
|
|
|
GRUB_TERMINALS += console
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(CONFIG_X86_GRUB_SERIAL),)
|
|
|
|
GRUB_CONSOLE_CMDLINE += console=$(strip $(subst ",, $(CONFIG_X86_GRUB_SERIAL))),$(CONFIG_X86_GRUB_BAUDRATE)n8
|
|
|
|
GRUB_SERIAL_CONFIG = serial --unit=0 --speed=$(CONFIG_X86_GRUB_BAUDRATE) --word=8 --parity=no --stop=1
|
|
|
|
GRUB_TERMINALS += serial
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(GRUB_TERMINALS),)
|
|
|
|
GRUB_TERMINAL_CONFIG = terminal --timeout=2 $(GRUB_TERMINALS)
|
|
|
|
endif
|
2010-02-12 19:04:12 +00:00
|
|
|
|
|
|
|
|
2006-10-08 15:48:56 +00:00
|
|
|
ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
|
2008-06-28 17:54:44 +00:00
|
|
|
ifneq ($(HOST_OS),Darwin)
|
2007-03-02 01:23:36 +00:00
|
|
|
define Image/cmdline/squashfs
|
2009-12-06 09:12:34 +00:00
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootwait
|
2007-03-02 01:23:36 +00:00
|
|
|
endef
|
|
|
|
|
2006-10-08 15:48:56 +00:00
|
|
|
define Image/cmdline/jffs2-64k
|
2009-12-06 09:12:34 +00:00
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
|
2006-10-08 15:48:56 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/cmdline/jffs2-128k
|
2009-12-06 09:12:34 +00:00
|
|
|
block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
|
2006-10-08 15:48:56 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/cmdline/ext2
|
2009-12-06 09:12:34 +00:00
|
|
|
root=$(ROOTPART) rootfstype=ext2 rootwait
|
2006-10-08 15:48:56 +00:00
|
|
|
endef
|
2007-03-02 01:23:36 +00:00
|
|
|
|
2006-10-08 15:48:56 +00:00
|
|
|
define Image/Build/grub
|
2007-02-01 01:07:26 +00:00
|
|
|
# left here because the image builder doesnt need these
|
|
|
|
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
|
2006-10-08 15:48:56 +00:00
|
|
|
$(CP) \
|
2007-01-14 22:59:51 +00:00
|
|
|
$(KDIR)/*stage* \
|
2006-10-08 15:48:56 +00:00
|
|
|
$(KDIR)/root.grub/boot/grub/
|
2007-01-14 22:59:51 +00:00
|
|
|
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
|
2006-10-08 15:48:56 +00:00
|
|
|
sed \
|
2010-02-17 00:59:41 +00:00
|
|
|
-e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
|
|
|
|
-e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
|
|
|
|
-e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
|
2007-10-09 16:57:12 +00:00
|
|
|
./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
|
2009-11-03 01:02:39 +00:00
|
|
|
PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_x86.sh $(BIN_DIR)/openwrt-$(BOARD)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) $(KDIR)/root.grub $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
|
2007-03-02 01:23:36 +00:00
|
|
|
$(call Image/Build/grub/$(1))
|
2006-10-08 15:48:56 +00:00
|
|
|
endef
|
|
|
|
|
2007-02-01 01:07:26 +00:00
|
|
|
define Image/Prepare/grub
|
2007-01-14 22:59:51 +00:00
|
|
|
# for the image builder
|
|
|
|
$(CP) \
|
2009-01-10 23:12:21 +00:00
|
|
|
$(STAGING_DIR_HOST)/usr/lib/grub/i386-*/stage1 \
|
|
|
|
$(STAGING_DIR_HOST)/usr/lib/grub/i386-*/stage2 \
|
|
|
|
$(STAGING_DIR_HOST)/usr/lib/grub/i386-*/e2fs_stage1_5 \
|
2007-01-14 22:59:51 +00:00
|
|
|
$(KDIR)/
|
2007-02-01 01:07:26 +00:00
|
|
|
endef
|
2008-06-28 17:54:44 +00:00
|
|
|
else
|
|
|
|
define Image/Build/grub
|
2009-11-03 01:02:39 +00:00
|
|
|
PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" NOGRUB=1 ./gen_image_x86.sh $(BIN_DIR)/openwrt-$(BOARD)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) "" $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
|
2008-06-28 17:54:44 +00:00
|
|
|
endef
|
|
|
|
endif
|
2007-02-01 01:07:26 +00:00
|
|
|
endif
|
|
|
|
|
2008-05-30 16:50:37 +00: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
|
2009-01-02 14:35:18 +00:00
|
|
|
VBoxManage convertfromraw -format VDI $(BIN_DIR)/openwrt-$(BOARD)-ext2.image $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi
|
2008-05-30 16:50:37 +00:00
|
|
|
endif
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2008-11-09 17:39:09 +00: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 16:50:37 +00:00
|
|
|
|
2009-11-03 01:02:39 +00:00
|
|
|
ROOTDELAY=10
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES),y)
|
|
|
|
define Image/cmdline/squashfs
|
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootdelay=$(ROOTDELAY)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/cmdline/jffs2-64k
|
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootdelay=$(ROOTDELAY)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/cmdline/jffs2-128k
|
|
|
|
block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootdelay=$(ROOTDELAY)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/cmdline/ext2
|
|
|
|
root=$(ROOTPART) rootfstype=ext2 rootwait
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/Build/bootscript
|
|
|
|
# left here because the image builder doesnt need these
|
|
|
|
$(INSTALL_DIR) $(KDIR)/root.bootscript/boot
|
|
|
|
$(CP) $(KDIR)/bzImage $(KDIR)/root.bootscript/boot/vmlinuz
|
|
|
|
sed -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
|
|
|
|
./olpc.fth > $(KDIR)/root.bootscript/boot/olpc.fth
|
|
|
|
PADDING="$(CONFIG_OLPC_BOOTSCRIPT_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_olpc.sh $(BIN_DIR)/openwrt-$(BOARD)-$(1).image $(CONFIG_OLPC_BOOTSCRIPT_KERNELPART) $(KDIR)/root.bootscript $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2007-02-01 01:07:26 +00:00
|
|
|
define Image/Prepare
|
2008-03-17 12:37:52 +00:00
|
|
|
$(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
|
2009-11-03 01:02:39 +00:00
|
|
|
ifeq ($(CONFIG_TARGET_x86_olpc),y)
|
|
|
|
$(call Image/Prepare/bootscript)
|
2009-11-17 19:49:25 +00:00
|
|
|
else
|
|
|
|
$(call Image/Prepare/grub)
|
2009-11-03 01:02:39 +00:00
|
|
|
endif
|
2007-01-10 21:52:28 +00:00
|
|
|
endef
|
2009-11-17 19:49:25 +00:00
|
|
|
|
2007-03-02 01:23:36 +00:00
|
|
|
define Image/Build/squashfs
|
|
|
|
$(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
|
|
|
|
endef
|
2007-01-10 21:52:28 +00:00
|
|
|
|
2007-10-08 18:53:19 +00:00
|
|
|
define Image/Build/iso
|
2009-05-07 13:50:09 +00:00
|
|
|
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
|
2007-10-08 18:53:19 +00:00
|
|
|
$(CP) \
|
2009-03-19 13:02:06 +00:00
|
|
|
$(STAGING_DIR_HOST)/usr/lib/grub/i386-openwrt/stage2_eltorito \
|
2007-10-08 18:53:19 +00:00
|
|
|
$(KDIR)/root.grub/boot/grub/stage2_eltorito
|
2009-05-07 13:50:09 +00:00
|
|
|
sed \
|
2010-02-17 00:59:41 +00:00
|
|
|
-e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
|
|
|
|
-e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
|
|
|
|
-e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
|
2007-10-08 18:53:19 +00:00
|
|
|
-e 's#(hd0,0)#(cd)#g' \
|
2009-05-07 13:50:09 +00:00
|
|
|
./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
|
2007-10-08 18:53:19 +00:00
|
|
|
$(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 17:12:23 +00:00
|
|
|
define Image/BuildKernel
|
2007-11-10 23:08:11 +00:00
|
|
|
$(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
|
2007-03-02 17:12:23 +00:00
|
|
|
endef
|
|
|
|
|
2006-06-04 21:57:59 +00:00
|
|
|
define Image/Build
|
2008-06-04 21:55:25 +00:00
|
|
|
$(call Image/Build/$(1))
|
2009-11-03 01:02:39 +00:00
|
|
|
$(call Image/Build/bootscript,$(1))
|
2010-02-12 19:04:12 +00:00
|
|
|
ifneq ($(1),iso)
|
2006-10-08 15:48:56 +00:00
|
|
|
$(call Image/Build/grub,$(1))
|
2008-05-30 16:50:37 +00:00
|
|
|
$(call Image/Build/vdi,$(1))
|
2008-11-09 17:39:09 +00:00
|
|
|
$(call Image/Build/vmdk,$(1))
|
2010-02-12 19:04:12 +00:00
|
|
|
endif
|
2007-11-10 23:08:11 +00:00
|
|
|
$(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1).fs
|
|
|
|
$(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
|
2010-02-12 19:04:12 +00:00
|
|
|
ifeq ($(1),ext2)
|
|
|
|
gzip -f9 $(BIN_DIR)/openwrt-$(BOARD)-$(1).image
|
|
|
|
endif
|
2006-06-04 21:57:59 +00:00
|
|
|
endef
|
2005-07-25 15:40:23 +00:00
|
|
|
|
2006-06-04 21:57:59 +00:00
|
|
|
$(eval $(call BuildImage))
|
2007-10-08 18:53:19 +00:00
|
|
|
|
2008-05-30 16:50:37 +00:00
|
|
|
ifeq ($(CONFIG_X86_VDI_IMAGES),y)
|
2009-01-02 14:35:18 +00:00
|
|
|
$(eval $(call RequireCommand,VBoxManage, \
|
|
|
|
You need VBoxManage to generate VirtualBox images. \
|
2008-05-30 16:50:37 +00:00
|
|
|
))
|
|
|
|
endif
|
|
|
|
|
2008-11-09 17:39:09 +00:00
|
|
|
ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
|
|
|
|
$(eval $(call RequireCommand,qemu-img, \
|
|
|
|
You need qemu-img to generate VMware images. \
|
|
|
|
))
|
|
|
|
endif
|