-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
executable file
·81 lines (60 loc) · 2.91 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
#
# Makefile
#
PWD=$(shell pwd)
CC = gcc
CFLAGS = -O3 -std=c++11 -Werror # -g
CXX = g++
CXXFLAGS = -O3 -std=c++11 -Werror # -g
MARISA_PATH=$(PWD)/third_party/marisa-trie
#MARISA_LIB=-L$(MARISA_PATH)/local/lib -lmarisa
MARISA_LIB=$(MARISA_PATH)/local/lib/libmarisa.a
MARISA_INCLUDE=-I$(MARISA_PATH)/local/include
LIBS=$(MARISA_LIB) # install marisa trie to this path
INCLUDES= -I./util -I./src $(MARISA_INCLUDE)
LDFLAGS =
TARGETS = deplibs train_pc train_svm decoder lmdecoder
OS := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CXXFLAGS += -DLINUX
endif
ifeq ($(UNAME_S),Darwin)
CXXFLAGS += -DOSX
endif
.PHONY: all clean
.SUFFIXES: .c .cpp .o
all: $(TARGETS)
deplibs:$(MARISA_PATH)/local/lib/libmarisa.a
$(MARISA_PATH)/local/lib/libmarisa.a:
git submodule update -i
cd $(MARISA_PATH) && autoreconf --install && ./configure --prefix=$(MARISA_PATH)/local && make && make install
make_data:
wget -q -O sample_data/aozora.csv.gz http://aozora-word.hahasoha.net/utf8/utf8_all.csv.gz
decoder: bin/decoder.o src/classifier/Model.o src/decoder/Feature.o src/decoder/Dic.o src/decoder/Lattice.o src/decoder/Decoder.o
$(CXX) $(CXXFLAGS) -o bin/$@ $^ $(LIBS) $(LDFLAGS) $(INCLUDES)
lmdecoder: bin/lmdecoder.o src/ngram/SLM.o src/decoder/Dic.o src/classifier/Model.o src/decoder/Feature.o src/decoder/Lattice.o src/decoder/Decoder.o src/decoder/NgramLMDecoder.o
$(CXX) $(CXXFLAGS) -o bin/$@ $^ $(LIBS) $(LDFLAGS) $(INCLUDES)
train_pc: bin/train_pc.o src/utils/FileChunker.o src/classifier/Perceptron.o src/learner/ILearner.o src/learner/StructuredPerceptron.o src/classifier/Model.o src/decoder/Feature.o src/decoder/Dic.o src/decoder/Lattice.o src/decoder/Decoder.o
$(CXX) $(CXXFLAGS) -o bin/train_pc $^ $(LIBS) $(LDFLAGS) $(INCLUDES)
train_svm: bin/train_svm.o src/utils/FileChunker.o src/classifier/SVM.o src/learner/ILearner.o src/learner/StructuredSVM.o src/classifier/Model.o src/decoder/Feature.o src/decoder/Dic.o src/decoder/Lattice.o src/decoder/Decoder.o src/decoder/SVMDecoder.o
$(CXX) $(CXXFLAGS) -o bin/train_svm $^ $(LIBS) $(LDFLAGS) $(INCLUDES)
SLM_test: test/SLM_test.o src/ngram/SLM.o
$(CXX) $(CXXFLAGS) $(LIBS) $(LDFLAGS) $(INCLUDES) -o test/$@ $^
valgrind --error-limit=no --leak-check=full --show-reachable=yes -v ./test/SLM_test
lattice_test: test/lattice_test.o src/decoder/Lattice.o
$(CXX) $(CXXFLAGS) $(LIBS) $(LDFLAGS) $(INCLUDES) -o test/$@ $^
#valgrind --error-limit=no --leak-check=full --show-reachable=yes -v ./test/SLM_test
file_chunk_test: test/file_chunk_test.o src/utils/FileChunker.o
$(CXX) $(CXXFLAGS) $(LIBS) $(LDFLAGS) $(INCLUDES) -o test/$@ $^
clean:
find ./src -name "*.o" | xargs -n 1 $(RM)
find ./bin -name "*.o" | xargs -n 1 $(RM)
$(RM) ./bin/decoder ./bin/lmdecoder ./bin/train_pc ./bin/train_svm
.c.o:
$(CC) $(CFLAGS) -o $@ -c $^
.cpp.o:
$(CXX) $(CXXFLAGS) $(INCLUDES) $(LDFLAGS) -o $@ -c $^
.c:
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
.cpp:
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)