forked from sPHENIX-Collaboration/RDBC
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathacinclude.m4
executable file
·409 lines (339 loc) · 7.52 KB
/
acinclude.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
dnl $Id: acinclude.m4,v 1.4 2012/10/17 09:48:21 bbannier Exp $
dnl
dnl This file is part of the RDBC
dnl Author: Valeriy Onuchin <onuchin@sirius.ihep.su>
dnl
dnl Local macros borrowed from libodbc++, ++ few macros added for RDBC
dnl ------------------------------------------------------------------------
dnl Find a file (or one of more files in a list of dirs)
dnl ------------------------------------------------------------------------
dnl
AC_DEFUN([AC_FIND_FILE],
[
$3=NO
for i in $2;
do
for j in $1;
do
if test -r "$i/$j"; then
$3=$i
break 2
fi
done
done
])
dnl Macro: AC_CHECK_CXX_STL
dnl Sets $ac_cv_cxx_stl to yes or no
dnl defines HAVE_CXX_STL if ok
AC_DEFUN([AC_CHECK_CXX_STL],
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_MSG_CHECKING([whether STL is available])
AC_CACHE_VAL(ac_cv_cxx_stl,
[
AC_TRY_COMPILE([
#include <set>
],[
std::set<int> t;
t.insert(t.begin(),1);
std::set<int>::iterator i=t.find(1);
],
ac_cv_cxx_stl=yes,
ac_cv_cxx_stl=no)
])
AC_MSG_RESULT($ac_cv_cxx_stl)
if test "x$ac_cv_cxx_stl" = "xyes"
then
AC_DEFINE(HAVE_CXX_STL)
fi
AC_LANG_RESTORE
])
dnl Macro: AC_CHECK_CXX_EH
dnl Sets $ac_cv_cxx_eh to yes or no
AC_DEFUN([AC_CHECK_CXX_EH],
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS) has correct exception handling])
AC_CACHE_VAL(ac_cv_cxx_eh,
[
AC_TRY_RUN(
[
#include <exception>
#include <string.h>
using namespace std;
struct test : public exception {
virtual const char* what() { return "test"; }
};
static void func() { throw test(); }
int main(void)
{
try {
func();
} catch(exception& e) {
return (strcmp(e.what(),"test")==0);
} catch(...) { return 1; }
return 1;
}
],
ac_cv_cxx_eh=yes,
ac_cv_cxx_eh=no)
])
AC_MSG_RESULT([$ac_cv_cxx_eh])
if test "x$ac_cv_cxx_eh" = "xyes"
then
AC_DEFINE(HAVE_CXX_EH)
fi
AC_LANG_RESTORE
])
dnl Macro: AC_CHECK_CXX_NS
dnl Test if the c++ compiler supports namespaces
dnl Set $ac_cv_cxx_ns to either yes or no
dnl Define HAVE_CXX_NS if yes
AC_DEFUN([AC_CHECK_CXX_NS],
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS) supports namespaces])
AC_CACHE_VAL(ac_cv_cxx_ns,
[
AC_TRY_COMPILE([
namespace A {
namespace B {
struct X {};
};
};
],[
A::B::X x;
],
ac_cv_cxx_ns=yes,
ac_cv_cxx_ns=no)
])
AC_MSG_RESULT([$ac_cv_cxx_ns])
if test "x$ac_cv_cxx_ns" = "xyes"
then
AC_DEFINE(HAVE_CXX_NS)
fi
AC_LANG_RESTORE
])
dnl Macro: AC_CHECK_THREADS
dnl Test if we should compile with thread support
AC_DEFUN([AC_CHECK_THREADS],
[
AC_MSG_CHECKING([whether to enable threads])
enable_threads=yes
if test "x$enable_threads" = "xyes"
then
AC_MSG_RESULT(yes)
# ok, now check for pthreads
AC_CHECK_HEADER(pthread.h,[
AC_DEFINE(HAVE_PTHREAD_H)
],[AC_MSG_ERROR([pthread.h not found. Consider not using --enable-threads])])
# check if pthreads are in our default library environment
AC_CHECK_FUNCS(pthread_create,pthreads_ok=yes,pthreads_ok=no)
THREAD_LIBS=""
if test "x$pthreads_ok" != xyes
then
AC_CHECK_LIB(pthread,pthread_create,
pthreads_ok=yes
THREAD_LIBS="-lpthread",pthreads_ok=no)
fi
if test "x$pthreads_ok" != xyes
then
# try libc_r (*BSD)
AC_CHECK_LIB(c_r,pthread_create,
pthreads_ok=yes
THREAD_LIBS="-lc_r",pthreads_ok=no)
fi
if test "x$pthreads_ok" = xyes
then
# now we know we can use pthreads
AC_DEFINE(ENABLE_THREADS)
CXXFLAGS="-D_REENTRANT $CXXFLAGS"
CFLAGS="-D_REENTRANT $CFLAGS"
else
AC_MSG_ERROR([Unable to find a POSIX threads environment.])
fi
else
AC_MSG_RESULT(no)
fi
AC_SUBST(THREAD_LIBS)
])
dnl Macro: AC_CHECK_IODBC
dnl Checks for iodbc optionally in provided directories
dnl sets shell variable iodbc_ok to yes or no.
dnl Defines HAVE_LIBIODBC, HAVE_ISQL_H, HAVE_ISQLEXT_H if they are found
AC_DEFUN([AC_CHECK_IODBC],
[
AC_LANG_SAVE
AC_LANG_C
AC_ARG_WITH(iodbc,
[ --with-iodbc[=DIR] Use iodbc, optionally installed in DIR],
[
if test "x$withval" != "xyes"
then
iodbc_dir=$withval
else
iodbc_dir="/usr/local"
fi
])
if test "x$iodbc_dir" = "x"
then
iodbc_dir="/usr/local"
fi
AC_ARG_WITH(iodbc-includes,
[ --with-iodbc-includes=DIR Find iodbc headers in DIR],
[iodbc_includes_dir=$withval],
[iodbc_includes_dir="$iodbc_dir/include"]
)
AC_ARG_WITH(iodbc-libraries,
[ --with-iodbc-libs=DIR Find iodbc libraries in DIR],
[iodbc_libraries_dir=$withval],
[iodbc_libraries_dir="$iodbc_dir/lib"]
)
save_CFLAGS="$CFLAGS"
save_LIBS="$LIBS"
CFLAGS="$CFLAGS -I$iodbc_includes_dir"
LIBS="$LIBS -L$iodbc_libraries_dir"
AC_CHECK_HEADERS([isql.h isqlext.h],
[iodbc_ok=yes; odbc_headers="$odbc_headers $ac_hdr"],
[iodbc_ok=no; break])
if test "x$iodbc_ok" = "xyes"
then
AC_CHECK_LIB(iodbc,SQLConnect,[iodbc_ok=yes],[iodbc_ok=no])
fi
if test "x$iodbc_ok" = "xyes"
then
LIBS="$LIBS -liodbc"
AC_DEFINE(HAVE_LIBIODBC)
AC_DEFINE(HAVE_ISQL_H)
AC_DEFINE(HAVE_ISQLEXT_H)
else
CFLAGS="$save_CFLAGS"
LIBS="$save_LIBS"
fi
AC_LANG_RESTORE
])
AC_DEFUN([AC_CHECK_ODBC],
[
AC_LANG_SAVE
AC_LANG_C
AC_MSG_CHECKING([whether unixODBC should be used])
AC_ARG_WITH(odbc,
[ --with-odbc[=DIR] Use unixODBC, optionally installed in DIR],
[
if test "x$withval" != "xyes"
then
odbc_dir=$withval
else
odbc_dir="/usr/local"
fi
])
if test "x$odbc_dir" = "x"
then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
AC_ARG_WITH(odbc-includes,
[ --with-odbc-includes=DIR Find unixODBC headers in DIR],
[odbc_includes_dir=$withval],
[odbc_includes_dir="$odbc_dir/include"]
)
AC_ARG_WITH(odbc-libraries,
[ --with-odbc-libs=DIR Find unixODBC libraries in DIR],
[odbc_libraries_dir=$withval],
[odbc_libraries_dir="$odbc_dir/lib"]
)
odbc_libraries_dir="$odbc_dir/lib"
save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS -I$odbc_includes_dir"
LIBS="$LIBS -L$odbc_libraries_dir"
AC_CHECK_HEADERS([sql.h sqlext.h],
[odbc_ok=yes; odbc_headers="$odbc_headers $ac_hdr"],
[odbc_ok=no; break]
)
if test "x$odbc_ok" = "xyes"
then
AC_CHECK_LIB(odbc,SQLConnect,[odbc_ok=yes],[odbc_ok=no])
fi
if test "x$odbc_ok" = "xyes"
then
LIBS="$LIBS -lodbc"
AC_DEFINE(HAVE_LIBODBC)
AC_DEFINE(HAVE_SQL_H)
AC_DEFINE(HAVE_SQLEXT_H)
else
CPPFLAGS="$save_CPPFLAGS"
LIBS="$save_LIBS"
fi
fi
AC_LANG_RESTORE
])
dnl Macro: AC_CHECK_ODBC_TYPE
dnl Checks if $1 is a valid type in the ODBC environment,
dnl and #defines it to $2 if not
AC_DEFUN([AC_CHECK_ODBC_TYPE],
[
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_odbc_$1,
[
AC_LANG_SAVE
AC_LANG_C
echo > conftest.c
for i in $odbc_headers
do
echo "#include <$i>" >> conftest.c
done
echo "int main(void) { $1 x; return 0; }" >> conftest.c
if $CC -c $CFLAGS $CPPFLAGS conftest.c > /dev/null 2> /dev/null
then
eval ac_cv_odbc_$1=yes
else
eval ac_cv_odbc_$2=no
fi
rm -f conftest*
AC_LANG_RESTORE
])
eval ac_odbc_check_res=$ac_cv_odbc_$1
if test "x$ac_odbc_check_res" = "xyes"
then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT([no ($2)])
AC_DEFINE($1,$2)
fi
])
dnl Macro: AC_CHECK_ROOT
dnl Checks if ROOT installed
dnl Defines: ROOT dependent LIBS, CPPFLAGS etc.
AC_DEFUN([AC_CHECK_ROOT],
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ROOT_CPPFLAGS="`root-config --cflags`"
ROOT_LIBS="`root-config --libs`"
ROOTCINT=rootcint
ROOT_GLIBS="`root-config --glibs`"
ROOT_VER="`root-config --version | sed 's/\//\./'`"
AC_SUBST(ROOT_VER)
AC_SUBST(ROOTSYS)
if test "$GCC" = "yes"; then
GCC_VER="`g++ --version | perl -n -e 'if (($l) = m/(\d+\.\d+(\.\d+)?)/) {print $l;}'`"
AC_SUBST(GCC_VER)
fi
LIBS="$LIBS $ROOT_LIBS"
CPPFLAGS="$CPPFLAGS $ROOT_CPPFLAGS"
AC_SUBST(ROOT_CPPFLAGS)
AC_SUBST(ROOT_LIBS)
AC_SUBST(ROOTCINT)
AC_LANG_RESTORE
])
dnl AC_ARG_WITH(libodbcxx,
dnl [ --with-libodbcxx=DIR Find libodbc++ installed in DIR],
dnl [libodbcxx_dir=$withval],
dnl [libodbcxx_dir="/usr/local"]
dnl )
ODBCXX_DIR="/usr/local"
AC_SUBST(ODBCXX_DIR)