replace old quote stripping with calls to qstrip macro
[openwrt.git] / target / linux / x86 / image / Makefile
1 #
2 # Copyright (C) 2006-2010 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
12 ifneq ($(CONFIG_TARGET_x86_olpc),y)
13 BOOTOPTS=$(call qstrip,$(CONFIG_X86_GRUB_BOOTOPTS))
14 ROOTPART=$(call qstrip,$(CONFIG_X86_GRUB_ROOTPART))
15 endif
16
17 ifeq ($(CONFIG_TARGET_x86_olpc),y)
18 ROOTPART=$(call qstrip,$(CONFIG_OLPC_BOOTSCRIPT_ROOTPART))
19 endif
20
21 GRUB_TERMINALS =
22 GRUB_SERIAL_CONFIG =
23 GRUB_TERMINAL_CONFIG =
24 GRUB_CONSOLE_CMDLINE =
25
26 ifeq ($(CONFIG_X86_GRUB_CONSOLE),y)
27 GRUB_CONSOLE_CMDLINE += console=tty0
28 GRUB_TERMINALS += console
29 endif
30
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
35 endif
36
37 ifneq ($(GRUB_TERMINALS),)
38 GRUB_TERMINAL_CONFIG = terminal --timeout=2 $(GRUB_TERMINALS)
39 endif
40
41
42 ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
43 ifneq ($(HOST_OS),Darwin)
44 define Image/cmdline/squashfs
45 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootwait
46 endef
47
48 define Image/cmdline/jffs2-64k
49 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
50 endef
51
52 define Image/cmdline/jffs2-128k
53 block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
54 endef
55
56 define Image/cmdline/ext2
57 root=$(ROOTPART) rootfstype=ext2 rootwait
58 endef
59
60 define Image/Build/grub
61 # left here because the image builder doesnt need these
62 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
63 $(CP) \
64 $(KDIR)/*stage* \
65 $(KDIR)/root.grub/boot/grub/
66 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
67 sed \
68 -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
69 -e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
70 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
71 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
72 PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_x86.sh $(BIN_DIR)/$(IMG_PREFIX)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) $(KDIR)/root.grub $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
73 $(call Image/Build/grub/$(1))
74 endef
75
76 define Image/Prepare/grub
77 # for the image builder
78 $(CP) \
79 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/stage1 \
80 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/stage2 \
81 $(STAGING_DIR_HOST)/usr/lib/grub/i386-*/e2fs_stage1_5 \
82 $(KDIR)/
83 endef
84 else
85 define Image/Build/grub
86 PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" NOGRUB=1 ./gen_image_x86.sh $(BIN_DIR)/$(IMG_PREFIX)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) "" $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
87 endef
88 endif
89 endif
90
91 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
92 define Image/Build/vdi
93 # left here because the image builder doesnt need these
94 ifeq ($(1),ext2)
95 rm $(BIN_DIR)/$(IMG_PREFIX)-ext2.vdi || true
96 VBoxManage convertfromraw -format VDI $(BIN_DIR)/$(IMG_PREFIX)-ext2.image $(BIN_DIR)/$(IMG_PREFIX)-ext2.vdi
97 endif
98 endef
99 endif
100
101 ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
102 define Image/Build/vmdk
103 # left here because the image builder doesnt need these
104 ifeq ($(1),ext2)
105 rm $(BIN_DIR)/$(IMG_PREFIX)-ext2.vmdk || true
106 qemu-img convert -f raw $(BIN_DIR)/$(IMG_PREFIX)-ext2.image \
107 -O vmdk $(BIN_DIR)/$(IMG_PREFIX)-ext2.vmdk
108 endif
109 endef
110 endif
111
112 ROOTDELAY=10
113
114 ifeq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES),y)
115 define Image/cmdline/squashfs
116 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootdelay=$(ROOTDELAY)
117 endef
118
119 define Image/cmdline/jffs2-64k
120 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootdelay=$(ROOTDELAY)
121 endef
122
123 define Image/cmdline/jffs2-128k
124 block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootdelay=$(ROOTDELAY)
125 endef
126
127 define Image/cmdline/ext2
128 root=$(ROOTPART) rootfstype=ext2 rootwait
129 endef
130
131 define Image/Build/bootscript
132 # left here because the image builder doesnt need these
133 $(INSTALL_DIR) $(KDIR)/root.bootscript/boot
134 $(CP) $(KDIR)/bzImage $(KDIR)/root.bootscript/boot/vmlinuz
135 sed -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
136 ./olpc.fth > $(KDIR)/root.bootscript/boot/olpc.fth
137 PADDING="$(CONFIG_OLPC_BOOTSCRIPT_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_olpc.sh $(BIN_DIR)/$(IMG_PREFIX)-$(1).image $(CONFIG_OLPC_BOOTSCRIPT_KERNELPART) $(KDIR)/root.bootscript $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
138 endef
139 endif
140
141 define Image/Prepare
142 $(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
143 ifeq ($(CONFIG_TARGET_x86_olpc),y)
144 $(call Image/Prepare/bootscript)
145 else
146 $(call Image/Prepare/grub)
147 endif
148 endef
149
150 define Image/Build/squashfs
151 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
152 endef
153
154 define Image/Build/iso
155 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
156 $(CP) \
157 $(STAGING_DIR_HOST)/usr/lib/grub/i386-openwrt/stage2_eltorito \
158 $(KDIR)/root.grub/boot/grub/stage2_eltorito
159 sed \
160 -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
161 -e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
162 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
163 -e 's#(hd0,0)#(cd)#g' \
164 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
165 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
166 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
167 -o $(KDIR)/root.iso $(KDIR)/root.grub
168 endef
169
170 define Image/BuildKernel
171 $(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz
172 endef
173
174 define Image/Build
175 $(call Image/Build/$(1))
176 $(call Image/Build/bootscript,$(1))
177 ifneq ($(1),iso)
178 $(call Image/Build/grub,$(1))
179 $(call Image/Build/vdi,$(1))
180 $(call Image/Build/vmdk,$(1))
181 endif
182 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).fs
183 $(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz
184 ifeq ($(1),ext2)
185 gzip -f9 $(BIN_DIR)/$(IMG_PREFIX)-$(1).image
186 endif
187 endef
188
189 $(eval $(call BuildImage))
190
191 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
192 $(eval $(call RequireCommand,VBoxManage, \
193 You need VBoxManage to generate VirtualBox images. \
194 ))
195 endif
196
197 ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
198 $(eval $(call RequireCommand,qemu-img, \
199 You need qemu-img to generate VMware images. \
200 ))
201 endif
This page took 0.048594 seconds and 5 git commands to generate.