2 # Copyright (C) 2006-2012 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 GRUB2_MODULES
= at_keyboard biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga
15 GRUB_TERMINAL_CONFIG
=
16 GRUB_CONSOLE_CMDLINE
=
18 ifneq ($(CONFIG_X86_GRUB_CONSOLE
),)
19 GRUB_CONSOLE_CMDLINE
+= console
=tty0
20 GRUB_TERMINALS
+= console
23 ifneq ($(CONFIG_X86_GRUB_SERIAL
),)
24 GRUB_CONSOLE_CMDLINE
+= console
=$(call qstrip
,$(CONFIG_X86_GRUB_SERIAL
)),$(CONFIG_X86_GRUB_BAUDRATE
)n8
25 GRUB_SERIAL_CONFIG
:= serial
--unit
=0 --speed
=$(CONFIG_X86_GRUB_BAUDRATE
) --word=8 --parity
=no
--stop
=1
26 GRUB_TERMINALS
+= serial
29 ifneq ($(GRUB_TERMINALS
),)
30 ifneq ($(CONFIG_X86_USE_GRUB2
),)
31 GRUB_TERMINAL_CONFIG
:= terminal_input
$(GRUB_TERMINALS
); terminal_output
$(GRUB_TERMINALS
)
33 GRUB_TERMINAL_CONFIG
:= terminal
--timeout
=2 $(GRUB_TERMINALS
)
37 ROOTPART
:=$(call qstrip
,$(CONFIG_TARGET_ROOTFS_PARTNAME
))
39 GRUB_TIMEOUT
:=$(call qstrip
,$(CONFIG_X86_GRUB_TIMEOUT
))
41 ifneq ($(CONFIG_X86_GRUB_IMAGES
),)
43 BOOTOPTS
:=$(call qstrip
,$(CONFIG_X86_GRUB_BOOTOPTS
))
45 define Image
/cmdline
/ext4
46 root
=$(ROOTPART
) rootfstype
=ext4 rootwait
49 define Image
/cmdline
/jffs2-64k
50 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
53 define Image
/cmdline
/jffs2-128k
54 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
57 define Image
/cmdline
/squashfs
58 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootwait
61 define Image
/Build
/grub
62 # left here because the image builder doesnt need these
63 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
67 $(KDIR
)/e2fs_stage1_5 \
68 $(KDIR
)/root.grub
/boot
/grub
/
69 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
71 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
72 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
73 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
74 -e
's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
75 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
76 PADDING
="$(CONFIG_TARGET_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_grub.sh \
77 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
78 $(CONFIG_TARGET_KERNEL_PARTSIZE
) $(KDIR
)/root.grub \
79 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1)
80 $(call Image
/Build
/grub
/$(1))
83 define Image
/Prepare
/grub
84 # for the image builder
86 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/stage1 \
87 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/stage2 \
88 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/stage2_eltorito \
89 $(STAGING_DIR
)/usr
/lib
/grub
/i386-openwrt
/e2fs_stage1_5 \
93 define Image
/Build
/grub2
94 # left here because the image builder doesnt need these
95 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
$(KDIR
)/grub2
96 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
98 -o
$(KDIR
)/grub2
/core.img \
100 -c .
/grub-early.cfg \
102 $(CP
) $(STAGING_DIR_HOST
)/lib
/grub
/i386-pc
/*.img
$(KDIR
)/grub2
/
103 echo
'(hd0) $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img' > $(KDIR
)/grub2
/device.map
105 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
106 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
107 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
108 -e
's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
109 .
/grub.cfg
> $(KDIR
)/root.grub
/boot
/grub
/grub.cfg
110 PADDING
="$(CONFIG_TARGET_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_generic.sh \
111 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
112 $(CONFIG_TARGET_KERNEL_PARTSIZE
) $(KDIR
)/root.grub \
113 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1) \
116 --device-map
="$(KDIR)/grub2/device.map" \
119 "$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img"
120 $(call Image
/Build
/grub
/$(1))
126 ifneq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES
),)
128 define Image
/cmdline
/ext4
129 root
=$(ROOTPART
) rootfstype
=ext4 rootwait
132 define Image
/cmdline
/jffs2-64k
133 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
136 define Image
/cmdline
/jffs2-128k
137 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
140 define Image
/cmdline
/squashfs
141 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootdelay
=$(ROOTDELAY
)
144 define Image
/Build
/bootscript
145 # left here because the image builder doesnt need these
146 $(INSTALL_DIR
) $(KDIR
)/root.bootscript
/boot
147 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.bootscript
/boot
/vmlinuz
148 sed
-e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
149 .
/olpc.fth
> $(KDIR
)/root.bootscript
/boot
/olpc.fth
150 PADDING
="$(CONFIG_TARGET_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_olpc.sh \
151 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
152 $(CONFIG_TARGET_KERNEL_PARTSIZE
) $(KDIR
)/root.bootscript \
153 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1)
158 define Image
/Build
/squashfs
159 $(call prepare_generic_squashfs
,$(KDIR
)/root.squashfs
)
162 define Image
/Build
/iso
163 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
165 $(KDIR
)/stage2_eltorito \
166 $(KDIR
)/root.grub
/boot
/grub
/
168 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
169 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
170 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
171 -e
's#(hd0,0)#(cd)#g' \
172 .
/menu.lst
> $(KDIR
)/root.grub
/boot
/grub
/menu.lst
173 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
174 mkisofs
-R
-b boot
/grub
/stage2_eltorito
-no-emul-boot
-boot-load-size
4 -boot-info-table \
175 -o
$(KDIR
)/root.iso
$(KDIR
)/root.grub
178 ifneq ($(CONFIG_X86_VDI_IMAGES
),)
179 define Image
/Build
/vdi
180 # left here because the image builder doesnt need these
182 rm $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi || true
183 qemu-img convert
-f raw
-O vdi \
184 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
185 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi
186 # XXX: VBoxManage insists on setting perms to 0600
187 chmod
0644 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi
192 ifneq ($(CONFIG_X86_VMDK_IMAGES
),)
193 define Image
/Build
/vmdk
194 # left here because the image builder doesnt need these
196 rm $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vmdk || true
197 qemu-img convert
-f raw
-O vmdk \
198 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
199 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vmdk
204 define Image
/Build
/gzip
205 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img
206 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-rootfs-
$(1).img
209 ifneq ($(CONFIG_TARGET_IMAGES_GZIP
),)
210 define Image
/Build
/gzip
/ext4
211 $(call Image
/Build
/gzip
,ext4
)
213 ifneq ($(CONFIG_TARGET_IMAGES_PAD
),)
214 define Image
/Build
/gzip
/squashfs
215 $(call Image
/Build
/gzip
,squashfs
)
217 define Image
/Build
/gzip
/jffs2-64k
218 $(call Image
/Build
/gzip
,jffs2-64k
)
220 define Image
/Build
/gzip
/jffs2-128k
221 $(call Image
/Build
/gzip
,jffs2-128k
)
226 define Image
/BuildKernel
227 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
228 ifneq ($(CONFIG_X86_ETHERBOOT_IMAGES
),)
229 rm -f
$(BIN_DIR
)/$(IMG_PREFIX
)-etherboot
230 $(STAGING_DIR_HOST
)/bin
/mkelfImage \
231 --append
=$(CONFIG_X86_ETHERBOOT_BOOTOPTS
) \
233 $(BIN_DIR
)/$(IMG_PREFIX
)-etherboot
238 $(CP
) $(LINUX_DIR
)/arch
/x86
/boot
/bzImage
$(KDIR
)/bzImage
239 $(call Image
/Prepare
/bootscript
)
240 $(call Image
/Prepare
/$(if
$(CONFIG_X86_USE_GRUB2
),grub2
,grub
))
244 $(call Image
/Build
/$(1))
245 $(call Image
/Build
/bootscript
,$(1))
247 $(call Image
/Build
/$(if
$(CONFIG_X86_USE_GRUB2
),grub2
,grub
),$(1))
248 $(call Image
/Build
/vdi
,$(1))
249 $(call Image
/Build
/vmdk
,$(1))
251 $(CP
) $(KDIR
)/root.
$(1) $(BIN_DIR
)/$(IMG_PREFIX
)-rootfs-
$(1).img
252 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
253 $(call Image
/Build
/gzip
/$(1))
256 $(eval
$(call BuildImage
))