Makefile 6.56 KB
Newer Older
1 2
# SHELL += -x

3
CXX = g++
4 5 6
# CXX = clang++  # Uncomment this line to build with Clang.

OPENFST_VERSION = 1.3.4
7 8
# Uncomment the next line to build with OpenFst-1.4.1.
# OPENFST_VERSION = 1.4.1
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# Note: OpenFst >= 1.4 requires C++11 support, hence you will need to use a
# relatively recent C++ compiler, e.g. gcc >= 4.6, clang >= 3.0.

# On Mac OS 10.9+, clang defaults to the new c++ standard library libc++.
# Since OpenFst-1.3 uses stuff from the tr1 namespace, we need to tell clang
# to use libstdc++ instead.
ifeq ($(OPENFST_VERSION), 1.3.4)
  COMPILER = $(shell $(CXX) -v 2>&1 )
  ifeq ($(findstring clang,$(COMPILER)),clang)
    CXXFLAGS += -stdlib=libstdc++
    LDFLAGS += -stdlib=libstdc++
  endif
else
  ifneq ($(OPENFST_VERSION), 1.4.1)
    $(error OpenFst version $(OPENFST_VERSION) is not supported. \
            Supported versions: 1.3.4, 1.4.1)
  endif
26
endif
27

28 29 30 31 32
all: check_required_programs sph2pipe atlas sclite openfst
	@echo -e "\n\n"
	@echo "Warning: IRSTLM is not installed by default anymore. If you need IRSTLM"
	@echo "Warning: use the script extras/install_irstlm.sh"
	@echo "All done OK."
33 34

check_required_programs:
35
	extras/check_dependencies.sh
36

37
clean: openfst_cleaned sclite_cleaned
38 39

openfst_cleaned:
40
	$(MAKE) -C openfst-$(OPENFST_VERSION) clean
41 42 43


sclite_cleaned:
44
	$(MAKE) -C sctk clean
45 46

distclean:
47
	rm -rf openfst-$(OPENFST_VERSION)/
48
	rm -rf sctk-2.4.9/
49
	rm -rf sctk
50 51 52 53
	rm -rf ATLAS/
	rm -rf sph2pipe_v2.5/
	rm -rf sph2pipe_v2.5.tar.gz
	rm -rf atlas3.8.3.tar.gz
54
	rm -rf sctk-2.4.9-20141015-1634Z.tar.bz2
55
	rm -rf openfst-$(OPENFST_VERSION).tar.gz
56
	rm -f openfst
57
	rm -rf libsndfile-1.0.25{,.tar.gz} BeamformIt-3.51{,.tgz}
58 59 60


.PHONY: openfst # so target will be made even though "openfst" exists.
61
openfst: openfst_compiled openfst-$(OPENFST_VERSION)/lib
62
	-rm -f openfst
63
	-ln -s openfst-$(OPENFST_VERSION) openfst
64 65

.PHONY: openfst_compiled
66 67
openfst_compiled: openfst-$(OPENFST_VERSION)/Makefile
	cd openfst-$(OPENFST_VERSION)/ && \
68 69
	$(MAKE) install

70 71
openfst-$(OPENFST_VERSION)/lib: | openfst-$(OPENFST_VERSION)/Makefile
	-cd openfst-$(OPENFST_VERSION) && [ -d lib64 ] && [ ! -d lib ] && ln -s lib64 lib
72

73
# Add the -O flag to CXXFLAGS on cygwin as it can fix the compilation error
74 75
# "file too big".
openfst-$(OPENFST_VERSION)/Makefile: openfst-$(OPENFST_VERSION)/.patched
76
ifeq ($(OSTYPE),cygwin)
77
	cd openfst-$(OPENFST_VERSION)/; ./configure --prefix=`pwd` --enable-static --enable-shared --enable-far --enable-ngram-fsts CXX=$(CXX) CXXFLAGS="$(CXXFLAGS) -O" LDFLAGS="$(LDFLAGS)" LIBS="-ldl"
78
else
79
	cd openfst-$(OPENFST_VERSION)/; ./configure --prefix=`pwd` --enable-static --enable-shared --enable-far --enable-ngram-fsts CXX=$(CXX) CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="-ldl"
80
endif
81

82 83
# patches for openfst. openfst_gcc41up.patch is a patch for openfst to \
# support multi-threads when compile with g++ (gcc) version above 4.1
84 85
openfst-$(OPENFST_VERSION)/.patched: | openfst-$(OPENFST_VERSION)
	-cd openfst-$(OPENFST_VERSION)/src/include/fst; \
86
	patch -p0 -N < ../../../../extras/openfst-$(OPENFST_VERSION).patch;
87 88 89 90 91 92 93 94 95
	$(CXX) -dumpversion | awk '{if(NR==1 && $$1>"4.1") print "cd openfst-$(OPENFST_VERSION)/src/include/fst; patch -p0 -N < ../../../../extras/openfst_gcc41up.patch"}' | sh -
	touch $@

openfst-$(OPENFST_VERSION): openfst-$(OPENFST_VERSION).tar.gz
	tar xozf openfst-$(OPENFST_VERSION).tar.gz

openfst-$(OPENFST_VERSION).tar.gz: 
	wget http://openfst.cs.nyu.edu/twiki/pub/FST/FstDownload/openfst-$(OPENFST_VERSION).tar.gz || \
	wget -T 10 -t 3 http://www.openslr.org/resources/2/openfst-$(OPENFST_VERSION).tar.gz
96

97
sclite: sclite_compiled
98 99

.PHONY: sclite_compiled
100
sclite_compiled: sctk sctk_configured
101 102 103
	cd sctk; \
	$(MAKE) all && $(MAKE) install && $(MAKE) doc

104
sctk_configured: sctk sctk/.configured
105

106
sctk/.configured: sctk
107 108 109 110
	cd sctk; $(MAKE) config
	touch sctk/.configured

.PHONY: sctk
111 112 113
sctk: sctk-2.4.9-20141015-1634Z.tar.bz2
	tar xojf sctk-2.4.9-20141015-1634Z.tar.bz2
	rm -rf sctk && ln -s sctk-2.4.9 sctk
114

115 116 117
sctk-2.4.9-20141015-1634Z.tar.bz2:
	wget -T 10 -t 3 ftp://jaguar.ncsl.nist.gov/pub/sctk-2.4.9-20141015-1634Z.tar.bz2|| \
    wget --no-check-certificate -T 10 http://www.openslr.org/resources/4/sctk-2.4.9-20141015-1634Z.tar.bz2
118 119 120 121 122


atlas: ATLAS/include/cblas.h

ATLAS/include/cblas.h: | atlas3.8.3.tar.gz
123
	tar xozf atlas3.8.3.tar.gz ATLAS/include
124 125

atlas3.8.3.tar.gz:
126 127
	wget -T 10  http://sourceforge.net/projects/math-atlas/files/Stable/3.8.3/atlas3.8.3.tar.gz || \
	wget --no-check-certificate -T 10 -t 3 http://www.danielpovey.com/files/kaldi/atlas3.8.3.tar.gz
128 129 130 131 132 133

sph2pipe: sph2pipe_compiled

sph2pipe_compiled: sph2pipe_v2.5/sph2pipe

sph2pipe_v2.5/sph2pipe: | sph2pipe_v2.5
134 135
	cd sph2pipe_v2.5/; \
	$(CC) -o sph2pipe  *.c -lm
136 137

sph2pipe_v2.5: sph2pipe_v2.5.tar.gz
138
	tar xzf sph2pipe_v2.5.tar.gz
139 140

sph2pipe_v2.5.tar.gz:
141 142
	wget --no-check-certificate -T 10  https://sourceforge.net/projects/kaldi/files/sph2pipe_v2.5.tar.gz || \
	wget -T 10 -t 3 http://www.openslr.org/resources/3/sph2pipe_v2.5.tar.gz
143

144 145 146 147
openblas: openblas_compiled

.PHONY: openblas_compiled

148
fortran_opt = $(shell gcc -v 2>&1 | perl -e '$$x = join(" ", <STDIN>); if($$x =~ m/target=\S+64\S+/) { print "BINARY=64"; }')
149

150

Dan Povey's avatar
Dan Povey committed
151 152 153 154
# note: you can change the USE_THREAD=0 option below to USE_THREAD=1
# if you want Open Blas to use multiple threads.  then you could set,
# for example, OPENBLAS_NUM_THREADS=2 in your path.sh so that the
# runtime knows how many threads to use.
155 156 157 158 159
# Note: if you ever get the error "Program is Terminated. Because you tried to
# allocate too many memory regions.", this is because OpenBLAS has a fixed
# buffer size for the number of threads and you might have gone beyond that.  It
# may possibly help to add e.g. NUM_THREADS=64 to the command line below (after
# $(MAKE)).
160 161
openblas_compiled:
	-git clone git://github.com/xianyi/OpenBLAS
Dan Povey's avatar
Dan Povey committed
162 163
	cd OpenBLAS; sed 's:# FCOMMON_OPT = -frecursive:FCOMMON_OPT = -frecursive:' < Makefile.rule >tmp && mv tmp Makefile.rule
	$(MAKE) PREFIX=`pwd`/OpenBLAS/install FC=gfortran $(fortran_opt) DEBUG=1 USE_THREAD=1 -C OpenBLAS all install
164

165 166 167 168 169 170 171 172 173 174
# libsndfile needed by beamformit,
libsndfile: libsndfile-1.0.25.tar.gz libsndfile-1.0.25/lib/libsndfile.so
libsndfile-1.0.25.tar.gz:
	wget http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.25.tar.gz
libsndfile-1.0.25/lib/libsndfile.so:
	tar xvf libsndfile-1.0.25.tar.gz && cd libsndfile-1.0.25/ && \
	./configure --prefix=$(PWD)/libsndfile-1.0.25/ && make && make install

# beamforming tool,
beamformit: libsndfile beamformit-3.51
175

176
.PHONY: beamformit-3.51
177

178
beamformit-3.51: beamformit-3.51.tgz
179
	tar -xozf BeamformIt-3.51.tgz; \
180
	cd BeamformIt-3.51; patch -p1 -N < ../extras/beamformit.patch; cmake . ; make
181

182 183
beamformit-3.51.tgz:
	wget -c -T 10 http://www.xavieranguera.com/beamformit/releases/BeamformIt-3.51.tgz
184