annotate GEMBASSY-1.0.3/m4/postgresql.m4 @ 0:8300eb051bea draft

Initial upload
author ktnyt
date Fri, 26 Jun 2015 05:19:29 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1 dnl -*- Autoconf -*-
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2 ##### http://autoconf-archive.cryp.to/ax_lib_postgresql.html
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
4 # SYNOPSIS
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
5 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
6 # AX_LIB_POSTGRESQL([MINIMUM-VERSION])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
7 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
8 # DESCRIPTION
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
9 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
10 # This macro provides tests of availability of PostgreSQL 'libpq'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
11 # library of particular version or newer.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
12 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
13 # AX_LIB_POSTGRESQL macro takes only one argument which is optional.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
14 # If there is no required version passed, then macro does not run
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
15 # version test.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
16 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
17 # The --with-postgresql option takes one of three possible values:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
18 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
19 # no - do not check for PostgreSQL client library
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
20 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
21 # yes - do check for PostgreSQL library in standard locations
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
22 # (pg_config should be in the PATH)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
23 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
24 # path - complete path to pg_config utility, use this option if
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
25 # pg_config can't be found in the PATH
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
26 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
27 # This macro calls:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
28 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
29 # AC_SUBST([POSTGRESQL_CFLAGS])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
30 # AC_SUBST([POSTGRESQL_CPPFLAGS])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
31 # AC_SUBST([POSTGRESQL_LDFLAGS])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
32 # AC_SUBST([POSTGRESQL_VERSION])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
33 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
34 # And sets:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
35 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
36 # HAVE_POSTGRESQL
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
37 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
38 # LAST MODIFICATION
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
39 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
40 # 2006-07-16
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
41 # 2010-05-14 MKS: Added POSTGRESQL_CPPFLAGS
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
42 # 2011-06-21 AJB: Added workaround for Fedora pg_config oddity
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
43 # 2011-08-01 MKS: Changed PG_CONFIG to POSTGRESQL_CONFIG
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
44 # Made test constructs more portable
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
45 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
46 # COPYLEFT
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
47 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
48 # Copyright (c) 2006 Mateusz Loskot <mateusz@loskot.net>
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
49 #
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
50 # Copying and distribution of this file, with or without
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
51 # modification, are permitted in any medium without royalty provided
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
52 # the copyright notice and this notice are preserved.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
53
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
54 AC_DEFUN([AX_LIB_POSTGRESQL],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
55 [
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
56 POSTGRESQL_CFLAGS=""
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
57 POSTGRESQL_CPPFLAGS=""
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
58 POSTGRESQL_LDFLAGS=""
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
59 POSTGRESQL_CONFIG=""
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
60 POSTGRESQL_VERSION=""
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
61
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
62 AC_ARG_WITH([postgresql],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
63 [AS_HELP_STRING([--with-postgresql@<:=@ARG@:>@],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
64 [use PostgreSQL library @<:@default=yes@:>@, optionally specify path to pg_config])],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
65 [
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
66 AS_IF([test "x${withval}" = "xno"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
67 [want_postgresql="no"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
68 [test "x${withval}" = "xyes"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
69 [want_postgresql="yes"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
70 [
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
71 want_postgresql="yes"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
72 POSTGRESQL_CONFIG="${withval}"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
73 ])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
74 ],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
75 [want_postgresql="yes"])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
76
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
77 dnl
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
78 dnl Check PostgreSQL libraries (libpq)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
79 dnl
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
80
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
81 AS_IF([test "x${want_postgresql}" = "xyes"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
82 [
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
83 AS_IF([test -z "${POSTGRESQL_CONFIG}" -o test],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
84 [AC_PATH_PROG([POSTGRESQL_CONFIG], [pg_config], [no])])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
85
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
86 AS_IF([test "x${POSTGRESQL_CONFIG}" != "xno"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
87 [
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
88 AC_MSG_CHECKING([for PostgreSQL libraries])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
89
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
90 POSTGRESQL_CFLAGS="-I`${POSTGRESQL_CONFIG} --includedir`"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
91 POSTGRESQL_CPPFLAGS="-I`${POSTGRESQL_CONFIG} --includedir`"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
92 POSTGRESQL_LDFLAGS="-L`${POSTGRESQL_CONFIG} --libdir` -lpq"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
93
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
94 POSTGRESQL_VERSION=`${POSTGRESQL_CONFIG} --version | sed -e 's#PostgreSQL ##'`
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
95
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
96 dnl It isn't enough to just test for pg_config as Fedora
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
97 dnl provides it in the postgresql RPM even though postgresql-devel may
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
98 dnl not be installed
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
99
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
100 EMBCPPFLAGS="${CPPFLAGS}"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
101 EMBLDFLAGS="${LDFLAGS}"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
102
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
103 CPPFLAGS="${POSTGRESQL_CPPFLAGS} ${EMBCPPFLAGS}"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
104 LDFLAGS="${POSTGRESQL_LDFLAGS} ${EMBLDFLAGS}"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
105
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
106 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
107 #include "libpq-fe.h"]],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
108 [[PQconnectdb(NULL)]])],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
109 [havepostgresql="yes"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
110 [havepostgresql="no"])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
111
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
112 CPPFLAGS="${EMBCPPFLAGS}"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
113 LDFLAGS="${EMBLDFLAGS}"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
114
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
115 AS_IF([test "x${havepostgresql}" = "xyes"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
116 [
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
117 AC_DEFINE([HAVE_POSTGRESQL], [1],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
118 [Define to 1 if PostgreSQL libraries are available.])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
119 found_postgresql="yes"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
120 AC_MSG_RESULT([yes])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
121 ],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
122 [
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
123 POSTGRESQL_CFLAGS=""
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
124 POSTGRESQL_CPPFLAGS=""
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
125 POSTGRESQL_LDFLAGS=""
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
126 found_postgresql="no"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
127 AC_MSG_RESULT([no])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
128 ])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
129 ],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
130 [
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
131 found_postgresql="no"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
132 ])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
133 ])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
134
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
135 dnl
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
136 dnl Check if required version of PostgreSQL is available
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
137 dnl
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
138
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
139 postgresql_version_req=ifelse([$1], [], [], [$1])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
140
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
141 AS_IF([test "x${found_postgresql}" = "xyes" -a -n "${postgresql_version_req}"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
142 [
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
143 AC_MSG_CHECKING([if PostgreSQL version is >= ${postgresql_version_req}])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
144
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
145 dnl Decompose required version string of PostgreSQL
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
146 dnl and calculate its number representation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
147
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
148 postgresql_version_req_major=`expr ${postgresql_version_req} : '\([[0-9]]*\)'`
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
149 postgresql_version_req_minor=`expr ${postgresql_version_req} : '[[0-9]]*\.\([[0-9]]*\)'`
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
150 postgresql_version_req_micro=`expr ${postgresql_version_req} : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
151
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
152 AS_IF([test "x${postgresql_version_req_micro}" = "x"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
153 [postgresql_version_req_micro="0"])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
154
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
155 postgresql_version_req_number=`expr ${postgresql_version_req_major} \* 1000000 \
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
156 \+ ${postgresql_version_req_minor} \* 1000 \
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
157 \+ ${postgresql_version_req_micro}`
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
158
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
159 dnl Decompose version string of installed PostgreSQL
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
160 dnl and calculate its number representation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
161
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
162 postgresql_version_major=`expr ${POSTGRESQL_VERSION} : '\([[0-9]]*\)'`
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
163 postgresql_version_minor=`expr ${POSTGRESQL_VERSION} : '[[0-9]]*\.\([[0-9]]*\)'`
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
164 postgresql_version_micro=`expr ${POSTGRESQL_VERSION} : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
165
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
166 AS_IF([test "x${postgresql_version_micro}" = "x"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
167 [postgresql_version_micro="0"])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
168
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
169 postgresql_version_number=`expr ${postgresql_version_major} \* 1000000 \
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
170 \+ ${postgresql_version_minor} \* 1000 \
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
171 \+ ${postgresql_version_micro}`
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
172
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
173 postgresql_version_check=`expr ${postgresql_version_number} \>\= ${postgresql_version_req_number}`
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
174
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
175 AS_IF([test "x${postgresql_version_check}" = "x1"],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
176 [AC_MSG_RESULT([yes])],
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
177 [AC_MSG_RESULT([no])])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
178 ])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
179
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
180 AC_SUBST([POSTGRESQL_CFLAGS])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
181 AC_SUBST([POSTGRESQL_CPPFLAGS])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
182 AC_SUBST([POSTGRESQL_LDFLAGS])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
183 AC_SUBST([POSTGRESQL_VERSION])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
184 ])