<commit_before>##
## originally by <NAME> <<EMAIL>>,
## who borrowed ideas from <NAME>.
## then this file was tweaked by <NAME> for libdbi.
## and finally it was ripped out and modified by Markus
## Hoenicka who then used for the libdbi-drivers project
##

dnl AC_SEARCH_LIBS_VAR(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
dnl            [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES [, VAR]]]])
dnl Search for a library defining FUNC, if it's not already available.
dnl If a library is needed, add it to VAR (typically prog_LDADD) but
dnl not to LIBS

AC_DEFUN([AC_SEARCH_LIBS_VAR],
[AC_PREREQ([2.13])
AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
[ac_func_search_save_LIBS="$LIBS"
ac_cv_search_$1="no"
AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
test "$ac_cv_search_$1" = "no" && for i in $2; do
LIBS="-l$i $5 $ac_func_search_save_LIBS"
AC_TRY_LINK_FUNC([$1],
[ac_cv_search_$1="-l$i"
break])
done
LIBS="$ac_func_search_save_LIBS"])
if test "$ac_cv_search_$1" != "no"; then
  test "$ac_cv_search_$1" = "none required" || $6="$$6 $ac_cv_search_$1"
  $3
else :
  $4
fi])

dnl try to get rid of this
AC_DEFUN([AC_FIND_FILE],
[
$3=no
for i in $2; do
	for j in $1; do
		if test -r "$i/$j"; then
			$3=$i
			break 2
		fi
	done
done
])

## DBI

AC_DEFUN([AC_CHECK_DBI],
[
AM_CONDITIONAL(HAVE_DBI, false)
ac_dbi_incdir="no"

# exported variables
DBI_INCLUDE=""

AC_MSG_CHECKING(for libdbi framework)

AC_ARG_WITH(dbi-incdir,
	[  --with-dbi-incdir       Specifies where the libdbi include files are.],
	[  ac_dbi_incdir="$withval" ])

if test "$ac_dbi_incdir" = "no"; then
	AC_CHECK_HEADERS([dbi/dbi.h])
	DBI_INCLUDE=""
else
	DBI_INCLUDE=-I$ac_dbi_incdir
fi
	
AC_SUBST(DBI_INCLUDE)
])

## MYSQL

AC_DEFUN([AC_CHECK_MYSQL],
[
AM_CONDITIONAL(HAVE_MYSQL, false)
ac_mysql="no"
ac_mysql_incdir="no"
ac_mysql_libdir="no"

# exported variables
MYSQL_LIBS=""
MYSQL_LDFLAGS=""
MYSQL_INCLUDE=""
MYSQL_TEST=""

AC_MSG_CHECKING(for MySQL support)

AC_ARG_WITH(mysql,
	[  --with-mysql            Include MySQL support.],
	[  ac_mysql="$withval" ])
AC_ARG_WITH(mysql-incdir,
	[  --with-mysql-incdir     Specifies where the MySQL include files are.],
	[  ac_mysql_incdir="$withval" ])
AC_ARG_WITH(mysql-libdir,
	[  --with-mysql-libdir     Specifies where the MySQL libraries are.],
	[  ac_mysql_libdir="$withval" ])

ac_mysql_threadsafe="NO"
AC_ARG_ENABLE(mysql-threadsafe,
	[  --enable-mysql-threadsafe	  use threadsafe version of libmysqlclient.],
	[  if test "$enable_mysql_threadsafe" = "yes"; then
	       ac_mysql_threadsafe="YES"
	   fi])

if test "$ac_mysql" = "yes"; then
   	AC_MSG_RESULT(yes)
	if test "$ac_mysql_incdir" = "no" || test "$ac_mysql_libdir" = "no"; then
	   	AC_CHECK_PROG([MYSQL_CONFIG], [mysql_config], [yes], [no])
		if test "$MYSQL_CONFIG" = "no"; then
		   AC_MSG_ERROR([cannot auto-configure MySQL without mysql_config])
		fi
	fi

	if test "$ac_mysql_incdir" = "no"; then
		MYSQL_INCLUDE=`mysql_config --include`
	else
		MYSQL_INCLUDE=-I$ac_mysql_incdir
	fi
	if test "$ac_mysql_libdir" = "no"; then
	   	if test "$ac_mysql_threadsafe" = "YES"; then
			MYSQL_LDFLAGS=`mysql_config --libs_r`
		else
			MYSQL_LDFLAGS=`mysql_config --libs`
		fi
	else
		MYSQL_LDFLAGS=-L$ac_mysql_libdir
	fi

	AM_CONDITIONAL(HAVE_MYSQL, true)
	MYSQL_TEST="test_mysql.sh"
	
	AC_SUBST(MYSQL_LIBS)
	AC_SUBST(MYSQL_INCLUDE)
	AC_MSG_CHECKING(for MySQL includes)
	AC_MSG_RESULT($MYSQL_INCLUDE)
	AC_SUBST(MYSQL_LDFLAGS)
	AC_MSG_CHECKING(for MySQL libraries)
	AC_MSG_RESULT($MYSQL_LDFLAGS)
else
	AC_MSG_RESULT(no)
fi
AC_SUBST(MYSQL_TEST)
])

## PGSQL

AC_DEFUN([AC_CHECK_PGSQL],
[
AM_CONDITIONAL(HAVE_PGSQL, false)
ac_pgsql="no"
ac_pgsql_incdir="no"
ac_pgsql_libdir="no"

# exported variables
PGSQL_LIBS=""
PGSQL_LDFLAGS=""
PGSQL_INCLUDE=""
PGSQL_TEST=""

AC_MSG_CHECKING(for PostgreSQL support)

AC_ARG_WITH(pgsql,
	[  --with-pgsql            Include PostgreSQL support.],
	[  ac_pgsql="$withval" ])
AC_ARG_WITH(pgsql-incdir,
	[  --with-pgsql-incdir     Specifies where the PostgreSQL include files are.],
	[  ac_pgsql_incdir="$withval" ])
AC_ARG_WITH(pgsql-libdir,
	[  --with-pgsql-libdir     Specifies where the PostgreSQL libraries are.],
	[  ac_pgsql_libdir="$withval" ])

if test "$ac_pgsql" = "yes"; then
	AC_MSG_RESULT([yes])
	if test "$ac_pgsql_incdir" = "no" || test "$ac_pgsql_libdir" = "no"; then
	   	AC_CHECK_PROG([PG_CONFIG], [pg_config], [yes], [no])
		if test "$PG_CONFIG" = "no"; then
		   AC_MSG_ERROR([cannot auto-configure PostgreSQL without pg_config])
		fi
	fi
	if test "$ac_pgsql_incdir" = "no"; then
		PGSQL_INCLUDE="-I"`pg_config --includedir`
	else
		PGSQL_INCLUDE=-I$ac_mysql_incdir
	fi
	if test "$ac_pgsql_libdir" = "no"; then
		PGSQL_LDFLAGS=`pg_config --libdir`
	else
		PGSQL_LDFLAGS=-L$ac_mysql_libdir<commit_msg>Jans patch for fixing mysql vs. pgsql typos<commit_after>##
## originally by <NAME> <<EMAIL>>,
## who borrowed ideas from <NAME>.
## then this file was tweaked by <NAME> for libdbi.
## and finally it was ripped out and modified by Markus
## Hoenicka who then used for the libdbi-drivers project
##

dnl AC_SEARCH_LIBS_VAR(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
dnl            [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES [, VAR]]]])
dnl Search for a library defining FUNC, if it's not already available.
dnl If a library is needed, add it to VAR (typically prog_LDADD) but
dnl not to LIBS

AC_DEFUN([AC_SEARCH_LIBS_VAR],
[AC_PREREQ([2.13])
AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
[ac_func_search_save_LIBS="$LIBS"
ac_cv_search_$1="no"
AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
test "$ac_cv_search_$1" = "no" && for i in $2; do
LIBS="-l$i $5 $ac_func_search_save_LIBS"
AC_TRY_LINK_FUNC([$1],
[ac_cv_search_$1="-l$i"
break])
done
LIBS="$ac_func_search_save_LIBS"])
if test "$ac_cv_search_$1" != "no"; then
  test "$ac_cv_search_$1" = "none required" || $6="$$6 $ac_cv_search_$1"
  $3
else :
  $4
fi])

dnl try to get rid of this
AC_DEFUN([AC_FIND_FILE],
[
$3=no
for i in $2; do
	for j in $1; do
		if test -r "$i/$j"; then
			$3=$i
			break 2
		fi
	done
done
])

## DBI

AC_DEFUN([AC_CHECK_DBI],
[
AM_CONDITIONAL(HAVE_DBI, false)
ac_dbi_incdir="no"

# exported variables
DBI_INCLUDE=""

AC_MSG_CHECKING(for libdbi framework)

AC_ARG_WITH(dbi-incdir,
	[  --with-dbi-incdir       Specifies where the libdbi include files are.],
	[  ac_dbi_incdir="$withval" ])

if test "$ac_dbi_incdir" = "no"; then
	AC_CHECK_HEADERS([dbi/dbi.h])
	DBI_INCLUDE=""
else
	DBI_INCLUDE=-I$ac_dbi_incdir
fi
	
AC_SUBST(DBI_INCLUDE)
])

## MYSQL

AC_DEFUN([AC_CHECK_MYSQL],
[
AM_CONDITIONAL(HAVE_MYSQL, false)
ac_mysql="no"
ac_mysql_incdir="no"
ac_mysql_libdir="no"

# exported variables
MYSQL_LIBS=""
MYSQL_LDFLAGS=""
MYSQL_INCLUDE=""
MYSQL_TEST=""

AC_MSG_CHECKING(for MySQL support)

AC_ARG_WITH(mysql,
	[  --with-mysql            Include MySQL support.],
	[  ac_mysql="$withval" ])
AC_ARG_WITH(mysql-incdir,
	[  --with-mysql-incdir     Specifies where the MySQL include files are.],
	[  ac_mysql_incdir="$withval" ])
AC_ARG_WITH(mysql-libdir,
	[  --with-mysql-libdir     Specifies where the MySQL libraries are.],
	[  ac_mysql_libdir="$withval" ])

ac_mysql_threadsafe="NO"
AC_ARG_ENABLE(mysql-threadsafe,
	[  --enable-mysql-threadsafe	  use threadsafe version of libmysqlclient.],
	[  if test "$enable_mysql_threadsafe" = "yes"; then
	       ac_mysql_threadsafe="YES"
	   fi])

if test "$ac_mysql" = "yes"; then
   	AC_MSG_RESULT(yes)
	if test "$ac_mysql_incdir" = "no" || test "$ac_mysql_libdir" = "no"; then
	   	AC_CHECK_PROG([MYSQL_CONFIG], [mysql_config], [yes], [no])
		if test "$MYSQL_CONFIG" = "no"; then
		   AC_MSG_ERROR([cannot auto-configure MySQL without mysql_config])
		fi
	fi

	if test "$ac_mysql_incdir" = "no"; then
		MYSQL_INCLUDE=`mysql_config --include`
	else
		MYSQL_INCLUDE=-I$ac_mysql_incdir
	fi
	if test "$ac_mysql_libdir" = "no"; then
	   	if test "$ac_mysql_threadsafe" = "YES"; then
			MYSQL_LDFLAGS=`mysql_config --libs_r`
		else
			MYSQL_LDFLAGS=`mysql_config --libs`
		fi
	else
		MYSQL_LDFLAGS=-L$ac_mysql_libdir
	fi

	AM_CONDITIONAL(HAVE_MYSQL, true)
	MYSQL_TEST="test_mysql.sh"
	
	AC_SUBST(MYSQL_LIBS)
	AC_SUBST(MYSQL_INCLUDE)
	AC_MSG_CHECKING(for MySQL includes)
	AC_MSG_RESULT($MYSQL_INCLUDE)
	AC_SUBST(MYSQL_LDFLAGS)
	AC_MSG_CHECKING(for MySQL libraries)
	AC_MSG_RESULT($MYSQL_LDFLAGS)
else
	AC_MSG_RESULT(no)
fi
AC_SUBST(MYSQL_TEST)
])

## PGSQL

AC_DEFUN([AC_CHECK_PGSQL],
[
AM_CONDITIONAL(HAVE_PGSQL, false)
ac_pgsql="no"
ac_pgsql_incdir="no"
ac_pgsql_libdir="no"

# exported variables
PGSQL_LIBS=""
PGSQL_LDFLAGS=""
PGSQL_INCLUDE=""
PGSQL_TEST=""

AC_MSG_CHECKING(for PostgreSQL support)

AC_ARG_WITH(pgsql,
	[  --with-pgsql            Include PostgreSQL support.],
	[  ac_pgsql="$withval" ])
AC_ARG_WITH(pgsql-incdir,
	[  --with-pgsql-incdir     Specifies where the PostgreSQL include files are.],
	[  ac_pgsql_incdir="$withval" ])
AC_ARG_WITH(pgsql-libdir,
	[  --with-pgsql-libdir     Specifies where the PostgreSQL libraries are.],
	[  ac_pgsql_libdir="$withval" ])

if test "$ac_pgsql" = "yes"; then
	AC_MSG_RESULT([yes])
	if test "$ac_pgsql_incdir" = "no" || test "$ac_pgsql_libdir" = "no"; then
	   	AC_CHECK_PROG([PG_CONFIG], [pg_config], [yes], [no])
		if test "$PG_CONFIG" = "no"; then
		   AC_MSG_ERROR([cannot auto-configure PostgreSQL without pg_config])
		fi
	fi
	if test "$ac_pgsql_incdir" = "no"; then
		PGSQL_INCLUDE="-I"`pg_config --includedir`
	else
		PGSQL_INCLUDE=-I$ac_pgsql_incdir
	fi
	if test "$ac_pgsql_libdir" = "no"; then
		PGSQL_LDFLAGS=`pg_config --libdir`
	else
		PGSQL_LDFLAGS=-L$ac_pgsql_libdir
{'fraction_non_alphanumeric': 0.1374133949191686, 'fraction_numerical': 0.005248792777661138, 'mean_word_length': 5.010725552050473, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1008001', 'n_tokens_mistral': 4149, 'n_tokens_neox': 4020, 'n_words': 810}