Makefile 4.02 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 scalalint 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
	python3 3rdparty/dmlc-core/scripts/lint.py vta cpp vta/include vta/src
	python3 3rdparty/dmlc-core/scripts/lint.py topi cpp topi/include;
72
	python3 3rdparty/dmlc-core/scripts/lint.py tvm cpp include src \
73
	 examples/extension/src examples/graph_executor/src
74 75

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

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

83 84 85 86
scalalint:
	make -C vta/hardware/chisel lint

lint: cpplint pylint jnilint scalalint
tqchen committed
87

88 89 90
doc:
	doxygen docs/Doxyfile

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

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

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

cyclean:
103
	rm -rf python/tvm/*/*/*.so python/tvm/*/*/*.dylib python/tvm/*/*/*.cpp
104

105 106
# JVM build rules
ifeq ($(OS),Windows_NT)
107 108
  JVM_PKG_PROFILE := windows
  SHARED_LIBRARY_SUFFIX := dll
109
else
110 111 112 113 114 115 116 117
  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
118 119 120 121
endif

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

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

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