blob: 978ac73c8867fed9719634a2b09bcc647dc0806a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
CC = gcc
CFLAGS ?= -O2 -pipe -Wall -Wextra -Wno-variadic-macros -Wno-strict-aliasing
PKGCONFIG = pkg-config
STRIP = strip
INSTALL = install
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
ifdef NDEBUG
CFLAGS += -DNDEBUG
endif
.PHONY: all strip install clean
.PRECIOUS: %.o
all: $(programs)
%.o: %.c
@echo ' CC $@'
@$(CC) $(CFLAGS) -fPIC -nostartfiles -c $< -o $@
postgres.so: CFLAGS += -I$(shell pg_config --includedir)
postgres.so: postgres.o
@echo ' LD $@'
@$(CC) -shared -L$(shell pg_config --libdir) -lpq $(LDFLAGS) $^ -o $@
%-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/$<
cpath-install:
@echo " INSTALL -d $(LUA_CPATH)/lem"
@$(INSTALL) -d $(DESTDIR)$(LUA_CPATH)/lem
%.so-install: %.so cpath-install
@echo " INSTALL $<"
@$(INSTALL) $< $(DESTDIR)$(LUA_CPATH)/lem/$<
install: $(programs:%=%-install) $(scripts:%=%-install)
clean:
rm -f $(programs) *.o *.c~ *.h~
|