3 SRCS = client.c loader.c objects.c pooler.c proto.c sbuf.c server.c util.c \
4 admin.c stats.c takeover.c md5.c janitor.c pktbuf.c system.c main.c \
5 varcache.c aatree.c hash.c slab.c
6 HDRS = client.h loader.h objects.h pooler.h proto.h sbuf.h server.h util.h \
7 admin.h stats.h takeover.h md5.h janitor.h pktbuf.h system.h bouncer.h \
8 list.h mbuf.h varcache.h aatree.h hash.h slab.h iobuf.h
10 # data & dirs to include in tgz
11 DOCS = doc/overview.txt doc/usage.txt doc/config.txt doc/todo.txt
12 MANPAGES = doc/pgbouncer.1 doc/pgbouncer.5
13 DATA = README NEWS AUTHORS etc/pgbouncer.ini etc/userlist.txt Makefile \
14 config.mak.in include/config.h.in \
15 configure configure.ac debian/packages debian/changelog doc/Makefile \
16 test/Makefile test/asynctest.c test/conntest.sh test/ctest6000.ini \
17 test/ctest7000.ini test/run-conntest.sh test/stress.py test/test.ini \
18 test/test.sh test/userlist.txt etc/example.debian.init.sh doc/fixman.py \
19 win32/wbnmsgevent.mc win32/wbnmsgevent.rc win32/MSG00001.bin
20 DIRS = doc etc include src debian test
22 # keep autoconf stuff separate
25 # fill values for unconfigured tree
29 # calculate full-path values
31 hdrs = $(addprefix $(srcdir)/include/, $(HDRS))
32 srcs = $(addprefix $(srcdir)/src/, $(SRCS))
33 objs = $(addprefix $(builddir)/lib/, $(OBJS))
34 FULL = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
35 DISTFILES = $(DIRS) $(DATA) $(DOCS) $(srcs) $(hdrs) $(MANPAGES) $(WINPORT)
36 exe = $(builddir)/pgbouncer$(EXT)
38 CPPCFLAGS += -I$(srcdir)/include
40 ifneq ($(builddir),$(srcdir))
41 CPPCFLAGS += -I$(builddir)/include
44 ifeq ($(enable_debug),yes)
45 CPPCFLAGS += -DDBGVER="\"compiled by <$${USER}@`hostname`> at `date '+%Y-%m-%d %H:%M:%S'`\""
48 ifeq ($(PORTNAME),win32)
52 CPPFLAGS += -I$(srcdir)/win32
53 WSRCS = win32service.c
54 WOBJS = $(WSRCS:.c=.o)
55 WHDRS = win32service.h compat_win32.h
56 srcs += $(addprefix $(srcdir)/win32/, $(WSRCS))
57 hdrs += $(addprefix $(srcdir)/win32/, $(WHDRS))
58 objs += $(addprefix $(builddir)/lib/, $(WOBJS))
60 dll = $(builddir)/pgbevent.dll
61 dlldef = $(builddir)/lib/pgbevent.def
62 dllobjs = $(builddir)/lib/eventmsg.o $(builddir)/lib/pgbevent.o
66 # Quiet by default, 'make V=1' shows commands
76 ## actual targets now ##
79 all: $(exe) $(dll) doc-all
82 $(exe): $(builddir)/config.mak $(objs)
84 $(Q) $(CC) -o $@ $(LDFLAGS) $(objs) $(LIBS)
86 # objects depend on all the headers
87 $(builddir)/lib/%.o: $(srcdir)/src/%.c $(builddir)/config.mak $(hdrs)
88 @mkdir -p $(builddir)/lib
90 $(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
92 $(builddir)/lib/%.o: $(srcdir)/win32/%.c $(builddir)/config.mak $(hdrs)
93 @mkdir -p $(builddir)/lib
95 $(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
97 # install binary and other stuff
98 install: $(exe) doc-install
99 mkdir -p $(DESTDIR)$(bindir)
100 mkdir -p $(DESTDIR)$(docdir)
101 $(BININSTALL) -m 755 $(exe) $(DESTDIR)$(bindir)
102 $(INSTALL) -m 644 $(srcdir)/etc/pgbouncer.ini $(DESTDIR)$(docdir)
103 ifeq ($(PORTNAME),win32)
104 $(BININSTALL) -m 755 $(dll) $(DESTDIR)$(bindir)
108 tgz: config.mak $(DISTFILES) $(MANPAGES)
109 rm -rf $(FULL) $(FULL).tgz
111 (for f in $(DISTFILES); do echo $$f; done) | cpio -pm $(FULL)
112 tar czf $(FULL).tgz $(FULL)
116 $(MAKE) -C doc pgbouncer.1
119 $(MAKE) -C doc pgbouncer.5
121 # create debian package
128 rm -f $(objs) $(exe) $(dll) $(dlldef) $(dllobjs)
130 # clean configure results
131 distclean: clean doc-distclean
132 rm -f include/config.h include/config.h.in~ config.log config.status config.mak
135 # clean autoconf results
136 realclean: distclean doc-realclean
137 rm -f aclocal* include/config.h.in configure depcomp install-sh missing
140 # generate configure script and config.h.in
143 rm -rf autom4te* include/config.h.in~
145 # targets can depend on this to force ./configure
146 $(builddir)/config.mak::
147 @test -f $(srcdir)/configure || { \
148 echo "Please run 'make boot && ./configure' first.";exit 1;}
149 @test -f $@ || { echo "Please run ./configure first.";exit 1;}
151 doc-all doc-install doc-clean doc-distclean doc-realclean:
152 @if test -d doc; then $(MAKE) -C doc $(subst doc-,,$@) DESTDIR=$(DESTDIR) ;\
156 # targets can depend on this to force 'make boot'
158 @test -f $@ || { echo "Please run 'make boot' first.";exit 1;}
161 tags: $(srcs) $(hdrs)
162 if test -f ../libevent/event.h; then \
163 ctags $(srcs) $(hdrs) ../libevent/*.[ch]; \
165 ctags $(srcs) $(hdrs); \
168 # run sparse over code
171 $(MAKE) clean pgbouncer CC=cgcc
175 $(CC) -pg $(DEFS) -g -O2 $(CPPFLAGS) $(LDFLAGS) -o $@ $(srcs) $(LIBS)
180 $(builddir)/lib/%.s: $(srcdir)/src/%.c config.mak $(hdrs)
181 @mkdir -p $(builddir)/lib
183 $(Q) $(CC) -S -fverbose-asm -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
187 ifeq ($(PORTNAME),win32)
189 $(builddir)/lib/eventmsg.o: $(srcdir)/win32/eventmsg.rc
191 $(Q) $(WINDRES) $< -o $@ --include-dir=$(srcdir)/win32
193 $(dlldef): $(dllobjs)
195 $(Q) $(DLLTOOL) --output-def $@ $(dllobjs)
198 $(dll): $(builddir)/config.mak $(dllobjs) $(dlldef)
200 $(Q) $(DLLWRAP) --def $(dlldef) -o $@ $(dllobjs)
204 stripped: $(exe) $(dll)
205 $(STRIP) $(exe) $(dll)