]> granicus.if.org Git - pgbouncer/blob - Makefile
pgbevent: make g_module static var
[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 endif
66
67 # Quiet by default, 'make V=1' shows commands
68 V=0
69 ifeq ($(V), 0)
70 Q = @
71 E = @echo
72 else
73 Q = 
74 E = @true
75 endif
76
77 ## actual targets now ##
78
79 # default target
80 all: $(exe) $(dll) doc-all
81
82 # final executable
83 $(exe): $(builddir)/config.mak $(objs)
84         $(E) "  LD" $@
85         $(Q) $(CC) -o $@ $(LDFLAGS) $(objs) $(LIBS)
86
87 # objects depend on all the headers
88 $(builddir)/lib/%.o: $(srcdir)/src/%.c $(builddir)/config.mak $(hdrs)
89         @mkdir -p $(builddir)/lib
90         $(E) "  CC" $<
91         $(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
92
93 $(builddir)/lib/%.o: $(srcdir)/win32/%.c $(builddir)/config.mak $(hdrs)
94         @mkdir -p $(builddir)/lib
95         $(E) "  CC" $<
96         $(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
97
98 # install binary and other stuff
99 install: $(exe) doc-install
100         mkdir -p $(DESTDIR)$(bindir)
101         mkdir -p $(DESTDIR)$(docdir)
102         $(BININSTALL) -m 755 $(exe) $(DESTDIR)$(bindir)
103         $(INSTALL) -m 644 $(srcdir)/etc/pgbouncer.ini  $(DESTDIR)$(docdir)
104 ifeq ($(PORTNAME),win32)
105         $(BININSTALL) -m 755 $(dll) $(DESTDIR)$(bindir)
106 endif
107
108 # create tarfile
109 tgz: config.mak $(DISTFILES) $(MANPAGES)
110         rm -rf $(FULL) $(FULL).tgz
111         mkdir $(FULL)
112         (for f in $(DISTFILES); do echo $$f; done) | cpio -pm $(FULL)
113         tar czf $(FULL).tgz $(FULL)
114         rm -rf $(FULL)
115
116 doc/pgbouncer.1:
117         $(MAKE) -C doc pgbouncer.1
118
119 doc/pgbouncer.5:
120         $(MAKE) -C doc pgbouncer.5
121
122 # create debian package
123 deb: configure
124         yada rebuild
125         debuild -uc -us -b
126
127 # clean object files
128 clean: doc-clean
129         rm -f $(objs) $(exe) $(dll) $(dlldef) $(dllobjs)
130
131 # clean configure results
132 distclean: clean doc-distclean
133         rm -f include/config.h include/config.h.in~ config.log config.status config.mak
134         rm -rf lib autom4te*
135
136 # clean autoconf results
137 realclean: distclean doc-realclean
138         rm -f aclocal* include/config.h.in configure depcomp install-sh missing
139         rm -f tags
140
141 # generate configure script and config.h.in
142 boot:
143         autoreconf -i -f
144         rm -rf autom4te* include/config.h.in~
145
146 # targets can depend on this to force ./configure
147 $(builddir)/config.mak::
148         @test -f $(srcdir)/configure || { \
149                  echo "Please run 'make boot && ./configure' first.";exit 1;}
150         @test -f $@ || { echo "Please run ./configure first.";exit 1;}
151
152 doc-all doc-install doc-clean doc-distclean doc-realclean:
153         @if test -d doc; then $(MAKE) -C doc $(subst doc-,,$@) DESTDIR=$(DESTDIR) ;\
154         else true; fi
155
156
157 # targets can depend on this to force 'make boot'
158 configure::
159         @test -f $@ || { echo "Please run 'make boot' first.";exit 1;}
160
161 # create tags file
162 tags: $(srcs) $(hdrs)
163         if test -f ../libevent/event.h; then \
164           ctags $(srcs) $(hdrs) ../libevent/*.[ch]; \
165         else \
166           ctags $(srcs) $(hdrs); \
167         fi
168
169 # run sparse over code
170 check: config.mak
171         REAL_CC="$(CC)" \
172         $(MAKE) clean pgbouncer CC=cgcc
173
174 # profiled exe
175 pgbouncer.pg:
176         $(CC) -pg $(DEFS) -g -O2 $(CPPFLAGS) $(LDFLAGS) -o $@ $(srcs) $(LIBS)
177
178 pg: pgbouncer.pg
179
180 # asm hacks
181 $(builddir)/lib/%.s: $(srcdir)/src/%.c config.mak $(hdrs)
182         @mkdir -p $(builddir)/lib
183         $(E) "  CC -S" $<
184         $(Q) $(CC) -S -fverbose-asm -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
185 asms = $(objs:.o=.s)
186 asm: $(asms)
187
188 ifeq ($(PORTNAME),win32)
189
190 $(builddir)/lib/eventmsg.o: $(srcdir)/win32/eventmsg.rc
191         $(E) "  WINDRES" $<
192         $(Q) $(WINDRES) $< -o $@ --include-dir=$(srcdir)/win32
193
194 $(dlldef): $(dllobjs)
195         $(E) "  DLLTOOL" $@
196         $(Q) $(DLLTOOL) --output-def $@ $(dllobjs)
197
198 # final executable
199 $(dll): $(builddir)/config.mak $(dllobjs) $(dlldef)
200         $(E) "  DLLWRAP" $@
201         $(Q) $(DLLWRAP) --def $(dlldef) -o $@ $(dllobjs)
202
203 endif
204
205 stripped: $(exe) $(dll)
206         $(STRIP) $(exe) $(dll)
207