aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-05-14 08:53:50 +0800
committerDeterminant <[email protected]>2015-05-14 08:53:50 +0800
commit32e1ebaa367bc9df4e19ee0634dd054ae298ae06 (patch)
tree45e20ac6fa9dcf42ca6f66702b7f2eeef4d6fd8a
parenta774bfc860471ac880a9b33bbe68761ec9187caf (diff)
integrate luajit build process into makefile
-rw-r--r--Makefile17
-rwxr-xr-xbuild_luajit.sh5
-rwxr-xr-xinstall.sh5
3 files changed, 15 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 659774c..9fd8873 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,21 @@
-.PHONY: all clean
+.PHONY: all clean luajit
OBJS := oop_example.o nerv.o luaT.o
-INCLUDE := -I luajit-2.0/build/include/luajit-2.0/ -DLUA_USE_APICHECK
-LDFLAGS := -L luajit-2.0/build/lib/ -llua -lm
+LIBS := libnerv.so
+INCLUDE := -I build/luaJIT/include/luajit-2.0/ -DLUA_USE_APICHECK
+#LDFLAGS := -L luajit-2.0/build/lib/ -llua -lm
OBJ_DIR := build/objs
OBJS := $(addprefix $(OBJ_DIR)/,$(OBJS))
-all: libnerv.so
-$(OBJS): $(OBJ_DIR)
+LIBS := $(addprefix $(OBJ_DIR)/,$(LIBS))
+all: luajit $(OBJ_DIR) $(LIBS)
+luajit:
+ ./build_luajit.sh
$(OBJ_DIR):
-mkdir -p $(OBJ_DIR)
$(OBJ_DIR)/%.o: %.c
gcc -c -o $@ $< $(INCLUDE) -fPIC
$(OBJ_DIR)/luaT.o:
gcc -c -o $@ luaT/luaT.c $(INCLUDE) -fPIC
-libnerv.so: $(OBJS)
- gcc -shared -o $(OBJ_DIR)/$@ $(OBJS)
+$(LIBS): $(OBJS)
+ gcc -shared -o $@ $(OBJS)
clean:
-rm -rf $(OBJ_DIR)
diff --git a/build_luajit.sh b/build_luajit.sh
new file mode 100755
index 0000000..bb23b5f
--- /dev/null
+++ b/build_luajit.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+PREFIX="${PWD}/build"
+LUAJIT_SRC='luajit-2.0/'
+LUAJIT_PREFIX="${PREFIX}/luajit-2.0"
+[[ -d $LUAJIT_PREFIX ]] || (cd "$LUAJIT_SRC"; make && make PREFIX="$LUAJIT_PREFIX" install)
diff --git a/install.sh b/install.sh
deleted file mode 100755
index 3b0f423..0000000
--- a/install.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-PREFIX="${PWD}/build"
-LUAJIT_SRC='luajit-2.0/'
-LUAJIT_PREFIX="${PREFIX}/luaJIT"
-(cd "$LUAJIT_SRC"; make && make PREFIX="$LUAJIT_PREFIX" install)