blob: 2ccedfbbd186c2dbf77a7ffbda95d9a9d69b9f75 (
plain) (
blame)
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
|
ifndef LUA_BINDIR
$(error Please build the package via luarocks: `luarocks make`)
endif
ifndef KALDI_BASE
$(error KALDI_BASE is not set)
endif
ifndef CUDA_BASE
$(error CUDA_BASE is not set)
endif
KDIR := $(KALDI_BASE)
BUILD_DIR := $(CURDIR)/build
INC_PATH := $(LUA_BINDIR)/../include/
OBJS := src/nnet-forward.o nnet-forward
SUBDIR := src
OBJ_DIR := $(BUILD_DIR)/objs
LUA_DIR = $(INST_LUADIR)/kaldi_decode
KALDIINCLUDE := -I $(KDIR)/tools/ATLAS/include/ -I $(KDIR)/tools/openfst/include/ -I $(KDIR)/src/
OBJS := $(addprefix $(OBJ_DIR)/,$(OBJS))
OBJ_SUBDIR := $(addprefix $(OBJ_DIR)/,$(SUBDIR))
KL := $(KDIR)/src/feat/kaldi-feat.a $(KDIR)/src/cudamatrix/kaldi-cudamatrix.a $(KDIR)/src/matrix/kaldi-matrix.a $(KDIR)/src/base/kaldi-base.a $(KDIR)/src/util/kaldi-util.a $(KDIR)/src/hmm/kaldi-hmm.a $(KDIR)/src/tree/kaldi-tree.a $(KDIR)/src/nnet/kaldi-nnet.a $(BLAS_LDFLAGS)
build: $(OBJ_DIR) $(OBJ_SUBDIR) $(OBJS)
$(OBJ_DIR)/%.o: %.cc
g++ -c -o $@ $< -Wall $(KALDIINCLUDE) -DHAVE_ATLAS -DKALDI_DOUBLEPRECISION=0 -DHAVE_POSIX_MEMALIGN -DLUA_USE_APICHECK -I $(LUA_INCDIR) -I $(INC_PATH) $(CFLAGS)
$(OBJ_DIR)/nnet-forward: $(OBJ_DIR)/src/nnet-forward.o
g++ -o $@ $< $(KL) -L$(LUA_LIBDIR) -Wl,-rpath=$(LUA_LIBDIR) -lluajit-5.1 -L$(CUDA_BASE)/lib64/ -Wl,-rpath=$(CUDA_BASE)/lib64/ -lcudart -lcublas -ldl
$(OBJ_DIR) $(LUA_DIR) $(OBJ_SUBDIR):
-mkdir -p $@
install: $(LUA_DIR)
cp $(OBJ_DIR)/nnet-forward $(LUA_BINDIR)/nnet-forward-with-nerv
cp src/asr_propagator.lua $(LUA_DIR)/
sed 's*nnet_forward=*nnet_forward=$(LUA_BINDIR)/nnet-forward-with-nerv.sh*g;s*asr_propagator=*asr_propagator=$(LUA_BINDIR)/../share/lua/5.1/kaldi_decode/asr_propagator.lua*g' decode_with_nerv.sh > $(LUA_BINDIR)/decode_with_nerv.sh
echo '$(LUA_BINDIR)/nnet-forward-with-nerv "$$@"' | cat nnet-forward-with-nerv.sh - | sed 's*\.\./\.\./install/bin/luarocks*$(LUA_BINDIR)/luarocks*g' > $(LUA_BINDIR)/nnet-forward-with-nerv.sh
chmod +x $(LUA_BINDIR)/nnet-forward-with-nerv.sh
chmod +x $(LUA_BINDIR)/decode_with_nerv.sh
clean:
-rm -r $(OBJ_DIR)
|