This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
223 lines (188 loc) · 5.33 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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
include config.mak
bin_PROGRAMS = pgbouncer
pgbouncer_SOURCES = \
src/admin.c \
src/auth_ldap.c \
src/client.c \
src/dnslookup.c \
src/hba.c \
src/janitor.c \
src/loader.c \
src/messages.c \
src/main.c \
src/objects.c \
src/pam.c \
src/pktbuf.c \
src/pooler.c \
src/proto.c \
src/prepare.c \
src/sbuf.c \
src/scram.c \
src/server.c \
src/stats.c \
src/system.c \
src/takeover.c \
src/util.c \
src/varcache.c \
src/common/base64.c \
src/common/saslprep.c \
src/common/scram-common.c \
src/common/unicode_norm.c \
src/common/wchar.c \
include/admin.h \
include/auth_ldap.h \
include/bouncer.h \
include/client.h \
include/dnslookup.h \
include/hba.h \
include/iobuf.h \
include/janitor.h \
include/loader.h \
include/messages.h \
include/objects.h \
include/pam.h \
include/pktbuf.h \
include/pooler.h \
include/proto.h \
include/prepare.h \
include/sbuf.h \
include/scram.h \
include/server.h \
include/stats.h \
include/system.h \
include/takeover.h \
include/util.h \
include/varcache.h \
include/common/base64.h \
include/common/pg_wchar.h \
include/common/postgres_compat.h \
include/common/saslprep.h \
include/common/scram-common.h \
include/common/unicode_combining_table.h \
include/common/unicode_norm.h \
include/common/unicode_norm_table.h \
include/common/uthash_lowercase.h
UTHASH = uthash
COMMON_CFLAGS = -g -Wall -DLDAP_DEPRECATED
pgbouncer_CPPFLAGS = -Iinclude $(CARES_CFLAGS) $(LIBEVENT_CFLAGS) $(TLS_CPPFLAGS) $(COMMON_CFLAGS)
pgbouncer_CPPFLAGS += -I$(UTHASH)/src
# include libusual sources directly
AM_FEATURES = libusual
pgbouncer_EMBED_LIBUSUAL = 1
# docs to install as-is
dist_doc_DATA = README.md NEWS.md \
etc/pgbouncer-minimal.ini \
etc/pgbouncer.ini \
etc/pgbouncer.service \
etc/pgbouncer.socket \
etc/userlist.txt
DISTCLEANFILES = config.mak config.status lib/usual/config.h config.log
DIST_SUBDIRS = doc test
dist_man_MANS = doc/pgbouncer.1 doc/pgbouncer.5
# files in tgz
EXTRA_DIST = AUTHORS COPYRIGHT Makefile config.mak.in config.sub config.guess \
pyproject.toml requirements.txt \
install-sh autogen.sh configure configure.ac \
etc/mkauth.py etc/optscan.sh etc/example.debian.init.sh \
win32/Makefile \
$(LIBUSUAL_DIST) \
$(UTHASH_DIST)
# libusual files (FIXME: list should be provided by libusual...)
LIBUSUAL_DIST = $(filter-out %/config.h, $(sort $(wildcard \
lib/usual/*.[chg] \
lib/usual/*/*.[ch] \
lib/m4/*.m4 \
lib/usual/config.h.in \
lib/mk/*.mk \
lib/mk/antimake.mk lib/mk/antimake.txt \
lib/mk/install-sh lib/mk/std-autogen.sh \
lib/README lib/COPYRIGHT \
lib/find_modules.sh )))
UTHASH_DIST = $(UTHASH)/src/uthash.h \
$(UTHASH)/LICENSE
pgbouncer_LDFLAGS := $(TLS_LDFLAGS)
pgbouncer_LDADD := $(CARES_LIBS) $(LIBEVENT_LIBS) $(TLS_LIBS) $(LIBS)
LIBS :=
#
# win32
#
EXTRA_pgbouncer_SOURCES = win32/win32support.c win32/win32support.h win32/win32ver.rc
EXTRA_PROGRAMS = pgbevent
ifeq ($(PORTNAME),win32)
pgbouncer_CPPFLAGS += -Iwin32
pgbouncer_SOURCES += $(EXTRA_pgbouncer_SOURCES)
bin_PROGRAMS += pgbevent
endif
pgbevent_SOURCES = win32/pgbevent.c win32/eventmsg.rc \
win32/eventmsg.mc win32/MSG00001.bin
pgbevent_EXT = .dll
pgbevent_LINK = $(CC) -shared -Wl,--export-all-symbols -Wl,--add-stdcall-alias -o $@ $^
# .rc->.o
AM_LANGUAGES = RC
AM_LANG_RC_SRCEXTS = .rc
AM_LANG_RC_COMPILE = $(WINDRES) $< -o $@ --include-dir=$(srcdir)/win32 --include-dir=lib
AM_LANG_RC_LINK = false
#
# now load antimake
#
USUAL_DIR = lib
abs_top_srcdir ?= $(CURDIR)
include $(abs_top_srcdir)/lib/mk/antimake.mk
config.mak:
@echo "Please run ./configure"
@exit 1
PYTEST = $(shell command -v pytest || echo '$(PYTHON) -m pytest')
CONCURRENCY = auto
check: all
etc/optscan.sh
if [ $(CONCURRENCY) = 1 ]; then \
PYTHONIOENCODING=utf8 $(PYTEST); \
else \
PYTHONIOENCODING=utf8 $(PYTEST) -n $(CONCURRENCY); \
fi
$(MAKE) -C test check
w32zip = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)-windows-$(host_cpu).zip
zip: $(w32zip)
$(w32zip): pgbouncer.exe pgbevent.dll etc/pgbouncer.ini etc/userlist.txt README.md COPYRIGHT
rm -rf $(basename $@)
mkdir $(basename $@)
cp $^ $(basename $@)
$(STRIP) $(addprefix $(basename $@)/,$(filter %.exe %.dll,$(^F)))
zip -MM $@ $(addprefix $(basename $@)/,$(filter %.exe %.dll,$(^F)))
# NB: zip -l for text files for end-of-line conversion
zip -MM -l $@ $(addprefix $(basename $@)/,$(filter-out %.exe %.dll,$(^F)))
.PHONY: tags
tags:
ctags src/*.c include/*.h lib/usual/*.[ch] lib/usual/*/*.[ch]
htmls:
for f in *.md doc/*.md; do \
mkdir -p html && $(PANDOC) $$f -o html/`basename $$f`.html; \
done
doc/pgbouncer.1 doc/pgbouncer.5:
$(MAKE) -C doc $(@F)
lint:
flake8
format-check: uncrustify
black --check .
isort --check .
./uncrustify -c uncrustify.cfg --check include/*.h src/*.c -L WARN
format: uncrustify
$(MAKE) format-c
$(MAKE) format-python
format-python: uncrustify
black .
isort .
format-c: uncrustify
./uncrustify -c uncrustify.cfg --replace --no-backup include/*.h src/*.c -L WARN
UNCRUSTIFY_VERSION=0.77.1
uncrustify:
temp=$$(mktemp -d) \
&& cd $$temp \
&& curl -L https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-$(UNCRUSTIFY_VERSION).tar.gz --output uncrustify.tar.gz \
&& tar xzf uncrustify.tar.gz \
&& cd uncrustify-uncrustify-$(UNCRUSTIFY_VERSION) \
&& mkdir -p build \
&& cd build \
&& cmake .. \
&& $(MAKE) \
&& cp uncrustify $(CURDIR)/uncrustify