aboutsummaryrefslogblamecommitdiffstats
path: root/lib/odbc/configure.in
blob: 24e286c290c0441e9639ef7e1bae0221e4816d5a (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

if test "$with_odbc" = "no"; then

   rm -f "$ERL_TOP/lib/odbc/SKIP"
   echo "odbc disabled by user." > "$ERL_TOP/lib/odbc/SKIP"

else dnl "$with_odbc" != "no"

ERL_XCOMP_SYSROOT_INIT

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_PROG(LD, ld.sh)
AC_CHECK_TOOL(LD, ld, '$(CC)')

AC_SUBST(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
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"

LM_CHECK_THR_LIB
AC_SUBST(THR_DEFS)
AC_SUBST(THR_LIBS)

odbc_lib_link_success=no
AC_SUBST(TARGET_FLAGS)
    case $host_os in
        darwin*)
                TARGET_FLAGS="-DUNIX"
	        if test ! -d "$with_odbc" || test "$with_odbc" = "yes" ; 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_success=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_success=yes])
	    ;;
	    *)
	        TARGET_FLAGS="-DUNIX"
		case "$erl_xcomp_without_sysroot-$with_odbc" in
		    yes-yes | yes- )
			msg="Dont know where to search for odbc (setting erl_xcomp_sysroot will help)"
			AC_MSG_WARN([$msg])
			echo "$msg" > "$ERL_TOP/lib/odbc/SKIP"
			odbc_lib_link_success=wont_try
			;;
		    no- )
			AC_CHECK_SIZEOF(void *)
			AC_MSG_CHECKING([for odbc in standard locations])
			for rdir in /usr/local/odbc /usr/local /usr/odbc \
			            /usr /opt/local/pgm/odbc /usr/local/pgm/odbc; do
			  test -f "$erl_xcomp_isysroot$rdir/include/sql.h" || continue
			  is_odbc_std_location=yes
			  libdir="$erl_xcomp_sysroot$rdir/lib"
			  if test "$ac_cv_sizeof_void_p" = "8"; then
			      dnl "/." in test is important (dir symlinks)
			      if test -d "${libdir}64/."; then
				  libdir="${libdir}64"
			      elif test -d "${libdir}/64/."; then
				  libdir="${libdir}/64"
			      fi
			  fi			  
			  ODBC_LIB="-L$libdir"
			  ODBC_INCLUDE="-I$erl_xcomp_isysroot$rdir/include"
			  break
			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_success=yes])			 
			fi
			;;

		    no-*)
			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_success=yes])
			;;
		esac
	  ;;
esac

if test $odbc_lib_link_success = no;  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)

fi dnl "$with_odbc" != "no"

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