fix 4-arg uci.set()
[project/uci.git] / lua / Makefile
index 29d7fbd..2861d21 100644 (file)
@@ -1,27 +1,29 @@
-CC=gcc
-LD=ld
-CFLAGS=-O2 -Wall -Werror -pedantic --std=gnu99 -Wno-unused
-CPPFLAGS=-I..
-LIBS=-L.. -luci
-OS=$(shell uname)
-LINK=$(CC)
+include ../Makefile.inc
+prefix=/usr/local
+libdir=$(prefix)/lib
+luadir=$(libdir)/lua/5.1
+
+CPPFLAGS=-I.. $(shell pkg-config --silence-errors --cflags lua5.1)
+LIBS=-L.. -luci $(shell pkg-config --silence-errors --libs lua5.1)
+
+PLUGIN_LD=$(CC)
 ifeq ($(OS),Darwin)
-  SHLIB_FLAGS=-bundle -undefined dynamic_lookup
+  PLUGIN_LDFLAGS=-bundle -undefined dynamic_lookup
 else
-  SHLIB_FLAGS=-shared -Wl,-soname,$(SHLIB_FILE)
+  PLUGIN_LDFLAGS=-shared -Wl,-soname,$(SHLIB_FILE)
 endif
 
 all: uci.so
 
 uci.so: uci.o
-       $(LINK) $(SHLIB_FLAGS) -o $@ $^ $(LIBS)
+       $(PLUGIN_LD) $(PLUGIN_LDFLAGS) -o $@ $^ $(LIBS)
 
 %.o: %.c
-       $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(FPIC) -c -o $@ $<
 
 install:
-       mkdir -p $(DESTDIR)/usr/lib/lua
-       install -m0644 uci.so $(DESTDIR)/usr/lib/lua/
+       mkdir -p $(DESTDIR)$(luadir)
+       $(INSTALL) -m0644 uci.so $(DESTDIR)$(luadir)/
 
 clean:
        rm -f *.so *.o uci.so