1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
#
# Bindle Binaries Tools
# Copyright (C) 2013 Bindle Binaries <syzdek@bindlebinaries.com>.
#
# @BINDLE_BINARIES_BSD_LICENSE_START@
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Bindle Binaries nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BINDLE BINARIES BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @BINDLE_BINARIES_BSD_LICENSE_END@
#
# m4/bindle-postgresql.m4 - m4 macros for find PostgreSQL client library
# and CLI utility.
#
# AC_BINDLE_WITH_POSTGRESQL(action-if-true, action-if-false)
# ______________________________________________________________________________
AC_DEFUN([AC_BINDLE_WITH_POSTGRESQL],[dnl
# prerequists
AC_REQUIRE([AC_PROG_CC])
# set initial values
HAVE_POSTGRESQL="yes"
POSTGRESQL_CFLAGS=""
POSTGRESQL_CPPFLAGS=""
POSTGRESQL_LDFLAGS=""
POSTGRESQL_LIBS=""
POSTGRESQL_PATH="${PATH}"
# display options
withval=""
AC_ARG_WITH(
pg-includedir,
[AS_HELP_STRING([--with-pg-includedir=DIR], [Search for PostgreSQL headers in DIR.])],
[ WITH_PG_INCLUDEDIR=$withval ],
[ WITH_PG_INCLUDEDIR=$withval ]
)
withval=""
AC_ARG_WITH(
pg-libdir,
[AS_HELP_STRING([--with-pg-libdir=DIR], [Search for PostgreSQL libraries in DIR.])],
[ WITH_PG_LIBDIR=$withval ],
[ WITH_PG_LIBDIR=$withval ]
)
withval=""
AC_ARG_WITH(
pg-path,
[AS_HELP_STRING([--with-pg-path=PATH], [Search for PostgreSQL utilities in PATH.])],
[ WITH_PG_PATH=$withval ],
[ WITH_PG_PATH=$withval ]
)
# checks for pg-includedir
if test "x${WITH_PG_INCLUDEDIR}" != "x" && \
test "x${WITH_PG_INCLUDEDIR}" != "xno" && \
test "x${WITH_PG_INCLUDEDIR}" != "xyes";then
POSTGRESQL_CPPFLAGS="-I${WITH_PG_INCLUDEDIR}"
fi
# checks for pg-libdir
if test "x${WITH_PG_LIBDIR}" != "x" && \
test "x${WITH_PG_LIBDIR}" != "xno" && \
test "x${WITH_PG_LIBDIR}" != "xyes";then
POSTGRESQL_LDLAGS="-L${WITH_PG_LIBDIR}"
fi
# checks for pg-path
if test "x${WITH_PG_PATH}" != "x" && \
test "x${WITH_PG_PATH}" != "xno" && \
test "x${WITH_PG_PATH}" != "xyes";then
POSTGRESQL_PATH="${WITH_PG_PATH}"
fi
# checks for utilities
AC_PATH_PROG([PG_CONFIG], [pg_config], [pg_config], [${POSTGRESQL_PATH}])
AC_PATH_PROG([PSQL], [psql], [psql], [${POSTGRESQL_PATH}])
# saves old parameters
OLD_CFLAGS=${CFLAGS}
OLD_CPPFLAGS=${CPPFLAGS}
OLD_LDFLAGS=${LDFLAGS}
OLD_LIBS=${LIBS}
# set new compile flags
CFLAGS="${OLD_CFLAGS} ${POSTGRESQL_CFLAGS}"
CPPFLAGS="${OLD_CPPFLAGS} ${POSTGRESQL_CPPFLAGS}"
LDFLAGS="${OLD_LDFLAGS} ${POSTGRESQL_LDFLAGS}"
LIBS="${OLD_LIBS} ${POSTGRESQL_LIBS}"
# check for headers and library
AC_CHECK_HEADERS([libpq-fe.h], [], [HAVE_POSTGRESQL="no"])
AC_SEARCH_LIBS([PQclear], [pq], [], [HAVE_POSTGRESQL="no"])
AC_SEARCH_LIBS([PQconnectdb], [pq], [], [HAVE_POSTGRESQL="no"])
AC_SEARCH_LIBS([PQerrorMessage], [pg], [], [HAVE_POSTGRESQL="no"])
AC_SEARCH_LIBS([PQexec], [pg], [], [HAVE_POSTGRESQL="no"])
AC_SEARCH_LIBS([PQfinish], [pg], [], [HAVE_POSTGRESQL="no"])
AC_SEARCH_LIBS([PQgetvalue], [pg], [], [HAVE_POSTGRESQL="no"])
AC_SEARCH_LIBS([PQnfields], [pg], [], [HAVE_POSTGRESQL="no"])
AC_SEARCH_LIBS([PQntuples], [pg], [], [HAVE_POSTGRESQL="no"])
AC_SEARCH_LIBS([PQstatus], [pg], [], [HAVE_POSTGRESQL="no"])
AC_SEARCH_LIBS([PQresultStatus], [pg], [], [HAVE_POSTGRESQL="no"])
# Apply substitution
AC_SUBST([HAVE_POSTGRESQL], [${HAVE_POSTGRESQL}])
AC_SUBST([POSTGRESQL_CFLAGS], [${POSTGRESQL_CFLAGS}])
AC_SUBST([POSTGRESQL_CPPFLAGS], [${POSTGRESQL_CPPFLAGS}])
AC_SUBST([POSTGRESQL_LDFLAGS], [${POSTGRESQL_LDFLAGS}])
AC_SUBST([POSTGRESQL_LIBS], [${LIBS}])
# replace old parameters
CFLAGS=${OLD_CFLAGS}
CPPFLAGS=${OLD_CPPFLAGS}
LDFLAGS=${OLD_LDFLAGS}
LIBS=${OLD_LIBS}
# runs specified response
if test "x${HAVE_POSTGRESQL}" == "xno" && test "x${2}" != "x";then
:
$2
elif test "x${HAVE_POSTGRESQL}" != "xno" && test "x${1}" != "x";then
:
$1
fi
])dnl
# end of m4 file
|