e74b06dd4b887461a15fe2f63422466ab2663592
[openwrt/openwrt.git] / target / linux / octeon / image / Makefile
1 #
2 # Copyright (C) 2009-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 define Image/Prepare
11 # Workaround pre-SDK-1.9.0 u-boot versions not handling the .notes section
12 $(TARGET_CROSS)strip -R .notes $(KDIR)/vmlinux.elf -o $(KDIR)/vmlinux.elf.stripped
13 endef
14
15 define Image/BuildKernel/Template
16 $(CP) $(KDIR)/vmlinux.elf.stripped $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux.64
17 $(STAGING_DIR_HOST)/bin/patch-cmdline $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux.64 '$(strip $(2))'
18 md5sum $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux.64 | cut -d " " -f 1 | tee $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux.64.md5
19 endef
20
21 define Image/BuildKernel/Initramfs/Template
22 $(TARGET_CROSS)strip -R .notes $(KDIR)/vmlinux-initramfs.elf -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux-initramfs.elf
23 $(STAGING_DIR_HOST)/bin/patch-cmdline $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux-initramfs.elf '$(strip $(2))'
24 endef
25
26 ER_CMDLINE:=-mtdparts=phys_mapped_flash:640k(boot0)ro,640k(boot1)ro,64k(eeprom)ro block2mtd.block2mtd=/dev/mmcblk0p2,65536,rootfs,5 root=/dev/mtdblock3 rootfstype=squashfs rootwait
27 ERLITE_CMDLINE:=-mtdparts=phys_mapped_flash:512k(boot0),512k(boot1),64k@1024k(eeprom) block2mtd.block2mtd=/dev/sda2,65536,rootfs,5 root=/dev/mtdblock3 rootfstype=squashfs rootwait
28
29 define Image/BuildKernel
30 $(call Image/BuildKernel/Template,generic,)
31 $(call Image/BuildKernel/Template,er,$(ER_CMDLINE))
32 $(call Image/BuildKernel/Template,erlite,$(ERLITE_CMDLINE))
33 endef
34
35 define Image/BuildKernel/Initramfs
36 $(call Image/BuildKernel/Initramfs/Template,generic,)
37 $(call Image/BuildKernel/Initramfs/Template,er,$(ER_CMDLINE))
38 $(call Image/BuildKernel/Initramfs/Template,erlite,$(ERLITE_CMDLINE))
39 endef
40
41 define Image/Build/sysupgrade
42 mkdir -p $(KDIR)/sysupgrade-$(1)/
43 echo "BOARD=$(1)" > $(KDIR)/sysupgrade-$(1)/CONTROL
44 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(2)-vmlinux.64 $(KDIR)/sysupgrade-$(1)/kernel
45 $(CP) $(KDIR)/root.$(3) $(KDIR)/sysupgrade-$(1)/root
46 (cd $(KDIR); $(TAR) cvf \
47 $(BIN_DIR)/$(IMG_PREFIX)-$(1)-$(3)-sysupgrade.tar sysupgrade-$(1))
48 endef
49
50 define Image/Build/ext4
51 $(call Image/Build/sysupgrade,erlite,generic,ext4)
52 endef
53
54 define Image/Build/squashfs
55 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
56 $(call Image/Build/sysupgrade,er,er,squashfs)
57 $(call Image/Build/sysupgrade,erlite,erlite,squashfs)
58 endef
59
60 define Image/Build
61 $(call Image/Build/$(1))
62 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
63 endef
64
65 $(eval $(call BuildImage))