X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=lua%2FMakefile;h=7dbe6964b14e81a33c2afa5965dca7983e8de13d;hp=9b6e72839aed97c46f3c3286e1787fbe530b1604;hb=c7430fd3578af03d9fe998f3195756603295ce2f;hpb=55736115e73e52ee2c210a466e61dd7129661aa8 diff --git a/lua/Makefile b/lua/Makefile index 9b6e728..7dbe696 100644 --- a/lua/Makefile +++ b/lua/Makefile @@ -1,7 +1,25 @@ include ../Makefile.inc +LUA_VERSION=5.1 +PREFIX_SEARCH=/usr /usr/local /opt/local +LUA_PLUGINDIR=$(firstword \ + $(foreach ldir,$(subst ;, ,$(shell lua -e 'print(package.cpath)')), \ + $(if $(findstring lib/lua/,$(ldir)),$(patsubst %/?.so,%,$(ldir))) \ + ) \ +) -CPPFLAGS=-I.. $(shell pkg-config --silence-errors --cflags lua5.1) -LIBS=-L.. -luci $(shell pkg-config --silence-errors --libs lua5.1) +# find lua prefix +LUA_PREFIX=$(firstword \ + $(foreach prefix,$(PREFIX_SEARCH),\ + $(if $(wildcard $(prefix)/include/lua.h),$(prefix)) \ + ) \ +) + +libdir=$(prefix)/libs +luadir=$(if $(LUA_PLUGINDIR),$(LUA_PLUGINDIR),$(libdir)/lua/$(LUA_VERSION)) +luainc=$(shell pkg-config --silence-errors --cflags lua$(LUA_VERSION)) + +CPPFLAGS=-I.. -I$(if $(luainc),$(luainc),$(LUA_PREFIX)/include) +LIBS=-L.. -luci $(shell pkg-config --silence-errors --libs lua$(LUA_VERSION)) PLUGIN_LD=$(CC) ifeq ($(OS),Darwin) @@ -19,8 +37,8 @@ uci.so: uci.o $(CC) $(CPPFLAGS) $(CFLAGS) $(FPIC) -c -o $@ $< install: - mkdir -p $(DESTDIR)$(prefix)/lib/lua/5.1 - $(INSTALL) -m0644 uci.so $(DESTDIR)$(prefix)/lib/lua/5.1/ + mkdir -p $(DESTDIR)$(luadir) + $(INSTALL) -m0644 uci.so $(DESTDIR)$(luadir)/ clean: rm -f *.so *.o uci.so