Makefile 4.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

18 19
ROOTDIR = $(CURDIR)

20
.PHONY: clean all test doc pylint cpplint lint\
21
	 cython cython2 cython3 web runtime vta
22

ziheng committed
23
ifndef DMLC_CORE_PATH
24
  DMLC_CORE_PATH = $(ROOTDIR)/3rdparty/dmlc-core
ziheng committed
25 26 27
endif

ifndef DLPACK_PATH
28
  DLPACK_PATH = $(ROOTDIR)/3rdparty/dlpack
ziheng committed
29 30
endif

31
INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include
32
PKG_CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC
33
PKG_LDFLAGS =
34

35

36 37
all:
	@mkdir -p build && cd build && cmake .. && $(MAKE)
38

39 40
runtime:
	@mkdir -p build && cd build && cmake .. && $(MAKE) runtime
41

42 43 44
vta:
	@mkdir -p build && cd build && cmake .. && $(MAKE) vta

45 46
cpptest:
	@mkdir -p build && cd build && cmake .. && $(MAKE) cpptest
47

48 49 50 51
# EMCC; Web related scripts
EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
	-Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\
	-s TOTAL_MEMORY=1073741824\
52
	-s EXTRA_EXPORTED_RUNTIME_METHODS="['addFunction','cwrap','getValue','setValue']"\
53 54
	-s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw\
	$(INCLUDE_FLAGS)
tqchen committed
55

56
web: build/libtvm_web_runtime.js build/libtvm_web_runtime.bc
tqchen committed
57

58
build/libtvm_web_runtime.bc: web/web_runtime.cc
59 60
	@mkdir -p build/web
	@mkdir -p $(@D)
61
	emcc $(EMCC_FLAGS) -MM -MT build/libtvm_web_runtime.bc $< >build/web/web_runtime.d
62 63
	emcc $(EMCC_FLAGS) -o $@ web/web_runtime.cc

64
build/libtvm_web_runtime.js: build/libtvm_web_runtime.bc
65
	@mkdir -p $(@D)
66
	emcc $(EMCC_FLAGS) -o $@ build/libtvm_web_runtime.bc
67

68
# Lint scripts
69
cpplint:
70 71 72
	python3 3rdparty/dmlc-core/scripts/lint.py vta cpp vta/include vta/src
	python3 3rdparty/dmlc-core/scripts/lint.py topi cpp topi/include;
	python3 3rdparty/dmlc-core/scripts/lint.py nnvm cpp nnvm/include nnvm/src;
73
	python3 3rdparty/dmlc-core/scripts/lint.py tvm cpp include src \
74
	 examples/extension/src examples/graph_executor/src
75 76

pylint:
77 78 79
	python3 -m pylint python/tvm --rcfile=$(ROOTDIR)/tests/lint/pylintrc
	python3 -m pylint topi/python/topi --rcfile=$(ROOTDIR)/tests/lint/pylintrc
	python3 -m pylint nnvm/python/nnvm --rcfile=$(ROOTDIR)/tests/lint/pylintrc
80
	python3 -m pylint vta/python/vta --rcfile=$(ROOTDIR)/tests/lint/pylintrc
81

82
jnilint:
83
	python3 3rdparty/dmlc-core/scripts/lint.py tvm4j-jni cpp jvm/native/src
84 85

lint: cpplint pylint jnilint
tqchen committed
86

87 88 89
doc:
	doxygen docs/Doxyfile

90 91 92 93
javadoc:
	# build artifact is in jvm/core/target/site/apidocs
	cd jvm && mvn javadoc:javadoc

94 95 96 97 98 99 100 101 102 103 104
# Cython build
cython:
	cd python; python setup.py build_ext --inplace

cython2:
	cd python; python2 setup.py build_ext --inplace

cython3:
	cd python; python3 setup.py build_ext --inplace

cyclean:
105
	rm -rf python/tvm/*/*/*.so python/tvm/*/*/*.dylib python/tvm/*/*/*.cpp
106

107 108
# JVM build rules
ifeq ($(OS),Windows_NT)
109 110
  JVM_PKG_PROFILE := windows
  SHARED_LIBRARY_SUFFIX := dll
111
else
112 113 114 115 116 117 118 119
  UNAME_S := $(shell uname -s)
  ifeq ($(UNAME_S), Darwin)
    JVM_PKG_PROFILE := osx-x86_64
    SHARED_LIBRARY_SUFFIX := dylib
  else
    JVM_PKG_PROFILE := linux-x86_64
    SHARED_LIBRARY_SUFFIX := so
  endif
120 121 122 123
endif

JVM_TEST_ARGS := $(if $(JVM_TEST_ARGS),$(JVM_TEST_ARGS),-DskipTests -Dcheckstyle.skip=true)

124 125 126
jvmpkg:
	(cd $(ROOTDIR)/jvm; \
		mvn clean package -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \
127 128
			-Dcflags="$(PKG_CFLAGS)" -Dldflags="$(PKG_LDFLAGS)" \
			-Dcurrent_libdir="$(ROOTDIR)/build" $(JVM_TEST_ARGS))
Yizhi Liu committed
129 130 131
jvminstall:
	(cd $(ROOTDIR)/jvm; \
		mvn install -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \
132 133
			-Dcflags="$(PKG_CFLAGS)" -Dldflags="$(PKG_LDFLAGS)" \
			-Dcurrent_libdir="$(ROOTDIR)/build" $(JVM_TEST_ARGS))
134

135
# clean rule
tqchen committed
136
clean:
137
	@mkdir -p build && cd build && cmake .. && $(MAKE) clean