-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile
65 lines (49 loc) · 2.27 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
CXX ?= g++
WGET ?= wget
# Note: OpenFst requires a relatively recent C++ compiler with C++11 support,
# e.g. g++ >= 4.7, Apple clang >= 5.0 or LLVM clang >= 3.3.
OPENFST_VERSION ?= 1.7.5
# Default features configured for OpenFST; can be overridden in the make command line.
OPENFST_COMFIGURE ?= --enable-static --enable-shared --enable-ngram-fsts
CPPFLAGS ?= -D_GLIBCXX_USE_CXX11_ABI=0
CXXFLAGS ?= -D_GLIBCXX_USE_CXX11_ABI=0
.PHONY: all clean
all: openfst pychain
clean: openfst_cleaned
rm -rf pychain
openfst_cleaned:
$(MAKE) -C openfst-$(OPENFST_VERSION) clean
.PHONY: openfst # so target will be made even though "openfst" exists.
openfst: openfst_compiled openfst-$(OPENFST_VERSION)/lib
-rm -f openfst
-ln -s openfst-$(OPENFST_VERSION) openfst
.PHONY: openfst_compiled
openfst_compiled: openfst-$(OPENFST_VERSION)/Makefile
$(MAKE) -C openfst-$(OPENFST_VERSION) install MAKEOVERRIDES=
openfst-$(OPENFST_VERSION)/lib: | openfst-$(OPENFST_VERSION)/Makefile
-cd openfst-$(OPENFST_VERSION) && [ -d lib64 ] && [ ! -d lib ] && ln -s lib64 lib
# Add the -O flag to CXXFLAGS on cygwin as it can fix the compilation error
# "file too big".
ifeq ($(OSTYPE),cygwin)
# Note: OSTYPE path is probably dead for latest cygwin64 (installed on 2016/11/11).
openfst_add_CXXFLAGS = -O -Wa,-mbig-obj
else ifeq ($(OS),Windows_NT)
# This new OS path is confirmed working on Windows 10 / Cygwin64.
openfst_add_CXXFLAGS = -O -Wa,-mbig-obj
else
openfst_add_CXXFLAGS =
endif
openfst-$(OPENFST_VERSION)/Makefile: openfst-$(OPENFST_VERSION)
cd openfst-$(OPENFST_VERSION)/ && \
./configure --prefix=`pwd` $(OPENFST_CONFIGURE) CXX="$(CXX)" CPPFLAGS="$(CPPFLAGS)" CXXFLAGS="$(CXXFLAGS) $(openfst_add_CXXFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="-ldl"
openfst-$(OPENFST_VERSION): openfst-$(OPENFST_VERSION).tar.gz
tar xozf openfst-$(OPENFST_VERSION).tar.gz
openfst-$(OPENFST_VERSION).tar.gz:
$(WGET) -T 10 -t 1 http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-$(OPENFST_VERSION).tar.gz || \
$(WGET) -T 10 -t 3 https://www.openslr.org/resources/2/openfst-$(OPENFST_VERSION).tar.gz;
.PHONY: pychain
pychain:
export OPENFST_PATH=`pwd`/openfst && \
export LD_LIBRARY_PATH=`pwd`/openfst/lib:$$LD_LIBRARY_PATH && \
cd openfst_binding && python3 setup.py install && \
cd ../pytorch_binding && python3 setup.py install