[RFC] Use autoconf for (parts of) configuration

Richard Guenther rguenth at tat.physik.uni-tuebingen.de
Mon Aug 19 08:33:17 UTC 2002


Hi!

I'd like to hear opinions to getting rid of config/arch/* and instead use
autoconf to collect equivalent information. A quick try revealed the
attached patch which shoves the compiler feature bits to a set of
configure checks. The patch passes compile & check on gcc-2.95.4 and
gcc-3.1. (The former needs additional patches which I'll send off later)

Any comments, suggestions?

Richard.

--
Richard Guenther <richard.guenther at uni-tuebingen.de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
The GLAME Project: http://www.glame.de/
-------------- next part --------------
diff --minimal -Nru a/r2/configure b/r2/configure
--- a/r2/configure	Mon Aug 19 10:28:48 2002
+++ b/r2/configure	Mon Aug 19 10:28:48 2002
@@ -1695,13 +1695,13 @@
 ### add settings for non-standard behavior
 sub setcharacteristics
 {
-  # if the system does not have the stringstream class, must use workaround
-  add_yesno_define("POOMA_NO_STRINGSTREAM",
-		   $no_stringstream);
+#  # if the system does not have the stringstream class, must use workaround
+#  add_yesno_define("POOMA_NO_STRINGSTREAM",
+#		   $no_stringstream);
 
-  # if the system is missing some of the iostream manipulators, must avoid them
-  add_yesno_define("POOMA_MISSING_IOMANIPS",
-		   $no_complete_iomanips);
+#  # if the system is missing some of the iostream manipulators, must avoid them
+#  add_yesno_define("POOMA_MISSING_IOMANIPS",
+#		   $no_complete_iomanips);
 
   # if the C++ compiler does not allow templated friends, must say so
   add_yesno_define("POOMA_NO_TEMPLATE_FRIENDS",
@@ -1716,34 +1716,34 @@
   add_yesno_define("POOMA_NO_OSTREAM_ITERATOR_1ARG",
 		   $no_ostream_iterator_1arg);
 
-  # if the compiler does not allow definitions of placement delete operations
-  add_yesno_define("POOMA_NO_PLACEMENT_DELETE",
-		   $no_placement_delete);
+#  # if the compiler does not allow definitions of placement delete operations
+#  add_yesno_define("POOMA_NO_PLACEMENT_DELETE",
+#		   $no_placement_delete);
 
   # should we include extra specializations of some things for small dim?
   add_yesno_define("POOMA_SMALL_DIM_SPECIALIZATIONS",
 		   $small_dim_specializations);
 
-  # if the C++ compiler does not allow template parameters to be dependent, 
-  # on others (e.g., template<int D1, int D2=D1, ...>,  must say so
-  add_yesno_define("POOMA_NO_DEPENDENT_TEMPLATE_ARGS",
-		   $no_dependent_templ_args);
+#  # if the C++ compiler does not allow template parameters to be dependent, 
+#  # on others (e.g., template<int D1, int D2=D1, ...>,  must say so
+#  add_yesno_define("POOMA_NO_DEPENDENT_TEMPLATE_ARGS",
+#		   $no_dependent_templ_args);
 
-  # if the C++ library does not have templated complex number class, say so
-  add_yesno_define("POOMA_NO_TEMPLATED_COMPLEX",
-		   $no_templated_complex);
+#  # if the C++ library does not have templated complex number class, say so
+#  add_yesno_define("POOMA_NO_TEMPLATED_COMPLEX",
+#		   $no_templated_complex);
 
-  # if the C++ library does not have complex number class in std::, say so
-  add_yesno_define("POOMA_NO_STD_COMPLEX",
-		   $no_std_complex);
+#  # if the C++ library does not have complex number class in std::, say so
+#  add_yesno_define("POOMA_NO_STD_COMPLEX",
+#		   $no_std_complex);
 
   # if the C++ library has O_BINARY defined
   add_yesno_define("POOMA_HAS_O_BINARY_OPEN_MODE",
                    $o_binary_open_mode);
 
-  # if the C++ library does not have ios_base class in std::, say so
-  add_yesno_define("POOMA_NO_STD_IOSBASE",
-		   $no_std_iosbase);
+#  # if the C++ library does not have ios_base class in std::, say so
+#  add_yesno_define("POOMA_NO_STD_IOSBASE",
+#		   $no_std_iosbase);
 
   # if must include <sys/stat.h> for POSIX file modes, say so
   add_yesno_define("POOMA_INC_SYS_STAT_H_FOR_FILE_MODES",
@@ -2093,6 +2093,8 @@
   print FHEADER "#ifndef POOMA_GENERATED_CONFIG_H\n";
   print FHEADER "#define POOMA_GENERATED_CONFIG_H\n";
   print FHEADER "\n";
+  print FHEADER "#include \"PoomaAutoconf.h\"\n";
+  print FHEADER "\n";
 
   # go through all the defines, and write them out.  First find max length
   # of macro names to get spacing right
@@ -2316,6 +2318,13 @@
   close MFILE;
 }
 
+sub runautoconf
+{
+  chdir("scripts");
+  unlink("config.cache");
+  system("env CXX=$cpp ./configure");
+  chdir("..");
+}
 
 ###########################################################################
 #
@@ -2408,6 +2417,9 @@
 
 ### create dependencies
 writedependfile;
+
+### run autoconfiguration part
+runautoconf;
 
 ### print out final instructions
 printinstructions;
diff --minimal -Nru a/r2/scripts/acconfig.h b/r2/scripts/acconfig.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/r2/scripts/acconfig.h	Mon Aug 19 10:28:48 2002
@@ -0,0 +1,7 @@
+#undef POOMA_NO_STRINGSTREAM
+#undef POOMA_MISSING_IOMANIPS
+#undef POOMA_NO_STD_IOSBASE
+#undef POOMA_NO_STD_COMPLEX
+#undef POOMA_NO_TEMPLATED_COMPLEX
+#undef POOMA_NO_DEPENDENT_TEMPLATE_ARGS
+#undef POOMA_NO_PLACEMENT_DELETE
diff --minimal -Nru a/r2/scripts/configure.in b/r2/scripts/configure.in
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/r2/scripts/configure.in	Mon Aug 19 10:28:48 2002
@@ -0,0 +1,123 @@
+AC_INIT(configure.in)
+AC_CONFIG_HEADER([../lib/$POOMASUITE/PoomaAutoconf.h])
+
+AC_PROG_CXX
+AC_PROG_CXXCPP
+
+AC_LANG_CPLUSPLUS
+
+dnl
+dnl check for IO manipulators
+dnl
+AC_MSG_CHECKING([wether we have complete IO manipulators])
+AC_TRY_COMPILE([
+#include <iostream>
+#include <iomanip>
+], [
+	std::cout << std::left;
+], [
+AC_MSG_RESULT([yes])
+] , [
+AC_MSG_RESULT([no])
+AC_DEFINE(POOMA_MISSING_IOMANIPS)
+])
+
+dnl
+dnl check for std iosbase
+dnl
+AC_MSG_CHECKING([wether we have a standard iosbase class])
+AC_TRY_COMPILE([
+#include <iostream>
+#include <iomanip>
+class Inform;
+inline Inform &operator<<(Inform &o, std::ios_base &(*d)(std::ios_base &))
+{
+}
+], [
+], [
+AC_MSG_RESULT([yes])
+] , [
+AC_MSG_RESULT([no])
+AC_DEFINE(POOMA_NO_STD_IOSBASE)
+])
+
+dnl
+dnl check for stringstream
+dnl
+AC_MSG_CHECKING([wether we have sstream])
+AC_TRY_COMPILE([
+#include <sstream>
+], [
+	std::ostringstream *msg;
+], [
+AC_MSG_RESULT([yes])
+] , [
+AC_MSG_RESULT([no])
+AC_DEFINE(POOMA_NO_STRINGSTREAM)
+])
+
+dnl
+dnl check for complex in std and templated complex
+dnl
+AC_MSG_CHECKING([wether we have a complex inside std])
+AC_TRY_COMPILE([
+#include <complex>
+], [
+	std::complex<double> val;
+], [
+complexok=yes
+AC_MSG_RESULT([yes])
+] , [
+AC_MSG_RESULT([no])
+AC_DEFINE(POOMA_NO_STD_COMPLEX)
+])
+if test x$complexok != xyes; then
+  AC_MSG_CHECKING([wether we have a not-templated complex])
+  AC_TRY_COMPILE([
+  #include <complex>
+  ], [
+	complex<double> val;
+  ], [
+  AC_MSG_RESULT([no])
+  ] , [
+  AC_MSG_RESULT([yes])
+  AC_DEFINE(POOMA_NO_TEMPLATED_COMPLEX)
+  ])
+fi
+
+dnl
+dnl check for dependent template arguments
+dnl
+AC_MSG_CHECKING([wether we support dependent template arguments])
+AC_TRY_COMPILE([
+template <int D1, int D2>
+class Foo;
+template <int D1, int D2=D1>
+class Foo {
+};
+], [
+], [
+AC_MSG_RESULT([yes])
+] , [
+AC_MSG_RESULT([no])
+AC_DEFINE(POOMA_NO_DEPENDENT_TEMPLATE_ARGS)
+])
+
+dnl
+dnl check for placement delete operator support
+dnl
+AC_MSG_CHECKING([wether we support delete operators with placement argument])
+AC_TRY_COMPILE([
+class foo {
+	void operator delete(void *, void *) { }
+};
+], [
+], [
+AC_MSG_RESULT([yes])
+] , [
+AC_MSG_RESULT([no])
+AC_DEFINE(POOMA_NO_PLACEMENT_DELETE)
+])
+
+
+AC_OUTPUT()


More information about the pooma-dev mailing list