source: branches/backfire/target/linux/x86/image/Makefile @ 21324

Last change on this file since 21324 was 21324, checked in by nico, 6 years ago

[backfire] merge r21242

  • Property svn:eol-style set to native
File size: 6.3 KB
Line 
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#
7include $(TOPDIR)/rules.mk
8include $(INCLUDE_DIR)/image.mk
9
10export PATH=$(TARGET_PATH):/sbin
11
12ifneq ($(CONFIG_TARGET_x86_olpc),y)
13BOOTOPTS=$(call qstrip,$(CONFIG_X86_GRUB_BOOTOPTS))
14ROOTPART=$(call qstrip,$(CONFIG_X86_GRUB_ROOTPART))
15endif
16
17ifeq ($(CONFIG_TARGET_x86_olpc),y)
18ROOTPART=$(call qstrip,$(CONFIG_OLPC_BOOTSCRIPT_ROOTPART))
19endif
20
21GRUB_TERMINALS =
22GRUB_SERIAL_CONFIG =
23GRUB_TERMINAL_CONFIG =
24GRUB_CONSOLE_CMDLINE =
25
26ifeq ($(CONFIG_X86_GRUB_CONSOLE),y)
27GRUB_CONSOLE_CMDLINE += console=tty0
28GRUB_TERMINALS += console
29endif
30
31ifneq ($(CONFIG_X86_GRUB_SERIAL),)
32GRUB_CONSOLE_CMDLINE += console=$(call qstrip,$(CONFIG_X86_GRUB_SERIAL)),$(CONFIG_X86_GRUB_BAUDRATE)n8
33GRUB_SERIAL_CONFIG = serial --unit=0 --speed=$(CONFIG_X86_GRUB_BAUDRATE) --word=8 --parity=no --stop=1
34GRUB_TERMINALS += serial
35endif
36
37ifneq ($(GRUB_TERMINALS),)
38GRUB_TERMINAL_CONFIG = terminal --timeout=2 $(GRUB_TERMINALS)
39endif
40
41
42ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
43ifneq ($(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
84else
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
88endif
89endif
90
91ifeq ($(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
99endif
100
101ifeq ($(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
110endif
111
112ROOTDELAY=10
113
114ifeq ($(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
139endif
140
141define Image/Prepare
142        $(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
143ifeq ($(CONFIG_TARGET_x86_olpc),y)
144        $(call Image/Prepare/bootscript)
145else
146        $(call Image/Prepare/grub)
147endif
148endef
149
150define Image/Build/squashfs
151    $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
152endef
153
154define 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
168endef
169
170define Image/BuildKernel
171        $(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz
172endef
173
174define 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
187endef
188
189$(eval $(call BuildImage))
190
191ifeq ($(CONFIG_X86_VDI_IMAGES),y)
192  $(eval $(call RequireCommand,VBoxManage, \
193        You need VBoxManage to generate VirtualBox images. \
194  ))
195endif
196
197ifeq ($(CONFIG_X86_VMDK_IMAGES),y)
198   $(eval $(call RequireCommand,qemu-img, \
199        You need qemu-img to generate VMware images. \
200   ))
201endif
Note: See TracBrowser for help on using the repository browser.