AC_DEFUN([CF_ADD_CFLAGS],
[
cf_new_cflags=
cf_new_cppflags=
for cf_add_cflags in $1
do
case $cf_add_cflags in -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) 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
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
])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 ; 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])
if test "$GCC" = yes
then
cat > conftest.$ac_ext <<EOF
int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
EOF
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
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
rm -f conftest*
CFLAGS="$cf_save_CFLAGS"
fi
AC_SUBST(EXTRA_CFLAGS)
])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_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"
LDFLAGS=`echo "$LDFLAGS -Zmt -Zcrtdll" | sed -e "s%-Zexe%%g"`
;;
esac
AC_EXEEXT
AC_OBJEXT
PROG_EXT="$EXEEXT"
AC_SUBST(PROG_EXT)
test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
])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
fi
fi
])