summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorEmil Renner Berthing <esmil@mailme.dk>2011-03-02 23:18:34 +0100
committerEmil Renner Berthing <esmil@mailme.dk>2011-03-02 23:19:55 +0100
commit0b728575358645f6e9a3f98959dd6995325f7380 (patch)
tree0f536cee6ad6cdfa982e143bc0c5fb85193f5fc9 /Makefile
downloadlem-postgres-0b728575358645f6e9a3f98959dd6995325f7380.tar.gz
lem-postgres-0b728575358645f6e9a3f98959dd6995325f7380.tar.xz
lem-postgres-0b728575358645f6e9a3f98959dd6995325f7380.zip
initial commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile52
1 files changed, 52 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ca0b6b5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,52 @@
+CC = gcc
+CFLAGS ?= -O2 -pipe -Wall -Wextra -Wno-variadic-macros -Wno-strict-aliasing -I$(shell pg_config --includedir)
+LDFLAGS ?= -L$(shell pg_config --libdir)
+STRIP = strip
+INSTALL = install
+
+LUA_VERSION = 5.1
+PREFIX = /usr/local
+LIBDIR = $(PREFIX)/lib/lua/$(LUA_VERSION)/lem
+
+programs = postgres.so
+scripts = queued.lua
+
+ifdef NDEBUG
+DEFINES+=-DNDEBUG
+endif
+
+.PHONY: all strip install indent clean
+.PRECIOUS: %.o
+
+all: $(programs)
+
+%.o: %.c
+ @echo ' CC $@'
+ @$(CC) $(CFLAGS) -I$(PREFIX)/include -fPIC -nostartfiles $(DEFINES) -c $< -o $@
+
+%.so: %.o
+ @echo ' LD $@'
+ @$(CC) -shared -lpq $(LDFLAGS) $^ -o $@
+
+%-strip: %
+ @echo ' STRIP $<'
+ @$(STRIP) $<
+
+strip: $(programs:%=%-strip)
+
+libdir-install:
+ @echo " INSTALL -d $(LIBDIR)"
+ @$(INSTALL) -d $(DESTDIR)$(LIBDIR)/postgres
+
+%.lua-install: %.lua libdir-install
+ @echo " INSTALL $<"
+ @$(INSTALL) $< $(DESTDIR)$(LIBDIR)/postgres/$<
+
+%.so-install: %.so libdir-install
+ @echo " INSTALL $<"
+ @$(INSTALL) $< $(DESTDIR)$(LIBDIR)/$<
+
+install: $(programs:%=%-install) $(scripts:%=%-install)
+
+clean:
+ rm -f $(programs) *.o *.c~ *.h~