ab6aec1997-02-11Fredrik Hübinette (Hubbe) #
620f662003-03-28Marcus Comstedt # $Id: configure.in,v 1.38 2003/03/28 15:21:02 marcus Exp $
ab6aec1997-02-11Fredrik Hübinette (Hubbe) # # Configure script for the mysql-module #
147f382000-09-12Fredrik Noring # Henrik Grubbström
ab6aec1997-02-11Fredrik Hübinette (Hubbe) # # # NOTE: # Prior to 3.20.0 After 3.20.0
8db4cc2002-07-16Per Hedbor # -------------------------------------------------------------------
ab6aec1997-02-11Fredrik Hübinette (Hubbe) # /usr/local/mysql/mach-lib-threads /usr/local/lib/mysql # /usr/local/mysql/include /usr/local/include/mysql # libmysql.a libmysqllib.a # libstrings.a libmystrings.a # AC_INIT(mysql.c) AC_CONFIG_HEADER(config.h)
e269811998-09-20Fredrik Hübinette (Hubbe) AC_MODULE_INIT()
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
e45ef22001-02-14Mirar (Pontus Hagland) PIKE_FEATURE_WITHOUT(Mysql)
ab6aec1997-02-11Fredrik Hübinette (Hubbe) OLD_LIBS=$LIBS OLD_LDFLAGS=$LDFLAGS OLD_CPPFLAGS=$CPPFLAGS MYSQL_LIBS="" AC_ARG_WITH(mysql, [ --without-mysql no support for the Mysql database],[],[with_mysql=yes])
9d53421998-10-20Henrik Grubbström (Grubba) if test x$with_mysql = xno; then : else
e45ef22001-02-14Mirar (Pontus Hagland)  PIKE_FEATURE_NODEP(Mysql)
9d53421998-10-20Henrik Grubbström (Grubba)  AC_MSG_CHECKING(for Mysql lib-directory)
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
f067c32001-11-29Henrik Grubbström (Grubba)  libdirs="$with_root/usr/local/lib/mysql $with_root/usr/local/mysql/lib/mysql $with_root/opt/lib/mysql $with_root/opt/mysql/lib/mysql $with_root/usr/gnu/lib/mysql $with_root/usr/lib/mysql $with_root/lib/mysql $with_root/usr/pkg/lib/mysql $with_root/usr/local/mysql/lib $with_root/usr/local/mysql/mach-lib-thread no" incdirs="$with_root/usr/local/include/mysql $with_root/usr/local/mysql/include/mysql $with_root/opt/include/mysql $with_root/opt/mysql/include/mysql $with_root/usr/gnu/include/mysql $with_root/usr/include/mysql $with_root/include/mysql $with_root/usr/pkg/include/mysql $with_root/usr/local/mysql/include no"
7e2be31999-02-07Henrik Grubbström (Grubba)  if test x$with_mysql = xyes; then :; else # Mysql installation directory specified. libdirs="$with_mysql/lib/mysql $with_mysql/lib $libdirs" incdirs="$with_mysql/include/mysql $with_mysql/include $incdirs" fi
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  AC_CACHE_VAL(pike_cv_mysql_lib_dir, [
7e2be31999-02-07Henrik Grubbström (Grubba)  for pike_cv_mysql_lib_dir in $libdirs; do
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  if test -d $pike_cv_mysql_lib_dir/.; then break else : fi done ]) AC_MSG_RESULT($pike_cv_mysql_lib_dir) if test x$pike_cv_mysql_lib_dir = xno; then :; else echo Adding $pike_cv_mysql_lib_dir to the library search path.
f5ecde2001-01-18Henrik Grubbström (Grubba)  LDFLAGS="${LDFLAGS} -R$pike_cv_mysql_lib_dir -L$pike_cv_mysql_lib_dir"
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  fi
9d53421998-10-20Henrik Grubbström (Grubba)  AC_MSG_CHECKING(for Mysql include-directory)
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  AC_CACHE_VAL(pike_cv_mysql_include_dir, [
7e2be31999-02-07Henrik Grubbström (Grubba)  for pike_cv_mysql_include_dir in $incdirs; do
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  if test -d $pike_cv_mysql_include_dir/.; then break else : fi done ]) AC_MSG_RESULT($pike_cv_mysql_include_dir) if test x$pike_cv_mysql_include_dir = xno; then :; else echo Adding $pike_cv_mysql_include_dir to the include search path.
f5ecde2001-01-18Henrik Grubbström (Grubba)  CPPFLAGS="${CPPFLAGS} -I$pike_cv_mysql_include_dir"
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  fi # Header file
620f662003-03-28Marcus Comstedt  AC_CHECK_HEADERS(winsock.h windows.h mysql.h mysql/mysql.h errmsg.h mysql/errmsg.h)
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
438bdc2003-02-26Marcus Agehall  # Defines within headerfile define([AC_CHECK_MYSQL_OPTIONS], [ AC_MSG_CHECKING(for $1) AC_TRY_COMPILE([ #ifdef HAVE_MYSQL_H #include <mysql.h> #else #ifdef HAVE_MYSQL_MYSQL_H #include <mysql/mysql.h> #endif #endif ], [ int tmp; tmp = $1; ], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_$1) ], [ AC_MSG_RESULT(no) ])]) AC_CHECK_MYSQL_OPTIONS(MYSQL_READ_DEFAULT_FILE) AC_CHECK_MYSQL_OPTIONS(MYSQL_OPT_CONNECT_TIMEOUT) AC_CHECK_MYSQL_OPTIONS(MYSQL_OPT_COMPRESS) AC_CHECK_MYSQL_OPTIONS(MYSQL_OPT_NAMED_PIPE) AC_CHECK_MYSQL_OPTIONS(MYSQL_INIT_COMMAND) AC_CHECK_MYSQL_OPTIONS(MYSQL_READ_DEFAULT_GROUP) AC_CHECK_MYSQL_OPTIONS(MYSQL_SET_CHARSET_DIR) AC_CHECK_MYSQL_OPTIONS(MYSQL_SET_CHARSET_NAME) AC_CHECK_MYSQL_OPTIONS(MYSQL_OPT_LOCAL_INFILE)
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  # Mysql libs
5251601997-04-03Henrik Grubbström (Grubba)  pike_cv_mysql="unknown"
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
8db4cc2002-07-16Per Hedbor  AC_CHECK_LIB(mysqlclient, bchange, [ LIBS="-lmysqlclient $LIBS" MYSQL_LIBS="-lmysqlclient" pike_cv_mysql="post3.20" ], [ AC_CHECK_LIB(mystrings, bchange, [
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  LIBS="-lmystrings $LIBS" MYSQL_LIBS="-lmystrings ${MYSQL_LIBS}" pike_cv_mysql="post3.20" ], [ AC_CHECK_LIB(strings, bchange, [ LIBS="-lstrings $LIBS" MYSQL_LIBS="-lstrings ${MYSQL_LIBS}" pike_cv_mysql="pre3.20" ], []) ])
8db4cc2002-07-16Per Hedbor ])
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  AC_MSG_CHECKING(Mysql version) AC_MSG_RESULT($pike_cv_mysql)
5251601997-04-03Henrik Grubbström (Grubba)  # System libs which might be needed
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
5251601997-04-03Henrik Grubbström (Grubba)  if echo $LIBS|grep -- -lsocket >&5 2>&5; then :
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  else
5251601997-04-03Henrik Grubbström (Grubba)  AC_CHECK_LIB(socket, socket, [ LIBS="-lsocket $LIBS" MYSQL_LIBS="-lsocket ${MYSQL_LIBS}" ], []) fi if echo $LIBS|grep -- -lnsl >&5 2>&5; then : else AC_CHECK_LIB(nsl, gethostbyname, [ LIBS="-lnsl $LIBS" MYSQL_LIBS="-lnsl ${MYSQL_LIBS}" ], []) fi if echo $LIBS|grep -- -lm >&5 2>&5; then : else AC_CHECK_LIB(m, floor, [ LIBS="-lm $LIBS" MYSQL_LIBS="-lm ${MYSQL_LIBS}" ], []) fi
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
5251601997-04-03Henrik Grubbström (Grubba)  # Pthreads is still needed in 3.20.0. AC_CHECK_FUNC(pthread_self, [], [ AC_CHECK_LIB(pthread, pthread_self, [ LIBS="-lpthread $LIBS" echo Warning added -lpthread to \$LIBS\! ], [ AC_CHECK_LIB(pthreads, pthread_self, [ LIBS="-lpthreads $LIBS" echo Warning added -lpthreads to \$LIBS\!
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  ], []) ])
5251601997-04-03Henrik Grubbström (Grubba)  ])
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
5251601997-04-03Henrik Grubbström (Grubba)  AC_CHECK_LIB(dbug, _db_doprnt_, [ LIBS="-ldbug $LIBS" MYSQL_LIBS="-ldbug ${MYSQL_LIBS}" ], []) AC_CHECK_LIB(mysys, my_init, [ LIBS="-lmysys $LIBS" MYSQL_LIBS="-lmysys ${MYSQL_LIBS}" ], [])
7a29ba2000-08-23Elias Levy  # mysql 3.23.x libmysqlclient requires zlib... AC_CHECK_LIB(z, compress, [ LIBS="-lz $LIBS" MYSQL_LIBS="-lz ${MYSQL_LIBS}" ], [])
5251601997-04-03Henrik Grubbström (Grubba)  # Try a couple of mysqlclient libs # in order of age, newest first.
bfbae31998-09-01Fredrik Hübinette (Hubbe) define([AC_CHECK_SQLLIB], [
cf381a2001-11-15Henrik Grubbström (Grubba) AC_MSG_CHECKING(for mysql_real_connect in $1) AC_CACHE_VAL(ac_cv_pike_lib_$1_mysql_real_connect,
bfbae31998-09-01Fredrik Hübinette (Hubbe) [ ac_save_LIBS="$LIBS" LIBS="-l$1 $LIBS" AC_TRY_LINK( [ #ifdef HAVE_WINSOCK_H #include <winsock.h> #endif #ifdef HAVE_MYSQL_H #include <mysql.h> #else #ifdef HAVE_MYSQL_MYSQL_H #include <mysql/mysql.h> #endif #endif ],[
cf381a2001-11-15Henrik Grubbström (Grubba)  mysql_real_connect(0,0,0,0,0,0,0,0); ],ac_cv_pike_lib_$1_mysql_real_connect=yes, ac_cv_pike_lib_$1_mysql_real_connect=no)
bfbae31998-09-01Fredrik Hübinette (Hubbe) LIBS="$ac_save_LIBS" ])
cf381a2001-11-15Henrik Grubbström (Grubba) if test "x$ac_cv_pike_lib_$1_mysql_real_connect" = xyes ; then
e45ef22001-02-14Mirar (Pontus Hagland)  PIKE_FEATURE(Mysql,[yes (lib$1)])
bfbae31998-09-01Fredrik Hübinette (Hubbe)  AC_MSG_RESULT(yes) $2 else AC_MSG_RESULT(no)
cf381a2001-11-15Henrik Grubbström (Grubba)  AC_MSG_CHECKING(for mysql_connect in $1) AC_CACHE_VAL(ac_cv_pike_lib_$1_mysql_connect, [ ac_save_LIBS="$LIBS" LIBS="-l$1 $LIBS" AC_TRY_LINK( [ #ifdef HAVE_WINSOCK_H #include <winsock.h> #endif #ifdef HAVE_MYSQL_H #include <mysql.h> #else #ifdef HAVE_MYSQL_MYSQL_H #include <mysql/mysql.h> #endif #endif ],[ mysql_connect(0,0,0,0); ],ac_cv_pike_lib_$1_mysql_connect=yes, ac_cv_pike_lib_$1_mysql_connect=no) LIBS="$ac_save_LIBS" ]) if test "x$ac_cv_pike_lib_$1_mysql_connect" = xyes ; then PIKE_FEATURE(Mysql,[yes (lib$1)]) AC_MSG_RESULT(yes) $2 else AC_MSG_RESULT(no) $3 fi
bfbae31998-09-01Fredrik Hübinette (Hubbe) fi ]) AC_CHECK_SQLLIB(mysqlclient, [
5251601997-04-03Henrik Grubbström (Grubba)  LIBS="-lmysqlclient $LIBS" MYSQL_LIBS="-lmysqlclient ${MYSQL_LIBS}" ], [
bfbae31998-09-01Fredrik Hübinette (Hubbe)  AC_CHECK_SQLLIB(mysqllib, [
5251601997-04-03Henrik Grubbström (Grubba)  LIBS="-lmysqllib $LIBS" MYSQL_LIBS="-lmysqllib ${MYSQL_LIBS}" ], [
bfbae31998-09-01Fredrik Hübinette (Hubbe)  AC_CHECK_SQLLIB(mysql, [
5251601997-04-03Henrik Grubbström (Grubba)  LIBS="-lmysql $LIBS" MYSQL_LIBS="-lmysql ${MYSQL_LIBS}"
e45ef22001-02-14Mirar (Pontus Hagland)  ], [ PIKE_FEATURE_NODEP(Mysql) pike_cv_mysql="no" ])
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  ])
5251601997-04-03Henrik Grubbström (Grubba)  ])
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
5251601997-04-03Henrik Grubbström (Grubba)  if test x$pike_cv_mysql = xno; then # Restore variables, so we don't link with unnessesary libs
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
5251601997-04-03Henrik Grubbström (Grubba)  LIBS=$OLD_LIBS CPPFLAGS=$OLD_CPPFLAGS LDFLAGS=$OLD_LDFLAGS MYSQL_LIBS="" else AC_DEFINE(HAVE_MYSQL)
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
c9cd161998-07-02Henrik Grubbström (Grubba)  # Note: mysql_port and mysql_unix_port aren't functions, but that shouldn't matter
04b20a2001-02-06Henrik Grubbström (Grubba)  define([PIKE_CHECK_MYSQL_FUNC], [ changequote(<<, >>)dnl define(<<AC_CV_NAME>>, translit(pike_cv_mysql_$1, [ *], [_p]))dnl changequote([, ])dnl AC_MSG_CHECKING(for $1) AC_CACHE_VAL(AC_CV_NAME, [
adfdb02001-02-07Henrik Grubbström (Grubba)  AC_TRY_LINK([ #ifdef HAVE_WINSOCK_H #include <winsock.h> #endif
04b20a2001-02-06Henrik Grubbström (Grubba) #ifdef HAVE_MYSQL_H #include <mysql.h> #else #ifdef HAVE_MYSQL_MYSQL_H #include <mysql/mysql.h> #else #error Need mysql.h headerfile! #endif #endif
b853432001-02-06Henrik Grubbström (Grubba)  ], [ void (*foo__)() = (void (*)())&$1;
f5aba22001-02-06Henrik Grubbström (Grubba)  ], [AC_CV_NAME="yes"], [AC_CV_NAME="no"])
04b20a2001-02-06Henrik Grubbström (Grubba)  ]) if test "$AC_CV_NAME" = "yes"; then AC_DEFINE(translit(HAVE_$1,[a-z],[A-Z])) fi AC_MSG_RESULT($AC_CV_NAME) ]) PIKE_CHECK_MYSQL_FUNC(mysql_real_query) PIKE_CHECK_MYSQL_FUNC(mysql_fetch_lengths)
4996ea2002-03-18Henrik Grubbström (Grubba)  PIKE_CHECK_MYSQL_FUNC(mysql_options)
04b20a2001-02-06Henrik Grubbström (Grubba) 
5ae8af2003-02-07Marcus Agehall  AC_CHECK_LIB(mysqlclient, mysql_ssl_set, [
c67ceb2003-02-07Marcus Agehall  AC_DEFINE(HAVE_MYSQL_SSL)
5ae8af2003-02-07Marcus Agehall  ])
de9cfa2003-02-07Marcus Agehall 
b853432001-02-06Henrik Grubbström (Grubba)  # Note: The following two are variables: PIKE_CHECK_MYSQL_FUNC(mysql_port) PIKE_CHECK_MYSQL_FUNC(mysql_unix_port)
04b20a2001-02-06Henrik Grubbström (Grubba) 
35a8502001-02-06Henrik Grubbström (Grubba)  if test "$pike_cv_mysql_mysql_fetch_lengths" = "yes"; then
0f1d4b2000-03-23Henrik Grubbström (Grubba)  # # In 3.20.6b mysql_fetch_lengths() returns an uint *. # In 3.20.22 it returns an unsigned int *. # In 3.22.23 it returns an unsigned long *. # AC_MSG_CHECKING([if mysql_fetch_lengths() returns an uint or an ulong]) AC_CACHE_VAL(pike_cv_mysql_fetch_lengths_ret_type, [
359c382000-03-23Henrik Grubbström (Grubba)  for ret_type in "unsigned long long" "unsigned long" "unsigned int" "long long" "long" "int"; do
0f1d4b2000-03-23Henrik Grubbström (Grubba)  AC_TRY_COMPILE([
344cde2001-02-07Henrik Grubbström (Grubba) #ifdef HAVE_WINSOCK_H #include <winsock.h> #endif
0f1d4b2000-03-23Henrik Grubbström (Grubba) #ifdef HAVE_MYSQL_H #include <mysql.h> #else #ifdef HAVE_MYSQL_MYSQL_H #include <mysql/mysql.h> #else #error Need mysql.h headerfile! #endif #endif
359c382000-03-23Henrik Grubbström (Grubba)  #ifndef STDCALL #define STDCALL #endif /* STDCALL */ $ret_type * STDCALL mysql_fetch_lengths(MYSQL_RES *mysql)
0f1d4b2000-03-23Henrik Grubbström (Grubba) { return 0; }
359c382000-03-23Henrik Grubbström (Grubba)  ], [], [ pike_cv_mysql_fetch_lengths_ret_type="$ret_type"; break; ])
0f1d4b2000-03-23Henrik Grubbström (Grubba)  done ]) if test "X$pike_cv_mysql_fetch_lengths_ret_type" = "X"; then AC_MSG_RESULT(Unknown -- Defaulting to unsigned long) AC_DEFINE(FETCH_LENGTHS_TYPE, unsigned long) else AC_MSG_RESULT($pike_cv_mysql_fetch_lengths_ret_type)
c6d6e02000-03-23Henrik Grubbström (Grubba)  AC_DEFINE_UNQUOTED(FETCH_LENGTHS_TYPE, $pike_cv_mysql_fetch_lengths_ret_type)
0f1d4b2000-03-23Henrik Grubbström (Grubba)  fi else :; fi
5c44b02003-03-28Marcus Comstedt 
620f662003-03-28Marcus Comstedt  AC_MSG_CHECKING(for CreateSemaphoreA) AC_CACHE_VAL(ac_cv_func_CreateSemaphoreA,[ AC_TRY_LINK([ #ifdef HAVE_WINDOWS_H #include <windows.h> #endif ],[ CreateSemaphoreA(0, 0, 0, 0); ],[ac_cv_func_CreateSemaphoreA=yes],[ac_cv_func_CreateSemaphoreA=no]) ]) if test "x$ac_cv_func_CreateSemaphoreA" = xyes; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_CREATESEMAPHOREA) else AC_MSG_RESULT(no) fi
5c44b02003-03-28Marcus Comstedt  AC_CHECK_FUNCS(CreateSemaphoreA)
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  fi fi AC_SUBST(MYSQL_LIBS) AC_OUTPUT(Makefile,echo FOO >stamp-h )