client_login_timeout: check wait_for_welcome
[pgbouncer.git] / Makefile
blob67a9966fa576b3a2956bdc086baaf6d5604a6bc8
2 # sources
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 COPYRIGHT 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/eventmsg.mc win32/eventmsg.rc win32/MSG00001.bin \
20 win32/Makefile win32/pgbevent.c \
21 win32/win32support.c win32/win32support.h
22 DIRS = doc etc include src debian test win32
24 # keep autoconf stuff separate
25 -include config.mak
27 # fill values for unconfigured tree
28 srcdir ?= .
29 builddir ?= .
31 # calculate full-path values
32 OBJS = $(SRCS:.c=.o)
33 hdrs = $(addprefix $(srcdir)/include/, $(HDRS))
34 srcs = $(addprefix $(srcdir)/src/, $(SRCS))
35 objs = $(addprefix $(builddir)/lib/, $(OBJS))
36 FULL = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
37 DISTFILES = $(DIRS) $(DATA) $(DOCS) $(srcs) $(hdrs) $(MANPAGES)
38 exe = $(builddir)/pgbouncer$(EXT)
40 CPPCFLAGS += -I$(srcdir)/include
42 ifneq ($(builddir),$(srcdir))
43 CPPCFLAGS += -I$(builddir)/include
44 endif
46 ifeq ($(enable_debug),yes)
47 CPPCFLAGS += -DDBGVER="\"compiled by <$${USER}@`hostname`> at `date '+%Y-%m-%d %H:%M:%S'`\""
48 endif
50 ifeq ($(PORTNAME),win32)
52 EXT = .exe
54 CPPFLAGS += -I$(srcdir)/win32
55 WSRCS = win32support.c
56 WHDRS = win32support.h
57 WOBJS = $(WSRCS:.c=.o)
58 srcs += $(srcdir)/win32/win32support.c
59 hdrs += $(srcdir)/win32/win32support.h
60 objs += $(builddir)/lib/win32support.o
62 dll = $(builddir)/pgbevent.dll
63 dlldef = $(builddir)/lib/pgbevent.def
64 dllobjs = $(builddir)/lib/eventmsg.o $(builddir)/lib/pgbevent.o
66 DEFFLAGS = --export-all-symbols -A
68 endif
70 # Quiet by default, 'make V=1' shows commands
71 V=0
72 ifeq ($(V), 0)
73 Q = @
74 E = @echo
75 else
76 Q =
77 E = @true
78 endif
80 ## actual targets now ##
82 # default target
83 all: $(exe) $(dll) doc-all
85 # final executable
86 $(exe): $(builddir)/config.mak $(objs)
87 $(E) " LD" $@
88 $(Q) $(CC) -o $@ $(LDFLAGS) $(objs) $(LIBS)
90 # objects depend on all the headers
91 $(builddir)/lib/%.o: $(srcdir)/src/%.c $(builddir)/config.mak $(hdrs)
92 @mkdir -p $(builddir)/lib
93 $(E) " CC" $<
94 $(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
96 $(builddir)/lib/%.o: $(srcdir)/win32/%.c $(builddir)/config.mak $(hdrs)
97 @mkdir -p $(builddir)/lib
98 $(E) " CC" $<
99 $(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
101 # install binary and other stuff
102 install: $(exe) doc-install
103 mkdir -p $(DESTDIR)$(bindir)
104 mkdir -p $(DESTDIR)$(docdir)
105 $(BININSTALL) -m 755 $(exe) $(DESTDIR)$(bindir)
106 $(INSTALL) -m 644 $(srcdir)/etc/pgbouncer.ini $(DESTDIR)$(docdir)
107 ifeq ($(PORTNAME),win32)
108 $(BININSTALL) -m 755 $(dll) $(DESTDIR)$(bindir)
109 endif
111 # create tarfile
112 tgz: config.mak $(DISTFILES) $(MANPAGES)
113 rm -rf $(FULL) $(FULL).tgz
114 mkdir $(FULL)
115 (for f in $(DISTFILES); do echo $$f; done) | cpio -pm $(FULL)
116 tar czf $(FULL).tgz $(FULL)
117 rm -rf $(FULL)
119 doc/pgbouncer.1:
120 $(MAKE) -C doc pgbouncer.1
122 doc/pgbouncer.5:
123 $(MAKE) -C doc pgbouncer.5
125 # create debian package
126 deb: configure
127 yada rebuild
128 debuild -uc -us -b
130 # clean object files
131 clean: doc-clean
132 rm -f $(objs) $(exe) $(dll) $(dlldef) $(dllobjs)
134 # clean configure results
135 distclean: clean doc-distclean
136 rm -f include/config.h include/config.h.in~ config.log config.status config.mak
137 rm -rf lib autom4te*
139 # clean autoconf results
140 realclean: distclean doc-realclean
141 rm -f aclocal* include/config.h.in configure depcomp install-sh missing
142 rm -f tags
144 # generate configure script and config.h.in
145 boot:
146 autoreconf -i -f
147 rm -rf autom4te* include/config.h.in~
149 # targets can depend on this to force ./configure
150 $(builddir)/config.mak::
151 @test -f $(srcdir)/configure || { \
152 echo "Please run 'make boot && ./configure' first.";exit 1;}
153 @test -f $@ || { echo "Please run ./configure first.";exit 1;}
155 doc-all doc-install doc-clean doc-distclean doc-realclean:
156 @if test -d doc; then $(MAKE) -C doc $(subst doc-,,$@) DESTDIR=$(DESTDIR) ;\
157 else true; fi
160 # targets can depend on this to force 'make boot'
161 configure::
162 @test -f $@ || { echo "Please run 'make boot' first.";exit 1;}
164 # create tags file
165 tags: $(srcs) $(hdrs)
166 if test -f ../libevent/event.h; then \
167 ctags $(srcs) $(hdrs) ../libevent/*.[ch]; \
168 else \
169 ctags $(srcs) $(hdrs); \
172 # run sparse over code
173 check: config.mak
174 REAL_CC="$(CC)" \
175 $(MAKE) clean pgbouncer CC=cgcc
177 # profiled exe
178 pgbouncer.pg:
179 $(CC) -pg $(DEFS) -g -O2 $(CPPFLAGS) $(LDFLAGS) -o $@ $(srcs) $(LIBS)
181 pg: pgbouncer.pg
183 # asm hacks
184 $(builddir)/lib/%.s: $(srcdir)/src/%.c config.mak $(hdrs)
185 @mkdir -p $(builddir)/lib
186 $(E) " CC -S" $<
187 $(Q) $(CC) -S -fverbose-asm -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
188 asms = $(objs:.o=.s)
189 asm: $(asms)
191 ifeq ($(PORTNAME),win32)
193 $(builddir)/lib/eventmsg.o: $(srcdir)/win32/eventmsg.rc
194 $(E) " WINDRES" $<
195 $(Q) $(WINDRES) $< -o $@ --include-dir=$(srcdir)/win32
197 $(dlldef): $(dllobjs)
198 $(E) " DLLTOOL" $@
199 $(Q) $(DLLTOOL) $(DEFFLAGS) --output-def $@ $(dllobjs)
201 # final executable
202 $(dll): $(builddir)/config.mak $(dllobjs) $(dlldef)
203 $(E) " DLLWRAP" $@
204 $(Q) $(DLLWRAP) --def $(dlldef) -o $@ $(dllobjs)
206 endif
208 stripped: $(exe) $(dll)
209 $(STRIP) $(exe) $(dll)