-
Notifications
You must be signed in to change notification settings - Fork 0
/
soci.m4
211 lines (182 loc) · 5.61 KB
/
soci.m4
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
dnl @synopsis AX_SOCI
dnl
dnl This macro tries to find Soci C API header and library locations.
dnl
dnl We define the following configure script flags:
dnl
dnl --with-soci: Give prefix for both library and headers, and try
dnl to guess subdirectory names for each. (e.g. Tack /lib and
dnl /include onto given dir name, and other common schemes.)
dnl --with-soci-lib: Similar to --with-soci, but for library only.
dnl --with-soci-include: Similar to --with-soci, but for headers
dnl only.
dnl
dnl @version 1.2, 2007/02/20
dnl @author Warren Young <[email protected]>
AC_DEFUN([AX_SOCI],
[
#
# Set up configure script macros
#
AC_ARG_WITH(soci,
[ --with-soci=<path> root directory path of Soci installation],
[SOCI_lib_check="$with_soci/lib64/soci $with_soci/lib/soci $with_soci/lib64 $with_soci/lib"
SOCI_inc_check="$with_soci/include $with_soci/include/soci"
SOCI_bin_check="$with_soci/bin"],
[SOCI_lib_check="/usr/lib64 /usr/lib /usr/lib64/soci /usr/lib/soci /usr/local/lib64 /usr/local/lib /usr/local/lib/soci /usr/local/soci/lib /usr/local/soci/lib/soci /opt/soci/lib /opt/soci/lib/soci"
SOCI_inc_check="/usr/include /usr/include/soci /usr/local/include/soci /usr/local/soci/include /usr/local/soci/include/soci /opt/soci/include /opt/soci/include/soci"
SOCI_bin_check="/usr/bin /usr/local/bin /usr/local/soci/bin /opt/bin /opt/soci/bin /opt/bin/soci"])
AC_ARG_WITH(soci-lib,
[ --with-soci-lib=<path> directory path of Soci library installation],
[SOCI_lib_check="$with_soci_lib $with_soci_lib/lib64 $with_soci_lib/lib $with_soci_lib/lib64/soci $with_soci_lib/lib/soci"])
AC_ARG_WITH(soci-include,
[ --with-soci-include=<path> directory path of Soci header installation],
[SOCI_inc_check="$with_soci_include $with_soci_include/include $with_soci_include/include/soci"])
#
# Look for Soci Configuration Script
#
AC_MSG_CHECKING([for Soci configuration script])
SOCI_CONFIG=
SOCI_bindir=
for m in $SOCI_bin_check
do
if test -d "$m" && test -f "$m/soci-config"
then
SOCI_CONFIG=$m/soci-config
SOCI_bindir=$m
break
fi
done
# if test -z "$SOCI_bindir"
# then
# AC_MSG_ERROR([Didn't find $SOCI_CONFIG binary in '$SOCI_bin_check'])
# fi
# case "$SOCI_bindir" in
# /* ) ;;
# * ) AC_MSG_ERROR([The Soci binary directory ($SOCI_bindir) must be an absolute path.]) ;;
# esac
AC_MSG_RESULT([$SOCI_CONFIG])
# AC_PATH_PROG(SOCI_CONFIG, soci-config, $SOCI_bindir)
if test "x${SOCI_CONFIG}1" != "x1"
then
SOCI_VERSION=`${SOCI_CONFIG} --version`
fi
# SOCI library
SOCI_CORE_LIB=soci_core
SOCI_MYSQL_LIB=soci_mysql
SOCI_LIB_SUFFIX=gcc-3_0
#
# Look for Soci Core API library
#
AC_MSG_CHECKING([for Soci library directory])
SOCI_libdir=
for m in $SOCI_lib_check
do
if test -d "$m"
then
for socilib in "$SOCI_CORE_LIB $SOCI_CORE_LIB-${SOCI_LIB_SUFFIX}"
do
if (test -f "$m/lib$SOCI_CORE_LIB.so" || test -f "$m/lib$SOCI_CORE_LIB.a")
then
SOCI_libdir=$m
break
fi
if (test -f "$m/lib${SOCI_CORE_LIB}-${SOCI_LIB_SUFFIX}.so" \
|| test -f "$m/lib${SOCI_CORE_LIB}-${SOCI_LIB_SUFFIX}.a")
then
SOCI_CORE_LIB=${SOCI_CORE_LIB}-${SOCI_LIB_SUFFIX}
SOCI_MYSQL_LIB=${SOCI_MYSQL_LIB}-${SOCI_LIB_SUFFIX}
SOCI_libdir=$m
break
fi
done
fi
done
if test -z "$SOCI_libdir"
then
AC_MSG_ERROR([Didn't find $SOCI_CORE_LIB library in '$SOCI_lib_check'])
fi
case "$SOCI_libdir" in
/* ) ;;
* ) AC_MSG_ERROR([The Soci library directory ($SOCI_libdir) must be an absolute path.]) ;;
esac
AC_MSG_RESULT([$SOCI_libdir])
# case "$SOCI_libdir" in
# /usr/lib) ;;
# *) LDFLAGS="$LDFLAGS -L${SOCI_libdir}" ;;
# esac
SOCI_areHeadersBuried=
#
# Look for Soci Core API headers (case of buried headers)
#
AC_MSG_CHECKING([for Soci include directory])
SOCI_incdir=
for m in $SOCI_inc_check
do
if test -d "$m" && test -f "$m/soci/core/soci.h"
then
SOCI_incdir=$m
SOCI_areHeadersBuried=true
break
fi
done
#
# if Soci Code API headers not found, look for non-buried headers
#
if test -z "$SOCI_incdir"
then
for m in $SOCI_inc_check
do
if test -d "$m" && test -f "$m/soci.h"
then
SOCI_incdir=$m
break
fi
done
fi
if test -z "$SOCI_incdir"
then
AC_MSG_ERROR([Didn't find the Soci include dir in '$SOCI_inc_check'])
fi
case "$SOCI_incdir" in
/* ) ;;
* ) AC_MSG_ERROR([The Soci include directory ($SOCI_incdir) must be an absolute path.]) ;;
esac
AC_MSG_RESULT([$SOCI_incdir])
if test "$SOCI_incdir" != "/usr/include"
then
SOCI_CFLAGS="-I${SOCI_incdir}"
fi
if test "$SOCI_libdir" != "/usr/lib" -a "$SOCI_libdir" != "/usr/lib64"
then
SOCI_LIBS="-L${SOCI_libdir}"
fi
# Checking whether or not the headers are buried
AC_MSG_CHECKING(for Soci whether headers are buried)
if test "$SOCI_areHeadersBuried" = true
then
AC_MSG_RESULT(they are => -DSOCI_HEADERS_BURIED -DSOCI_MYSQL_HEADERS_BURIED added to SOCI_CFLAGS.)
SOCI_CFLAGS="-DSOCI_HEADERS_BURIED -DSOCI_MYSQL_HEADERS_BURIED ${SOCI_CFLAGS}"
else
AC_MSG_RESULT(they are not.)
fi
SOCI_CFLAGS="${MYSQL_CFLAGS} ${SOCI_CFLAGS}"
SOCI_LIBS="${MYSQL_LIBS} ${SOCI_LIBS} -l${SOCI_CORE_LIB} -l${SOCI_MYSQL_LIB} -ldl"
AC_SUBST(SOCI_VERSION)
AC_SUBST(SOCI_CFLAGS)
AC_SUBST(SOCI_LIBS)
# Test linking with soci (note that it needs MySQL client to have
# been defined before)
save_LIBS="$LIBS"
if test -z "$MYSQL_LIBS"
then
MYSQL_LIBS="-L/usr/lib64/mysql -L/usr/lib/mysql -lmysqlclient"
fi
LIBS="$LIBS $MYSQL_LIBS $SOCI_LIBS"
AC_CHECK_LIB($SOCI_CORE_LIB, soci_begin,
[],
[AC_MSG_ERROR([Could not find working Soci client library!])]
)
LIBS="$save_LIBS"
AC_SUBST(SOCI_CORE_LIB)
]) dnl AX_SOCI