summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile22
1 files changed, 17 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 60a1d7e..38043f6 100644
--- a/Makefile
+++ b/Makefile
@@ -19,11 +19,16 @@ CMOD_OBJECTS := $(patsubst %,lib/%.o,$(subst .,/,$(CMODULES)))
.PRECIOUS: $(CMOD_OBJECTS)
+LUA_INTERP_NAME := lua$(LUA_VER)
+LUA_INTERP_PATH := $(shell which lua$(LUA_VER))
+
INCS := -I/usr/include/lua$(LUA_VER)
OPT := -O0 -g
WARN := -Wall -Werror
-CFLAGS := $(INCS) $(OPT) $(WARN) $(CFLAGS)
-LFLAGS := -O1 -g -shared $(LFLAGS)
+DEFS := -D'LUA_INTERP_NAME="$(LUA_INTERP_NAME)"' \
+ -D'LUA_INTERP_PATH="$(LUA_INTERP_PATH)"'
+CFLAGS := $(INCS) $(OPT) $(WARN) $(DEFS) $(CFLAGS)
+LFLAGS := -O1 -g $(LFLAGS)
%.so: %.o
$(CC) $(LFLAGS) -shared -o $@ $^ -llua$(LUA_VER)
@@ -31,7 +36,13 @@ LFLAGS := -O1 -g -shared $(LFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -fPIC -o $@ -c $<
-build: $(CMOD_TARGETS)
+build: $(CMOD_TARGETS) wrapper
+
+wrapper: src/wrapper.c
+ $(CC) $(LFLAGS) $(CFLAGS) -o $@ $< -llua$(LUA_VER)
+
+testwrapper: src/wrapper.c
+ $(CC) $(LFLAGS) $(CFLAGS) -DTESTING_SUPPLE -o $@ $< -llua$(LUA_VER)
install: build
mkdir -p $(LINST_ROOT)/supple
@@ -47,11 +58,12 @@ ifeq ($(DEBUG),gdb)
GDB := gdb --args
endif
-LUA := LUA_PATH="$(shell pwd)/lib/?.lua;$(shell pwd)/extras/luacov/src/?.lua;;" LUA_CPATH="$(shell pwd)/lib/?.so;;" $(GDB) lua$(LUA_VER)
+LUA := LUA_PATH="$(shell pwd)/lib/?.lua;$(shell pwd)/extras/luacov/src/?.lua;;" LUA_CPATH="$(shell pwd)/lib/?.so;;" $(GDB) $(LUA_INTERP_PATH)
clean:
$(RM) luacov.report.out luacov.stats.out
$(RM) $(CMOD_TARGETS) $(CMOD_OBJECTS)
+ $(RM) wrapper testwrapper
distclean: clean
find . -name "*~" -delete
@@ -61,7 +73,7 @@ example:
$(LUA) example/supple-example.lua
.PHONY: test
-test: build
+test: build testwrapper
@$(RM) luacov.stats.out
@ERR=0; \
for MOD in $(sort $(TEST_MODULES)); do \