2 # Copyright (C) 2006-2010 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
14 GRUB_TERMINAL_CONFIG
=
15 GRUB_CONSOLE_CMDLINE
=
17 ifneq ($(CONFIG_X86_GRUB_CONSOLE
),)
18 GRUB_CONSOLE_CMDLINE
+= console
=tty0
19 GRUB_TERMINALS
+= console
22 ifneq ($(CONFIG_X86_GRUB_SERIAL
),)
23 GRUB_CONSOLE_CMDLINE
+= console
=$(call qstrip
,$(CONFIG_X86_GRUB_SERIAL
)),$(CONFIG_X86_GRUB_BAUDRATE
)n8
24 GRUB_SERIAL_CONFIG
:= serial
--unit
=0 --speed
=$(CONFIG_X86_GRUB_BAUDRATE
) --word=8 --parity
=no
--stop
=1
25 GRUB_TERMINALS
+= serial
28 ifneq ($(GRUB_TERMINALS
),)
29 GRUB_TERMINAL_CONFIG
:= terminal
--timeout
=2 $(GRUB_TERMINALS
)
33 ifneq ($(CONFIG_X86_GRUB_IMAGES
),)
34 ifneq ($(HOST_OS
),Darwin
)
36 BOOTOPTS
:=$(call qstrip
,$(CONFIG_X86_GRUB_BOOTOPTS
))
37 ROOTPART
:=$(call qstrip
,$(CONFIG_X86_GRUB_ROOTPART
))
39 define Image
/cmdline
/ext2
40 root
=$(ROOTPART
) rootfstype
=ext2 rootwait
43 define Image
/cmdline
/jffs2-64k
44 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
47 define Image
/cmdline
/jffs2-128k
48 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
51 define Image
/cmdline
/squashfs
52 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootwait
55 define Image
/Build
/grub
56 # left here because the image builder doesnt need these
57 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
60 $(KDIR
)/root.grub
/boot
/grub
/
61 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
63 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
64 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
65 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
66 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
67 PADDING
="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_x86.sh \
68 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
69 $(CONFIG_X86_GRUB_KERNELPART
) $(KDIR
)/root.grub \
70 $(CONFIG_TARGET_ROOTFS_FSPART
) $(KDIR
)/root.
$(1)
71 $(call Image
/Build
/grub
/$(1))
74 define Image
/Prepare
/grub
75 # for the image builder
77 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-
*/stage1 \
78 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-
*/stage2 \
79 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-
*/e2fs_stage1_5 \
85 define Image
/Build
/grub
86 PADDING
="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH
="$(TARGET_PATH)" NOGRUB
=1 .
/gen_image_x86.sh
87 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
88 $(CONFIG_X86_GRUB_KERNELPART
) "" \
89 $(CONFIG_TARGET_ROOTFS_FSPART
) $(KDIR
)/root.
$(1)
97 ifneq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES
),)
99 ROOTPART
:=$(call qstrip
,$(CONFIG_OLPC_BOOTSCRIPT_ROOTPART
))
101 define Image
/cmdline
/ext2
102 root
=$(ROOTPART
) rootfstype
=ext2 rootwait
105 define Image
/cmdline
/jffs2-64k
106 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
109 define Image
/cmdline
/jffs2-128k
110 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
113 define Image
/cmdline
/squashfs
114 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootdelay
=$(ROOTDELAY
)
117 define Image
/Build
/bootscript
118 # left here because the image builder doesnt need these
119 $(INSTALL_DIR
) $(KDIR
)/root.bootscript
/boot
120 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.bootscript
/boot
/vmlinuz
121 sed
-e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
122 .
/olpc.fth
> $(KDIR
)/root.bootscript
/boot
/olpc.fth
123 PADDING
="$(CONFIG_OLPC_BOOTSCRIPT_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_olpc.sh \
124 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
125 $(CONFIG_OLPC_BOOTSCRIPT_KERNELPART
) $(KDIR
)/root.bootscript \
126 $(CONFIG_TARGET_ROOTFS_FSPART
) $(KDIR
)/root.
$(1)
131 define Image
/Build
/squashfs
132 $(call prepare_generic_squashfs
,$(KDIR
)/root.squashfs
)
135 define Image
/Build
/iso
136 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
138 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-openwrt
/stage2_eltorito \
139 $(KDIR
)/root.grub
/boot
/grub
/stage2_eltorito
141 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
142 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
143 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
144 -e
's#(hd0,0)#(cd)#g' \
145 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
146 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
147 mkisofs
-R
-b boot
/grub
/stage2_eltorito
-no-emul-boot
-boot-load-size
4 -boot-info-table \
148 -o
$(KDIR
)/root.iso
$(KDIR
)/root.grub
151 ifneq ($(CONFIG_X86_VDI_IMAGES
),)
152 define Image
/Build
/vdi
153 # left here because the image builder doesnt need these
155 rm $(BIN_DIR
)/$(IMG_PREFIX
)-ext2.vdi || true
156 VBoxManage convertfromraw
-format VDI \
157 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
158 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi
159 # XXX: VBoxManage insists on setting perms to 0600
160 chmod
0644 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi
165 ifneq ($(CONFIG_X86_VMDK_IMAGES
),)
166 define Image
/Build
/vmdk
167 # left here because the image builder doesnt need these
169 rm $(BIN_DIR
)/$(IMG_PREFIX
)-ext2.vmdk || true
170 qemu-img convert
-f raw
-O vmdk \
171 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
172 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vmdk
177 define Image
/BuildKernel
178 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
182 $(CP
) $(LINUX_DIR
)/arch
/x86
/boot
/bzImage
$(KDIR
)/bzImage
183 $(call Image
/Prepare
/bootscript
)
184 $(call Image
/Prepare
/grub
)
188 $(call Image
/Build
/$(1))
189 $(call Image
/Build
/bootscript
,$(1))
191 $(call Image
/Build
/grub
,$(1))
192 $(call Image
/Build
/vdi
,$(1))
193 $(call Image
/Build
/vmdk
,$(1))
195 $(CP
) $(KDIR
)/root.
$(1) $(BIN_DIR
)/$(IMG_PREFIX
)-rootfs-
$(1).img
196 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
198 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img
199 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-rootfs-
$(1).img
203 $(eval
$(call BuildImage
))
205 ifneq ($(CONFIG_X86_VDI_IMAGES
),)
206 $(eval
$(call RequireCommand
,VBoxManage
, \
207 You need VBoxManage to generate VirtualBox images. \
211 ifneq ($(CONFIG_X86_VMDK_IMAGES
),)
212 $(eval
$(call RequireCommand
,qemu-img
, \
213 You need qemu-img to generate VMware images. \