Commit 674c77e4 authored by Eric J. Korpela's avatar Eric J. Korpela

Added C++ namespace and header checks

svn path=/trunk/boinc/; revision=2777
parent 201a94b6
......@@ -1064,3 +1064,108 @@ AC_SUBST(MYSQL_LIBS)
AC_SUBST(MYSQL_CFLAGS)
])
# SETI_BOINC is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any later
# version.
AC_PREREQ([2.54])
AC_DEFUN([SAH_HEADER_STDCXX],[
save_inc="$ac_includes_default"
ac_includes_default="$ac_includes_default
#define CONFIG_TEST
#include \"lib/std_fixes.h\"
"
sah_stdcxx_headers="algorithm bitset cassert cctype cerrno cfloat climits clocale cmath complex csetjmp csignal cstdarg cstddef cstdio cstdlib cstring ctime deque fstream functional iomanip ios iosfwd iostream istream iterator limits list locale map memory numeric ostream queue set sstream stack stdexcept streambuf string utility valarray vector"
AC_LANG_PUSH(C++)
AC_CHECK_HEADERS([$sah_stdcxx_headers])
for header in $sah_stdcxx_headers
do
eval tmp_var=\$ac_cv_header_${header}
if test "$tmp_var" = "yes"
then
sah_cxx_includes="$sah_cxx_includes
#include <$header>
"
fi
done
AC_CACHE_SAVE
AC_LANG_POP
ac_includes_default="$save_inc"
CONFIG_TEST=
])
# The contents of this file are subject to the BOINC Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://boinc.berkeley.edu/license_1.0.txt
#
# Revision Log:
# $Log$
# Revision 1.55 2003/12/11 18:37:40 korpela
# Added C++ namespace and header checks
#
# Revision 1.5 2003/12/03 23:46:11 korpela
# Fixed "sah_namespaces.m4" not to rely on "tr".
#
#
AC_PREREQ([2.54])
AC_DEFUN([SAH_LC_TO_DEFN],[
$1=`echo $2 | $AWK '{split($[]1,a,"(");print a[[ 1 ]]}' | $as_tr_cpp`
])
AC_DEFUN([SAH_NS_TO_DEFN],[
$1=`echo $2 | $as_tr_cpp`
])
AC_DEFUN([SAH_CHECK_NAMESPACES],[
AC_LANG_PUSH(C++)
AC_MSG_CHECKING(for C++ namespaces)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#define CONFIG_TEST
namespace foo {
int foo(void) { return(0); }
}
],[
return foo::foo();
])
], [AC_DEFINE(HAVE_NAMESPACES,[1],[Define if your C++ compiler supports namespaces]) sah_cv_have_namespaces="yes"], [sah_cv_have_namespaces="no"])
AC_MSG_RESULT($sah_cv_have_namespaces)
AC_LANG_POP
])
AC_DEFUN([SAH_FUNCS_IN_NAMESPACE],[
AC_LANG_PUSH(C++)
for func_name in $1
do
func_name=m4_quote($func_name)
t_ns=m4_quote($2)
AC_MSG_CHECKING([$func_name in namespace $t_ns])
SAH_LC_TO_DEFN(ac_func_upper,[$func_name])
SAH_LC_TO_DEFN(ac_namespace_upper,[$t_ns])
ac_uc_defn=`echo HAVE_"$ac_namespace_upper"_$ac_func_upper`
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#define CONFIG_TEST
$sah_cxx_includes
]],
[[
$2::$func_name ;
]])],
[AC_DEFINE_UNQUOTED([$ac_uc_defn], [1],
["Define to 1 if $func_name is in namespace $t_ns::" ] ) tmp_res=yes],
[tmp_res=no])
eval sah_cv_func_$2_$ac_func_upper=$tmp_res
AC_MSG_RESULT($tmp_res)
done
AC_LANG_POP
])
......@@ -8344,9 +8344,16 @@ Eric K. 12/11/2003
Added check for strlcpy() to configure.ac and definition of
strlcpy() to std_fixes.h.
Added C++ header and namespace checks to m4 and config.h
Added include of "std_fixes.h" to boinc_db.C
aclocal.m4
configure.ac
configure
config.h
config.h.in
lib/std_fixes.h
m4/sah_namespace.m4
m4/sah_header_stdcxx.m4
......@@ -84,9 +84,6 @@
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <map> header file. */
#undef HAVE_MAP
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
......@@ -105,6 +102,9 @@
/* Define to 1 if you have the `mkdir' function. */
#undef HAVE_MKDIR
/* Define if your C++ compiler supports namespaces */
#undef HAVE_NAMESPACES
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
......@@ -150,6 +150,15 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if max is in namespace std:: */
#undef HAVE_STD_MAX
/* Define to 1 if min is in namespace std:: */
#undef HAVE_STD_MIN
/* Define to 1 if transform is in namespace std:: */
#undef HAVE_STD_TRANSFORM
/* Have strfind */
#undef HAVE_STRFIND
......
#! /bin/sh
# From configure.ac Revision: 1.63 .
# From configure.ac Revision: 1.64 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.57 for BOINC 2.14.
#
......@@ -6527,7 +6527,20 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
for ac_header in map
save_inc="$ac_includes_default"
ac_includes_default="$ac_includes_default
#define CONFIG_TEST
#include \"lib/std_fixes.h\"
"
sah_stdcxx_headers="algorithm bitset cassert cctype cerrno cfloat climits clocale cmath complex csetjmp csignal cstdarg cstddef cstdio cstdlib cstring ctime deque fstream functional iomanip ios iosfwd iostream istream iterator limits list locale map memory numeric ostream queue set sstream stack stdexcept streambuf string utility valarray vector"
ac_ext=cc
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
for ac_header in $sah_stdcxx_headers
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
......@@ -6668,6 +6681,229 @@ fi
done
for header in $sah_stdcxx_headers
do
eval tmp_var=\$ac_cv_header_${header}
if test "$tmp_var" = "yes"
then
sah_cxx_includes="$sah_cxx_includes
#include <$header>
"
fi
done
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems. If it contains results you don't
# want to keep, you may remove or edit it.
#
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
# `ac_cv_env_foo' variables (set or unset) will be overridden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.
_ACEOF
# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, don't put newlines in cache variables' values.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
{
(set) 2>&1 |
case `(ac_space=' '; set | grep ac_space) 2>&1` in
*ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote
# substitution turns \\\\ into \\, and sed turns \\ into \).
sed -n \
"s/'/'\\\\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
;;
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n \
"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
;;
esac;
} |
sed '
t clear
: clear
s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
t end
/^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
: end' >>confcache
if diff $cache_file confcache >/dev/null 2>&1; then :; else
if test -w $cache_file; then
test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
cat confcache >$cache_file
else
echo "not updating unwritable cache $cache_file"
fi
fi
rm -f confcache
ac_ext=cc
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
ac_includes_default="$save_inc"
CONFIG_TEST=
ac_ext=cc
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
echo "$as_me:$LINENO: checking for C++ namespaces" >&5
echo $ECHO_N "checking for C++ namespaces... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#define CONFIG_TEST
namespace foo {
int foo(void) { return(0); }
}
int
main ()
{
return foo::foo();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_NAMESPACES 1
_ACEOF
sah_cv_have_namespaces="yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
sah_cv_have_namespaces="no"
fi
rm -f conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $sah_cv_have_namespaces" >&5
echo "${ECHO_T}$sah_cv_have_namespaces" >&6
ac_ext=cc
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
ac_ext=cc
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
for func_name in 'min(0,0)' 'max(0,0)' 'transform((char *)0,(char *)
0,(char *)0,(int(*)(int))malloc)'
do
func_name=$func_name
t_ns=std
echo "$as_me:$LINENO: checking $func_name in namespace $t_ns" >&5
echo $ECHO_N "checking $func_name in namespace $t_ns... $ECHO_C" >&6
ac_func_upper=`echo $func_name | $AWK '{split($1,a,"(");print a[ 1 ]}' | $as_tr_cpp`
ac_namespace_upper=`echo $t_ns | $AWK '{split($1,a,"(");print a[ 1 ]}' | $as_tr_cpp`
ac_uc_defn=`echo HAVE_"$ac_namespace_upper"_$ac_func_upper`
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#define CONFIG_TEST
$sah_cxx_includes
int
main ()
{
std::$func_name ;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
cat >>confdefs.h <<_ACEOF
#define $ac_uc_defn 1
_ACEOF
tmp_res=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
tmp_res=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
eval sah_cv_func_std_$ac_func_upper=$tmp_res
echo "$as_me:$LINENO: result: $tmp_res" >&5
echo "${ECHO_T}$tmp_res" >&6
done
ac_ext=cc
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
......
......@@ -87,7 +87,14 @@ AC_HEADER_TIME
AC_CHECK_HEADERS(arpa/inet.h dirent.h fcntl.h malloc.h netdb.h netinet/in.h netinet/tcp.h signal.h strings.h sys/file.h sys/ipc.h sys/mount.h sys/resource.h sys/select.h sys/shm.h sys/socket.h sys/statvfs.h sys/statfs.h sys/swap.h sys/sysctl.h sys/systeminfo.h sys/time.h sys/types.h sys/utsname.h sys/vmmeter.h sys/wait.h unistd.h)
SAH_GRX_INCLUDES
AC_LANG_PUSH(C++)
AC_CHECK_HEADERS([map])
SAH_HEADER_STDCXX
SAH_CHECK_NAMESPACES
AH_TEMPLATE([HAVE_STD_MIN],[Define to 1 if min is in namespace std::])
AH_TEMPLATE([HAVE_STD_MAX],[Define to 1 if max is in namespace std::])
AH_TEMPLATE([HAVE_STD_TRANSFORM],[Define to 1 if transform is in namespace std::
])
SAH_FUNCS_IN_NAMESPACE([['min(0,0)'] ['max(0,0)'] ['transform((char *)0,(char *)
0,(char *)0,(int(*)(int))malloc)']],std)
AC_LANG_POP
dnl TODO: use compiler to test these; there probably exists an autoconf macro already!
case "$target" in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment