targets: prepare for supporting normal and initramfs images
[openwrt/openwrt.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 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
23 IMAGE_SUFFIX=-initramfs
24 endif
25
26 zImage:=$(BIN_DIR)/$(IMG_PREFIX)-zImage$(IMAGE_SUFFIX)
27
28 DTS_TARGETS = mpc8548cds_32b p1010rdb tl-wdr4900-v1 p1020rdb
29 BOOT_IMAGES:=zImage cuImage.tl-wdr4900-v1
30
31 define Image/Prepare
32 $(foreach image,$(BOOT_IMAGES),
33 cp $(LINUX_DIR)/arch/powerpc/boot/$(image) $(KDIR)/$(image)
34 )
35 endef
36
37 define Image/BuildKernel
38 cp $(KDIR)/zImage$(IMAGE_SUFFIX) $(zImage)
39 $(foreach dts,$(DTS_TARGETS),
40 $(LINUX_DIR)/scripts/dtc/dtc -I dts -O dtb $(LINUX_DIR)/arch/powerpc/boot/dts/$(dts).dts > $(BIN_DIR)/$(IMG_PREFIX)-$(dts).fdt
41 )
42 endef
43
44 define Image/Build/TPLINK
45 -$(STAGING_DIR_HOST)/bin/mktplinkfw \
46 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) $(7) \
47 -k $(KDIR)/$(3) \
48 -r $(KDIR)/root.$(1) \
49 -o $(call factoryname,$(1),$(2))
50 -$(STAGING_DIR_HOST)/bin/mktplinkfw \
51 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) $(7) -s \
52 -k $(KDIR)/$(3) \
53 -r $(KDIR)/root.$(1) \
54 -o $(call sysupname,$(1),$(2))
55 endef
56
57 define Image/Build/Profile/TLWDR4900
58 $(call Image/Build/TPLINK,$(1),tl-wdr4900-v1,cuImage.tl-wdr4900-v1,0x49000001,1,16Mppc)
59 endef
60
61 define Image/Build/Profile/Default
62 $(call Image/Build/Profile/TLWDR4900,$(1))
63 endef
64
65 define Image/Build/ext2
66 cp $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-ext2.img
67 endef
68
69 define Image/Build/squashfs
70 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
71 cp $(KDIR)/root.squashfs $(BIN_DIR)/$(IMG_PREFIX)-root.squashfs
72 endef
73
74 PROFILE ?= Default
75
76 define Image/Build
77 $(call Image/Build/$(1),$(1))
78 $(call Image/Build/Profile/$(PROFILE),$(1))
79 endef
80
81 $(eval $(call BuildImage))