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
=$(call qstrip
,$(CONFIG_X86_GRUB_BOOTOPTS
))
14 ROOTPART
=$(call qstrip
,$(CONFIG_X86_GRUB_ROOTPART
))
17 ifeq ($(CONFIG_TARGET_x86_olpc
),y
)
18 ROOTPART
=$(call qstrip
,$(CONFIG_OLPC_BOOTSCRIPT_ROOTPART
))
23 GRUB_TERMINAL_CONFIG
=
24 GRUB_CONSOLE_CMDLINE
=
26 ifeq ($(CONFIG_X86_GRUB_CONSOLE
),y
)
27 GRUB_CONSOLE_CMDLINE
+= console
=tty0
28 GRUB_TERMINALS
+= console
31 ifneq ($(CONFIG_X86_GRUB_SERIAL
),)
32 GRUB_CONSOLE_CMDLINE
+= console
=$(call qstrip
,$(CONFIG_X86_GRUB_SERIAL
)),$(CONFIG_X86_GRUB_BAUDRATE
)n8
33 GRUB_SERIAL_CONFIG
= serial
--unit
=0 --speed
=$(CONFIG_X86_GRUB_BAUDRATE
) --word=8 --parity
=no
--stop
=1
34 GRUB_TERMINALS
+= serial
37 ifneq ($(GRUB_TERMINALS
),)
38 GRUB_TERMINAL_CONFIG
= terminal
--timeout
=2 $(GRUB_TERMINALS
)
42 ifeq ($(CONFIG_X86_GRUB_IMAGES
),y
)
43 ifneq ($(HOST_OS
),Darwin
)
44 define Image
/cmdline
/squashfs
45 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootwait
48 define Image
/cmdline
/jffs2-64k
49 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
52 define Image
/cmdline
/jffs2-128k
53 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
56 define Image
/cmdline
/ext2
57 root
=$(ROOTPART
) rootfstype
=ext2 rootwait
60 define Image
/Build
/grub
61 # left here because the image builder doesnt need these
62 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
65 $(KDIR
)/root.grub
/boot
/grub
/
66 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
68 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
69 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
70 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
71 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
72 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)
73 $(call Image
/Build
/grub
/$(1))
76 define Image
/Prepare
/grub
77 # for the image builder
79 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-
*/stage1 \
80 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-
*/stage2 \
81 $(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
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).image
$(CONFIG_X86_GRUB_KERNELPART
) "" $(CONFIG_TARGET_ROOTFS_FSPART
) $(KDIR
)/root.
$(1)
91 ifeq ($(CONFIG_X86_VDI_IMAGES
),y
)
92 define Image
/Build
/vdi
93 # left here because the image builder doesnt need these
95 rm $(BIN_DIR
)/$(IMG_PREFIX
)-ext2.vdi || true
96 VBoxManage convertfromraw
-format VDI
$(BIN_DIR
)/$(IMG_PREFIX
)-ext2.image
$(BIN_DIR
)/$(IMG_PREFIX
)-ext2.vdi
101 ifeq ($(CONFIG_X86_VMDK_IMAGES
),y
)
102 define Image
/Build
/vmdk
103 # left here because the image builder doesnt need these
105 rm $(BIN_DIR
)/$(IMG_PREFIX
)-ext2.vmdk || true
106 qemu-img convert
-f raw
$(BIN_DIR
)/$(IMG_PREFIX
)-ext2.image \
107 -O vmdk
$(BIN_DIR
)/$(IMG_PREFIX
)-ext2.vmdk
114 ifeq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES
),y
)
115 define Image
/cmdline
/squashfs
116 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootdelay
=$(ROOTDELAY
)
119 define Image
/cmdline
/jffs2-64k
120 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
123 define Image
/cmdline
/jffs2-128k
124 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
127 define Image
/cmdline
/ext2
128 root
=$(ROOTPART
) rootfstype
=ext2 rootwait
131 define Image
/Build
/bootscript
132 # left here because the image builder doesnt need these
133 $(INSTALL_DIR
) $(KDIR
)/root.bootscript
/boot
134 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.bootscript
/boot
/vmlinuz
135 sed
-e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
136 .
/olpc.fth
> $(KDIR
)/root.bootscript
/boot
/olpc.fth
137 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)
142 $(CP
) $(LINUX_DIR
)/arch
/x86
/boot
/bzImage
$(KDIR
)/bzImage
143 ifeq ($(CONFIG_TARGET_x86_olpc
),y
)
144 $(call Image
/Prepare
/bootscript
)
146 $(call Image
/Prepare
/grub
)
150 define Image
/Build
/squashfs
151 $(call prepare_generic_squashfs
,$(KDIR
)/root.squashfs
)
154 define Image
/Build
/iso
155 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
157 $(STAGING_DIR_HOST
)/usr
/lib
/grub
/i386-openwrt
/stage2_eltorito \
158 $(KDIR
)/root.grub
/boot
/grub
/stage2_eltorito
160 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
161 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
162 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
163 -e
's#(hd0,0)#(cd)#g' \
164 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
165 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
166 mkisofs
-R
-b boot
/grub
/stage2_eltorito
-no-emul-boot
-boot-load-size
4 -boot-info-table \
167 -o
$(KDIR
)/root.iso
$(KDIR
)/root.grub
170 define Image
/BuildKernel
171 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
175 $(call Image
/Build
/$(1))
176 $(call Image
/Build
/bootscript
,$(1))
178 $(call Image
/Build
/grub
,$(1))
179 $(call Image
/Build
/vdi
,$(1))
180 $(call Image
/Build
/vmdk
,$(1))
182 $(CP
) $(KDIR
)/root.
$(1) $(BIN_DIR
)/$(IMG_PREFIX
)-$(1).fs
183 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
185 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).image
189 $(eval
$(call BuildImage
))
191 ifeq ($(CONFIG_X86_VDI_IMAGES
),y
)
192 $(eval
$(call RequireCommand
,VBoxManage
, \
193 You need VBoxManage to generate VirtualBox images. \
197 ifeq ($(CONFIG_X86_VMDK_IMAGES
),y
)
198 $(eval
$(call RequireCommand
,qemu-img
, \
199 You need qemu-img to generate VMware images. \