forked from UFAL-DSG/pykaldi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
131 lines (112 loc) · 4.73 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# TODO Cython does not recompile because of the templates and sourcefiles
FSTDIR=kaldi/tools/openfst
AFSTDIR=$(PWD)/$(FSTDIR)
PYTHON=python
INSTALL_PREFIX=/usr/local
INSTALL_PYTHON_PREFIX=/usr/local/
# OPENFST_VERSION=1.4.1 # fails with pyfst
OPENFST_VERSION=1.3.4
LINUX=$(shell lsb_release -sd | sed 's: :_:g')
KALDI_LIBS = ../kaldi/src/online2/kaldi-online2.a \
../kaldi/src/decoder/kaldi-decoder.a \
../kaldi/src/feat/kaldi-feat.a \
../kaldi/src/thread/kaldi-thread.a \
../kaldi/src/lat/kaldi-lat.a \
../kaldi/src/hmm/kaldi-hmm.a \
../kaldi/src/transform/kaldi-transform.a \
../kaldi/src/gmm/kaldi-gmm.a \
../kaldi/src/fstext/kaldi-fstext.a \
../kaldi/src/tree/kaldi-tree.a \
../kaldi/src/matrix/kaldi-matrix.a \
../kaldi/src/util/kaldi-util.a \
../kaldi/src/base/kaldi-base.a
all: onl-rec/onl-rec.a pykaldi/kaldi/decoders.so pyfst/fst/_fst.so
kaldi/.git:
git clone https://github.com/kaldi-asr/kaldi.git kaldi
cd kaldi ; git checkout ea37842dc1f4f03819acae27a6363c993ce5d12b; cd -
pyfst/.git: .gitmodules
git clone https://github.com/UFAL-DSG/pyfst.git pyfst
cd pyfst; git checkout c4672ac229e32aa8cf45c88831aacea305b1765f; cd -
kaldi/src/kaldi.mk: kaldi/.git $(FSTDIR)/lib/libfst.a kaldi/tools/ATLAS/include/clapack.h
@echo "kaldi configure"
cd kaldi/src && \
./configure --shared
kaldi/tools/ATLAS/include/clapack.h: kaldi/.git
$(MAKE) -C kaldi/tools atlas ; echo "Installing atlas finished $?"
$(FSTDIR)/lib/libfst.a: kaldi/.git
$(MAKE) -C kaldi/tools openfst OPENFST_VERSION=$(OPENFST_VERSION); echo "Installing OpenFST finished: $?"
# If you want to develop or install pyfst
# use setup.py develop --user or setup.py install respectively
pyfst/fst/_fst.so: $(FSTDIR)/lib/libfst.a pyfst/.git
cd pyfst && \
LIBRARY_PATH=$(AFSTDIR)/lib:$(AFSTDIR)/lib/fst CPLUS_INCLUDE_PATH=$(AFSTDIR)/include $(PYTHON) \
setup.py build_ext --inplace
onl-rec/onl-rec.a: $(FSTDIR)/lib/libfst.a kaldi/tools/ATLAS/include/clapack.h kaldi/src/kaldi.mk
$(MAKE) -C kaldi/src
# $(MAKE) -C kaldi/src online2 ivector decoder feat thread lat hmm transform gmm fstext tree matrix util base
$(MAKE) -C onl-rec
pykaldi/kaldi/decoders.so: pyfst/fst/_fst.so onl-rec/onl-rec.a
cd pykaldi && \
PYKALDI_ADDLIBS="../onl-rec/onl-rec.a $(KALDI_LIBS)" \
LIBRARY_PATH=$(AFSTDIR)/lib:$(AFSTDIR)/lib/fst CPLUS_INCLUDE_PATH=$(AFSTDIR)/include \
$(PYTHON) setup.py build_ext --inplace
test: onl-rec/onl-rec.a $(FSTDIR)/lib/libfst.a pyfst/.git
$(MAKE) -C onl-rec test
cd pyfst && \
LIBRARY_PATH=$(AFSTDIR)/lib:$(AFSTDIR)/lib/fst CPLUS_INCLUDE_PATH=$(AFSTDIR)/include \
LD_LIBRARY_PATH=$(AFSTDIR)/lib:$(AFSTDIR)/lib/fst \
DYLD_LIBRARY_PATH=$$LD_LIBRARY_PATH \
$(PYTHON) setup.py nosetests
cd pykaldi && \
PYKALDI_ADDLIBS="../onl-rec/onl-rec.a $(KALDI_LIBS)" \
LD_LIBRARY_PATH=$(AFSTDIR)/lib:$(AFSTDIR)/lib/fst \
DYLD_LIBRARY_PATH=$$LD_LIBRARY_PATH \
LIBRARY_PATH=$(AFSTDIR)/lib:$(AFSTDIR)/lib/fst CPLUS_INCLUDE_PATH=$(AFSTDIR)/include \
PYTHONPATH=$(PWD)/pyfst:$$PYTHONPATH \
$(PYTHON) setup.py nosetests
distclean:
$(MAKE) -C onl-rec distclean
cd pykaldi && \
$(PYTHON) setup.py clean --all
rm -rf pykaldi/{dist,build,*e.egg-info}
rm -f kaldi/decoders.{cpp,so}
rm -f fst/_fst.{cpp,so}
rm -rf pyfst
rm -rf kaldi
deploy: pykaldi_$(LINUX).zip
pykaldi_$(LINUX).zip: pykaldi/kaldi/decoders.so pyfst/fst/_fst.so
cd pyfst && \
LIBRARY_PATH=$(AFSTDIR)/lib:$(AFSTDIR)/lib/fst CPLUS_INCLUDE_PATH=$(AFSTDIR)/include \
$(PYTHON) setup.py bdist_egg
cd pykaldi && \
PYKALDI_ADDLIBS="../onl-rec/onl-rec.a $(KALDI_LIBS)" \
LIBRARY_PATH=$(AFSTDIR)/lib:$(AFSTDIR)/lib/fst CPLUS_INCLUDE_PATH=$(AFSTDIR)/include \
$(PYTHON) setup.py bdist_egg
mkdir -p $(basename $@)/openfst
cp pykaldi/dist/pykaldi*.egg pyfst/dist/pyfst*.egg $(basename $@)
for d in include lib bin ; do cp -r $(AFSTDIR)/$$d $(basename $@)/openfst ; done
zip -r $@ $(basename $@)
install-kaldi-binaries: kaldi/src/kaldi.mk
cp -r kaldi/src/lib/* $(INSTALL_PREFIX)/lib
cp `find kaldi/src -executable -type f` $(INSTALL_PREFIX)/bin
install: pykaldi_$(LINUX).zip
# as one command due to setting up dir variable (TODO move it to make variable)
export dir=`mktemp -d pykaldi_install_XXXXX`; \
echo -e "\nInstalling from $$dir\n"; \
mkdir -p $$dir; \
cp $< $$dir; \
cd $$dir && \
unzip -q $<
cd $(basename $<) && \
for d in bin include lib ; do cp -r openfst/$$d/* $(INSTALL_PREFIX)/$$d/ ; done ; \
easy_install pyfst*.egg ; \
easy_install pykaldi*.egg; \
echo -e "\nRemoving $$dir\n" ; \
rm -rf $$dir
irstlm:
svn -r 769 co --non-interactive --trust-server-cert https://svn.code.sf.net/p/irstlm/code/trunk irstlm
irstlm/Makefile: irstlm
cd irstlm && cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$(INSTALL_PREFIX)"
install-irstlm: irstlm/Makefile
$(MAKE) -C irstlm
$(MAKE) -C irstlm install