-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
159 lines (121 loc) · 3.87 KB
/
Makefile
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
EXTENSION = plproxy
# sync with NEWS, META.json, plproxy.control, debian/changelog
DISTVERSION = 2.6
EXTVERSION = 2.6.0
UPGRADE_VERS = 2.3.0 2.4.0 2.5.0
# set to 1 to disallow functions containing SELECT
NO_SELECT = 0
# libpq config
PG_CONFIG = pg_config
PQINCSERVER = $(shell $(PG_CONFIG) --includedir-server)
PQINC = $(shell $(PG_CONFIG) --includedir)
PQLIB = $(shell $(PG_CONFIG) --libdir)
# module setup
MODULE_big = $(EXTENSION)
SRCS = src/cluster.c src/execute.c src/function.c src/main.c \
src/query.c src/result.c src/type.c src/poll_compat.c src/aatree.c
OBJS = src/scanner.o src/parser.tab.o $(SRCS:.c=.o)
EXTRA_CLEAN = src/scanner.[ch] src/parser.tab.[ch] libplproxy.* plproxy.so
SHLIB_LINK = -L$(PQLIB) -lpq
HDRS = src/plproxy.h src/rowstamp.h src/aatree.h src/poll_compat.h
# Server include must come before client include, because there could
# be mismatching libpq-dev and postgresql-server-dev installed.
PG_CPPFLAGS = -I$(PQINCSERVER) -I$(PQINC) -DNO_SELECT=$(NO_SELECT)
ifdef VPATH
PG_CPPFLAGS += -I$(VPATH)/src
endif
DISTNAME = $(EXTENSION)-$(DISTVERSION)
# regression testing setup
REGRESS = plproxy_init plproxy_test plproxy_select plproxy_many \
plproxy_errors plproxy_clustermap plproxy_dynamic_record \
plproxy_encoding plproxy_split plproxy_target plproxy_alter \
plproxy_cancel
REGRESS_OPTS = --dbname=regression --inputdir=test
# pg9.1 ignores --dbname
override CONTRIB_TESTDB := regression
# sql source
PLPROXY_SQL = sql/plproxy_lang.sql
# Generated SQL files
EXTSQL = sql/$(EXTENSION)--$(EXTVERSION).sql \
$(foreach v,$(UPGRADE_VERS),sql/plproxy--$(v)--$(EXTVERSION).sql) \
sql/plproxy--unpackaged--$(EXTVERSION).sql
# PostgreSQL version
PGVER = $(shell $(PG_CONFIG) --version | sed 's/PostgreSQL //')
SQLMED = $(shell test "$(PGVER)" "<" "8.4" && echo "false" || echo "true")
PG91 = $(shell test "$(PGVER)" "<" "9.1" && echo "false" || echo "true")
PG92 = $(shell test "$(PGVER)" "<" "9.2" && echo "false" || echo "true")
# SQL/MED available, add foreign data wrapper and regression tests
ifeq ($(SQLMED), true)
REGRESS += plproxy_sqlmed plproxy_table
PLPROXY_SQL += sql/plproxy_fdw.sql
endif
# SQL for extensions or plain?
ifeq ($(PG91),true)
DATA_built = $(EXTSQL)
DATA = $(EXTMISC)
EXTRA_CLEAN += sql/plproxy.sql
else
DATA_built = sql/plproxy.sql
EXTRA_CLEAN += $(EXTSQL)
endif
ifeq ($(PG92), true)
REGRESS += plproxy_range
endif
#
# load PGXS makefile
#
PGXS = $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
ifeq ($(PORTNAME), win32)
SHLIB_LINK += -lws2_32 -lpgport
endif
# PGXS may define them as empty
FLEX := $(if $(FLEX),$(FLEX),flex)
BISON := $(if $(BISON),$(BISON),bison)
# parser rules
src/scanner.o: src/parser.tab.h
src/parser.tab.h: src/parser.tab.c
src/parser.tab.c: src/parser.y
@mkdir -p src
$(BISON) -b src/parser -d $<
src/scanner.c: src/scanner.l
@mkdir -p src
$(FLEX) -o$@ $<
sql/plproxy.sql: $(PLPROXY_SQL)
@mkdir -p sql
cat $^ > $@
# plain plproxy.sql is not installed, but used in tests
sql/$(EXTENSION)--$(EXTVERSION).sql: $(PLPROXY_SQL)
@mkdir -p sql
echo "create extension plproxy;" > sql/plproxy.sql
cat $^ > $@
$(foreach v,$(UPGRADE_VERS),sql/plproxy--$(v)--$(EXTVERSION).sql): sql/ext_update_validator.sql
@mkdir -p sql
cat $< >$@
sql/plproxy--unpackaged--$(EXTVERSION).sql: sql/ext_unpackaged.sql
@mkdir -p sql
cat $< > $@
# dependencies
$(OBJS): $(HDRS)
# utility rules
tags: $(SRCS) $(HDRS)
ctags $(SRCS) $(HDRS)
tgz:
git archive --prefix=$(DISTNAME)/ HEAD | gzip -9 > $(DISTNAME).tar.gz
zip:
git archive -o $(DISTNAME).zip --format zip --prefix=$(DISTNAME)/ HEAD
clean: doc-clean
doc-clean:
$(MAKE) -C doc clean
test: install
$(MAKE) installcheck || { filterdiff --format=unified regression.diffs | less; exit 1; }
ack:
cp results/*.out test/expected/
deb:
rm -f debian/control
make -f debian/rules debian/control
debuild -uc -us -b
debclean:
$(MAKE) -f debian/rules realclean
orig:
make -f debian/rules orig