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
12 ifneq ($(CONFIG_TARGET_x86_olpc
),y
)
13 BOOTOPTS
=$(strip $(subst ",, $(CONFIG_X86_GRUB_BOOTOPTS)))
14 ROOTPART=$(strip $(subst ",, $(CONFIG_X86_GRUB_ROOTPART
)))
15 #"))")) # fix vim's broken syntax highlighting
18 ifeq ($(CONFIG_TARGET_x86_olpc
),y
)
19 ROOTPART
=$(strip $(subst ",, $(CONFIG_OLPC_BOOTSCRIPT_ROOTPART)))
21 #"))")) # fix vim's broken syntax highlighting
25 GRUB_TERMINAL_CONFIG =
26 GRUB_CONSOLE_CMDLINE =
28 ifeq ($(CONFIG_X86_GRUB_CONSOLE),y)
29 GRUB_CONSOLE_CMDLINE += console=tty0
30 GRUB_TERMINALS += console
33 ifneq ($(CONFIG_X86_GRUB_SERIAL),)
34 GRUB_CONSOLE_CMDLINE += console=$(strip $(subst ",, $(CONFIG_X86_GRUB_SERIAL
))),$(CONFIG_X86_GRUB_BAUDRATE
)n8
35 GRUB_SERIAL_CONFIG
= serial
--unit
=0 --speed
=$(CONFIG_X86_GRUB_BAUDRATE
) --word=8 --parity
=no
--stop
=1
36 GRUB_TERMINALS
+= serial
39 ifneq ($(GRUB_TERMINALS
),)
40 GRUB_TERMINAL_CONFIG
= terminal
--timeout
=2 $(GRUB_TERMINALS
)
44 ifeq ($(CONFIG_X86_GRUB_IMAGES
),y
)
45 ifneq ($(HOST_OS
),Darwin
)
46 define Image
/cmdline
/squashfs
47 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootwait
50 define Image
/cmdline
/jffs2-64k
51 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
54 define Image
/cmdline
/jffs2-128k
55 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
58 define Image
/cmdline
/ext2
59 root
=$(ROOTPART
) rootfstype
=ext2 rootwait
62 define Image
/Build
/grub
63 # left here because the image builder doesnt need these
64 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
67 $(KDIR
)/root.grub
/boot
/grub
/
68 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
70 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
71 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
72 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
73 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
74 PADDING
="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_x86.sh
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).image
$(CONFIG_X86_GRUB_KERNELPART
) $(KDIR
)/root.grub
$(CONFIG_TARGET_ROOTFS_FSPART
) $(KDIR
)/root.
$(1)
75 $(call Image
/Build
/grub
/$(1))
78 define Image
/Prepare
/grub
79 # for the image builder
81 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-
*/stage1 \
82 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-
*/stage2 \
83 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-
*/e2fs_stage1_5 \
87 define Image
/Build
/grub
88 PADDING
="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH
="$(TARGET_PATH)" NOGRUB
=1 .
/gen_image_x86.sh
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).image
$(CONFIG_X86_GRUB_KERNELPART
) "" $(CONFIG_TARGET_ROOTFS_FSPART
) $(KDIR
)/root.
$(1)
93 ifeq ($(CONFIG_X86_VDI_IMAGES
),y
)
94 define Image
/Build
/vdi
95 # left here because the image builder doesnt need these
97 rm $(BIN_DIR
)/$(IMG_PREFIX
)-ext2.vdi || true
98 VBoxManage convertfromraw
-format VDI
$(BIN_DIR
)/$(IMG_PREFIX
)-ext2.image
$(BIN_DIR
)/$(IMG_PREFIX
)-ext2.vdi
103 ifeq ($(CONFIG_X86_VMDK_IMAGES
),y
)
104 define Image
/Build
/vmdk
105 # left here because the image builder doesnt need these
107 rm $(BIN_DIR
)/$(IMG_PREFIX
)-ext2.vmdk || true
108 qemu-img convert
-f raw
$(BIN_DIR
)/$(IMG_PREFIX
)-ext2.image \
109 -O vmdk
$(BIN_DIR
)/$(IMG_PREFIX
)-ext2.vmdk
116 ifeq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES
),y
)
117 define Image
/cmdline
/squashfs
118 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootdelay
=$(ROOTDELAY
)
121 define Image
/cmdline
/jffs2-64k
122 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
125 define Image
/cmdline
/jffs2-128k
126 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
129 define Image
/cmdline
/ext2
130 root
=$(ROOTPART
) rootfstype
=ext2 rootwait
133 define Image
/Build
/bootscript
134 # left here because the image builder doesnt need these
135 $(INSTALL_DIR
) $(KDIR
)/root.bootscript
/boot
136 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.bootscript
/boot
/vmlinuz
137 sed
-e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
138 .
/olpc.fth
> $(KDIR
)/root.bootscript
/boot
/olpc.fth
139 PADDING
="$(CONFIG_OLPC_BOOTSCRIPT_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_olpc.sh
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).image
$(CONFIG_OLPC_BOOTSCRIPT_KERNELPART
) $(KDIR
)/root.bootscript
$(CONFIG_TARGET_ROOTFS_FSPART
) $(KDIR
)/root.
$(1)
144 $(CP
) $(LINUX_DIR
)/arch
/x86
/boot
/bzImage
$(KDIR
)/bzImage
145 ifeq ($(CONFIG_TARGET_x86_olpc
),y
)
146 $(call Image
/Prepare
/bootscript
)
148 $(call Image
/Prepare
/grub
)
152 define Image
/Build
/squashfs
153 $(call prepare_generic_squashfs
,$(KDIR
)/root.squashfs
)
156 define Image
/Build
/iso
157 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
159 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-openwrt
/stage2_eltorito \
160 $(KDIR
)/root.grub
/boot
/grub
/stage2_eltorito
162 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
163 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
164 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
165 -e
's#(hd0,0)#(cd)#g' \
166 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
167 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
168 mkisofs
-R
-b boot
/grub
/stage2_eltorito
-no-emul-boot
-boot-load-size
4 -boot-info-table \
169 -o
$(KDIR
)/root.iso
$(KDIR
)/root.grub
172 define Image
/BuildKernel
173 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
177 $(call Image
/Build
/$(1))
178 $(call Image
/Build
/bootscript
,$(1))
180 $(call Image
/Build
/grub
,$(1))
181 $(call Image
/Build
/vdi
,$(1))
182 $(call Image
/Build
/vmdk
,$(1))
184 $(CP
) $(KDIR
)/root.
$(1) $(BIN_DIR
)/$(IMG_PREFIX
)-$(1).fs
185 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
187 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).image
191 $(eval
$(call BuildImage
))
193 ifeq ($(CONFIG_X86_VDI_IMAGES
),y
)
194 $(eval
$(call RequireCommand
,VBoxManage
, \
195 You need VBoxManage to generate VirtualBox images. \
199 ifeq ($(CONFIG_X86_VMDK_IMAGES
),y
)
200 $(eval
$(call RequireCommand
,qemu-img
, \
201 You need qemu-img to generate VMware images. \