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
)
32 ROOTPART
:=$(call qstrip
,$(CONFIG_TARGET_ROOTFS_PARTNAME
))
34 ifneq ($(CONFIG_X86_GRUB_IMAGES
),)
35 ifneq ($(HOST_OS
),Darwin
)
37 BOOTOPTS
:=$(call qstrip
,$(CONFIG_X86_GRUB_BOOTOPTS
))
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
61 $(KDIR
)/e2fs_stage1_5 \
62 $(KDIR
)/root.grub
/boot
/grub
/
63 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
65 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
66 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
67 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
68 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
69 PADDING
="$(CONFIG_TARGET_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_x86.sh \
70 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
71 $(CONFIG_TARGET_KERNEL_PARTSIZE
) $(KDIR
)/root.grub \
72 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1)
73 $(call Image
/Build
/grub
/$(1))
76 define Image
/Prepare
/grub
77 # for the image builder
79 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/stage1 \
80 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/stage2 \
81 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/stage2_eltorito \
82 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/e2fs_stage1_5 \
88 define Image
/Build
/grub
89 PADDING
="$(CONFIG_TARGET_IMAGES_PAD)" PATH
="$(TARGET_PATH)" NOGRUB
=1 .
/gen_image_x86.sh \
90 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
91 $(CONFIG_TARGET_KERNEL_PARTSIZE
) "" \
92 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1)
100 ifneq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES
),)
102 define Image
/cmdline
/ext2
103 root
=$(ROOTPART
) rootfstype
=ext2 rootwait
106 define Image
/cmdline
/jffs2-64k
107 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
110 define Image
/cmdline
/jffs2-128k
111 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
114 define Image
/cmdline
/squashfs
115 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootdelay
=$(ROOTDELAY
)
118 define Image
/Build
/bootscript
119 # left here because the image builder doesnt need these
120 $(INSTALL_DIR
) $(KDIR
)/root.bootscript
/boot
121 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.bootscript
/boot
/vmlinuz
122 sed
-e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
123 .
/olpc.fth
> $(KDIR
)/root.bootscript
/boot
/olpc.fth
124 PADDING
="$(CONFIG_TARGET_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_olpc.sh \
125 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
126 $(CONFIG_TARGET_KERNEL_PARTSIZE
) $(KDIR
)/root.bootscript \
127 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1)
132 define Image
/Build
/squashfs
133 $(call prepare_generic_squashfs
,$(KDIR
)/root.squashfs
)
136 define Image
/Build
/iso
137 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
139 $(KDIR
)/stage2_eltorito \
140 $(KDIR
)/root.grub
/boot
/grub
/
142 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
143 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
144 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
145 -e
's#(hd0,0)#(cd)#g' \
146 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
147 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
148 mkisofs
-R
-b boot
/grub
/stage2_eltorito
-no-emul-boot
-boot-load-size
4 -boot-info-table \
149 -o
$(KDIR
)/root.iso
$(KDIR
)/root.grub
152 ifneq ($(CONFIG_X86_VDI_IMAGES
),)
153 define Image
/Build
/vdi
154 # left here because the image builder doesnt need these
156 rm $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi || true
157 VBoxManage convertfromraw
-format VDI \
158 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
159 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi
160 # XXX: VBoxManage insists on setting perms to 0600
161 chmod
0644 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi
166 ifneq ($(CONFIG_X86_VMDK_IMAGES
),)
167 define Image
/Build
/vmdk
168 # left here because the image builder doesnt need these
170 rm $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vmdk || true
171 qemu-img convert
-f raw
-O vmdk \
172 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
173 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vmdk
178 define Image
/BuildKernel
179 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
183 $(CP
) $(LINUX_DIR
)/arch
/x86
/boot
/bzImage
$(KDIR
)/bzImage
184 $(call Image
/Prepare
/bootscript
)
185 $(call Image
/Prepare
/grub
)
189 $(call Image
/Build
/$(1))
190 $(call Image
/Build
/bootscript
,$(1))
192 $(call Image
/Build
/grub
,$(1))
193 $(call Image
/Build
/vdi
,$(1))
194 $(call Image
/Build
/vmdk
,$(1))
196 $(CP
) $(KDIR
)/root.
$(1) $(BIN_DIR
)/$(IMG_PREFIX
)-rootfs-
$(1).img
197 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
199 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img
200 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-rootfs-
$(1).img
204 $(eval
$(call BuildImage
))
206 ifneq ($(CONFIG_X86_VDI_IMAGES
),)
207 $(eval
$(call RequireCommand
,VBoxManage
, \
208 You need VBoxManage to generate VirtualBox images. \
212 ifneq ($(CONFIG_X86_VMDK_IMAGES
),)
213 $(eval
$(call RequireCommand
,qemu-img
, \
214 You need qemu-img to generate VMware images. \