aboutsummaryrefslogblamecommitdiffstats
path: root/lib/odbc/configure.in
blob: 77b576ee881ec136047c48ad2b77c31a2b8a5313 (plain) (tree)
























































































































































































































                                                                                                                                 
dnl define([AC_CACHE_LOAD], )dnl
dnl define([AC_CACHE_SAVE], )dnl

if test "x$no_recursion" != "xyes" -a "x$OVERRIDE_CONFIG_CACHE" = "x"; then
    # We do not want to use a common cache!
    cache_file=/dev/null
fi



dnl Process this file with autoconf to produce a configure script.
AC_INIT(c_src/odbcserver.c)

if test -z "$ERL_TOP" || test ! -d $ERL_TOP ; then
  AC_CONFIG_AUX_DIRS(autoconf)
else
  erl_top=${ERL_TOP}
  AC_CONFIG_AUX_DIRS($erl_top/erts/autoconf)
fi

if test "X$host" != "Xfree_source" -a "X$host" != "Xwin32"; then
    AC_CANONICAL_HOST
else
    host_os=win32
fi

dnl Checks for programs.
AC_PROG_CC

dnl ---------------------------------------------------------------------
dnl Special windows stuff regarding CFLAGS and details in the environment...
dnl ---------------------------------------------------------------------
AC_MSG_CHECKING(for mixed cygwin and native VC++ environment)
if test "X$CC" = "Xcc.sh" -a "X$host" = "Xwin32"; then
	if test -x /usr/bin/cygpath; then
		CFLAGS="-O2"
		AC_MSG_RESULT([yes])
		MIXED_CYGWIN_VC=yes
	else
		AC_MSG_RESULT([undeterminable])
		AC_MSG_ERROR(Seems to be mixed windows but not with cygwin, cannot handle this!)
	fi
else
	AC_MSG_RESULT([no])
	MIXED_CYGWIN_VC=no
fi
AC_SUBST(MIXED_CYGWIN_VC)

AC_PROG_MAKE_SET
AC_CHECK_PROGS(DED_LD, [ld.sh ld], '$(CC)')
AC_SUBST(DED_LD)

# Sockets
#--------------------------------------------------------------------
#	Check for the existence of the -lsocket and -lnsl libraries.
#	The order here is important, so that they end up in the right
#	order in the command line generated by make.  Here are some
#	special considerations:
#	1. Use "connect" and "accept" to check for -lsocket, and
#	   "gethostbyname" to check for -lnsl.
#	2. Use each function name only once:  can't redo a check because
#	   autoconf caches the results of the last check and won't redo it.
#	3. Use -lnsl and -lsocket only if they supply procedures that
#	   aren't already present in the normal libraries.  This is because
#	   IRIX 5.2 has libraries, but they aren't needed and they're
#	   bogus:  they goof up name resolution if used.
#	4. On some SVR4 systems, can't use -lsocket without -lnsl too.
#	   To get around this problem, check for both libraries together
#	   if -lsocket doesn't work by itself.
#--------------------------------------------------------------------
erl_checkBoth=0
AC_CHECK_FUNC(connect, erl_checkSocket=0, erl_checkSocket=1)
if test "$erl_checkSocket" = 1; then
    AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket", erl_checkBoth=1)
fi
if test "$erl_checkBoth" = 1; then
    tk_oldLibs=$LIBS
    LIBS="$LIBS -lsocket -lnsl"
    AC_CHECK_FUNC(accept, odbc_erl_checkNsl=0, [LIBS=$tk_oldLibs])
fi
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))

dnl Checks for header files.
AC_HEADER_STDC
case $have_pthread_lib-$host_os in
    yes-linux*)
	dnl NPTL test stolen from $ERL_TOP/erts/aclocal.m4
	AC_MSG_CHECKING(for Native POSIX Thread Library)
	case `getconf GNU_LIBPTHREAD_VERSION 2>/dev/null` in
	    nptl*) nptl=yes;;
	    NPTL*) nptl=yes;;
	    *)  nptl=no;;
	esac
	AC_MSG_RESULT($nptl)
	if test $nptl = yes; then
	    need_nptl_incldir=no
	    AC_CHECK_HEADER(nptl/pthread.h, need_nptl_incldir=yes)
	    if test $need_nptl_incldir = yes; then
		# Ahh...
		nptl_path="$C_INCLUDE_PATH:$CPATH:/usr/local/include:/usr/include"
		nptl_ws_path=
		save_ifs="$IFS"; IFS=":"
		for dir in $nptl_path; do
		    if test "x$dir" != "x"; then
			nptl_ws_path="$nptl_ws_path $dir"
		    fi
		done
		IFS=$save_ifs
		nptl_incldir=
		for dir in $nptl_ws_path; do
	            AC_CHECK_HEADER($dir/nptl/pthread.h,
				    nptl_incldir=$dir/nptl)
		    if test "x$nptl_incldir" != "x"; then
			CFLAGS="$CFLAGS -isystem $nptl_incldir"
			dnl CPPFLAGS is for configure internal use
			CPPFLAGS="$CPPFLAGS -isystem $nptl_incldir"
			break
		    fi
		done
		if test "x$nptl_incldir" = "x"; then
		    AC_MSG_ERROR(Failed to locate nptl system include directory)
		fi
	    fi
	fi
	;;
    *)
	;;
esac
AC_CHECK_HEADERS([fcntl.h netdb.h stdlib.h string.h sys/socket.h])

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T

dnl Checks for library functions.
AC_CHECK_FUNCS([memset socket])
	
# ODBC 
/bin/rm -f $ERL_TOP/lib/odbc/SKIP

have_pthread_lib=no
have_odbc_lib=no
	
AC_SUBST(TARGET_FLAGS)
    case $host_os in
        darwin*)
                TARGET_FLAGS="-DUNIX"
                AC_CHECK_LIB(pthread, pthread_create,
                           [AC_DEFINE(HAVE_LIBPTHREAD, 1, [Define if you have the pthread library (-lpthread).])
                            LIBS="$LIBS -lpthread"
                            have_pthread_lib=yes])
	        if test ! -d "$with_odbc"; then				
		    ODBC_LIB= -L"/usr/lib"
		    ODBC_INCLUDE="-I/usr/lib/include"
		else
		    ODBC_LIB=-L"$with_odbc/lib"
		    ODBC_INCLUDE="-I$with_odbc/include"
		fi
			    
               AC_CHECK_LIB(iodbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -liodbc" odbc_lib_link_sucess=yes])
            ;;
        win32|cygwin)
		TARGET_FLAGS="-DWIN32"
		AC_CHECK_LIB(ws2_32, main)
		if test ! -d "$with_odbc"; then				
		    ODBC_LIB=""   
		    ODBC_INCLUDE=""
		else
		    ODBC_LIB=-L"$with_odbc/lib"
		    ODBC_INCLUDE="-I$with_odbc/include"
		fi
		AC_CHECK_LIB(odbc32, main, [ODBC_LIB="$ODBC_LIB -lodbc32" odbc_lib_link_sucess=yes])
	    ;;
	    *)
	       TARGET_FLAGS="-DUNIX"
	       AC_CHECK_LIB(pthread, pthread_create,
			    [AC_DEFINE(HAVE_LIBPTHREAD, 1, [Define if you have the pthread library (-lpthread).])
			     LIBS="$LIBS -lpthread"
			     have_pthread_lib=yes])
	       if test ! -d "$with_odbc"; then			
	       AC_MSG_CHECKING([for odbc in standard locations])
	         for dir in /usr/local/odbc /usr/local /usr/odbc \
		     /usr /opt/local/pgm/odbc /usr/local/pgm/odbc
		 do
		    if test -f "$dir/include/sql.h"; then
		      is_odbc_std_location=yes	   
		       ODBC_LIB=-L"$dir/lib"
		       ODBC_INCLUDE="-I$dir/include"
		       break	
		    fi	    
	         done	    			
                 if  test "x$is_odbc_std_location" != "xyes"; then
		    AC_MSG_RESULT(no)
		    AC_MSG_WARN([No odbc library found skipping odbc])
		    echo "No odbc library found" > $ERL_TOP/lib/odbc/SKIP
	         else
		      AC_MSG_RESULT($ODBC_LIB)
		      AC_CHECK_LIB(odbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc" odbc_lib_link_sucess=yes])			 
	         fi     
              else
                ODBC_LIB=-L"$with_odbc/lib"
                ODBC_INCLUDE="-I$with_odbc/include"
	        AC_CHECK_LIB(odbc, SQLAllocHandle,[ODBC_LIB="$ODBC_LIB -lodbc" odbc_lib_link_sucess=yes])		
              fi
	  ;;
esac

if test "x$odbc_lib_link_sucess" != "xyes";  then
    AC_MSG_WARN(["ODBC library - link check failed"])
    echo "ODBC library - link check failed" > $ERL_TOP/lib/odbc/SKIP
fi
		
AC_SUBST(ODBC_LIB)
AC_SUBST(ODBC_INCLUDE)

AC_OUTPUT(c_src/$host/Makefile:c_src/Makefile.in)