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
),)
36 BOOTOPTS
:=$(call qstrip
,$(CONFIG_X86_GRUB_BOOTOPTS
))
38 define Image
/cmdline
/ext2
39 root
=$(ROOTPART
) rootfstype
=ext2 rootwait
42 define Image
/cmdline
/jffs2-64k
43 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
46 define Image
/cmdline
/jffs2-128k
47 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
50 define Image
/cmdline
/squashfs
51 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootwait
54 define Image
/Build
/grub
55 # left here because the image builder doesnt need these
56 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
60 $(KDIR
)/e2fs_stage1_5 \
61 $(KDIR
)/root.grub
/boot
/grub
/
62 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
64 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
65 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
66 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
67 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
68 PADDING
="$(CONFIG_TARGET_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_x86.sh \
69 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
70 $(CONFIG_TARGET_KERNEL_PARTSIZE
) $(KDIR
)/root.grub \
71 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1)
72 $(call Image
/Build
/grub
/$(1))
75 define Image
/Prepare
/grub
76 # for the image builder
78 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/stage1 \
79 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/stage2 \
80 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/stage2_eltorito \
81 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/e2fs_stage1_5 \
89 ifneq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES
),)
91 define Image
/cmdline
/ext2
92 root
=$(ROOTPART
) rootfstype
=ext2 rootwait
95 define Image
/cmdline
/jffs2-64k
96 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
99 define Image
/cmdline
/jffs2-128k
100 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
103 define Image
/cmdline
/squashfs
104 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootdelay
=$(ROOTDELAY
)
107 define Image
/Build
/bootscript
108 # left here because the image builder doesnt need these
109 $(INSTALL_DIR
) $(KDIR
)/root.bootscript
/boot
110 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.bootscript
/boot
/vmlinuz
111 sed
-e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
112 .
/olpc.fth
> $(KDIR
)/root.bootscript
/boot
/olpc.fth
113 PADDING
="$(CONFIG_TARGET_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_olpc.sh \
114 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
115 $(CONFIG_TARGET_KERNEL_PARTSIZE
) $(KDIR
)/root.bootscript \
116 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1)
121 define Image
/Build
/squashfs
122 $(call prepare_generic_squashfs
,$(KDIR
)/root.squashfs
)
125 define Image
/Build
/iso
126 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
128 $(KDIR
)/stage2_eltorito \
129 $(KDIR
)/root.grub
/boot
/grub
/
131 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
132 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
133 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
134 -e
's#(hd0,0)#(cd)#g' \
135 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
136 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
137 mkisofs
-R
-b boot
/grub
/stage2_eltorito
-no-emul-boot
-boot-load-size
4 -boot-info-table \
138 -o
$(KDIR
)/root.iso
$(KDIR
)/root.grub
141 ifneq ($(CONFIG_X86_VDI_IMAGES
),)
142 define Image
/Build
/vdi
143 # left here because the image builder doesnt need these
145 rm $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi || true
146 qemu-img convert
-f raw
-O vdi \
147 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
148 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi
149 # XXX: VBoxManage insists on setting perms to 0600
150 chmod
0644 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi
155 ifneq ($(CONFIG_X86_VMDK_IMAGES
),)
156 define Image
/Build
/vmdk
157 # left here because the image builder doesnt need these
159 rm $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vmdk || true
160 qemu-img convert
-f raw
-O vmdk \
161 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
162 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vmdk
167 define Image
/BuildKernel
168 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
172 $(CP
) $(LINUX_DIR
)/arch
/x86
/boot
/bzImage
$(KDIR
)/bzImage
173 $(call Image
/Prepare
/bootscript
)
174 $(call Image
/Prepare
/grub
)
178 $(call Image
/Build
/$(1))
179 $(call Image
/Build
/bootscript
,$(1))
181 $(call Image
/Build
/grub
,$(1))
182 $(call Image
/Build
/vdi
,$(1))
183 $(call Image
/Build
/vmdk
,$(1))
185 $(CP
) $(KDIR
)/root.
$(1) $(BIN_DIR
)/$(IMG_PREFIX
)-rootfs-
$(1).img
186 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
188 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img
189 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-rootfs-
$(1).img
193 $(eval
$(call BuildImage
))