add new target 'oxnas'
[openwrt/openwrt.git] / target / linux / oxnas / image / Makefile
1 #
2 # Copyright (C) 2013 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 STG212_UBI_OPTS = -m 2048 -p 128KiB -s 512
11 STG212_UBIFS_OPTS = -m 2048 -e 126KiB -c 4096
12
13 KD20_UBI_OPTS = -m 2048 -p 128KiB -s 512
14 KD20_UBIFS_OPTS = -m 2048 -e 126KiB -c 4096
15
16 POGOPLUG_PRO_UBI_OPTS = -m 2048 -p 128KiB -s 512
17 POGOPLUG_PRO_UBIFS_OPTS = -m 2048 -e 126KiB -c 4096
18
19 POGOPLUG_V3_UBI_OPTS = -m 2048 -p 128KiB -s 512
20 POGOPLUG_V3_UBIFS_OPTS = -m 2048 -e 126KiB -c 4096
21
22 KDIR_TMP:=$(KDIR)/tmp
23 VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux
24 UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage
25
26 define sanitize_profile_name
27 $(shell echo $(PROFILE) | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')
28 endef
29
30 define Image/BuildKernel/Template
31 $(CP) $(LINUX_DIR)/arch/arm/boot/dts/ox820-$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
32
33 $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x60008000,0x60008000)
34 $(CP) $(KDIR)/fit-$(1).itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage.bin
35
36 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
37 $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage-initramfs,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x60008000,0x60008000,-initramfs)
38 $(CP) $(KDIR)/fit-$(1)-initramfs.itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage-initramfs.itb
39 if [ -e "$(BIN_DIR)/$(IMG_PREFIX)-ox820-u-boot.bin" ]; then \
40 ( dd if=$(BIN_DIR)/$(IMG_PREFIX)-ox820-u-boot.bin bs=128k conv=sync ; dd if=$(KDIR)/fit-$(1)-initramfs.itb bs=128k conv=sync ) \
41 > $(BIN_DIR)/$(IMG_PREFIX)-$(1)-u-boot-initramfs.itb; \
42 fi
43 endif
44
45 $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
46 $(call Image/BuildKernel/MkuImage, \
47 none, 0x60008000, 0x60008000, \
48 $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
49 $(BIN_DIR)/$(IMG_PREFIX)-uImage \
50 )
51
52 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
53 $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
54 $(call Image/BuildKernel/MkuImage, \
55 none, 0x60008000, 0x60008000, \
56 $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
57 $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
58 )
59 endif
60 endef
61
62 define Image/InstallKernel/Template
63
64 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL),)
65 $(INSTALL_DIR) $(TARGET_DIR)/boot
66 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE),)
67 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/
68 ln -sf $(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/uImage
69 endif
70 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE),)
71 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/
72 ln -sf $(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/zImage
73 endif
74 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_FIT),)
75 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage.itb $(TARGET_DIR)/boot/
76 ln -sf $(IMG_PREFIX)-$(1)-fit-uImage.itb $(TARGET_DIR)/boot/uImage.itb
77 endif
78 endif
79
80 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
81 $(INSTALL_DIR) $(TARGET_DIR)/boot
82 ifneq ($(1),)
83 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb $(TARGET_DIR)/boot/
84 ln -sf $(IMG_PREFIX)-$(1).dtb $(TARGET_DIR)/boot/$(1).dtb
85 endif
86 endif
87 endef
88
89 define Image/Build/squashfs
90 $(call Image/Build/SysupgradeNAND,$(call sanitize_profile_name),$(1),$(KDIR)/fit-$(call sanitize_profile_name).itb)
91 $(call Image/Build/UbinizeImage,$(call sanitize_profile_name),--uboot-env --kernel $(KDIR)/fit-$(call sanitize_profile_name).itb,$(1),$($(PROFILE)_UBI_OPTS))
92 endef
93
94 define Image/mkfs/targz
95
96 $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
97 endef
98
99 define Image/Build/ubifs
100
101 ifneq ($($(PROFILE)_UBIFS_OPTS),)
102 $(call Image/Build/SysupgradeNAND,$(call sanitize_profile_name),ubifs,$(KDIR)/fit-$(call sanitize_profile_name).itb)
103 $(call Image/Build/UbinizeImage,$(call sanitize_profile_name),--uboot-env --kernel $(KDIR)/fit-$(call sanitize_profile_name).itb,ubifs,$($(PROFILE)_UBI_OPTS))
104 endif
105
106 endef
107
108 Image/BuildKernel/Template/POGOPLUG_PRO=$(call Image/BuildKernel/Template,pogoplug-pro)
109 Image/InstallKernel/Template/POGOPLUG_PRO=$(call Image/InstallKernel/Template,pogoplug-pro)
110
111 Image/BuildKernel/Template/POGOPLUG_V3=$(call Image/BuildKernel/Template,pogoplug-v3)
112 Image/InstallKernel/Template/POGOPLUG_V3=$(call Image/InstallKernel/Template,pogoplug-v3)
113
114 Image/BuildKernel/Template/STG212=$(call Image/BuildKernel/Template,stg212)
115 Image/InstallKernel/Template/STG212=$(call Image/InstallKernel/Template,stg212)
116
117 Image/BuildKernel/Template/KD20=$(call Image/BuildKernel/Template,kd20)
118 Image/InstallKernel/Template/KD20=$(call Image/InstallKernel/Template,kd20)
119
120 define Image/BuildKernel
121 $(call Image/BuildKernel/Template/$(PROFILE))
122 endef
123
124 define Image/InstallKernel
125 $(call Image/InstallKernel/Template/$(PROFILE))
126 endef
127
128 define Image/Build
129 $(if $(Image/Build/$(1)), \
130 $(call Image/Build/$(1),$(1)), \
131 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
132 )
133 endef
134
135 $(eval $(call BuildImage))