2006-06-27 08:35:46 +08:00
|
|
|
#
|
2010-02-13 03:04:12 +08:00
|
|
|
# Copyright (C) 2006-2010 OpenWrt.org
|
2006-06-27 08:35:46 +08:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
2006-06-21 11:13:25 +08:00
|
|
|
include $(TOPDIR)/rules.mk
|
2006-06-21 10:32:39 +08:00
|
|
|
include $(INCLUDE_DIR)/image.mk
|
2005-07-25 23:40:23 +08:00
|
|
|
|
2006-11-19 05:14:45 +08:00
|
|
|
export PATH=$(TARGET_PATH):/sbin
|
2009-11-03 09:02:39 +08:00
|
|
|
|
2010-02-17 08:59:41 +08:00
|
|
|
GRUB_TERMINALS =
|
|
|
|
GRUB_SERIAL_CONFIG =
|
|
|
|
GRUB_TERMINAL_CONFIG =
|
|
|
|
GRUB_CONSOLE_CMDLINE =
|
|
|
|
|
2010-04-29 08:47:05 +08:00
|
|
|
ifneq ($(CONFIG_X86_GRUB_CONSOLE),)
|
|
|
|
GRUB_CONSOLE_CMDLINE += console=tty0
|
|
|
|
GRUB_TERMINALS += console
|
2010-02-17 08:59:41 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(CONFIG_X86_GRUB_SERIAL),)
|
2010-04-29 08:47:05 +08:00
|
|
|
GRUB_CONSOLE_CMDLINE += console=$(call qstrip,$(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
|
2010-02-17 08:59:41 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(GRUB_TERMINALS),)
|
2010-04-29 08:47:05 +08:00
|
|
|
GRUB_TERMINAL_CONFIG := terminal --timeout=2 $(GRUB_TERMINALS)
|
2010-02-17 08:59:41 +08:00
|
|
|
endif
|
2010-02-13 03:04:12 +08:00
|
|
|
|
2010-05-05 10:07:38 +08:00
|
|
|
ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
|
2010-02-13 03:04:12 +08:00
|
|
|
|
2010-04-29 08:47:05 +08:00
|
|
|
ifneq ($(CONFIG_X86_GRUB_IMAGES),)
|
|
|
|
|
|
|
|
BOOTOPTS:=$(call qstrip,$(CONFIG_X86_GRUB_BOOTOPTS))
|
2007-03-02 09:23:36 +08:00
|
|
|
|
2010-04-29 08:47:05 +08:00
|
|
|
define Image/cmdline/ext2
|
|
|
|
root=$(ROOTPART) rootfstype=ext2 rootwait
|
|
|
|
endef
|
|
|
|
|
2006-10-08 23:48:56 +08:00
|
|
|
define Image/cmdline/jffs2-64k
|
2009-12-06 17:12:34 +08:00
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
|
2006-10-08 23:48:56 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/cmdline/jffs2-128k
|
2009-12-06 17:12:34 +08:00
|
|
|
block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
|
2006-10-08 23:48:56 +08:00
|
|
|
endef
|
|
|
|
|
2010-04-29 08:47:05 +08:00
|
|
|
define Image/cmdline/squashfs
|
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootwait
|
2006-10-08 23:48:56 +08:00
|
|
|
endef
|
2010-04-29 08:47:05 +08:00
|
|
|
|
2006-10-08 23:48:56 +08:00
|
|
|
define Image/Build/grub
|
2007-02-01 09:07:26 +08:00
|
|
|
# left here because the image builder doesnt need these
|
|
|
|
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
|
2006-10-08 23:48:56 +08:00
|
|
|
$(CP) \
|
2010-05-03 01:32:25 +08:00
|
|
|
$(KDIR)/stage1 \
|
|
|
|
$(KDIR)/stage2 \
|
|
|
|
$(KDIR)/e2fs_stage1_5 \
|
2006-10-08 23:48:56 +08:00
|
|
|
$(KDIR)/root.grub/boot/grub/
|
2007-01-15 06:59:51 +08:00
|
|
|
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
|
2006-10-08 23:48:56 +08:00
|
|
|
sed \
|
2010-02-17 08:59:41 +08: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-10 00:57:12 +08:00
|
|
|
./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
|
2010-05-05 10:07:38 +08:00
|
|
|
PADDING="$(CONFIG_TARGET_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_x86.sh \
|
2010-04-29 11:03:47 +08:00
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
|
2010-05-05 10:07:38 +08:00
|
|
|
$(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/root.grub \
|
2010-05-05 09:52:54 +08:00
|
|
|
$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1)
|
2007-03-02 09:23:36 +08:00
|
|
|
$(call Image/Build/grub/$(1))
|
2006-10-08 23:48:56 +08:00
|
|
|
endef
|
|
|
|
|
2007-02-01 09:07:26 +08:00
|
|
|
define Image/Prepare/grub
|
2007-01-15 06:59:51 +08:00
|
|
|
# for the image builder
|
|
|
|
$(CP) \
|
2010-05-03 01:32:25 +08:00
|
|
|
$(STAGING_DIR)/usr/lib/grub/i386-openwrt/stage1 \
|
|
|
|
$(STAGING_DIR)/usr/lib/grub/i386-openwrt/stage2 \
|
|
|
|
$(STAGING_DIR)/usr/lib/grub/i386-openwrt/stage2_eltorito \
|
|
|
|
$(STAGING_DIR)/usr/lib/grub/i386-openwrt/e2fs_stage1_5 \
|
2007-01-15 06:59:51 +08:00
|
|
|
$(KDIR)/
|
2007-02-01 09:07:26 +08:00
|
|
|
endef
|
|
|
|
|
2008-11-10 01:39:09 +08:00
|
|
|
endif
|
2008-05-31 00:50:37 +08:00
|
|
|
|
2009-11-03 09:02:39 +08:00
|
|
|
ROOTDELAY=10
|
|
|
|
|
2010-04-29 08:47:05 +08:00
|
|
|
ifneq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES),)
|
|
|
|
|
|
|
|
define Image/cmdline/ext2
|
|
|
|
root=$(ROOTPART) rootfstype=ext2 rootwait
|
2009-11-03 09:02:39 +08:00
|
|
|
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
|
|
|
|
|
2010-04-29 08:47:05 +08:00
|
|
|
define Image/cmdline/squashfs
|
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootdelay=$(ROOTDELAY)
|
2009-11-03 09:02:39 +08:00
|
|
|
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
|
2010-05-05 10:07:38 +08:00
|
|
|
PADDING="$(CONFIG_TARGET_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_olpc.sh \
|
2010-04-29 11:03:47 +08:00
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
|
2010-05-05 10:07:38 +08:00
|
|
|
$(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/root.bootscript \
|
2010-05-05 09:52:54 +08:00
|
|
|
$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1)
|
2009-11-03 09:02:39 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
endif
|
2009-11-18 03:49:25 +08:00
|
|
|
|
2007-03-02 09:23:36 +08:00
|
|
|
define Image/Build/squashfs
|
2010-04-29 08:47:05 +08:00
|
|
|
$(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
|
2007-03-02 09:23:36 +08:00
|
|
|
endef
|
2007-01-11 05:52:28 +08:00
|
|
|
|
2007-10-09 02:53:19 +08:00
|
|
|
define Image/Build/iso
|
2009-05-07 21:50:09 +08:00
|
|
|
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
|
2007-10-09 02:53:19 +08:00
|
|
|
$(CP) \
|
2010-05-03 01:32:25 +08:00
|
|
|
$(KDIR)/stage2_eltorito \
|
|
|
|
$(KDIR)/root.grub/boot/grub/
|
2009-05-07 21:50:09 +08:00
|
|
|
sed \
|
2010-02-17 08:59:41 +08: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 02:53:19 +08:00
|
|
|
-e 's#(hd0,0)#(cd)#g' \
|
2009-05-07 21:50:09 +08:00
|
|
|
./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
|
2007-10-09 02:53:19 +08: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
|
|
|
|
|
2010-04-29 08:47:05 +08:00
|
|
|
ifneq ($(CONFIG_X86_VDI_IMAGES),)
|
|
|
|
define Image/Build/vdi
|
|
|
|
# left here because the image builder doesnt need these
|
|
|
|
ifeq ($(1),ext2)
|
2010-05-01 02:43:39 +08:00
|
|
|
rm $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vdi || true
|
2010-08-09 12:22:39 +08:00
|
|
|
qemu-img convert -f raw -O vdi \
|
2010-04-29 11:03:47 +08:00
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
|
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vdi
|
|
|
|
# XXX: VBoxManage insists on setting perms to 0600
|
|
|
|
chmod 0644 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vdi
|
2010-04-29 08:47:05 +08:00
|
|
|
endif
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(CONFIG_X86_VMDK_IMAGES),)
|
|
|
|
define Image/Build/vmdk
|
|
|
|
# left here because the image builder doesnt need these
|
|
|
|
ifeq ($(1),ext2)
|
2010-05-01 02:43:39 +08:00
|
|
|
rm $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vmdk || true
|
2010-04-29 11:03:47 +08:00
|
|
|
qemu-img convert -f raw -O vmdk \
|
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
|
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vmdk
|
2010-04-29 08:47:05 +08:00
|
|
|
endif
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2007-03-03 01:12:23 +08:00
|
|
|
define Image/BuildKernel
|
2010-04-13 07:15:56 +08:00
|
|
|
$(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz
|
2007-03-03 01:12:23 +08:00
|
|
|
endef
|
|
|
|
|
2010-04-29 08:47:05 +08:00
|
|
|
define Image/Prepare
|
|
|
|
$(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
|
|
|
|
$(call Image/Prepare/bootscript)
|
|
|
|
$(call Image/Prepare/grub)
|
|
|
|
endef
|
|
|
|
|
2006-06-05 05:57:59 +08:00
|
|
|
define Image/Build
|
2008-06-05 05:55:25 +08:00
|
|
|
$(call Image/Build/$(1))
|
2009-11-03 09:02:39 +08:00
|
|
|
$(call Image/Build/bootscript,$(1))
|
2010-02-13 03:04:12 +08:00
|
|
|
ifneq ($(1),iso)
|
2006-10-08 23:48:56 +08:00
|
|
|
$(call Image/Build/grub,$(1))
|
2008-05-31 00:50:37 +08:00
|
|
|
$(call Image/Build/vdi,$(1))
|
2008-11-10 01:39:09 +08:00
|
|
|
$(call Image/Build/vmdk,$(1))
|
2010-02-13 03:04:12 +08:00
|
|
|
endif
|
2010-04-29 11:03:47 +08:00
|
|
|
$(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img
|
2010-04-13 07:15:56 +08:00
|
|
|
$(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz
|
2010-02-13 03:04:12 +08:00
|
|
|
ifeq ($(1),ext2)
|
2010-04-29 11:03:47 +08:00
|
|
|
gzip -f9 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img
|
|
|
|
gzip -f9 $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img
|
2010-02-13 03:04:12 +08:00
|
|
|
endif
|
2006-06-05 05:57:59 +08:00
|
|
|
endef
|
2005-07-25 23:40:23 +08:00
|
|
|
|
2006-06-05 05:57:59 +08:00
|
|
|
$(eval $(call BuildImage))
|