freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Introduce autoconf


From: Richard Guenther
Subject: [PATCH] Introduce autoconf
Date: Fri, 10 Jan 2003 22:52:34 +0100 (CET)

Hi!

The following patch is a further reduced introduction of autoconfisciation
of parts of the configuration process. It introduces scripts/configure.ac
(and scripts/configure, if autogenerated files should be in CVS) and
changes the toplevel configure script to write the suite file, the
makefile stub and the pooma configuration header as .in file and pass it
down through a autoconf configure script.

For now some of the compiler feature bits are checked and substituted in
the pooma configuration header.

Tested by configuring and installing on ia32-gnu-linux and configuring
on HP-UX (aCC sucks) and IRIX (CC sucks, too).

Ok?

Richard.


2002Jan10  Richard Guenther <address@hidden>

        * scripts/configure.ac: new.
        configure: generate lib/$suite/suite.mk.in,
        lib/$suite/Makefile.pooma.in and
        lib/$suite/PoomaConfiguration.h.in and from them generate using
        scripts/configure autoconf script the config/$suite.suite.mk,
        lib/$suite/Makefile.pooma-EXT and lib/$suite/PoomaConfiguration.h
        files. Use scripts/configure to check for compiler feature bits.

Index: configure
===================================================================
RCS file: /home/pooma/Repository/r2/configure,v
retrieving revision 1.107
diff -u -u -r1.107 configure
--- configure   8 Jan 2003 23:18:47 -0000       1.107
+++ configure   10 Jan 2003 21:41:33 -0000
@@ -101,7 +101,7 @@
 ###########################################################################

 ### the name of the make program - gmake if available, else make
-if ( system("gmake README") == 0 )
+if ( system("gmake -v >/dev/null 2>&1") == 0 )
   {
      $makecmd         = gmake;
   }
@@ -548,6 +548,9 @@
 ### list of defines that should be surrounded by #ifndef checks
 @protecteddeflist = ();

+### list of autoconfigured #define statements in header
address@hidden = ();
+
 ### list of -D define statements that should go with each compilation
 $defines = "";

@@ -669,6 +672,20 @@
 }


+### adds a define stub that gets substituted by autoconf
+sub add_autoconf_define
+{
+  my ($argstring) = @_;
+  if (not $argstring)
+    {
+      die "Error in add_yesno_define: must supply one arguments.\n";
+    }
+  $argstring .= "address@hidden@";
+  print "  Adding autoconf define string = $argstring.\n" if $dbgprnt;
+  push @autoconfdeflist, $argstring;
+}
+
+
 ### if the second argument is true, add a define to our list of the form
 ### FIRSTARG=POOMA_YES; otherwise, add it as FIRSTARG=POOMA_NO
 ### Same as add_yesno_define, except protected
@@ -829,6 +846,11 @@
   if (scalar @{$arghash{$cppnm}} > 1)
     {
       $cpp = $arghash{$cppnm}[1];
+      # if no link cmd is specified, use $cpp
+      if (scalar @{$arghash{$linknm}} == 0)
+        {
+          $link = $cpp;
+        }
     }
   else
     {
@@ -882,7 +904,7 @@
     {
       $arargs .= " $arghash{$arargnm}[$i]";
     }
-  for $i (2 .. $#{$arghash{$linkargnm}})
+  for $i (1 .. $#{$arghash{$linkargnm}})
     {
       $linkargs .= " $arghash{$linkargnm}[$i]";
     }
@@ -1703,12 +1725,10 @@
 sub setcharacteristics
 {
   # if the system does not have the stringstream class, must use workaround
-  add_yesno_define("POOMA_NO_STRINGSTREAM",
-                  $no_stringstream);
+  add_autoconf_define("POOMA_NO_STRINGSTREAM");

   # if the system is missing some of the iostream manipulators, must avoid them
-  add_yesno_define("POOMA_MISSING_IOMANIPS",
-                  $no_complete_iomanips);
+  add_autoconf_define("POOMA_MISSING_IOMANIPS");

   # if the C++ compiler does not allow templated friends, must say so
   add_yesno_define("POOMA_NO_TEMPLATE_FRIENDS",
@@ -1724,8 +1744,7 @@
                   $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);
+  add_autoconf_define("POOMA_NO_PLACEMENT_DELETE");

   # should we include extra specializations of some things for small dim?
   add_yesno_define("POOMA_SMALL_DIM_SPECIALIZATIONS",
@@ -1733,24 +1752,20 @@

   # 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);
+  add_autoconf_define("POOMA_NO_DEPENDENT_TEMPLATE_ARGS");

   # if the C++ library does not have templated complex number class, say so
-  add_yesno_define("POOMA_NO_TEMPLATED_COMPLEX",
-                  $no_templated_complex);
+  add_autoconf_define("POOMA_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);
+  add_autoconf_define("POOMA_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);
+  add_autoconf_define("POOMA_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",
@@ -1862,11 +1877,11 @@
   # put all the link options together
   my $totlibraries = "$preliblist $midliblist $postliblist";
   my $liblinkargs="$linkshare $totlibraries";
-  my $totlinkargs = "$linkargs $liblinkargs";
+  my $totlinkargs = "$liblinkargs $linkargs";

   # open the suite file and write out a prefix
-  print "Writing suite file $suitefile ...\n";
-  open(FSUITE,">$suitefile") or die "Cannot open $suitefile for write.\n";
+  print "Writing suite file lib/$suite/suite.mk.in ...\n";
+  open(FSUITE,">lib/$suite/suite.mk.in") or die "Cannot open 
lib/$suite/suite.mk.in for write.\n";
   print FSUITE "##########################################################\n";
   print FSUITE "# POOMA suite file for suite: $suite\n";
   print FSUITE "# Created $datestr by $userstr on $hoststr\n";
@@ -2089,8 +2104,8 @@
     }

   # open the output file, and write header
-  print "Writing version info header file $vheader ...\n";
-  open(FHEADER,">$vheader") or die "Cannot open $vheader for write.\n";
+  print "Writing version info header file $vheader.in ...\n";
+  open(FHEADER,">$vheader.in") or die "Cannot open $vheader.in for write.\n";
   print FHEADER "/*******************************************************\n";
   print FHEADER " * POOMA version information file for suite: $suite\n";
   print FHEADER " * Created $datestr by $userstr on $hoststr\n";
@@ -2120,6 +2135,14 @@
       my $spaces = length $symbol;
       $maxmacrolen = $spaces + 1 if $spaces >= $maxmacrolen;
     }
+  foreach $d (@autoconfdeflist)
+    {
+      my $symbol = "";
+      my $value  = "";
+      ($symbol, $value) = split /=/, $d, 2;
+      my $spaces = length $symbol;
+      $maxmacrolen = $spaces + 1 if $spaces >= $maxmacrolen;
+    }

   foreach $d (@deflist)
     {
@@ -2142,6 +2165,16 @@
       print FHEADER "#endif\n\n";
     }

+  foreach $d (@autoconfdeflist)
+    {
+      my $symbol = "";
+      my $value  = "";
+      ($symbol, $value) = split /=/, $d, 2;
+      my $spaces = $maxmacrolen - (length $symbol);
+      print FHEADER "#define $symbol" . " " x $spaces . "$value\n";
+    }
+  print FHEADER "\n";
+
   # finished writing header file
   print FHEADER "#endif\n";
   print FHEADER "\n";
@@ -2203,7 +2236,7 @@
     }

   # put all the link options together
-  my $totlinkargs = "$linkargs $linkshare $preliblist $midliblist 
$postliblist";
+  my $totlinkargs = "$linkshare $preliblist $midliblist $postliblist 
$linkargs";

   # put all the includes together
   my $totinclist = "-I\$(POOMA_LIBDIR)/$versionheaderbase$extensions $inclist";
@@ -2212,8 +2245,8 @@
   my $totdefines = "$defines";

   # open the makefile stub file and write out a prefix
-  print "Writing makefile stub $mfile ...\n";
-  open(MFILE,">$mfile") or die "Cannot open $mfile for write.\n";
+  print "Writing makefile stub lib/$suite/$makefilestub.in ...\n";
+  open(MFILE,">lib/$suite/$makefilestub.in") or die "Cannot open 
lib/$suite/$makefilestub.in for write.\n";
   print MFILE "##########################################################\n";
   print MFILE "# POOMA application makefile stub for suite: $suite\n";
   print MFILE "# Created $datestr by $userstr on $hoststr\n";
@@ -2323,6 +2356,23 @@
   close MFILE;
 }

+sub runautoconf
+{
+  # change to libdir, remove autoconf cache
+  chdir("lib/$suite");
+  unlink("config.cache");
+
+  # run configure
+  system("env CXX=$cpp CXXFLAGS=\"$cppargs\" ../../scripts/configure") == 0
+    or die "Autoconf configuration failed: $?\n";
+
+  # move generated files to their place
+  system("mv -f suite.mk ../../$suitefile");
+  system("mv -f Makefile.pooma $makefilestub$extensions");
+
+  # go back
+  chdir("../../");
+}

 ###########################################################################
 #
@@ -2403,8 +2453,10 @@
 setshared;                      # figure out if a shared lib should be made
 setarchfns;                     # figure out if we enable arch-specific init 
fns

-### write out the suite file, and run 'make dirs' to create the directory
-### where the header file will go
+### create the lib dir to write the following stuff to
+system("mkdir -p lib/$suite");
+
+### write out the suite file
 writesuitefile;

 ### write out the header file with versions information, in the lib dir
@@ -2412,6 +2464,12 @@

 ### write out a makefile stub that other users can include, in the lib dir
 writemakestub;
+
+### run autoconfiguration part
+runautoconf;
+
+### create remaining dirs
+system("$makecmd dirs SUITE=$suite");

 ### create dependencies
 writedependfile;
--- /dev/null   2002-12-29 19:08:32.000000000 +0100
+++ scripts/configure.ac        2003-01-10 21:57:10.000000000 +0100
@@ -0,0 +1,188 @@
+AC_INIT(pooma, 2.4.0)
+
+AC_ARG_VAR(CXX, [C++ compiler])
+AC_ARG_VAR(CXXFLAGS, [C++ compiler flags])
+
+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])
+POOMA_MISSING_IOMANIPS=POOMA_NO
+] , [
+AC_MSG_RESULT([no])
+POOMA_MISSING_IOMANIPS=POOMA_YES
+])
+AC_SUBST(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])
+POOMA_NO_STD_IOSBASE=POOMA_NO
+] , [
+AC_MSG_RESULT([no])
+POOMA_NO_STD_IOSBASE=POOMA_YES
+])
+AC_SUBST(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])
+POOMA_NO_STRINGSTREAM=POOMA_NO
+] , [
+AC_MSG_RESULT([no])
+POOMA_NO_STRINGSTREAM=POOMA_YES
+])
+AC_SUBST(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])
+POOMA_NO_STD_COMPLEX=POOMA_NO
+] , [
+AC_MSG_RESULT([no])
+POOMA_NO_STD_COMPLEX=POOMA_YES
+])
+POOMA_NO_TEMPLATED_COMPLEX=POOMA_NO
+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])
+  POOMA_NO_TEMPLATED_COMPLEX=POOMA_YES
+  ])
+fi
+AC_SUBST(POOMA_NO_STD_COMPLEX)
+AC_SUBST(POOMA_NO_TEMPLATED_COMPLEX)
+
+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])
+POOMA_NO_DEPENDENT_TEMPLATE_ARGS=POOMA_NO
+] , [
+AC_MSG_RESULT([no])
+POOMA_NO_DEPENDENT_TEMPLATE_ARGS=POOMA_YES
+])
+AC_SUBST(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])
+POOMA_NO_PLACEMENT_DELETE=POOMA_NO
+] , [
+AC_MSG_RESULT([no])
+POOMA_NO_PLACEMENT_DELETE=POOMA_YES
+])
+AC_SUBST(POOMA_NO_PLACEMENT_DELETE)
+
+dnl
+dnl check for correct handling of default arguments to specialized
+dnl template functions
+dnl
+AC_MSG_CHECKING([wether we handle default args to template functions correct])
+AC_TRY_COMPILE([
+template <int Dim>
+class Centering {};
+template <int Dim>
+const Centering<Dim> test(int a, int b = 0);
+template <>
+const Centering<1> test<1>(int a, int b);
+], [
+       Centering<1> c = test<1>(1);
+], [
+AC_MSG_RESULT([yes])
+POOMA_NO_TEMPLATEFUNC_DEFAULTARGS=POOMA_NO
+] , [
+AC_MSG_RESULT([no])
+POOMA_NO_TEMPLATEFUNC_DEFAULTARGS=POOMA_YES
+])
+AC_SUBST(POOMA_NO_TEMPLATEFUNC_DEFAULTARGS)
+
+dnl
+dnl check for ios header, use iostream if not
+dnl
+AC_CHECK_HEADER([ios],
+  [POOMA_NO_IOS_HEADER=POOMA_NO],
+  [POOMA_NO_IOS_HEADER=POOMA_YES])
+AC_SUBST(POOMA_NO_IOS_HEADER)
+
+dnl
+dnl check for std::ios_base::fmtflags
+dnl
+AC_MSG_CHECKING([wether we have std::ios_base::fmtflags])
+AC_TRY_COMPILE([
+#include <iostream>
+typedef std::ios_base::fmtflags FmtFlags_t;
+], [
+       FmtFlags_t f;
+], [
+AC_MSG_RESULT([yes])
+POOMA_NO_IOSBASE_FMTFLAGS=POOMA_NO
+] , [
+AC_MSG_RESULT([no])
+POOMA_NO_IOSBASE_FMTFLAGS=POOMA_YES
+])
+AC_SUBST(POOMA_NO_IOSBASE_FMTFLAGS)
+
+AC_OUTPUT(PoomaConfiguration.h suite.mk Makefile.pooma)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]