bb7d171faf095c1d51f945da23462d928b256845
[openwrt/openwrt.git] / target / linux / x86-2.6 / 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 ROOTPART=$(strip $(subst ",, $(CONFIG_X86_GRUB_ROOTPART)))
12 #")) # fix vim's broken syntax highlighting
13
14
15 ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
16 define Build/Compile
17 $(MAKE) -C grub compile
18 endef
19
20 define Build/Clean
21 $(MAKE) -C grub clean
22 endef
23
24 define Image/cmdline/jffs2-64k
25 block2mtd.block2mtd=$(ROOTPART),65536 root=/dev/mtdblock0 rootfstype=jffs2
26 endef
27
28 define Image/cmdline/jffs2-128k
29 block2mtd.block2mtd=$(ROOTPART),131072 root=/dev/mtdblock0 rootfstype=jffs2
30 endef
31
32 define Image/cmdline/ext2
33 root=$(ROOTPART) rootfstype=ext2
34 endef
35
36 define Image/Build/grub
37 # left here because the image builder doesnt need these
38 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
39 $(CP) \
40 $(KDIR)/*stage* \
41 $(KDIR)/root.grub/boot/grub/
42 $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
43 sed \
44 -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(CONFIG_X86_GRUB_BOOTOPTS)#g' \
45 -e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
46 ./grub/menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
47 PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(STAGING_DIR)/usr/sbin:$(STAGING_DIR)/bin:$(PATH)" ./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) $(KDIR)/root.grub $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
48 endef
49 endif
50
51 ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
52 define Image/Prepare/grub
53 # for the image builder
54 $(CP) \
55 $(STAGING_DIR)/usr/lib/grub/i386-pc/stage1 \
56 $(STAGING_DIR)/usr/lib/grub/i386-pc/stage2 \
57 $(STAGING_DIR)/usr/lib/grub/i386-pc/e2fs_stage1_5 \
58 $(KDIR)/
59 $(CP) $(STAGING_DIR)/usr/sbin/grub $(STAGING_DIR)/bin
60 endef
61 endif
62
63 define Image/Prepare
64 $(CP) $(LINUX_DIR)/arch/i386/boot/bzImage $(KDIR)/bzImage
65 $(call Image/Prepare/grub)
66 endef
67
68 define Image/Build
69 $(call Image/Build/grub,$(1))
70 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).fs
71 $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz
72 endef
73
74 $(eval $(call BuildImage))