version 1.1.2
[pgbouncer.git] / Makefile
blobc96acba5aa26f554041f4688b36841cee30c9446
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
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
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 Makefile config.mak.in config.h.in \
14 configure configure.ac debian/packages debian/changelog doc/Makefile \
15 test/Makefile test/asynctest.c test/conntest.sh test/ctest6000.ini \
16 test/ctest7000.ini test/run-conntest.sh test/stress.py test/test.ini \
17 test/test.sh test/userlist.txt etc/example.debian.init.sh doc/fixman.py
18 DIRS = doc etc src debian test
20 # keep autoconf stuff separate
21 -include config.mak
23 ifeq ($(enable_debug),yes)
24 CFLAGS += -DDBGVER="\"compiled by <$${USER}@`hostname`> at `date '+%Y-%m-%d %H:%M:%S'`\""
25 endif
27 # calculate full-path values
28 OBJS = $(SRCS:.c=.o)
29 hdrs = $(addprefix $(srcdir)/src/, $(HDRS))
30 srcs = $(addprefix $(srcdir)/src/, $(SRCS))
31 objs = $(addprefix $(builddir)/lib/, $(OBJS))
32 FULL = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
33 DISTFILES = $(DIRS) $(DATA) $(DOCS) $(srcs) $(hdrs) $(MANPAGES)
35 # Quiet by default, 'make V=1' shows commands
36 V=0
37 ifeq ($(V), 0)
38 Q = @
39 E = @echo
40 else
41 Q =
42 E = @true
43 endif
45 ## actual targets now ##
47 # default target
48 all: pgbouncer doc-all
50 # final executable
51 pgbouncer: config.mak $(objs)
52 $(E) " LD" $@
53 $(Q) $(CC) -o $@ $(LDFLAGS) $(objs) $(LIBS)
55 # objects depend on all the headers
56 $(builddir)/lib/%.o: $(srcdir)/src/%.c config.mak $(hdrs)
57 @mkdir -p $(builddir)/lib
58 $(E) " CC" $<
59 $(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
61 # install binary and other stuff
62 install: pgbouncer doc-install
63 mkdir -p $(DESTDIR)$(bindir)
64 mkdir -p $(DESTDIR)$(docdir)
65 $(BININSTALL) -m 755 pgbouncer $(DESTDIR)$(bindir)
66 $(INSTALL) -m 644 $(srcdir)/etc/pgbouncer.ini $(DESTDIR)$(docdir)
68 # create tarfile
69 tgz: config.mak $(DISTFILES) $(MANPAGES)
70 rm -rf $(FULL) $(FULL).tgz
71 mkdir $(FULL)
72 (for f in $(DISTFILES); do echo $$f; done) | cpio -p $(FULL)
73 tar czf $(FULL).tgz $(FULL)
74 rm -rf $(FULL)
76 doc/pgbouncer.1:
77 make -C doc pgbouncer.1
79 doc/pgbouncer.5:
80 make -C doc pgbouncer.5
82 # create debian package
83 deb: configure
84 yada rebuild
85 debuild -uc -us -b
87 # clean object files
88 clean: doc-clean
89 rm -f *~ src/*~ *.o src/*.o lib/*.o lib/*.s pgbouncer core core.*
90 rm -f lib/*.log
92 # clean configure results
93 distclean: clean doc-distclean
94 rm -f config.h config.log config.status config.mak
95 rm -rf lib autom4te*
97 # clean autoconf results
98 realclean: distclean doc-realclean
99 rm -f aclocal* config.h.in configure depcomp install-sh missing
100 rm -f tags
102 # generate configure script and config.h.in
103 boot: distclean
104 autoreconf -i -f
105 rm -rf autom4te* config.h.in~
107 # targets can depend on this to force ./configure
108 config.mak::
109 @test -f configure || { \
110 echo "Please run 'make boot && ./configure' first.";exit 1;}
111 @test -f $@ || { echo "Please run ./configure first.";exit 1;}
113 doc-all doc-install doc-clean doc-distclean doc-realclean:
114 $(MAKE) -C doc $(subst doc-,,$@) DESTDIR=$(DESTDIR)
117 # targets can depend on this to force 'make boot'
118 configure::
119 @test -f $@ || { echo "Please run 'make boot' first.";exit 1;}
121 # create tags file
122 tags: $(srcs) $(hdrs)
123 if test -f ../libevent/event.h; then \
124 ctags $(srcs) $(hdrs) ../libevent/*.[ch]; \
125 else \
126 ctags $(srcs) $(hdrs); \
129 # fixes for macos
130 SPARSE_MACOS=-D__STDC_VERSION__=199901 -D__LP64__=0 -DSENDFILE=1 \
131 -I/usr/lib/gcc/i486-linux-gnu/4.1.2/include
132 # sparse does not have any identity
133 SPARCE_FLAGS=-D__LITTLE_ENDIAN__ -D__i386__ -D__GNUC__=3 -D__GNUC_MINOR__=0 \
134 -Wno-transparent-union \
135 -Wall $(SPARSE_MACOS) $(CPPFLAGS) $(DEFS)
137 # run sparse over code
138 check: config.mak
139 $(E) " CHECK" $(srcs)
140 $(Q) sparse $(SPARCE_FLAGS) $(srcs)
142 pgbouncer.pg:
143 $(CC) -pg $(DEFS) -g -O2 $(CPPFLAGS) $(LDFLAGS) -o $@ $(srcs) $(LIBS)
145 pg: pgbouncer.pg
147 $(builddir)/lib/%.s: $(srcdir)/src/%.c config.mak $(hdrs)
148 @mkdir -p $(builddir)/lib
149 $(E) " CC -S" $<
150 $(Q) $(CC) -S -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS)
151 asms = $(objs:.o=.s)
152 asm: $(asms)