mpc85xx: Fix building ramdisk images
[openwrt/staging/chunkeey.git] / target / linux / mpc85xx / image / Makefile
1 #
2 # Copyright (C) 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 imgname
11 $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
12 endef
13
14 define sysupname
15 $(call imgname,$(1),$(2))-sysupgrade.bin
16 endef
17
18 define factoryname
19 $(call imgname,$(1),$(2))-factory.bin
20 endef
21
22 zImage:=$(BIN_DIR)/$(IMG_PREFIX)-zImage
23
24 DTS_TARGETS = mpc8548cds_32b p1010rdb tl-wdr4900-v1 p1020rdb
25 BOOT_IMAGES:=zImage cuImage.tl-wdr4900-v1
26
27 define Image/Prepare
28 $(foreach image,$(BOOT_IMAGES),
29 cp $(LINUX_DIR)/arch/powerpc/boot/$(image) $(KDIR)/$(image)
30 )
31 endef
32
33 define Image/BuildKernel
34 cp $(KDIR)/zImage $(zImage)
35 $(foreach dts,$(DTS_TARGETS),
36 $(LINUX_DIR)/scripts/dtc/dtc -I dts -O dtb $(LINUX_DIR)/arch/powerpc/boot/dts/$(dts).dts > $(BIN_DIR)/$(IMG_PREFIX)-$(dts).fdt
37 )
38 endef
39
40 define Image/Build/TPLINK
41 -$(STAGING_DIR_HOST)/bin/mktplinkfw \
42 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) $(7) \
43 -k $(KDIR)/$(3) \
44 -r $(KDIR)/root.$(1) \
45 -o $(call factoryname,$(1),$(2))
46 -$(STAGING_DIR_HOST)/bin/mktplinkfw \
47 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) $(7) -s \
48 -k $(KDIR)/$(3) \
49 -r $(KDIR)/root.$(1) \
50 -o $(call sysupname,$(1),$(2))
51 endef
52
53 define Image/Build/Profile/TLWDR4900
54 $(call Image/Build/TPLINK,$(1),tl-wdr4900-v1,cuImage.tl-wdr4900-v1,0x49000001,1,16Mppc)
55 endef
56
57 define Image/Build/Profile/Default
58 $(call Image/Build/Profile/TLWDR4900,$(1))
59 endef
60
61 define Image/Build/ext2
62 cp $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-ext2.img
63 endef
64
65 define Image/Build/squashfs
66 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
67 cp $(KDIR)/root.squashfs $(BIN_DIR)/$(IMG_PREFIX)-root.squashfs
68 endef
69
70 PROFILE ?= Default
71
72 define Image/Build
73 $(call Image/Build/$(1),$(1))
74 $(call Image/Build/Profile/$(PROFILE),$(1))
75 endef
76
77 $(eval $(call BuildImage))