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 ifeq ($(CONFIG_TARGET_x86_generic
),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_generic),y)
124 $(call Image/Prepare/grub)
126 ifeq ($(CONFIG_TARGET_x86_olpc),y)
127 $(call Image/Prepare/bootscript)
131 define Image/Build/squashfs
132 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
135 define Image/Build/iso
136 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
138 $(STAGING_DIR_HOST)/usr/lib/grub/i386-openwrt/stage2_eltorito \
139 $(KDIR)/root.grub/boot/grub/stage2_eltorito
141 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
142 -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
143 -e 's#(hd0,0)#(cd)#g' \
144 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
145 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
146 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
147 -o $(KDIR)/root.iso $(KDIR)/root.grub
150 define Image/BuildKernel
151 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
155 $(call Image/Build/$(1))
156 $(call Image/Build/bootscript,$(1))
158 $(call Image/Build/grub,$(1))
159 $(call Image/Build/vdi,$(1))
160 $(call Image/Build/vmdk,$(1))
162 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1).fs
163 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
166 $(eval $(call BuildImage))
168 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
169 $(eval $(call RequireCommand,VBoxManage, \
170 You need VBoxManage to generate VirtualBox images. \
174 ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
175 $(eval $(call RequireCommand,qemu-img, \
176 You need qemu-img to generate VMware images. \