1# Licensed to the Apache Software Foundation (ASF) under one
2# or more contributor license agreements.  See the NOTICE file
3# distributed with this work for additional information
4# regarding copyright ownership.  The ASF licenses this file
5# to you under the Apache License, Version 2.0 (the
6# "License"); you may not use this file except in compliance
7# with the License.  You may obtain a copy of the License at
8#
9#   http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing,
12# software distributed under the License is distributed on an
13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14# KIND, either express or implied.  See the License for the
15# specific language governing permissions and limitations
16# under the License.
17
18# Makefile Example to deploy TVM modules.
19TVM_ROOT=$(shell cd ../..; pwd)
20DMLC_CORE=${TVM_ROOT}/3rdparty/dmlc-core
21
22PKG_CFLAGS = -std=c++14 -O2 -fPIC\
23	-I${TVM_ROOT}/include\
24	-I${DMLC_CORE}/include\
25	-I${TVM_ROOT}/3rdparty/dlpack/include
26
27PKG_LDFLAGS = -L${TVM_ROOT}/build -ldl -pthread
28
29.PHONY: clean all
30
31all: lib/cpp_deploy_pack lib/cpp_deploy_normal
32
33# Build rule for all in one TVM package library
34lib/libtvm_runtime_pack.o: tvm_runtime_pack.cc
35	@mkdir -p $(@D)
36	$(CXX) -c $(PKG_CFLAGS) -o $@  $^
37
38# The code library built by TVM
39lib/test_addone_sys.o: prepare_test_libs.py
40	@mkdir -p $(@D)
41	python3 prepare_test_libs.py
42
43# Deploy using the all in one TVM package library
44lib/cpp_deploy_pack: cpp_deploy.cc lib/test_addone_sys.o lib/libtvm_runtime_pack.o
45	@mkdir -p $(@D)
46	$(CXX) $(PKG_CFLAGS) -o $@  $^ $(PKG_LDFLAGS)
47
48# Deploy using pre-built libtvm_runtime.so
49lib/cpp_deploy_normal: cpp_deploy.cc lib/test_addone_sys.o
50	@mkdir -p $(@D)
51	$(CXX) $(PKG_CFLAGS) -o $@  $^ -ltvm_runtime $(PKG_LDFLAGS)
52clean:
53	rm -rf lib
54