From b8ebfeeb6ed5b7ab67505f7fba3beaf46ef85a02 Mon Sep 17 00:00:00 2001
From: Claus-Justus Heine <Claus-Justus.Heine@IANS.Uni-Stuttgart.DE>
Date: Thu, 3 May 2007 16:26:28 +0000
Subject: [PATCH] merge init-element-branch -> trunk

---
 AUTHORS                           |  33 +-
 COPYING                           |  23 +-
 MAINTENANCE                       |  55 +--
 Makefile.am                       |  55 +--
 Makefile.am.template              |  13 +-
 NEWS                              |  51 ++-
 README                            | 219 +++++++-----
 README-ALBERTA-1.2                |  25 +-
 configure.ac                      | 545 +++++++++++++++++++++---------
 generate-alberta-automakefiles.sh |   2 +-
 gnu-compat/Makefile.am            |   2 +-
 m4/alberta-check.m4               |  14 +-
 m4/alberta-dims.m4                |  36 +-
 m4/check-package.m4               | 177 ++++++----
 m4/grapeiface.m4                  |   9 +-
 m4/simple-enable-flag.m4          |  35 +-
 16 files changed, 870 insertions(+), 424 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index e57259a..78f7942 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -2,8 +2,6 @@ ALBERTA:   an Adaptive multi Level finite element toolbox using
           Bisectioning refinement and Error control by Residual
           Techniques
 
-http://www.mathematik.uni-freiburg.de/IAM/ALBERTA
-
    authors: Alfred Schmidt
 
             Zentrum fuer Technomathematik
@@ -13,20 +11,31 @@ http://www.mathematik.uni-freiburg.de/IAM/ALBERTA
 
             schmidt@math.uni-bremen.de
 
-            Permanent address:
+            Kunibert G. Siebert
 
-            Institut f"ur Angewandte Mathematik   
-            Albert-Ludwigs-Universit"at Freiburg  
-            Germany                    
+            Institut fuer Mathematik
+            Universitaet Augsburg
+            Universitaetsstr. 14
+            D-86159 Augsburg
+            Germany
 
+            Daniel Koester
+            Institut fuer Mathematik
+            Universitaet Augsburg
+            Universitaetsstr. 14
+            D-86159 Augsburg
+            Germany
 
-            Kunibert G. Siebert
+            Claus-Justus Heine
+            Abteilung f�r Angewandte Mathematik
+            Universit�t Freiburg
+            Hermann-Herder-Stra�e 10
+            79104 Freiburg
+            Germany
 
-            Institut f"ur Angewandte Mathematik   
-            Albert-Ludwigs-Universit"at Freiburg  
-            Germany                               
 
-            kunibert@mathematik.uni-freiburg.de
+          http://www.alberta-fem.de
 
+  (c) by A. Schmidt and K.G. Siebert (1996-2004),
+         D. Koester, C.-J. Heine (2002-2007).
 
-   (c) by A. Schmidt and K.G. Siebert (1996-2001)
diff --git a/COPYING b/COPYING
index 96f60cb..d34bab6 100644
--- a/COPYING
+++ b/COPYING
@@ -2,24 +2,9 @@ ALBERTA:  an Adaptive multi Level finite element toolbox using
           Bisectioning refinement and Error control by Residual
           Techniques for scientific Applications.
 
-   (c) by A. Schmidt and K.G. Siebert (1996-2003)
+   (c) by A. Schmidt and K.G. Siebert (1996-2004),
+          D. Koester, C.-J. Heine (2002-2007).
 
+Until further notice copying is only allowed with explicit
+authorization by one of the authors.
 
-ALBERTA is freely distributed for research and education, 
-but you have to sign a license agreement, enclosed in the
-file
-
-                           license.ps,
-
-or download the license agreement from
-
-    http://www.mathematik.uni-freiburg.de/IAM/ALBERTA/license.html
-
-Please print it and fill it and send TWO COPIES to
-
-                                  ALBERTA
-                    Institut fuer Angewandte Mathematik
-                           Universitaet Freiburg
-                         Hermann-Herder-Strasse 10
-                               79104 Freiburg
-                                  Germany 
diff --git a/MAINTENANCE b/MAINTENANCE
index d23edfa..aff5bde 100644
--- a/MAINTENANCE
+++ b/MAINTENANCE
@@ -13,30 +13,35 @@ The alberta-2.0 package is currently distributed using GNU "autoconf 2.60",
 necessary, a few hints seemed like a good idea. Here is the general
 structure of the alberta2-2.0 packages:
 
-                  __________ alberta/ __________ src/ _______|--- 1d/
-                 /                          \                |--- 2d/ 
-                /                            -- doc/         |--- 3d/
-               /                                             |--- Common/
-              /_____________ demo/ __ src/ _______|--- 1d/   |--- alberta*/
-alberta2-2.0 /                                    |--- 2d/  
-             \                                    |--- 3d/
-              \                                   |--- Common/
-               \                           
-                \__________ alberta_util/ ___ src/
-                 \
-                  \
-                   \_______ add_ons/ ---- GRAPE/ __ mesh/ ____|--- 2d/
-                    \               \                         |--- 3d/
-                     \               \                        |--- Common/
-                      \               \
-	               \               - MESHTV/ ___|--- 1d/
-		        \                           |--- 2d/ 
-		         \                          |--- 3d/
-		          \                         |--- Common/
-                           \
-                            \_ configure.ac and other distribution
-                               files
-
+                  __________ alberta/ __________ src/ ______|--- 1d/
+                 /                         \                |--- 2d/ 
+                /                           -- doc/         |--- 3d/
+               /                                            |--- Nd/
+              /                                             |--- Common/
+             /_____________ demo/ __ src/ _______|--- 1d/   |--- alberta*/
+alberta-2.0 /                                    |--- 2d/  
+            \                                    |--- 3d/
+             \                                   |--- 4d/
+              \                                  |--- 5d/
+               \                                 |--- Common/
+                \                                   
+                 \                           
+                  \__________ alberta_util/ ___ src/
+                   \
+                    \
+                     \_______ add_ons/ ---- grape/ __ mesh/ ____|--- 2d/
+                      \               \                         |--- 3d/
+                       \               \                        |--- Common/
+                        \               \
+	                 \               - meshtv/ ___|--- 1d/
+		          \               \           |--- 2d/ 
+		           \               \          |--- 3d/
+		            \               \         |--- Common/
+                             \               \
+                              \               \- geomview/
+                               \
+                                \_ configure.ac and other distribution
+                                   files
 
 We keep track of the "Makefile.am"s, which are processed by automake
 to create "Makefile.in"s. Two exceptions:
@@ -235,6 +240,8 @@ which runs the steps 4.)-5.).
 VI) Possible problems and tested platforms
 ==========================================
 
+OUT OF DATE, probably.
+
 Some things are already explained in "configure.ac". If not explicitly
 stated otherwise below, "configure" will run without extra command
 line options.
diff --git a/Makefile.am b/Makefile.am
index 16a1334..6037d95 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@ SUBDIRS = gnu-compat alberta_util alberta add_ons
 
 ACLOCAL_AMFLAGS  = -I ./m4
 
-# EXTRA_DIST = demo
+EXTRA_DIST = gen-assemble-fcts.sh
 
 #
 # install the libtool-script in the libexecdir s.t. Makefile.alberta
@@ -10,10 +10,9 @@ ACLOCAL_AMFLAGS  = -I ./m4
 #
 
 if INSTALL_LIBTOOL
-BUILT_SOURCES = libtool.alberta2
-libexec_SCRIPTS = libtool.@PACKAGE@
-libtool.@PACKAGE@: libtool
-	cp libtool libtool.@PACKAGE@
+BUILT_SOURCES = libtool
+pkglibexecdir = @libexecdir@/@PACKAGE@
+pkglibexec_SCRIPTS = libtool
 endif
 
 #
@@ -32,7 +31,7 @@ uninstall_code:
 # make a DEMO tar-ball and install it in pkgdatadir for later use
 #
 
-DEMO = @PACKAGE_NAME@-demo
+DEMO = @PACKAGE_NAME@-@VERSION@-demo
 pkgdata_DATA = $(DEMO).tar.gz
 
 demo-tarball: $(DEMO).tar.gz
@@ -40,21 +39,36 @@ demo-tarball: $(DEMO).tar.gz
 $(DEMO).tar.gz: $(DEMO)
 	$(TAR_PROGRAM) cf - $(DEMO) | $(GZIP_PROGRAM) -9 > $@
 
+demo: $(wildcard $(srcdir)/demo/src/Common/*.[ch]) $(top_builddir)/config.status
+	echo $?
+	@case '$?' in \
+	  *config.status*) \
+	    echo ' $(SHELL) ./config.status'; \
+	    $(SHELL) ./config.status;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+	esac;
+
 $(DEMO): demo
-	mkdir $@ ; cd $@ ; \
-	( cd ../demo ; $(TAR_PROGRAM) cf - . ) | $(TAR_PROGRAM) xf -
+	mkdir -p $@
+	$(TAR_PROGRAM) cf - -C $< . | $(TAR_PROGRAM) xf - -C $@
+	find $@ \( -name "*~" -o -name "*.o" \) -exec rm -f \{\} \;
+	for i in `find $@ -name ".svn"`; do rm -rf $$i; done
+	for i in `find $@ -name ".libs"`; do rm -rf $$i; done
 	rm -f $@/src/[0-9]d/Makefile.in
 
 clean-local:
+	-rm -rf $(DEMO)
 	-rm -f  $(DEMO).tar.gz
 
 distclean-local:
-	-rm -f $(BUILT_SOURCES)
-	-chmod -R u+rwX $(DEMO) && rm -rf $(DEMO)
-	-if ! test "$(srcdir)" = "." ; then \
-	    chmod -R u+rwX demo ; \
-            rm -rf demo ; \
-        fi
+	if ! test "$(srcdir)" = "."; then\
+  chmod -R u+rwX demo;\
+  rm -rf demo;\
+fi
+	rm -f libtool.alberta2
+
 
 if MAINTAINER_MODE
 # These targets only makes sense for maintainers!!
@@ -104,12 +118,12 @@ generate-alberta-dist:
 	./generate-alberta-automakefiles.sh
 	autoreconf
 	./configure --enable-maintainer-mode --prefix=@prefix@
-	make dist
+	make distcheck
 
 #
 # The documentation is available as book.
 #
-# EXTRA_DIST = doc/alberta.pdf
+#EXTRA_DIST = doc/alberta.pdf
 
 #
 # this one requires write access to the source directory. One day one might
@@ -119,11 +133,12 @@ generate-alberta-dist:
 #	make -C $(srcdir)/doc/ vclean
 #	make -C $(srcdir)/doc/ alberta.ps
 
-# doc/alberta.pdf:
-# 	make -C $(srcdir)/doc/ vclean
-# 	make -C $(srcdir)/doc/ alberta.pdf
+#doc/alberta.pdf:
+#	make -C $(srcdir)/doc/ vclean
+#	make -C $(srcdir)/doc/ alberta.pdf
+
+#documentation: doc/alberta.pdf
 
-# documentation: doc/alberta.pdf
 
 #dist-hook: documentation
 
diff --git a/Makefile.am.template b/Makefile.am.template
index 58be6a5..22cafd6 100644
--- a/Makefile.am.template
+++ b/Makefile.am.template
@@ -10,14 +10,9 @@ lib_LTLIBRARIES = libalberta2%LIBCODE%.la
 
 include $(srcdir)/../Common/Makefile.am.include
 
-AM_CFLAGS = $(ALBERTA_%EFLAGS%_CFLAGS)
+AM_CFLAGS   = $(ALBERTA_%EFLAGS%_CFLAGS)
+AM_CXXFLAGS = $(ALBERTA_%EFLAGS%_CXXFLAGS)
 
 nodist_libalberta2%LIBCODE%_la_SOURCES = $(sources)
-
-if HAVE_GLTOOLS
-nodist_libalberta2%LIBCODE%_la_SOURCES += ../Common/gltools.c
-endif
-
-if HAVE_DX
-nodist_libalberta2%LIBCODE%_la_SOURCES += ../Common/dxtools.c
-endif
+libalberta2%LIBCODE%_la_CPPFLAGS = \
+ $(CPPFLAGS) -DDIM_OF_WORLD=$(DIM_OF_WORLD) -DALBERTA_DEBUG=$(ALBERTA_DEBUG)
diff --git a/NEWS b/NEWS
index fc6cf4d..76ed0cd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,52 @@
-2003-12-01
-	ALBERTA 1.2 -- not yet released
+2007-01-09
+	ALBERTA-2.0 UNRELEASED
+
+        - easy-to-use (iso-)parametric meshes, up to piecewise polynomial
+          degree of 4
+
+        - parametric meshes for arbitrary co-dimension for 1d/2d/3d meshes
+          (computations on embedded 3-manifolds are now possible, e.g.)
+
+        - periodic meshes; with non-periodic and periodic finite element
+          spaces on the same mesh, definition via geometric or
+          combinatorial face transformations
+
+        - support for non-oriented meshes; affects mainly 2d (think,
+          e.g., of a Klein's bottle or a Moebius-strip)
+
+        - sub-mesh hierarchies, with proper mapping of
+          trace-spaces. Sub-meshes inherit the parametric and/or
+          periodic structures of their master-meshes.
+
+        - get_fe_space() can be called at any time, formerly it had to be
+          called before doing any mesh-refinement.
+
+        - _optional_ per-element intializers for basis functions and
+          quadratures, for extensions which require more complicated stuff
+          than is provided by ALBERTA.
+
+        - fast (i.e. caching) quadratures for faces
+
+        - (a little) improved quadrature rules for 3d
+
+        - extended demo-program suite, with example programs for parametric
+          meshes (iso-parametric, but also higher co-dimension),
+          non-orientable surfaces, stationary Quasi-Stokes with stress
+          boundary conditions, periodic meshes
+
+        - improved GRAPE interface, interfaces to GMV, Silo, Geomview
+          (with varying degree of completeness, usability)
+
+        - global configure-time graphics kill-switch
+          "--disable-graphics".
+
+2004-12-07
+	ALBERTA 1.2.1
+	
+	Bug fixes.
+
+2004-07-30
+	ALBERTA 1.2
 
 	Renamed from ALBERT to ALBERTA (copyright issues)
 
diff --git a/README b/README
index 0e3a43b..2ad38c9 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-  is an Adaptive multi-Level finite element toolbox using 
+ALBERTA  is an Adaptive multi-Level finite element toolbox using 
          Bisectioning refinement and Error control by Residual
          Techniques for scientific Applications.
 
@@ -17,11 +17,11 @@ II.  External Packages (both required and optional packages)
          gltools
          GRAPE
          Silo
-         Open DX 
+         OpenDX 
          alternate compilers
 
 III. Configure Options
-   1.) Non-standard behaviour of ALBERTA
+   1.) Non-standard behavior of ALBERTA
    2.) Options affecting which versions of ALBERTA are built
    3.) Options controlling the search-path for external libraries
 
@@ -44,34 +44,39 @@ at
 Please see the file `COPYING' for information about the availability of
 ALBERTA.
 
-The directory layout 
+The directory layout
 Contained in the package are the following sub-packages:
 
-                  __________ alberta/ __________ src/ _______|--- 1d/
-                 /                          \                |--- 2d/ 
-                /                            -- doc/         |--- 3d/
-               /                                             |--- Common/
-              /_____________ demo/ __ src/ _______|--- 1d/   |--- alberta*/
-alberta2-2.0 /                                    |--- 2d/  
-             \                                    |--- 3d/
-              \                                   |--- Common/
-               \                           
-                \__________ alberta_util/ ___ src/
-                 \
-                  \
-                   \_______ add_ons/ ---- grape/ __ mesh/ ____|--- 2d/
-                    \               \                         |--- 3d/
-                     \               \                        |--- Common/
-                      \               \
-	               \___            - meshtv/ ___|--- 1d/
-		        \                           |--- 2d/ 
-		         \                          |--- 3d/
-		          \                         |--- Common/
-                           \
-                            \_ configure.ac and other distribution
-                               files
-
-1) alberta
+                  __________ alberta/ __________ src/ ______|--- 1d/
+                 /                         \                |--- 2d/ 
+                /                           -- doc/         |--- 3d/
+               /                                            |--- Nd/
+              /                                             |--- Common/
+             /_____________ demo/ __ src/ _______|--- 1d/   |--- alberta*/
+alberta-2.0 /                                    |--- 2d/  
+            \                                    |--- 3d/
+             \                                   |--- 4d/
+              \                                  |--- 5d/
+               \                                 |--- Common/
+                \                                   
+                 \                           
+                  \__________ alberta_util/ ___ src/
+                   \
+                    \
+                     \_______ add_ons/ ---- grape/ __ mesh/ ____|--- 2d/
+                      \               \                         |--- 3d/
+                       \               \                        |--- Common/
+                        \               \
+	                 \               - meshtv/ ___|--- 1d/
+		          \               \           |--- 2d/ 
+		           \               \          |--- 3d/
+		            \               \         |--- Common/
+                             \               \
+                              \               \- geomview/
+                               \
+                                \_ configure.ac and other distribution
+                                   files
+
 The main package.
 
 2) demo
@@ -79,7 +84,7 @@ The sub-directory demo/ contains a few demonstration programs. After
 running "make install" (see file ./INSTALL) a tar-ball containing all
 demo programs will be installed in PREFIX/share/alberta/. The tar-ball
 can be extracted elsewhere; the make-files contained in the tar-ball
-have apropriate defaults for the location of the (installed) ALBERTA
+have appropriate defaults for the location of the (installed) ALBERTA
 libraries and header files.
 
 3) alberta_util
@@ -88,7 +93,7 @@ several smaller source files. As of version 2.0 it also contains the former
 SOLVER library. It is compiled to form a separate utility library 
 (message macros, ALBERTA memory allocation routines, BLAS routines and 
 wrappers, etc.) and should linked to any program using the ALBERTA package. It
-can also be used as a standalone utility library.
+can also be used as a stand-alone utility library.
 
 4) grape
 GRAPE interface for ALBERTA. Only for non-parametric FE of dimension 2
@@ -172,14 +177,14 @@ gltools -- OpenGL toolkit
 	work. "configure" does not check for right version, it's up to
 	yourself.
 
-dxtools -- Open DX toolkit
-	The dxtools are an interface to the Open DX visualization software.
+dxtools -- OpenDX toolkit
+	The dxtools are an interface to the OpenDX visualization software.
 	It may be downloaded from
 
 	http://www.opendx.org/
 
 	The visualization features are far more advanced than gltools, 
-	however Open DX is a huge project that takes time getting used to.
+	however OpenDX is a huge project that takes time getting used to.
 	The dxtools interface was designed to keep things simple and 
 	intuitive.
 	
@@ -194,8 +199,7 @@ GRAPE -- Graphics Programming Environment
 
 	http://www.mathematik.uni-freiburg.de/IAM/Research/grape/GENERAL/
 
-Silo -- 
-	Silo is a library developed at the Lawrence Livermore National
+Silo -- Silo is a library developed at the Lawrence Livermore National
 	Laboratory to handle portable storage of mesh and function data. It
 	serves as an interface to MeshTV, an open source visualization 
 	project also based at the LLNL.
@@ -208,6 +212,25 @@ Silo --
 
 	http://www.llnl.gov/bdiv/meshtv/
 
+GMV --  "General Mesh Viewer" is available from 
+
+        http://www-xdiv.lanl.gov/XCM/gmv/GMVHome.html
+
+        ALBERTA provides a routine "write_mesh_gmv()", which converts
+        the mesh and the finite element functions to a format
+        understood by "gmv". This is just a separate program, no
+        external library needs to be linked in.
+
+Geomview -- An ancient program, originally from the Geometry Center,
+        available from
+
+        http://geomview.sourceforge.net/
+
+        More-or-less easy to use, demo/src/Common/geomview-graphics.c
+        contains an interface from ALBERTA to Geomview. The
+        demo-programs for parametric meshes, especially those for
+        higher co-dimension, can make use of Geomview. geomview-graphics.c
+        does not require any external libraries for linking.
 
 alternate compilers
 	Many CPU-vendors distribute highly optimizing compilers for
@@ -227,7 +250,7 @@ generic command line options for configure.
 The remaining (i.e. ALBERTA specific) options are explained here:
 
 
-1.) Non-standard behaviour of ALBERTA
+1.) Non-standard behavior of ALBERTA
 -------------------------------------
 
 BIG FAT NOTE: the _default_ installation prefix of the ALBERTA-package
@@ -271,26 +294,27 @@ ALBERTA libraries are all named
 
 The options below control which of them are actually created.
 
-  --disable-alberta-1
-	Disable building of an ALBERTA library for Finite Elements of
-	dimension 1. (default: enabled)
-
-  --disable-alberta-2
-	Disable building of an ALBERTA library for Finite Elements of
-	dimension 2. (default: enabled)
-
-  --disable-alberta-3
-	Disable building of an ALBERTA library for Finite Elements of
-	dimension 3. (default: enabled)
-
-  --disable-debug 
-	Disable building of ALBERTA libraries with debugging
-	information. On some systems (or better: with some compilers)
-	optimization and debugging are mutual exclusive, therefore
-	there are separate ALBERTA libraries which are compiled with
-	optimization, but without debugging information, and other
-	versions which are compiled without optimization, but with
-	debugging. (default: enabled)
+  --disable-alberta-1     disable building of an ALBERTA library for Finite
+                          Elements of dimension 1. (default: enabled)
+  --disable-alberta-2     disable building of an ALBERTA library for Finite
+                          Elements of dimension 2. (default: enabled)
+  --disable-alberta-3     disable building of an ALBERTA library for Finite
+                          Elements of dimension 3. (default: enabled)
+  --enable-dim-of-world="DIM1 ... DIMk"
+                          Compile ALBERTA libraries for DIM_OF_WORLD=DIM1,
+                          ..., DIM_OF_WORLD=DIMk. Supported dimensions range
+                          from 4 to 9. Dimensions are separated by spaces.
+                          Note that this does not change the maximal mesh
+                          dimension which remains at 3. The default is NOT to
+                          compile for any dimension > 3.
+  --disable-debug         disable building of ALBERTA libraries with debugging
+                          information. (default: enabled)
+  --disable-graphics      disable support for visualization, including all
+                          add-ons which need graphics. (default: enabled)
+  --enable-efence         use the malloc debugger "Electric Fence" for all
+                          allocations for the DEBUG libraries, the optimized
+                          libraries will still use the default allocators.
+                          (default: disabled)
 
 3.) Options controlling the search-path for external libraries
 --------------------------------------------------------------
@@ -339,17 +363,18 @@ notation (e.g. PREFIX, EPREFIX etc.).
                           "blas"
   --with-blas-lib=DIR     use blas library below directory DIR (default:
                           EPREFIX/lib/)
-  --with-opengl-name=NAME use NAME as the name of the opengl library (without
+  --without-OpenGL        disable use of package OpenGL (default: auto-detect)
+  --with-OpenGL-name=NAME use NAME as the name of the OpenGL library (without
                           leading "lib" prefix and trailing suffix). Default:
                           "GL"
-  --with-opengl-dir=DIR   use opengl library (and headers) below directory DIR
+  --with-OpenGL-dir=DIR   use OpenGL library (and headers) below directory DIR
                           (no default)
-  --with-opengl-lib=DIR   use opengl library below directory DIR (default:
-                          EPREFIX/lib/)
-  --with-opengl-headers=DIR
-                          use opengl include files below directory DIR
-                          (default: PREFIX/include/)
-  --without-gltools       disable use of package gltools (default: autodetect)
+  --with-OpenGL-lib=DIR   use OpenGL library below directory DIR (default:
+                          ${x_libraries})
+  --with-OpenGL-headers=DIR
+                          use OpenGL include files below directory DIR
+                          (default: ${x_includes}/GL -I/usr/include/GL/)
+  --without-gltools       disable use of package gltools (default: auto-detect)
   --with-gltools-name=NAME
                           use NAME as the name of the gltools library (without
                           leading "lib" prefix and trailing suffix). Default:
@@ -361,39 +386,50 @@ notation (e.g. PREFIX, EPREFIX etc.).
   --with-gltools-headers=DIR
                           use gltools include files below directory DIR
                           (default: PREFIX/include/)
-  --without-dx       	  disable use of package dx (default: autodetect)
-  --with-dx-name=NAME
-                          use NAME as the name of the dx library (without
+  --without-OpenDX        disable use of package OpenDX (default: auto-detect)
+  --with-OpenDX-name=NAME use NAME as the name of the OpenDX library (without
                           leading "lib" prefix and trailing suffix). Default:
-                          "dx"
-  --with-dx-dir=DIR       use dx library (and headers) below directory
-                          DIR (no default)
-  --with-dx-lib=DIR       use dx library below directory DIR (default:
+                          "DXL"
+  --with-OpenDX-dir=DIR   use OpenDX library (and headers) below directory DIR
+                          (no default)
+  --with-OpenDX-lib=DIR   use OpenDX library below directory DIR (default:
                           EPREFIX/lib/)
-  --with-dx-headers=DIR
-                          use dx include files below directory DIR
+  --with-OpenDX-headers=DIR
+                          use OpenDX include files below directory DIR
                           (default: PREFIX/include/)
-  --without-grape         disable use of package grape (default: autodetect)
+  --without-grape         disable use of package grape (default: auto-detect)
   --with-grape-name=NAME  use NAME as the name of the grape library (without
                           leading "lib" prefix and trailing suffix). Default:
                           "gr"
   --with-grape-dir=DIR    use grape library (and headers) below directory DIR
                           (no default)
   --with-grape-lib=DIR    use grape library below directory DIR (default:
-                          PREFIX/lib/)
+                          EPREFIX/lib/)
   --with-grape-headers=DIR
                           use grape include files below directory DIR
                           (default: PREFIX/include/)
-
-  --with-silo-dir=DIR	  use Silo library (and headers) below directory DIR
+  --without-silo          disable use of package silo (default: auto-detect)
+  --with-silo-name=NAME   use NAME as the name of the silo library (without
+                          leading "lib" prefix and trailing suffix). Default:
+                          "silo"
+  --with-silo-dir=DIR     use silo library (and headers) below directory DIR
                           (no default)
-  --with-silo-lib=DIR     use Silo library below directory DIR (default:
-                          PREFIX/lib/)
-  --with-silo-headers=DIR
-                          use Silo include files below directory DIR
+  --with-silo-lib=DIR     use silo library below directory DIR (default:
+                          EPREFIX/lib/)
+  --with-silo-headers=DIR use silo include files below directory DIR (default:
+                          PREFIX/include/)
+  --with-efence           enable use of package efence (default: disabled)
+  --with-efence-name=NAME use NAME as the name of the efence library (without
+                          leading "lib" prefix and trailing suffix). Default:
+                          "efence"
+  --with-efence-dir=DIR   use efence library (and headers) below directory DIR
+                          (no default)
+  --with-efence-lib=DIR   use efence library below directory DIR (default:
+                          EPREFIX/lib/)
+  --with-efence-headers=DIR
+                          use efence include files below directory DIR
                           (default: PREFIX/include/)
 
-
 IV. Compiler flags
 ==================
 
@@ -408,12 +444,12 @@ The relevant environment- respectively make-variables are
 CFLAGS
   C-compiler flags used for _both_, optimized and debug enabled libraries
 
-ALBERTA_OPTIMIZE_CFLAGS
-  C-compiler flags used fo the optimized library. They are prepended
+ALBERTA_OPTIMISM_CFLAGS
+  C-compiler flags used for the optimized library. They are prepended
   to the CFLAGS variable.
 
 ALBERTA_DEBUG_CFLAGS
-  C-compiler flags used fo the debug enabled library. They are
+  C-compiler flags used for the debug enabled library. They are
   prepended to the CFLAGS variable.
 
 FFLAGS
@@ -484,7 +520,7 @@ V. Some platform dependent notes and examples
 
 a) SuSE 9.2: We used MesaGL and a BLAS lib included in our
    distribution. If MesaGL is not found, "configure" will also try "GL". The 
-   alberta_util lib needed "-lg2c" to process FORTRAN code properly.
+   alberta_util library needed "-lg2c" to process FORTRAN code properly.
 
 b) SuSE 10.0: More trouble with the FORTRAN compiler. Try running
    F77=gfortran ../configure
@@ -595,13 +631,14 @@ The following switch has been reported to work:
 
 The following location was used for the OpenGL library:
 
-	--with-opengl-lib=/usr/X11R6/lib --with-opengl-headers=/usr/X11R6/include
+	--with-opengl-lib=/usr/X11R6/lib --with-opengl-headers=/usr/X11R6/includ
 
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 PLEASE LEAVE HERE FOR ISPELL:
  LocalWords:  src alberta UTIL ac in's installdir util gltools FE grapeXX SGI's
- LocalWords:  moviXX OpenGL API MesaGL AMD's Athlon Opteron acml movi gcc
+ LocalWords:  moviXX OpenGL API MesaGL AMD's Athlon Opteron acml movi gcc LLNL
  LocalWords:  libtool libalberta PKG GL cxml blas libNAME libPKG dir DIR opengl
- LocalWords:  EPREFIX gr CFLAGS FFLAGS ggdb fno inline pentium sse
- LocalWords:  mfpmath
+ LocalWords:  EPREFIX gr CFLAGS FFLAGS ggdb fno inline pentium sse OpenDX DOF
+ LocalWords:  mfpmath meshtv geomview MeshTV meshtvX dxtools VECS GMV gmv DOWX
+ LocalWords:  ALBERTA's libsunperf sunperf lfui lfsu lsunmath SuSE
diff --git a/README-ALBERTA-1.2 b/README-ALBERTA-1.2
index 211100a..1c62fce 100644
--- a/README-ALBERTA-1.2
+++ b/README-ALBERTA-1.2
@@ -1,15 +1,28 @@
 Main changes from ALBERTA 1.2 -> ALBERTA 2.0
+
 - support of submeshes, DIM constant removed
-- support of parametric meshes
+- support of parametric meshes, piecewise polynomial parameterisations
+  up to degree 4.
+- support for arbitrary co-dimension
+- support for periodic boundary conditions
+- builtin support for Robin boundary conditions
+- easier interface to the saddle point solver
+- estimators now work also for the parametric case and for the case
+  of non-zero co-dimension
+- demo programs for parametric meshes, for periodici meshes, for
+  finite elements on embedded manifolds with non-zero co-dimension
 - more generalized node projection mechanism
 - graphics output interface to GMV
-- some new basis functions available
-- get_fe_space() works at any time
+- graphics output to Geomview (incorporated into the demo-program suite)
+- discontinuous Lagrange basis functions up to degree 2.
+- get_fe_space() works at any time, "even" after mesh refinement
 - INDEX macro only available for ALBERTA_DEBUG=1
 - NEIGH_IN_EL, EL_INDEX macros removed
-- former SOLVER package incorporated into "alberta_util", "PLOT_ANSI" package removed
+- former SOLVER package incorporated into "alberta_util",
+  "PLOT_ANSI" package removed
 - ALBERTA_DEBUG=1 introduces additional safety checks
 - changed "preserve_coarse_dofs" mechanism
-- changed "fe_space" entry in DOF_[DOWB_]MATRIX into a "row_fe_space" and a 
-  "col_fe_space". Fixed issue with dof_compress() and different fe_spaces.
+- changed "fe_space" entry in DOF_[DOWB_,RDR_]MATRIX into a
+  "row_fe_space" and a "col_fe_space".
+  Fixed issue with dof_compress() and different fe_spaces.
 - added a "DOF_PTR_VEC" type.
diff --git a/configure.ac b/configure.ac
index 3687132..b84b5d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,12 +1,14 @@
+
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.59)
-AC_INIT([alberta2], [2.0], [claus@mathematik.uni-freiburg.de,kosterdtp@ewi.uwente.nl])
+AC_INIT([alberta2], [2.0], [Claus.Heine@Mathematik.Uni-Freiburg.DE,kosterdtp@ewi.uwente.nl])
 
 AC_CONFIG_SRCDIR([alberta/src/Common/alberta.h])
 AM_MAINTAINER_MODE
 AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
 
 AC_CONFIG_FILES([Makefile gnu-compat/Makefile
                  alberta_util/Makefile alberta_util/src/Makefile
@@ -22,14 +24,23 @@ AC_CONFIG_FILES([Makefile gnu-compat/Makefile
 		 add_ons/meshtv/2d/Makefile
 		 add_ons/meshtv/3d/Makefile
 		 demo/src/Makefile
-		 demo/src/1d/Makefile demo/src/2d/Makefile demo/src/3d/Makefile
-		 alberta/Makefile alberta/src/Makefile
-		 alberta/src/Common/Makefile alberta/src/Common/Makefile.alberta])
+		 demo/src/1d/Makefile
+		 demo/src/2d/Makefile
+		 demo/src/3d/Makefile
+		 demo/src/4d/Makefile
+		 demo/src/5d/Makefile
+		 alberta/Makefile
+		 alberta/src/Makefile
+		 alberta/src/Common/Makefile
+		 alberta/src/Common/Makefile.alberta
+		 alberta/src/alberta2_Nd/Makefile
+		 alberta/src/alberta2_Nd_debug/Makefile])
 
 AC_CONFIG_COMMANDS([demo],
 [if ! test "$srcdir" = \. ; then
-	AC_MSG_NOTICE([Copying $srcdir/demo sources to current directory])
-	( cd $srcdir && tar cf - demo ) | tar xf -
+    AC_MSG_NOTICE([Copying $srcdir/demo sources to current directory])
+    ( cd $srcdir && tar cf - demo ) | tar xmf -
+    find demo -exec chmod u+rwX \{\} \;
 fi])
 
 #
@@ -50,20 +61,65 @@ else
 		alberta_util/src/alberta_util_inlines.h
 fi])
 
-dnl
-dnl all CONFIG_FILES for the ALBERTA libraries are added through the
-dnl ALBERT_DIMENSION_ENABLE/DISABLE() macros
-dnl
+#
+# all CONFIG_FILES for the ALBERTA libraries are added through the
+# ALBERT_DIMENSION_ENABLE/DISABLE() macros
+#
 
-AM_INIT_AUTOMAKE([1.7])
+AM_INIT_AUTOMAKE([1.7 dist-bzip2])
 AM_CONFIG_HEADER([config.h])
 
 # change the installation directory. This could surely be done more elegantly...
-dnl
-dnl cH: hey, boys and girls, why do we do that?
-dnl
+#
+# cH: hey, boys and girls, why do we do that?
+#
 AC_PREFIX_DEFAULT([`pwd`])
 
+AC_ARG_ENABLE([dim-of-world],
+[AC_HELP_STRING([--enable-dim-of-world="DIM1 ... DIMk"],
+   [Compile ALBERTA libraries for DIM_OF_WORLD=DIM1,
+   ..., DIM_OF_WORLD=DIMk. Supported dimensions range from 4 to 9.
+   Dimensions are separated by spaces.
+   Note that this does not change the maximal mesh dimension which remains
+   at 3. The default is NOT to compile for any dimension > 3.])],
+[case "${enableval}" in
+    no|yes)
+    AC_MSG_ERROR([Option "--enable-dim-of-world" needs an argument])
+      ;;
+    *)
+    for dim in $enableval; do
+      if test "$dim" -gt 9 -o "$dim" -lt 4; then
+	AC_MSG_ERROR([Supported dimensions range from 4 to 9, you specified ${dim}])
+      fi
+      eval BUILD_ALBERTA_${dim}=1
+    done
+    EXTRA_DIMENSIONS="${enableval}"
+      ;;
+esac])
+
+ASSEMBLE_TYPES="
+ M_M_M_M
+ M_M_DM_DM
+ M_M_SCM_SCM
+ DM_DM_DM_DM
+ DM_DM_SCM_SCM
+ SCM_SCM_SCM_SCM"
+ASSEMBLE_FCTS_BASE=assemble_fcts.c
+ASSEMBLE_FCTS=""
+for variant in ${ASSEMBLE_TYPES}; do
+  ASSEMBLE_FCTS="${ASSEMBLE_FCTS} ${variant}_${ASSEMBLE_FCTS_BASE}"
+done
+AC_SUBST(ASSEMBLE_FCTS)
+
+ASSEMBLE_BNDRY_TYPES="M_M M_DM M_SCM DM_DM DM_SCM SCM_SCM"
+ASSEMBLE_BNDRY_FCTS_BASE=assemble_bndry_fcts.c
+ASS_BNDRY_FCTS=""
+for variant in ${ASSEMBLE_BNDRY_TYPES}; do
+  ASS_BNDRY_FCTS="${ASS_BNDRY_FCTS} ${variant}_${ASSEMBLE_BNDRY_FCTS_BASE}"
+done
+ASSEMBLE_BNDRY_FCTS="${ASS_BNDRY_FCTS}"
+AC_SUBST(ASSEMBLE_BNDRY_FCTS)
+
 # Checks for programs.
 AC_PROG_INSTALL
 AC_PROG_LN_S
@@ -73,33 +129,29 @@ AC_ARG_VAR([GZIP_PROGRAM],[name of gzip program])
 AC_ARG_VAR([TAR_PROGRAM],[name of tar program (need _not_ be GNU-tar)])
 
 # Compiler characteristics
-dnl
-dnl ****************************************************************************
-dnl
-dnl First, we zap CFLAGS, FFLAGS and CXXFLAGS (unless explicitly set
-dnl by the user). We then choose -O3 for gcc and -O for all other
-dnl compilers, and no optimization for the debugging library.
-dnl
-dnl NOTE: we use 7 spaces to distinguish a user-override of "" from
-dnl our internal hack. Personally, I'd prefer to leave the fiddling
-dnl with the CFLAGS to the user. Mmmh.
-dnl
-test -z "$CFLAGS" && CFLAGS="       "
-test -z "$FFLAGS" && FFLAGS="       "
-dnl test -z "$CXXFLAGS" && CXXFLAGS="       "
-dnl
-dnl ****************************************************************************
-dnl
-dnl now check for compilers
-dnl
+#
+#
+# now check for compilers
+#
+
+#
+# remember the user override, if any.
+#
+if test "${CFLAGS+set}" = set; then
+    alberta_save_CFLAGS="$CFLAGS"
+fi
+if test "${FFLAGS+set}" = set; then
+    alberta_save_FFLAGS="$FFLAGS"
+fi
 
 AC_PROG_CC
 AC_C_INLINE
+AC_PROG_CPP
 AC_PROG_F77
 
-dnl
-dnl Support for FORTRAN code in ALBERTA
-dnl
+#
+# Support for FORTRAN code in ALBERTA
+#
 
 AC_F77_LIBRARY_LDFLAGS
 AC_F77_FUNC([dnrm2],[DNRM2_F77_FUNC])
@@ -123,83 +175,183 @@ AC_SUBST([DSWAP_F77_FUNC])
 AC_SUBST([DXPAY_F77_FUNC])
 AC_SUBST([DRANDN_F77_FUNC])
 
-dnl
-dnl ****************************************************************************
-dnl
-dnl quick and very dirty hack for icc
-dnl
-if test `basename $CC` = icc; then
-	GCC=yes
-fi
-dnl
-dnl work around a bug in libtool which pulls in the C++ compiler which
-dnl we do not want at the moment. Remove the next two lines when this
-dnl changes!
-dnl
-dnl AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG],[:])
-dnl AC_DEFUN([AC_LIBTOOL_CXX],[:])
+#
+# Debugging. Should come first because if not set we can forget about
+# ALBERTA_DEBUG_CFLAGS
+#
+ALBERTA_ENABLE_FLAG([debug],
+  [disable building of ALBERTA libraries with debugging information.],
+  1,
+  BUILD_DEBUG_LIBS)
 
-dnl *********************** end CXX hack ***************************************
-AC_PROG_LIBTOOL
+################################################################################
+#
+# Set useful default flags for debugging and optimization, but allow
+# for user override.
+#
 
-if test `basename $CC` = icc; then
-	GCC=no
+if test "${BUILD_DEBUG_LIBS}" = "1"; then
+#
+# ****************************************************************************
+#
+# set default debugging flags, but allow for user-override
+#
+    if ! test "${ALBERTA_DEBUG_CFLAGS+set}" = set; then
+	if test "${alberta_save_CFLAGS+set}" = set; then
+	    if test "$GCC" = yes; then
+		ALBERTA_DEBUG_CFLAGS="${alberta_save_CFLAGS} -O0 -ggdb3 -fno-inline -fno-builtin"
+	    else
+		ALBERTA_DEBUG_CFLAGS="${alberta_save_CFLAGS} -g"
+	    fi
+	else # CFLAGS not set, use our defaults.
+	    if test "$GCC" = yes; then
+		ALBERTA_DEBUG_CFLAGS="-Wall -pedantic -std=c99 -O0 -ggdb3 -fno-inline -fno-builtin"
+	    else # use autoconf default
+		ALBERTA_DEBUG_CFLAGS="${CFLAGS}"
+	    fi
+	fi
+    fi
+    AC_ARG_VAR([ALBERTA_DEBUG_CFLAGS],
+	[Compiler-flags used to create the debug-enabled libraries])
+    ALBERTA_ISO_C99_CHECK([${ALBERTA_DEBUG_CFLAGS}])
+
+    if ! test "${ALBERTA_DEBUG_CXXFLAGS+set}" = set; then
+	if test "${alberta_save_CXXFLAGS+set}" = set; then
+	    if test "$GCC" = yes; then
+		ALBERTA_DEBUG_CXXFLAGS="${alberta_save_CXXFLAGS} -fno-rtti -fno-exceptions -O0 -ggdb3 -fno-inline -fno-builtin"
+	    else
+		ALBERTA_DEBUG_CFLAGS="${alberta_save_CXXFLAGS} -g"
+	    fi
+	else # CXXFLAGS not set, use our defaults.
+	    if test "$GCC" = yes; then
+		ALBERTA_DEBUG_CXXFLAGS="-Wall -fno-rtti -fno-exceptions -O0 -ggdb3 -fno-inline -fno-builtin"
+	    else # use autoconf default
+		ALBERTA_DEBUG_CFXXLAGS="${CXXFLAGS}"
+	    fi
+	fi
+    fi
+    AC_ARG_VAR([ALBERTA_DEBUG_CXXFLAGS],
+	[C++ cCompiler-flags used to create the debug-enabled libraries])
 fi
-dnl
-dnl ****************************************************************************
-dnl
-dnl set default debugging flags, but allow for user-override
-dnl
-if test -z "${ALBERTA_DEBUG_CFLAGS}"; then
+
+#
+# ****************************************************************************
+#
+# Set default optimizing flags, but allow for user-override.
+# With gcc, provide basic debugging facilities even with optimized
+# code.
+#
+if ! test "${ALBERTA_OPTIMIZE_CFLAGS+set}" = set; then
+    if test "${alberta_save_CFLAGS+set}" = set; then
+	ALBERTA_OPTIMIZE_CFLAGS="${alberta_save_CFLAGS}"
+    else
 	if test "$GCC" = yes; then
-		ALBERTA_DEBUG_CFLAGS="-Wall -O0 -g3 -ggdb -fno-inline -fno-builtin"
-	else
-		ALBERTA_DEBUG_CFLAGS="-g"
+	    ALBERTA_OPTIMIZE_CFLAGS="-Wall -pedantic -std=c99 -O3"
+	else # use autoconf default
+	    ALBERTA_OPTIMIZE_CFLAGS="${CFLAGS}"
 	fi
+    fi
 fi
-AC_ARG_VAR([ALBERTA_DEBUG_CFLAGS],[Compiler-flags used to create the debug-enabled libraries])
-dnl
-dnl ****************************************************************************
-dnl
-dnl Set default optimizing flags, but allow for user-override.
-dnl With gcc, provide basic debugging facilities even with optimized
-dnl code.
-dnl
-if test -z "${ALBERTA_OPTIMIZE_CFLAGS}"; then
+
+AC_ARG_VAR([ALBERTA_OPTIMIZE_CFLAGS],
+    [C compiler-flags used to create the optimised libraries])
+ALBERTA_ISO_C99_CHECK([${ALBERTA_OPTIMIZE_CFLAGS}])
+
+if ! test "${ALBERTA_OPTIMIZE_CXXFLAGS+set}" = set; then
+    if test "${alberta_save_CXXFLAGS+set}" = set; then
+	ALBERTA_OPTIMIZE_CXXFLAGS="${alberta_save_CXXFLAGS}"
+    else
 	if test "$GCC" = yes; then
-		ALBERTA_OPTIMIZE_CFLAGS="-Wall -O3 -g3 -ggdb"
-	else
-		ALBERTA_OPTIMIZE_CFLAGS="-O"
+	    ALBERTA_OPTIMIZE_CXXFLAGS="-Wall -fno-rtti -fno-exceptions -O3"
+	else # use autoconf defaults
+	    ALBERTA_OPTIMIZE_CXXFLAGS="${CXXFLAGS}"
 	fi
+    fi
 fi
-AC_ARG_VAR([ALBERTA_OPTIMIZE_CFLAGS],[Compiler-flags used to create the optimised libraries])
-if test "${FFLAGS}" = "       "; then
+AC_ARG_VAR([ALBERTA_OPTIMIZE_CXXFLAGS],
+    [C++ compiler-flags used to create the optimised libraries])
+
+if ! test "${ALBERTA_FFLAGS+set}" = set; then
+    if test "${alberta_save_FFLAGS+set}" = set; then
+	ALBERTA_FFLAGS="${alberta_save_FFLAGS}"
+    else
 	if test "$GCC" = yes; then
-		FFLAGS="-O3"
+	    ALBERTA_FFLAGS="${FFLAGS} -O3"
 	else
-		FFLAGS="-O"
+	    ALBERTA_FFLAGS="-O"
 	fi
+    fi
 fi
-dnl if test "${CXXFLAGS}" = "       "; then
-dnl 	if test "$GCC" = yes; then
-dnl 		CXXFLAGS="-O3"
-dnl 	else
-dnl 		CXXFLAGS="-O"
-dnl 	fi
-dnl fi
-dnl
-dnl ****************************************************************************
-dnl
+AC_ARG_VAR([ALBERTA_FFLAGS], [Fortran compiler-flags])
 
-# Checks for libraries.
+#
+# Now set the XXFLAGS to the set of flags we will likely use for the
+# actual build. Later we will zap them.
+#
+CFLAGS="${ALBERTA_OPTIMIZE_CFLAGS}"
+CXXFLAGS="${ALBERTA_OPTIMIZE_CFLAGS}"
+FFLAGS="${ALBERTA_FFLAGS}"
+
+#                                                                              #
+############################### end flags fiddling #############################
+
+# Configure libtool
+AC_PROG_LIBTOOL
+
+# Checks for libraries, headers, functions, declarations ...
+AC_FUNC_OBSTACK
 
-# Replace `main' with a function in -lm:
+# Check for libraries
 AC_CHECK_LIB([m],[main],,
              [AC_MSG_ERROR([no math library, exiting...!])])
 
-AC_CHECK_FUNCS([alarm pow sqrt strdup strchr strstr random srandom],,
+# Check for header files.
+AC_HEADER_STDC
+AC_HEADER_STDBOOL
+AC_CHECK_HEADERS([math.h stdlib.h unistd.h string.h rpc/types.h rpc/xdr.h],,
+                 [AC_MSG_ERROR([Sorry, these are needed..])])
+
+#
+# try to pull in some special features (but make sure to supply
+# replacements if they are not available)
+#
+AC_DEFINE([_XOPEN_SOURCE], 600, [Define to get POSIX and XPG stuff])
+AC_DEFINE([_SVID_SOURCE], 1, [Define to get SVID stuff, e.g. strdup])
+
+#
+# check for some functions we need ... add more as needed.
+#
+AC_CHECK_FUNCS([pow sqrt strdup strchr strstr rand srand xdr_int32_t xdr_int64_t xdr_int],,
 	       [AC_MSG_ERROR([Sorry, these are needed..])])
 
+#
+# check whether we also have declarations for those functions
+#
+AC_CHECK_DECLS([alarm, isfinite, pow, sqrt,
+                strdup, strchr, strstr, rand, srand,
+                xdr_int32_t, xdr_int64_t, xdr_int],,,
+[#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <rpc/types.h>
+#include <rpc/xdr.h>
+#include <math.h>])
+
+#
+# define replacements and prototypes if necessary
+#
+AH_VERBATIM([strdup],
+[/* missing strdup() prototype */
+#if !HAVE_DECL_STRDUP
+extern char *strdup(const char *s);
+#endif])
+
+AH_VERBATIM([isfinite],
+[/* replacement for isfinite() (C99 standard) */
+#if !defined(isfinite) && !HAVE_DECL_ISFINITE
+# define isfinite(a) ((a) == (a))
+#endif])
+
 AC_FUNC_MALLOC
 AC_FUNC_VPRINTF
 
@@ -210,88 +362,138 @@ AC_CHECK_FUNCS([getopt_long],[],
 	GNUCOMPAT_INCLUDE_PATH='$(top_srcdir)/gnu-compat/'])
 AC_SUBST([GNUCOMPAT_INCLUDE_PATH])
 
-# Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS([unistd.h X11/Xlib.h X11/Xutil.h],,
-		 [AC_MSG_ERROR([Exiting...])])
-AC_CHECK_HEADERS([rpc/xdr.h],,[AC_MSG_ERROR([Exiting...])])
-
-# xdr_intXX_t() functions (i.e. processor independent type sizes)
-AC_CHECK_FUNCS([xdr_int32_t xdr_int64_t xdr_int])
-
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_TYPE_SIZE_T
 AC_TYPE_SIGNAL
+AC_CHECK_SIZEOF([long long])
 
-dnl -----------------------
-dnl THESE ARE OUR OWN TESTS
-dnl -----------------------
-dnl
-dnl check for BLAS library. The BLAS may come under different names. We default
-dnl to -lblas, but other possibilities are sunperf, atlas, cxml (Alpha AXP)
-dnl etc etc etc etc etc etc etc etc etc etc ...........................
-dnl
-dnl Let the user decide what it wants (handled by ALBERTA_CHECK_PACKAGE()
-dnl
-ALBERTA_CHECK_PACKAGE(blas, blas, , ${FLIBS},,,,required)
+# Check the size of the (presumably) largest native integer type
+AC_CHECK_SIZEOF(long)
+AC_DEFINE([SIZEOF_DOF_FREE_UNIT],
+  [SIZEOF_LONG],
+  [size of the integer type used for DOF_FREE_UNIT])
 
-dnl
-dnl check for X11
-dnl
-AC_PATH_X
-AC_PATH_XTRA
-X_ALL_LIBS="${X_PRE_LIBS} ${X_LIBS} -lX11 ${X_EXTRA_LIBS}"
-AC_SUBST(X_ALL_LIBS)
+# Check for libltdl
+AC_CHECK_LIB([ltdl],[lt_dlinit])
+AC_CHECK_HEADERS([ltdl.h])
 
-dnl
-dnl check for OpenGL
-dnl
-ALBERTA_CHECK_PACKAGE(opengl, GL, ,${X_ALL_LIBS}, GL/gl.h,,,required)
+# try do define HAVE_STRUCT_SIGACTION_SA_SIGACTION for SIGFPE-handler.
+AC_CHECK_MEMBERS([struct sigaction.sa_sigaction],,,[#include <signal.h>])
 
-dnl
-dnl check for optional package gltools
-dnl
-ALBERTA_CHECK_PACKAGE(gltools, gltools, ,${OPENGL_ALL_LIB} ${X_ALL_LIBS}, glmesh.h,,,optional)
+# -----------------------
+# THESE ARE OUR OWN TESTS
+# -----------------------
+#
+# check for BLAS library. The BLAS may come under different names. We default
+# to -lblas, but other possibilities are sunperf, atlas, cxml (Alpha AXP)
+# etc etc etc etc etc etc etc etc etc etc ...........................
+#
+# Let the user decide what it wants (handled by ALBERTA_CHECK_PACKAGE()
+#
+ALBERTA_CHECK_PACKAGE([blas],[blas],[],[${FLIBS}],[],[],[],[required])
+
+ALBERTA_ENABLE_FLAG([graphics],
+  [disable support for visualization, including all add-ons which need graphics.],
+  1,
+  ALBERTA_USE_GRAPHICS,
+  [SUBST cond define])
+
+if test "${ALBERTA_USE_GRAPHICS}" = 1; then
+
+#
+# check for X11
+#
+    AC_CHECK_HEADERS([X11/Xlib.h X11/Xutil.h],,
+	[AC_MSG_ERROR([Exiting...])])
+
+    AC_PATH_X
+    AC_PATH_XTRA
+    X_ALL_LIBS="${X_PRE_LIBS} ${X_LIBS} -lX11 ${X_EXTRA_LIBS}"
+    AC_SUBST(X_ALL_LIBS)
+else
+#
+# disable the packages, but still run the CHECK_PACKAGE() macros, this
+# way the automake conditionals should still be defined (to false),
+# but the packages will not be used.
+#
+    OPENGL_DISABLE=yes
+    GLTOOLS_DISABLE=yes
+    SILO_DISABLE=yes
+    GRAPE_DISABLE=yes
+    OPENDX_DISABLE=yes
+fi
+
+#
+# check for OpenGL
+#
+ALBERTA_OPENGL_CHECK
+
+#
+# check for optional package gltools
+#
+ALBERTA_GLTOOLS_CHECK
 
 dnl
 dnl check for optional package dx
 dnl
-ALBERTA_CHECK_PACKAGE(dx, DXL, ,-lrt -lDXcallm,dx/dx.h,,,optional)
-
-if test -n "${HAVE_DX_FALSE}"; then
-AC_CHECK_HEADERS([unistd.h errno.h Xm/Xm.h Xm/Form.h Xm/DrawingA.h pthread.h],,
-		 [AC_MSG_ERROR([Sorry, needed for dxtools, exiting...])])
-fi
+ALBERTA_OPENDX_CHECK
 
 dnl
 dnl GRAPE interface stuff
 dnl
 ALBERTA_GRAPE_STUFF
 
-dnl
-dnl MeshTV interface stuff
-dnl
-ALBERTA_CHECK_PACKAGE(silo, silo, ,, silo.h, , ,optional)
+#
+# MeshTV interface stuff
+#
+ALBERTA_CHECK_PACKAGE([silo],[silo],[],[],[silo.h],[],[],[optional])
 
-dnl
-dnl Geomview interface, should not depend on any other installed
-dnl library, just a conversion tool.
-dnl
-AM_CONDITIONAL(GEOMVIEW, false)
+#
+# Geomview interface, should not depend on any other installed
+# library, just a conversion tool.
+#
+AM_CONDITIONAL(GEOMVIEW, true)
 
-dnl
-dnl Debugging
-dnl
+#
+# Whether or not to enable the init_element() stuff. Switching off the
+# init_element() feature will result in a library which is compatible
+# at the binary and API level for standard application, and which is
+# slightly faster because the if-statements testing for the presence
+# of the init_element methods are disabled.
+#
+ALBERTA_ENABLE_FLAG([init-element],
+  [disable support for per-element initializers for basis-functions and
+   quadrature rules.],
+  1,
+  USE_INIT_ELEMENT,
+  [subst cond def])
 
-ALBERTA_ENABLE_FLAG([debug],
-                    [disable building of ALBERTA libraries with debugging information.],
-                    1,
-                    ALBERTA_DEBUG)
+#
+# Malloc debugging
+#
+ALBERTA_ENABLE_FLAG([efence],
+  [use the malloc debugger "Electric Fence" for all allocations for the DEBUG
+   libraries, the optimized libraries will still use the default allocators.],
+  0,
+  ALBERTA_EFENCE)
+test "$ALBERTA_EFENCE" = "1"        && EFENCE_DISABLE=no
+test "${BUILD_ALBERTA_DEBUG}" = "0" && EFENCE_DISABLE=yes
+ALBERTA_CHECK_PACKAGE([efence],[efence],[],[],[efence.h],[],[],
+                      [optional disabled])
+if test "$ALBERTA_EFENCE" = 1 -a -z "$EFENCE_LIB"; then
+	AC_MSG_RESULT(
+["EFence" memory debugger not found or disabled, we will not try to use it.])
+	ALBERTA_EFENCE=0
+fi
+if test "$ALBERTA_EFENCE" = 0 -a -n "$EFENCE_LIB"; then
+    AC_MSG_RESULT([using "Electric Fence" memory debugger for debugging libraries.])
+    ALBERTA_EFENCE=1
+fi
 
-dnl
-dnl Install libtool.alberta for shared libraries?
-dnl
+#
+# Install libtool.alberta for shared libraries?
+#
 ALBERTA_ENABLE_FLAG([install-libtool], [disable installation of libtool.alberta], 1)
 
 # building of all versions is enabled by default, but can be
@@ -306,6 +508,43 @@ ALBERTA_DIMENSION_DISABLE(1)
 ALBERTA_DIMENSION_DISABLE(2)
 ALBERTA_DIMENSION_DISABLE(3)
 
+#
+# Define the necessary conditional unconditionally, so that automake
+# can get hold of the default value.
+#
+ALBERTA_DEFINE_DIMENSION(4)
+ALBERTA_DEFINE_DIMENSION(5)
+ALBERTA_DEFINE_DIMENSION(6)
+ALBERTA_DEFINE_DIMENSION(7)
+ALBERTA_DEFINE_DIMENSION(8)
+ALBERTA_DEFINE_DIMENSION(9)
+AM_CONDITIONAL([ALBERTA_EXTRA_DIMENSIONS], [test -n "${EXTRA_DIMENSIONS}"])
+
+unset CFLAGS
+unset CXXFLAGS
+unset FFLAGS
+
+# remove duplicates
+CPPFLAGS=`for flag in $CPPFLAGS ; do echo $flag ; done | sort | uniq`
+CPPFLAGS=`echo $CPPFLAGS`
+
+if test "z${EXPERIMENTAL}" = "z1"; then
+  AC_MSG_RESULT([])
+  AC_MSG_NOTICE([The following experimental features are enabled:])
+  AC_MSG_RESULT([])
+  for dim in $EXTRA_DIMENSIONS; do
+    AC_MSG_RESULT(build ALBERTA libraries for DIM_OF_WORLD=${dim})
+  done
+  if test "z${PERIODIC_MESHES}" = "z1"; then
+    AC_MSG_RESULT([support for periodic meshes])
+  fi
+  if test "z${BOUNDARY_OPERATORS}" = "z1"; then
+    AC_MSG_RESULT([support for boundary operators])
+  fi
+  AC_MSG_RESULT([])
+fi
+
+
 #
 # flush everything to disk
 #
diff --git a/generate-alberta-automakefiles.sh b/generate-alberta-automakefiles.sh
index 00192b5..623a62b 100755
--- a/generate-alberta-automakefiles.sh
+++ b/generate-alberta-automakefiles.sh
@@ -18,4 +18,4 @@ for ALBERTA_DEBUG in 0 1; do
         mkdir -p alberta/src/alberta2$LIBCODE
 	sed -e "s/%DIM_OF_WORLD%/$DIM_OF_WORLD/g" Makefile.am.template -e "s/%DEBUG%/$DEBUG/g" -e "s/%ALBERTA_DEBUG%/$ALBERTA_DEBUG/g" -e "s/%LIBCODE%/$LIBCODE/g" -e "s/%EFLAGS%/$EFLAGS/g" > alberta/src/alberta2$LIBCODE/Makefile.am
     done
-done
\ No newline at end of file
+done
diff --git a/gnu-compat/Makefile.am b/gnu-compat/Makefile.am
index 47eda57..ceeef2a 100644
--- a/gnu-compat/Makefile.am
+++ b/gnu-compat/Makefile.am
@@ -1,7 +1,7 @@
 EXTRADIST = README COPYING
 
 noinst_LTLIBRARIES = libalbertagnucompat.la
-noinst_HEADERS = getopt.h
+noinst_HEADERS = getopt.h obstack.h
 
 libalbertagnucompat_la_SOURCES = getopt.h dummy.c
 libalbertagnucompat_la_LIBADD = @LTLIBOBJS@
diff --git a/m4/alberta-check.m4 b/m4/alberta-check.m4
index 8a85524..f87340e 100644
--- a/m4/alberta-check.m4
+++ b/m4/alberta-check.m4
@@ -131,10 +131,10 @@ dnl
 dnl Now check for the libraries ALBERTA might depend on. Take into
 dnl account that we might need gltools and OpenGL
 dnl
-ALBERTA_CHECK_PACKAGE(OpenGL, GL, ${x_libraries}, ${X_LIBS} -lX11,
-                     gl.h, ${x_includes}/GL ,, optional)
-ALBERTA_CHECK_PACKAGE(gltools,  gltools,, $OPENGL_LIB,
-                     glwin.h,,, optional)
+ALBERTA_CHECK_PACKAGE([OpenGL],[GL],[${x_libraries}],[${X_LIBS} -lX11],
+                      [gl.h],[${x_includes}/GL],[${X_CFLAGS}],[optional])
+ALBERTA_CHECK_PACKAGE([gltools],[gltools],[],[$OPENGL_LIB],
+                      [glwin.h],[],[],[optional])
 AC_LANG_PUSH(Fortran 77)
 AC_CHECK_LIB(blas, dnrm2,
              [FLIBS="-lblas ${FLIBS}"
@@ -143,7 +143,7 @@ AC_CHECK_LIB(blas, dnrm2,
 AC_LANG_POP(Fortran 77)
 # Cache check-point
 AC_CACHE_SAVE
-ALBERTA_CHECK_PACKAGE(alberta2_util, alberta2_util, $ALBERTA_LIB_PATH, 
-                      -lm ${FLIBS},
-                     alberta_util.h, $ALBERTA_INCLUDE_PATH,, required)
+ALBERTA_CHECK_PACKAGE([alberta2_util],
+                      [alberta2_util],[$ALBERTA_LIB_PATH],[-lm ${FLIBS}],
+                      [alberta_util.h],[$ALBERTA_INCLUDE_PATH],[],[required])
 ])
\ No newline at end of file
diff --git a/m4/alberta-dims.m4 b/m4/alberta-dims.m4
index f99f2e3..7d000fa 100644
--- a/m4/alberta-dims.m4
+++ b/m4/alberta-dims.m4
@@ -5,13 +5,33 @@
 # NOTE: it is a bad idea to remove the unneeded Makefiles from the
 # config-files, it breaks "make distclean"
 #
+# Arguments:
+# $1: dimension (integer value)
+# $2: if given, the default value. The default for the default is 1.
+#
+#
 AC_DEFUN([ALBERTA_DIMENSION_DISABLE],
-[ALBERTA_ENABLE_FLAG([alberta-$1],
-[disable building of an ALBERTA library for Finite Elements of dimension $1.], 1)
-dnl if test "$ALBERTA_$1$1" -eq 1; then
-	AC_CONFIG_FILES([alberta/src/alberta2_$1d/Makefile])
-dnl	if test "$DEBUG" -eq 1; then
-		AC_CONFIG_FILES([alberta/src/alberta2_$1d_debug/Makefile])
-dnl	fi
-dnl fi
+[m4_if($#,2,
+	[m4_define([DEFAULT],[$2])],
+	[m4_define([DEFAULT],[1])])
+m4_if(DEFAULT,1,
+	[ALBERTA_ENABLE_FLAG([alberta-$1],
+		[disable building of an ALBERTA library for Finite Elements of dimension $1.],
+		1, BUILD_ALBERTA_$1)],
+	[ALBERTA_ENABLE_FLAG([alberta-$1],
+		[EXPERIMENTAL: enable building of an ALBERTA library for Finite Elements of dimension $1.],
+		0, BUILD_ALBERTA_$1)])
+m4_if(m4_eval(($1) < 4),1,
+	[AC_CONFIG_FILES([alberta/src/alberta2_$1d/Makefile])
+	 AC_CONFIG_FILES([alberta/src/alberta2_$1d_debug/Makefile])])
 ])
+
+#
+# Set the necessary defines and conditinonals for the given dimension.
+#
+# Arguments:
+# $1 dimension (DIM_OF_WORLD)
+#
+AC_DEFUN([ALBERTA_DEFINE_DIMENSION],
+[AC_SUBST(BUILD_ALBERTA_$1)
+AM_CONDITIONAL(BUILD_ALBERTA_$1, [test "z${BUILD_ALBERTA_$1}" = "z1"])])
diff --git a/m4/check-package.m4 b/m4/check-package.m4
index 284868f..1ee1612 100644
--- a/m4/check-package.m4
+++ b/m4/check-package.m4
@@ -9,34 +9,44 @@ dnl $2: library name (base name, lib$2[.so|.a]
 dnl $3: library path (-L$3)
 dnl $4: additional libraries needed (e.g. -lm -lGL)
 dnl $5: header name
-dnl $6: include path (-I$6)
-dnl $7: package prefix, headers and library below $7/
-dnl $8 \in \{optional, required\}, bail out if required, warning otherwise
+dnl $6: include path for $5 (-I$6)
+dnl $7: additional include paths (e.g. when $5 includes some other headers)
+dnl $8: a space separated list of the keywords
+dnl
+dnl     optional, required, disabled, enabled
+dnl
+dnl     optional: failing to detect the package is not fatal
+dnl     required: configure is terminated when the package is not detected
+dnl               (default)
+dnl     disabled: package is initially disabled and needs the appropriate
+dnl               --with-blah switch, otherwise the package is not checked for
+dnl     enabled:  package is initially enabled (the default)
 dnl
 dnl Default is to check for libraries below $prefix/lib/ and for header-files
 dnl below $prefix/include/
 dnl
 dnl $5 may be empty (e.g. to check for a Fortran library). In this case
-dnl $6 is ignored
-dnl
-dnl $7 may be empty, actually the idea to install libraries and
-dnl headers in the same directory is a little bit awkward.
+dnl $6 and $7 are ignored
 dnl
-dnl This Macro defines the following variables:
+dnl This Macro defines the following variables (UPNAME means a
+dnl canonicalized version of $1: i.e. uppercase and - converted to _)
 dnl
 dnl Makefile-substitution
 dnl
-dnl $1_INCLUDE_PATH
-dnl $1_LIB_PATH                  
-dnl $1_INCLUDE
-dnl $1_LIB       linker flags excluding $4
-dnl $1_ALL_LIB   linker flags including $4
+dnl UPNAME[]_INCLUDE_PATH
+dnl UPNAME[]_LIB_PATH                  
+dnl UPNAME[]_INCLUDE
+dnl UPNAME[]_LIB       linker flags excluding $4
+dnl UPNAME[]_ALL_LIB   linker flags including $4
 dnl
 dnl config.h preprocessor macros
 dnl
 dnl HAVE_LIB$2
 dnl HAVE_$5_H
 dnl
+dnl Automake conditional
+dnl
+dnl AM_CONDITIONAL([HAVE_]UPNAME, [test -n "$[]UPNAME[_LIB]"])
 
 dnl
 dnl Helper-macros
@@ -47,11 +57,20 @@ dnl ALBERTA_CHECK_PKG_OPT(PKGNAME)
 dnl
 AC_DEFUN([ALBERTA_CHECK_PKG_OPT],
 [m4_define([UPNAME], [m4_bpatsubst(m4_toupper([$1]),-,_)])
+m4_if($2,enabled,
+      [m4_define([NEGDEFAULT],[without])
+       m4_define([NEGVERB],[disable])
+       m4_define([DEFAULT],[auto-detect])],
+      [m4_define([NEGDEFAULT],[with])
+       m4_define([NEGVERB],[enable])
+       m4_define([DEFAULT],[disabled])])
 AC_ARG_WITH($1,
-AC_HELP_STRING([--without-$1], [disable use of package $1
-                      (default: autodetect)]),
-	[case "$withval" in
+AC_HELP_STRING(--[]NEGDEFAULT[]-$1,
+[NEGVERB use of package $1 (default: DEFAULT)]),
+	[if test -z "$[]UPNAME[_DISABLE]"; then
+	    case "$withval" in
 		yes)
+			UPNAME[_DISABLE]=no
 			;;
 		no)
 			UPNAME[_DISABLE]=yes
@@ -60,8 +79,13 @@ AC_HELP_STRING([--without-$1], [disable use of package $1
 		*)
 	      AC_MSG_ERROR(["$withval" should have been either "yes" or "no"])
 			  ;;
-	esac],
-	[UPNAME[_DISABLE]=no])
+	    esac
+	fi],
+	[if test -z "$[]UPNAME[_DISABLE]"; then
+		m4_if($2,enabled,
+                      [UPNAME[_DISABLE]=no],
+                      [UPNAME[_DISABLE]=yes])
+	fi])
 ])
 dnl
 dnl ALBERTA_CHECK_PKG_HDR_OPT(PKGNAME, INCLUDEPATH)
@@ -79,10 +103,10 @@ m4_if($2,[],
 	;;
     no) AC_MSG_ERROR("option \"--with-$1-headers\" requires an argument")
 	;;
-    *) UPNAME[_INCLUDE_PATH]=$withval
+    *) UPNAME[_INCLUDE_PATH]="$withval"
 	;;
 esac],
-test -z "${UPNAME[_INCLUDE_PATH]}" && UPNAME[_INCLUDE_PATH]=$DEFAULT_INCDIR)
+test -z "`eval eval eval echo ${UPNAME[_INCLUDE_PATH]}`" && UPNAME[_INCLUDE_PATH]="${DEFAULT_INCDIR}")
 ])
 dnl
 dnl headers and libraries below the same directory :(
@@ -97,8 +121,8 @@ AC_HELP_STRING([--with-$1-dir=DIR],
 	;;
     no) AC_MSG_ERROR("option \"--with-$1-dir\" requires an argument")
 	;;
-    *) UPNAME[_LIB_PATH]=$withval
-       UPNAME[_INCLUDE_PATH]=$withval
+    *) UPNAME[_LIB_PATH]="$withval"
+       UPNAME[_INCLUDE_PATH]="$withval"
 	;;
 esac])
 ])
@@ -107,11 +131,11 @@ dnl the macro itself
 dnl
 AC_DEFUN([ALBERTA_CHECK_PACKAGE],
 [AC_REQUIRE([ALBERTA_SET_PREFIX])
-m4_if($#,
-       8,,[
-errprint([$0] needs EXACTLY eight (8) arguments, but got $#
-)
-m4exit(1)])
+dnl m4_if($#,8,,
+dnl  [m4_if($#,9,,
+dnl     [errprint([$0] needs eight (8) or nine (9) arguments, but got $#
+dnl	)
+dnl      m4exit(1)])])
 dnl
 dnl upcase $1
 dnl
@@ -119,7 +143,19 @@ m4_define([UPNAME], [m4_bpatsubst(m4_toupper([$1]),-,_)])
 dnl
 dnl need to use m4_if, the $i arguments are not shell variables
 dnl
-m4_if($8, optional,[ALBERTA_CHECK_PKG_OPT([$1])])
+m4_define([ENABLED],[enabled])
+m4_define([OPTIONAL],[required])
+m4_if($#,8,[
+  m4_foreach_w([ac_al_lvar],[$8],
+    [m4_if(ac_al_lvar,[disabled],
+           [m4_define([ENABLED],ac_al_lvar)],
+           ac_al_lvar,[enabled],
+           [m4_define([ENABLED],ac_al_lvar)],
+           ac_al_lvar,[optional],
+           [m4_define([OPTIONAL],ac_al_lvar)],
+           ac_al_lvar,[required],
+           [m4_define([OPTIONAL],ac_al_lvar)])])])
+m4_if(OPTIONAL,[optional],[ALBERTA_CHECK_PKG_OPT([$1],[ENABLED])])
 dnl
 dnl bail out if package is completely disabled
 dnl
@@ -127,8 +163,13 @@ if test "${UPNAME[_DISABLE]}" = yes; then
 	:
 else
 
-m4_if($3,[],[DEFAULT_LIBDIR=`eval eval echo ${libdir}`],
-	    [DEFAULT_LIBDIR=$3])
+m4_if($3,[],[DEFAULT_LIBDIR="${libdir}"],
+	    [DEFAULT_LIBDIR="$3"])
+
+if test "${DEFAULT_LIBDIR}" = ''
+then
+	DEFAULT_LIBDIR="'${libdir}'"
+fi
 
 dnl
 dnl Optionally use an alternate name (e.g. MesaGL instead of GL etc.)
@@ -140,12 +181,14 @@ AC_HELP_STRING([--with-$1-name=NAME], [use NAME as the name of the $1 library (w
 	;;
     no) AC_MSG_ERROR("option \"--with-$1-name\" requires an argument")
 	;;
-    *) UPNAME[_NAME]=$withval
+    *) UPNAME[_NAME]="$withval"
 	;;
 esac],
-UPNAME[_NAME]=$2)
+UPNAME[_NAME]="$2")
 dnl
 dnl headers and libraries below the same directory :(
+dnl If we have no header to check for, then this additional option does not
+dnl make sense, hence the m4_if()
 dnl
 m4_if($5,[],[],[ALBERTA_CHECK_PKG_DIR_OPT([$1])])
 dnl
@@ -162,30 +205,30 @@ m4_if($3,[],
 	;;
     no) AC_MSG_ERROR("option \"--with-$1-lib\" requires an argument")
 	;;
-    *) UPNAME[_LIB_PATH]=$withval
+    *) UPNAME[_LIB_PATH]="$withval"
 	;;
 esac],
-test -z "${UPNAME[_LIB_PATH]}" && UPNAME[_LIB_PATH]=$DEFAULT_LIBDIR)
+test -z "`eval eval eval echo ${UPNAME[_LIB_PATH]}`" && UPNAME[_LIB_PATH]="${DEFAULT_LIBDIR}")
 dnl
 dnl now for the header file
 dnl
 m4_if($5,[],[],
-	[m4_if($6,[],[DEFAULT_INCDIR=`eval eval echo ${includedir}`],
-		     [DEFAULT_INCDIR=$6])
-	 ALBERTA_CHECK_PKG_HDR_OPT([$1], [PREFIX/include/])])
+	[m4_if($6,[],[DEFAULT_INCDIR="${includedir}"
+                     ALBERTA_CHECK_PKG_HDR_OPT([$1], [PREFIX/include/])],
+		     [DEFAULT_INCDIR="$6"
+                     ALBERTA_CHECK_PKG_HDR_OPT([$1], [$6/])])])
 dnl
 dnl now check if the library and header files exist
 dnl
-m4_if($8,[optional],
+m4_if(OPTIONAL,[optional],
   [AC_CHECK_LIB(${UPNAME[_NAME]}, main,
     [UPNAME[_LIB]="-L${UPNAME[_LIB_PATH]} -l${UPNAME[_NAME]}"
      UPNAME[_ALL_LIB]="-L${UPNAME[_LIB_PATH]} -l${UPNAME[_NAME]} $4"],
     [UPNAME[_LIB]=""
      UPNAME[_ALL_LIB]=""
      UPNAME[_LIB_PATH]=""
-     UPNAME[_INCLUDE]=""
      UPNAME[_INCLUDE_PATH]=""],
-    -L${UPNAME[_LIB_PATH]} $4)],
+    -L`eval eval eval echo ${UPNAME[_LIB_PATH]}` $4)],
   [AC_CHECK_LIB(${UPNAME[_NAME]}, main,
      [UPNAME[_LIB]="-L${UPNAME[_LIB_PATH]} -l${UPNAME[_NAME]}"
       UPNAME[_ALL_LIB]="-L${UPNAME[_LIB_PATH]} -l${UPNAME[_NAME]} $4"],
@@ -197,7 +240,7 @@ m4_if($8,[optional],
 		AC_MSG_ERROR([Library "lib${UPNAME[_NAME]}" was not found])
 		;;
 	esac],
-     -L$UPNAME[_LIB_PATH] $4)])
+     -L`eval eval eval echo $UPNAME[_LIB_PATH]` `eval eval eval echo $4`)])
 
 dnl
 dnl On MacOS X we have that funky -framework switch ...
@@ -208,21 +251,20 @@ if test "x${UPNAME[_LIB]}" = "x" ; then
   case "$host" in
 	*darwin*)
 	eval "unset ac_cv_lib_${UPNAME[_NAME]}___main"
-m4_if($8,[optional],
+m4_if(OPTIONAL,[optional],
   [AC_CHECK_FRAMEWORK(${UPNAME[_NAME]}, main,
     [UPNAME[_LIB]="-F${UPNAME[_LIB_PATH]} -framework ${UPNAME[_NAME]}"
      UPNAME[_ALL_LIB]="-F${UPNAME[_LIB_PATH]} -framework ${UPNAME[_NAME]} $4"],
     [UPNAME[_LIB]=""
      UPNAME[_ALL_LIB]=""
      UPNAME[_LIB_PATH]=""
-     UPNAME[_INCLUDE]=""
      UPNAME[_INCLUDE_PATH]=""],
-    -F${UPNAME[_LIB_PATH]} $4)],
+    -F`eval eval eval echo ${UPNAME[_LIB_PATH]}` `eval eval eval echo $4`)],
   [AC_CHECK_FRAMEWORK(${UPNAME[_NAME]}, main,
      [UPNAME[_LIB]="-F${UPNAME[_LIB_PATH]} -framework ${UPNAME[_NAME]}"
       UPNAME[_ALL_LIB]="-F${UPNAME[_LIB_PATH]} -framework ${UPNAME[_NAME]} $4"],
      [AC_MSG_ERROR([Framework "${UPNAME[_NAME]}" was not found])],
-     -F$UPNAME[_LIB_PATH] $4)])
+     -F`eval eval eval echo $UPNAME[_LIB_PATH]` `eval eval eval echo $4`)])
 	;;
   esac
 fi
@@ -234,23 +276,33 @@ else
     dnl
     dnl  check for the header file
     dnl
-    [ac_]UPNAME[_save_CPPFLAGS]="$CPPFLAGS"
-    CPPFLAGS="-I${UPNAME[_INCLUDE_PATH]} $CPPFLAGS"
-    m4_if($8,[optional],
-	[AC_CHECK_HEADERS($5,, [UPNAME[_LIB]=""
-			       UPNAME[_ALL_LIB]=""
-			       UPNAME[_INCLUDE]=""
-			       UPNAME[_LIB_PATH]=""
-			       UPNAME[_INCLUDE_PATH]=""])],
-	[AC_CHECK_HEADERS($5,, AC_MSG_ERROR([Header file "$5" was not found]))])
-
-dnl
-dnl no need to use -I... if header is located in standard include path
-dnl
-    if ! test -f "${UPNAME[_INCLUDE_PATH]}/$5"; then
-	UPNAME[_INCLUDE]=""
+    [gv_ac_]UPNAME[_save_CPPFLAGS]="$CPPFLAGS"
+    m4_define([gv_ac_inctemp],[m4_bpatsubst([gv_ac_$5],[[].-[]],_)])
+    unset gv_ac_inctemp
+    for incdir in "${UPNAME[_INCLUDE_PATH]}"; do
+      if test -n "`eval eval eval echo ${incdir}`"; then
+	CPPFLAGS="-I`eval eval eval echo ${incdir}` $7 ${[gv_ac_]UPNAME[_save_CPPFLAGS]}"
+      fi
+      AC_CHECK_HEADERS($5,[gv_ac_inctemp="$5"])
+      if ! test "${gv_ac_inctemp}" = "$5"; then
+	eval "[unset ac_cv_header_]m4_bpatsubst([$5],[[].-[]],_)"
+      else
+     	break
+      fi
+    done
+    if ! test "${gv_ac_inctemp}" = "$5"; then
+      m4_if(OPTIONAL,[optional],
+        [UPNAME[_LIB]=""
+	UPNAME[_ALL_LIB]=""
+	UPNAME[_LIB_PATH]=""
+	UPNAME[_INCLUDE_PATH]=""],
+        [AC_MSG_ERROR([Header file "$5" was not found])])
+    else
+      UPNAME[_ALL_INCLUDES]="-I${incdir} $7"
+      UPNAME[_INCLUDES]="-I${incdir}"
+      UPNAME[_INCLUDE_PATH]="${incdir}"
     fi
-    CPPCLAGS="${[ac_]UPNAME[_save_CPPFLAGS]}"
+    CPPFLAGS="${[gv_ac_]UPNAME[_save_CPPFLAGS]}"
   ])
   dnl
   dnl define makefile substitutions and config.h macros
@@ -267,8 +319,9 @@ fi dnl disable fi
 
 AM_CONDITIONAL([HAVE_]UPNAME, [test -n "$[]UPNAME[_LIB]"])
 AC_SUBST(UPNAME[_INCLUDE_PATH])
+AC_SUBST(UPNAME[_INCLUDES])
+AC_SUBST(UPNAME[_ALL_INCLUDES])
 AC_SUBST(UPNAME[_LIB_PATH])
-AC_SUBST(UPNAME[_INCLUDE])
 AC_SUBST(UPNAME[_LIB])
 AC_SUBST(UPNAME[_ALL_LIB])
 AC_SUBST(UPNAME[_NAME])
diff --git a/m4/grapeiface.m4 b/m4/grapeiface.m4
index a80064e..ec19e86 100644
--- a/m4/grapeiface.m4
+++ b/m4/grapeiface.m4
@@ -4,16 +4,17 @@ dnl Some defines to enable building of alberta_movi. This is more
 dnl complicated than necessary so that it is easier to build a
 dnl stand-alone version of albert_movi.
 dnl
-ALBERTA_CHECK_PACKAGE(grape, gr, , ${OPENGL_LIB} ${X_ALL_LIBS}, grape.h,,, optional)
+ALBERTA_CHECK_PACKAGE([grape],[gr],[],[${OPENGL_LIB} ${X_ALL_LIBS}],
+                      [grape.h],[],[],[optional])
 AM_CONDITIONAL(GRAPE, test -n "${GRAPE_LIB}")
 ALBERTA_LIB_PATH=$prefix/lib
 ALBERTA_INCLUDE_PATH='$(top_srcdir)/alberta/src/Common/ -I$(top_srcdir)/alberta_util/src/  -I$(top_builddir)/alberta_util/src/'
 
-ALBERTA_LIBS_1='$(top_builddir)/alberta/src/alberta2_1d/libalberta2_1d.la $(top_builddir)/alberta_util/src/libalberta2_util.la $(BLAS_ALL_LIB) $(GLTOOLS_ALL_LIB)'
+ALBERTA_LIBS_1='$(top_builddir)/alberta/src/alberta2_1d/libalberta2_1d.la $(top_builddir)/alberta_util/src/libalberta2_util.la $(BLAS_ALL_LIB) $(GLTOOLS_ALL_LIB) $(OPENDX_ALL_LIB)'
 
-ALBERTA_LIBS_2='$(top_builddir)/alberta/src/alberta2_2d/libalberta2_2d.la $(top_builddir)/alberta_util/src/libalberta2_util.la $(BLAS_ALL_LIB) $(GLTOOLS_ALL_LIB)'
+ALBERTA_LIBS_2='$(top_builddir)/alberta/src/alberta2_2d/libalberta2_2d.la $(top_builddir)/alberta_util/src/libalberta2_util.la $(BLAS_ALL_LIB) $(GLTOOLS_ALL_LIB) $(OPENDX_ALL_LIB)'
 
-ALBERTA_LIBS_3='$(top_builddir)/alberta/src/alberta2_3d/libalberta2_3d.la $(top_builddir)/alberta_util/src/libalberta2_util.la $(BLAS_ALL_LIB) $(GLTOOLS_ALL_LIB)'
+ALBERTA_LIBS_3='$(top_builddir)/alberta/src/alberta2_3d/libalberta2_3d.la $(top_builddir)/alberta_util/src/libalberta2_util.la $(BLAS_ALL_LIB) $(GLTOOLS_ALL_LIB) $(OPENDX_ALL_LIB)'
 ALBERTA_DEBUG=
 AC_SUBST(ALBERTA_DEBUG)
 AC_SUBST(ALBERTA_LIB_PATH)
diff --git a/m4/simple-enable-flag.m4 b/m4/simple-enable-flag.m4
index 9796f07..f031de9 100644
--- a/m4/simple-enable-flag.m4
+++ b/m4/simple-enable-flag.m4
@@ -9,6 +9,10 @@
 # $2: help string
 # $3: default value
 # $4: name of the preprocessor/Makefile/shell variable
+# $5: optional, if set it is a list of the keywords DEFINE, SUBST and COND
+#     and specifies whether to AC_DEFINE, AC_SUBST and define an
+#     AM_CONDITIONAL corresponding to the flag. The default is (if the 5th
+#     argument is missing to just AC_SUBST and define a conditional.
 #
 # Results: declare proper AC_ARG_ENABLE(), define make-file
 # subsitution (e.g. EL_INDEX), define automake conditional
@@ -18,11 +22,17 @@ AC_DEFUN([ALBERTA_ENABLE_FLAG],
 [m4_if($#,3,
        [m4_define([FLAGNAME], [m4_bpatsubst(m4_toupper([$1]),-,_)])],
        [m4_define([FLAGNAME], [m4_bpatsubst(m4_toupper([$4]),-,_)])])
+m4_define([NEGDEFAULT],[enable])
+m4_define([DEFAULT],[disabled])
 m4_if([$3],[1],
       [m4_define([NEGDEFAULT],[disable])
-       m4_define([DEFAULT],[enabled])],
-      [m4_define([NEGDEFAULT],[enable])
-       m4_define([DEFAULT],[disabled])])
+       m4_define([DEFAULT],[enabled])])
+m4_if([$3],[yes],
+      [m4_define([NEGDEFAULT],[disable])
+       m4_define([DEFAULT],[enabled])])
+m4_if([$3],[enabled],
+      [m4_define([NEGDEFAULT],[disable])
+       m4_define([DEFAULT],[enabled])])
 AC_ARG_ENABLE($1,
 	AC_HELP_STRING(--[]NEGDEFAULT[]-$1,
 			[$2 (default: DEFAULT)]),
@@ -38,6 +48,21 @@ AC_ARG_ENABLE($1,
 			;;
 	esac],
 	[FLAGNAME=$3])
-AC_SUBST(FLAGNAME)
-AM_CONDITIONAL(FLAGNAME, [test "$[]FLAGNAME" -eq 1])
+m4_if($#,5,
+[for i in m4_toupper([$5]); do
+    case $i in
+      DEF*)
+	AC_DEFINE_UNQUOTED(FLAGNAME, $[]FLAGNAME,
+    		[Flag corresponding to the "$1" enable/disable option])
+	;;
+      SUBST*)	
+	AC_SUBST(FLAGNAME)
+	;;
+      COND*)
+	AM_CONDITIONAL(FLAGNAME, [test "$[]FLAGNAME" -eq 1])
+	;;
+    esac
+done],
+[AC_SUBST(FLAGNAME)
+AM_CONDITIONAL(FLAGNAME, [test "$[]FLAGNAME" -eq 1])])
 ])
-- 
GitLab