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