File: configure.ac

package info (click to toggle)
freetds 0.82-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 10,716 kB
  • ctags: 8,697
  • sloc: ansic: 74,312; sh: 8,868; makefile: 815; perl: 556; php: 22
file content (770 lines) | stat: -rw-r--r-- 24,578 bytes parent folder | download | duplicates (2)
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
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
dnl Process this file with autoconf to produce a configure script.

dnl ------------------------------------------------------------
dnl $Id: configure.ac,v 1.29.2.11 2008/05/07 22:57:52 jklowden Exp $
dnl If you're trying to create a new configure test, try
dnl
dnl 	http://autogen.sourceforge.net/conftest.html
dnl	http://autoconf-archive.cryp.to/
dnl
dnl ------------------------------------------------------------

# ------------------------------------------------------------
# Initialization
# ------------------------------------------------------------
AC_INIT(FreeTDS, 0.82)
AC_CONFIG_SRCDIR(src/dblib/dblib.c)
AC_PREREQ(2.53)
AC_REVISION($Revision: 1.29.2.11 $)

AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS(include/config.h)

dnl configuration directory will be /usr/local/etc
AC_PREFIX_DEFAULT(/usr/local)

MAJOR=$(echo $VERSION | sed 's,\..*,,g')
MINOR=[$(echo $VERSION | sed 's,^[0-9]*\.\([0-9]*\).*,\1,g')]
SUBVERSION=[$(echo $VERSION.0 | sed 's,^\([0-9]*\.[0-9]*\)\(rc\|RC\),\1.dev.,g; s,^[0-9]*\.[^.]*\.\([^.]*\).*,\1,g')]
BUILD_NUMBER=$(date +"%y%j" | sed 's,^0*,,g')
if test "X$SUBVERSION" = "Xdev"; then
	MINOR=$(expr $MINOR - 1)
	SUBVERSION=9999
fi
AC_SUBST(MAJOR)
AC_SUBST(MINOR)
AC_SUBST(SUBVERSION)
AC_SUBST(BUILD_NUMBER)

# ------------------------------------------------------------
# Host-specific configuration
# ------------------------------------------------------------
AC_CANONICAL_HOST
netdb_reentrant=no
case $host in
  *-*-osf*)
    CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_POSIX_C_SOURCE=199506L"
    netdb_reentrant=yes
    ;;
  *-*-hpux11*)
    netdb_reentrant=yes
    ;;
  *-*-cygwin*)
    netdb_reentrant=yes
    ;;
esac

case $host_os in
  darwin* | rhapsody*)
    AM_CONDITIONAL(MACOSX, true)
    ;;
  *)
    AM_CONDITIONAL(MACOSX, false)
    ;;
esac

if test $netdb_reentrant = yes; then 
    AC_DEFINE(NETDB_REENTRANT, 1, [Define to 1 if the BSD-style netdb interface is reentrant.])
fi

AC_GNU_SOURCE
AC_SYS_LARGEFILE

# ------------------------------------------------------------
# Flag to include library-private definitions
# ------------------------------------------------------------
CPPFLAGS="$CPPFLAGS -D_FREETDS_LIBRARY_SOURCE"

# ------------------------------------------------------------
# Checks for programs.
# ------------------------------------------------------------
AC_PROG_CC
AC_PROG_CPP
AM_PROG_CC_C_O

dnl Disable libtool 1.5 support for languages we don't use
dnl (cfr http://lists.gnu.org/archive/html/libtool/2005-08/msg00137.html)
define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl
define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
define([AC_LIBTOOL_LANG_GCJ_CONFIG], [:])dnl

AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
LT_AC_PROG_RC

AC_ARG_ENABLE(libiconv,
	AS_HELP_STRING([--disable-libiconv], [do not attempt to include libiconv]),
	[use_libiconv=$enableval], [use_libiconv=yes])
  
if test "$use_libiconv" = "yes" ; then
	AM_ICONV
else 
	AC_MSG_NOTICE(libiconv disabled)	
fi


# See if we have doxygen installed
AC_CHECK_PROG(DOXYGEN,doxygen,doxygen)
AC_CHECK_PROG(ODBC_CONFIG,odbc_config,odbc_config)
AM_CONDITIONAL(HAVE_DOXYGEN, [test -n "$DOXYGEN"])

# ------------------------------------------------------------
# Check for CVS-only sources.
# ------------------------------------------------------------
#
# Distribution tarballs include some generated files.  These
# files are not maintained in CVS, but their bases are, and 
# the bases are not in the tarball.  For example, num_limits.h
# is distributed, but it is generated from numeric.pl, which
# is kept in CVS.  
# If the base is found, we use it as a source in the Makefile, 
# otherwise the Makefile will (correctly) assume that the
# generated file is already present.  
#
if test -f "${srcdir}/src/tds/num_limits.pl"; then
	AM_CONDITIONAL(HAVE_PERL_SOURCES, true)
else
	AM_CONDITIONAL(HAVE_PERL_SOURCES, false)
fi
AC_SUBST(HAVE_PERL_SOURCES)


# ------------------------------------------------------------
# Checks for libraries.
# ------------------------------------------------------------
AC_ARG_ENABLE(krb5,
  AS_HELP_STRING([--enable-krb5], [enable Kerberos support (EXPERIMENTAL)]))

OLDLIBS="$LIBS"
LIBS=""
tds_mingw=no
case $host in
*-*-mingw*)
	tds_mingw=yes
	if test "$host_cpu" = "x86_64"; then
		LIBS="-lws2_32"
	elif test -r /usr/lib/w32api/libwsock32.a; then
		LIBS="-L/usr/lib/w32api -lwsock32"
	else
		LIBS="-lwsock32"
	fi
	AM_CONDITIONAL(MINGW32, true)
	;;
*-*-hpux*)
	# these lines are needed to fix a problem for HP-UX
	# HP-UX define two versions of sockets, one BSD and one X/Open
	# these versions are not binary compatible (BSD use int where X/Open 
	# use socklen_t == size_t) and different libraries (BSD in libc and
	# X/Open in libxnet). X/Open is used if _XOPEN_SOURCE and 
	# _XOPEN_SOURCE_EXTENDED are defined. To complicate the things gcc
	# by default define _XOPEN_SOURCE_EXTENDED so define always both
	# constants and link always libxnet!
	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"
	LIBS="$LIBS -lxnet"
	AC_SEARCH_LIBS(gethostbyname, nsl)
	if test "$enable_krb5" = "yes" ; then
		AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gssapi])
		if test "$ac_cv_search_gss_init_sec_context" != no; then
			AC_DEFINE(ENABLE_KRB5, 1, [Defined if --enable-krb5 used and library detected])
		fi
	fi

	AM_CONDITIONAL(MINGW32, false)
	;;
*)
	AC_SEARCH_LIBS(socket, socket)
	AC_SEARCH_LIBS(gethostbyname, nsl)
	if test "$enable_krb5" = "yes" ; then
		AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gssapi])
		if test "$ac_cv_search_gss_init_sec_context" != no; then
			AC_DEFINE(ENABLE_KRB5, 1, [Defined if --enable-krb5 used and library detected])
		fi
	fi

	AM_CONDITIONAL(MINGW32, false)
	;;
esac
NETWORK_LIBS="$LIBS"
LIBS="$OLDLIBS"
AC_SUBST(NETWORK_LIBS)

if test $tds_mingw = no; then
	# readline test
	# Readline is needed by the tty session. Set up a special READLINE_LIBS
	# substitution for it.
	OLDLIBS="$LIBS"
	# Readline is linked with curses, and on some systems termcap must be
	# linked in. Others (inc debian) have termcap built into ncurses.
	LIBS=""
	AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap])
	AC_CHECK_LIB([readline], [readline], [LIBS="$LIBS -lreadline"
	  AC_DEFINE(HAVE_READLINE, 1, [Define to 1 if you have the GNU Readline library.])], [LIBS=""] )
	AC_CHECK_FUNCS([rl_on_new_line rl_reset_line_state])
	AC_LINK_IFELSE([AC_LANG_SOURCE([[

#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif

#ifdef HAVE_READLINE
#include <readline/readline.h>
#include <readline/history.h>
#endif /* HAVE_READLINE */

int main()
{
	rl_inhibit_completion = 1;
	return 0;
}
]])],AC_DEFINE(HAVE_RL_INHIBIT_COMPLETION, 1, [Define to 1 if you have rl_inhibit_completion.]))
	READLINE_LIBS="$LIBS"
	LIBS="$OLDLIBS"
	AC_SUBST(READLINE_LIBS)

	ACX_PTHREAD
	AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
	AC_SUBST(AM_CFLAGS)
	LIBS="$PTHREAD_LIBS $LIBS"
fi


# ------------------------------------------------------------
# Checks for header files.
# ------------------------------------------------------------
AC_HEADER_STDC
AC_HEADER_TIME
AC_STRUCT_TIMEZONE
AC_CHECK_MEMBERS([struct tm.__tm_zone],,,[#include <sys/types.h>
#include <$ac_cv_struct_tm>
])
AC_CHECK_HEADERS([unistd.h errno.h wchar.h sys/time.h sys/types.h \
sys/param.h sys/stat.h sys/wait.h limits.h locale.h odbcss.h readpassphrase.h \
signal.h libgen.h poll.h])
if test $tds_mingw = no; then
	AC_CHECK_HEADERS([sys/socket.h arpa/inet.h netdb.h netinet/in.h \
netinet/tcp.h paths.h sys/ioctl.h langinfo.h])
fi
AC_HAVE_INADDR_NONE

# ------------------------------------------------------------
# Checks for integers/floats of different sizes
# ------------------------------------------------------------
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)
AC_CHECK_SIZEOF(long double)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(__int64)
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(wchar_t,,[$ac_includes_default
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif])

case 2 in
$ac_cv_sizeof_short)   tds_sysdep_int16_type=short;;
$ac_cv_sizeof_int)     tds_sysdep_int16_type=int;;
*)                     AC_MSG_ERROR(No 16-bit int found.)
esac

case 4 in
$ac_cv_sizeof_short)   tds_sysdep_int32_type=short;;
$ac_cv_sizeof_int)     tds_sysdep_int32_type=int;;
$ac_cv_sizeof_long)    tds_sysdep_int32_type=long;;
*)                     AC_MSG_ERROR(No 32-bit int found.)
esac

case 4 in
$ac_cv_sizeof_float)       tds_sysdep_real32_type=float;;
$ac_cv_sizeof_double)      tds_sysdep_real32_type=double;;
$ac_cv_sizeof_long_double) tds_sysdep_real32_type="long double";;
*)                     AC_MSG_ERROR(No 32-bit real found.)
esac

case 8 in
$ac_cv_sizeof_float)       tds_sysdep_real64_type=float;;
$ac_cv_sizeof_double)      tds_sysdep_real64_type=double;;
$ac_cv_sizeof_long_double) tds_sysdep_real64_type="long double";;
*)                     AC_MSG_ERROR(No 64-bit real found.)
esac

case 8 in
$ac_cv_sizeof_long)      tds_sysdep_int64_type=long;;
$ac_cv_sizeof_long_long) tds_sysdep_int64_type="long long";;
$ac_cv_sizeof___int64)   tds_sysdep_int64_type=__int64;;
esac
if test "$tds_sysdep_int64_type"; then
    AC_DEFINE(HAVE_INT64, 1, [Define to 1 if you have a 64-bit integral type.])
    SPRINTF_I64_FORMAT
else
    tds_sysdep_int64_type=long
    AC_MSG_WARN([SQL Server 2000 "bigint" 8-byte integer will not work])
fi

case $ac_cv_sizeof_void_p in
$ac_cv_sizeof_short)     tds_sysdep_intptr_type=short;;
$ac_cv_sizeof_int)       tds_sysdep_intptr_type=int;;
$ac_cv_sizeof_long)      tds_sysdep_intptr_type=long;;
$ac_cv_sizeof_long_long) tds_sysdep_intptr_type="long long";;
$ac_cv_sizeof___int64)   tds_sysdep_intptr_type=__int64;;
*)                     AC_MSG_ERROR(No intptr type found.)
esac

AC_SUBST(tds_sysdep_int16_type)
AC_SUBST(tds_sysdep_int32_type)
AC_SUBST(tds_sysdep_real32_type)
AC_SUBST(tds_sysdep_real64_type)
AC_SUBST(tds_sysdep_int64_type)
AC_SUBST(tds_sysdep_intptr_type)

# ------------------------------------------------------------
# Checks for typedefs and structures
# ------------------------------------------------------------

# ---- Solaris needs -DBSD_COMP to get FIONBIO defined ----
AC_MSG_CHECKING(is FIONBIO defined)
AC_EGREP_CPP(yes,
[#include <sys/ioctl.h>
#ifdef FIONBIO
 yes
#endif
],
    AC_MSG_RESULT(yes),
    [ AC_EGREP_CPP(yes,
[#define BSD_COMP
#include <sys/ioctl.h>
#ifdef FIONBIO
 yes
#endif
],
    AC_DEFINE(BSD_COMP, 1, [Define to 1 if you need BSD_COMP defined to get FIONBIO defined.]) AC_MSG_RESULT(need -DBSD_COMP),
    AC_MSG_RESULT(no))
    ])

TYPE_SOCKLEN_T

# ------------------------------------------------------------
# Checks for compiler characteristics.
# ------------------------------------------------------------
AC_C_BIGENDIAN
AC_C_CONST

case $host_os in
mingw*)
	FREETDS_SYMBOLIC="-no-undefined"
	;;
hpux* | linux* | solaris*)
AC_MSG_CHECKING([whether we can use -Wl,-Bsymbolic])
AC_LANG_CONFTEST([AC_LANG_PROGRAM([], [return 1])])
rm -f conftest.$ac_objext
CMD="$SHELL $(test -n "$ac_top_builddir" && echo $ac_top_builddir || echo .)/libtool --mode=link $CC -o libtest.la conftest.$ac_ext >/dev/null 2>&1"
if eval $CMD && test -s libtest.la; then
AC_MSG_RESULT(yes)
FREETDS_SYMBOLIC="-Wl,-Bsymbolic"
else
AC_MSG_RESULT(no)
fi
rm -f conftest.$ac_objext conftest.$ac_ext libtest.la
rm -rf .libs
;;
esac
AC_SUBST(FREETDS_SYMBOLIC)

# if GNU compiler but no GNU linker add explicitly libgcc
# this is required for Solaris for example
if test "$GCC" = yes; then
	for freetds_ldflag in "-static-libgcc" "-Wl,-static-libgcc"; do
		AC_MSG_CHECKING([whether we can use $freetds_ldflag])
		saved_LDFLAGS=$LDFLAGS
		LDFLAGS="$LDFLAGS $freetds_ldflag"
		AC_LINK_IFELSE(AC_LANG_SOURCE(,[return 1]), ac_cv_use_freetds_flag="yes", ac_cv_use_freetds_flag="no")
		LDFLAGS=$saved_LDFLAGS
		AC_MSG_RESULT($ac_cv_use_freetds_flag)
		if test "$ac_cv_use_freetds_flag" = "yes"; then
			FREETDS_LIBGCC="$freetds_ldflag"
			break;
		fi
	done
	AC_COMPILE_IFELSE(AC_LANG_SOURCE([static void __attribute__((destructor)) my_uninit(void) {}], []), 
			  AC_DEFINE(TDS_ATTRIBUTE_DESTRUCTOR, 1, 
				    [Define to 1 if your compiler supports __attribute__((destructor)).]))
fi
AC_SUBST(FREETDS_LIBGCC)

TDS_NULL_IS_ZERO

# ------------------------------------------------------------
# Checks for library functions.
# ------------------------------------------------------------
AC_CHECK_FUNCS([vsnprintf _vsnprintf gettimeofday \
nl_langinfo locale_charset setenv putenv \
getuid getpwuid getpwuid_r fstat alarm fork \
gethrtime localtime_r setitimer])
OLD_LIBS="$LIBS"
LIBS="$LIBS $NETWORK_LIBS"
AC_CHECK_FUNCS([inet_ntoa_r getipnodebyaddr getipnodebyname \
getaddrinfo getnameinfo inet_ntop gethostname poll])
LIBS="$OLD_LIBS"
AC_REPLACE_FUNCS([asprintf vasprintf atoll strtok_r readpassphrase \
strlcpy strlcat basename])
AC_FUNC_FSEEKO
TDS_GETTIMEMILLI

# ------------------------------------------------------------
# Checks for library variables.
# ------------------------------------------------------------
AC_HAVE_MALLOC_OPTIONS

# ------------------------------------------------------------
# Compile time options
# ------------------------------------------------------------
AC_MSG_RESULT(checking compile-time options)

AC_ARG_WITH(tdsver,
AS_HELP_STRING([--with-tdsver=VERSION], [TDS protocol version (4.2/4.6/5.0/7.0/8.0) [5.0]]))
if test "$with_tdsver" = "4.2"; then
	AC_DEFINE(TDS42, 1, [Define to use TDS 4.2 by default])
elif test "$with_tdsver" = "4.6"; then
	AC_DEFINE(TDS46, 1, [Define to use TDS 4.6 by default])
elif test "$with_tdsver" = "7.0"; then
	AC_DEFINE(TDS70, 1, [Define to use TDS 7.0 by default])
elif test "$with_tdsver" = "8.0"; then
	AC_DEFINE(TDS80, 1, [Define to use TDS 8.0 by default])
else
	AC_DEFINE(TDS50, 1, [Define to use TDS 5.0 by default])
fi

AC_ARG_WITH(iodbc,
AS_HELP_STRING([--with-iodbc=DIR], [build odbc driver against iODBC in DIR]))
if test "$with_iodbc"; then
	if echo "$with_iodbc" | grep -v '^/'; then
		with_iodbc="$PWD/$with_iodbc"
	fi
	CPPFLAGS="$CPPFLAGS -DIODBC"
	ODBC_INC="$with_iodbc/include"
	test -r "$ODBC_INC/isql.h" || AC_ERROR([isql.h not found])
	test -r "$ODBC_INC/isqlext.h" || AC_ERROR([isqlext.h not found])
	ODBC_INC="-I$ODBC_INC"
	LDFLAGS="$LDFLAGS -L$with_iodbc/lib"
	ODBCLIB="-liodbc"
	odbc=true
	iodbc=true
fi

AC_ARG_WITH(unixodbc,
AS_HELP_STRING([--with-unixodbc=DIR], [build odbc driver against unixODBC in DIR]))
if test "$with_unixodbc"; then
	if echo "$with_unixodbc" | grep -v '^/'; then
		with_unixodbc="$PWD/$with_unixodbc"
	fi
	CPPFLAGS="$CPPFLAGS -DUNIXODBC"
	if test -f "$with_unixodbc/bin/odbc_config"; then
		ODBC_CONFIG="$with_unixodbc/bin/odbc_config"
		ODBC_INC=`$ODBC_CONFIG --include-prefix`
		LDFLAGS="$LDFLAGS -L`$ODBC_CONFIG --lib-prefix`"
	else
		# if not available do not use system default
		ODBC_CONFIG=""
		ODBC_INC="$with_unixodbc/include"
		LDFLAGS="$LDFLAGS -L$with_unixodbc/lib"
	fi
	test -r "$ODBC_INC/sql.h" || AC_ERROR([sql.h not found])
	test -r "$ODBC_INC/sqlext.h" || AC_ERROR([sqlext.h not found])
	ODBC_INC="-I$ODBC_INC"
	ODBCLIB="-lodbc"
	odbc=true
	unixodbc=true
fi

AC_ARG_WITH(odbc_nodm,
AS_HELP_STRING([--with-odbc-nodm=DIR], [build odbc without driver manager (headers in DIR)]))
if test "$with_odbc_nodm"; then
	if echo "$with_odbc_nodm" | grep -v '^/'; then
		with_odbc_nodm="$PWD/$with_odbc_nodm"
	fi
	CPPFLAGS="$CPPFLAGS -DTDS_NO_DM"
	ODBC_INC="$with_odbc_nodm/include"
	test -r "$ODBC_INC/sql.h" || AC_ERROR([sql.h not found])
	test -r "$ODBC_INC/sqlext.h" || AC_ERROR([sqlext.h not found])
	ODBC_INC="-I$ODBC_INC"
	# The next line is for linking the unittests. Here the ODBC driver
	#  itself is treated as the driver manager to be linked.
	# Can't use ODBCLIB/LDFLAGS variables since they are used in building
	#  other directories.
	ODBCNODMLIB="-L.. -ltdsodbc"
	ODBCNODMLIBAPP="-L../odbc -ltdsodbc"
	odbc=true
fi

build_odbc=yes
if test "$odbc" != "true"; then
AC_ARG_ENABLE(odbc,
	AS_HELP_STRING([--disable-odbc], [do not attempt to build odbc the driver]),
	[build_odbc=$enableval], [build_odbc=yes])
fi
AM_CONDITIONAL(INCODBC, test "$build_odbc" = "yes")
  
if test "$build_odbc" = "yes"
then
	case $host_os in
	darwin* | rhapsody*)
		FREETDS_ODBC_MODULE="-module"
		;;
	esac
	AC_SUBST(FREETDS_ODBC_MODULE)

	# odbc not specified, try to detect it
	echo looking for installed odbc driver manager
	if test "$odbc" != "true" -a $tds_mingw = yes; then
		odbc=true
		unixodbc=true
		CPPFLAGS="$CPPFLAGS -DUNIXODBC"
		ODBCLIB="-lodbc32"
	elif test "$odbc" != "true"; then
		AC_CHECK_LIB(iodbc, SQLConnect, [AC_CHECK_HEADER([isql.h], [odbc=true
	iodbc=true
	CPPFLAGS="$CPPFLAGS -DIODBC"
	ODBCLIB="-liodbc"])], 
		[AC_CHECK_LIB(odbc, SQLConnect, [AC_CHECK_HEADER([sql.h], [odbc=true
	unixodbc=true
	CPPFLAGS="$CPPFLAGS -DUNIXODBC"
	ODBCLIB="-lodbc"])] )] )
	fi

	if test "$odbc" = "true"; then
		ODBCINSTLIB=
		if test $tds_mingw = yes; then
			ODBCINSTLIB="-lodbccp32"
		elif test "$unixodbc" = "true"; then
			if test -n "$ODBC_CONFIG"; then
				CPPFLAGS="$CPPFLAGS `$ODBC_CONFIG --cflags`"
			fi
			AC_CHECK_LIB(odbcinst, SQLGetPrivateProfileString, [ODBCINSTLIB="-lodbcinst"])
		elif test "$iodbc" = "true"; then
			AC_CHECK_LIB(iodbcinst, SQLGetPrivateProfileString, [ODBCINSTLIB="-liodbcinst"])
		fi
		if test "$ODBCINSTLIB" != ""; then
			AC_DEFINE_UNQUOTED(HAVE_SQLGETPRIVATEPROFILESTRING, 1, [Define to 1 if you have the SQLGetPrivateProfileString function.])
		fi
	fi
	if test "$iodbc" = "true"; then
		save_cppflags="$CPPFLAGS"
		CPPFLAGS="$CPPFLAGS $ODBC_INC"
		AC_CHECK_HEADERS(iodbcinst.h)
		CPPFLAGS="$save_cppflags"
	fi
	# test for SQLLEN (iODBC do not define but typedef it)
	save_cppflags="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $ODBC_INC"
	AC_TRY_COMPILE([#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__)
#include <windows.h>
#endif
#include <sql.h>], [SQLLEN len = 123;],
		AC_DEFINE(HAVE_SQLLEN, 1, [Define if sqltypes.h define SQLLEN])
		# check SQLColAttribute definition
		AC_TRY_COMPILE([#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__)
#include <windows.h>
#endif
#include <sql.h>
#include <sqlext.h>

SQLRETURN  SQL_API SQLColAttribute (SQLHSTMT StatementHandle,
	SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
	SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
	SQLSMALLINT *StringLength, SQLLEN * NumericAttribute) {
}], [return 0],
		AC_DEFINE(TDS_SQLCOLATTRIBUTE_SQLLEN, 1, [Define to 1 if last argument of SQLColAttribute it's SQLLEN *]))

		# check is SQLParamOptions accept SQLULEN
		AC_TRY_COMPILE([#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__)
#include <windows.h>
#endif
#include <sql.h>
#include <sqlext.h>

SQLRETURN SQL_API SQLParamOptions(SQLHSTMT       hstmt,
	SQLULEN crow, SQLULEN *pirow) {
	return SQL_SUCCESS;
}], [return 0],
		AC_DEFINE(TDS_SQLPARAMOPTIONS_SQLLEN, 1, [Define to 1 if SQLParamOptions accept SQLULEN as arguments]))
	)

	AC_CHECK_TYPES([SQLSETPOSIROW, SQLROWSETSIZE, SQLROWOFFSET],,, [#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__)
#include <windows.h>
#endif
#include <sql.h>
#include <sqlext.h>])

	# test for sizeof(SQLWCHAR)
	AC_CHECK_SIZEOF(SQLWCHAR,,[#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__)
#include <windows.h>
#endif
#include <sql.h>])

	CPPFLAGS="$save_cppflags"
else 
	AC_MSG_NOTICE(odbc disabled)	
fi

AM_CONDITIONAL(ODBC, test "$odbc" = "true")
AM_CONDITIONAL(UNIXODBC, test "$unixodbc" = "true")
AC_SUBST(ODBC)
AC_SUBST(ODBC_INC)
AC_SUBST(ODBCLIB)
AC_SUBST(ODBCINSTLIB)
AC_SUBST(ODBCNODMLIB)
AC_SUBST(ODBCNODMLIBAPP)

AC_ARG_WITH(gnutls,
AS_HELP_STRING([--with-gnutls], [build with TLS support]))
if test "$with_gnutls" = "yes"; then
	AC_DEFINE(HAVE_GNUTLS, 1, [Define to 1 if you have GNU tls.])
	CPPFLAGS="$CPPFLAGS `libgnutls-config --cflags`"
	NETWORK_LIBS="$NETWORK_LIBS `libgnutls-config --libs`"
else
	CHECK_OPENSSL
fi



AC_ARG_ENABLE(apps,
	AS_HELP_STRING([--disable-apps], [skip build of src/apps (including tsql)]))
AM_CONDITIONAL(INCAPPS, test "$enable_apps" != "no")

AC_ARG_ENABLE(server,
	AS_HELP_STRING([--disable-server], [skip build of src/server directory]))
AM_CONDITIONAL(INCSERVER, test "$enable_server" != "no")

AC_ARG_ENABLE(pool,
	AS_HELP_STRING([--disable-pool], [skip build of src/pool directory]))
 AM_CONDITIONAL(INCPOOL, test "$enable_pool" != "no")

AC_ARG_ENABLE(msdblib,
  AS_HELP_STRING([--enable-msdblib], [for MS style dblib]))

if test "$enable_msdblib" = "yes" ; then
	dblib_define="#define MSDBLIB 1"
else
	dblib_define="#define SYBDBLIB 1"
fi
AC_SUBST(dblib_define)

AC_ARG_ENABLE(sybase-compat,
  AS_HELP_STRING([--enable-sybase-compat], [enable increased Open Client binary compatibility]))
AM_CONDITIONAL(SYBASE_COMPAT, test x$enable_sybase_compat = xyes)
if test x$enable_sybase_compat = xyes; then
	AC_DEFINE(TDS_SYBASE_COMPAT, 1, [Defined if --enable-sybase-compat used])
fi

AC_MSG_CHECKING(threadsafety)
# Enable or disable thread safetiness
# This option is enabled by default because most OS's support it.   
# A more sophisticated approach would be to set the default per-OS.  
AC_ARG_ENABLE(threadsafe,
	AS_HELP_STRING([--disable-threadsafe], [disable calls to threadsafe fuctions e.g.,gethostbyname_r ]),
	[use_threadsafe=$enableval], [use_threadsafe=yes])

if test "$enable_threadsafe" != "no" ; then
	CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE"
	AC_MSG_RESULT(enabled)
else
	AC_DEFINE(TDS_NO_THREADSAFE, 1, [Define if you don't care about thread safety])
	AC_MSG_RESULT(disabled)
fi
AM_CONDITIONAL(ENABLE_THREADSAFE, test "$enable_threadsafe" != "no")

# we don't need to check netdb functions if they are already threadsafe
if test $netdb_reentrant != yes; then
	AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R
	AC_raf_FUNC_WHICH_GETSERVBYNAME_R
	AC_tds_FUNC_WHICH_GETHOSTBYADDR_R
fi
AC_tds_FUNC_WHICH_GETPWUID_R
AC_tds_FUNC_WHICH_LOCALTIME_R

# easy test for pthread (no library, only mutex support)
AC_TRY_LINK([#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;],
[pthread_mutex_lock(&mutex);
pthread_mutex_unlock(&mutex)], AC_DEFINE(TDS_HAVE_PTHREAD_MUTEX, 1, [Define if you have pthread with mutex support]))

AC_ARG_ENABLE(debug,
	AS_HELP_STRING([--disable-debug], [disable assert and other things]),
	[use_debug=$enableval], [use_debug=yes])
  
if test "$use_debug" = "yes" ; then
	AC_MSG_NOTICE(debug enabled)	
	CPPFLAGS="$CPPFLAGS -DDEBUG=1"

	AC_ARG_ENABLE(extra-checks,
	  AS_HELP_STRING([--enable-extra-checks], [enable extra checks on code]))
	if test "$enable_extra_checks" = "yes" ; then
		AC_DEFINE_UNQUOTED(ENABLE_EXTRA_CHECKS, 1, [Define to enable extra checks on code])
	fi
else
	AC_MSG_NOTICE(debug disabled)	
	CPPFLAGS="$CPPFLAGS -DNDEBUG=1"
fi

AC_ARG_ENABLE(developing,
  AS_HELP_STRING([--enable-developing], [enable code still in develop]))
if test "$enable_developing" = "yes" ; then
	AC_DEFINE_UNQUOTED(ENABLE_DEVELOPING, 1, [Define to enable work in progress code])
fi

AC_ARG_ENABLE(distcheck_build,
  AS_HELP_STRING([--enable-distcheck-build], [used internally for testing]))
if test "$enable_distcheck_build" = "yes" ; then
	AM_CONDITIONAL(DISTCHECK_BUILD, true)
else
	AM_CONDITIONAL(DISTCHECK_BUILD, false)
fi

# ------------------------------------------------------------
# LTLIBOBJS hack (for autoconf-2.53)
# ------------------------------------------------------------
# This is necessary so that .o files in LIBOBJS are also built via
# the ANSI2KNR-filtering rules.
LIB@&t@OBJS=`echo "$LIB@&t@OBJS" |
             sed 's,\.[[^.]]* ,$U&,g;s,\.[[^.]]*$,$U&,'`
LTLIBOBJS=`echo "$LIB@&t@OBJS" |
           sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
AC_SUBST(LTLIBOBJS)

# enable some warning for gcc
if test "$ac_compiler_gnu" = "yes" ; then
	CPPFLAGS="$CPPFLAGS -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long"
fi

AX_CFLAGS_GCC_OPTION([-Wdeclaration-after-statement])

AC_MSG_RESULT(done)
# ------------------------------------------------------------
# Final output
# ------------------------------------------------------------
AC_CONFIG_FILES(include/tdsver.h \
	include/tds_sysdep_public.h \
	Makefile \
	include/Makefile \
	doc/Makefile \
	samples/Makefile \
	src/Makefile \
		src/tds/Makefile src/tds/unittests/Makefile \
		src/dblib/Makefile src/dblib/unittests/Makefile \
		src/ctlib/Makefile src/ctlib/unittests/Makefile \
		src/replacements/Makefile \
	src/server/Makefile \
	src/pool/Makefile \
	src/odbc/Makefile \
	src/odbc/unittests/Makefile \
	src/apps/Makefile \
	src/apps/fisql/Makefile \
	freetds.spec \
	win32/Makefile win32/msvc6/Makefile win32/dev-cpp/Makefile \
	win32/version.rc win32/freetds.nsh
)
AC_OUTPUT