summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2015-06-22 18:56:04 +0800
committerDeterminant <ted.sybil@gmail.com>2015-06-22 18:56:04 +0800
commit32eac093cc431849a92e5a2297c5fe646fd60556 (patch)
tree28a7043f7d7138d58916b60de7231b093d93bbde
parent3910eb670f3c29aba95596bb8c55cbee3368f805 (diff)
make it a luarocks package
-rw-r--r--Makefile34
-rw-r--r--init.c2
-rw-r--r--speech-scm-1.rockspec38
-rw-r--r--tnet_io/cwrapper.cpp2
-rw-r--r--tnet_io/cwrapper.h4
-rw-r--r--tnet_io/init.c2
6 files changed, 70 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 78c18da..08c4392 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,33 @@
.PHONY: tnet
-INCLUDE := -I $(BUILD_DIR)/luajit-2.0/include/luajit-2.0
-all: tnet $(OBJ_DIR)/tnet_io/test $(LIB_DIR)/libspeech.so $(LUA_DIR)/speech/init.lua
-$(LUA_DIR)/speech/init.lua: init.lua
- mkdir -p $(LUA_DIR)/speech
+SHELL := /bin/bash
+BUILD_DIR := $(CURDIR)/build
+OBJS := init.o tnet_io/cwrapper.o tnet_io/init.o
+LIBS := libspeech.so
+LUA_LIBS := init.lua
+INCLUDE := -I $(LUA_INCDIR) -DLUA_USE_APICHECK
+
+SUBDIR := tnet_io
+OBJ_DIR := $(BUILD_DIR)/objs
+LUA_DIR = $(INST_LUADIR)/speech
+
+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
+
+build: $(OBJ_DIR) $(OBJ_SUBDIR) $(OBJS) tnet $(OBJ_DIR)/tnet_io/test
+install: $(LUA_DIR) $(LUA_SUBDIR) $(LUA_LIBS) $(LIBS)
+
+$(OBJ_DIR) $(LUA_DIR) $(OBJ_SUBDIR) $(LUA_SUBDIR):
+ -mkdir -p $@
+$(LUA_DIR)/%.lua: %.lua
cp $< $@
-$(LIB_DIR)/libspeech.so: $(OBJ_DIR)/tnet_io/cwrapper.o $(OBJ_DIR)/init.o $(OBJ_DIR)/tnet_io/init.o $(OBJ_DIR)/tnet_io/libKaldiLib.a
- gcc -shared -o $@ $(OBJ_DIR)/tnet_io/cwrapper.o $(OBJ_DIR)/init.o $(OBJ_DIR)/tnet_io/libKaldiLib.a $(OBJ_DIR)/tnet_io/init.o -lstdc++ -Wl,-rpath=$(LIB_DIR) -L$(LIB_DIR) -lnerv
+$(LIBS): $(OBJ_DIR)/tnet_io/cwrapper.o $(OBJ_DIR)/init.o $(OBJ_DIR)/tnet_io/init.o $(OBJ_DIR)/tnet_io/libKaldiLib.a
+ gcc -shared -o $@ $(OBJ_DIR)/tnet_io/cwrapper.o $(OBJ_DIR)/init.o $(OBJ_DIR)/tnet_io/libKaldiLib.a $(OBJ_DIR)/tnet_io/init.o -lstdc++ -Wl,-rpath=$(LIB_PATH) -L$(LIB_PATH) -lnerv
$(OBJ_DIR)/tnet_io/test: $(OBJ_DIR)/tnet_io/cwrapper.o $(OBJ_DIR)/tnet_io/test.o $(OBJ_DIR)/tnet_io/libKaldiLib.a
- gcc -o $@ $^ -Wl,-rpath=$(LIB_DIR) -L$(LIB_DIR) -lnerv -Wl,-rpath=$(BUILD_DIR)/luajit-2.0/lib -L$(BUILD_DIR)/luajit-2.0/lib -lluajit-5.1 -lstdc++ -lm
+ gcc -o $@ $^ -Wl,-rpath=$(LIB_PATH) -L$(LIB_PATH) -lnerv -Wl,-rpath=$(LUA_LIBDIR) -L$(LUA_LIBDIR) -lluajit-5.1 -lstdc++ -lm
$(OBJ_DIR)/tnet_io/cwrapper.o: tnet_io/cwrapper.cpp
g++ -o $@ -c $< -DHAVE_ATLAS -I tnet_io/KaldiLib/ -g -fPIC $(INCLUDE)
$(OBJ_DIR)/%.o: %.c
diff --git a/init.c b/init.c
index 0cf476d..fef5527 100644
--- a/init.c
+++ b/init.c
@@ -1,4 +1,4 @@
-#include "../common.h"
+#include "../nerv/common.h"
#include <stdio.h>
extern void tnet_io_init(lua_State *L);
diff --git a/speech-scm-1.rockspec b/speech-scm-1.rockspec
new file mode 100644
index 0000000..bf11cbc
--- /dev/null
+++ b/speech-scm-1.rockspec
@@ -0,0 +1,38 @@
+package = "speech"
+version = "scm-1"
+source = {
+ url = "..." -- We don't have one yet
+}
+description = {
+ summary = "An example for the LuaRocks tutorial.",
+ detailed = [[
+ ]],
+ homepage = "https://github.com/Determinant/nerv-speech", -- We don't have one yet
+ license = "BSD" -- or whatever you like
+}
+dependencies = {
+ "nerv >= scm-1",
+ "lua >= 5.1"
+ -- If you depend on other rocks, add them here
+}
+build = {
+ -- We'll start here.
+ type = "make",
+ build_variables = {
+ CFLAGS="$(CFLAGS)",
+ LIBFLAG="$(LIBFLAG)",
+ LUA_LIBDIR="$(LUA_LIBDIR)",
+ LUA_BINDIR="$(LUA_BINDIR)",
+ LUA_INCDIR="$(LUA_INCDIR)",
+ INST_PREFIX="$(PREFIX)",
+ LUA="$(LUA)",
+ },
+ install_variables = {
+ LUA_BINDIR="$(LUA_BINDIR)",
+ INST_PREFIX="$(PREFIX)",
+ INST_BINDIR="$(BINDIR)",
+ INST_LIBDIR="$(LIBDIR)",
+ INST_LUADIR="$(LUADIR)",
+ INST_CONFDIR="$(CONFDIR)",
+ },
+}
diff --git a/tnet_io/cwrapper.cpp b/tnet_io/cwrapper.cpp
index 800df2e..84e1d63 100644
--- a/tnet_io/cwrapper.cpp
+++ b/tnet_io/cwrapper.cpp
@@ -8,7 +8,7 @@
extern "C" {
#include "cwrapper.h"
#include "string.h"
-#include "../../common.h"
+#include "../../nerv/common.h"
extern Matrix *nerv_matrix_host_float_new_(lua_State *L, long nrow, long ncol);
diff --git a/tnet_io/cwrapper.h b/tnet_io/cwrapper.h
index c2ca1ba..01371ec 100644
--- a/tnet_io/cwrapper.h
+++ b/tnet_io/cwrapper.h
@@ -1,7 +1,7 @@
#ifndef NERV_TNET_IO_CWRAPPER
#define NERV_TNET_IO_CWRAPPER
-#include "../../matrix/generic/matrix.h"
-#include "../../common.h"
+#include "../../nerv/matrix/generic/matrix.h"
+#include "../../nerv/common.h"
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/tnet_io/init.c b/tnet_io/init.c
index da93b35..5251d1e 100644
--- a/tnet_io/init.c
+++ b/tnet_io/init.c
@@ -1,4 +1,4 @@
-#include "../../common.h"
+#include "../../nerv/common.h"
#include "cwrapper.h"
#include <stdio.h>