2 # Copyright (C) 2006-2012 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR
)/rules.mk
8 include $(INCLUDE_DIR
)/image.mk
10 export PATH
=$(TARGET_PATH
):/sbin
15 GRUB_TERMINAL_CONFIG
=
16 GRUB_CONSOLE_CMDLINE
=
18 USE_ATKBD
= generic
64
20 ifneq ($(strip $(foreach subtarget
,$(USE_ATKBD
),$(CONFIG_TARGET_x86_
$(subtarget
)))),)
21 GRUB2_VARIANT
:= generic
23 GRUB2_VARIANT
:= legacy
26 ifneq ($(CONFIG_GRUB_CONSOLE
),)
27 GRUB_CONSOLE_CMDLINE
+= console
=tty0
28 GRUB_TERMINALS
+= console
31 GRUB_SERIAL
:=$(call qstrip
,$(CONFIG_GRUB_SERIAL
))
33 ifneq ($(GRUB_SERIAL
),)
34 GRUB_CONSOLE_CMDLINE
+= console
=$(GRUB_SERIAL
),$(CONFIG_GRUB_BAUDRATE
)n8
$(if
$(CONFIG_GRUB_FLOWCONTROL
),r
,)
35 GRUB_SERIAL_CONFIG
:= serial
--unit
=0 --speed
=$(CONFIG_GRUB_BAUDRATE
) --word=8 --parity
=no
--stop
=1 --rtscts
=$(if
$(CONFIG_GRUB_FLOWCONTROL
),on
,off
)
36 GRUB_TERMINALS
+= serial
39 ifneq ($(GRUB_TERMINALS
),)
40 GRUB_TERMINAL_CONFIG
:= terminal_input
$(GRUB_TERMINALS
); terminal_output
$(GRUB_TERMINALS
)
43 ROOTPART
:=$(call qstrip
,$(CONFIG_TARGET_ROOTFS_PARTNAME
))
44 ROOTPART
:=$(if
$(ROOTPART
),$(ROOTPART
),PARTUUID
=$(IMG_PART_SIGNATURE
)-02)
46 GRUB_TIMEOUT
:=$(call qstrip
,$(CONFIG_GRUB_TIMEOUT
))
47 GRUB_TITLE
:=$(call qstrip
,$(CONFIG_GRUB_TITLE
))
49 ifneq ($(CONFIG_GRUB_IMAGES
),)
51 BOOTOPTS
:=$(call qstrip
,$(CONFIG_GRUB_BOOTOPTS
))
53 define Image
/cmdline
/ext4
54 root
=$(ROOTPART
) rootfstype
=ext4 rootwait
57 define Image
/cmdline
/squashfs
58 root
=$(ROOTPART
) rootfstype
=squashfs rootwait
61 define Image
/Build
/grub2
62 # left here because the image builder doesnt need these
63 rm -fR
$(KDIR
)/root.grub
$(KDIR
)/grub2
64 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
$(KDIR
)/grub2
65 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
66 $(CP
) $(STAGING_DIR_HOST
)/lib
/grub
/i386-pc
/*.img \
67 $(STAGING_DIR_HOST
)/lib
/grub
/grub2-
$(strip $(GRUB2_VARIANT
))/core.img \
69 echo
'(hd0) $(BIN_DIR)/$(IMG_COMBINED)-$(1).img' > $(KDIR
)/grub2
/device.map
71 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
72 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
73 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
74 -e
's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
75 -e
's#@TITLE@#$(GRUB_TITLE)#g' \
76 .
/grub.cfg
> $(KDIR
)/root.grub
/boot
/grub
/grub.cfg
77 -$(CP
) $(STAGING_DIR_ROOT
)/boot
/.
$(KDIR
)/root.grub
/boot
/
78 grub-bios-setup
-V | cut
-d
' ' -f3
> $(KDIR
)/root.grub
/boot
/grub
/version
79 PADDING
="1" SIGNATURE
="$(IMG_PART_SIGNATURE)" PATH
="$(TARGET_PATH)" $(SCRIPT_DIR
)/gen_image_generic.sh \
80 $(BIN_DIR
)/$(IMG_COMBINED
)-$(1).img \
81 $(CONFIG_TARGET_KERNEL_PARTSIZE
) $(KDIR
)/root.grub \
82 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1) \
85 --device-map
="$(KDIR)/grub2/device.map" \
86 -d
"$(KDIR)/root.grub/boot/grub" \
88 "$(BIN_DIR)/$(IMG_COMBINED)-$(1).img"
92 define Image
/Build
/iso
93 rm -fR
$(KDIR
)/root.grub
$(KDIR
)/grub2
94 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
$(KDIR
)/grub2
95 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
96 $(STAGING_DIR_HOST
)/lib
/grub
/grub2-iso
/eltorito.img \
97 > $(KDIR
)/root.grub
/boot
/grub
/eltorito.img
99 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
100 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
101 -e
's#@CMDLINE@#root=/dev/sr0 rootfstype=iso9660 rootwait $(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
102 -e
's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
103 -e
's#@TITLE@#$(GRUB_TITLE)#g' \
104 .
/grub-iso.cfg
> $(KDIR
)/root.grub
/boot
/grub
/grub.cfg
105 -$(CP
) $(STAGING_DIR_ROOT
)/boot
/.
$(KDIR
)/root.grub
/boot
/
106 mkisofs
-R
-b boot
/grub
/eltorito.img
-no-emul-boot
-boot-info-table \
107 -o
$(KDIR
)/root.iso
$(KDIR
)/root.grub
$(TARGET_DIR
)
110 ifneq ($(CONFIG_VDI_IMAGES
),)
111 define Image
/Build
/vdi
112 rm $(BIN_DIR
)/$(IMG_COMBINED
)-$(1).vdi || true
113 $(STAGING_DIR_HOST
)/bin
/qemu-img convert
-f raw
-O vdi \
114 $(BIN_DIR
)/$(IMG_COMBINED
)-$(1).img \
115 $(BIN_DIR
)/$(IMG_COMBINED
)-$(1).vdi
119 ifneq ($(CONFIG_VMDK_IMAGES
),)
120 define Image
/Build
/vmdk
121 rm $(BIN_DIR
)/$(IMG_COMBINED
)-$(1).vmdk || true
122 $(STAGING_DIR_HOST
)/bin
/qemu-img convert
-f raw
-O vmdk \
123 $(BIN_DIR
)/$(IMG_COMBINED
)-$(1).img \
124 $(BIN_DIR
)/$(IMG_COMBINED
)-$(1).vmdk
125 #build the ESXI VMDK with
126 rm $(BIN_DIR
)/$(IMG_COMBINED
)-$(1)-esxi.vmdk || true
127 rm $(BIN_DIR
)/$(IMG_COMBINED
)-$(1)-esxi-flat.vmdk || true
128 $(STAGING_DIR_HOST
)/bin
/qemu-img convert
-f raw
-O vmdk
-o adapter_type
=lsilogic
,subformat
=monolithicFlat \
129 $(BIN_DIR
)/$(IMG_COMBINED
)-$(1).img \
130 $(BIN_DIR
)/$(IMG_COMBINED
)-$(1)-esxi.vmdk
134 define Image
/Build
/gzip
135 gzip
-f9n
$(BIN_DIR
)/$(IMG_COMBINED
)-$(1).img
136 gzip
-f9n
$(BIN_DIR
)/$(IMG_ROOTFS
)-$(1).img
139 $(eval
$(call Image
/gzip-ext4-padded-squashfs
))
141 define Image
/BuildKernel
142 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
146 $(call Image
/Prepare
/grub2
)
149 define Image
/Build
/Initramfs
150 $(CP
) $(KDIR
)/bzImage-initramfs
$(BIN_DIR
)/$(IMG_PREFIX
)-ramfs.bzImage
154 $(call Image
/Build
/$(1))
156 $(call Image
/Build
/grub2
,$(1))
157 $(call Image
/Build
/vdi
,$(1))
158 $(call Image
/Build
/vmdk
,$(1))
159 $(CP
) $(KDIR
)/root.
$(1) $(BIN_DIR
)/$(IMG_ROOTFS
)-$(1).img
161 $(CP
) $(KDIR
)/root.iso
$(BIN_DIR
)/$(IMG_PREFIX
).iso
163 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
164 $(call Image
/Build
/gzip
/$(1))
165 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
166 $(call Image
/Build
/Initramfs
)
170 $(eval
$(call BuildImage
))