Make the grub timeout configurable on x86 targets
[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 GRUB_TERMINALS =
13 GRUB_SERIAL_CONFIG =
14 GRUB_TERMINAL_CONFIG =
15 GRUB_CONSOLE_CMDLINE =
16
17 ifneq ($(CONFIG_X86_GRUB_CONSOLE),)
18 GRUB_CONSOLE_CMDLINE += console=tty0
19 GRUB_TERMINALS += console
20 endif
21
22 ifneq ($(CONFIG_X86_GRUB_SERIAL),)
23 GRUB_CONSOLE_CMDLINE += console=$(call qstrip,$(CONFIG_X86_GRUB_SERIAL)),$(CONFIG_X86_GRUB_BAUDRATE)n8
24 GRUB_SERIAL_CONFIG := serial --unit=0 --speed=$(CONFIG_X86_GRUB_BAUDRATE) --word=8 --parity=no --stop=1
25 GRUB_TERMINALS += serial
26 endif
27
28 ifneq ($(GRUB_TERMINALS),)
29 GRUB_TERMINAL_CONFIG := terminal --timeout=2 $(GRUB_TERMINALS)
30 endif
31
32 ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
33
34 GRUB_TIMEOUT:=$(call qstrip,$(CONFIG_X86_GRUB_TIMEOUT))
35
36 ifneq ($(CONFIG_X86_GRUB_IMAGES),)
37
38 BOOTOPTS:=$(call qstrip,$(CONFIG_X86_GRUB_BOOTOPTS))
39
40 define Image/cmdline/ext4
41 root=$(ROOTPART) rootfstype=ext4 rootwait
42 endef
43
44 define Image/cmdline/jffs2-64k
45 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
46 endef
47
48 define Image/cmdline/jffs2-128k
49 block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
50 endef
51
52 define Image/cmdline/squashfs
53 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootwait
54 endef
55
56 define Image/Build/grub
57 # left here because the image builder doesnt need these
58 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
59 $(CP) \
60 $(KDIR)/stage1 \
61 $(KDIR)/stage2 \
62 $(KDIR)/e2fs_stage1_5 \
63 $(KDIR)/root.grub/boot/grub/
64 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
65 sed \
66 -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
67 -e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
68 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
69 -e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
70 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
71 PADDING="$(CONFIG_TARGET_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_x86.sh \
72 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
73 $(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/root.grub \
74 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1)
75 $(call Image/Build/grub/$(1))
76 endef
77
78 define Image/Prepare/grub
79 # for the image builder
80 $(CP) \
81 $(STAGING_DIR)/usr/lib/grub/i386-openwrt/stage1 \
82 $(STAGING_DIR)/usr/lib/grub/i386-openwrt/stage2 \
83 $(STAGING_DIR)/usr/lib/grub/i386-openwrt/stage2_eltorito \
84 $(STAGING_DIR)/usr/lib/grub/i386-openwrt/e2fs_stage1_5 \
85 $(KDIR)/
86 endef
87
88 endif
89
90 ROOTDELAY=10
91
92 ifneq ($(CONFIG_OLPC_BOOTSCRIPT_IMAGES),)
93
94 define Image/cmdline/ext4
95 root=$(ROOTPART) rootfstype=ext4 rootwait
96 endef
97
98 define Image/cmdline/jffs2-64k
99 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootdelay=$(ROOTDELAY)
100 endef
101
102 define Image/cmdline/jffs2-128k
103 block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootdelay=$(ROOTDELAY)
104 endef
105
106 define Image/cmdline/squashfs
107 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs rootdelay=$(ROOTDELAY)
108 endef
109
110 define Image/Build/bootscript
111 # left here because the image builder doesnt need these
112 $(INSTALL_DIR) $(KDIR)/root.bootscript/boot
113 $(CP) $(KDIR)/bzImage $(KDIR)/root.bootscript/boot/vmlinuz
114 sed -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
115 ./olpc.fth > $(KDIR)/root.bootscript/boot/olpc.fth
116 PADDING="$(CONFIG_TARGET_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image_olpc.sh \
117 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
118 $(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/root.bootscript \
119 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1)
120 endef
121
122 endif
123
124 define Image/Build/squashfs
125 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
126 endef
127
128 define Image/Build/iso
129 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
130 $(CP) \
131 $(KDIR)/stage2_eltorito \
132 $(KDIR)/root.grub/boot/grub/
133 sed \
134 -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
135 -e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
136 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
137 -e 's#(hd0,0)#(cd)#g' \
138 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
139 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
140 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
141 -o $(KDIR)/root.iso $(KDIR)/root.grub
142 endef
143
144 ifneq ($(CONFIG_X86_VDI_IMAGES),)
145 define Image/Build/vdi
146 # left here because the image builder doesnt need these
147 ifeq ($(1),ext4)
148 rm $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vdi || true
149 qemu-img convert -f raw -O vdi \
150 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
151 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vdi
152 # XXX: VBoxManage insists on setting perms to 0600
153 chmod 0644 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vdi
154 endif
155 endef
156 endif
157
158 ifneq ($(CONFIG_X86_VMDK_IMAGES),)
159 define Image/Build/vmdk
160 # left here because the image builder doesnt need these
161 ifeq ($(1),ext4)
162 rm $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vmdk || true
163 qemu-img convert -f raw -O vmdk \
164 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \
165 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vmdk
166 endif
167 endef
168 endif
169
170 define Image/BuildKernel
171 $(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz
172 ifneq ($(CONFIG_X86_ETHERBOOT_IMAGES),)
173 rm -f $(BIN_DIR)/$(IMG_PREFIX)-etherboot
174 $(STAGING_DIR_HOST)/bin/mkelfImage \
175 --append=$(CONFIG_X86_ETHERBOOT_BOOTOPTS) \
176 $(KDIR)/bzImage \
177 $(BIN_DIR)/$(IMG_PREFIX)-etherboot
178 endif
179 endef
180
181 define Image/Prepare
182 $(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
183 $(call Image/Prepare/bootscript)
184 $(call Image/Prepare/grub)
185 endef
186
187 define Image/Build
188 $(call Image/Build/$(1))
189 $(call Image/Build/bootscript,$(1))
190 ifneq ($(1),iso)
191 $(call Image/Build/grub,$(1))
192 $(call Image/Build/vdi,$(1))
193 $(call Image/Build/vmdk,$(1))
194 endif
195 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img
196 $(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz
197 ifneq (,$findstring($(1),ext4 jffs2))
198 gzip -f9 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img
199 gzip -f9 $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img
200 endif
201 endef
202
203 $(eval $(call BuildImage))
This page took 0.060315 seconds and 5 git commands to generate.