[kernel] update to 2.6.27.35
[openwrt.git] / target / linux / x86 / image / Makefile
1 #
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 export PATH=$(TARGET_PATH):/sbin
11 BOOTOPTS=$(strip $(subst ",, $(CONFIG_X86_GRUB_BOOTOPTS)))
12 ROOTPART=$(strip $(subst ",, $(CONFIG_X86_GRUB_ROOTPART)))
13 #"))")) # fix vim's broken syntax highlighting
14
15
16 ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
17 ifneq ($(HOST_OS),Darwin)
18 define Image/cmdline/squashfs
19 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs
20 endef
21
22 define Image/cmdline/jffs2-64k
23 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2
24 endef
25
26 define Image/cmdline/jffs2-128k
27 block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2
28 endef
29
30 define Image/cmdline/ext2
31 root=$(ROOTPART) rootfstype=ext2
32 endef
33
34 define Image/Build/grub
35 # left here because the image builder doesnt need these
36 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
37 $(CP) \
38 $(KDIR)/*stage* \
39 $(KDIR)/root.grub/boot/grub/
40 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
41 sed \
42 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
43 -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
44 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
45 PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) $(KDIR)/root.grub $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
46 $(call Image/Build/grub/$(1))
47 endef
48
49 define Image/Prepare/grub
50 # for the image builder
51 $(CP) \
52 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/stage1 \
53 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/stage2 \
54 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/e2fs_stage1_5 \
55 $(KDIR)/
56 endef
57 else
58 define Image/Build/grub
59 PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" NOGRUB=1 ./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) "" $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
60 endef
61 endif
62 endif
63
64 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
65 define Image/Build/vdi
66 # left here because the image builder doesnt need these
67 ifeq ($(1),ext2)
68 rm $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi || true
69 VBoxManage convertfromraw -format VDI $(BIN_DIR)/openwrt-$(BOARD)-ext2.image $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi
70 endif
71 endef
72 endif
73
74 ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
75 define Image/Build/vmdk
76 # left here because the image builder doesnt need these
77 ifeq ($(1),ext2)
78 rm $(BIN_DIR)/openwrt-$(BOARD)-ext2.vmdk || true
79 qemu-img convert -f raw $(BIN_DIR)/openwrt-$(BOARD)-ext2.image \
80 -O vmdk $(BIN_DIR)/openwrt-$(BOARD)-ext2.vmdk
81 endif
82 endef
83 endif
84
85 define Image/Prepare
86 $(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
87 $(call Image/Prepare/grub)
88 endef
89
90 define Image/Build/squashfs
91 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
92 endef
93
94 define Image/Build/iso
95 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
96 $(CP) \
97 $(STAGING_DIR_HOST)/usr/lib/grub/i386-openwrt/stage2_eltorito \
98 $(KDIR)/root.grub/boot/grub/stage2_eltorito
99 sed \
100 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
101 -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
102 -e 's#(hd0,0)#(cd)#g' \
103 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
104 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
105 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
106 -o $(KDIR)/root.iso $(KDIR)/root.grub
107 endef
108
109 define Image/BuildKernel
110 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
111 endef
112
113 define Image/Build
114 $(call Image/Build/$(1))
115 ifneq ($(1),iso)
116 $(call Image/Build/grub,$(1))
117 $(call Image/Build/vdi,$(1))
118 $(call Image/Build/vmdk,$(1))
119 endif
120 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1).fs
121 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
122 endef
123
124 $(eval $(call BuildImage))
125
126 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
127 $(eval $(call RequireCommand,VBoxManage, \
128 You need VBoxManage to generate VirtualBox images. \
129 ))
130 endif
131
132 ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
133 $(eval $(call RequireCommand,qemu-img, \
134 You need qemu-img to generate VMware images. \
135 ))
136 endif
This page took 0.048268 seconds and 5 git commands to generate.