-
Notifications
You must be signed in to change notification settings - Fork 594
/
Makefile
109 lines (90 loc) · 3.16 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
ifdef config
include $(config)
endif
ifndef DEPS_PATH
DEPS_PATH = $(shell pwd)/third_party
endif
ifndef PYTHON_PATH
PYTHON_PATH = $(shell python -c"import sys; print(sys.prefix)")
endif
ifndef PYTHON_VERSION
PYTHON_VERSION = $(shell ls $(PYTHON_PATH)/include | grep python | head -n1)
endif
ifndef PYTHON_INCLUDE
PYTHON_INCLUDE = $(shell ls $(PYTHON_PATH)/include | grep python | head -n1 | sed "s:^:$(PYTHON_PATH)/include/:")
endif
ifndef PROTOC
PROTOC = ${DEPS_PATH}/bin/protoc
endif
ifndef CXX
CXX = g++
endif
CXXFLAGS=-pipe \
-W \
-Wall \
-fPIC \
-std=c++11 \
-fno-omit-frame-pointer \
-fpermissive \
-O3 \
-ffast-math
INCPATH=-I./include/ \
-I./include/familia \
-I./third_party/include \
-I$(PYTHON_INCLUDE)
LDFLAGS_SO = -L$(DEPS_PATH)/lib -L$(PYTHON_PATH)/lib -L./build/ -lfamilia -lprotobuf -lglog -lgflags
.PHONY: all
all: familia python/familia.so
@echo $(SOURCES)
@echo $(OBJS)
$(CXX) $(CXXFLAGS) $(INCPATH) build/demo/inference_demo.o $(LDFLAGS_SO) -o inference_demo
$(CXX) $(CXXFLAGS) $(INCPATH) build/demo/doc_distance_demo.o $(LDFLAGS_SO) -o doc_distance_demo
$(CXX) $(CXXFLAGS) $(INCPATH) build/demo/query_doc_sim_demo.o $(LDFLAGS_SO) -o query_doc_sim_demo
$(CXX) $(CXXFLAGS) $(INCPATH) build/demo/word_distance_demo.o $(LDFLAGS_SO) -o word_distance_demo
$(CXX) $(CXXFLAGS) $(INCPATH) build/demo/topic_word_demo.o $(LDFLAGS_SO) -o topic_word_demo
$(CXX) $(CXXFLAGS) $(INCPATH) build/demo/show_topic_demo.o $(LDFLAGS_SO) -o show_topic_demo
$(CXX) $(CXXFLAGS) $(INCPATH) build/demo/document_keywords_demo.o $(LDFLAGS_SO) -o document_keywords_demo
include depends.mk
.PHONY: clean
clean:
rm -rf inference_demo
rm -rf doc_distance_demo
rm -rf query_doc_sim_demo
rm -rf word_distance_demo
rm -rf topic_word_demo
rm -rf show_topic_demo
rm -rf document_keywords_demo
rm -rf build
rm -rf python/cpp/*.o
rm -rf python/demo/*.so
rm -rf python/demo/*.pyc
find src -name "*.pb.[ch]*" -delete
# third party dependency
deps: ${GLOGS} ${GFLAGS} ${PROTOBUF}
@echo "dependency installed!"
.PHONY: familia
familia: build/libfamilia.a
OBJS = $(addprefix build/, vose_alias.o inference_engine.o model.o vocab.o document.o sampler.o config.o util.o semantic_matching.o tokenizer.o \
demo/inference_demo.o \
demo/doc_distance_demo.o \
demo/query_doc_sim_demo.o \
demo/word_distance_demo.o \
demo/topic_word_demo.o \
demo/document_keywords_demo.o \
demo/show_topic_demo.o)
build/libfamilia.a: include/config.pb.h $(OBJS)
@echo Target $@;
ar crv $@ $(filter %.o, $?)
build/%.o: src/%.cpp
@mkdir -p $(@D)
$(CXX) $(INCPATH) $(CXXFLAGS) -MM -MT build/$*.o $< >build/$*.d
$(CXX) $(INCPATH) $(CXXFLAGS) -c $< -o $@
# build proto
include/config.pb.h src/config.cpp : proto/config.proto
$(PROTOC) --cpp_out=./src --proto_path=./proto $<
mv src/config.pb.h ./include/familia
mv src/config.pb.cc ./src/config.cpp
python/familia.so : python/cpp/familia_wrapper.cpp familia
$(CXX) $(INCPATH) $(CXXFLAGS) -c $< -o python/cpp/familia_wrapper.o
$(CXX) $(INCPATH) $(CXXFLAGS) -shared python/cpp/familia_wrapper.o $(LDFLAGS_SO) -l$(PYTHON_VERSION) -o $@
-include $(wildcard */*.d *.d)