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
= biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga
13 GRUB2_MODULES_ISO
= biosdisk boot chain configfile iso9660 linux ls part_msdos reboot serial vga
16 GRUB_TERMINAL_CONFIG
=
17 GRUB_CONSOLE_CMDLINE
=
19 USE_ATKBD
= generic kvm_guest
21 ifneq ($(strip $(foreach subtarget
,$(USE_ATKBD
),$(CONFIG_TARGET_x86_
$(subtarget
)))),)
22 GRUB2_MODULES
+= at_keyboard
23 GRUB2_MODULES_ISO
+= at_keyboard
26 ifneq ($(CONFIG_X86_GRUB_CONSOLE
),)
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_input
$(GRUB_TERMINALS
); terminal_output
$(GRUB_TERMINALS
)
41 ROOTPART
:=$(call qstrip
,$(CONFIG_TARGET_ROOTFS_PARTNAME
))
43 GRUB_TIMEOUT
:=$(call qstrip
,$(CONFIG_X86_GRUB_TIMEOUT
))
45 ifneq ($(CONFIG_X86_GRUB_IMAGES
),)
47 BOOTOPTS
:=$(call qstrip
,$(CONFIG_X86_GRUB_BOOTOPTS
))
49 define Image
/cmdline
/ext4
50 root
=$(ROOTPART
) rootfstype
=ext4 rootwait
53 define Image
/cmdline
/jffs2-64k
54 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
57 define Image
/cmdline
/jffs2-128k
58 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootwait
61 define Image
/cmdline
/squashfs
62 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootwait
65 define Image
/Build
/grub2
66 # left here because the image builder doesnt need these
67 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
$(KDIR
)/grub2
68 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
70 -o
$(KDIR
)/grub2
/core.img \
74 $(CP
) $(STAGING_DIR_HOST
)/lib
/grub
/i386-pc
/*.img
$(KDIR
)/grub2
/
75 echo
'(hd0) $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img' > $(KDIR
)/grub2
/device.map
77 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
78 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
79 -e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
80 -e
's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
81 .
/grub.cfg
> $(KDIR
)/root.grub
/boot
/grub
/grub.cfg
82 PADDING
="$(CONFIG_TARGET_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_generic.sh \
83 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
84 $(CONFIG_TARGET_KERNEL_PARTSIZE
) $(KDIR
)/root.grub \
85 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1) \
88 --device-map
="$(KDIR)/grub2/device.map" \
91 "$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img"
92 $(call Image
/Build
/grub
/$(1))
98 ifneq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES
),)
100 define Image
/cmdline
/ext4
101 root
=$(ROOTPART
) rootfstype
=ext4 rootwait
104 define Image
/cmdline
/jffs2-64k
105 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
108 define Image
/cmdline
/jffs2-128k
109 block2mtd.block2mtd
=$(ROOTPART
),131072,rootfs root
=/dev
/mtdblock0 rootfstype
=jffs2 rootdelay
=$(ROOTDELAY
)
112 define Image
/cmdline
/squashfs
113 block2mtd.block2mtd
=$(ROOTPART
),65536,rootfs root
=/dev
/mtdblock0 rootfstype
=squashfs rootdelay
=$(ROOTDELAY
)
116 define Image
/Build
/bootscript
117 # left here because the image builder doesnt need these
118 $(INSTALL_DIR
) $(KDIR
)/root.bootscript
/boot
119 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.bootscript
/boot
/vmlinuz
120 sed
-e
's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
121 .
/olpc.fth
> $(KDIR
)/root.bootscript
/boot
/olpc.fth
122 PADDING
="$(CONFIG_TARGET_IMAGES_PAD)" PATH
="$(TARGET_PATH)" .
/gen_image_olpc.sh \
123 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
124 $(CONFIG_TARGET_KERNEL_PARTSIZE
) $(KDIR
)/root.bootscript \
125 $(CONFIG_TARGET_ROOTFS_PARTSIZE
) $(KDIR
)/root.
$(1)
130 define Image
/Build
/squashfs
131 $(call prepare_generic_squashfs
,$(KDIR
)/root.squashfs
)
134 define Image
/Build
/iso
135 $(INSTALL_DIR
) $(KDIR
)/root.grub
/boot
/grub
$(KDIR
)/grub2
136 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
138 -o
$(KDIR
)/grub2
/eltorito.img \
140 -c .
/grub-early.cfg \
143 $(STAGING_DIR_HOST
)/lib
/grub
/i386-pc
/cdboot.img \
144 $(KDIR
)/grub2
/eltorito.img \
145 > $(KDIR
)/root.grub
/boot
/grub
/eltorito.img
147 -e
's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
148 -e
's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
149 -e
's#@CMDLINE@#root=/dev/sr0 rootfstype=iso9660 rootwait $(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
150 -e
's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
151 .
/grub-iso.cfg
> $(KDIR
)/root.grub
/boot
/grub
/grub.cfg
152 $(CP
) $(KDIR
)/bzImage
$(KDIR
)/root.grub
/boot
/vmlinuz
153 mkisofs
-R
-b boot
/grub
/eltorito.img
-no-emul-boot
-boot-info-table \
154 -o
$(KDIR
)/root.iso
$(KDIR
)/root.grub
$(TARGET_DIR
)
157 ifneq ($(CONFIG_X86_VDI_IMAGES
),)
158 define Image
/Build
/vdi
159 # left here because the image builder doesnt need these
161 rm $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi || true
162 qemu-img convert
-f raw
-O vdi \
163 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
164 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi
165 # XXX: VBoxManage insists on setting perms to 0600
166 chmod
0644 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vdi
171 ifneq ($(CONFIG_X86_VMDK_IMAGES
),)
172 define Image
/Build
/vmdk
173 # left here because the image builder doesnt need these
175 rm $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vmdk || true
176 qemu-img convert
-f raw
-O vmdk \
177 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img \
178 $(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).vmdk
183 define Image
/Build
/gzip
184 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-combined-
$(1).img
185 gzip
-f9
$(BIN_DIR
)/$(IMG_PREFIX
)-rootfs-
$(1).img
188 ifneq ($(CONFIG_TARGET_IMAGES_GZIP
),)
189 define Image
/Build
/gzip
/ext4
190 $(call Image
/Build
/gzip
,ext4
)
192 ifneq ($(CONFIG_TARGET_IMAGES_PAD
),)
193 define Image
/Build
/gzip
/squashfs
194 $(call Image
/Build
/gzip
,squashfs
)
196 define Image
/Build
/gzip
/jffs2-64k
197 $(call Image
/Build
/gzip
,jffs2-64k
)
199 define Image
/Build
/gzip
/jffs2-128k
200 $(call Image
/Build
/gzip
,jffs2-128k
)
205 define Image
/BuildKernel
206 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
207 ifneq ($(CONFIG_X86_ETHERBOOT_IMAGES
),)
208 rm -f
$(BIN_DIR
)/$(IMG_PREFIX
)-etherboot
209 $(STAGING_DIR_HOST
)/bin
/mkelfImage \
210 --append
=$(CONFIG_X86_ETHERBOOT_BOOTOPTS
) \
212 $(BIN_DIR
)/$(IMG_PREFIX
)-etherboot
216 define Image
/Build
/Profile
/ar525w
217 cp
$(KDIR
)/bzImage
$(KDIR
)/bzImage.tmp
218 $(SCRIPT_DIR
)/pad_image
$(1) $(KDIR
)/bzImage.tmp
$(KDIR
)/root.
$(1) 32
219 $(STAGING_DIR_HOST
)/bin
/airlink
-b
1 $(KDIR
)/bzImage.tmp
$(KDIR
)/root.
$(1) \
220 $(BIN_DIR
)/$(IMG_PREFIX
)-$(1)-ar525w.img
221 $(STAGING_DIR_HOST
)/bin
/airlink
-e
-b
1 $(KDIR
)/bzImage.tmp
$(KDIR
)/root.
$(1) \
222 $(BIN_DIR
)/$(IMG_PREFIX
)-$(1)-ar525w-web.img
225 define Image
/Build
/Profile
/sitecom
226 cp
$(KDIR
)/bzImage
$(KDIR
)/bzImage.tmp
227 #32k config data + 20 bytes header + 2 bytes checksum after kernel image
228 $(SCRIPT_DIR
)/pad_image
$(1) $(KDIR
)/bzImage.tmp
$(KDIR
)/root.
$(1) 32790
229 $(TOPDIR
)/target
/linux
/rdc
/image
/mkimg_sitecom.pl
$(KDIR
)/bzImage.tmp
> $(KDIR
)/tmp.img
230 cat
$(KDIR
)/root.
$(1) >> $(KDIR
)/tmp.img
231 cp
$(KDIR
)/tmp.img
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1)-sitecom.img
232 rm $(KDIR
)/tmp.img
$(KDIR
)/bzImage.tmp
235 define Image
/Build
/Profile
/bifferboard
236 $(TOPDIR
)/target
/linux
/rdc
/image
/mkimg_bifferboard.py
$(KDIR
)/bzImage
$(KDIR
)/root.
$(1) \
237 $(BIN_DIR
)/$(IMG_PREFIX
)-$(1)-bifferboard.img
241 $(CP
) $(LINUX_DIR
)/arch
/x86
/boot
/bzImage
$(KDIR
)/bzImage
242 $(call Image
/Prepare
/bootscript
)
243 $(call Image
/Prepare
/grub2
)
246 define Image
/Build
/Initramfs
247 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-ramfs.bzImage
251 $(call Image
/Build
/$(1))
252 $(call Image
/Build
/bootscript
,$(1))
254 $(call Image
/Build
/grub2
,$(1))
255 $(call Image
/Build
/vdi
,$(1))
256 $(call Image
/Build
/vmdk
,$(1))
257 $(CP
) $(KDIR
)/root.
$(1) $(BIN_DIR
)/$(IMG_PREFIX
)-rootfs-
$(1).img
259 $(CP
) $(KDIR
)/root.iso
$(BIN_DIR
)/$(IMG_PREFIX
).iso
261 $(CP
) $(KDIR
)/bzImage
$(BIN_DIR
)/$(IMG_PREFIX
)-vmlinuz
262 $(call Image
/Build
/gzip
/$(1))
263 $(call Image
/Build
/Profile
/$(PROFILE
),$(1))
264 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
265 $(call Image
/Build
/Initramfs
)
269 $(eval
$(call BuildImage
))