AC_DEFUN([CF_ADD_CFLAGS],
[
cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=
for cf_add_cflags in $1
do
case $cf_fix_cppflags in
no)
case $cf_add_cflags in -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case $cf_add_cflags in
-D*)
cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
test "${cf_add_cflags}" != "${cf_tst_cflags}" \
&& test -z "${cf_tst_cflags}" \
&& cf_fix_cppflags=yes
if test $cf_fix_cppflags = yes ; then
cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
continue
elif test "${cf_tst_cflags}" = "\"'" ; then
cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
continue
fi
;;
esac
case "$CPPFLAGS" in
*$cf_add_cflags) ;;
*) cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
;;
esac
;;
*)
cf_new_cflags="$cf_new_cflags $cf_add_cflags"
;;
esac
;;
yes)
cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
test "${cf_add_cflags}" != "${cf_tst_cflags}" \
&& test -z "${cf_tst_cflags}" \
&& cf_fix_cppflags=no
;;
esac
done
if test -n "$cf_new_cflags" ; then
ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
CFLAGS="$CFLAGS $cf_new_cflags"
fi
if test -n "$cf_new_cppflags" ; then
ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
fi
if test -n "$cf_new_extra_cppflags" ; then
ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
fi
AC_SUBST(EXTRA_CPPFLAGS)
])AC_DEFUN([CF_ANSI_CC_CHECK],
[
AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
cf_cv_ansi_cc=no
cf_save_CFLAGS="$CFLAGS"
cf_save_CPPFLAGS="$CPPFLAGS"
for cf_arg in "-DCC_HAS_PROTOS" \
"" \
-qlanglvl=ansi \
-std1 \
-Ae \
"-Aa -D_HPUX_SOURCE" \
-Xc
do
CF_ADD_CFLAGS($cf_arg)
AC_TRY_COMPILE(
[
choke me
],[
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};],
[cf_cv_ansi_cc="$cf_arg"; break])
done
CFLAGS="$cf_save_CFLAGS"
CPPFLAGS="$cf_save_CPPFLAGS"
])
if test "$cf_cv_ansi_cc" != "no"; then
if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
CF_ADD_CFLAGS($cf_cv_ansi_cc)
else
AC_DEFINE(CC_HAS_PROTOS)
fi
fi
])AC_DEFUN([CF_ANSI_CC_REQD],
[AC_REQUIRE([CF_ANSI_CC_CHECK])
if test "$cf_cv_ansi_cc" = "no"; then
AC_ERROR(
[Your compiler does not appear to recognize prototypes.
You have the following choices:
a. adjust your compiler options
b. get an up-to-date compiler
c. use a wrapper such as unproto])
fi
])AC_DEFUN([CF_ARG_DISABLE],
[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])AC_DEFUN([CF_ARG_OPTION],
[AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
if test "$enableval" != "$5" ; then
ifelse($3,,[ :],[ $3]) ifelse($4,,,[
else
$4])
fi],[enableval=$5 ifelse($4,,,[
$4
]) ])])AC_DEFUN([CF_CHECK_CACHE],
[
if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
ifelse([$1],,[AC_CANONICAL_HOST],[$1])
system_name="$host_os"
else
system_name="`(uname -s -r) 2>/dev/null`"
if test -z "$system_name" ; then
system_name="`(hostname) 2>/dev/null`"
fi
fi
test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
test -z "$system_name" && system_name="$cf_cv_system_name"
test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
if test ".$system_name" != ".$cf_cv_system_name" ; then
AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
AC_ERROR("Please remove config.cache and try again.")
fi
])AC_DEFUN([CF_DISABLE_ECHO],[
AC_MSG_CHECKING(if you want to see long compiling messages)
CF_ARG_DISABLE(echo,
[ --disable-echo display "compiling" commands],
[
ECHO_LT='--silent'
ECHO_LD='@echo linking [$]@;'
RULE_CC=' @echo compiling [$]<'
SHOW_CC=' @echo compiling [$]@'
ECHO_CC='@'
],[
ECHO_LT=''
ECHO_LD=''
RULE_CC=' SHOW_CC=' ECHO_CC=''
])
AC_MSG_RESULT($enableval)
AC_SUBST(ECHO_LT)
AC_SUBST(ECHO_LD)
AC_SUBST(RULE_CC)
AC_SUBST(SHOW_CC)
AC_SUBST(ECHO_CC)
])AC_DEFUN([CF_GCC_ATTRIBUTES],
[
if test "$GCC" = yes
then
cat > conftest.i <<EOF
EOF
if test "$GCC" = yes
then
AC_CHECKING([for $CC __attribute__ directives])
cat > conftest.$ac_ext <<EOF
extern void wow(char *,...) GCC_SCANFLIKE(1,2);
extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
extern void foo(void) GCC_NORETURN;
int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
EOF
for cf_attribute in scanf printf unused noreturn
do
CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
cf_directive="__attribute__(($cf_attribute))"
echo "checking for $CC $cf_directive" 1>&AC_FD_CC
case $cf_attribute in
scanf|printf)
cat >conftest.h <<EOF
EOF
;;
*)
cat >conftest.h <<EOF
EOF
;;
esac
if AC_TRY_EVAL(ac_compile); then
test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
cat conftest.h >>confdefs.h
fi
done
else
fgrep define conftest.i >>confdefs.h
fi
rm -rf conftest*
fi
])AC_DEFUN([CF_GCC_VERSION],[
AC_REQUIRE([AC_PROG_CC])
GCC_VERSION=none
if test "$GCC" = yes ; then
AC_MSG_CHECKING(version of $CC)
GCC_VERSION="`${CC} --version|sed -e '2,$d' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
test -z "$GCC_VERSION" && GCC_VERSION=unknown
AC_MSG_RESULT($GCC_VERSION)
fi
])AC_DEFUN([CF_GCC_WARNINGS],
[
AC_REQUIRE([CF_GCC_VERSION])
CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
cat > conftest.$ac_ext <<EOF
int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
EOF
if test "$INTEL_COMPILER" = yes
then
AC_CHECKING([for $CC warning options])
cf_save_CFLAGS="$CFLAGS"
EXTRA_CFLAGS="-Wall"
for cf_opt in $1 \
wd1419 \
wd1682 \
wd1683 \
wd1684 \
wd193 \
wd279 \
wd593 \
wd810 \
wd869 \
wd981
do
CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
if AC_TRY_EVAL(ac_compile); then
test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
fi
done
CFLAGS="$cf_save_CFLAGS"
elif test "$GCC" = yes
then
AC_CHECKING([for $CC warning options])
cf_save_CFLAGS="$CFLAGS"
EXTRA_CFLAGS="-W -Wall"
cf_warn_CONST=""
test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
for cf_opt in \
Wbad-function-cast \
Wcast-align \
Wcast-qual \
Winline \
Wmissing-declarations \
Wmissing-prototypes \
Wnested-externs \
Wpointer-arith \
Wshadow \
Wstrict-prototypes \
Wundef $cf_warn_CONST $1
do
CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
if AC_TRY_EVAL(ac_compile); then
test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
case $cf_opt in Wcast-qual) CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
;;
Winline) case $GCC_VERSION in
3.3*)
CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
continue;;
esac
;;
esac
EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
fi
done
CFLAGS="$cf_save_CFLAGS"
fi
rm -f conftest*
AC_SUBST(EXTRA_CFLAGS)
])AC_DEFUN([CF_GNU_SOURCE],
[
AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
AC_TRY_COMPILE([make an error
[cf_cv_gnu_source=no],
[cf_save="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
AC_TRY_COMPILE([make an error
[cf_cv_gnu_source=no],
[cf_cv_gnu_source=yes])
CPPFLAGS="$cf_save"
])
])
test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
])AC_DEFUN([CF_INTEL_COMPILER],[
ifelse($2,,INTEL_COMPILER,[$2])=no
if test "$ifelse($1,,[$1],GCC)" = yes ; then
case $host_os in
linux*|gnu*)
AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
AC_TRY_COMPILE([],[
make an error
],[ifelse($2,,INTEL_COMPILER,[$2])=yes
cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
],[])
ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
;;
esac
fi
])AC_DEFUN([CF_MSG_LOG],[
echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
])AC_DEFUN([CF_PATH_SYNTAX],[
case ".[$]$1" in .\[$]\(*\)*|.\'*\'*) ;;
..|./*|.\\*) ;;
.[[a-zA-Z]]:[[\\/]]*) ;;
.\[$]{*prefix}*) eval $1="[$]$1"
case ".[$]$1" in .NONE/*)
$1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%`
;;
esac
;; .NONE/*)
$1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%`
;;
*)
ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2)
;;
esac
])AC_DEFUN([CF_POSIX_C_SOURCE],
[
cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
cf_save_CFLAGS="$CFLAGS"
cf_save_CPPFLAGS="$CPPFLAGS"
CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
CF_MSG_LOG(if the symbol is already defined go no further)
AC_TRY_COMPILE([make an error
[cf_cv_posix_c_source=no],
[cf_want_posix_source=no
case .$cf_POSIX_C_SOURCE in .[[12]]??*) cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
;;
.2) cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
cf_want_posix_source=yes
;;
.*)
cf_want_posix_source=yes
;;
esac
if test "$cf_want_posix_source" = yes ; then
AC_TRY_COMPILE([make an error
cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
fi
CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
CFLAGS="$cf_trim_CFLAGS"
CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
CF_MSG_LOG(if the second compile does not leave our definition intact error)
AC_TRY_COMPILE([make an error
[cf_cv_posix_c_source=no])
CFLAGS="$cf_save_CFLAGS"
CPPFLAGS="$cf_save_CPPFLAGS"
])
])
if test "$cf_cv_posix_c_source" != no ; then
CFLAGS="$cf_trim_CFLAGS"
CPPFLAGS="$cf_trim_CPPFLAGS"
if test "$cf_cv_cc_u_d_options" = yes ; then
cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
sed -e 's/-D/-U/g' -e 's/=[[^ ]]*//g'`
CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
fi
CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
fi
])AC_DEFUN([CF_PROG_CC_U_D],
[
AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
cf_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
AC_TRY_COMPILE([],[
make an undefined-error
#endif
#ifdef D_U_OPTIONS
make a defined-error
#endif
],[
cf_cv_cc_u_d_options=yes],[
cf_cv_cc_u_d_options=no])
CPPFLAGS="$cf_save_CPPFLAGS"
])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
dnl -----------
dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
AC_DEFUN([CF_PROG_EXT],
[
AC_REQUIRE([CF_CHECK_CACHE])
case $cf_cv_system_name in
os2*)
CFLAGS="$CFLAGS -Zmt"
CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
CXXFLAGS="$CXXFLAGS -Zmt"
# autoconf's macro sets -Zexe and suffix both, which conflict:w
LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
ac_cv_exeext=.exe
;;
esac
AC_EXEEXT
AC_OBJEXT
PROG_EXT="$EXEEXT"
AC_SUBST(PROG_EXT)
test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
])define([CF_REMOVE_DEFINE],
[
$1=`echo "$2" | \
sed -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[[ ]]/ /g' \
-e 's/-[[UD]]$3\(=[[^ ]]*\)\?[$]//g'`
])AC_DEFUN([CF_UPPER],
[
$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
])AC_DEFUN([CF_VERBOSE],
[test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
])AC_DEFUN([CF_WITH_INSTALL_PREFIX],
[
AC_MSG_CHECKING(for install-prefix)
AC_ARG_WITH(install-prefix,
[ --with-install-prefix=XXX sets DESTDIR, useful for packaging],
[cf_opt_with_install_prefix=$withval],
[cf_opt_with_install_prefix=${DESTDIR-no}])
AC_MSG_RESULT($cf_opt_with_install_prefix)
if test "$cf_opt_with_install_prefix" != no ; then
CF_PATH_SYNTAX($cf_opt_with_install_prefix)
DESTDIR=$cf_opt_with_install_prefix
fi
AC_SUBST(DESTDIR)
])AC_DEFUN([CF_WITH_WARNINGS],
[
if ( test "$GCC" = yes || test "$GXX" = yes )
then
AC_MSG_CHECKING(if you want to check for gcc warnings)
AC_ARG_WITH(warnings,
[ --with-warnings test: turn on gcc warnings],
[cf_opt_with_warnings=$withval],
[cf_opt_with_warnings=no])
AC_MSG_RESULT($cf_opt_with_warnings)
if test "$cf_opt_with_warnings" != no ; then
CF_GCC_ATTRIBUTES
CF_GCC_WARNINGS([$1])
fi
fi
])AC_DEFUN([CF_XOPEN_SOURCE],[
AC_REQUIRE([CF_PROG_CC_U_D])
cf_XOPEN_SOURCE=ifelse($1,,500,$1)
cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
case $host_os in aix[[45]]*) CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
;;
darwin*) ;;
freebsd*) cf_POSIX_C_SOURCE=200112L
cf_XOPEN_SOURCE=600
CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
;;
hpux*) CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
;;
irix[[56]].*) CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
;;
linux*|gnu*) CF_GNU_SOURCE
;;
mirbsd*) ;;
netbsd*) ;;
openbsd*) ;;
osf[[45]]*) CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
;;
nto-qnx*) CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
;;
sco*) ;;
solaris*) CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
;;
*)
AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
AC_TRY_COMPILE([make an error
[cf_cv_xopen_source=no],
[cf_save="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
AC_TRY_COMPILE([make an error
[cf_cv_xopen_source=no],
[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
CPPFLAGS="$cf_save"
])
])
if test "$cf_cv_xopen_source" != no ; then
CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
test "$cf_cv_cc_u_d_options" = yes && \
CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
fi
CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
;;
esac
])