################################################################################
## Process this file with autoconf to produce a configure script. ##
################################################################################
################################################################################
## ##
## File - configure.ac ##
## ##
## Copyright (C) 2003 D.H.McKay ##
## Mr_ET
##
## ##
################################################################################
################################################################################
## ##
## This program has been released under the GNU General Public License ##
## Version 2 as defined in the file COPYING. You may redistribute it ##
## and/or modify it under these terms or at your option using this or any ##
## later version of the GPL. ##
## ##
################################################################################
#
# sn_FUNC_SNPRINTF
#
# checks for a working snprintf function
# if not found sets NEED_SNPRINTF and LIBOBJ(snprintf)
#
AN_FUNCTION([snprintf],[sn_FUNC_SNPRINTF])
AC_DEFUN([sn_FUNC_SNPRINTF],
[ AC_CHECK_TYPE([long long],AC_DEFINE_UNQUOTED(SNPRINTF_LONGLONG_SUPPORT,[1],
[define to 1 if your system has long long int defined]),,)
AC_CACHE_CHECK([for working snprintf], sn_cv_func_snprintf,
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[#include ],
[[
#define S1 "foo"
#define S1_LEN ( sizeof(S1) - 1 )
#define S2 "bar"
#define S2_LEN ( sizeof(S2) - 1 )
#define S_LEN ( S1_LEN + S2_LEN )
char s[10];
int i = snprintf(s,S_LEN - 2,"%s%s",S1,S2);
if((i != S_LEN)||(s[S_LEN - 3] != '\0'))
exit(i);
exit(0);
]])
],
[sn_cv_func_snprintf=yes],
[sn_cv_func_snprintf=no],
[sn_cv_func_snprintf=no])
])
if test $sn_cv_func_snprintf = no
then
sn_cv_func_snprintf_obj=yes
AC_DEFINE_UNQUOTED(NEED_SNPRINTF,[1],
[defined to 1 if rpl snprintf is needed])
AC_LIBOBJ([snprintf])
else
sn_cv_func_snprintf_obj=no
AC_DEFINE_UNQUOTED(HAVE_SNPRINTF,[1],
[defined to 1 if the system snprintf exists])
fi
])
#
# sn_FUNC_VSNPRINTF
#
# checks for a working vsnprintf function
# if not found sets NEED_VSNPRINTF
# forces check for snprintf
#
AN_FUNCTION([vsnprintf],[sn_FUNC_VSNPRINTF])
AC_DEFUN([sn_FUNC_VSNPRINTF],
[ AC_REQUIRE([sn_FUNC_SNPRINTF])
AC_CACHE_CHECK([for working vsnprintf], sn_cv_func_vsnprintf,
[ if test $sn_cv_func_snprintf = no
then
sn_cv_func_vsnprintf=forced_no
else
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([vsnprintf])],
[sn_cv_func_vsnprintf=yes],
[ sn_cv_func_vsnprintf=no ])
fi
])
test $sn_cv_func_vsnprintf = forced_no && sn_cv_func_vsnprintf=no
if test $sn_cv_func_vsnprintf = no
then
AC_DEFINE_UNQUOTED(NEED_VSNPRINTF,[1],
[defined to 1 if rpl vsnprintf is needed])
if test x$sn_cv_func_snprintf_obj = xno
then
sn_cv_func_snprintf_obj=yes
AC_LIBOBJ([snprintf])
fi
else
AC_DEFINE_UNQUOTED(HAVE_VSNPRINTF,[1],
[defined to 1 if the system vsnprintf exists])
fi
])
#
# sn_FUNC_ASPRINTF
#
# checks for a working asprintf function
# if not found sets NEED_ASPRINTF
# forces check for snprintf
#
AN_FUNCTION([asprintf],[sn_FUNC_ASPRINTF])
AC_DEFUN([sn_FUNC_ASPRINTF],
[ AC_REQUIRE([sn_FUNC_SNPRINTF])
AC_CACHE_CHECK([for working asprintf], sn_cv_func_asprintf,
[ if test $sn_cv_func_snprintf = no
then
sn_cv_func_asprintf=forced_no
else
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([asprintf])],
[sn_cv_func_asprintf=yes],
[ sn_cv_func_asprintf=no ])
fi
])
test $sn_cv_func_asprintf = forced_no && sn_cv_func_asprintf=no
if test $sn_cv_func_asprintf = no
then
AC_DEFINE_UNQUOTED(NEED_ASPRINTF,[1],
[defined to 1 if rpl asprintf is needed])
if test x$sn_cv_func_snprintf_obj = xno
then
sn_cv_func_snprintf_obj=yes
AC_LIBOBJ([snprintf])
fi
else
AC_DEFINE_UNQUOTED(HAVE_ASPRINTF,[1],
[defined to 1 if the system asprintf exists])
fi
])
#
# sn_FUNC_VASPRINTF
#
# checks for a working vasprintf function
# if not found sets NEED_VASPRINTF
# forces check for snprintf
#
AN_FUNCTION([vasprintf],[sn_FUNC_VASPRINTF])
AC_DEFUN([sn_FUNC_VASPRINTF],
[ AC_REQUIRE([sn_FUNC_SNPRINTF])
AC_CACHE_CHECK([for working vasprintf], sn_cv_func_vasprintf,
[ if test $sn_cv_func_snprintf = no
then
sn_cv_func_vasprintf=forced_no
else
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([vasprintf])],
[sn_cv_func_vasprintf=yes],
[ sn_cv_func_vasprintf=no ])
fi
])
test $sn_cv_func_vasprintf = forced_no && sn_cv_func_vasprintf=no
if test $sn_cv_func_vasprintf = no
then
AC_DEFINE_UNQUOTED(NEED_VASPRINTF,[1],
[defined to 1 if rpl vasprintf is needed])
if test x$sn_cv_func_snprintf_obj = xno
then
sn_cv_func_snprintf_obj=yes
AC_LIBOBJ([snprintf])
fi
else
AC_DEFINE_UNQUOTED(HAVE_VASPRINTF,[1],
[defined to 1 if the system vasprintf exists])
fi
])
#
# sn_FUNC_ASNPRINTF
#
# checks for a working asnprintf function
# if not found sets NEED_ASNPRINTF
# forces check for snprintf
#
AN_FUNCTION([asnprintf],[sn_FUNC_ASNPRINTF])
AC_DEFUN([sn_FUNC_ASNPRINTF],
[ AC_REQUIRE([sn_FUNC_SNPRINTF])
AC_CACHE_CHECK([for working asnprintf], sn_cv_func_asnprintf,
[ if test $sn_cv_func_snprintf = no
then
sn_cv_func_asnprintf=forced_no
else
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([asnprintf])],
[sn_cv_func_asnprintf=yes],
[ sn_cv_func_asnprintf=no ])
fi
])
test $sn_cv_func_asnprintf = forced_no && sn_cv_func_asnprintf=no
if test $sn_cv_func_asnprintf = no
then
AC_DEFINE_UNQUOTED(NEED_ASNPRINTF,[1],
[defined to 1 if rpl asnprintf is needed])
if test x$sn_cv_func_snprintf_obj = xno
then
sn_cv_func_snprintf_obj=yes
AC_LIBOBJ([snprintf])
fi
else
AC_DEFINE_UNQUOTED(HAVE_ASNPRINTF,[1],
[defined to 1 if the system asnprintf exists])
fi
])
#
# sn_FUNC_VASNPRINTF
#
# checks for a working vasnprintf function
# if not found sets NEED_VASNPRINTF
# forces check for snprintf
#
AN_FUNCTION([vasnprintf],[sn_FUNC_VASNPRINTF])
AC_DEFUN([sn_FUNC_VASNPRINTF],
[ AC_REQUIRE([sn_FUNC_SNPRINTF])
AC_CACHE_CHECK([for working vasnprintf], sn_cv_func_vasnprintf,
[ if test $sn_cv_func_snprintf = no
then
sn_cv_func_vasnprintf=forced_no
else
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([vasnprintf])],
[sn_cv_func_vasnprintf=yes],
[ sn_cv_func_vasnprintf=no ])
fi
])
test $sn_cv_func_vasnprintf = forced_no && sn_cv_func_vasnprintf=no
if test $sn_cv_func_vasnprintf = no
then
AC_DEFINE_UNQUOTED(NEED_VASNPRINTF,[1],
[defined to 1 if rpl vasnprintf is needed])
if test x$sn_cv_func_snprintf_obj = xno
then
sn_cv_func_snprintf_obj=yes
AC_LIBOBJ([snprintf])
fi
else
AC_DEFINE_UNQUOTED(HAVE_VASNPRINTF,[1],
[defined to 1 if the system vasnprintf exists])
fi
])