Code

RRTimeslice: added a cast to timestamp.
[postrr.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 dnl This is the PostRR configure script.
4 dnl
5 dnl Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>
6 dnl All rights reserved.
7 dnl
8 dnl Redistribution and use in source and binary forms, with or without
9 dnl modification, are permitted provided that the following conditions
10 dnl are met:
11 dnl 1. Redistributions of source code must retain the above copyright
12 dnl    notice, this list of conditions and the following disclaimer.
13 dnl 2. Redistributions in binary form must reproduce the above copyright
14 dnl    notice, this list of conditions and the following disclaimer in the
15 dnl    documentation and/or other materials provided with the distribution.
16 dnl
17 dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 dnl PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21 dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 dnl OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 dnl WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 dnl ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 AC_INIT([PostgreSQL Round-Robin Extension],
30                 [m4_esyscmd(./version-gen.sh)],
31                 [sh@tokkee.org],
32                 [postrr],
33                 [http://git.tokkee.org/?p=postrr.git])
34 PACKAGE_MAINTAINER="Sebastian 'tokkee' Harl <sh@tokkee.org>"
35 AC_DEFINE_UNQUOTED([PACKAGE_MAINTAINER], ["$PACKAGE_MAINTAINER"],
36                 [Define to the name of the maintainer of this package.])
37 AC_CONFIG_SRCDIR([src/base.c])
38 AC_CONFIG_HEADERS([src/postrr_config.h])
39 AC_PREFIX_DEFAULT([/opt/postrr])
41 AM_INIT_AUTOMAKE([foreign -Wall])
43 AC_LANG(C)
45 AC_SYS_LARGEFILE
47 AC_PROG_CC
48 AC_PROG_CPP
49 AC_PROG_INSTALL
50 AC_PROG_LN_S
51 AC_PROG_MAKE_SET
53 AM_PROG_CC_C_O
55 m4_ifdef([LT_INIT],
56         [
57          LT_INIT
58         ],
59         # else
60         # (older libtools)
61         [
62          AC_PROG_LIBTOOL
63         ]
64 )
66 test_cc_flags() {
67         AC_LANG_CONFTEST([AC_LANG_PROGRAM([[ ]], [[ ]])])
68         $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
69         ret=$?
70         rm -f conftest.o
71         return $ret
72 }
74 m4_divert_once([HELP_ENABLE], [
75 Build options:])
77 dnl Optionally stick to standard C99 and POSIX:2001 as close as possible.
78 AC_ARG_ENABLE([standards],
79                 AS_HELP_STRING([--enable-standards],
80                                 [C99 / POSIX standards compliance mode @<:@default=no@:>@]),
81                 [enable_standards="$enableval"],
82                 [enable_standards="no"])
84 if test "x$enable_standards" = "xyes"; then
85         AC_DEFINE([_ISOC99_SOURCE], 1,
86                         [Define to enforce ISO/IEC 9899:1999 (C99) compliance.])
87         AC_DEFINE([_POSIX_C_SOURCE], 200112L,
88                         [Define to enforce IEEE 1003.1-2001 (POSIX:2001) compliance.])
89         AC_DEFINE([_XOPEN_SOURCE], 600,
90                         [Define to enforce X/Open 6 (XSI) compliance.])
91         AC_DEFINE([_REENTRANT], 1,
92                         [Define to enable reentrant interfaces.])
93         AC_DEFINE([_THREAD_SAFE], 1,
94                         [Define to enable reentrant interfaces.])
96         for flag in -std=c99 -pedantic; do
97                 AC_MSG_CHECKING([whether $CC accepts $flag])
99                 if test_cc_flags $flag; then
100                         CFLAGS="$CFLAGS $flag"
101                         AC_MSG_RESULT([yes])
102                 else
103                         AC_MSG_RESULT([no])
104                 fi
105         done
106 fi
108 dnl Hardening (see e.g. http://wiki.debian.org/Hardening for a motivation).
109 AC_DEFINE([_FORTIFY_SOURCE], 2,
110                 [Define to enable protection against static sized buffer overflows.])
111 AC_ARG_ENABLE([hardening],
112                 AS_HELP_STRING([--disable-hardening],
113                                 [hardening options @<:@default=yes@:>@]),
114                 [enable_hardening="$enableval"],
115                 [enable_hardening="yes"])
117 if test "x$enable_hardening" = "xyes"; then
118         hardening=0
119         hardening_tests=0
120         for flag in -Wformat -Wformat-security; do
121                 hardening_tests=$(($hardening_tests + 1))
122                 AC_MSG_CHECKING([whether $CC accepts $flag])
124                 if test_cc_flags $flag; then
125                         CFLAGS="$CFLAGS $flag"
126                         hardening=$(($hardening + 1))
127                         AC_MSG_RESULT([yes])
128                 else
129                         AC_MSG_RESULT([no])
130                 fi
131         done
132         if test $hardening -ne $hardening_tests; then
133                 AC_MSG_WARN(
134                                 [Some hardening options are not supported by your compiler!])
135         fi
136 fi
138 dnl Strict checking for potential problems.
139 AC_ARG_ENABLE([strict-checks],
140                 AS_HELP_STRING([--disable-strict-checks],
141                                 [strict compiler checks @<:@default=yes@:>@]),
142                 [enable_strict_checks="$enableval"],
143                 [enable_strict_checks="yes"])
145 STRICT_CPPFLAGS=""
146 for flag in -Wall -Werror; do
147         AC_MSG_CHECKING([whether $CC accepts $flag])
149         if test_cc_flags $flag; then
150                 STRICT_CPPFLAGS="$STRICT_CPPFLAGS $flag"
151                 AC_MSG_RESULT([yes])
152         else
153                 AC_MSG_RESULT([no])
154         fi
155 done
157 if test "x$enable_strict_checks" = "xyes"; then
158         for flag in -Wextra \
159                         -Wbad-function-cast \
160                         -Wcast-align \
161                         -Wcast-qual \
162                         -Wconversion \
163                         -Wdeclaration-after-statement \
164                         -Wmissing-prototypes \
165                         -Wpointer-arith \
166                         -Wshadow \
167                         -Wstrict-prototypes \
168                         -Wunreachable-code; do
169                 AC_MSG_CHECKING([whether $CC accepts $flag])
171                 if test_cc_flags $flag; then
172                         STRICT_CPPFLAGS="$STRICT_CPPFLAGS $flag"
173                         AC_MSG_RESULT([yes])
174                 else
175                         AC_MSG_RESULT([no])
176                 fi
177         done
178 fi
179 AC_SUBST([STRICT_CPPFLAGS])
181 AC_CHECK_HEADERS(libgen.h)
183 dnl Check for dependencies.
184 build_documentation="yes"
186 have_xsltproc="yes"
187 AC_PATH_PROG([XSLTPROC], [xsltproc])
188 if test "x$XSLTPROC" = "x"; then
189        have_xsltproc="no"
190        build_documentation="no (missing xsltproc)"
191 fi
193 have_a2x="yes"
194 AC_PATH_PROG([A2X], [a2x])
195 if test "x$A2X" = "x"; then
196        have_a2x="no"
197        build_documentation="no (missing a2x)"
198 fi
199 AC_SUBST([A2X])
201 dnl pg_config
202 AC_ARG_WITH([pgconfig],
203                 [AS_HELP_STRING([--with-pgconfig=FILE], [foo bar],)],
204                 [PG_CONFIG="$withval"], [PG_CONFIG=""])
206 if test "x$PG_CONFIG" = "x"; then
207         AC_PATH_PROG([PG_CONFIG], [pg_config])
209         if test "x$PG_CONFIG" = "x"; then
210                 AC_MSG_ERROR([could not find pg_config in \$PATH; rerun configure with the --with-pgconfig parameter.])
211         fi
212 else
213         if test "x$PG_CONFIG" = "xyes" -o "x$PG_CONFIG" = "xno"; then
214                 AC_MSG_ERROR([please specify a parameter for --with-pgconfig])
215         else
216                 if ! test -f "$PG_CONFIG"; then
217                         AC_MSG_ERROR([the specified path to pg_config does not exist: $PG_CONFIG])
218                 fi
219         fi
220 fi
221 AC_SUBST([PG_CONFIG])
223 PGXS=`$PG_CONFIG --pgxs`
224 if ! test -f "$PGXS"; then
225         AC_MSG_ERROR([could not find PGXS Makefile: '$PGXS'])
226 fi
227 AC_SUBST([PGXS])
229 PG_VERSION=`$PG_CONFIG --version`
231 AC_DEFINE_UNQUOTED([PG_VERSION], ["$PG_VERSION"],
232                 [Define to the version of PostgreSQL the package was built against.])
234 POSTRR_MAJOR_VERSION=`cat version | grep VERSION_MAJOR | cut -d= -f2`
235 POSTRR_MINOR_VERSION=`cat version | grep VERSION_MINOR | cut -d= -f2`
236 POSTRR_PATCH_VERSION=`cat version | grep VERSION_PATCH | cut -d= -f2`
238 AC_SUBST([POSTRR_MAJOR_VERSION])
239 AC_SUBST([POSTRR_MINOR_VERSION])
240 AC_SUBST([POSTRR_PATCH_VERSION])
242 AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
244 AC_CONFIG_FILES([Makefile doc/Makefile
245                 src/Makefile src/Makefile.pgxs
246                 src/postrr.sql])
247 AC_OUTPUT
249 AC_MSG_RESULT()
250 AC_MSG_RESULT([$PACKAGE_NAME has been configured successfully.])
251 AC_MSG_RESULT()
252 AC_MSG_RESULT([Run 'make' to compile the software and use 'make install' to])
253 AC_MSG_RESULT([install the package into $prefix.])
254 AC_MSG_RESULT()
255 AC_MSG_RESULT([Configuration summary:])
256 AC_MSG_RESULT()
257 AC_MSG_RESULT([  package version: $PACKAGE_VERSION])
258 AC_MSG_RESULT([  build date: `date --utc '+%F %T'` (UTC)])
259 AC_MSG_RESULT()
260 AC_MSG_RESULT([  Tools:])
261 AC_MSG_RESULT([    AsciiDoc (a2x): . . . . . . $have_a2x])
262 AC_MSG_RESULT([    xsltproc: . . . . . . . . . $have_xsltproc])
263 AC_MSG_RESULT()
264 AC_MSG_RESULT([  PostgreSQL tools and helpers:])
265 AC_MSG_RESULT([    pg_config:  . . . . . . . . $PG_CONFIG])
266 AC_MSG_RESULT([    PGXS Makefile:  . . . . . . $PGXS])
267 AC_MSG_RESULT([    Version:  . . . . . . . . . $PG_VERSION])
268 AC_MSG_RESULT()
269 AC_MSG_RESULT([  Features:])
270 AC_MSG_RESULT([    documentation:  . . . . . . $build_documentation])
271 AC_MSG_RESULT()
272 AC_MSG_RESULT([This package is maintained by $PACKAGE_MAINTAINER.])
273 AC_MSG_RESULT([Please report bugs to $PACKAGE_BUGREPORT.])
274 AC_MSG_RESULT()