File: acinclude.m4

package info (click to toggle)
myodbc 3.51.09-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,400 kB
  • ctags: 1,596
  • sloc: ansic: 29,806; sh: 10,765; cpp: 627; makefile: 610
file content (124 lines) | stat: -rw-r--r-- 2,802 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
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,
[
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 Macro: AC_CHECK_IODBC
dnl Required arguments: $1=includedir, $2=libdir
dnl Sets have_iodbcinst=yes if inst library is found
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 Macro: AC_CHECK_UNIXODBC
dnl Required arguments:
dnl	$1=includedir
dnl	$2=libdir
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   
])