blob: c831f47d5b7e53182fdf166aebaf81241ab105bb (
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
58
59
60
61
62
|
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)
CFLAGS += -I$(shell $(PG_CONFIG) --includedir)
LDFLAGS += -L$(shell $(PG_CONFIG) --libdir)
LIBS = -lpq
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
llibs = lem/postgres/queued.lua
clibs = lem/postgres.so
ifdef V
E=@\#
Q=
else
E=@echo
Q=@
endif
.PHONY: all debug strip install clean
all: CFLAGS += -DNDEBUG
all: $(clibs)
debug: $(clibs)
lem/postgres.so: lem/postgres.c
$E ' CCLD $@'
$Q$(CC) $(CFLAGS) -fPIC -nostartfiles $(SHARED) $^ -o $@ $(LDFLAGS) $(LIBS)
%-strip: %
$E ' STRIP $<'
$Q$(STRIP) $<
strip: $(clibs:%=%-strip)
$(DESTDIR)$(lmoddir)/% $(DESTDIR)$(cmoddir)/%: %
$E ' INSTALL $@'
$Q$(INSTALL) -d $(dir $@)
$Q$(INSTALL) -m 644 $< $@
install: \
$(llibs:%=$(DESTDIR)$(lmoddir)/%) \
$(clibs:%=$(DESTDIR)$(cmoddir)/%)
clean:
rm -f $(clibs)
|