blob: ea6609725c791269aaab2154086666e4d3004231 (
plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
COMPILER=clang
CFLAGS=-std=c++11 -O3 -Wall
TCMALLOC=external/gperftools/lib/libtcmalloc_minimal.a -pthread
MSGPACK_C_INCLUDE=-I external/msgpack-c/include
MSGPACK_C=external/msgpack-c/lib/libmsgpack.a $(MSGPACK_C_INCLUDE)
JSON_CPP_INCLUDE=-I external/json-cpp/include
SRC=src
BIN=bin
PRINT_BEGIN = @echo -e "\e[1;31mBuilding $@ ...\e[0m"
PRINT_END = @echo -e "\e[1;32mfinished building $@\e[0m"
###############################################################################
# all
#
all: $(BIN)/fast_weaver util test
###############################################################################
# fast_weaver
#
$(BIN)/fast_weaver: $(BIN) $(SRC)/hypergraph.o $(SRC)/fast_weaver.cc
$(PRINT_BEGIN)
$(COMPILER) $(CFLAGS) \
-lstdc++ \
-lm \
$(MSGPACK_C) \
$(TCMALLOC) \
$(SRC)/hypergraph.o \
$(SRC)/fast_weaver.cc \
-o $(BIN)/fast_weaver
$(PRINT_END)
$(BIN):
mkdir -p $(BIN)
$(SRC)/hypergraph.o: $(SRC)/hypergraph.cc $(SRC)/hypergraph.hh \
$(SRC)/grammar.hh \
$(SRC)/semiring.hh $(SRC)/sparse_vector.hh \
$(SRC)/types.hh
$(PRINT_BEGIN)
$(COMPILER) $(CFLAGS) \
-g \
-c \
$(MSGPACK_C_INCLUDE) \
$(SRC)/hypergraph.cc \
-o $(SRC)/hypergraph.o
$(PRINT_END)
###############################################################################
# util
#
util: $(BIN)/make_pak $(BIN)/read_pak
$(BIN)/make_pak: $(BIN) $(SRC)/make_pak.cc external/json-cpp/single_include/json-cpp.hpp \
$(SRC)/hypergraph.hh $(SRC)/types.hh
$(PRINT_BEGIN)
$(COMPILER) $(CFLAGS) \
-lstdc++ \
-lm \
$(MSGPACK_C) \
$(JSON_CPP_INCLUDE) \
$(SRC)/make_pak.cc \
-o $(BIN)/make_pak
$(PRINT_END)
$(BIN)/read_pak: $(SRC)/read_pak.cc
$(PRINT_BEGIN)
$(COMPILER) $(CFLAGS) \
-lstdc++ \
$(MSGPACK_C) \
$(SRC)/read_pak.cc \
-o $(BIN)/read_pak
$(PRINT_END)
###############################################################################
# test
#
test: $(BIN)/test_grammar $(BIN)/test_hypergraph $(BIN)/test_parse $(BIN)/test_sparse_vector
$(BIN)/test_grammar: $(BIN) $(SRC)/test_grammar.cc $(SRC)/grammar.hh
$(PRINT_BEGIN)
$(COMPILER) $(CFLAGS) \
-lstdc++ \
-lm \
$(TCMALLOC) \
$(MSGPACK_C) \
$(SRC)/test_grammar.cc \
-o $(BIN)/test_grammar
$(PRINT_END)
$(BIN)/test_hypergraph: $(BIN) $(SRC)/test_hypergraph.cc $(SRC)/hypergraph.o $(SRC)/grammar.hh
$(PRINT_BEGIN)
$(COMPILER) $(CFLAGS) \
-lstdc++ \
-lm \
$(TCMALLOC) \
$(MSGPACK_C) \
$(SRC)/hypergraph.o \
$(SRC)/test_hypergraph.cc \
-o $(BIN)/test_hypergraph
$(PRINT_END)
$(BIN)/test_parse: $(BIN) $(SRC)/test_parse.cc $(SRC)/parse.hh \
$(SRC)/grammar.hh $(SRC)/util.hh
$(PRINT_BEGIN)
$(COMPILER) $(CFLAGS) \
-lstdc++ \
-lm \
$(TCMALLOC) \
$(MSGPACK_C) \
$(SRC)/test_parse.cc \
-o $(BIN)/test_parse
$(PRINT_END)
$(BIN)/test_sparse_vector: $(BIN) $(SRC)/test_sparse_vector.cc $(SRC)/sparse_vector.hh
$(PRINT_BEGIN)
$(COMPILER) $(CFLAGS) \
-lstdc++ \
-lm \
$(TCMALLOC) \
$(SRC)/test_sparse_vector.cc \
-o $(BIN)/test_sparse_vector
$(PRINT_END)
###############################################################################
# clean
#
clean:
rm -f $(SRC)/*.o
rm -f $(BIN)/*
|