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