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