diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -28,12 +28,26 @@ CMOD_OBJECTS := $(patsubst %,lib/%.o,$(subst .,/,$(CMODULES))) LUA_INTERP_NAME := lua$(LUA_VER) LUA_INTERP_PATH := $(shell which lua$(LUA_VER)) +# Override these variables +# to bake LUA_PATH and LUA_CPATH environment variables into the sandbox binary. +# They can't be set at runtime for security reasons. +BAKE_SUPPLE_PATHS := 0 +SUPPLE_LUA_PATH := "" +SUPPLE_LUA_CPATH := "" + +ifeq ($(BAKE_SUPPLE_PATHS), 1) + DEF_BAKE_SUPPLE_PATHS=-DBAKE_SUPPLE_PATHS +else + DEF_BAKE_SUPPLE_PATHS= +endif + INCS := -I/usr/include/lua$(LUA_VER) OPT := -O0 -g WARN := -Wall -Werror DEFS := -D'LUA_INTERP_NAME="$(LUA_INTERP_NAME)"' \ -D'LUA_INTERP_PATH="$(LUA_INTERP_PATH)"' \ - -D'WRAPPER_PATH="$(WRAPPER_PATH)"' + -D'WRAPPER_PATH="$(WRAPPER_PATH)"' $(DEF_BAKE_SUPPLE_PATHS) + CFLAGS := $(INCS) $(OPT) $(WARN) $(DEFS) $(CFLAGS) LFLAGS := -O1 -g $(LFLAGS) @@ -45,7 +59,10 @@ LFLAGS := -O1 -g $(LFLAGS) build: $(CMOD_TARGETS) wrapper -wrapper: src/wrapper.c +src/supple_paths.h: src/supple_paths.h.in + sed -e 's|@@SUPPLE_LUA_PATH@@|$(SUPPLE_LUA_PATH)|' -e 's|@@SUPPLE_LUA_CPATH@@|$(SUPPLE_LUA_CPATH)|' < $< > $@ + +wrapper: src/wrapper.c src/supple_paths.h $(CC) $(LFLAGS) $(CFLAGS) -o $@ $< $(LIB_LUA) testwrapper: src/wrapper.c @@ -80,7 +97,7 @@ LUA := SUPPLE_TEST_WRAPPER="$(shell pwd)/testwrapper" LUA_PATH="$(shell pwd)/lib clean: $(RM) luacov.report.out luacov.stats.out $(RM) $(CMOD_TARGETS) $(CMOD_OBJECTS) - $(RM) wrapper testwrapper + $(RM) wrapper testwrapper supple_paths.h $(RM) -r html distclean: clean |