Makefile 2.36 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
ROOTDIR = $(CURDIR)

ifndef config
ifneq ("$(wildcard ./config.mk)", "")
	config = config.mk
else
	config = make/config.mk
endif
endif
include $(config)

tqchen committed
12 13
TVMPATH = ..

tqchen committed
14
export LDFLAGS = -pthread -lm
Tianqi Chen committed
15
export CFLAGS = -std=c++11 -Wall -O2 -Iinclude -fPIC
tqchen committed
16
CFLAGS += -I$(TVMPATH)/include -I$(TVMPATH)/dlpack/include -I$(TVMPATH)/HalideIR/src -I$(TVMPATH)/topi/include
17

18 19 20
ifdef DMLC_CORE_PATH
  CFLAGS += -I$(DMLC_CORE_PATH)/include
else
tqchen committed
21
  CFLAGS += -I$(ROOTDIR)/../dmlc-core/include
22 23
endif

24 25 26 27 28
ifneq ($(ADD_CFLAGS), NONE)
	CFLAGS += $(ADD_CFLAGS)
endif

ifneq ($(ADD_LDFLAGS), NONE)
29
	LDFLAGS += $(ADD_LDFLAGS)
30 31 32 33 34 35
endif

# plugin
PLUGIN_OBJ =
include $(NNVM_PLUGINS)

36
# specify tensor path
37
.PHONY: clean all test lint cpplint pylint doc cython cython3 cyclean
38

Tianqi Chen committed
39 40 41
UNAME_S := $(shell uname -s)

ifeq ($(UNAME_S), Darwin)
42
	SHARED_LIBRARY_SUFFIX := dylib
Tianqi Chen committed
43 44
	WHOLE_ARCH= -all_load
	NO_WHOLE_ARCH= -noall_load
45
	LDFLAGS += -undefined dynamic_lookup
Tianqi Chen committed
46
else
47
	SHARED_LIBRARY_SUFFIX := so
Tianqi Chen committed
48 49 50 51
	WHOLE_ARCH= --whole-archive
	NO_WHOLE_ARCH= --no-whole-archive
endif

52
all: lib/libnnvm.a lib/libnnvm_compiler.$(SHARED_LIBRARY_SUFFIX)
53

tqchen committed
54
SRC = $(wildcard src/*.cc src/c_api/*.cc src/core/*.cc src/pass/*.cc)
55
SRC_COMPILER = $(wildcard src/top/*/*.cc wildcard src/top/vision/*/*.cc src/compiler/*.cc src/compiler/*/*.cc)
56
ALL_OBJ = $(patsubst %.cc, build/%.o, $(SRC))
57
TOP_OBJ = $(patsubst %.cc, build/%.o, $(SRC_COMPILER))
tqchen committed
58
ALL_DEP = $(ALL_OBJ)
Tianqi Chen committed
59

tqchen committed
60 61 62
include tests/cpp/unittest.mk

test: $(TEST)
63

64
build/src/%.o: src/%.cc
65
	@mkdir -p $(@D)
66
	$(CXX) $(CFLAGS) -MM -MT build/src/$*.o $< >build/src/$*.d
67 68
	$(CXX) -c $(CFLAGS) -c $< -o $@

69
lib/libnnvm.a: $(ALL_DEP)
tqchen committed
70
	@mkdir -p $(@D)
71
	$(AR) crv $@ $(filter %.o, $?)
tqchen committed
72

73
lib/libnnvm_compiler.$(SHARED_LIBRARY_SUFFIX): lib/libnnvm.a ${TOP_OBJ}
74
	@mkdir -p $(@D)
tqchen committed
75
	$(CXX) $(CFLAGS) -shared -o $@ $(filter %.o, $^) $(LDFLAGS) -Wl,${WHOLE_ARCH} lib/libnnvm.a -Wl,${NO_WHOLE_ARCH}
76

77
cython:
78 79
	cd python; python setup.py build_ext --inplace

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

83
cyclean:
84
	rm -rf python/nnvm/*/*.so python/nnvm/*/*.dylib python/nnvm/*/*.cpp
85

86 87
lint: pylint cpplint

tqchen committed
88 89 90
doc:
	doxygen docs/Doxyfile

91
cpplint:
tqchen committed
92
	python ../dmlc-core/scripts/lint.py nnvm cpp include src
tqchen committed
93

94 95 96
pylint:
	pylint python/nnvm --rcfile=$(ROOTDIR)/tests/lint/pylintrc

97
clean:
tqchen committed
98
	$(RM) -rf build lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o cli_test
99 100 101

-include build/*.d
-include build/*/*.d
ziheng committed
102
-include build/*/*/*.d
103
-include build/*/*/*/*.d