2006-06-27 08:35:46 +08:00
|
|
|
#
|
2012-02-17 01:53:57 +08:00
|
|
|
# Copyright (C) 2006-2012 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
|
|
|
|
2012-11-09 18:19:51 +08:00
|
|
|
GRUB2_MODULES = biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga
|
|
|
|
GRUB2_MODULES_ISO = biosdisk boot chain configfile iso9660 linux ls part_msdos reboot serial vga
|
2010-02-17 08:59:41 +08:00
|
|
|
GRUB_TERMINALS =
|
|
|
|
GRUB_SERIAL_CONFIG =
|
|
|
|
GRUB_TERMINAL_CONFIG =
|
|
|
|
GRUB_CONSOLE_CMDLINE =
|
|
|
|
|
2012-11-09 18:19:51 +08:00
|
|
|
USE_ATKBD = generic kvm_guest
|
|
|
|
|
2012-11-09 18:53:36 +08:00
|
|
|
ifneq ($(strip $(foreach subtarget,$(USE_ATKBD),$(CONFIG_TARGET_x86_$(subtarget)))),)
|
2012-11-09 18:19:51 +08:00
|
|
|
GRUB2_MODULES += at_keyboard
|
|
|
|
GRUB2_MODULES_ISO += at_keyboard
|
|
|
|
endif
|
|
|
|
|
2014-01-07 18:18:55 +08:00
|
|
|
ifneq ($(CONFIG_GRUB_CONSOLE),)
|
2010-04-29 08:47:05 +08:00
|
|
|
GRUB_CONSOLE_CMDLINE += console=tty0
|
|
|
|
GRUB_TERMINALS += console
|
2010-02-17 08:59:41 +08:00
|
|
|
endif
|
|
|
|
|
2014-01-07 18:18:55 +08:00
|
|
|
GRUB_SERIAL:=$(call qstrip,$(CONFIG_GRUB_SERIAL))
|
2013-08-11 02:35:29 +08:00
|
|
|
|
|
|
|
ifneq ($(GRUB_SERIAL),)
|
2014-01-07 18:18:55 +08:00
|
|
|
GRUB_CONSOLE_CMDLINE += console=$(GRUB_SERIAL),$(CONFIG_GRUB_BAUDRATE)n8
|
|
|
|
GRUB_SERIAL_CONFIG := serial --unit=0 --speed=$(CONFIG_GRUB_BAUDRATE) --word=8 --parity=no --stop=1
|
2010-04-29 08:47:05 +08:00
|
|
|
GRUB_TERMINALS += serial
|
2010-02-17 08:59:41 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(GRUB_TERMINALS),)
|
2012-10-08 07:01:56 +08:00
|
|
|
GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(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
|
|
|
|
2014-01-07 18:18:55 +08:00
|
|
|
GRUB_TIMEOUT:=$(call qstrip,$(CONFIG_GRUB_TIMEOUT))
|
2012-01-19 09:14:45 +08:00
|
|
|
|
2014-01-07 18:18:55 +08:00
|
|
|
ifneq ($(CONFIG_GRUB_IMAGES),)
|
2010-04-29 08:47:05 +08:00
|
|
|
|
2014-01-07 18:18:55 +08:00
|
|
|
BOOTOPTS:=$(call qstrip,$(CONFIG_GRUB_BOOTOPTS))
|
2007-03-02 09:23:36 +08:00
|
|
|
|
2010-11-22 20:12:39 +08:00
|
|
|
define Image/cmdline/ext4
|
|
|
|
root=$(ROOTPART) rootfstype=ext4 rootwait
|
2010-04-29 08:47:05 +08:00
|
|
|
endef
|
2012-10-08 07:01:52 +08:00
|
|
|
|
2006-10-08 23:48:56 +08:00
|
|
|
define Image/cmdline/jffs2-64k
|
2014-04-10 22:43:17 +08:00
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs,5 root=/dev/mtdblock0 rootfstype=jffs2 rootwait
|
2006-10-08 23:48:56 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/cmdline/jffs2-128k
|
2014-04-10 22:43:17 +08:00
|
|
|
block2mtd.block2mtd=$(ROOTPART),131072,rootfs,5 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
|
2014-04-10 22:43:17 +08:00
|
|
|
block2mtd.block2mtd=$(ROOTPART),65536,rootfs,5 root=/dev/mtdblock0 rootfstype=squashfs rootwait
|
2006-10-08 23:48:56 +08:00
|
|
|
endef
|
2010-04-29 08:47:05 +08:00
|
|
|
|
2012-09-23 04:10:42 +08:00
|
|
|
define Image/Build/grub2
|
|
|
|
# left here because the image builder doesnt need these
|
|
|
|
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
|
|
|
|
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
|
|
|
|
grub-mkimage \
|
2013-01-17 23:46:26 +08:00
|
|
|
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
|
2012-09-23 04:10:42 +08:00
|
|
|
-o $(KDIR)/grub2/core.img \
|
|
|
|
-O i386-pc \
|
|
|
|
-c ./grub-early.cfg \
|
|
|
|
$(GRUB2_MODULES)
|
|
|
|
$(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img $(KDIR)/grub2/
|
|
|
|
echo '(hd0) $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img' > $(KDIR)/grub2/device.map
|
|
|
|
sed \
|
|
|
|
-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' \
|
|
|
|
-e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
|
|
|
|
./grub.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg
|
|
|
|
PADDING="$(CONFIG_TARGET_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_generic.sh \
|
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
|
|
|
|
$(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/root.grub \
|
|
|
|
$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1) \
|
|
|
|
256
|
|
|
|
grub-bios-setup \
|
|
|
|
--device-map="$(KDIR)/grub2/device.map" \
|
|
|
|
-d "$(KDIR)/grub2" \
|
|
|
|
-r "hd0,msdos1" \
|
|
|
|
"$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img"
|
|
|
|
$(call Image/Build/grub/$(1))
|
|
|
|
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),)
|
|
|
|
|
2010-11-22 20:12:39 +08:00
|
|
|
define Image/cmdline/ext4
|
|
|
|
root=$(ROOTPART) rootfstype=ext4 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
|
|
|
|
2012-10-08 07:01:56 +08:00
|
|
|
define Image/Build/iso
|
2012-10-08 07:01:52 +08:00
|
|
|
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
|
|
|
|
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
|
|
|
|
grub-mkimage \
|
2013-01-17 23:46:26 +08:00
|
|
|
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
|
2012-10-08 07:01:52 +08:00
|
|
|
-o $(KDIR)/grub2/eltorito.img \
|
|
|
|
-O i386-pc \
|
|
|
|
-c ./grub-early.cfg \
|
|
|
|
$(GRUB2_MODULES_ISO)
|
|
|
|
cat \
|
|
|
|
$(STAGING_DIR_HOST)/lib/grub/i386-pc/cdboot.img \
|
|
|
|
$(KDIR)/grub2/eltorito.img \
|
|
|
|
> $(KDIR)/root.grub/boot/grub/eltorito.img
|
|
|
|
sed \
|
|
|
|
-e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
|
|
|
|
-e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
|
|
|
|
-e 's#@CMDLINE@#root=/dev/sr0 rootfstype=iso9660 rootwait $(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
|
|
|
|
-e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
|
|
|
|
./grub-iso.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg
|
|
|
|
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
|
|
|
|
mkisofs -R -b boot/grub/eltorito.img -no-emul-boot -boot-info-table \
|
|
|
|
-o $(KDIR)/root.iso $(KDIR)/root.grub $(TARGET_DIR)
|
2012-10-08 07:01:56 +08:00
|
|
|
endef
|
2007-10-09 02:53:19 +08:00
|
|
|
|
2014-01-07 18:18:55 +08:00
|
|
|
ifneq ($(CONFIG_VDI_IMAGES),)
|
2010-04-29 08:47:05 +08:00
|
|
|
define Image/Build/vdi
|
|
|
|
# left here because the image builder doesnt need these
|
2010-11-22 20:12:39 +08:00
|
|
|
ifeq ($(1),ext4)
|
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
|
|
|
|
|
2014-01-07 18:18:55 +08:00
|
|
|
ifneq ($(CONFIG_VMDK_IMAGES),)
|
2010-04-29 08:47:05 +08:00
|
|
|
define Image/Build/vmdk
|
|
|
|
# left here because the image builder doesnt need these
|
2010-11-22 20:12:39 +08:00
|
|
|
ifeq ($(1),ext4)
|
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
|
|
|
|
|
2012-02-17 01:53:57 +08:00
|
|
|
define Image/Build/gzip
|
|
|
|
gzip -f9 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img
|
|
|
|
gzip -f9 $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img
|
|
|
|
endef
|
|
|
|
|
|
|
|
ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
|
|
|
|
define Image/Build/gzip/ext4
|
|
|
|
$(call Image/Build/gzip,ext4)
|
|
|
|
endef
|
2012-02-17 01:54:01 +08:00
|
|
|
ifneq ($(CONFIG_TARGET_IMAGES_PAD),)
|
2012-02-17 01:54:04 +08:00
|
|
|
define Image/Build/gzip/squashfs
|
|
|
|
$(call Image/Build/gzip,squashfs)
|
|
|
|
endef
|
2012-02-17 01:54:01 +08:00
|
|
|
define Image/Build/gzip/jffs2-64k
|
2012-02-17 01:53:57 +08:00
|
|
|
$(call Image/Build/gzip,jffs2-64k)
|
2012-02-17 01:54:01 +08:00
|
|
|
endef
|
|
|
|
define Image/Build/gzip/jffs2-128k
|
2012-02-17 01:53:57 +08:00
|
|
|
$(call Image/Build/gzip,jffs2-128k)
|
2012-02-17 01:54:01 +08:00
|
|
|
endef
|
|
|
|
endif
|
2012-02-17 01:53:57 +08:00
|
|
|
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
|
2011-05-17 18:35:14 +08:00
|
|
|
ifneq ($(CONFIG_X86_ETHERBOOT_IMAGES),)
|
|
|
|
rm -f $(BIN_DIR)/$(IMG_PREFIX)-etherboot
|
|
|
|
$(STAGING_DIR_HOST)/bin/mkelfImage \
|
|
|
|
--append=$(CONFIG_X86_ETHERBOOT_BOOTOPTS) \
|
|
|
|
$(KDIR)/bzImage \
|
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-etherboot
|
|
|
|
endif
|
2007-03-03 01:12:23 +08:00
|
|
|
endef
|
|
|
|
|
2012-10-16 02:54:34 +08:00
|
|
|
define Image/Build/Profile/ar525w
|
|
|
|
cp $(KDIR)/bzImage $(KDIR)/bzImage.tmp
|
|
|
|
$(SCRIPT_DIR)/pad_image $(1) $(KDIR)/bzImage.tmp $(KDIR)/root.$(1) 32
|
|
|
|
$(STAGING_DIR_HOST)/bin/airlink -b 1 $(KDIR)/bzImage.tmp $(KDIR)/root.$(1) \
|
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-$(1)-ar525w.img
|
|
|
|
$(STAGING_DIR_HOST)/bin/airlink -e -b 1 $(KDIR)/bzImage.tmp $(KDIR)/root.$(1) \
|
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-$(1)-ar525w-web.img
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/Build/Profile/sitecom
|
|
|
|
cp $(KDIR)/bzImage $(KDIR)/bzImage.tmp
|
|
|
|
#32k config data + 20 bytes header + 2 bytes checksum after kernel image
|
|
|
|
$(SCRIPT_DIR)/pad_image $(1) $(KDIR)/bzImage.tmp $(KDIR)/root.$(1) 32790
|
|
|
|
$(TOPDIR)/target/linux/rdc/image/mkimg_sitecom.pl $(KDIR)/bzImage.tmp > $(KDIR)/tmp.img
|
|
|
|
cat $(KDIR)/root.$(1) >> $(KDIR)/tmp.img
|
|
|
|
cp $(KDIR)/tmp.img $(BIN_DIR)/$(IMG_PREFIX)-$(1)-sitecom.img
|
|
|
|
rm $(KDIR)/tmp.img $(KDIR)/bzImage.tmp
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/Build/Profile/bifferboard
|
|
|
|
$(TOPDIR)/target/linux/rdc/image/mkimg_bifferboard.py $(KDIR)/bzImage $(KDIR)/root.$(1) \
|
|
|
|
$(BIN_DIR)/$(IMG_PREFIX)-$(1)-bifferboard.img
|
|
|
|
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)
|
2012-10-08 07:01:56 +08:00
|
|
|
$(call Image/Prepare/grub2)
|
2010-04-29 08:47:05 +08:00
|
|
|
endef
|
|
|
|
|
2012-10-16 02:54:34 +08:00
|
|
|
define Image/Build/Initramfs
|
2013-06-28 03:58:31 +08:00
|
|
|
$(CP) $(KDIR)/bzImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-ramfs.bzImage
|
2012-10-16 02:54:34 +08:00
|
|
|
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)
|
2012-10-08 07:01:56 +08:00
|
|
|
$(call Image/Build/grub2,$(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-04-29 11:03:47 +08:00
|
|
|
$(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img
|
2012-10-08 07:05:39 +08:00
|
|
|
else
|
|
|
|
$(CP) $(KDIR)/root.iso $(BIN_DIR)/$(IMG_PREFIX).iso
|
|
|
|
endif
|
2010-04-13 07:15:56 +08:00
|
|
|
$(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz
|
2012-02-17 01:53:57 +08:00
|
|
|
$(call Image/Build/gzip/$(1))
|
2012-10-16 02:54:34 +08:00
|
|
|
$(call Image/Build/Profile/$(PROFILE),$(1))
|
|
|
|
ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
|
|
|
|
$(call Image/Build/Initramfs)
|
|
|
|
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))
|