Makefile 3.3 KB
Newer Older
小湉湉's avatar
小湉湉 已提交
1
SHELL:= /bin/bash
H
Hui Zhang 已提交
2
PYTHON:= python3.7
H
Hui Zhang 已提交
3 4 5 6 7 8 9 10

CXX ?= g++
CC ?= gcc        # used for sph2pipe
# CXX = clang++  # Uncomment these lines...
# CC = clang     # ...to build with Clang.

WGET ?= wget

H
Hui Zhang 已提交
11
.PHONY: all clean
H
Hui Zhang 已提交
12

H
Hui Zhang 已提交
13
all: virtualenv kenlm.done sox.done soxbindings.done mfa.done sclite.done
H
Hui Zhang 已提交
14 15 16 17 18

virtualenv:
	test -d venv || virtualenv -p $(PYTHON) venv
	touch venv/bin/activate

H
Hui Zhang 已提交
19 20 21 22 23 24
clean:
	rm -fr venv
	find -iname "*.pyc" -delete
	rm -rf kenlm

kenlm.done:
H
Hui Zhang 已提交
25 26 27 28 29
	# Ubuntu 16.04 透過 apt 會安裝 boost 1.58.0
	# it seems that boost (1.54.0) requires higher version. After I switched to g++-5 it compiles normally.
	apt install -y build-essential cmake libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-test-dev libeigen3-dev zlib1g-dev libbz2-dev liblzma-dev
	apt-get install -y gcc-5 g++-5 && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50  && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50
	test -d kenlm || wget -O - https://kheafield.com/code/kenlm.tar.gz | tar xz
30
	rm -rf kenlm/build && mkdir -p kenlm/build && cd kenlm/build && cmake .. && make -j4 && make install
H
Hui Zhang 已提交
31
	source venv/bin/activate; cd kenlm && python setup.py install
H
Hui Zhang 已提交
32
	touch kenlm.done
H
Hui Zhang 已提交
33

H
Hui Zhang 已提交
34 35 36 37 38 39
sox.done:
	apt install -y libvorbis-dev libmp3lame-dev libmad-ocaml-dev
	test -d sox-14.4.2 || wget https://nchc.dl.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.gz
	tar -xvzf sox-14.4.2.tar.gz -C .
	cd sox-14.4.2 && ./configure --prefix=/usr/ && make -j4 && make install
	touch sox.done
H
Hui Zhang 已提交
40

H
Hui Zhang 已提交
41 42
soxbindings.done:
	test -d soxbindings || git clone https://github.com/pseeth/soxbindings.git
H
Hui Zhang 已提交
43
	source venv/bin/activate; cd soxbindings && python setup.py install
H
Hui Zhang 已提交
44
	touch soxbindings.done
小湉湉's avatar
小湉湉 已提交
45 46 47 48

mfa.done:
	test -d montreal-forced-aligner || wget https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner/releases/download/v1.0.1/montreal-forced-aligner_linux.tar.gz
	tar xvf montreal-forced-aligner_linux.tar.gz
49
	touch mfa.done
H
Hui Zhang 已提交
50 51


H
Hui Zhang 已提交
52 53 54 55 56 57 58 59 60 61
#== SCTK ===============================================================================
# SCTK official repo does not have version tags. Here's the mapping:
# # 2.4.9 = 659bc36; 2.4.10 = d914e1b; 2.4.11 = 20159b5.
SCTK_GITHASH = 20159b5

SCTK_CXFLAGS = -w -march=native
SCTK_MKENV = CFLAGS="$(CFLAGS) $(SCTK_CXFLAGS)" \
			              CXXFLAGS="$(CXXFLAGS) -std=c++11 $(SCTK_CXFLAGS)" \


H
Hui Zhang 已提交
62 63
# Keep the existing target 'sclite' to avoid breaking the users who might have
# scripted it in.
H
Hui Zhang 已提交
64
.PHONY: sclite.done sctk_cleaned sctk_made
H
Hui Zhang 已提交
65

H
Hui Zhang 已提交
66 67
sclite.done sctk_made: sctk/.compiled
	touch sclite.done
H
Hui Zhang 已提交
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

sctk/.compiled: sctk
	rm -f sctk/.compiled
	$(SCTK_MKENV) $(MAKE) -C sctk config
	$(SCTK_MKENV) $(MAKE) -C sctk all doc
	$(MAKE) -C sctk install
	touch sctk/.compiled

# The GitHub archive unpacks into SCTK-{40-character-long-hash}/
sctk: sctk-$(SCTK_GITHASH).tar.gz
	tar zxvf sctk-$(SCTK_GITHASH).tar.gz
	rm -rf sctk-$(SCTK_GITHASH) sctk
	mv SCTK-$(SCTK_GITHASH)* sctk-$(SCTK_GITHASH)
	ln -s sctk-$(SCTK_GITHASH) sctk
	touch sctk-$(SCTK_GITHASH).tar.gz

sctk-$(SCTK_GITHASH).tar.gz:
	if [ -d '$(DOWNLOAD_DIR)' ]; then \
	  cp -p '$(DOWNLOAD_DIR)/sctk-$(SCTK_GITHASH).tar.gz' .; \
	else \
	  $(WGET) -nv -T 10 -t 3 -O sctk-$(SCTK_GITHASH).tar.gz \
	    https://github.com/usnistgov/SCTK/archive/$(SCTK_GITHASH).tar.gz; \
	fi

sctk_cleaned:
	-for d in sctk/ sctk-*/; do \
	   [ ! -f $$d/.compiled ] || $(MAKE) -C $$d clean; \
	   rm -f $$d/.compiled; \
H
Hui Zhang 已提交
96
	done