summaryrefslogtreecommitdiff
path: root/kaldi_io/Makefile
blob: abfa8e67a128cd344d3d0f7cb234ba2c73e22511 (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
44
45
46
47
48
49
50
ifndef LUA_BINDIR
$(error Please build the package via luarocks: `luarocks make`)
endif

ifndef KALDI_BASE
$(error KALDI_BASE is not set)
endif

KDIR := $(KALDI_BASE)
SHELL := /bin/bash
BUILD_DIR := $(CURDIR)/build
INC_PATH := $(LUA_BINDIR)/../include/
OBJS := init.o src/cwrapper_kaldi.o src/init.o
LIBS := libkaldiio.so
LUA_LIBS := init.lua
INCLUDE := -I $(LUA_INCDIR) -I $(INC_PATH) -DLUA_USE_APICHECK

SUBDIR := src
OBJ_DIR := $(BUILD_DIR)/objs
LUA_DIR := $(INST_LUADIR)/kaldi_io
KALDIINCLUDE := -I $(KDIR)/tools/ATLAS/include/ -I $(KDIR)/tools/openfst/include/ -I $(KDIR)/src/

OBJS := $(addprefix $(OBJ_DIR)/,$(OBJS))
LIBS := $(addprefix $(INST_LIBDIR)/,$(LIBS))
OBJ_SUBDIR := $(addprefix $(OBJ_DIR)/,$(SUBDIR))
LUA_SUBDIR := $(addprefix $(LUA_DIR)/,$(SUBDIR))
LUA_LIBS := $(addprefix $(LUA_DIR)/,$(LUA_LIBS))
LIB_PATH := $(LUA_BINDIR)/../lib
LUALIB_PATH := $(LUA_BINDIR)/../lib/lua/5.1/

build: $(OBJ_DIR) $(OBJ_SUBDIR) $(OBJS) $(OBJ_DIR)/src/test
install: $(LUA_DIR) $(LUA_SUBDIR) $(LUA_LIBS) $(LIBS)

include $(KDIR)/src/kaldi.mk
KL := $(KDIR)/src/feat/kaldi-feat.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 $(BLAS_LDFLAGS)
$(OBJ_DIR) $(LUA_DIR) $(OBJ_SUBDIR) $(LUA_SUBDIR):
	-mkdir -p $@
$(LUA_DIR)/%.lua: %.lua
	cp $< $@
$(LIBS): $(OBJ_DIR)/src/cwrapper_kaldi.o $(OBJ_DIR)/init.o $(OBJ_DIR)/src/init.o
	gcc -shared -fPIC -o $@ $(OBJ_DIR)/src/cwrapper_kaldi.o $(OBJ_DIR)/init.o $(OBJ_DIR)/src/init.o -lstdc++ -Wl,-rpath=$(LIB_PATH) -L$(LIB_PATH) -lnervcore -Wl,-rpath=$(LUALIB_PATH) -L$(LUALIB_PATH) -lnerv -lluaT $(KL)
$(OBJ_DIR)/src/cwrapper_kaldi.o: src/cwrapper_kaldi.cpp
	g++ -o $@ -c $< -DHAVE_ATLAS $(KALDIINCLUDE) -g -fPIC $(INCLUDE) -DKALDI_DOUBLEPRECISION=0 -msse2 -DHAVE_POSIX_MEMALIGN
$(OBJ_DIR)/src/test: $(OBJ_DIR)/src/cwrapper_kaldi.o $(OBJ_DIR)/src/test.o
	gcc -o $@ $^ -Wl,-rpath=$(LIB_PATH) -L$(LIB_PATH) $(INCLUDE) $(KALDIINCLUDE) -lnervcore -Wl,-rpath=$(LUA_LIBDIR) -L$(LUA_LIBDIR) -lluajit-5.1 -lstdc++ -lm $(KL)
$(OBJ_DIR)/%.o: %.c
	gcc -o $@ -c $< -g $(INCLUDE) -fPIC
clean:
	-rm -r $(OBJ_DIR)