2020-03-20 10:10:55 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2006-2020 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
|
|
|
|
2020-03-20 10:10:54 +00:00
|
|
|
GRUB2_VARIANT =
|
2010-02-17 00:59:41 +00:00
|
|
|
GRUB_TERMINALS =
|
|
|
|
GRUB_SERIAL_CONFIG =
|
|
|
|
GRUB_TERMINAL_CONFIG =
|
|
|
|
GRUB_CONSOLE_CMDLINE =
|
|
|
|
|
2012-11-09 10:53:36 +00:00
|
|
|
ifneq ($(strip $(foreach subtarget,$(USE_ATKBD),$(CONFIG_TARGET_x86_$(subtarget)))),)
|
2020-03-20 10:10:54 +00:00
|
|
|
GRUB2_VARIANT := generic
|
|
|
|
else
|
|
|
|
GRUB2_VARIANT := legacy
|
2012-11-09 10:19:51 +00:00
|
|
|
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
|
|
|
|
2010-05-05 02:07:38 +00:00
|
|
|
ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
|
2019-11-04 20:55:23 +00:00
|
|
|
ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(IMG_PART_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
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
BOOTOPTS:=$(call qstrip,$(CONFIG_GRUB_BOOTOPTS))
|
2012-10-07 23:01:52 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
define Build/combined
|
|
|
|
$(CP) $(KDIR)/$(KERNEL_NAME) $@.boot/boot/vmlinuz
|
|
|
|
-$(CP) $(STAGING_DIR_ROOT)/boot/. $@.boot/boot/
|
|
|
|
PADDING="$(CONFIG_TARGET_IMAGES_PAD)" SIGNATURE="$(IMG_PART_SIGNATURE)" $(SCRIPT_DIR)/gen_image_generic.sh \
|
|
|
|
$@ \
|
|
|
|
$(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
|
|
|
|
$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
|
|
|
|
256
|
|
|
|
endef
|
2010-04-29 00:47:05 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
define Build/grub-config
|
|
|
|
rm -fR $@.boot
|
|
|
|
$(INSTALL_DIR) $@.boot/boot/grub
|
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' \
|
2020-03-20 10:10:55 +00:00
|
|
|
-e 's#@ROOTPART@#root=$(ROOTPART) rootwait#g' \
|
|
|
|
-e 's#@CMDLINE@#$(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE)#g' \
|
2012-09-22 20:10:42 +00:00
|
|
|
-e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
|
2018-06-05 13:47:05 +00:00
|
|
|
-e 's#@TITLE@#$(GRUB_TITLE)#g' \
|
2020-03-20 10:10:55 +00:00
|
|
|
./grub-$(1).cfg > $@.boot/boot/grub/grub.cfg
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/grub-install
|
|
|
|
rm -fR $@.grub2
|
|
|
|
$(INSTALL_DIR) $@.grub2
|
|
|
|
$(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img \
|
|
|
|
$(STAGING_DIR_HOST)/lib/grub/grub2-$(GRUB2_VARIANT)/core.img \
|
|
|
|
$@.grub2/
|
|
|
|
echo '(hd0) $@' > $@.grub2/device.map
|
|
|
|
$(STAGING_DIR_HOST)/bin/grub-bios-setup \
|
|
|
|
-m "$@.grub2/device.map" \
|
|
|
|
-d "$@.grub2" \
|
2012-09-22 20:10:42 +00:00
|
|
|
-r "hd0,msdos1" \
|
2020-03-20 10:10:55 +00:00
|
|
|
$@
|
|
|
|
endef
|
2008-05-30 16:50:37 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
define Build/iso
|
|
|
|
$(CP) $(KDIR)/$(KERNEL_NAME) $@.boot/boot/vmlinuz
|
|
|
|
cat \
|
|
|
|
$(STAGING_DIR_HOST)/lib/grub/i386-pc/cdboot.img \
|
2020-03-20 10:10:54 +00:00
|
|
|
$(STAGING_DIR_HOST)/lib/grub/grub2-iso/eltorito.img \
|
2020-03-20 10:10:55 +00:00
|
|
|
> $@.boot/boot/grub/eltorito.img
|
|
|
|
-$(CP) $(STAGING_DIR_ROOT)/boot/. $@.boot/boot/
|
2012-10-07 23:01:52 +00:00
|
|
|
mkisofs -R -b boot/grub/eltorito.img -no-emul-boot -boot-info-table \
|
2020-03-20 10:10:55 +00:00
|
|
|
-o $@ $@.boot $(TARGET_DIR)
|
2012-10-07 23:01:56 +00:00
|
|
|
endef
|
2007-10-08 18:53:19 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
DEVICE_VARS += GRUB2_VARIANT
|
|
|
|
define Device/Default
|
|
|
|
ARTIFACT/image.iso := grub-config iso | iso
|
2020-03-20 10:10:58 +00:00
|
|
|
IMAGE/combined.img := append-rootfs | pad-extra 128k | grub-config pc | combined | grub-install
|
2020-03-20 10:10:55 +00:00
|
|
|
IMAGE/combined.img.gz := append-rootfs | pad-extra 128k | grub-config pc | combined | grub-install | gzip
|
2020-03-20 10:10:57 +00:00
|
|
|
IMAGE/combined.vdi := append-rootfs | pad-extra 128k | grub-config pc | combined | grub-install | qemu-image vdi
|
|
|
|
IMAGE/combined.vmdk := append-rootfs | pad-extra 128k | grub-config pc | combined | grub-install | qemu-image vmdk
|
2020-03-20 10:10:58 +00:00
|
|
|
ifeq ($(CONFIG_TARGET_IMAGES_GZIP),y)
|
|
|
|
IMAGES := combined.img.gz
|
|
|
|
else
|
|
|
|
IMAGES := combined.img
|
|
|
|
endif
|
2020-03-20 10:10:55 +00:00
|
|
|
KERNEL := kernel-bin
|
|
|
|
KERNEL_INSTALL := 1
|
|
|
|
KERNEL_NAME := bzImage
|
|
|
|
ifeq ($(CONFIG_ISO_IMAGES),y)
|
|
|
|
ARTIFACTS := image.iso
|
|
|
|
endif
|
|
|
|
ifeq ($(CONFIG_VDI_IMAGES),y)
|
|
|
|
IMAGES += combined.vdi
|
|
|
|
endif
|
|
|
|
ifeq ($(CONFIG_VMDK_IMAGES),y)
|
|
|
|
IMAGES += combined.vmdk
|
|
|
|
endif
|
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
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
ifeq ($(SUBTARGET),64)
|
|
|
|
include 64.mk
|
|
|
|
endif
|
2010-04-29 00:47:05 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
ifeq ($(SUBTARGET),generic)
|
|
|
|
include generic.mk
|
|
|
|
endif
|
2012-10-15 18:54:34 +00:00
|
|
|
|
2020-03-20 10:10:55 +00:00
|
|
|
ifeq ($(SUBTARGET),legacy)
|
|
|
|
include legacy.mk
|
2012-10-15 18:54:34 +00:00
|
|
|
endif
|
2005-07-25 15:40:23 +00:00
|
|
|
|
2006-06-04 21:57:59 +00:00
|
|
|
$(eval $(call BuildImage))
|
2020-03-20 10:10:55 +00:00
|
|
|
|