[runtime/api] Update I/O buffer set function comment (#9322)
[platform/core/ml/nnfw.git] / Makefile.template
1 HOST_ARCH?=$(shell uname -p)
2 TARGET_ARCH?=$(shell uname -p)
3 BUILD_TYPE?=Debug
4 CROSS_BUILD?=0
5 HOST_OS?=linux
6 TARGET_OS?=linux
7 PARALLEL_BUILD?=1
8 COVERAGE_BUILD?=0
9 BENCHMARK_ACL_BUILD?=0
10 OPTIONS?=
11
12 # make TARGET and TYPE to lowercase
13 HOST_ARCH_LC=$(shell echo $(HOST_ARCH) | tr A-Z a-z)
14 TARGET_ARCH_LC=$(shell echo $(TARGET_ARCH) | tr A-Z a-z)
15 BUILD_TYPE_LC=$(shell echo $(BUILD_TYPE) | tr A-Z a-z)
16 # we need base name 'arm` for all arm arch
17 TARGET_ARCH_BASE=$(TARGET_ARCH_LC)
18 ifneq (,$(findstring arm64,$(TARGET_ARCH_BASE)))
19         # arm64 as target-arch comes from Android
20         TARGET_ARCH_BASE=arm64
21         # For now Android is the only option for arm64
22         TARGET_OS:=android
23 else ifneq (,$(findstring arm,$(TARGET_ARCH_BASE)))
24         TARGET_ARCH_BASE=arm
25 else ifneq (,$(findstring aarch64,$(TARGET_ARCH_BASE)))
26         # aarch64 as target-arch comes from all except for Android
27         TARGET_ARCH_BASE=aarch64
28 endif
29 # Set CROSS_BUILD=1 when ROOTFS_DIR is given, and TARGET_ARCH is different to HOST_ARCH.
30 ifneq ($(ROOTFS_DIR),)
31 ifneq ($(TARGET_ARCH_LC),$(HOST_ARCH_LC))
32   CROSS_BUILD=$(if $(wildcard $(ROOTFS_DIR)),1,0)
33 endif
34 endif
35 # the toolchain file, only for cross build
36 ifeq ($(CROSS_BUILD),1)
37         TOOLCHAIN_FILE=cmake/buildtool/cross/toolchain_$(TARGET_ARCH_LC)-$(TARGET_OS).cmake
38         OPTIONS+= -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE)
39 endif
40
41 ifeq ($(COVERAGE_BUILD),1)
42         OPTIONS+= -DENABLE_COVERAGE=ON
43 else
44         OPTIONS+= -DENABLE_COVERAGE=OFF
45 endif
46
47 ifeq ($(BENCHMARK_ACL_BUILD),1)
48         OPTIONS+= -DBUILD_BENCHMARK_ACL=1
49 endif
50
51 ifneq ($(EXT_ACL_FOLDER),)
52         OPTIONS+= -DBUILD_ARMCOMPUTE=OFF
53         OPTIONS+= -DARMCompute_EXTDIR=$(EXT_ACL_FOLDER)
54 endif
55
56 ifneq ($(EXTERNAL_VOLUME),)
57         OPTIONS+= -DNNAS_EXTERNALS_DIR=$(EXTERNAL_VOLUME)
58 endif
59
60 ifeq ($(TARGET_OS),android)
61         OPTIONS+= -DNDK_DIR=$(NDK_DIR)
62 endif
63
64 ifneq ($(ANDROID_BUILD_TOOLS_DIR),)
65   OPTIONS+= -DANDROID_BUILD_TOOLS_DIR=$(ANDROID_BUILD_TOOLS_DIR)
66 endif
67
68 ifneq ($(ANDROID_SDK_DIR),)
69   OPTIONS+= -DANDROID_SDK_DIR=$(ANDROID_SDK_DIR)
70 endif
71
72 ifneq ($(TFLITE_MODEL_PATH),)
73   OPTIONS+= -DTFLITE_MODEL_PATH=$(TFLITE_MODEL_PATH)
74 endif
75
76 ifneq ($(ANDROID_BOOST_ROOT),)
77   OPTIONS+= -DANDROID_BOOST_ROOT=$(ANDROID_BOOST_ROOT)
78 endif
79
80 ifeq ($(PARALLEL_BUILD),1)
81         # Get number of processors (linux only for now)
82         ifeq ($(HOST_OS),linux)
83                 NPROCS?=$(shell grep -c ^processor /proc/cpuinfo)
84         endif
85 endif
86
87 NPROCS?=1
88 WORKHOME=$(CURDIR)/Product
89 WORKFOLDER=$(TARGET_ARCH_LC)-$(TARGET_OS).$(BUILD_TYPE_LC)
90 WORKSPACE=$(WORKHOME)/$(WORKFOLDER)
91
92 BUILD_FOLDER=$(WORKSPACE)/obj
93 INSTALL_PATH?=$(WORKSPACE)/out
94 OVERLAY_FOLDER?=$(WORKSPACE)/overlay
95 BUILD_ALIAS=$(WORKHOME)/obj
96 INSTALL_ALIAS=$(WORKHOME)/out
97
98 TIMESTAMP_CONFIGURE=$(WORKSPACE)/CONFIGURE
99 TIMESTAMP_BUILD=$(WORKSPACE)/BUILD
100 TIMESTAMP_INSTALL=$(WORKSPACE)/INSTALL
101
102 all: build
103
104 ###
105 ### Command (public)
106 ###
107 configure: configure_internal
108
109 build: build_internal
110
111 install: $(TIMESTAMP_INSTALL)
112
113 create_tar: runtime_tar_internal
114
115 clean:
116         rm -rf $(WORKSPACE)
117
118 distclean:
119         rm -rf $(WORKSPACE)
120         rm -rf externals/*.stamp
121         rm -rf tests/nnapi/src/generated/
122
123 ###
124 ### Command (internal)
125 ###
126 configure_internal:
127         NNFW_WORKSPACE="$(WORKSPACE)" NNFW_INSTALL_PREFIX=$(INSTALL_PATH) ./nnfw configure \
128                 -DCMAKE_BUILD_TYPE=$(BUILD_TYPE_LC) -DTARGET_ARCH=$(TARGET_ARCH_LC) \
129                 -DHOST_OS=$(HOST_OS) \
130                 -DTARGET_OS=$(TARGET_OS) \
131                 -DNNFW_OVERLAY_DIR=$(OVERLAY_FOLDER) \
132                 $(OPTIONS)
133         touch $(TIMESTAMP_CONFIGURE)
134
135 build_internal: $(BUILD_FOLDER)
136         NNFW_WORKSPACE="$(WORKSPACE)" NPROCS="$(NPROCS)" PARALLEL_BUILD="1" ./nnfw build
137         rm -rf $(BUILD_ALIAS)
138         ln -s $(BUILD_FOLDER) $(BUILD_ALIAS)
139         touch $(TIMESTAMP_BUILD)
140
141 install_internal:
142         NNFW_WORKSPACE="$(WORKSPACE)" ./nnfw install
143         rm -rf $(INSTALL_ALIAS)
144         ln -s $(INSTALL_PATH) $(INSTALL_ALIAS)
145         touch $(TIMESTAMP_INSTALL)
146
147 runtime_tar_internal: $(TIMESTAMP_BUILD) install_internal
148         tar -zcf nnfw-package.tar.gz -C $(INSTALL_PATH) lib include
149         mv nnfw-package.tar.gz $(INSTALL_PATH)/.
150
151 install_internal_acl:
152 # Workaround to install acl for test (ignore error when there is no file to copy)
153         cp $(OVERLAY_FOLDER)/lib/* $(INSTALL_ALIAS)/lib || true
154
155 build_test_suite: install_internal install_internal_acl
156         @echo "packaging test suite"
157         @rm -rf $(INSTALL_PATH)/test-suite.tar.gz
158 # TODO Divide runtime package, external library package, and test suite
159         @tar -zcf test-suite.tar.gz tests/scripts tests/framework infra Product/out --dereference
160         @mv test-suite.tar.gz $(INSTALL_PATH)/.
161
162 build_coverage_suite: install_internal install_internal_acl
163         @echo "packaging test-coverage suite"
164         @rm -rf $(INSTALL_PATH)/coverage-suite.tar.gz
165         @find Product -name "*.gcno" > include_lists.txt
166         @pwd | grep -o '/' | wc -l > tests/scripts/build_path_depth.txt
167         @tar -zcf coverage-suite.tar.gz tests/scripts tests/framework infra Product/out --dereference -T include_lists.txt
168         @rm -rf include_lists.txt tests/scripts/build_path_depth.txt
169         @mv coverage-suite.tar.gz $(INSTALL_PATH)/.
170
171 ###
172 ### Timestamps
173 ###
174 $(WORKSPACE):
175         mkdir -p $@
176
177 $(BUILD_FOLDER): $(WORKSPACE) configure_internal
178
179 $(TIMESTAMP_CONFIGURE): configure_internal
180
181 $(TIMESTAMP_BUILD): $(TIMESTAMP_CONFIGURE) build_internal
182
183 $(TIMESTAMP_INSTALL): $(TIMESTAMP_BUILD) install_internal install_internal_acl