Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
202 lines (170 loc) · 5.12 KB
/
Copy pathMakefile
File metadata and controls
202 lines (170 loc) · 5.12 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
OS = $(shell uname -s)
GREP ?= grep
PG_CONFIG = pg_config
# the `-Wno`s quiet C90 warnings
PG_CFLAGS = -std=gnu11 -Wextra -Wall -Werror \
-Wno-declaration-after-statement \
-Wno-vla \
-Wno-long-long
ifeq ($(TEST_CORE), 1)
PG_CFLAGS += -DTEST_CORE=1
endif
ifeq ($(COVERAGE), 1)
PG_CFLAGS += --coverage
endif
MODULE_big = supautils
MODVERSION = 3.4.4
SRC_DIR = src
SRC = $(wildcard src/*.c)
PG_VERSION = $(strip $(shell $(PG_CONFIG) --version | $(GREP) -oP '(?<=PostgreSQL )[0-9]+'))
# 0 is true
PG_EQ15 = $(shell test $(PG_VERSION) -eq 15; echo $$?)
PG_NEQ15 = $(shell test $(PG_VERSION) -ne 15; echo $$?)
PG_GE15 = $(shell test $(PG_VERSION) -ge 15; echo $$?)
PG_LE13 = $(shell test $(PG_VERSION) -le 13; echo $$?)
PG_LT15 = $(shell test $(PG_VERSION) -lt 15; echo $$?)
PG_EQ18 = $(shell test $(PG_VERSION) -eq 18; echo $$?)
PG_NEQ18 = $(shell test $(PG_VERSION) -ne 18; echo $$?)
PG_GE18 = $(shell test $(PG_VERSION) -ge 18; echo $$?)
PG_GE16 = $(shell test $(PG_VERSION) -ge 16; echo $$?)
PG_GE14 = $(shell test $(PG_VERSION) -ge 14; echo $$?)
SYSTEM = $(shell uname -s)
TESTS := $(wildcard test/sql/*.sql)
ifneq ($(SYSTEM), Linux)
TESTS := $(filter-out test/sql/linux_%.sql, $(TESTS))
endif
ifneq ($(PG_GE16), 0)
TESTS := $(filter-out test/sql/ge16_%.sql, $(TESTS))
else
TESTS := $(filter-out test/sql/lt16_%.sql, $(TESTS))
endif
ifeq ($(PG_NEQ15), 0)
TESTS := $(filter-out test/sql/eq15_%.sql, $(TESTS))
endif
ifeq ($(PG_NEQ18), 0)
TESTS := $(filter-out test/sql/eq18_%.sql, $(TESTS))
endif
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
REGRESS_OPTS = --use-existing --inputdir=test
GENERATED_OUT = test/expected/event_triggers.out test/expected/permission_hints.out test/expected/privileged_role.out
EXTRA_CLEAN = $(GENERATED_OUT)
PGXS := $(shell $(PG_CONFIG) --pgxs)
.DEFAULT_GOAL := all
ifeq ($(OS), Linux)
DL_SUFFIX=so
else ifeq ($(OS), Darwin)
ifeq ($(PG_GE16), 0)
DL_SUFFIX=dylib
else
DL_SUFFIX=so
endif
else
DL_SUFFIX=dylib
endif
PG_CPPFLAGS := $(CPPFLAGS) -DMODVERSION=\"$(MODVERSION)\"
ifdef BUILD_DIR
OBJS = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC))
else
OBJS = $(patsubst $(SRC_DIR)/%.c, src/%.o, $(SRC)) # if no BUILD_DIR, just build on src so standard PGXS `make` works
endif
build: $(BUILD_DIR)/$(MODULE_big).$(DL_SUFFIX) test/init.conf
.PHONY: test/init.conf
test/init.conf: test/init.conf.in
ifeq ($(PG_EQ15), 0)
sed \
-e '/<\/\?PG_EQ_15>/d' \
$? > $@
else
sed \
-e '/<PG_EQ_15>/,/<\/PG_EQ_15>/d' \
$? > $@
endif
$(BUILD_DIR)/.gitignore:
mkdir -p $(BUILD_DIR)
echo "*" > $(BUILD_DIR)/.gitignore
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(BUILD_DIR)/.gitignore
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/$(MODULE_big).$(DL_SUFFIX): $(MODULE_big).$(DL_SUFFIX)
mv $? $@
include $(PGXS)
.PHONY: test/expected/event_triggers.out
test/expected/event_triggers.out: test/expected/event_triggers.out.in
ifeq ($(PG_GE16), 0)
sed \
-e '/<\/\?PG_GE_16>/d' \
-e '/<PG_GE_13>/,/<\/PG_GE_13>/d' \
-e '/<PG_GE_14>/,/<\/PG_GE_14>/d' \
$? > $@
else ifeq ($(PG_GE14), 0)
sed \
-e '/<\/\?PG_GE_14>/d' \
-e '/<PG_GE_13>/,/<\/PG_GE_13>/d' \
-e '/<PG_GE_16>/,/<\/PG_GE_16>/d' \
$? > $@
else
sed \
-e '/<\/\?PG_GE_13>/d' \
-e '/<PG_GE_14>/,/<\/PG_GE_14>/d' \
-e '/<PG_GE_16>/,/<\/PG_GE_16>/d' \
$? > $@
endif
.PHONY: test/expected/permission_hints.out
test/expected/permission_hints.out: test/expected/permission_hints.out.in
ifeq ($(PG_GE18), 0)
sed \
-e '/<\/\?PG_GE_15>/d' \
-e '/<PG_LT_18>/,/<\/PG_LT_18>/d' \
-e '/<PG_LT_15>/,/<\/PG_LT_15>/d' \
$? > $@
else ifeq ($(PG_GE15), 0)
sed \
-e '/<\/\?PG_GE_15>/d' \
-e '/<\/\?PG_LT_18>/d' \
-e '/<PG_LT_15>/,/<\/PG_LT_15>/d' \
$? > $@
else
sed \
-e '/<\/\?PG_LT_15>/d' \
-e '/<\/\?PG_LT_18>/d' \
-e '/<PG_GE_15>/,/<\/PG_GE_15>/d' \
$? > $@
endif
.PHONY: test/expected/privileged_role.out
test/expected/privileged_role.out: test/expected/privileged_role.out.in
ifeq ($(PG_LE13), 0)
sed \
-e '/<\/\?PG_LE13>/d' \
-e '/<PG_GT13>/,/<\/PG_GT13>/d' \
$? > $@
else
sed \
-e '/<\/\?PG_GT13>/d' \
-e '/<PG_LE13>/,/<\/PG_LE13>/d' \
$? > $@
endif
# extra dep for target in pgxs.mk
installcheck: $(GENERATED_OUT)
CORE_STAGEDIR = $(BUILD_DIR)/$(notdir $(PG_REGRESS_TESTS))
CORE_VERSION_PATCH_DIR = $(if $(filter 15 16 17 18 19,$(PG_VERSION)),test/core_patches/$(PG_VERSION))
CORE_PATCHES = $(wildcard $(CORE_VERSION_PATCH_DIR)/*.patch)
$(CORE_STAGEDIR)/parallel_schedule: $(CORE_PATCHES)
rm -rf $(CORE_STAGEDIR)
mkdir -p $(CORE_STAGEDIR)/sql $(CORE_STAGEDIR)/expected $(CORE_STAGEDIR)/data
cp -R $(PG_REGRESS_TESTS)/sql/. $(CORE_STAGEDIR)/sql/
cp -R $(PG_REGRESS_TESTS)/expected/. $(CORE_STAGEDIR)/expected/
cp -R $(PG_REGRESS_TESTS)/data/. $(CORE_STAGEDIR)/data/
cp $(PG_REGRESS_TESTS)/parallel_schedule $(CORE_STAGEDIR)/
@set -e; \
for patch in $(CORE_PATCHES); do \
patch -d $(CORE_STAGEDIR) -p1 < $$patch; \
done
.PHONY: test-core
test-core: $(CORE_STAGEDIR)/parallel_schedule
$(pg_regress_installcheck) --dlpath=$(PG_REGRESS_TESTS)/lib --inputdir=$(CORE_STAGEDIR) --schedule=$(CORE_STAGEDIR)/parallel_schedule --dbname=regression
.PHONY: test-startup
test-startup:
bash test/startup.sh
.PHONY: test
test:
make installcheck
make test-startup