2 # Copyright (C) 2006 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 ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
24 ifneq ($(HOST_OS),Darwin)
25 define Image/cmdline/squashfs
26 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs
29 define Image/cmdline/jffs2-64k
30 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2
33 define Image/cmdline/jffs2-128k
34 block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2
37 define Image/cmdline/ext2
38 root=$(ROOTPART) rootfstype=ext2
41 define Image/Build/grub
42 # left here because the image builder doesnt need these
43 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
46 $(KDIR)/root.grub/boot/grub/
47 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
49 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
50 -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
51 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
52 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)
53 $(call Image/Build/grub/$(1))
56 define Image/Prepare/grub
57 # for the image builder
59 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/stage1 \
60 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/stage2 \
61 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/e2fs_stage1_5 \
65 define Image/Build/grub
66 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)
71 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
72 define Image/Build/vdi
73 # left here because the image builder doesnt need these
75 rm $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi || true
76 VBoxManage convertfromraw -format VDI $(BIN_DIR)/openwrt-$(BOARD)-ext2.image $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi
81 ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
82 define Image/Build/vmdk
83 # left here because the image builder doesnt need these
85 rm $(BIN_DIR)/openwrt-$(BOARD)-ext2.vmdk || true
86 qemu-img convert -f raw $(BIN_DIR)/openwrt-$(BOARD)-ext2.image \
87 -O vmdk $(BIN_DIR)/openwrt-$(BOARD)-ext2.vmdk
94 ifeq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES),y)
95 define Image/cmdline/squashfs
96 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootdelay=$(ROOTDELAY)
99 define Image/cmdline/jffs2-64k
100 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootdelay=$(ROOTDELAY)
103 define Image/cmdline/jffs2-128k
104 block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootdelay=$(ROOTDELAY)
107 define Image/cmdline/ext2
108 root=$(ROOTPART) rootfstype=ext2 rootwait
111 define Image/Build/bootscript
112 # left here because the image builder doesnt need these
113 $(INSTALL_DIR) $(KDIR)/root.bootscript/boot
114 $(CP) $(KDIR)/bzImage $(KDIR)/root.bootscript/boot/vmlinuz
115 sed -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
116 ./olpc.fth > $(KDIR)/root.bootscript/boot/olpc.fth
117 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)
122 $(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
123 ifeq ($(CONFIG_TARGET_x86_olpc),y)
124 $(call Image/Prepare/bootscript)
126 $(call Image/Prepare/grub)
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
137 $(STAGING_DIR_HOST)/usr/lib/grub/i386-openwrt/stage2_eltorito \
138 $(KDIR)/root.grub/boot/grub/stage2_eltorito
140 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
141 -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
142 -e 's#(hd0,0)#(cd)#g' \
143 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
144 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
145 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
146 -o $(KDIR)/root.iso $(KDIR)/root.grub
149 define Image/BuildKernel
150 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
154 $(call Image/Build/$(1))
155 $(call Image/Build/bootscript,$(1))
157 $(call Image/Build/grub,$(1))
158 $(call Image/Build/vdi,$(1))
159 $(call Image/Build/vmdk,$(1))
161 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1).fs
162 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
165 $(eval $(call BuildImage))
167 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
168 $(eval $(call RequireCommand,VBoxManage, \
169 You need VBoxManage to generate VirtualBox images. \
173 ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
174 $(eval $(call RequireCommand,qemu-img, \
175 You need qemu-img to generate VMware images. \