forked from pgbouncer/pgbouncer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
225 lines (178 loc) · 6.05 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
224
225
# sources
SRCS = client.c loader.c objects.c pooler.c proto.c sbuf.c server.c util.c \
admin.c stats.c takeover.c janitor.c pktbuf.c system.c main.c \
varcache.c
HDRS = client.h loader.h objects.h pooler.h proto.h sbuf.h server.h util.h \
admin.h stats.h takeover.h janitor.h pktbuf.h system.h bouncer.h \
varcache.h iobuf.h
# data & dirs to include in tgz
DOCS = doc/overview.txt doc/usage.txt doc/config.txt doc/todo.txt
MANPAGES = doc/pgbouncer.1 doc/pgbouncer.5
DATA = README NEWS AUTHORS COPYRIGHT etc/pgbouncer.ini etc/userlist.txt Makefile \
config.mak.in include/config.h.in etc/mkauth.py \
configure configure.ac debian/packages debian/changelog doc/Makefile \
test/Makefile test/asynctest.c test/conntest.sh test/ctest6000.ini \
test/ctest7000.ini test/run-conntest.sh test/stress.py test/test.ini \
test/test.sh test/userlist.txt etc/example.debian.init.sh doc/fixman.py \
win32/eventmsg.mc win32/eventmsg.rc win32/MSG00001.bin \
win32/Makefile win32/pgbevent.c \
win32/win32support.c win32/win32support.h
DIRS = doc etc include src debian test win32
# keep autoconf stuff separate
-include config.mak
# fill values for unconfigured tree
srcdir ?= .
builddir ?= .
local_hdrs = $(addprefix $(srcdir)/include/, $(HDRS))
local_srcs = $(addprefix $(srcdir)/src/, $(SRCS))
USUAL_DIR = $(srcdir)/lib
USUAL_OBJDIR = $(builddir)/obj
USUAL_LOCAL_SRCS = $(local_srcs) $(local_hdrs)
include $(USUAL_DIR)/Setup.mk
# calculate full-path values
OBJS = $(SRCS:.c=.o)
hdrs = $(local_hdrs) $(USUAL_HDRS)
srcs = $(local_srcs)
objs = $(addprefix $(builddir)/obj/, $(OBJS)) $(USUAL_OBJS)
FULL = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
DISTFILES = $(DIRS) $(DATA) $(DOCS) $(srcs) $(hdrs) $(MANPAGES)
exe = $(builddir)/pgbouncer$(EXT)
CPPFLAGS := -I$(srcdir)/include $(USUAL_CPPFLAGS) $(CPPFLAGS)
ifeq ($(enable_debug),yes)
CPPFLAGS += -DDBGVER="\"compiled by <$${USER}@`hostname`> at `date '+%Y-%m-%d %H:%M:%S'`\""
endif
ifeq ($(PORTNAME),win32)
EXT = .exe
CPPFLAGS += -I$(srcdir)/win32
WSRCS = win32support.c
WHDRS = win32support.h
WOBJS = $(WSRCS:.c=.o)
srcs += $(srcdir)/win32/win32support.c
hdrs += $(srcdir)/win32/win32support.h
objs += $(builddir)/obj/win32support.o
dll = $(builddir)/pgbevent.dll
dlldef = $(builddir)/obj/pgbevent.def
dllobjs = $(builddir)/obj/eventmsg.o $(builddir)/obj/pgbevent.o
DEFFLAGS = --export-all-symbols -A
endif
# Quiet by default, 'make V=1' shows commands
V=0
ifeq ($(V), 0)
Q = @
E = @echo
else
Q =
E = @true
endif
## actual targets now ##
# default target
all: $(exe) $(dll) doc-all
# final executable
$(exe): $(builddir)/config.mak $(objs)
$(E) " LD" $@
$(Q) $(CC) -o $@ $(LDFLAGS) $(objs) $(LIBS)
# objects depend on all the headers
$(builddir)/obj/%.o: $(srcdir)/src/%.c $(builddir)/config.mak $(hdrs)
@mkdir -p $(builddir)/obj
$(E) " CC" $<
$(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
$(builddir)/obj/%.o: $(srcdir)/win32/%.c $(builddir)/config.mak $(hdrs)
@mkdir -p $(builddir)/obj
$(E) " CC" $<
$(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
$(builddir)/obj/%.o: $(USUAL_DIR)/usual/%.c $(builddir)/config.mak $(hdrs)
@mkdir -p $(builddir)/obj
$(E) " CC" $<
$(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
# install binary and other stuff
install: $(exe) doc-install
mkdir -p $(DESTDIR)$(bindir)
mkdir -p $(DESTDIR)$(docdir)
$(BININSTALL) -m 755 $(exe) $(DESTDIR)$(bindir)
$(INSTALL) -m 644 $(srcdir)/etc/pgbouncer.ini $(DESTDIR)$(docdir)
ifeq ($(PORTNAME),win32)
$(BININSTALL) -m 755 $(dll) $(DESTDIR)$(bindir)
endif
# create tarfile
tgz: config.mak $(DISTFILES) $(MANPAGES)
rm -rf $(FULL) $(FULL).tgz
mkdir $(FULL)
(for f in $(DISTFILES); do echo $$f; done) | cpio -pm $(FULL)
tar czf $(FULL).tgz $(FULL)
rm -rf $(FULL)
doc/pgbouncer.1:
$(MAKE) -C doc pgbouncer.1
doc/pgbouncer.5:
$(MAKE) -C doc pgbouncer.5
# create debian package
deb: configure
yada rebuild
debuild -uc -us -b
# clean object files
clean: doc-clean
rm -f $(objs) $(exe) $(dll) $(dlldef) $(dllobjs)
# clean configure results
distclean: clean doc-distclean
rm -f include/config.h include/config.h.in~ config.log config.status config.mak
rm -rf obj autom4te*
# clean autoconf results
realclean: distclean doc-realclean
rm -f aclocal* include/config.h.in configure depcomp install-sh missing
rm -f tags
# generate configure script and config.h.in
boot:
aclocal -I lib/m4
autoheader -f
autoconf -f
rm -rf autom4te* include/config.h.in~
# targets can depend on this to force ./configure
$(builddir)/config.mak::
@test -f $(srcdir)/configure || { \
echo "Please run 'make boot && ./configure' first.";exit 1;}
@test -f $@ || { echo "Please run ./configure first.";exit 1;}
doc-all doc-install doc-clean doc-distclean doc-realclean:
@if test -d doc; then $(MAKE) -C doc $(subst doc-,,$@) DESTDIR=$(DESTDIR) ;\
else true; fi
# targets can depend on this to force 'make boot'
configure::
@test -f $@ || { echo "Please run 'make boot' first.";exit 1;}
# create tags file
tags: $(srcs) $(hdrs)
if test -f ../libevent/event.h; then \
ctags $(srcs) $(hdrs) ../libevent/*.[ch]; \
else \
ctags $(srcs) $(hdrs); \
fi
# run sparse over code
check: config.mak
REAL_CC="$(CC)" \
$(MAKE) clean pgbouncer CC=cgcc
# profiled exe
pgbouncer.pg:
$(CC) -pg $(DEFS) -g -O2 $(CPPFLAGS) $(LDFLAGS) -o $@ $(srcs) $(LIBS)
pg: pgbouncer.pg
# asm hacks
$(builddir)/obj/%.s: $(srcdir)/src/%.c config.mak $(hdrs)
@mkdir -p $(builddir)/obj
$(E) " CC -S" $<
$(Q) $(CC) -S -fverbose-asm -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
asms = $(objs:.o=.s)
asm: $(asms)
ifeq ($(PORTNAME),win32)
$(builddir)/obj/eventmsg.o: $(srcdir)/win32/eventmsg.rc
$(E) " WINDRES" $<
$(Q) $(WINDRES) $< -o $@ --include-dir=$(srcdir)/win32
$(dlldef): $(dllobjs)
$(E) " DLLTOOL" $@
$(Q) $(DLLTOOL) $(DEFFLAGS) --output-def $@ $(dllobjs)
# final executable
$(dll): $(builddir)/config.mak $(dllobjs) $(dlldef)
$(E) " DLLWRAP" $@
$(Q) $(DLLWRAP) --def $(dlldef) -o $@ $(dllobjs)
endif
stripped: $(exe) $(dll)
$(STRIP) $(exe) $(dll)
tmp:
@echo CPPFLAGS=$(CPPFLAGS)
@echo USUAL_CPPFLAGS=$(USUAL_CPPFLAGS)
@echo USUAL_LDFLAGS=$(USUAL_LDFLAGS)