2006-06-27 00:35:46 +00:00
|
|
|
#
|
2012-02-16 17:53:57 +00:00
|
|
|
# Copyright (C) 2006-2012 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
|
|
|
|
2019-01-13 20:39:36 +00:00
|
|
|
GRUB2_MODULES = biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial test vga
|
|
|
|
GRUB2_MODULES_ISO = biosdisk boot chain configfile iso9660 linux ls part_msdos reboot serial test vga
|
2010-02-17 00:59:41 +00:00
|
|
|
GRUB_TERMINALS =
|
|
|
|
GRUB_SERIAL_CONFIG =
|
|
|
|
GRUB_TERMINAL_CONFIG =
|
|
|
|
GRUB_CONSOLE_CMDLINE =
|
|
|
|
|
2016-05-12 15:00:38 +00:00
|
|
|
USE_ATKBD = generic 64
|
2012-11-09 10:19:51 +00:00
|
|
|
|
2012-11-09 10:53:36 +00:00
|
|
|
ifneq ($(strip $(foreach subtarget,$(USE_ATKBD),$(CONFIG_TARGET_x86_$(subtarget)))),)
|
2012-11-09 10:19:51 +00:00
|
|
|
GRUB2_MODULES += at_keyboard
|
|
|
|
GRUB2_MODULES_ISO += at_keyboard
|
|
|
|
endif
|
|
|
|
|
2014-01-07 10:18:55 +00:00
|
|
|
ifneq ($(CONFIG_GRUB_CONSOLE),)
|
2010-04-29 00:47:05 +00:00
|
|
|
GRUB_CONSOLE_CMDLINE += console=tty0
|
|
|
|
GRUB_TERMINALS += console
|
2010-02-17 00:59:41 +00:00
|
|
|
endif
|
|
|
|
|
2014-01-07 10:18:55 +00:00
|
|
|
GRUB_SERIAL:=$(call qstrip,$(CONFIG_GRUB_SERIAL))
|
2013-08-10 18:35:29 +00:00
|
|
|
|
|
|
|
ifneq ($(GRUB_SERIAL),)
|
2017-02-07 03:33:36 +00:00
|
|
|
GRUB_CONSOLE_CMDLINE += console=$(GRUB_SERIAL),$(CONFIG_GRUB_BAUDRATE)n8$(if $(CONFIG_GRUB_FLOWCONTROL),r,)
|
|
|
|
GRUB_SERIAL_CONFIG := serial --unit=0 --speed=$(CONFIG_GRUB_BAUDRATE) --word=8 --parity=no --stop=1 --rtscts=$(if $(CONFIG_GRUB_FLOWCONTROL),on,off)
|
2010-04-29 00:47:05 +00:00
|
|
|
GRUB_TERMINALS += serial
|
2010-02-17 00:59:41 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(GRUB_TERMINALS),)
|
2012-10-07 23:01:56 +00:00
|
|
|
GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS)
|
2010-02-17 00:59:41 +00:00
|
|
|
endif
|
2010-02-12 19:04:12 +00:00
|
|
|
|
2016-07-03 16:39:08 +00:00
|
|
|
SIGNATURE:=$(shell perl -e 'printf("%08x", rand(0xFFFFFFFF))')
|
2010-05-05 02:07:38 +00:00
|
|
|
ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
|
2015-03-24 10:08:12 +00:00
|
|
|
ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(SIGNATURE)-02)
|
2010-02-12 19:04:12 +00:00
|
|
|
|
2014-01-07 10:18:55 +00:00
|
|
|
GRUB_TIMEOUT:=$(call qstrip,$(CONFIG_GRUB_TIMEOUT))
|
2018-06-05 13:47:05 +00:00
|
|
|
GRUB_TITLE:=$(call qstrip,$(CONFIG_GRUB_TITLE))
|
2012-01-19 01:14:45 +00:00
|
|
|
|
2014-01-07 10:18:55 +00:00
|
|
|
ifneq ($(CONFIG_GRUB_IMAGES),)
|
2010-04-29 00:47:05 +00:00
|
|
|
|
2014-01-07 10:18:55 +00:00
|
|
|
BOOTOPTS:=$(call qstrip,$(CONFIG_GRUB_BOOTOPTS))
|
2007-03-02 01:23:36 +00:00
|
|
|
|
2010-11-22 12:12:39 +00:00
|
|
|
define Image/cmdline/ext4
|
|
|
|
root=$(ROOTPART) rootfstype=ext4 rootwait
|
2010-04-29 00:47:05 +00:00
|
|
|
endef
|
2012-10-07 23:01:52 +00:00
|
|
|
|
2010-04-29 00:47:05 +00:00
|
|
|
define Image/cmdline/squashfs
|
2016-09-08 11:40:12 +00:00
|
|
|
root=$(ROOTPART) rootfstype=squashfs rootwait
|
2006-10-08 15:48:56 +00:00
|
|
|
endef
|
2010-04-29 00:47:05 +00:00
|
|
|
|
2012-09-22 20:10:42 +00: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 \
|
2016-11-23 08:27:55 +00:00
|
|
|
-p /boot/grub \
|
2013-01-17 15:46:26 +00:00
|
|
|
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
|
2012-09-22 20:10:42 +00: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/
|
2019-03-28 15:02:22 +00:00
|
|
|
echo '(hd0) $(BIN_DIR)/$(IMG_COMBINED)-$(1).img' > $(KDIR)/grub2/device.map
|
2012-09-22 20:10:42 +00:00
|
|
|
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' \
|
2018-06-05 13:47:05 +00:00
|
|
|
-e 's#@TITLE@#$(GRUB_TITLE)#g' \
|
2012-09-22 20:10:42 +00:00
|
|
|
./grub.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg
|
2018-11-20 16:20:41 +00:00
|
|
|
-$(CP) $(STAGING_DIR_ROOT)/boot/. $(KDIR)/root.grub/boot/
|
2019-03-27 10:31:14 +00:00
|
|
|
PADDING="1" SIGNATURE="$(SIGNATURE)" PATH="$(TARGET_PATH)" $(SCRIPT_DIR)/gen_image_generic.sh \
|
2019-03-28 15:02:22 +00:00
|
|
|
$(BIN_DIR)/$(IMG_COMBINED)-$(1).img \
|
2012-09-22 20:10:42 +00:00
|
|
|
$(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" \
|
2019-03-28 15:02:22 +00:00
|
|
|
"$(BIN_DIR)/$(IMG_COMBINED)-$(1).img"
|
2012-09-22 20:10:42 +00:00
|
|
|
endef
|
2008-11-09 17:39:09 +00:00
|
|
|
endif
|
2008-05-30 16:50:37 +00:00
|
|
|
|
2012-10-07 23:01:56 +00:00
|
|
|
define Image/Build/iso
|
2012-10-07 23:01:52 +00:00
|
|
|
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
|
|
|
|
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
|
|
|
|
grub-mkimage \
|
2016-11-23 08:27:55 +00:00
|
|
|
-p /boot/grub \
|
2013-01-17 15:46:26 +00:00
|
|
|
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
|
2012-10-07 23:01:52 +00: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' \
|
2018-06-05 13:47:05 +00:00
|
|
|
-e 's#@TITLE@#$(GRUB_TITLE)#g' \
|
2012-10-07 23:01:52 +00:00
|
|
|
./grub-iso.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg
|
2018-11-20 16:20:41 +00:00
|
|
|
-$(CP) $(STAGING_DIR_ROOT)/boot/. $(KDIR)/root.grub/boot/
|
2012-10-07 23:01:52 +00:00
|
|
|
mkisofs -R -b boot/grub/eltorito.img -no-emul-boot -boot-info-table \
|
|
|
|
-o $(KDIR)/root.iso $(KDIR)/root.grub $(TARGET_DIR)
|
2012-10-07 23:01:56 +00:00
|
|
|
endef
|
2007-10-08 18:53:19 +00:00
|
|
|
|
2014-01-07 10:18:55 +00:00
|
|
|
ifneq ($(CONFIG_VDI_IMAGES),)
|
2010-04-29 00:47:05 +00:00
|
|
|
define Image/Build/vdi
|
2019-03-28 15:02:22 +00:00
|
|
|
rm $(BIN_DIR)/$(IMG_COMBINED)-$(1).vdi || true
|
2014-07-20 08:18:50 +00:00
|
|
|
qemu-img convert -f raw -O vdi \
|
2019-03-28 15:02:22 +00:00
|
|
|
$(BIN_DIR)/$(IMG_COMBINED)-$(1).img \
|
|
|
|
$(BIN_DIR)/$(IMG_COMBINED)-$(1).vdi
|
2010-04-29 00:47:05 +00:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2014-01-07 10:18:55 +00:00
|
|
|
ifneq ($(CONFIG_VMDK_IMAGES),)
|
2010-04-29 00:47:05 +00:00
|
|
|
define Image/Build/vmdk
|
2019-03-28 15:02:22 +00:00
|
|
|
rm $(BIN_DIR)/$(IMG_COMBINED)-$(1).vmdk || true
|
2014-07-20 08:18:50 +00:00
|
|
|
qemu-img convert -f raw -O vmdk \
|
2019-03-28 15:02:22 +00:00
|
|
|
$(BIN_DIR)/$(IMG_COMBINED)-$(1).img \
|
|
|
|
$(BIN_DIR)/$(IMG_COMBINED)-$(1).vmdk
|
2010-04-29 00:47:05 +00:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2012-02-16 17:53:57 +00:00
|
|
|
define Image/Build/gzip
|
2019-03-28 15:02:22 +00:00
|
|
|
gzip -f9n $(BIN_DIR)/$(IMG_COMBINED)-$(1).img
|
|
|
|
gzip -f9n $(BIN_DIR)/$(IMG_ROOTFS)-$(1).img
|
2012-02-16 17:53:57 +00:00
|
|
|
endef
|
|
|
|
|
2019-03-28 15:05:25 +00:00
|
|
|
$(eval $(call Image/gzip-ext4-padded-squashfs))
|
2012-02-16 17:53:57 +00:00
|
|
|
|
2007-03-02 17:12:23 +00:00
|
|
|
define Image/BuildKernel
|
2010-04-12 23:15:56 +00:00
|
|
|
$(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz
|
2007-03-02 17:12:23 +00:00
|
|
|
endef
|
|
|
|
|
2010-04-29 00:47:05 +00:00
|
|
|
define Image/Prepare
|
2012-10-07 23:01:56 +00:00
|
|
|
$(call Image/Prepare/grub2)
|
2010-04-29 00:47:05 +00:00
|
|
|
endef
|
|
|
|
|
2012-10-15 18:54:34 +00:00
|
|
|
define Image/Build/Initramfs
|
2013-06-27 19:58:31 +00:00
|
|
|
$(CP) $(KDIR)/bzImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-ramfs.bzImage
|
2012-10-15 18:54:34 +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))
|
2010-02-12 19:04:12 +00:00
|
|
|
ifneq ($(1),iso)
|
2012-10-07 23:01:56 +00:00
|
|
|
$(call Image/Build/grub2,$(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))
|
2019-03-28 15:02:22 +00:00
|
|
|
$(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_ROOTFS)-$(1).img
|
2012-10-07 23:05:39 +00:00
|
|
|
else
|
|
|
|
$(CP) $(KDIR)/root.iso $(BIN_DIR)/$(IMG_PREFIX).iso
|
|
|
|
endif
|
2010-04-12 23:15:56 +00:00
|
|
|
$(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz
|
2012-02-16 17:53:57 +00:00
|
|
|
$(call Image/Build/gzip/$(1))
|
2012-10-15 18:54:34 +00:00
|
|
|
ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
|
|
|
|
$(call Image/Build/Initramfs)
|
|
|
|
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))
|