configure.in   [plain text]


AC_PREREQ(2.53)
AC_REVISION($Id: configure.in,v 1.1.1.2 2002/04/30 00:40:19 miner Exp $)
#
#  configure.in
#  
#  The iODBC driver manager.
#  
#  Copyright (C) 1995 by Ke Jin <kejin@empress.com> 
#  Copyright (C) 1996-2002 by OpenLink Software <iodbc@openlinksw.com>
#  All Rights Reserved.
#
#  This software is released under the terms of either of the following
#  licenses:
#
#      - GNU Library General Public License (see LICENSE.LGPL) 
#      - The BSD License (see LICENSE.BSD).
#
#  While not mandated by the BSD license, any patches you make to the
#  iODBC source code may be contributed back into the iODBC project
#  at your discretion. Contributions will benefit the Open Source and
#  Data Access community as a whole. Submissions may be made at:
#
#      http://www.iodbc.org
#
#
#  GNU Library Generic Public License Version 2
#  ============================================
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Library General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#
#  This library 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
#  Library General Public License for more details.
#
#  You should have received a copy of the GNU Library General Public
#  License along with this library; if not, write to the Free
#  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#  The BSD License
#  ===============
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions
#  are met:
#
#  1. Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#  2. Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in
#     the documentation and/or other materials provided with the
#     distribution.
#  3. Neither the name of OpenLink Software Inc. nor the names of its
#     contributors may be used to endorse or promote products derived
#     from this software without specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OPENLINK OR
#  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
#  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
#  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##########################################################################
##									##
##  Initialization							##
##									##
##########################################################################
AC_INIT
AC_CONFIG_SRCDIR([include/isql.h])
AC_CONFIG_AUX_DIR(admin)
AM_CONFIG_HEADER(include/config.h)
AM_INIT_AUTOMAKE(libiodbc,3.0.6)
AC_CANONICAL_HOST
AM_MAINTAINER_MODE


##########################################################################
##									##
##  Check whether config.cache belongs to this machine			##
##									##
##########################################################################
AC_MSG_CHECKING(cached information)
hostcheck="$host"
AC_CACHE_VAL(ac_cv_hostcheck, [ ac_cv_hostcheck="$hostcheck" ])
if test "$ac_cv_hostcheck" != "$hostcheck"; then
  AC_MSG_RESULT(changed)

  AC_MSG_WARN([Running on a different architecture.])
  AC_MSG_WARN([Can't use cached values.])
  AC_MSG_ERROR([Please remove the invalid config.cache file, then try again.])
else
  AC_MSG_RESULT(ok)
fi


##########################################################################
##									##
##  Check for C compiler						##
##									##
##########################################################################
AC_PROG_CC
AC_PROG_CC_C_O
AC_PROG_CC_STDC
AC_PROG_CPP
AC_LANG([C])


##########################################################################
##									##
##  Check for standard programs						##
##									##
##########################################################################
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
dnl AC_PROG_RANLIB
AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL


##########################################################################
##									##
##  Check for standard header files					##
##									##
##########################################################################
AC_HEADER_STDC


##########################################################################
##									##
##  Check for specific library functions				##
##									##
##########################################################################
AC_CHECK_FUNCS(strerror setenv)


##########################################################################
##									##
##  Check if we want to build the GUI applications and libraries	##
##									##
##########################################################################
AC_ARG_ENABLE(gui,
[  --enable-gui            build GUI applications (default),
  --disable-gui           build GUI applications],
[ case "${enableval}" in
    yes) USE_GUI=true ;;
    no)  USE_GUI=false ;;
    *) AC_MSG_ERROR(bad value ${enableval} for --enable-gui) ;;
  esac
],[USE_GUI=true]) 


##########################################################################
##									##
##  Check for GTK library functions					##
##									##
##########################################################################
USE_GTK=false
if test x$USE_GUI = xtrue
then
  AM_PATH_GTK(1.2.3)
  if test x$no_gtk = x
  then
    USE_GTK=true
  fi
fi


##########################################################################
##									##
##  Now make the final checks whether we can use GUI extentions		##
##									##
##########################################################################
if test x$USE_GTK = xfalse
then
  USE_GUI=false
fi

if test x$USE_GUI = xtrue
then
  AC_DEFINE(GUI, 1, [Define if we detected a GUI library we can use])
fi

AM_CONDITIONAL(GUI, [test x$USE_GUI = xtrue])
AM_CONDITIONAL(GTK, [test x$USE_GTK = xtrue])


##########################################################################
##									##
##  Check for dynamic load module					##
##									##
##########################################################################

AC_CHECK_HEADERS(dlfcn.h dl.h dld.h)

LIBADD_DL=

AC_CHECK_LIB(dl, dlopen, 
  [AC_DEFINE(HAVE_LIBDL, 1, [Define if you have the -ldl library]) 
	LIBADD_DL="-ldl"],
  [AC_CHECK_FUNCS(dlopen _dlopen, [
	AC_DEFINE(HAVE_LIBDL, 1,[Define if you have the -ldl library])
  ])]
  )

AC_CHECK_FUNC(shl_load, 
  [AC_DEFINE(HAVE_SHL_LOAD, 1, [Define if you have the shl_load function])],
  [AC_CHECK_LIB(dld, shl_load, 
    [AC_DEFINE(HAVE_SHL_LOAD, 1, [Define if you have the shl_load function]) LIBADD_DL="$LIBADD_DL -ldld"])]
  )

AC_CHECK_LIB(dld, dld_link, 
   [AC_DEFINE(HAVE_DLD, 1, [Define if you have the -ldld library])dnl
    test "x$ac_cv_lib_dld_shl_load" = yes || LIBADD_DL="$LIBADD_DL -ldld"])

AC_CHECK_FUNC(NSCreateObjectFileImageFromFile,
    [AC_DEFINE(HAVE_DYLD, 1, [Define if you have the DYLD library])])

AC_SUBST(LIBADD_DL)

AC_CACHE_CHECK([for underscore before symbols], libltdl_cv_uscore, [
  echo "main(){int i=1;} fnord(){int i=23; int ltuae=42;}" > conftest.c
  ${CC} -c conftest.c > /dev/null
  if (nm conftest.o | grep _fnord) > /dev/null; then
    libltdl_cv_uscore=yes
  else
    libltdl_cv_uscore=no
  fi
  rm -f conftest*
])

if test x"$libltdl_cv_uscore" = xyes; then
  if test x"$ac_cv_func_dlopen" = xyes ||
     test x"$ac_cv_lib_dl_dlopen" = xyes ; then
	AC_CACHE_CHECK([whether we have to add an underscore for dlsym],
		libltdl_cv_need_uscore, [dnl
		AC_TRY_RUN([
#if HAVE_DLFCN_H
#include <dlfcn.h>
#endif

#include <stdio.h>

#ifdef RTLD_GLOBAL
# define LTDL_GLOBAL	RTLD_GLOBAL
#else
# ifdef DL_GLOBAL
#  define LTDL_GLOBAL	DL_GLOBAL
# else
#  define LTDL_GLOBAL	0
# endif
#endif

/* We may have to define LTDL_LAZY_OR_NOW in the command line if we
   find out it does not work in some platform. */
#ifndef LTDL_LAZY_OR_NOW
# ifdef RTLD_LAZY
#  define LTDL_LAZY_OR_NOW	RTLD_LAZY
# else
#  ifdef DL_LAZY
#   define LTDL_LAZY_OR_NOW	DL_LAZY
#  else
#   ifdef RTLD_NOW
#    define LTDL_LAZY_OR_NOW	RTLD_NOW
#   else
#    ifdef DL_NOW
#     define LTDL_LAZY_OR_NOW	DL_NOW
#    else
#     define LTDL_LAZY_OR_NOW	0
#    endif
#   endif
#  endif
# endif
#endif

fnord ()
{
  int i = 42;
}

main ()
{
  void *self, *ptr1, *ptr2;
  self = dlopen (0, LTDL_GLOBAL | LTDL_LAZY_OR_NOW);
  if (self)
    {
      ptr1 = dlsym (self, "fnord");
      ptr2 = dlsym (self, "_fnord");
      if (ptr1 && !ptr2)
	{
	  dlclose (self);
	  exit (0);
	}
    }
  exit (1);
}
],	libltdl_cv_need_uscore=no, libltdl_cv_need_uscore=yes,
	libltdl_cv_need_uscore=no
)])
  fi
fi

if test x"$libltdl_cv_need_uscore" = xyes; then
   AC_DEFINE(NEED_USCORE, 1,
	[Define if dlsym() requires a leading underscode in symbol names. ])
fi


##########################################################################
##                                                                      ##
##  Check if the dl library has the dladdr function                     ##
##                                                                      ##
##########################################################################
AC_CHECK_FUNC(dladdr, AC_DEFINE(HAVE_DLADDR, 1, [Define to 1 if you have the `dladdr' function.]),
[AC_CHECK_LIB(dl, dladdr, [AC_DEFINE(HAVE_DLADDR, 1, [Define to 1 if you have the `dladdr' function]) LIBADD_DL="-ldl"],[])]
)
 
AC_CHECK_TYPES([Dl_info])


##########################################################################
##									##
##  Set version information						## 
##									##
##########################################################################

AC_MSG_CHECKING(for iODBC mode)
AC_ARG_ENABLE(odbc3,
[  --enable-odbc3          build ODBC 3.x compatible driver manager (default) 
  --disable-odbc3         build ODBC 2.x compatible driver manager],
[
    case "${enableval}" in
      yes)	odbcmode=3 ;;
      no)	odbcmode=2 ;;
      *)	AC_MSG_ERROR(bad value ${enableval} for --enable-odbc3) ;;
    esac
],
[
    odbcmode=3	  # set default to ODBC 3.x mode 
])

if test "x$odbcmode" = "x3"
then
	lib_version=3:6:1
	CFLAGS="$CFLAGS -DODBCVER=0x0350" 
	AC_MSG_RESULT(ODBC 3.x compatible mode)
else
	lib_version=2:55:0; 
	CFLAGS="$CFLAGS -DODBCVER=0x0250" 
	AC_MSG_RESULT(ODBC 2.x compatible mode)
fi
AC_SUBST(odbcmode)
AC_SUBST(lib_version)


##########################################################################
##									##
##  Where to find the system odbc.ini file				**
##									##
##########################################################################

#
#  First determine the systemwide default directory according 
#  to GNU specifications
#
AC_MSG_CHECKING(system config directory)
sysinidir=`eval echo $sysconfdir`
case "$sysinidir" in
NONE*) 
       sysinidir=$ac_default_prefix/etc
       ;;
/usr/etc)
       sysinidir=/etc
       ;;
*)
       sysinidir=`eval echo $sysconfdir`
       ;;
esac
AC_MSG_RESULT($sysinidir)

#
#  Now allow to overrule this directory with a custom setting
#
AC_MSG_CHECKING(for iODBC ini directory)
AC_ARG_WITH(iodbc-inidir,
[  --with-iodbc-inidir=DIR where the system odbc.ini file should be located.
                            (default is /etc) ],
[ 
    case "$withval" in
    yes|no)
        inidir=$sysinidir
	;;
    *)
    	inidir=$withval
	;;
    esac 
], [ inidir=/etc ])
AC_MSG_RESULT($inidir)

AC_SUBST(inidir)
AC_DEFINE_UNQUOTED(SYS_ODBC_INI, "$inidir/odbc.ini",
	[Define path to systemwide odbc.ini file])
AC_DEFINE_UNQUOTED(SYS_ODBCINST_INI, "$inidir/odbcinst.ini",
	[Define path to systemwide odbcinst.ini file])


##########################################################################
##									##
##  Checkout pthread situation						##
##									##
##########################################################################

AC_ARG_WITH(pthreads,
    [  --with-pthreads         build pthread implementation if possible],
    [CFLAGS="$CFLAGS -DWITH_PTHREADS -D_REENTRANT"
     AC_CHECK_LIB(pthreads, pthread_create,
       [if test "$host_os" = "osf3.2"
	then
	  CFLAGS="$CFLAGS -DOLD_PTHREADS"
	  LIBS="$LIBS -lpthreads -lmach -lc_r"
	else
	  LIBS="$LIBS -lpthreads"
	fi
       ],
       [AC_CHECK_LIB(pthread, pthread_create, [LIBS="$LIBS -lpthread"])])
    ])



########################################################################## 
##									##
##  Generate Makefiles etc.						##
##									##
##########################################################################
AC_CONFIG_FILES([
    Makefile 
    admin/Makefile
    admin/libiodbc.spec
    bin/Makefile
    bin/iodbc-config
    etc/Makefile
    include/Makefile
    iodbc/Makefile
    iodbcinst/Makefile
    iodbcadm/Makefile
    iodbcadm/gtk/Makefile
    drvproxy/Makefile
    drvproxy/gtk/Makefile
    samples/Makefile
])
AC_CONFIG_COMMANDS([default],[
    chmod 755 bin/iodbc-config
])
AC_OUTPUT