File: configure.in

package info (click to toggle)
myodbc 5.1.10-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, sid
  • size: 2,984 kB
  • ctags: 2,099
  • sloc: ansic: 33,649; cpp: 1,360; xml: 1,261; sh: 353; makefile: 264; perl: 43
file content (765 lines) | stat: -rw-r--r-- 25,315 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
# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
#
# The MySQL Connector/ODBC is licensed under the terms of the GPLv2
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most 
# MySQL Connectors. There are special exceptions to the terms and 
# conditions of the GPLv2 as it is applied to this software, see the 
# FLOSS License Exception
# <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
#
# This program is free software; you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published 
# by the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA


AC_INIT(driver/driver.c)
AC_PREREQ(2.12)dnl    Minimum Autoconf version required.
AC_CANONICAL_SYSTEM

# When changing, also change VersionInfo.h and driver/driver.def
AM_INIT_AUTOMAKE(mysql-connector-odbc, 5.1.10)

# Version but without "-alpha", "-beta", i.e. numeric part
NUMERIC_VERSION=`echo "$VERSION" | sed 's/-.*//'`

###################################################################
#                                                                 #
# See the libtool docs for information on how to do shared lib    #
# versions.                                                       #
#                                                                 #
###################################################################

SHARED_LIB_VERSION=1:0:0
AC_CONFIG_HEADERS(driver/myconf.h)
AC_SUBST(NUMERIC_VERSION)

# Canonicalize the configuration name.
SYSTEM_TYPE="$host_vendor-$host_os"
MACHINE_TYPE="$host_cpu"
AC_SUBST(SYSTEM_TYPE)
AC_SUBST(MACHINE_TYPE)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP

# Fix for sgi gcc / sgiCC which tries to emulate gcc
if test "$CC" = "sgicc"
then
  ac_cv_prog_gcc="no"
fi

# Only build shared libraries by default
AM_ENABLE_SHARED
AM_DISABLE_STATIC

# define _UNIX_, always true if running this configure script
AC_DEFINE(_UNIX_,1,[Define if we are using unix build environment])

AM_PROG_LIBTOOL
AC_CHECK_LIB(z,compress)

###################################################################
#
# Dynamic loading, only "libdl" is supported
#
###################################################################

LT_LIB_DLLOAD
DL_LIB="$LIBADD_DLOPEN"
AC_SUBST(DL_LIB)

###################################################################
#
# --enable-myodbc-installer
#
###################################################################
AC_ARG_ENABLE( myodbc-installer,
[AC_HELP_STRING([--enable-myodbc-installer],[Build myodbc installer command-line interface [default=yes]])],
[ case "${enableval}" in
    yes) myodbc_installer=true ;;
    no) myodbc_installer=false ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-myodbc-installer) ;;
    esac],[myodbc_installer=true])

AM_CONDITIONAL(MYODBCINST, test "x$myodbc_installer" = "xtrue" )

AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(LD)
AC_SUBST(INSTALL_SCRIPT)

export CC CFLAGS LD LDFLAGS

###################################################################
#                                                                 #
# Check if localtime_r exists in libc or not                      #
#                                                                 #
###################################################################

AC_CHECK_FUNCS(localtime_r)

###################################################################
#                                                                 #
# Check for the client libraries and compile options              #
# Options are taken from the output of mysql_config               #
#                                                                 #
###################################################################

AC_ARG_WITH(mysql-path,
            [  --with-mysql-path=DIR   Path where MySQL is installed],
            mysql_path=$withval,
            mysql_path="")

mysql_config=""
building_against_source=""
MYSQL_PATH_ARG=""

if test "$mysql_path" != ""
then
  MYSQL_PATH_ARG="--with-mysql-path=$mysql_path"
  if test -f $mysql_path/libmysql_r/libmysqlclient_r.la
  then
    building_against_source="true"
    CFLAGS="$CFLAGS -I$mysql_path/include"
    MYSQL_LIB="$mysql_path/libmysql_r/libmysqlclient_r.la"
  else
    mysql_config="$mysql_path/bin/mysql_config"
    if test ! -x $mysql_config
    then
      AC_MSG_ERROR([File $mysql_config doesn't exists or isn't executable.  Please specify with --with-mysql-path where bin/mysql_config can be found]);
    fi
  fi
else
  # Search where mysql_config is installed
  TEST_PATHS="/opt/mysql/mysql /usr/local/mysql /usr"
  for i in $TEST_PATHS
  do
    mysql_config="$i/bin/mysql_config"
    if test -x $mysql_config
    then
      MYSQL_PATH_ARG="--with-mysql-path=$TEST_PATHS"
      break;
    fi   
    mysql_config=""
  done

  if test "$mysql_config" = ""
  then
    AC_MSG_ERROR([Can't find mysql_config in $TEST_PATHS]);
  fi
fi

AC_SUBST(MYSQL_PATH_ARG)

if test "x$building_against_source" = x
then
  OPT=`$mysql_config --cflags`
  if test $? != "0"
  then
    AC_MSG_ERROR([Could not execute $mysql_config. Please check your installation])
  fi

  # We have to remove any ' around paths as this confuses configure
  OPT=`echo $OPT | sed -e "s;';;g"`
  CFLAGS="$OPT $CFLAGS"

  OPT=`$mysql_config --libs_r`
  if test $? != "0"
  then
    # mysql_config that is before 4.0.17
    # In this case assume we can use the same compile options for the
    # thread safe library as for the normal
    OPT=`$mysql_config --libs | sed -e 's;lmysqlclient;lmysqlclient_r;'`
  else
    OPT=`echo $OPT | sed -e "s;';;g"`
  fi
  MYSQL_LIB="$OPT"

  SAVE_LIBS=$LIBS
  LIBS="$LIBS $MYSQL_LIB"
  AC_CHECK_FUNC(mysql_real_query,[],
  [ AC_MSG_ERROR([Could not use the single thread MySQL client library, please check config.log for errors]) ])
  LIBS=$SAVE_LIBS
fi

AC_SUBST(MYSQL_LIB)

###################################################################
#                                                                 #
# Link driver against odbcinst library?                           #
#   If no, this builds the "dmless" driver.                       #
#                                                                 #
###################################################################

AC_MSG_CHECKING([if driver should be linked against odbcinst library])
AC_ARG_ENABLE(odbcinstlink,
  [AC_HELP_STRING([--enable-odbcinstlink],[Enable linking of driver against odbcinst library [default=yes]])],
    [ case "${enableval}" in
        yes) enable_odbcinstlink=yes
        ;;
        no)  enable_odbcinstlink=no
             CFLAGS="$CFLAGS -DNO_DRIVERMANAGER"
        ;;
        *)   AC_MSG_ERROR(bad value '${enableval}' for --enable-odbcinstlink);;
      esac
    ], [enable_odbcinstlink=yes])
AC_MSG_RESULT([$enable_odbcinstlink])
AM_CONDITIONAL(ODBCINSTLINK, [test "x$enable_odbcinstlink" = "xyes"])

dm_type=
dm_prefix="/usr"		dnl Default to /usr
iodbc_conf=
AC_ARG_WITH(iODBC,
            [  --with-iODBC[=DIR]        Use iODBC located in DIR],
            [
              dm_type="iODBC"
              if test "x$withval" != "xyes"; then
                dm_prefix="$withval"
              fi
            ])

AC_ARG_WITH(unixODBC,
            [  --with-unixODBC[=DIR]     Use unixODBC located in DIR],
            [
              dm_type="unixODBC"
              if test "x$withval" != "xyes"; then
                dm_prefix="$withval"
              fi
            ])

if test "x$dm_type" = "x"
then
  AC_PATH_PROGS(iodbc_conf, iodbc-config, no, [$dm_prefix/bin:$PATH])
  if test "x$iodbc_conf" = "xno"
  then
    AC_MSG_CHECKING(for SQL_ATTR_UNIXODBC_VERSION in sqlext.h)
    AC_PREPROC_IFELSE(
      [AC_LANG_PROGRAM([[#include <sqlext.h>]],
                       [[printf("%d", SQL_ATTR_UNIXODBC_VERSION)]])],
      [
       dm_type="unixODBC"
       AC_MSG_RESULT(found)
      ],
      [AC_MSG_RESULT(not found)])
  else
    dm_type="iODBC"
  fi
fi

if test "x$dm_type" = "x"
then
  AC_MSG_ERROR(no suitable driver manager selected or found)
fi

if test "$dm_type" = "iODBC"
then
  AC_DEFINE([USE_IODBC], [1], [use iODBC])

  if test "x$iodbc_conf" = "x"
  then
    AC_PATH_PROGS(iodbc_conf, iodbc-config, no, [$dm_prefix/bin:$PATH])
  fi

  AC_ARG_WITH(iodbc-includes,
              [  --with-iodbc-includes=DIR Find iODBC headers in DIR],
	      iodbc_includes="$withval",
	      iodbc_includes="$dm_prefix/include")

  AC_ARG_WITH(iodbc-libs,
              [  --with-iodbc-libs=DIR     Find iODBC libraries in DIR],
              iodbc_libs="$withval",
	      iodbc_libs="$dm_prefix/lib")

  AC_MSG_CHECKING([for iODBC version])
  if test "$iodbc_conf" != "no"
  then
    iodbc_version=`$iodbc_conf --version`
    iodbc_cflags=`$iodbc_conf --cflags`
    if test "x$iodbc_cflags" != "x"; then
      CFLAGS="$CFLAGS $iodbc_cflags"
    fi
    ODBC_DM_LIB=`$iodbc_conf --libs`
  else
    iodbc_version="unknown"
    ODBC_DM_LIB="-liodbc"
  fi
  AC_MSG_RESULT([$iodbc_version])

  AC_SUBST(ODBC_DM_LIB)

  AC_CHECK_IODBC($iodbc_includes, $iodbc_libs)

  AC_ARG_WITH(odbc-ini,
  [  --with-odbc-ini=PATH    Location of system ODBC.INI [IODBCDIR/etc/odbc.ini]],
  odbc_ini="$withval", odbc_ini="$dm_prefix/etc/odbc.ini")

  if test "x$have_iodbcinst" != "xyes"
  then
    AC_DEFINE_UNQUOTED(SYSTEM_ODBC_INI,"$odbc_ini",
                       [Define path to system ODBC.INI file])
  fi

  ODBC_DM_PATH_ARG="--with-iodbc=$dm_prefix"
  AC_SUBST(ODBC_DM_PATH_ARG)

else
# unixODBC
  AC_DEFINE([USE_UNIXODBC], [1], [use unixODBC])

  AC_MSG_CHECKING([for unixODBC version])
  AC_PATH_PROGS(isql, isql, no, [$dm_prefix/bin:$PATH])
  if test "$isql" != "no"
  then
    unixodbc_version=`$isql --version`
  else
    unixodbc_version="unknown"
  fi
  AC_MSG_RESULT([$unixodbc_version])

  AC_ARG_WITH(unixODBC-includes,
              [  --with-unixODBC-includes=DIR Find unixODBC headers in DIR],
              unixODBC_includes="$withval",
              unixODBC_includes="$dm_prefix/include")

  AC_ARG_WITH(unixODBC-libs,
              [  --with-unixODBC-libs=DIR Find unixODBC libraries in DIR],
              unixODBC_libs="$withval",
	      unixODBC_libs="$dm_prefix/lib")

  AC_CHECK_UNIXODBC($unixODBC_includes, $unixODBC_libs)

  AC_ARG_WITH(odbc-ini,
              [  --with-odbc-ini=PATH    Location of system ODBC.INI [UnixODBCDIR/etc/odbc.ini]],
              odbc_ini="$withval",
	      odbc_ini="$unixODBC/etc/odbc.ini")

  if test "x$have_odbcinst" != "xyes"
  then
    AC_DEFINE_UNQUOTED(SYSTEM_ODBC_INI,"$odbc_ini",
                       [Define path to system ODBC.INI file])
  fi

  ODBC_DM_PATH_ARG="--with-unixODBC=$dm_prefix"
  AC_SUBST(ODBC_DM_PATH_ARG)

  ODBC_DM_LIB="-lodbc"
  AC_SUBST(ODBC_DM_LIB)
fi

###################################################################
# if we're working in an older odbc environment,                  #
# we don't have the SQL* types, so we need to fall                #
# back to the old versions                                        #
###################################################################

AC_CHECK_ODBC_TYPE(SQLHENV,HENV)
AC_CHECK_ODBC_TYPE(SQLHDBC,HDBC)
AC_CHECK_ODBC_TYPE(SQLHSTMT,HSTMT)

AC_CHECK_ODBC_TYPE(SQLINTEGER,SDWORD)
AC_CHECK_ODBC_TYPE(SQLUINTEGER,UDWORD)
AC_CHECK_ODBC_TYPE(SQLSMALLINT,SWORD)
AC_CHECK_ODBC_TYPE(SQLUSMALLINT,UWORD)

AC_CHECK_ODBC_TYPE(SQLPOINTER,PTR)
AC_CHECK_ODBC_TYPE(SQLHWND,HWND)

AC_CHECK_ODBC_TYPE(SQLRETURN,RETCODE)

AC_CHECK_ODBC_TYPE(SQLCHAR,UCHAR)

###################################################################
#                                                                 #
# Check and validate for odbc.ini                                 #
#                                                                 #
###################################################################

if test "x$iodbc_ok" = "xyes" && test "x$have_iodbcinst" != "xyes"
then
cat <<EOF
----------------------------------------------------------------
Warning: using iODBC but libiodbcinst library not found.
Enabling workaround, which will search for MySQL datasource
configuration as follows:

1. \$ODBCINI, and if not found - \$HOME/.odbc.ini (User data sources)
2. $odbc_ini (System data sources)

If you want to change (2), re-run configure using the
   --with-odbc-ini=/some/other/path/odbc.ini
option.
----------------------------------------------------------------
EOF
fi

###################################################################
#                                                                 #
# Build optimized or debug version ?                              #
#                                                                 #
#   1. If CFLAGS or DEBUG_CFLAGS set in environment, honor that   #
#   2. If not set and gcc, set flags                              #
#   3. If DEBUG_CFLAGS not set and not gcc, set DEBUG_CFLAGS      #
#      to CFLAGS is set                                           #
#                                                                 #
###################################################################

if test "$ac_cv_prog_gcc" = "yes"
then
  DEBUG_CFLAGS="-ggdb3"
  OPTIMIZE_CFLAGS="-O3"
else
  DEBUG_CFLAGS="-g"
  OPTIMIZE_CFLAGS="-O"
fi

AC_MSG_CHECKING([if debug mode is enabled])
AC_ARG_WITH(debug,
    [AC_HELP_STRING(
        [--with-debug],
        [Include debug support in the binaries [default=no]])],
    [with_debug=$withval],
    [with_debug=no])

AC_ARG_WITH(debug,
[  --with-debug            Build the debug version default=no],
    [with_debug=$withval],
    [with_debug=no])
AC_MSG_RESULT([$with_debug])

AM_CONDITIONAL(WITH_DEBUG, test "x$with_debug" != xno)

if test "$with_debug" = "yes" || test "$with_debug" = "full"
then
  CFLAGS="$DEBUG_CFLAGS -DDBUG_ON $CFLAGS"
else
  # Optimized version. No debug
  CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS"
fi
AC_SUBST(CFLAGS)


###################################################################
#                                                                 #
# Add some extra LDFLAGS to the linking of the shared library     #
#                                                                 #
###################################################################

AC_ARG_WITH(ldflags,
    [  --with-ldflags=option   Extra arguments for linking],
    EXTRA_LDFLAGS="$withval",EXTRA_LDFLAGS="")
AC_SUBST(EXTRA_LDFLAGS)
LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"

###################################################################
#                                                                 #
# Add some extra X libs when linking shared library that usees X  #
#                                                                 #
###################################################################

AC_ARG_WITH(ldflags,
    [  --with-ldflags=option   Extra arguments for linking],
    EXTRA_LDFLAGS="$withval",EXTRA_LDFLAGS="")
AC_SUBST(EXTRA_LDFLAGS)
LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"

extra_xlibs=
AC_ARG_WITH(extra-xlibs,
    [  --with-extra-xlibs=     Extra arguments for linking X apps/libs],
    use_extra_xlibs=$withval,
    use_extra_xlibs=no
)
if test -n "$use_extra_xlibs" && \
   test "$use_extra_xlibs" != "no"; then

   EXTRA_XLIBS="$use_extra_xlibs"
fi
AC_SUBST(EXTRA_XLIBS)

###################################################################
#
# X
#
###################################################################

# We delayed the test for X, as it will use LDFLAGS and LIBS
# set above. This configure doesn't even try find threads library
# etc, it trust to get these configuration from the packages it uses.

AC_PATH_X
if test -z "$ac_x_libraries" || test "x$ac_x_libraries" = xNONE; then
  X_LDFLAGS=""
  x_libraries="/usr/lib"; dnl better than nothing :-
 else
  x_libraries=$ac_x_libraries
  X_LDFLAGS="-L$x_libraries"
fi
all_includes="$all_includes $X_INCLUDES"
all_libraries="$all_libraries $X_LDFLAGS"

AC_SUBST(X_INCLUDES)
AC_SUBST(X_LDFLAGS)
AC_SUBST(x_libraries)
AC_SUBST(x_includes)

LIB_X11='-lX11 $(LIBSOCKET)'
AC_SUBST(LIB_X11)

###################################################################
#
# --enable-gui
#
###################################################################
AC_ARG_ENABLE( gui,
[AC_HELP_STRING([--enable-gui],[Build GUI bits [default=yes]])],
[ case "${enableval}" in
    yes) gui=true ;;
    no) gui=false ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-gui) ;;
    esac],[gui=true])

if test "x$gui" = "xtrue"; then
  AC_PROG_CXX
else
  if
    test "x$enable_dependency_tracking" != xno \
    && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
    am__fastdepCXX_TRUE=
    am__fastdepCXX_FALSE='#'
  else
    am__fastdepCXX_TRUE='#'
    am__fastdepCXX_FALSE=
  fi
fi

###################################################################
#                                                                 #
# Build test library ?                                            #
#                                                                 #
###################################################################

AC_MSG_CHECKING([if building of test is enabled])
AC_ARG_ENABLE(test,
[AC_HELP_STRING([--enable-test],[Enable building of test library [default=yes]])],
 [ case "${enableval}" in
     yes) enable_test=yes ;;
     no)  enable_test=no ;;
     *) AC_MSG_ERROR(bad value '${enableval}' for --enable-test);;
     esac
 ],[enable_test=yes])
 AC_MSG_RESULT([$enable_test])

if test "x$enable_test" = "xyes"
then
  myodbc_test_dir="test"
fi
AC_SUBST(myodbc_test_dir)

###################################################################
#                                                                 #
# Link test library againt Driver Manager supplied ?              #
#                                                                 #
###################################################################


AC_MSG_CHECKING([if linking of test library is specified])
AC_ARG_ENABLE(dmlink,
[AC_HELP_STRING([--enable-dmlink],[Enable linking of test library againt supplied driver manager [default=no]])],
 [ case "${enableval}" in
     yes) enable_dmlink=yes ;;
     no)  enable_dmlink=no ;;
     *) AC_MSG_ERROR(bad value '${enableval}' for --enable-dmlink);;
     esac
 ],[enable_dmlink=no])
 AC_MSG_RESULT([$enable_dmlink])

if test "x$enable_dmlink" = "xyes" ; then
  myodbc_test_linklib="$ODBC_DM_LIB"
else
  myodbc_test_linklib="../driver/libmyodbc5.la"
fi
AC_SUBST(myodbc_test_linklib)

###################################################################
#                                                                 #
# Find out if compiler defines __func__ or __FUNCTION__ macro     #
#                                                                 #
###################################################################

# Use expression that will result in syntax error if undefined
AC_MSG_CHECKING([if compiler defines the __FUNCTION__ macro])
AC_TRY_COMPILE([],[const char *cp = __FUNCTION__;],
 [AC_MSG_RESULT([yes])
  AC_DEFINE(USE_GNU_FUNC_MACRO, 1,
            [Define if compiler defines __FUNCTION__])],
 [AC_MSG_RESULT([no])])

AC_MSG_CHECKING([if compiler defines the C99 __func__ macro])
AC_TRY_COMPILE([], [const char *cp = __func__;],
 [AC_MSG_RESULT([yes])
  AC_DEFINE(USE_C99_FUNC_MACRO, 1,
            [Define if compiler defines C99 __func__ macro])],
 [AC_MSG_RESULT([no])])

###################################################################
#                                                                 #
# Should be done adding to LIBS, check if functions are there     #
#                                                                 #
###################################################################

# There are claims strndup() is broken on AIX 5.1, lets play safe
case "$host_os" in
  *aix*) ;;
  *) AC_CHECK_FUNCS(strndup) ;;
esac

###################################################################
#                                                                 #
# Handle declaration compatibility problems                       #
#                                                                 #
###################################################################

dnl Check for SQLGetPrivateProfileStringW
if test "x$enable_odbcinstlink" != "xno" ; then
  AC_CHECK_FUNCS(SQLGetPrivateProfileStringW)
fi

# Function SQLParamOptions() is deprecated in ODBC 3
AC_MSG_CHECKING([if SQLParamOptions() 2nd and 3rd arg is compatible with SQLULEN])
AC_COMPILE_IFELSE(
[
  AC_LANG_SOURCE(
  [
    #include <sql.h>
    #include <sqlext.h>

    SQLRETURN SQL_API SQLParamOptions( SQLHSTMT     hstmt, 
				       SQLULEN      crow,
				       SQLULEN      *pirow )
    { return 1; }
  ])
],
[
  AC_MSG_RESULT([yes])
  AC_DEFINE(USE_SQLPARAMOPTIONS_SQLULEN_PTR, 1,
            [Define if SQLParamOptions() 2nd and 3rd arg is compatible with SQLULEN])
],
[
  AC_MSG_RESULT([no])
  AC_MSG_CHECKING([if SQLParamOptions() 2nd and 3rd arg is compatible with SQLUINTEGER])
  AC_COMPILE_IFELSE(
  [
    AC_LANG_SOURCE(
    [
      #include <sql.h>
      #include <sqlext.h>

      SQLRETURN SQL_API SQLParamOptions( SQLHSTMT     hstmt, 
                                         SQLUINTEGER  crow,
                                         SQLUINTEGER *pirow )
      { return 1; }
    ])
  ],
  [
    AC_MSG_RESULT([yes])
    AC_DEFINE(USE_SQLPARAMOPTIONS_SQLUINTEGER_PTR, 1,
              [Define if SQLParamOptions() 2nd and 3rd arg is compatible with SQLUINTEGER])
  ],
  [ AC_MSG_RESULT([no]) ])
])

# Microsoft changed declaration for 64 bits to SQLLEN*, from SQLPOINTER
AC_MSG_CHECKING([if SQLColAttribute() last arg is compatible with SQLLEN*])
AC_COMPILE_IFELSE(
[
  AC_LANG_SOURCE(
  [
    #include <sql.h>
    #include <sqlext.h>

    SQLRETURN SQL_API SQLColAttribute( SQLHSTMT  StatementHandle,
                                       SQLUSMALLINT ColumnNumber,
                                       SQLUSMALLINT FieldIdentifier,
                                       SQLPOINTER  CharacterAttributePtr,
                                       SQLSMALLINT BufferLength,
                                       SQLSMALLINT *StringLengthPtr,
                                       SQLLEN *  NumericAttributePtr )
    { return 1; }
  ])
],
[
  AC_MSG_RESULT([yes])
  AC_DEFINE(USE_SQLCOLATTRIBUTE_SQLLEN_PTR, 1,
            [Define if SQLColAttribute() last arg is compatible with SQLLEN*])
],
[
  AC_MSG_RESULT([no])
  AC_MSG_CHECKING([if SQLColAttribute() last arg is compatible with SQLPOINTER])
  AC_COMPILE_IFELSE(
  [
    AC_LANG_SOURCE(
    [
      #include <sql.h>
      #include <sqlext.h>

      SQLRETURN SQL_API SQLColAttribute( SQLHSTMT  StatementHandle,
                                         SQLUSMALLINT ColumnNumber,
                                         SQLUSMALLINT FieldIdentifier,
                                         SQLPOINTER  CharacterAttributePtr,
                                         SQLSMALLINT BufferLength,
                                         SQLSMALLINT *StringLengthPtr,
                                         SQLPOINTER  NumericAttributePtr )
      { return 1; }
    ])
  ],
  [
    AC_MSG_RESULT([yes])
    AC_DEFINE(USE_SQLCOLATTRIBUTE_SQLPOINTER, 1,
              [Define if SQLColAttribute() last arg is compatible with SQLPOINTER])
  ],
  [ AC_MSG_RESULT([no]) ])
])

###################################################################
#                                                                 #
# Generate Makefiles                                              #
#                                                                 #
###################################################################

AC_OUTPUT([
  Makefile 
  util/Makefile
  driver/Makefile
  installer/Makefile
  test/Makefile
  scripts/Makefile
  dltest/Makefile
])

echo
echo "Success!!"
echo " -------------------------------------------------------------------- "
echo "| Remember to check the Connector/ODBC documentation for detailed    |"
echo "| installation and setup instructions at:                            |"
echo "|   http://dev.mysql.com/doc/refman/5.1/en/connector-odbc.html       |"
echo "|                                                                    |"
echo "| Connector/ODBC product information:                                |"
echo "|   http://www.mysql.com/products/myodbc/                            |" 
echo "|                                                                    |"
echo "| Connector/ODBC mailing list archive:                               |"
echo "|   http://lists.mysql.com/myodbc                                    |" 
echo "|                                                                    |"
echo "| If you have any questions or improvements to the driver, then     |"
echo "| send a detailed mail to 'myodbc@lists.mysql.com'                   |" 
echo " -------------------------------------------------------------------- "
echo