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=$(strip $(subst ",, $(CONFIG_X86_GRUB_BOOTOPTS)))
14 ROOTPART=$(strip $(subst ",, $(CONFIG_X86_GRUB_ROOTPART)))
15 #"))")) # fix vim's broken syntax highlighting
18 ifeq ($(CONFIG_TARGET_x86_olpc),y)
19 ROOTPART=$(strip $(subst ",, $(CONFIG_OLPC_BOOTSCRIPT_ROOTPART)))
21 #"))")) # fix vim's broken syntax highlighting
23 CONSOLE=$(strip $(subst ",, $(CONFIG_X86_GRUB_CONSOLE)))
26 ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
27 ifneq ($(HOST_OS),Darwin)
28 define Image/cmdline/squashfs
29 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootwait
32 define Image/cmdline/jffs2-64k
33 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
36 define Image/cmdline/jffs2-128k
37 block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
40 define Image/cmdline/ext2
41 root=$(ROOTPART) rootfstype=ext2 rootwait
44 define Image/Build/grub
45 # left here because the image builder doesnt need these
46 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
49 $(KDIR)/root.grub/boot/grub/
50 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
52 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
53 -e 's#@CONSOLE@#$(CONSOLE)#g' \
54 -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
55 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
56 PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_x86.sh $(BIN_DIR)/openwrt-$(BOARD)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) $(KDIR)/root.grub $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
57 $(call Image/Build/grub/$(1))
60 define Image/Prepare/grub
61 # for the image builder
63 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/stage1 \
64 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/stage2 \
65 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/e2fs_stage1_5 \
69 define Image/Build/grub
70 PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" NOGRUB=1 ./gen_image_x86.sh $(BIN_DIR)/openwrt-$(BOARD)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) "" $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
75 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
76 define Image/Build/vdi
77 # left here because the image builder doesnt need these
79 rm $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi || true
80 VBoxManage convertfromraw -format VDI $(BIN_DIR)/openwrt-$(BOARD)-ext2.image $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi
85 ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
86 define Image/Build/vmdk
87 # left here because the image builder doesnt need these
89 rm $(BIN_DIR)/openwrt-$(BOARD)-ext2.vmdk || true
90 qemu-img convert -f raw $(BIN_DIR)/openwrt-$(BOARD)-ext2.image \
91 -O vmdk $(BIN_DIR)/openwrt-$(BOARD)-ext2.vmdk
98 ifeq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES),y)
99 define Image/cmdline/squashfs
100 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootdelay=$(ROOTDELAY)
103 define Image/cmdline/jffs2-64k
104 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootdelay=$(ROOTDELAY)
107 define Image/cmdline/jffs2-128k
108 block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootdelay=$(ROOTDELAY)
111 define Image/cmdline/ext2
112 root=$(ROOTPART) rootfstype=ext2 rootwait
115 define Image/Build/bootscript
116 # left here because the image builder doesnt need these
117 $(INSTALL_DIR) $(KDIR)/root.bootscript/boot
118 $(CP) $(KDIR)/bzImage $(KDIR)/root.bootscript/boot/vmlinuz
119 sed -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
120 ./olpc.fth > $(KDIR)/root.bootscript/boot/olpc.fth
121 PADDING="$(CONFIG_OLPC_BOOTSCRIPT_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_olpc.sh $(BIN_DIR)/openwrt-$(BOARD)-$(1).image $(CONFIG_OLPC_BOOTSCRIPT_KERNELPART) $(KDIR)/root.bootscript $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
126 $(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
127 ifeq ($(CONFIG_TARGET_x86_olpc),y)
128 $(call Image/Prepare/bootscript)
130 $(call Image/Prepare/grub)
134 define Image/Build/squashfs
135 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
138 define Image/Build/iso
139 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
141 $(STAGING_DIR_HOST)/usr/lib/grub/i386-openwrt/stage2_eltorito \
142 $(KDIR)/root.grub/boot/grub/stage2_eltorito
144 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
145 -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
146 -e 's#(hd0,0)#(cd)#g' \
147 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
148 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
149 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
150 -o $(KDIR)/root.iso $(KDIR)/root.grub
153 define Image/BuildKernel
154 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
158 $(call Image/Build/$(1))
159 $(call Image/Build/bootscript,$(1))
161 $(call Image/Build/grub,$(1))
162 $(call Image/Build/vdi,$(1))
163 $(call Image/Build/vmdk,$(1))
165 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1).fs
166 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
168 gzip -f9 $(BIN_DIR)/openwrt-$(BOARD)-$(1).image
172 $(eval $(call BuildImage))
174 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
175 $(eval $(call RequireCommand,VBoxManage, \
176 You need VBoxManage to generate VirtualBox images. \
180 ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
181 $(eval $(call RequireCommand,qemu-img, \
182 You need qemu-img to generate VMware images. \