File: acinclude.m4

package info (click to toggle)
myodbc 3.51.11-6.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,056 kB
  • ctags: 1,933
  • sloc: ansic: 31,656; sh: 10,955; cpp: 2,439; makefile: 1,120
file content (571 lines) | stat: -rw-r--r-- 12,694 bytes parent folder | download
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
dnl ---------------------------------------------------------
dnl
dnl Macro: 
dnl     AC_FIND_FILE
dnl 
dnl Arguments:
dnl
dnl Description:
dnl     Find file(s) in given directories.
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 ---------------------------------------------------------
dnl
dnl Macro: 
dnl     AC_CHECK_ODBC_TYPE
dnl
dnl Arguments:
dnl
dnl Description:
dnl     Checks if $1 is a valid type in the ODBC environment,
dnl     and #defines it to $2 if not
dnl
dnl ---------------------------------------------------------

AC_DEFUN(AC_CHECK_ODBC_TYPE,
[

AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_odbc_$1,
[
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*
])

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,[Define if $1 is undefined])
fi
])


dnl ---------------------------------------------------------
dnl
dnl Macro: 
dnl     AC_CHECK_IODBC
dnl
dnl Arguments: 
dnl     $1=includedir
dnl     $2=libdir
dnl
dnl Description:
dnl     Checks for iODBC. If found configure for it.
dnl
dnl ---------------------------------------------------------

AC_DEFUN(AC_CHECK_IODBC,
[
CPPFLAGS="$CPPFLAGS $ODBC_FLAGS -I$1"
AC_CHECK_HEADERS([isql.h isqlext.h isqltypes.h],
[iodbc_ok=yes;odbc_headers="$odbc_headers $ac_hdr"],[iodbc_ok=no; break])

if test "x$iodbc_ok" != "xyes"
then
	AC_MSG_ERROR([Unable to find the iodbc headers in '$1'])
fi


# new autoconf tools doesn't detect through ac_hdr, so define
# odbc_headers manually to make AC_CHECK_ODBC_TYPE to work
if test "x$odbc_headers" = "x"
then
  odbc_headers="isql.h isqlext.h isqltypes.h"
fi

AC_CHECK_HEADERS(iodbcinst.h)

if test "x$ac_cv_header_iodbcinst_h" = "xyes"
then

  odbc_headers="$odbc_headers iodbcinst.h"
	save_LIBS="$LIBS"
	LIBS="-L$2 $LIBS"

	AC_CHECK_LIB(iodbcadm,_iodbcdm_admin_dialbox,
	[LIBS="$LIBS -liodbcadm"
	have_iodbcadm=yes],
	[LIBS="$save_LIBS"])

	AC_CHECK_LIB(iodbcinst,SQLGetPrivateProfileString,
	[AC_DEFINE(HAVE_SQLGETPRIVATEPROFILESTRING,1,[Define if SQLGetPrivateProfileString is defined])
	LIBS="$LIBS -liodbcinst"
	have_iodbcinst=yes],
	[LIBS="$save_LIBS"])
fi
])


dnl ---------------------------------------------------------
dnl
dnl Macro: 
dnl     AC_CHECK_UNIXODBC
dnl
dnl Arguments:
dnl	$1=includedir
dnl	$2=libdir
dnl
dnl Description:
dnl     Check for unixODBC. If found configure for it.
dnl
dnl ---------------------------------------------------------

AC_DEFUN(AC_CHECK_UNIXODBC,
[
CPPFLAGS="$CPPFLAGS $ODBC_FLAGS -I$1"
AC_CHECK_HEADERS([sql.h sqlext.h sqltypes.h],
[unixODBC_ok=yes;odbc_headers="$odbc_headers $ac_hdr"],[unixODBC_ok=no; break])

if test "x$unixODBC_ok" != "xyes"
then
	AC_MSG_ERROR([Unable to find the unixODBC headers in '$1'])
fi

# new autoconf tools doesn't detect through ac_hdr, so define
# odbc_headers manually to make AC_CHECK_ODBC_TYPE to work
if test "x$odbc_headers" = "x   "
then
  odbc_headers="sql.h sqlext.h sqltypes.h"
fi

AC_CHECK_HEADERS(odbcinst.h)

if test "x$ac_cv_header_odbcinst_h" = "xyes"
then

  odbc_headers="$odbc_headers odbcinst.h"
	save_LIBS="$LIBS"
	LIBS="-L$2 $LIBS"

  AC_CHECK_LIB(odbcinst,SQLGetPrivateProfileString,
  [AC_DEFINE(HAVE_SQLGETPRIVATEPROFILESTRING,1,[Define if SQLGetPrivateProfileString is defined])
  LIBS="$LIBS -lodbcinst"
  have_odbcinst=yes],
  [LIBS="$save_LIBS"])
fi   
])

dnl ---------------------------------------------------------
dnl
dnl Macro: 
dnl     AC_QT_TEXT
dnl
dnl Arguments:
dnl     none
dnl
dnl Description:
dnl     Allows user to tell us where qt is by providing
dnl     configure options.
dnl
dnl ---------------------------------------------------------

AC_DEFUN(AC_QT_TEXT,
[
ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO
qt_libraries=""
qt_includes=""
AC_ARG_WITH(qt-dir,
    [  --with-qt-dir=DIR       where the root of Qt is installed ],
    [  ac_qt_includes="$withval"/include
       ac_qt_libraries="$withval"/lib
       ac_qt_bindir="$withval"/bin
    ])

AC_ARG_WITH(qt-includes,
    [  --with-qt-includes=DIR  where the Qt includes are. ],
    [  ac_qt_includes="$withval" ]
    )

AC_ARG_WITH(qt-libraries,
    [  --with-qt-libraries=DIR where the Qt library is installed.],
    [  ac_qt_libraries="$withval"]
    )

AC_ARG_WITH(qt-bin,
    [  --with-qt-bin=DIR       where the Qt binaries are installed.],
    [  ac_qt_bindir="$withval"]
    )
])

dnl ---------------------------------------------------------
dnl
dnl Macro: 
dnl     QT_PROGRAM
dnl
dnl Arguments:
dnl     none
dnl
dnl Description:
dnl     Provides a small program to test qt config options.
dnl
dnl ---------------------------------------------------------

AC_DEFUN(QT_PROGRAM,
[
cat > conftest.$ac_ext <<EOF
#include <qapplication.h>
#include <qstringlist.h>

int main() 
{
    QStringList *t = new QStringList();
    return 0;
}
EOF
])

dnl ---------------------------------------------------------
dnl 
dnl Macro: 
dnl     AC_PATH_QT_WITHOUT_X
dnl
dnl Arguments:
dnl     none
dnl
dnl Description:
dnl     Check for qt. If found configure for it.
dnl
dnl ---------------------------------------------------------

AC_DEFUN(AC_PATH_QT_WITHOUT_X,
[
AC_REQUIRE([AC_QT_TEXT])
LIBQT=""
LIBQTEXACT="-lqt"
AC_MSG_CHECKING([for Qt])

AC_CACHE_VAL(ac_cv_have_qt, 
[#try to guess Qt locations

qt_incdirs="$QTINC /usr/lib/qt/include /usr/local/qt/include /usr/include/qt /usr/include $x_includes /usr/include/qt3"
test -n "$QTDIR" && qt_incdirs="$QTDIR/include $QTDIR $qt_incdirs"
qt_incdirs="$ac_qt_includes $qt_incdirs"
AC_FIND_FILE(qmovie.h, $qt_incdirs, qt_incdir)
ac_qt_includes="$qt_incdir"

qt_libdirs="$QTLIB /usr/lib/qt/lib /usr/lib /usr/local/qt/lib /usr/lib/qt $x_libraries"
test -n "$QTDIR" && qt_libdirs="$QTDIR/lib $QTDIR $qt_libdirs"
if test ! "$ac_qt_libraries" = "NO"; then
  qt_libdirs="$ac_qt_libraries $qt_libdirs"
fi

test=NONE
qt_libdir=NONE

dnl
dnl The static lib names are hard-coded because the "eval ls" thing
dnl was not working properly on OSX. Subsequently; qt built as shared
dnl will not work unless this is modified.
dnl
for dir in $qt_libdirs; do
  if [[ -e $dir/libqt-mt.a ]]; then
    qt_libdir=$dir;
    LIBQTEXACT="-lqt-mt"
    break;
  else
    if [[ -e $dir/libqt.a ]]; then
      qt_libdir=$dir;
      LIBQTEXACT="-lqt"
      break;
    else
      echo "tried $dir" ;
    fi
    echo "tried $dir" ;
  fi
done

dnl
dnl We toss in our alternative link dependencies assuming we are dealing with
dnl OSX and no X.
dnl
LIBQT="$LIBQTEXACT -framework Carbon -framework QuickTime -framework OpenGL -framework AGL"

ac_qt_libraries="$qt_libdir"

AC_LANG_SAVE
AC_LANG_CPLUSPLUS

ac_cxxflags_safe="$CXXFLAGS"
ac_ldflags_safe="$LDFLAGS"
ac_libs_safe="$LIBS"

CXXFLAGS="$CXXFLAGS -I$qt_incdir $all_includes"
dnl LDFLAGS="-L$qt_libdir $all_libraries"
LDFLAGS="-L$qt_libdir"
LIBS="$LIBS $LIBQT"

QT_PROGRAM

if AC_TRY_EVAL(ac_link) && test -s conftest; then
  rm -f conftest*
else
  echo "configure: failed program was:" >&AC_FD_CC
  cat conftest.$ac_ext >&AC_FD_CC
  ac_qt_libraries="NO"
fi
rm -f conftest*
CXXFLAGS="$ac_cxxflags_safe"
LDFLAGS="$ac_ldflags_safe"
LIBS="$ac_libs_safe"

AC_LANG_RESTORE
if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
  ac_cv_have_qt="have_qt=no"
  ac_qt_notfound=""
  if test "$ac_qt_includes" = NO; then
    if test "$ac_qt_libraries" = NO; then
      ac_qt_notfound="(headers and libraries)";
    else
      ac_qt_notfound="(headers)";
    fi
  else
    ac_qt_notfound="(libraries)";
  fi
  have_qt="no"
else
  have_qt="yes"
fi
])

eval "$ac_cv_have_qt"

if test "$have_qt" != yes; then
  AC_MSG_RESULT([$have_qt]);
else
  ac_cv_have_qt="have_qt=yes \
    ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries"
  AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes])

  qt_libraries="$ac_qt_libraries"
  qt_includes="$ac_qt_includes"
fi

AC_SUBST(qt_libraries)
AC_SUBST(qt_includes)

if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
 QT_INCLUDES="";
else
 QT_INCLUDES="-I$qt_includes"
 all_includes="$QT_INCLUDES $all_includes"
fi

if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then
 QT_LDFLAGS=""
else
 QT_LDFLAGS="-L$qt_libraries -framework Carbon -framework QuickTime -framework OpenGL -framework AGL"
 all_libraries="$QT_LDFLAGS $all_libraries"
fi

AC_SUBST(QT_INCLUDES)
AC_SUBST(QT_LDFLAGS)
AC_PATH_QT_MOC

LIB_QT='$(LIBPNG)'
LIB_QT="$LIBQTEXACT $LIB_QT"
AC_SUBST(LIB_QT)

])

dnl ---------------------------------------------------------
dnl
dnl Macro: 
dnl     AC_PATH_QT_WITH_X
dnl
dnl Arguments:
dnl     none
dnl
dnl Description:
dnl     Check for qt. If found configure for it.
dnl
dnl ---------------------------------------------------------

AC_DEFUN(AC_PATH_QT_WITH_X,
[
AC_REQUIRE([AC_QT_TEXT])
LIBQT=""
LIBQTEXACT="-lqt"
AC_MSG_CHECKING([for Qt])

LIBQT="$LIBQT $EXTRA_XLIBS -lXext -lX11 $LIBSOCKET"

AC_CACHE_VAL(ac_cv_have_qt,
[#try to guess Qt locations

qt_incdirs="$QTINC /usr/lib/qt/include /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt $x_includes /usr/include/qt3"
test -n "$QTDIR" && qt_incdirs="$QTDIR/include $QTDIR $qt_incdirs"
qt_incdirs="$ac_qt_includes $qt_incdirs"
AC_FIND_FILE(qmovie.h, $qt_incdirs, qt_incdir)
ac_qt_includes="$qt_incdir"

qt_libdirs="$QTLIB /usr/lib/qt/lib /usr/X11R6/lib /usr/lib /usr/local/qt/lib /usr/lib/qt $x_libraries"
test -n "$QTDIR" && qt_libdirs="$QTDIR/lib $QTDIR $qt_libdirs"
if test ! "$ac_qt_libraries" = "NO"; then
  qt_libdirs="$ac_qt_libraries $qt_libdirs"
fi

test=NONE
qt_libdir=NONE
for dir in $qt_libdirs; do
  try="ls -1 $dir/libqt-mt*"
  if test=`eval $try 2> /dev/null`; then
    qt_libdir=$dir;
    LIBQTEXACT="-lqt-mt"
    break;
  else
    try="ls -1 $dir/libqt*"
    if test=`eval $try 2> /dev/null`; then
      qt_libdir=$dir;
      break;
    else
      echo "tried $dir" >&AC_FD_CC ; fi
    echo "tried $dir" >&AC_FD_CC ; fi
done

LIBQT="$LIBQTEXACT $EXTRA_XLIBS -lXext -lX11 $LIBSOCKET"

ac_qt_libraries="$qt_libdir"

AC_LANG_SAVE
AC_LANG_CPLUSPLUS

ac_cxxflags_safe="$CXXFLAGS"
ac_ldflags_safe="$LDFLAGS"
ac_libs_safe="$LIBS"

CXXFLAGS="$CXXFLAGS -I$qt_incdir $all_includes"
LDFLAGS="-L$qt_libdir $all_libraries"
LIBS="$LIBS $LIBQT"

QT_PROGRAM

if AC_TRY_EVAL(ac_link) && test -s conftest; then
  rm -f conftest*
else
  echo "configure: failed program was:" >&AC_FD_CC
  cat conftest.$ac_ext >&AC_FD_CC
  ac_qt_libraries="NO"
fi
rm -f conftest*
CXXFLAGS="$ac_cxxflags_safe"
LDFLAGS="$ac_ldflags_safe"
LIBS="$ac_libs_safe"

AC_LANG_RESTORE
if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
  ac_cv_have_qt="have_qt=no"
  ac_qt_notfound=""
  if test "$ac_qt_includes" = NO; then
    if test "$ac_qt_libraries" = NO; then
      ac_qt_notfound="(headers and libraries)";
    else
      ac_qt_notfound="(headers)";
    fi
  else
    ac_qt_notfound="(libraries)";
  fi
  have_qt="no"
else
  have_qt="yes"
fi
])

eval "$ac_cv_have_qt"

if test "$have_qt" != yes; then
  AC_MSG_RESULT([$have_qt]);
else
  ac_cv_have_qt="have_qt=yes \
    ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries"
  AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes])

  qt_libraries="$ac_qt_libraries"
  qt_includes="$ac_qt_includes"
fi

AC_SUBST(qt_libraries)
AC_SUBST(qt_includes)

if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
 QT_INCLUDES="";
else
 QT_INCLUDES="-I$qt_includes"
 all_includes="$QT_INCLUDES $all_includes"
fi

if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then
 QT_LDFLAGS=""
else
 QT_LDFLAGS="-L$qt_libraries"
 all_libraries="$QT_LDFLAGS $all_libraries"
fi

AC_SUBST(QT_INCLUDES)
AC_SUBST(QT_LDFLAGS)
AC_PATH_QT_MOC

LIB_QT='$(LIBPNG) -lXext $(LIB_X11)'
LIB_QT="$LIBQTEXACT $LIB_QT"
AC_SUBST(LIB_QT)

])

dnl ---------------------------------------------------------
dnl
dnl Macro:
dnl     AC_PATH_QT_MOC
dnl
dnl Arguments:
dnl     none
dnl
dnl Description:
dnl     Determine the complete path to the qt moc precompiler.
dnl
dnl ---------------------------------------------------------

AC_DEFUN(AC_PATH_QT_MOC,
[
   AC_FIND_FILE(moc, [$ac_qt_bindir $QTDIR/bin $QTDIR/src/moc /usr/bin /usr/X11R6/bin /usr/lib/qt/bin /usr/local/qt/bin], MOC)

   if test -z "$MOC"; then
      MOC="$MOC/moc"
   else
      MOC="moc"
   fi

   AC_SUBST(MOC)
])