diff options
author | Emil Renner Berthing <esmil@mailme.dk> | 2012-01-06 17:54:40 +0100 |
---|---|---|
committer | Emil Renner Berthing <esmil@mailme.dk> | 2012-07-18 15:37:12 +0200 |
commit | bc525acebe8dbe4ec89e73703906b46fa6206d89 (patch) | |
tree | 7f1a5e520248f1dfc81c55149623039150ad8fda /Makefile | |
parent | a646b691b54cdb44fd404ab1a1332ee1bc8d7d25 (diff) | |
download | lem-postgres-bc525acebe8dbe4ec89e73703906b46fa6206d89.tar.gz lem-postgres-bc525acebe8dbe4ec89e73703906b46fa6206d89.tar.xz lem-postgres-bc525acebe8dbe4ec89e73703906b46fa6206d89.zip |
update for LEM 0.3
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 87 |
1 files changed, 46 insertions, 41 deletions
@@ -1,57 +1,62 @@ -CC = gcc -CFLAGS ?= -O2 -pipe -Wall -Wextra -Wno-variadic-macros -Wno-strict-aliasing -PKGCONFIG = pkg-config +CC = gcc -std=gnu99 +CFLAGS ?= -O2 -pipe -Wall -Wextra +PKG_CONFIG = pkg-config +PG_CONFIG = pg_config STRIP = strip INSTALL = install +UNAME = uname + +OS = $(shell $(UNAME)) +CFLAGS += $(shell $(PKG_CONFIG) --cflags lem) +lmoddir = $(shell $(PKG_CONFIG) --variable=INSTALL_LMOD lem) +cmoddir = $(shell $(PKG_CONFIG) --variable=INSTALL_CMOD lem) + +ifeq ($(OS),Darwin) +SHARED = -dynamiclib -Wl,-undefined,dynamic_lookup +STRIP += -x +else +SHARED = -shared +endif -CFLAGS += $(shell $(PKGCONFIG) --cflags lem) -LUA_PATH = $(shell $(PKGCONFIG) --variable=path lem) -LUA_CPATH = $(shell $(PKGCONFIG) --variable=cpath lem) - -programs = postgres.so -scripts = queued.lua +llibs = lem/postgres/queued.lua +clibs = lem/postgres.so -ifdef NDEBUG -CFLAGS += -DNDEBUG +ifdef V +E=@\# +Q= +else +E=@echo +Q=@ endif -.PHONY: all strip install clean -.PRECIOUS: %.o +.PHONY: all debug strip install clean -all: $(programs) +all: CFLAGS += -DNDEBUG +all: $(clibs) -%.o: %.c - @echo ' CC $@' - @$(CC) $(CFLAGS) -fPIC -nostartfiles -c $< -o $@ +debug: $(clibs) -postgres.so: CFLAGS += -I$(shell pg_config --includedir) -postgres.so: postgres.o - @echo ' LD $@' - @$(CC) -shared -L$(shell pg_config --libdir) -lpq $(LDFLAGS) $^ -o $@ +lem/postgres.so: CFLAGS += -I$(shell $(PG_CONFIG) --includedir) +lem/postgres.so: LDFLAGS += -L$(shell $(PG_CONFIG) --libdir) +lem/postgres.so: LIBS += -lpq +lem/postgres.so: lem/postgres.c + $E ' CCLD $@' + $Q$(CC) $(CFLAGS) -fPIC -nostartfiles $(SHARED) $^ -o $@ $(LDFLAGS) $(LIBS) %-strip: % - @echo ' STRIP $<' - @$(STRIP) $< - -strip: $(programs:%=%-strip) - -path-install: - @echo " INSTALL -d $(LUA_PATH)/lem/postgres" - @$(INSTALL) -d $(DESTDIR)$(LUA_PATH)/lem/postgres - -%.lua-install: %.lua path-install - @echo " INSTALL $<" - @$(INSTALL) -m644 $< $(DESTDIR)$(LUA_PATH)/lem/postgres/$< + $E ' STRIP $<' + $Q$(STRIP) $< -cpath-install: - @echo " INSTALL -d $(LUA_CPATH)/lem" - @$(INSTALL) -d $(DESTDIR)$(LUA_CPATH)/lem +strip: $(clibs:%=%-strip) -%.so-install: %.so cpath-install - @echo " INSTALL $<" - @$(INSTALL) $< $(DESTDIR)$(LUA_CPATH)/lem/$< +$(DESTDIR)$(lmoddir)/% $(DESTDIR)$(cmoddir)/%: % + $E ' INSTALL $@' + $Q$(INSTALL) -d $(dir $@) + $Q$(INSTALL) -m 644 $< $@ -install: $(programs:%=%-install) $(scripts:%=%-install) +install: \ + $(llibs:%=$(DESTDIR)$(lmoddir)/%) \ + $(clibs:%=$(DESTDIR)$(cmoddir)/%) clean: - rm -f $(programs) *.o *.c~ *.h~ + rm -f $(clibs) |