7af434874e7ffd09dcada1bfcf12afe4711995c2
[openwrt/svn-archive/archive.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 define Image/cmdline/squashfs
18 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=squashfs init=/etc/preinit
19 endef
20
21 define Image/cmdline/jffs2-64k
22 block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 init=/etc/preinit
23 endef
24
25 define Image/cmdline/jffs2-128k
26 block2mtd.block2mtd=$(ROOTPART),131072,rootfs root=/dev/mtdblock0 rootfstype=jffs2 init=/etc/preinit
27 endef
28
29 define Image/cmdline/ext2
30 root=$(ROOTPART) rootfstype=ext2 init=/etc/preinit
31 endef
32
33 define Image/Build/grub
34 # left here because the image builder doesnt need these
35 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
36 $(CP) \
37 $(KDIR)/*stage* \
38 $(KDIR)/root.grub/boot/grub/
39 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
40 sed \
41 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
42 -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
43 ./menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
44 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)
45 $(call Image/Build/grub/$(1))
46 endef
47 endif
48
49 ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
50 define Image/Prepare/grub
51 # for the image builder
52 $(CP) \
53 $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage1 \
54 $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage2 \
55 $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/e2fs_stage1_5 \
56 $(KDIR)/
57 endef
58 endif
59
60 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
61 define Image/Build/vdi
62 # left here because the image builder doesnt need these
63 ifeq ($(1),ext2)
64 rm $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi || true
65 vditool DD $(BIN_DIR)/openwrt-$(BOARD)-ext2.vdi $(BIN_DIR)/openwrt-$(BOARD)-ext2.image
66 endif
67 endef
68 endif
69
70
71 define Image/Prepare
72 $(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
73 $(call Image/Prepare/grub)
74 endef
75
76 define Image/Build/squashfs
77 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
78 endef
79
80 define Image/Build/iso
81 $(CP) \
82 $(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage2_eltorito \
83 $(KDIR)/root.grub/boot/grub/stage2_eltorito
84 sed -i \
85 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
86 -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
87 -e 's#(hd0,0)#(cd)#g' \
88 $(KDIR)/root.grub/boot/grub/menu.lst
89 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
90 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
91 -o $(KDIR)/root.iso $(KDIR)/root.grub
92 endef
93
94 define Image/BuildKernel
95 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
96 endef
97
98 define Image/Build
99 $(call Image/Build/grub,$(1))
100 $(call Image/Build/vdi,$(1))
101 $(call Image/Build/$(1))
102 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1).fs
103 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-vmlinuz
104 endef
105
106 $(eval $(call BuildImage))
107
108 ifeq ($(CONFIG_X86_VDI_IMAGES),y)
109 $(eval $(call RequireCommand,vditool, \
110 You need vditool to generate VirtualBox images. \
111 ))
112 endif
113