[ssm] 02/05: Imported Upstream version 1.3

Frédéric-Emmanuel Picca picca at alioth.debian.org
Mon Sep 2 19:46:09 UTC 2013


This is an automated email from the git hooks/post-receive script.

picca pushed a commit to branch master
in repository ssm.

commit 806ec2e893dced6c6d0fce30b87b68d05bb2e215
Author: Picca Frédéric-Emmanuel <picca at debian.org>
Date:   Sat Aug 31 08:42:39 2013 +0200

    Imported Upstream version 1.3
---
 Makefile.am                     |   13 +-
 Makefile.in                     |  245 +++-
 aclocal.m4                      |  446 ++++---
 build-aux/ar-lib                |  270 ++++
 build-aux/config.guess          |  261 ++--
 build-aux/config.sub            |  213 ++-
 build-aux/depcomp               |  189 ++-
 build-aux/install-sh            |   35 +-
 build-aux/missing               |  148 +--
 configure                       | 2793 +++++++++++++++++++++------------------
 configure.ac                    |    7 +-
 m4/libtool.m4                   |  265 +++-
 m4/ltoptions.m4                 |   19 +-
 ss_csia.h                       |  162 ---
 ss_graph.h                      |  266 ----
 ss_vxedge.h                     |  232 ----
 ssm_align.cpp                   |  393 +++---
 ssm_align.h                     |  325 +++--
 ss_csia.cpp => ssm_csia.cpp     |  264 ++--
 ssm_csia.h                      |  162 +++
 ssm_defs.h                      |   89 ++
 ss_graph.cpp => ssm_graph.cpp   |  949 ++++++-------
 ssm_graph.h                     |  238 ++++
 ssm_malign.cpp                  | 2525 +++++++++++++++++++++++++++++++++++
 ssm_malign.h                    |  313 +++++
 ssm_superpose.cpp               |  259 ++--
 ssm_superpose.h                 |  497 ++++---
 ss_vxedge.cpp => ssm_vxedge.cpp |  474 +++----
 ssm_vxedge.h                    |  219 +++
 sup_defs.h                      |   31 +
 sup_multiple.cpp                |  258 ++++
 sup_multiple.h                  |   34 +
 sup_pairwise.cpp                |  273 ++++
 sup_pairwise.h                  |   33 +
 superpose.cpp                   |  464 +++----
 35 files changed, 8946 insertions(+), 4418 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 5f910d9..ae84dd1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,16 +1,17 @@
 ACLOCAL_AMFLAGS = -I m4
 
 lib_LTLIBRARIES = libssm.la
-libssm_la_SOURCES = ssm_superpose.cpp ss_csia.cpp ss_vxedge.cpp \
-		    ssm_align.cpp ss_graph.cpp
+libssm_la_SOURCES = ssm_superpose.cpp ssm_csia.cpp ssm_vxedge.cpp \
+		    ssm_align.cpp ssm_malign.cpp ssm_graph.cpp
 libssm_la_LIBADD = -lmmdb
-libssm_la_LDFLAGS = -no-undefined
+libssm_la_LDFLAGS = -no-undefined -version-info 1:0:0
 
-pkginclude_HEADERS = ss_graph.h ssm_superpose.h ss_csia.h ss_vxedge.h \
-                     ssm_align.h
+pkginclude_HEADERS = ssm_graph.h ssm_superpose.h ssm_csia.h ssm_vxedge.h \
+                     ssm_align.h ssm_malign.h ssm_defs.h
 
 bin_PROGRAMS = superpose
-superpose_SOURCES = superpose.cpp
+superpose_SOURCES = superpose.cpp sup_pairwise.cpp sup_multiple.cpp \
+                    sup_pairwise.h sup_multiple.h sup_defs.h
 superpose_LDADD = libssm.la -lmmdb
 if USE_LIBCCP4
 superpose_CPPFLAGS = -D_ccp4_
diff --git a/Makefile.in b/Makefile.in
index 8c8e079..d6d6eb5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.12.2 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2012 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -18,6 +17,23 @@
 
 
 VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -41,10 +57,16 @@ bin_PROGRAMS = superpose$(EXEEXT)
 subdir = .
 DIST_COMMON = $(am__configure_deps) $(pkginclude_HEADERS) \
 	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-	$(srcdir)/config.h.in $(top_srcdir)/configure AUTHORS COPYING \
-	COPYING.LESSER INSTALL build-aux/config.guess \
-	build-aux/config.sub build-aux/depcomp build-aux/install-sh \
-	build-aux/ltmain.sh build-aux/missing
+	$(srcdir)/config.h.in $(top_srcdir)/build-aux/ar-lib \
+	$(top_srcdir)/build-aux/config.guess \
+	$(top_srcdir)/build-aux/config.sub \
+	$(top_srcdir)/build-aux/depcomp \
+	$(top_srcdir)/build-aux/install-sh \
+	$(top_srcdir)/build-aux/ltmain.sh \
+	$(top_srcdir)/build-aux/missing $(top_srcdir)/configure \
+	AUTHORS COPYING COPYING.LESSER INSTALL build-aux/ar-lib \
+	build-aux/config.guess build-aux/config.sub build-aux/depcomp \
+	build-aux/install-sh build-aux/ltmain.sh build-aux/missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
@@ -89,20 +111,35 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
 	"$(DESTDIR)$(pkgincludedir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
 libssm_la_DEPENDENCIES =
-am_libssm_la_OBJECTS = ssm_superpose.lo ss_csia.lo ss_vxedge.lo \
-	ssm_align.lo ss_graph.lo
+am_libssm_la_OBJECTS = ssm_superpose.lo ssm_csia.lo ssm_vxedge.lo \
+	ssm_align.lo ssm_malign.lo ssm_graph.lo
 libssm_la_OBJECTS = $(am_libssm_la_OBJECTS)
 AM_V_lt = $(am__v_lt_ at AM_V@)
 am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
 am__v_lt_0 = --silent
+am__v_lt_1 = 
 libssm_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
 	$(CXXFLAGS) $(libssm_la_LDFLAGS) $(LDFLAGS) -o $@
 PROGRAMS = $(bin_PROGRAMS)
-am_superpose_OBJECTS = superpose-superpose.$(OBJEXT)
+am_superpose_OBJECTS = superpose-superpose.$(OBJEXT) \
+	superpose-sup_pairwise.$(OBJEXT) \
+	superpose-sup_multiple.$(OBJEXT)
 superpose_OBJECTS = $(am_superpose_OBJECTS)
 am__DEPENDENCIES_1 =
 superpose_DEPENDENCIES = libssm.la $(am__DEPENDENCIES_1)
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 DEFAULT_INCLUDES = -I. at am__isrc@
 depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
 am__depfiles_maybe = depfiles
@@ -115,25 +152,46 @@ LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(AM_CXXFLAGS) $(CXXFLAGS)
 AM_V_CXX = $(am__v_CXX_ at AM_V@)
 am__v_CXX_ = $(am__v_CXX_ at AM_DEFAULT_V@)
-am__v_CXX_0 = @echo "  CXX   " $@;
-AM_V_at = $(am__v_at_ at AM_V@)
-am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
-am__v_at_0 = @
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
 CXXLD = $(CXX)
 CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
 	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 AM_V_CXXLD = $(am__v_CXXLD_ at AM_V@)
 am__v_CXXLD_ = $(am__v_CXXLD_ at AM_DEFAULT_V@)
-am__v_CXXLD_0 = @echo "  CXXLD " $@;
-AM_V_GEN = $(am__v_GEN_ at AM_V@)
-am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
-am__v_GEN_0 = @echo "  GEN   " $@;
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_ at AM_V@)
+am__v_CC_ = $(am__v_CC_ at AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
 SOURCES = $(libssm_la_SOURCES) $(superpose_SOURCES)
 DIST_SOURCES = $(libssm_la_SOURCES) $(superpose_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 HEADERS = $(pkginclude_HEADERS)
 ETAGS = etags
 CTAGS = ctags
+CSCOPE = cscope
+AM_RECURSIVE_TARGETS = cscope
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -143,8 +201,10 @@ am__remove_distdir = \
       && rm -rf "$(distdir)" \
       || { sleep 5 && rm -rf "$(distdir)"; }; \
   else :; fi
+am__post_remove_distdir = $(am__remove_distdir)
 DIST_ARCHIVES = $(distdir).tar.gz
 GZIP_ENV = --best
+DIST_TARGETS = dist-gzip
 distuninstallcheck_listfiles = find . -type f -print
 am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
   | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
@@ -272,15 +332,17 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 ACLOCAL_AMFLAGS = -I m4
 lib_LTLIBRARIES = libssm.la
-libssm_la_SOURCES = ssm_superpose.cpp ss_csia.cpp ss_vxedge.cpp \
-		    ssm_align.cpp ss_graph.cpp
+libssm_la_SOURCES = ssm_superpose.cpp ssm_csia.cpp ssm_vxedge.cpp \
+		    ssm_align.cpp ssm_malign.cpp ssm_graph.cpp
 
 libssm_la_LIBADD = -lmmdb
-libssm_la_LDFLAGS = -no-undefined
-pkginclude_HEADERS = ss_graph.h ssm_superpose.h ss_csia.h ss_vxedge.h \
-                     ssm_align.h
+libssm_la_LDFLAGS = -no-undefined -version-info 1:0:0
+pkginclude_HEADERS = ssm_graph.h ssm_superpose.h ssm_csia.h ssm_vxedge.h \
+                     ssm_align.h ssm_malign.h ssm_defs.h
+
+superpose_SOURCES = superpose.cpp sup_pairwise.cpp sup_multiple.cpp \
+                    sup_pairwise.h sup_multiple.h sup_defs.h
 
-superpose_SOURCES = superpose.cpp
 superpose_LDADD = libssm.la -lmmdb $(am__append_1)
 @USE_LIBCCP4_TRUE at superpose_CPPFLAGS = -D_ccp4_
 all: config.h
@@ -339,7 +401,6 @@ distclean-hdr:
 	-rm -f config.h stamp-h1
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
-	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
 	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
 	list2=; for p in $$list; do \
 	  if test -f $$p; then \
@@ -347,6 +408,8 @@ install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	  else :; fi; \
 	done; \
 	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
 	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
 	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
 	}
@@ -362,18 +425,23 @@ uninstall-libLTLIBRARIES:
 
 clean-libLTLIBRARIES:
 	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-	  test "$$dir" != "$$p" || dir=.; \
-	  echo "rm -f \"$${dir}/so_locations\""; \
-	  rm -f "$${dir}/so_locations"; \
-	done
+	@list='$(lib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
 libssm.la: $(libssm_la_OBJECTS) $(libssm_la_DEPENDENCIES) $(EXTRA_libssm_la_DEPENDENCIES) 
 	$(AM_V_CXXLD)$(libssm_la_LINK) -rpath $(libdir) $(libssm_la_OBJECTS) $(libssm_la_LIBADD) $(LIBS)
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
-	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
 	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+	fi; \
 	for p in $$list; do echo "$$p $$p"; done | \
 	sed 's/$(EXEEXT)$$//' | \
 	while read p p1; do if test -f $$p || test -f $$p1; \
@@ -423,11 +491,14 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ss_csia.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ss_graph.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ss_vxedge.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ssm_align.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ssm_csia.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ssm_graph.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ssm_malign.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ssm_superpose.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ssm_vxedge.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/superpose-sup_multiple.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/superpose-sup_pairwise.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/superpose-superpose.Po at am__quote@
 
 .cpp.o:
@@ -468,6 +539,34 @@ superpose-superpose.obj: superpose.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(superpose_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o superpose-superpose.obj `if test -f 'superpose.cpp'; then $(CYGPATH_W) 'superpose.cpp'; else $(CYGPATH_W) '$(srcdir)/superpose.cpp'; fi`
 
+superpose-sup_pairwise.o: sup_pairwise.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(superpose_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT superpose-sup_pairwise.o -MD -MP -MF $(DEPDIR)/superpose-sup_pairwise.Tpo -c -o superpose-sup_pairwise.o `test -f 'sup_pairwise.cpp' || echo '$(srcdir)/'`sup_pairwise.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/superpose-sup_pairwise.Tpo $(DEPDIR)/superpose-sup_pairwise.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='sup_pairwise.cpp' object='superpose-sup_pairwise.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(superpose_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o superpose-sup_pairwise.o `test -f 'sup_pairwise.cpp' || echo '$(srcdir)/'`sup_pairwise.cpp
+
+superpose-sup_pairwise.obj: sup_pairwise.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(superpose_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT superpose-sup_pairwise.obj -MD -MP -MF $(DEPDIR)/superpose-sup_pairwise.Tpo -c -o superpose-sup_pairwise.obj `if test -f 'sup_pairwise.cpp'; then $(CYGPATH_W) 'sup_pairwise.cpp'; else $(CYGPATH_W) '$(srcdir)/sup_pairwise.cpp'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/superpose-sup_pairwise.Tpo $(DEPDIR)/superpose-sup_pairwise.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='sup_pairwise.cpp' object='superpose-sup_pairwise.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(superpose_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o superpose-sup_pairwise.obj `if test -f 'sup_pairwise.cpp'; then $(CYGPATH_W) 'sup_pairwise.cpp'; else $(CYGPATH_W) '$(srcdir)/sup_pairwise.cpp'; fi`
+
+superpose-sup_multiple.o: sup_multiple.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(superpose_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT superpose-sup_multiple.o -MD -MP -MF $(DEPDIR)/superpose-sup_multiple.Tpo -c -o superpose-sup_multiple.o `test -f 'sup_multiple.cpp' || echo '$(srcdir)/'`sup_multiple.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/superpose-sup_multiple.Tpo $(DEPDIR)/superpose-sup_multiple.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='sup_multiple.cpp' object='superpose-sup_multiple.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(superpose_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o superpose-sup_multiple.o `test -f 'sup_multiple.cpp' || echo '$(srcdir)/'`sup_multiple.cpp
+
+superpose-sup_multiple.obj: sup_multiple.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(superpose_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT superpose-sup_multiple.obj -MD -MP -MF $(DEPDIR)/superpose-sup_multiple.Tpo -c -o superpose-sup_multiple.obj `if test -f 'sup_multiple.cpp'; then $(CYGPATH_W) 'sup_multiple.cpp'; else $(CYGPATH_W) '$(srcdir)/sup_multiple.cpp'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/superpose-sup_multiple.Tpo $(DEPDIR)/superpose-sup_multiple.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='sup_multiple.cpp' object='superpose-sup_multiple.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(superpose_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o superpose-sup_multiple.obj `if test -f 'sup_multiple.cpp'; then $(CYGPATH_W) 'sup_multiple.cpp'; else $(CYGPATH_W) '$(srcdir)/sup_multiple.cpp'; fi`
+
 mostlyclean-libtool:
 	-rm -f *.lo
 
@@ -478,8 +577,11 @@ distclean-libtool:
 	-rm -f libtool config.lt
 install-pkgincludeHEADERS: $(pkginclude_HEADERS)
 	@$(NORMAL_INSTALL)
-	test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
 	@list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \
+	fi; \
 	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 	  echo "$$d$$p"; \
@@ -544,8 +646,32 @@ GTAGS:
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
 
+cscope: cscope.files
+	test ! -s cscope.files \
+	  || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+
+clean-cscope:
+	-rm -f cscope.files
+
+cscope.files: clean-cscope  cscopelist
+
+cscopelist:  $(HEADERS) $(SOURCES) $(LISP)
+	list='$(SOURCES) $(HEADERS) $(LISP)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
+
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
 
 distdir: $(DISTFILES)
 	$(am__remove_distdir)
@@ -588,40 +714,36 @@ distdir: $(DISTFILES)
 	|| chmod -R a+r "$(distdir)"
 dist-gzip: distdir
 	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-bzip2: distdir
 	tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-lzip: distdir
 	tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
-	$(am__remove_distdir)
-
-dist-lzma: distdir
-	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-xz: distdir
 	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-shar: distdir
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-zip: distdir
 	-rm -f $(distdir).zip
 	zip -rq $(distdir).zip $(distdir)
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
-dist dist-all: distdir
-	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-	$(am__remove_distdir)
+dist dist-all:
+	$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+	$(am__post_remove_distdir)
 
 # This target untars the dist file and tries a VPATH configuration.  Then
 # it guarantees that the distribution is self-contained by making another
@@ -632,8 +754,6 @@ distcheck: dist
 	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
 	*.tar.bz2*) \
 	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
-	*.tar.lzma*) \
-	  lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
 	*.tar.lz*) \
 	  lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
 	*.tar.xz*) \
@@ -645,7 +765,7 @@ distcheck: dist
 	*.zip*) \
 	  unzip $(distdir).zip ;;\
 	esac
-	chmod -R a-w $(distdir); chmod a+w $(distdir)
+	chmod -R a-w $(distdir); chmod u+w $(distdir)
 	mkdir $(distdir)/_build
 	mkdir $(distdir)/_inst
 	chmod a-w $(distdir)
@@ -679,7 +799,7 @@ distcheck: dist
 	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
 	  && cd "$$am__cwd" \
 	  || exit 1
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 	@(echo "$(distdir) archives ready for distribution: "; \
 	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
 	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
@@ -826,13 +946,14 @@ uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES \
 .MAKE: all install-am install-strip
 
 .PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
-	clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
-	clean-libtool ctags dist dist-all dist-bzip2 dist-gzip \
-	dist-lzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
-	distcheck distclean distclean-compile distclean-generic \
-	distclean-hdr distclean-libtool distclean-tags distcleancheck \
-	distdir distuninstallcheck dvi dvi-am html html-am info \
-	info-am install install-am install-binPROGRAMS install-data \
+	clean-binPROGRAMS clean-cscope clean-generic \
+	clean-libLTLIBRARIES clean-libtool cscope cscopelist ctags \
+	dist dist-all dist-bzip2 dist-gzip dist-lzip dist-shar \
+	dist-tarZ dist-xz dist-zip distcheck distclean \
+	distclean-compile distclean-generic distclean-hdr \
+	distclean-libtool distclean-tags distcleancheck distdir \
+	distuninstallcheck dvi dvi-am html html-am info info-am \
+	install install-am install-binPROGRAMS install-data \
 	install-data-am install-dvi install-dvi-am install-exec \
 	install-exec-am install-html install-html-am install-info \
 	install-info-am install-libLTLIBRARIES install-man install-pdf \
diff --git a/aclocal.m4 b/aclocal.m4
index c9ede0b..c15146a 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,8 +1,7 @@
-# generated automatically by aclocal 1.11.3 -*- Autoconf -*-
+# generated automatically by aclocal 1.12.2 -*- Autoconf -*-
+
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,20 +13,19 @@
 
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],,
-[m4_warning([this file was generated for autoconf 2.68.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
+[m4_warning([this file was generated for autoconf 2.69.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
-To do so, use the procedure documented by the package, typically `autoreconf'.])])
+To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
+# serial 8
 
 # AM_AUTOMAKE_VERSION(VERSION)
 # ----------------------------
@@ -35,10 +33,10 @@ To do so, use the procedure documented by the package, typically `autoreconf'.])
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.11'
+[am__api_version='1.12'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.11.3], [],
+m4_if([$1], [1.12.2], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -54,24 +52,85 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.11.3])dnl
+[AM_AUTOMAKE_VERSION([1.12.2])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
+# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 1
+
+# AM_PROG_AR([ACT-IF-FAIL])
+# -------------------------
+# Try to determine the archiver interface, and trigger the ar-lib wrapper
+# if it is needed.  If the detection of archiver interface fails, run
+# ACT-IF-FAIL (default is to abort configure with a proper error message).
+AC_DEFUN([AM_PROG_AR],
+[AC_BEFORE([$0], [LT_INIT])dnl
+AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([ar-lib])dnl
+AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false])
+: ${AR=ar}
+
+AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface],
+  [am_cv_ar_interface=ar
+   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])],
+     [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
+      AC_TRY_EVAL([am_ar_try])
+      if test "$ac_status" -eq 0; then
+        am_cv_ar_interface=ar
+      else
+        am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
+        AC_TRY_EVAL([am_ar_try])
+        if test "$ac_status" -eq 0; then
+          am_cv_ar_interface=lib
+        else
+          am_cv_ar_interface=unknown
+        fi
+      fi
+      rm -f conftest.lib libconftest.a
+     ])
+   ])
+
+case $am_cv_ar_interface in
+ar)
+  ;;
+lib)
+  # Microsoft lib, so override with the ar-lib wrapper script.
+  # FIXME: It is wrong to rewrite AR.
+  # But if we don't then we get into trouble of one sort or another.
+  # A longer-term fix would be to have automake use am__AR in this case,
+  # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something
+  # similar.
+  AR="$am_aux_dir/ar-lib $AR"
+  ;;
+unknown)
+  m4_default([$1],
+             [AC_MSG_ERROR([could not determine $AR interface])])
+  ;;
+esac
+AC_SUBST([AR])dnl
+])
+
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
+# serial 2
 
 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
-# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
-# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
+# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
 #
 # Of course, Automake must honor this variable whenever it calls a
 # tool from the auxiliary directory.  The problem is that $srcdir (and
@@ -90,7 +149,7 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 #
 # The reason of the latter failure is that $top_srcdir and $ac_aux_dir
 # are both prefixed by $srcdir.  In an in-source build this is usually
-# harmless because $srcdir is `.', but things will broke when you
+# harmless because $srcdir is '.', but things will broke when you
 # start a VPATH build or use an absolute $srcdir.
 #
 # So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
@@ -116,22 +175,21 @@ am_aux_dir=`cd $ac_aux_dir && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 1997-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 9
+# serial 10
 
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -------------------------------------
 # Define a conditional.
 AC_DEFUN([AM_CONDITIONAL],
-[AC_PREREQ(2.52)dnl
- ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
-	[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
 AC_SUBST([$1_TRUE])dnl
 AC_SUBST([$1_FALSE])dnl
 _AM_SUBST_NOTMAKE([$1_TRUE])dnl
@@ -150,16 +208,15 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009,
-# 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 1999-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 12
+# serial 17
 
-# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
 # will think it sees a *use*, and therefore will trigger all it's
 # C support machinery.  Also note that it means that autoscan, seeing
@@ -169,7 +226,7 @@ fi])])
 # _AM_DEPENDENCIES(NAME)
 # ----------------------
 # See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
 # We try a few techniques and use that to set a single cache variable.
 #
 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
@@ -182,12 +239,13 @@ AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
 AC_REQUIRE([AM_DEP_TRACK])dnl
 
-ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
-       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
-       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
-       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
-       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
-                   [depcc="$$1"   am_compiler_list=])
+m4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
+      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
+      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
+      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
+      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                    [depcc="$$1"   am_compiler_list=])
 
 AC_CACHE_CHECK([dependency style of $depcc],
                [am_cv_$1_dependencies_compiler_type],
@@ -195,8 +253,8 @@ AC_CACHE_CHECK([dependency style of $depcc],
   # We make a subdir and do the tests there.  Otherwise we can end up
   # making bogus files that we don't know about and never remove.  For
   # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
   rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
@@ -236,16 +294,16 @@ AC_CACHE_CHECK([dependency style of $depcc],
     : > sub/conftest.c
     for i in 1 2 3 4 5 6; do
       echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
     # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
     am__obj=sub/conftest.${OBJEXT-o}
     am__minus_obj="-o $am__obj"
     case $depmode in
@@ -254,8 +312,8 @@ AC_CACHE_CHECK([dependency style of $depcc],
       test "$am__universal" = false || continue
       ;;
     nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
       if test "x$enable_dependency_tracking" = xyes; then
 	continue
       else
@@ -263,7 +321,7 @@ AC_CACHE_CHECK([dependency style of $depcc],
       fi
       ;;
     msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
+      # This compiler won't grok '-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
       am__obj=conftest.${OBJEXT-o}
@@ -311,7 +369,7 @@ AM_CONDITIONAL([am__fastdep$1], [
 # AM_SET_DEPDIR
 # -------------
 # Choose a directory name for dependency files.
-# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
 AC_DEFUN([AM_SET_DEPDIR],
 [AC_REQUIRE([AM_SET_LEADING_DOT])dnl
 AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
@@ -321,9 +379,13 @@ AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
 # AM_DEP_TRACK
 # ------------
 AC_DEFUN([AM_DEP_TRACK],
-[AC_ARG_ENABLE(dependency-tracking,
-[  --disable-dependency-tracking  speeds up one-time build
-  --enable-dependency-tracking   do not reject slow dependency extractors])
+[AC_ARG_ENABLE([dependency-tracking], [dnl
+AS_HELP_STRING(
+  [--enable-dependency-tracking],
+  [do not reject slow dependency extractors])
+AS_HELP_STRING(
+  [--disable-dependency-tracking],
+  [speeds up one-time build])])
 if test "x$enable_dependency_tracking" != xno; then
   am_depcomp="$ac_aux_dir/depcomp"
   AMDEPBACKSLASH='\'
@@ -338,14 +400,13 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 1999-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-#serial 5
+# serial 6
 
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
@@ -364,7 +425,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
     # Strip MF so we end up with the name of the file.
     mf=`echo "$mf" | sed -e 's/:.*$//'`
     # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named `Makefile.in', but
+    # We used to match only the files named 'Makefile.in', but
     # some people rename them; so instead we look at the file content.
     # Grep'ing the first line is not enough: some people post-process
     # each Makefile.in and add a new line on top of each file to say so.
@@ -376,21 +437,19 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
       continue
     fi
     # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running `make'.
+    # from the Makefile without running 'make'.
     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     test -z "$DEPDIR" && continue
     am__include=`sed -n 's/^am__include = //p' < "$mf"`
     test -z "am__include" && continue
     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # When using ansi2knr, U may be empty or an underscore; expand it
-    U=`sed -n 's/^U = //p' < "$mf"`
     # Find all dependency output files, they are included files with
     # $(DEPDIR) in their names.  We invoke sed twice because it is the
     # simplest approach to changing $(DEPDIR) to its actual value in the
     # expansion.
     for file in `sed -n "
       s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
       # Make sure the directory exists.
       test -f "$dirpart/$file" && continue
       fdir=`AS_DIRNAME(["$file"])`
@@ -408,7 +467,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
 # This macro should only be invoked once -- use via AC_REQUIRE.
 #
 # This code is only required when automatic dependency tracking
-# is enabled.  FIXME.  This creates each `.P' file that we will
+# is enabled.  FIXME.  This creates each '.P' file that we will
 # need in order to bootstrap the dependency handling code.
 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 [AC_CONFIG_COMMANDS([depfiles],
@@ -418,14 +477,13 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 16
+# serial 19
 
 # This macro actually does too much.  Some checks are only needed if
 # your package does certain things.  But this isn't really a big deal.
@@ -471,31 +529,41 @@ AC_SUBST([CYGPATH_W])
 # Define the identity of the package.
 dnl Distinguish between old-style and new-style calls.
 m4_ifval([$2],
-[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+[AC_DIAGNOSE([obsolete],
+[$0: two- and three-arguments forms are deprecated.  For more info, see:
+http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
  AC_SUBST([PACKAGE], [$1])dnl
  AC_SUBST([VERSION], [$2])],
 [_AM_SET_OPTIONS([$1])dnl
 dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
-m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+m4_if(
+  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+  [ok:ok],,
   [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
  AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
  AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
 
 _AM_IF_OPTION([no-define],,
-[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
- AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+ AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
 
 # Some tools Automake needs.
 AC_REQUIRE([AM_SANITY_CHECK])dnl
 AC_REQUIRE([AC_ARG_PROGRAM])dnl
-AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
-AM_MISSING_PROG(AUTOCONF, autoconf)
-AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
-AM_MISSING_PROG(AUTOHEADER, autoheader)
-AM_MISSING_PROG(MAKEINFO, makeinfo)
+AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
+AM_MISSING_PROG([AUTOCONF], [autoconf])
+AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
+AM_MISSING_PROG([AUTOHEADER], [autoheader])
+AM_MISSING_PROG([MAKEINFO], [makeinfo])
 AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
 AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
-AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
 # We need awk for the "check" target.  The system "awk" is bad on
 # some platforms.
 AC_REQUIRE([AC_PROG_AWK])dnl
@@ -506,28 +574,35 @@ _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
 			     [_AM_PROG_TAR([v7])])])
 _AM_IF_OPTION([no-dependencies],,
 [AC_PROVIDE_IFELSE([AC_PROG_CC],
-		  [_AM_DEPENDENCIES(CC)],
-		  [define([AC_PROG_CC],
-			  defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+		  [_AM_DEPENDENCIES([CC])],
+		  [m4_define([AC_PROG_CC],
+			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_CXX],
-		  [_AM_DEPENDENCIES(CXX)],
-		  [define([AC_PROG_CXX],
-			  defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+		  [_AM_DEPENDENCIES([CXX])],
+		  [m4_define([AC_PROG_CXX],
+			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_OBJC],
-		  [_AM_DEPENDENCIES(OBJC)],
-		  [define([AC_PROG_OBJC],
-			  defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+		  [_AM_DEPENDENCIES([OBJC])],
+		  [m4_define([AC_PROG_OBJC],
+			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
+dnl Support for Objective C++ was only introduced in Autoconf 2.65,
+dnl but we still cater to Autoconf 2.62.
+m4_ifdef([AC_PROG_OBJCXX],
+[AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+		  [_AM_DEPENDENCIES([OBJCXX])],
+		  [m4_define([AC_PROG_OBJCXX],
+			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])])dnl
 ])
 _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
-dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
-dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
+dnl The 'parallel-tests' driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
 dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
 AC_CONFIG_COMMANDS_PRE(dnl
 [m4_provide_if([_AM_COMPILER_EXEEXT],
   [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
 ])
 
-dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
 dnl mangled by Autoconf and run in a shell conditional statement.
 m4_define([_AC_COMPILER_EXEEXT],
@@ -555,14 +630,13 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
+# serial 8
 
 # AM_PROG_INSTALL_SH
 # ------------------
@@ -577,9 +651,9 @@ if test x"${install_sh}" != xset; then
     install_sh="\${SHELL} $am_aux_dir/install-sh"
   esac
 fi
-AC_SUBST(install_sh)])
+AC_SUBST([install_sh])])
 
-# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2003-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -603,20 +677,19 @@ AC_SUBST([am__leading_dot])])
 # Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
 # From Jim Meyering
 
-# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008,
-# 2011 Free Software Foundation, Inc.
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 5
+# serial 7
 
 # AM_MAINTAINER_MODE([DEFAULT-MODE])
 # ----------------------------------
 # Control maintainer-specific portions of Makefiles.
-# Default is to disable them, unless `enable' is passed literally.
-# For symmetry, `disable' may be passed as well.  Anyway, the user
+# Default is to disable them, unless 'enable' is passed literally.
+# For symmetry, 'disable' may be passed as well.  Anyway, the user
 # can override the default with the --enable/--disable switch.
 AC_DEFUN([AM_MAINTAINER_MODE],
 [m4_case(m4_default([$1], [disable]),
@@ -627,10 +700,11 @@ AC_DEFUN([AM_MAINTAINER_MODE],
 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
   dnl maintainer-mode's default is 'disable' unless 'enable' is passed
   AC_ARG_ENABLE([maintainer-mode],
-[  --][am_maintainer_other][-maintainer-mode  am_maintainer_other make rules and dependencies not useful
-			  (and sometimes confusing) to the casual installer],
-      [USE_MAINTAINER_MODE=$enableval],
-      [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes]))
+    [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode],
+      am_maintainer_other[ make rules and dependencies not useful
+      (and sometimes confusing) to the casual installer])],
+    [USE_MAINTAINER_MODE=$enableval],
+    [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes]))
   AC_MSG_RESULT([$USE_MAINTAINER_MODE])
   AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes])
   MAINT=$MAINTAINER_MODE_TRUE
@@ -642,13 +716,13 @@ AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# serial 5
 
 # AM_MAKE_INCLUDE()
 # -----------------
@@ -667,7 +741,7 @@ am__quote=
 _am_result=none
 # First try GNU make style include.
 echo "include confinc" > confmf
-# Ignore all kinds of additional output from `make'.
+# Ignore all kinds of additional output from 'make'.
 case `$am_make -s -f confmf 2> /dev/null` in #(
 *the\ am__doit\ target*)
   am__include=include
@@ -694,14 +768,13 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 1997-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 6
+# serial 7
 
 # AM_MISSING_PROG(NAME, PROGRAM)
 # ------------------------------
@@ -731,49 +804,19 @@ if eval "$MISSING --run true"; then
   am_missing_run="$MISSING --run "
 else
   am_missing_run=
-  AC_MSG_WARN([`missing' script is too old or missing])
+  AC_MSG_WARN(['missing' script is too old or missing])
 fi
 ])
 
-# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation,
-# Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 1
-
-# AM_PROG_MKDIR_P
-# ---------------
-# Check for `mkdir -p'.
-AC_DEFUN([AM_PROG_MKDIR_P],
-[AC_PREREQ([2.60])dnl
-AC_REQUIRE([AC_PROG_MKDIR_P])dnl
-dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
-dnl while keeping a definition of mkdir_p for backward compatibility.
-dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
-dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
-dnl Makefile.ins that do not define MKDIR_P, so we do our own
-dnl adjustment using top_builddir (which is defined more often than
-dnl MKDIR_P).
-AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
-case $mkdir_p in
-  [[\\/$]]* | ?:[[\\/]]*) ;;
-  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
-esac
-])
-
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 5
+# serial 6
 
 # _AM_MANGLE_OPTION(NAME)
 # -----------------------
@@ -784,7 +827,7 @@ AC_DEFUN([_AM_MANGLE_OPTION],
 # --------------------
 # Set option NAME.  Presently that only means defining a flag for this option.
 AC_DEFUN([_AM_SET_OPTION],
-[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
 
 # _AM_SET_OPTIONS(OPTIONS)
 # ------------------------
@@ -800,22 +843,18 @@ AC_DEFUN([_AM_IF_OPTION],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 5
+# serial 9
 
 # AM_SANITY_CHECK
 # ---------------
 AC_DEFUN([AM_SANITY_CHECK],
 [AC_MSG_CHECKING([whether build environment is sane])
-# Just in case
-sleep 1
-echo timestamp > conftest.file
 # Reject unsafe characters in $srcdir or the absolute working directory
 # name.  Accept space and tab only in the latter.
 am_lf='
@@ -826,32 +865,40 @@ case `pwd` in
 esac
 case $srcdir in
   *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
-    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
 esac
 
-# Do `set' in a subshell so we don't clobber the current shell's
+# Do 'set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
-   if test "$[*]" = "X"; then
-      # -L didn't work.
-      set X `ls -t "$srcdir/configure" conftest.file`
-   fi
-   rm -f conftest.file
-   if test "$[*]" != "X $srcdir/configure conftest.file" \
-      && test "$[*]" != "X conftest.file $srcdir/configure"; then
-
-      # If neither matched, then we have a broken ls.  This can happen
-      # if, for instance, CONFIG_SHELL is bash and it inherits a
-      # broken ls alias from the environment.  This has actually
-      # happened.  Such a system could not be considered "sane".
-      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
-alias in your environment])
-   fi
-
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$[*]" = "X"; then
+	# -L didn't work.
+	set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$[*]" != "X $srcdir/configure conftest.file" \
+	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+	# If neither matched, then we have a broken ls.  This can happen
+	# if, for instance, CONFIG_SHELL is bash and it inherits a
+	# broken ls alias from the environment.  This has actually
+	# happened.  Such a system could not be considered "sane".
+	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment])
+     fi
+     if test "$[2]" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
    test "$[2]" = conftest.file
    )
 then
@@ -861,31 +908,52 @@ else
    AC_MSG_ERROR([newly created file is older than distributed files!
 Check your system clock])
 fi
-AC_MSG_RESULT(yes)])
+AC_MSG_RESULT([yes])
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+AC_CONFIG_COMMANDS_PRE(
+  [AC_MSG_CHECKING([that generated files are newer than configure])
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   AC_MSG_RESULT([done])])
+rm -f conftest.file
+])
 
-# Copyright (C) 2009, 2011  Free Software Foundation, Inc.
+# Copyright (C) 2009-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 2
+# serial 3
 
 # AM_SILENT_RULES([DEFAULT])
 # --------------------------
 # Enable less verbose build rules; with the default set to DEFAULT
-# (`yes' being less verbose, `no' or empty being verbose).
+# ("yes" being less verbose, "no" or empty being verbose).
 AC_DEFUN([AM_SILENT_RULES],
-[AC_ARG_ENABLE([silent-rules],
-[  --enable-silent-rules          less verbose build output (undo: `make V=1')
-  --disable-silent-rules         verbose build output (undo: `make V=0')])
-case $enable_silent_rules in
-yes) AM_DEFAULT_VERBOSITY=0;;
-no)  AM_DEFAULT_VERBOSITY=1;;
-*)   AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+[AC_ARG_ENABLE([silent-rules], [dnl
+AS_HELP_STRING(
+  [--enable-silent-rules],
+  [less verbose build output (undo: "make V=1")])
+AS_HELP_STRING(
+  [--disable-silent-rules],
+  [verbose build output (undo: "make V=0")])dnl
+])
+case $enable_silent_rules in @%:@ (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
 esac
 dnl
-dnl A few `make' implementations (e.g., NonStop OS and NextStep)
+dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
 dnl do not support nested variable expansions.
 dnl See automake bug#9928 and bug#10237.
 am_make=${MAKE-make}
@@ -903,7 +971,7 @@ else
   am_cv_make_support_nested_variables=no
 fi])
 if test $am_cv_make_support_nested_variables = yes; then
-  dnl Using `$V' instead of `$(V)' breaks IRIX make.
+  dnl Using '$V' instead of '$(V)' breaks IRIX make.
   AM_V='$(V)'
   AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
 else
@@ -920,37 +988,37 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
+# serial 2
 
 # AM_PROG_INSTALL_STRIP
 # ---------------------
-# One issue with vendor `install' (even GNU) is that you can't
+# One issue with vendor 'install' (even GNU) is that you can't
 # specify the program used to strip binaries.  This is especially
 # annoying in cross-compiling environments, where the build's strip
 # is unlikely to handle the host's binaries.
 # Fortunately install-sh will honor a STRIPPROG variable, so we
-# always use install-sh in `make install-strip', and initialize
+# always use install-sh in "make install-strip", and initialize
 # STRIPPROG with the value of the STRIP variable (set by the user).
 AC_DEFUN([AM_PROG_INSTALL_STRIP],
 [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'.  However `strip' might not be the right
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
 # tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+# will honor the 'STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
 if test "$cross_compiling" != no; then
   AC_CHECK_TOOL([STRIP], [strip], :)
 fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2006-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -971,18 +1039,18 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc.
+# Copyright (C) 2004-2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 2
+# serial 3
 
 # _AM_PROG_TAR(FORMAT)
 # --------------------
 # Check how to create a tarball in format FORMAT.
-# FORMAT should be one of `v7', `ustar', or `pax'.
+# FORMAT should be one of 'v7', 'ustar', or 'pax'.
 #
 # Substitute a variable $(am__tar) that is a command
 # writing to stdout a FORMAT-tarball containing the directory
@@ -1005,7 +1073,7 @@ AC_MSG_CHECKING([how to create a $1 tar archive])
 _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
 _am_tools=${am_cv_prog_tar_$1-$_am_tools}
 # Do not fold the above two line into one, because Tru64 sh and
-# Solaris sh will not grok spaces in the rhs of `-'.
+# Solaris sh will not grok spaces in the rhs of '-'.
 for _am_tool in $_am_tools
 do
   case $_am_tool in
diff --git a/build-aux/ar-lib b/build-aux/ar-lib
new file mode 100755
index 0000000..67f5f36
--- /dev/null
+++ b/build-aux/ar-lib
@@ -0,0 +1,270 @@
+#! /bin/sh
+# Wrapper for Microsoft lib.exe
+
+me=ar-lib
+scriptversion=2012-03-01.08; # UTC
+
+# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+# Written by Peter Rosin <peda at lysator.liu.se>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake at gnu.org> or send patches to
+# <automake-patches at gnu.org>.
+
+
+# func_error message
+func_error ()
+{
+  echo "$me: $1" 1>&2
+  exit 1
+}
+
+file_conv=
+
+# func_file_conv build_file
+# Convert a $build file to $host form and store it in $file
+# Currently only supports Windows hosts.
+func_file_conv ()
+{
+  file=$1
+  case $file in
+    / | /[!/]*) # absolute file, and not a UNC file
+      if test -z "$file_conv"; then
+	# lazily determine how to convert abs files
+	case `uname -s` in
+	  MINGW*)
+	    file_conv=mingw
+	    ;;
+	  CYGWIN*)
+	    file_conv=cygwin
+	    ;;
+	  *)
+	    file_conv=wine
+	    ;;
+	esac
+      fi
+      case $file_conv in
+	mingw)
+	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
+	  ;;
+	cygwin)
+	  file=`cygpath -m "$file" || echo "$file"`
+	  ;;
+	wine)
+	  file=`winepath -w "$file" || echo "$file"`
+	  ;;
+      esac
+      ;;
+  esac
+}
+
+# func_at_file at_file operation archive
+# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
+# for each of them.
+# When interpreting the content of the @FILE, do NOT use func_file_conv,
+# since the user would need to supply preconverted file names to
+# binutils ar, at least for MinGW.
+func_at_file ()
+{
+  operation=$2
+  archive=$3
+  at_file_contents=`cat "$1"`
+  eval set x "$at_file_contents"
+  shift
+
+  for member
+  do
+    $AR -NOLOGO $operation:"$member" "$archive" || exit $?
+  done
+}
+
+case $1 in
+  '')
+     func_error "no command.  Try '$0 --help' for more information."
+     ;;
+  -h | --h*)
+    cat <<EOF
+Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
+
+Members may be specified in a file named with @FILE.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "$me, version $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test $# -lt 3; then
+  func_error "you must specify a program, an action and an archive"
+fi
+
+AR=$1
+shift
+while :
+do
+  if test $# -lt 2; then
+    func_error "you must specify a program, an action and an archive"
+  fi
+  case $1 in
+    -lib | -LIB \
+    | -ltcg | -LTCG \
+    | -machine* | -MACHINE* \
+    | -subsystem* | -SUBSYSTEM* \
+    | -verbose | -VERBOSE \
+    | -wx* | -WX* )
+      AR="$AR $1"
+      shift
+      ;;
+    *)
+      action=$1
+      shift
+      break
+      ;;
+  esac
+done
+orig_archive=$1
+shift
+func_file_conv "$orig_archive"
+archive=$file
+
+# strip leading dash in $action
+action=${action#-}
+
+delete=
+extract=
+list=
+quick=
+replace=
+index=
+create=
+
+while test -n "$action"
+do
+  case $action in
+    d*) delete=yes  ;;
+    x*) extract=yes ;;
+    t*) list=yes    ;;
+    q*) quick=yes   ;;
+    r*) replace=yes ;;
+    s*) index=yes   ;;
+    S*)             ;; # the index is always updated implicitly
+    c*) create=yes  ;;
+    u*)             ;; # TODO: don't ignore the update modifier
+    v*)             ;; # TODO: don't ignore the verbose modifier
+    *)
+      func_error "unknown action specified"
+      ;;
+  esac
+  action=${action#?}
+done
+
+case $delete$extract$list$quick$replace,$index in
+  yes,* | ,yes)
+    ;;
+  yesyes*)
+    func_error "more than one action specified"
+    ;;
+  *)
+    func_error "no action specified"
+    ;;
+esac
+
+if test -n "$delete"; then
+  if test ! -f "$orig_archive"; then
+    func_error "archive not found"
+  fi
+  for member
+  do
+    case $1 in
+      @*)
+        func_at_file "${1#@}" -REMOVE "$archive"
+        ;;
+      *)
+        func_file_conv "$1"
+        $AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
+        ;;
+    esac
+  done
+
+elif test -n "$extract"; then
+  if test ! -f "$orig_archive"; then
+    func_error "archive not found"
+  fi
+  if test $# -gt 0; then
+    for member
+    do
+      case $1 in
+        @*)
+          func_at_file "${1#@}" -EXTRACT "$archive"
+          ;;
+        *)
+          func_file_conv "$1"
+          $AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
+          ;;
+      esac
+    done
+  else
+    $AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
+    do
+      $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
+    done
+  fi
+
+elif test -n "$quick$replace"; then
+  if test ! -f "$orig_archive"; then
+    if test -z "$create"; then
+      echo "$me: creating $orig_archive"
+    fi
+    orig_archive=
+  else
+    orig_archive=$archive
+  fi
+
+  for member
+  do
+    case $1 in
+    @*)
+      func_file_conv "${1#@}"
+      set x "$@" "@$file"
+      ;;
+    *)
+      func_file_conv "$1"
+      set x "$@" "$file"
+      ;;
+    esac
+    shift
+    shift
+  done
+
+  if test -n "$orig_archive"; then
+    $AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
+  else
+    $AR -NOLOGO -OUT:"$archive" "$@" || exit $?
+  fi
+
+elif test -n "$list"; then
+  if test ! -f "$orig_archive"; then
+    func_error "archive not found"
+  fi
+  $AR -NOLOGO -LIST "$archive" || exit $?
+fi
diff --git a/build-aux/config.guess b/build-aux/config.guess
index dc84c68..c0adba9 100755
--- a/build-aux/config.guess
+++ b/build-aux/config.guess
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-#   Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+#   2011, 2012 Free Software Foundation, Inc.
 
-timestamp='2009-11-20'
+timestamp='2012-06-10'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -17,9 +17,7 @@ timestamp='2009-11-20'
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -56,8 +54,9 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -144,7 +143,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:NetBSD:*:*)
 	# NetBSD (nbsd) targets should (where applicable) match one or
-	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
 	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
 	# switched to ELF, *-*-netbsd* would select the old
 	# object file format.  This provides both forward
@@ -180,7 +179,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 		fi
 		;;
 	    *)
-	        os=netbsd
+		os=netbsd
 		;;
 	esac
 	# The OS release
@@ -223,7 +222,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
 		;;
 	*5.*)
-	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
 		;;
 	esac
 	# According to Compaq, /usr/sbin/psrinfo has been available on
@@ -269,7 +268,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
 	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	exit ;;
+	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+	exitcode=$?
+	trap '' 0
+	exit $exitcode ;;
     Alpha\ *:Windows_NT*:*)
 	# How do we know it's Interix rather than the generic POSIX subsystem?
 	# Should we change UNAME_MACHINE based on the output of uname instead
@@ -295,7 +297,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	echo s390-ibm-zvmoe
 	exit ;;
     *:OS400:*:*)
-        echo powerpc-ibm-os400
+	echo powerpc-ibm-os400
 	exit ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
@@ -394,23 +396,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
+	echo m68k-atari-mint${UNAME_RELEASE}
 	exit ;;
     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
 	echo m68k-atari-mint${UNAME_RELEASE}
-        exit ;;
+	exit ;;
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
+	echo m68k-atari-mint${UNAME_RELEASE}
 	exit ;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-        echo m68k-milan-mint${UNAME_RELEASE}
-        exit ;;
+	echo m68k-milan-mint${UNAME_RELEASE}
+	exit ;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-        echo m68k-hades-mint${UNAME_RELEASE}
-        exit ;;
+	echo m68k-hades-mint${UNAME_RELEASE}
+	exit ;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-        echo m68k-unknown-mint${UNAME_RELEASE}
-        exit ;;
+	echo m68k-unknown-mint${UNAME_RELEASE}
+	exit ;;
     m68k:machten:*:*)
 	echo m68k-apple-machten${UNAME_RELEASE}
 	exit ;;
@@ -480,8 +482,8 @@ EOF
 	echo m88k-motorola-sysv3
 	exit ;;
     AViiON:dgux:*:*)
-        # DG/UX returns AViiON for all architectures
-        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	# DG/UX returns AViiON for all architectures
+	UNAME_PROCESSOR=`/usr/bin/uname -p`
 	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
 	then
 	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
@@ -494,7 +496,7 @@ EOF
 	else
 	    echo i586-dg-dgux${UNAME_RELEASE}
 	fi
- 	exit ;;
+	exit ;;
     M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
 	echo m88k-dolphin-sysv3
 	exit ;;
@@ -551,7 +553,7 @@ EOF
 		echo rs6000-ibm-aix3.2
 	fi
 	exit ;;
-    *:AIX:*:[456])
+    *:AIX:*:[4567])
 	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
 	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
 		IBM_ARCH=rs6000
@@ -594,52 +596,52 @@ EOF
 	    9000/[678][0-9][0-9])
 		if [ -x /usr/bin/getconf ]; then
 		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-                    case "${sc_cpu_version}" in
-                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-                      532)                      # CPU_PA_RISC2_0
-                        case "${sc_kernel_bits}" in
-                          32) HP_ARCH="hppa2.0n" ;;
-                          64) HP_ARCH="hppa2.0w" ;;
+		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+		    case "${sc_cpu_version}" in
+		      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+		      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+		      532)                      # CPU_PA_RISC2_0
+			case "${sc_kernel_bits}" in
+			  32) HP_ARCH="hppa2.0n" ;;
+			  64) HP_ARCH="hppa2.0w" ;;
 			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-                        esac ;;
-                    esac
+			esac ;;
+		    esac
 		fi
 		if [ "${HP_ARCH}" = "" ]; then
 		    eval $set_cc_for_build
-		    sed 's/^              //' << EOF >$dummy.c
+		    sed 's/^		//' << EOF >$dummy.c
 
-              #define _HPUX_SOURCE
-              #include <stdlib.h>
-              #include <unistd.h>
+		#define _HPUX_SOURCE
+		#include <stdlib.h>
+		#include <unistd.h>
 
-              int main ()
-              {
-              #if defined(_SC_KERNEL_BITS)
-                  long bits = sysconf(_SC_KERNEL_BITS);
-              #endif
-                  long cpu  = sysconf (_SC_CPU_VERSION);
+		int main ()
+		{
+		#if defined(_SC_KERNEL_BITS)
+		    long bits = sysconf(_SC_KERNEL_BITS);
+		#endif
+		    long cpu  = sysconf (_SC_CPU_VERSION);
 
-                  switch (cpu)
-              	{
-              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-              	case CPU_PA_RISC2_0:
-              #if defined(_SC_KERNEL_BITS)
-              	    switch (bits)
-              		{
-              		case 64: puts ("hppa2.0w"); break;
-              		case 32: puts ("hppa2.0n"); break;
-              		default: puts ("hppa2.0"); break;
-              		} break;
-              #else  /* !defined(_SC_KERNEL_BITS) */
-              	    puts ("hppa2.0"); break;
-              #endif
-              	default: puts ("hppa1.0"); break;
-              	}
-                  exit (0);
-              }
+		    switch (cpu)
+			{
+			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+			case CPU_PA_RISC2_0:
+		#if defined(_SC_KERNEL_BITS)
+			    switch (bits)
+				{
+				case 64: puts ("hppa2.0w"); break;
+				case 32: puts ("hppa2.0n"); break;
+				default: puts ("hppa2.0"); break;
+				} break;
+		#else  /* !defined(_SC_KERNEL_BITS) */
+			    puts ("hppa2.0"); break;
+		#endif
+			default: puts ("hppa1.0"); break;
+			}
+		    exit (0);
+		}
 EOF
 		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
 		    test -z "$HP_ARCH" && HP_ARCH=hppa
@@ -730,22 +732,22 @@ EOF
 	exit ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
 	echo c1-convex-bsd
-        exit ;;
+	exit ;;
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
 	if getsysinfo -f scalar_acc
 	then echo c32-convex-bsd
 	else echo c2-convex-bsd
 	fi
-        exit ;;
+	exit ;;
     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
 	echo c34-convex-bsd
-        exit ;;
+	exit ;;
     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
 	echo c38-convex-bsd
-        exit ;;
+	exit ;;
     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
 	echo c4-convex-bsd
-        exit ;;
+	exit ;;
     CRAY*Y-MP:*:*:*)
 	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit ;;
@@ -769,14 +771,14 @@ EOF
 	exit ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
 	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-        exit ;;
+	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit ;;
     5000:UNIX_System_V:4.*:*)
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
-        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
 	exit ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
@@ -788,13 +790,12 @@ EOF
 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit ;;
     *:FreeBSD:*:*)
-	case ${UNAME_MACHINE} in
-	    pc98)
-		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	UNAME_PROCESSOR=`/usr/bin/uname -p`
+	case ${UNAME_PROCESSOR} in
 	    amd64)
 		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
 	    *)
-		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+		echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
 	esac
 	exit ;;
     i*:CYGWIN*:*)
@@ -803,15 +804,18 @@ EOF
     *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
+    i*:MSYS*:*)
+	echo ${UNAME_MACHINE}-pc-msys
+	exit ;;
     i*:windows32*:*)
-    	# uname -m includes "-pc" on this system.
-    	echo ${UNAME_MACHINE}-mingw32
+	# uname -m includes "-pc" on this system.
+	echo ${UNAME_MACHINE}-mingw32
 	exit ;;
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
 	exit ;;
     *:Interix*:*)
-    	case ${UNAME_MACHINE} in
+	case ${UNAME_MACHINE} in
 	    x86)
 		echo i586-pc-interix${UNAME_RELEASE}
 		exit ;;
@@ -857,6 +861,13 @@ EOF
     i*86:Minix:*:*)
 	echo ${UNAME_MACHINE}-pc-minix
 	exit ;;
+    aarch64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    aarch64_be:Linux:*:*)
+	UNAME_MACHINE=aarch64_be
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
     alpha:Linux:*:*)
 	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
 	  EV5)   UNAME_MACHINE=alphaev5 ;;
@@ -866,7 +877,7 @@ EOF
 	  EV6)   UNAME_MACHINE=alphaev6 ;;
 	  EV67)  UNAME_MACHINE=alphaev67 ;;
 	  EV68*) UNAME_MACHINE=alphaev68 ;;
-        esac
+	esac
 	objdump --private-headers /bin/sh | grep -q ld.so.1
 	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
 	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
@@ -878,20 +889,29 @@ EOF
 	then
 	    echo ${UNAME_MACHINE}-unknown-linux-gnu
 	else
-	    echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+		| grep -q __ARM_PCS_VFP
+	    then
+		echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+	    else
+		echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
+	    fi
 	fi
 	exit ;;
     avr32*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     cris:Linux:*:*)
-	echo cris-axis-linux-gnu
+	echo ${UNAME_MACHINE}-axis-linux-gnu
 	exit ;;
     crisv32:Linux:*:*)
-	echo crisv32-axis-linux-gnu
+	echo ${UNAME_MACHINE}-axis-linux-gnu
 	exit ;;
     frv:Linux:*:*)
-    	echo frv-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    hexagon:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     i*86:Linux:*:*)
 	LIBC=gnu
@@ -933,7 +953,7 @@ EOF
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
 	;;
     or32:Linux:*:*)
-	echo or32-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     padre:Linux:*:*)
 	echo sparc-unknown-linux-gnu
@@ -959,7 +979,7 @@ EOF
 	echo ${UNAME_MACHINE}-ibm-linux
 	exit ;;
     sh64*:Linux:*:*)
-    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     sh*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -967,14 +987,17 @@ EOF
     sparc:Linux:*:* | sparc64:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
+    tile*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
     vax:Linux:*:*)
 	echo ${UNAME_MACHINE}-dec-linux-gnu
 	exit ;;
     x86_64:Linux:*:*)
-	echo x86_64-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     xtensa*:Linux:*:*)
-    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     i*86:DYNIX/ptx:4*:*)
 	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -983,11 +1006,11 @@ EOF
 	echo i386-sequent-sysv4
 	exit ;;
     i*86:UNIX_SV:4.2MP:2.*)
-        # Unixware is an offshoot of SVR4, but it has its own version
-        # number series starting with 2...
-        # I am not positive that other SVR4 systems won't match this,
+	# Unixware is an offshoot of SVR4, but it has its own version
+	# number series starting with 2...
+	# I am not positive that other SVR4 systems won't match this,
 	# I just have to hope.  -- rms.
-        # Use sysv4.2uw... so that sysv4* matches it.
+	# Use sysv4.2uw... so that sysv4* matches it.
 	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
 	exit ;;
     i*86:OS/2:*:*)
@@ -1019,7 +1042,7 @@ EOF
 	fi
 	exit ;;
     i*86:*:5:[678]*)
-    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
+	# UnixWare 7.x, OpenUNIX and OpenServer 6.
 	case `/bin/uname -X | grep "^Machine"` in
 	    *486*)	     UNAME_MACHINE=i486 ;;
 	    *Pentium)	     UNAME_MACHINE=i586 ;;
@@ -1047,13 +1070,13 @@ EOF
 	exit ;;
     pc:*:*:*)
 	# Left here for compatibility:
-        # uname -m prints for DJGPP always 'pc', but it prints nothing about
-        # the processor, so we play safe by assuming i586.
+	# uname -m prints for DJGPP always 'pc', but it prints nothing about
+	# the processor, so we play safe by assuming i586.
 	# Note: whatever this is, it MUST be the same as what config.sub
 	# prints for the "djgpp" host, or else GDB configury will decide that
 	# this is a cross-build.
 	echo i586-pc-msdosdjgpp
-        exit ;;
+	exit ;;
     Intel:Mach:3*:*)
 	echo i386-pc-mach3
 	exit ;;
@@ -1088,8 +1111,8 @@ EOF
 	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
 	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-          && { echo i486-ncr-sysv4; exit; } ;;
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && { echo i486-ncr-sysv4; exit; } ;;
     NCR*:*:4.2:* | MPRAS*:*:4.2:*)
 	OS_REL='.3'
 	test -r /etc/.relid \
@@ -1132,10 +1155,10 @@ EOF
 		echo ns32k-sni-sysv
 	fi
 	exit ;;
-    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                      # says <Richard.M.Bartel at ccMail.Census.GOV>
-        echo i586-unisys-sysv4
-        exit ;;
+    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+			# says <Richard.M.Bartel at ccMail.Census.GOV>
+	echo i586-unisys-sysv4
+	exit ;;
     *:UNIX_System_V:4*:FTX*)
 	# From Gerald Hewes <hewes at openmarket.com>.
 	# How about differentiating between stratus architectures? -djm
@@ -1161,11 +1184,11 @@ EOF
 	exit ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
 	if [ -d /usr/nec ]; then
-	        echo mips-nec-sysv${UNAME_RELEASE}
+		echo mips-nec-sysv${UNAME_RELEASE}
 	else
-	        echo mips-unknown-sysv${UNAME_RELEASE}
+		echo mips-unknown-sysv${UNAME_RELEASE}
 	fi
-        exit ;;
+	exit ;;
     BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
 	echo powerpc-be-beos
 	exit ;;
@@ -1230,7 +1253,10 @@ EOF
     *:QNX:*:4*)
 	echo i386-pc-qnx
 	exit ;;
-    NSE-?:NONSTOP_KERNEL:*:*)
+    NEO-?:NONSTOP_KERNEL:*:*)
+	echo neo-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    NSE-*:NONSTOP_KERNEL:*:*)
 	echo nse-tandem-nsk${UNAME_RELEASE}
 	exit ;;
     NSR-?:NONSTOP_KERNEL:*:*)
@@ -1275,13 +1301,13 @@ EOF
 	echo pdp10-unknown-its
 	exit ;;
     SEI:*:*:SEIUX)
-        echo mips-sei-seiux${UNAME_RELEASE}
+	echo mips-sei-seiux${UNAME_RELEASE}
 	exit ;;
     *:DragonFly:*:*)
 	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit ;;
     *:*VMS:*:*)
-    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	UNAME_MACHINE=`(uname -p) 2>/dev/null`
 	case "${UNAME_MACHINE}" in
 	    A*) echo alpha-dec-vms ; exit ;;
 	    I*) echo ia64-dec-vms ; exit ;;
@@ -1299,6 +1325,9 @@ EOF
     i*86:AROS:*:*)
 	echo ${UNAME_MACHINE}-pc-aros
 	exit ;;
+    x86_64:VMkernel:*:*)
+	echo ${UNAME_MACHINE}-unknown-esx
+	exit ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
@@ -1321,11 +1350,11 @@ main ()
 #include <sys/param.h>
   printf ("m68k-sony-newsos%s\n",
 #ifdef NEWSOS4
-          "4"
+	"4"
 #else
-	  ""
+	""
 #endif
-         ); exit (0);
+	); exit (0);
 #endif
 #endif
 
diff --git a/build-aux/config.sub b/build-aux/config.sub
index 2a55a50..6205f84 100755
--- a/build-aux/config.sub
+++ b/build-aux/config.sub
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-#   Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+#   2011, 2012 Free Software Foundation, Inc.
 
-timestamp='2009-11-20'
+timestamp='2012-04-18'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -21,9 +21,7 @@ timestamp='2009-11-20'
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -75,8 +73,9 @@ Report bugs and patches to <config-patches at gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -123,13 +122,18 @@ esac
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
-  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+  linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+  knetbsd*-gnu* | netbsd*-gnu* | \
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
+  android-linux)
+    os=-linux-android
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+    ;;
   *)
     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
     if [ $basic_machine != $1 ]
@@ -156,8 +160,8 @@ case $os in
 		os=
 		basic_machine=$1
 		;;
-        -bluegene*)
-	        os=-cnk
+	-bluegene*)
+		os=-cnk
 		;;
 	-sim | -cisco | -oki | -wec | -winbond)
 		os=
@@ -173,10 +177,10 @@ case $os in
 		os=-chorusos
 		basic_machine=$1
 		;;
- 	-chorusrdb)
- 		os=-chorusrdb
+	-chorusrdb)
+		os=-chorusrdb
 		basic_machine=$1
- 		;;
+		;;
 	-hiux*)
 		os=-hiuxwe2
 		;;
@@ -221,6 +225,12 @@ case $os in
 	-isc*)
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
+	-lynx*178)
+		os=-lynxos178
+		;;
+	-lynx*5)
+		os=-lynxos5
+		;;
 	-lynx*)
 		os=-lynxos
 		;;
@@ -245,17 +255,22 @@ case $basic_machine in
 	# Some are omitted here because they have special meanings below.
 	1750a | 580 \
 	| a29k \
+	| aarch64 | aarch64_be \
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
 	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+        | be32 | be64 \
 	| bfin \
 	| c4x | clipper \
 	| d10v | d30v | dlx | dsp16xx \
+	| epiphany \
 	| fido | fr30 | frv \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| hexagon \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
+	| le32 | le64 \
 	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
 	| maxq | mb | microblaze | mcore | mep | metag \
@@ -281,29 +296,39 @@ case $basic_machine in
 	| moxie \
 	| mt \
 	| msp430 \
+	| nds32 | nds32le | nds32be \
 	| nios | nios2 \
 	| ns16k | ns32k \
+	| open8 \
 	| or32 \
 	| pdp10 | pdp11 | pj | pjl \
-	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
-	| rx \
+	| rl78 | rx \
 	| score \
 	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
-	| spu | strongarm \
-	| tahoe | thumb | tic4x | tic80 | tron \
+	| spu \
+	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
 	| ubicom32 \
-	| v850 | v850e \
+	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
 	| we32k \
-	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| x86 | xc16x | xstormy16 | xtensa \
 	| z8k | z80)
 		basic_machine=$basic_machine-unknown
 		;;
-	m6811 | m68hc11 | m6812 | m68hc12 | picochip)
-		# Motorola 68HC11/12.
+	c54x)
+		basic_machine=tic54x-unknown
+		;;
+	c55x)
+		basic_machine=tic55x-unknown
+		;;
+	c6x)
+		basic_machine=tic6x-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
@@ -313,6 +338,21 @@ case $basic_machine in
 		basic_machine=mt-unknown
 		;;
 
+	strongarm | thumb | xscale)
+		basic_machine=arm-unknown
+		;;
+	xgate)
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	xscaleeb)
+		basic_machine=armeb-unknown
+		;;
+
+	xscaleel)
+		basic_machine=armel-unknown
+		;;
+
 	# We use `pc' rather than `unknown'
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
@@ -327,21 +367,25 @@ case $basic_machine in
 	# Recognize the basic CPU types with company name.
 	580-* \
 	| a29k-* \
+	| aarch64-* | aarch64_be-* \
 	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
+	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
-	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* \
 	| clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
 	| elxsi-* \
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| hexagon-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| ip2k-* | iq2000-* \
+	| le32-* | le64-* \
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
@@ -367,25 +411,29 @@ case $basic_machine in
 	| mmix-* \
 	| mt-* \
 	| msp430-* \
+	| nds32-* | nds32le-* | nds32be-* \
 	| nios-* | nios2-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
+	| open8-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
 	| pyramid-* \
-	| romp-* | rs6000-* | rx-* \
+	| rl78-* | romp-* | rs6000-* | rx-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
-	| tahoe-* | thumb-* \
-	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+	| tahoe-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+	| tile*-* \
 	| tron-* \
 	| ubicom32-* \
-	| v850-* | v850e-* | vax-* \
+	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+	| vax-* \
 	| we32k-* \
-	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* \
 	| xstormy16-* | xtensa*-* \
 	| ymp-* \
 	| z8k-* | z80-*)
@@ -410,7 +458,7 @@ case $basic_machine in
 		basic_machine=a29k-amd
 		os=-udi
 		;;
-    	abacus)
+	abacus)
 		basic_machine=abacus-unknown
 		;;
 	adobe68k)
@@ -480,11 +528,20 @@ case $basic_machine in
 		basic_machine=powerpc-ibm
 		os=-cnk
 		;;
+	c54x-*)
+		basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	c55x-*)
+		basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	c6x-*)
+		basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
 	c90)
 		basic_machine=c90-cray
 		os=-unicos
 		;;
-        cegcc)
+	cegcc)
 		basic_machine=arm-unknown
 		os=-cegcc
 		;;
@@ -516,7 +573,7 @@ case $basic_machine in
 		basic_machine=craynv-cray
 		os=-unicosmp
 		;;
-	cr16)
+	cr16 | cr16-*)
 		basic_machine=cr16-unknown
 		os=-elf
 		;;
@@ -674,7 +731,6 @@ case $basic_machine in
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
 		;;
-# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
 	i*86v32)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv32
@@ -732,7 +788,7 @@ case $basic_machine in
 		basic_machine=ns32k-utek
 		os=-sysv
 		;;
-        microblaze)
+	microblaze)
 		basic_machine=microblaze-xilinx
 		;;
 	mingw32)
@@ -771,10 +827,18 @@ case $basic_machine in
 	ms1-*)
 		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
 		;;
+	msys)
+		basic_machine=i386-pc
+		os=-msys
+		;;
 	mvs)
 		basic_machine=i370-ibm
 		os=-mvs
 		;;
+	nacl)
+		basic_machine=le32-unknown
+		os=-nacl
+		;;
 	ncr3000)
 		basic_machine=i486-ncr
 		os=-sysv4
@@ -839,6 +903,12 @@ case $basic_machine in
 	np1)
 		basic_machine=np1-gould
 		;;
+	neo-tandem)
+		basic_machine=neo-tandem
+		;;
+	nse-tandem)
+		basic_machine=nse-tandem
+		;;
 	nsr-tandem)
 		basic_machine=nsr-tandem
 		;;
@@ -921,9 +991,10 @@ case $basic_machine in
 		;;
 	power)	basic_machine=power-ibm
 		;;
-	ppc)	basic_machine=powerpc-unknown
+	ppc | ppcbe)	basic_machine=powerpc-unknown
 		;;
-	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+	ppc-* | ppcbe-*)
+		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	ppcle | powerpclittle | ppc-le | powerpc-little)
 		basic_machine=powerpcle-unknown
@@ -1017,6 +1088,9 @@ case $basic_machine in
 		basic_machine=i860-stratus
 		os=-sysv4
 		;;
+	strongarm-* | thumb-*)
+		basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
 	sun2)
 		basic_machine=m68000-sun
 		;;
@@ -1073,20 +1147,8 @@ case $basic_machine in
 		basic_machine=t90-cray
 		os=-unicos
 		;;
-	tic54x | c54x*)
-		basic_machine=tic54x-unknown
-		os=-coff
-		;;
-	tic55x | c55x*)
-		basic_machine=tic55x-unknown
-		os=-coff
-		;;
-	tic6x | c6x*)
-		basic_machine=tic6x-unknown
-		os=-coff
-		;;
 	tile*)
-		basic_machine=tile-unknown
+		basic_machine=$basic_machine-unknown
 		os=-linux-gnu
 		;;
 	tx39)
@@ -1156,6 +1218,9 @@ case $basic_machine in
 	xps | xps100)
 		basic_machine=xps100-honeywell
 		;;
+	xscale-* | xscalee[bl]-*)
+		basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+		;;
 	ymp)
 		basic_machine=ymp-cray
 		os=-unicos
@@ -1253,11 +1318,11 @@ esac
 if [ x"$os" != x"" ]
 then
 case $os in
-        # First match some system type aliases
-        # that might get confused with valid system types.
+	# First match some system type aliases
+	# that might get confused with valid system types.
 	# -solaris* is a basic system type, with this one exception.
-        -auroraux)
-	        os=-auroraux
+	-auroraux)
+		os=-auroraux
 		;;
 	-solaris1 | -solaris1.*)
 		os=`echo $os | sed -e 's|solaris1|sunos4|'`
@@ -1293,8 +1358,9 @@ case $os in
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* | -cegcc* \
-	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -linux-android* \
+	      | -linux-newlib* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
@@ -1341,7 +1407,7 @@ case $os in
 	-opened*)
 		os=-openedition
 		;;
-        -os400*)
+	-os400*)
 		os=-os400
 		;;
 	-wince*)
@@ -1390,7 +1456,7 @@ case $os in
 	-sinix*)
 		os=-sysv4
 		;;
-        -tpf*)
+	-tpf*)
 		os=-tpf
 		;;
 	-triton*)
@@ -1435,6 +1501,8 @@ case $os in
 	-dicos*)
 		os=-dicos
 		;;
+	-nacl*)
+		;;
 	-none)
 		;;
 	*)
@@ -1457,10 +1525,10 @@ else
 # system, and we'll never get to this point.
 
 case $basic_machine in
-        score-*)
+	score-*)
 		os=-elf
 		;;
-        spu-*)
+	spu-*)
 		os=-elf
 		;;
 	*-acorn)
@@ -1472,8 +1540,20 @@ case $basic_machine in
 	arm*-semi)
 		os=-aout
 		;;
-        c4x-* | tic4x-*)
-        	os=-coff
+	c4x-* | tic4x-*)
+		os=-coff
+		;;
+	hexagon-*)
+		os=-elf
+		;;
+	tic54x-*)
+		os=-coff
+		;;
+	tic55x-*)
+		os=-coff
+		;;
+	tic6x-*)
+		os=-coff
 		;;
 	# This must come before the *-dec entry.
 	pdp10-*)
@@ -1493,14 +1573,11 @@ case $basic_machine in
 		;;
 	m68000-sun)
 		os=-sunos3
-		# This also exists in the configure program, but was not the
-		# default.
-		# os=-sunos4
 		;;
 	m68*-cisco)
 		os=-aout
 		;;
-        mep-*)
+	mep-*)
 		os=-elf
 		;;
 	mips*-cisco)
@@ -1527,7 +1604,7 @@ case $basic_machine in
 	*-ibm)
 		os=-aix
 		;;
-    	*-knuth)
+	*-knuth)
 		os=-mmixware
 		;;
 	*-wec)
diff --git a/build-aux/depcomp b/build-aux/depcomp
index df8eea7..debb6ff 100755
--- a/build-aux/depcomp
+++ b/build-aux/depcomp
@@ -1,10 +1,9 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2009-04-28.21; # UTC
+scriptversion=2012-03-27.16; # UTC
 
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
-# Software Foundation, Inc.
+# Copyright (C) 1999-2012 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -28,7 +27,7 @@ scriptversion=2009-04-28.21; # UTC
 
 case $1 in
   '')
-     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
      exit 1;
      ;;
   -h | --h*)
@@ -40,11 +39,11 @@ as side-effects.
 
 Environment variables:
   depmode     Dependency tracking mode.
-  source      Source file read by `PROGRAMS ARGS'.
-  object      Object file output by `PROGRAMS ARGS'.
+  source      Source file read by 'PROGRAMS ARGS'.
+  object      Object file output by 'PROGRAMS ARGS'.
   DEPDIR      directory where to store dependencies.
   depfile     Dependency file to output.
-  tmpdepfile  Temporary file to use when outputing dependencies.
+  tmpdepfile  Temporary file to use when outputting dependencies.
   libtool     Whether libtool is used (yes/no).
 
 Report bugs to <bug-automake at gnu.org>.
@@ -57,6 +56,12 @@ EOF
     ;;
 esac
 
+# A tabulation character.
+tab='	'
+# A newline character.
+nl='
+'
+
 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
   echo "depcomp: Variables source, object and depmode must be set" 1>&2
   exit 1
@@ -90,10 +95,24 @@ if test "$depmode" = msvcmsys; then
    # This is just like msvisualcpp but w/o cygpath translation.
    # Just convert the backslash-escaped backslashes to single forward
    # slashes to satisfy depend.m4
-   cygpath_u="sed s,\\\\\\\\,/,g"
+   cygpath_u='sed s,\\\\,/,g'
    depmode=msvisualcpp
 fi
 
+if test "$depmode" = msvc7msys; then
+   # This is just like msvc7 but w/o cygpath translation.
+   # Just convert the backslash-escaped backslashes to single forward
+   # slashes to satisfy depend.m4
+   cygpath_u='sed s,\\\\,/,g'
+   depmode=msvc7
+fi
+
+if test "$depmode" = xlc; then
+   # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
+   gccflag=-qmakedep=gcc,-MF
+   depmode=gcc
+fi
+
 case "$depmode" in
 gcc3)
 ## gcc 3 implements dependency tracking that does exactly what
@@ -148,20 +167,21 @@ gcc)
 ## The second -e expression handles DOS-style file names with drive letters.
   sed -e 's/^[^:]*: / /' \
       -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
+## This next piece of magic avoids the "deleted header file" problem.
 ## The problem is that when a header file which appears in a .P file
 ## is deleted, the dependency causes make to die (because there is
 ## typically no way to rebuild the header).  We avoid this by adding
 ## dummy dependencies for each header file.  Too bad gcc doesn't do
 ## this for us directly.
-  tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'.  On the theory
+  tr ' ' "$nl" < "$tmpdepfile" |
+## Some versions of gcc put a space before the ':'.  On the theory
 ## that the space means something, we add a space to the output as
-## well.
+## well.  hp depmode also adds that space, but also prefixes the VPATH
+## to the object.  Take care to not repeat it in the output.
 ## Some versions of the HPUX 10.20 sed can't process this invocation
 ## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
+      | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -193,18 +213,15 @@ sgi)
     # clever and replace this with sed code, as IRIX sed won't handle
     # lines with more than a fixed number of characters (4096 in
     # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
-    # the IRIX cc adds comments like `#:fec' to the end of the
+    # the IRIX cc adds comments like '#:fec' to the end of the
     # dependency line.
-    tr ' ' '
-' < "$tmpdepfile" \
+    tr ' ' "$nl" < "$tmpdepfile" \
     | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
-    tr '
-' ' ' >> "$depfile"
+    tr "$nl" ' ' >> "$depfile"
     echo >> "$depfile"
 
     # The second pass generates a dummy entry for each header file.
-    tr ' ' '
-' < "$tmpdepfile" \
+    tr ' ' "$nl" < "$tmpdepfile" \
    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
    >> "$depfile"
   else
@@ -216,10 +233,17 @@ sgi)
   rm -f "$tmpdepfile"
   ;;
 
+xlc)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
 aix)
   # The C for AIX Compiler uses -M and outputs the dependencies
   # in a .u file.  In older versions, this file always lives in the
-  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # current directory.  Also, the AIX compiler puts '$object:' at the
   # start of each line; $object doesn't have directory information.
   # Version 6 uses the directory in both cases.
   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
@@ -249,12 +273,11 @@ aix)
     test -f "$tmpdepfile" && break
   done
   if test -f "$tmpdepfile"; then
-    # Each line is of the form `foo.o: dependent.h'.
+    # Each line is of the form 'foo.o: dependent.h'.
     # Do two passes, one to just change these to
-    # `$object: dependent.h' and one to simply `dependent.h:'.
+    # '$object: dependent.h' and one to simply 'dependent.h:'.
     sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-    # That's a tab and a space in the [].
-    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+    sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
   else
     # The sourcefile does not contain any dependencies, so just
     # store a dummy comment line, to avoid errors with the Makefile
@@ -265,23 +288,26 @@ aix)
   ;;
 
 icc)
-  # Intel's C compiler understands `-MD -MF file'.  However on
-  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
+  # However on
+  #    $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
   # ICC 7.0 will fill foo.d with something like
   #    foo.o: sub/foo.c
   #    foo.o: sub/foo.h
-  # which is wrong.  We want:
+  # which is wrong.  We want
   #    sub/foo.o: sub/foo.c
   #    sub/foo.o: sub/foo.h
   #    sub/foo.c:
   #    sub/foo.h:
   # ICC 7.1 will output
   #    foo.o: sub/foo.c sub/foo.h
-  # and will wrap long lines using \ :
+  # and will wrap long lines using '\':
   #    foo.o: sub/foo.c ... \
   #     sub/foo.h ... \
   #     ...
-
+  # tcc 0.9.26 (FIXME still under development at the moment of writing)
+  # will emit a similar output, but also prepend the continuation lines
+  # with horizontal tabulation characters.
   "$@" -MD -MF "$tmpdepfile"
   stat=$?
   if test $stat -eq 0; then :
@@ -290,15 +316,21 @@ icc)
     exit $stat
   fi
   rm -f "$depfile"
-  # Each line is of the form `foo.o: dependent.h',
-  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Each line is of the form 'foo.o: dependent.h',
+  # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
   # Do two passes, one to just change these to
-  # `$object: dependent.h' and one to simply `dependent.h:'.
-  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
-  # Some versions of the HPUX 10.20 sed can't process this invocation
-  # correctly.  Breaking it into two sed invocations is a workaround.
-  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
-    sed -e 's/$/ :/' >> "$depfile"
+  # '$object: dependent.h' and one to simply 'dependent.h:'.
+  sed -e "s/^[ $tab][ $tab]*/  /" -e "s,^[^:]*:,$object :," \
+    < "$tmpdepfile" > "$depfile"
+  sed '
+    s/[ '"$tab"'][ '"$tab"']*/ /g
+    s/^ *//
+    s/ *\\*$//
+    s/^[^:]*: *//
+    /^$/d
+    /:$/d
+    s/$/ :/
+  ' < "$tmpdepfile" >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -334,7 +366,7 @@ hp2)
   done
   if test -f "$tmpdepfile"; then
     sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
-    # Add `dependent.h:' lines.
+    # Add 'dependent.h:' lines.
     sed -ne '2,${
 	       s/^ *//
 	       s/ \\*$//
@@ -349,9 +381,9 @@ hp2)
 
 tru64)
    # The Tru64 compiler uses -MD to generate dependencies as a side
-   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
    # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
-   # dependencies in `foo.d' instead, so we check for that too.
+   # dependencies in 'foo.d' instead, so we check for that too.
    # Subdirectories are respected.
    dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
    test "x$dir" = "x$object" && dir=
@@ -397,14 +429,59 @@ tru64)
    done
    if test -f "$tmpdepfile"; then
       sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-      # That's a tab and a space in the [].
-      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+      sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
    else
       echo "#dummy" > "$depfile"
    fi
    rm -f "$tmpdepfile"
    ;;
 
+msvc7)
+  if test "$libtool" = yes; then
+    showIncludes=-Wc,-showIncludes
+  else
+    showIncludes=-showIncludes
+  fi
+  "$@" $showIncludes > "$tmpdepfile"
+  stat=$?
+  grep -v '^Note: including file: ' "$tmpdepfile"
+  if test "$stat" = 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  # The first sed program below extracts the file names and escapes
+  # backslashes for cygpath.  The second sed program outputs the file
+  # name when reading, but also accumulates all include files in the
+  # hold buffer in order to output them again at the end.  This only
+  # works with sed implementations that can handle large buffers.
+  sed < "$tmpdepfile" -n '
+/^Note: including file:  *\(.*\)/ {
+  s//\1/
+  s/\\/\\\\/g
+  p
+}' | $cygpath_u | sort -u | sed -n '
+s/ /\\ /g
+s/\(.*\)/'"$tab"'\1 \\/p
+s/.\(.*\) \\/\1:/
+H
+$ {
+  s/.*/'"$tab"'/
+  G
+  p
+}' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvc7msys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
 #nosideeffect)
   # This comment above is used by automake to tell side-effect
   # dependency tracking mechanisms from slower ones.
@@ -422,7 +499,7 @@ dashmstdout)
     shift
   fi
 
-  # Remove `-o $object'.
+  # Remove '-o $object'.
   IFS=" "
   for arg
   do
@@ -442,15 +519,14 @@ dashmstdout)
   done
 
   test -z "$dashmflag" && dashmflag=-M
-  # Require at least two characters before searching for `:'
+  # Require at least two characters before searching for ':'
   # in the target name.  This is to cope with DOS-style filenames:
-  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
   "$@" $dashmflag |
-    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+    sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
   rm -f "$depfile"
   cat < "$tmpdepfile" > "$depfile"
-  tr ' ' '
-' < "$tmpdepfile" | \
+  tr ' ' "$nl" < "$tmpdepfile" | \
 ## Some versions of the HPUX 10.20 sed can't process this invocation
 ## correctly.  Breaking it into two sed invocations is a workaround.
     sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
@@ -503,9 +579,10 @@ makedepend)
   touch "$tmpdepfile"
   ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
   rm -f "$depfile"
-  cat < "$tmpdepfile" > "$depfile"
-  sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
+  # makedepend may prepend the VPATH from the source file name to the object.
+  # No need to regex-escape $object, excess matching of '.' is harmless.
+  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
 ## Some versions of the HPUX 10.20 sed can't process this invocation
 ## correctly.  Breaking it into two sed invocations is a workaround.
     sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
@@ -525,7 +602,7 @@ cpp)
     shift
   fi
 
-  # Remove `-o $object'.
+  # Remove '-o $object'.
   IFS=" "
   for arg
   do
@@ -594,8 +671,8 @@ msvisualcpp)
   sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
-  echo "	" >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
+  echo "$tab" >> "$depfile"
   sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
diff --git a/build-aux/install-sh b/build-aux/install-sh
index 6781b98..377bb86 100755
--- a/build-aux/install-sh
+++ b/build-aux/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2009-04-28.21; # UTC
+scriptversion=2011-11-20.07; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -35,7 +35,7 @@ scriptversion=2009-04-28.21; # UTC
 # FSF changes to this file are in the public domain.
 #
 # Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
+# 'make' implicit rules from creating a file called install from it
 # when there is no Makefile.
 #
 # This script is compatible with the BSD install script, but was written
@@ -156,6 +156,10 @@ while test $# -ne 0; do
     -s) stripcmd=$stripprog;;
 
     -t) dst_arg=$2
+	# Protect names problematic for 'test' and other utilities.
+	case $dst_arg in
+	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
+	esac
 	shift;;
 
     -T) no_target_directory=true;;
@@ -186,6 +190,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
     fi
     shift # arg
     dst_arg=$arg
+    # Protect names problematic for 'test' and other utilities.
+    case $dst_arg in
+      -* | [=\(\)!]) dst_arg=./$dst_arg;;
+    esac
   done
 fi
 
@@ -194,13 +202,17 @@ if test $# -eq 0; then
     echo "$0: no input file specified." >&2
     exit 1
   fi
-  # It's OK to call `install-sh -d' without argument.
+  # It's OK to call 'install-sh -d' without argument.
   # This can happen when creating conditional directories.
   exit 0
 fi
 
 if test -z "$dir_arg"; then
-  trap '(exit $?); exit' 1 2 13 15
+  do_exit='(exit $ret); exit $ret'
+  trap "ret=129; $do_exit" 1
+  trap "ret=130; $do_exit" 2
+  trap "ret=141; $do_exit" 13
+  trap "ret=143; $do_exit" 15
 
   # Set umask so as not to create temps with too-generous modes.
   # However, 'strip' requires both read and write access to temps.
@@ -228,9 +240,9 @@ fi
 
 for src
 do
-  # Protect names starting with `-'.
+  # Protect names problematic for 'test' and other utilities.
   case $src in
-    -*) src=./$src;;
+    -* | [=\(\)!]) src=./$src;;
   esac
 
   if test -n "$dir_arg"; then
@@ -252,12 +264,7 @@ do
       echo "$0: no destination specified." >&2
       exit 1
     fi
-
     dst=$dst_arg
-    # Protect names starting with `-'.
-    case $dst in
-      -*) dst=./$dst;;
-    esac
 
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
@@ -347,7 +354,7 @@ do
 	      if test -z "$dir_arg" || {
 		   # Check for POSIX incompatibilities with -m.
 		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
-		   # other-writeable bit of parent directory when it shouldn't.
+		   # other-writable bit of parent directory when it shouldn't.
 		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
 		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
 		   case $ls_ld_tmpdir in
@@ -385,7 +392,7 @@ do
 
       case $dstdir in
 	/*) prefix='/';;
-	-*) prefix='./';;
+	[-=\(\)!]*) prefix='./';;
 	*)  prefix='';;
       esac
 
@@ -403,7 +410,7 @@ do
 
       for d
       do
-	test -z "$d" && continue
+	test X"$d" = X && continue
 
 	prefix=$prefix$d
 	if test -d "$prefix"; then
diff --git a/build-aux/missing b/build-aux/missing
index 28055d2..9a55648 100755
--- a/build-aux/missing
+++ b/build-aux/missing
@@ -1,10 +1,9 @@
 #! /bin/sh
 # Common stub for a few missing GNU programs while installing.
 
-scriptversion=2009-04-28.21; # UTC
+scriptversion=2012-01-06.18; # UTC
 
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
-# 2008, 2009 Free Software Foundation, Inc.
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
 # Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
@@ -26,7 +25,7 @@ scriptversion=2009-04-28.21; # UTC
 # the same distribution terms that you use for the rest of that program.
 
 if test $# -eq 0; then
-  echo 1>&2 "Try \`$0 --help' for more information"
+  echo 1>&2 "Try '$0 --help' for more information"
   exit 1
 fi
 
@@ -34,7 +33,7 @@ run=:
 sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
 sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
 
-# In the cases where this matters, `missing' is being run in the
+# In the cases where this matters, 'missing' is being run in the
 # srcdir already.
 if test -f configure.ac; then
   configure_ac=configure.ac
@@ -65,7 +64,7 @@ case $1 in
     echo "\
 $0 [OPTION]... PROGRAM [ARGUMENT]...
 
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+Handle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
 error status if there is no known handling for PROGRAM.
 
 Options:
@@ -74,21 +73,20 @@ Options:
   --run           try to run the given command, and emulate it if it fails
 
 Supported PROGRAM values:
-  aclocal      touch file \`aclocal.m4'
-  autoconf     touch file \`configure'
-  autoheader   touch file \`config.h.in'
+  aclocal      touch file 'aclocal.m4'
+  autoconf     touch file 'configure'
+  autoheader   touch file 'config.h.in'
   autom4te     touch the output file, or create a stub one
-  automake     touch all \`Makefile.in' files
-  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
-  flex         create \`lex.yy.c', if possible, from existing .c
+  automake     touch all 'Makefile.in' files
+  bison        create 'y.tab.[ch]', if possible, from existing .[ch]
+  flex         create 'lex.yy.c', if possible, from existing .c
   help2man     touch the output file
-  lex          create \`lex.yy.c', if possible, from existing .c
+  lex          create 'lex.yy.c', if possible, from existing .c
   makeinfo     touch the output file
-  tar          try tar, gnutar, gtar, then tar without non-portable flags
-  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+  yacc         create 'y.tab.[ch]', if possible, from existing .[ch]
 
-Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
-\`g' are ignored when checking the name.
+Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
+'g' are ignored when checking the name.
 
 Send bug reports to <bug-automake at gnu.org>."
     exit $?
@@ -100,8 +98,8 @@ Send bug reports to <bug-automake at gnu.org>."
     ;;
 
   -*)
-    echo 1>&2 "$0: Unknown \`$1' option"
-    echo 1>&2 "Try \`$0 --help' for more information"
+    echo 1>&2 "$0: Unknown '$1' option"
+    echo 1>&2 "Try '$0 --help' for more information"
     exit 1
     ;;
 
@@ -122,22 +120,13 @@ case $1 in
     # Not GNU programs, they don't have --version.
     ;;
 
-  tar*)
-    if test -n "$run"; then
-       echo 1>&2 "ERROR: \`tar' requires --run"
-       exit 1
-    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
-       exit 1
-    fi
-    ;;
-
   *)
     if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
        # We have it, but it failed.
        exit 1
     elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
        # Could not run --version or --help.  This is probably someone
-       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # running '$TOOL --version' or '$TOOL --help' to check whether
        # $TOOL exists and not knowing $TOOL uses missing.
        exit 1
     fi
@@ -149,27 +138,27 @@ esac
 case $program in
   aclocal*)
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
-         to install the \`Automake' and \`Perl' packages.  Grab them from
+WARNING: '$1' is $msg.  You should only need it if
+         you modified 'acinclude.m4' or '${configure_ac}'.  You might want
+         to install the Automake and Perl packages.  Grab them from
          any GNU archive site."
     touch aclocal.m4
     ;;
 
   autoconf*)
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`${configure_ac}'.  You might want to install the
-         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+WARNING: '$1' is $msg.  You should only need it if
+         you modified '${configure_ac}'.  You might want to install the
+         Autoconf and GNU m4 packages.  Grab them from any GNU
          archive site."
     touch configure
     ;;
 
   autoheader*)
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
-         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+WARNING: '$1' is $msg.  You should only need it if
+         you modified 'acconfig.h' or '${configure_ac}'.  You might want
+         to install the Autoconf and GNU m4 packages.  Grab them
          from any GNU archive site."
     files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
     test -z "$files" && files="config.h"
@@ -186,9 +175,9 @@ WARNING: \`$1' is $msg.  You should only need it if
 
   automake*)
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
-         You might want to install the \`Automake' and \`Perl' packages.
+WARNING: '$1' is $msg.  You should only need it if
+         you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'.
+         You might want to install the Automake and Perl packages.
          Grab them from any GNU archive site."
     find . -type f -name Makefile.am -print |
 	   sed 's/\.am$/.in/' |
@@ -197,10 +186,10 @@ WARNING: \`$1' is $msg.  You should only need it if
 
   autom4te*)
     echo 1>&2 "\
-WARNING: \`$1' is needed, but is $msg.
+WARNING: '$1' is needed, but is $msg.
          You might have modified some files without having the
          proper tools for further handling them.
-         You can get \`$1' as part of \`Autoconf' from any GNU
+         You can get '$1' as part of Autoconf from any GNU
          archive site."
 
     file=`echo "$*" | sed -n "$sed_output"`
@@ -220,13 +209,13 @@ WARNING: \`$1' is needed, but is $msg.
 
   bison*|yacc*)
     echo 1>&2 "\
-WARNING: \`$1' $msg.  You should only need it if
-         you modified a \`.y' file.  You may need the \`Bison' package
+WARNING: '$1' $msg.  You should only need it if
+         you modified a '.y' file.  You may need the Bison package
          in order for those modifications to take effect.  You can get
-         \`Bison' from any GNU archive site."
+         Bison from any GNU archive site."
     rm -f y.tab.c y.tab.h
     if test $# -ne 1; then
-        eval LASTARG="\${$#}"
+        eval LASTARG=\${$#}
 	case $LASTARG in
 	*.y)
 	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
@@ -250,13 +239,13 @@ WARNING: \`$1' $msg.  You should only need it if
 
   lex*|flex*)
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified a \`.l' file.  You may need the \`Flex' package
+WARNING: '$1' is $msg.  You should only need it if
+         you modified a '.l' file.  You may need the Flex package
          in order for those modifications to take effect.  You can get
-         \`Flex' from any GNU archive site."
+         Flex from any GNU archive site."
     rm -f lex.yy.c
     if test $# -ne 1; then
-        eval LASTARG="\${$#}"
+        eval LASTARG=\${$#}
 	case $LASTARG in
 	*.l)
 	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
@@ -273,10 +262,10 @@ WARNING: \`$1' is $msg.  You should only need it if
 
   help2man*)
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
+WARNING: '$1' is $msg.  You should only need it if
 	 you modified a dependency of a manual page.  You may need the
-	 \`Help2man' package in order for those modifications to take
-	 effect.  You can get \`Help2man' from any GNU archive site."
+	 Help2man package in order for those modifications to take
+	 effect.  You can get Help2man from any GNU archive site."
 
     file=`echo "$*" | sed -n "$sed_output"`
     test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
@@ -291,12 +280,12 @@ WARNING: \`$1' is $msg.  You should only need it if
 
   makeinfo*)
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified a \`.texi' or \`.texinfo' file, or any other file
+WARNING: '$1' is $msg.  You should only need it if
+         you modified a '.texi' or '.texinfo' file, or any other file
          indirectly affecting the aspect of the manual.  The spurious
-         call might also be the consequence of using a buggy \`make' (AIX,
-         DU, IRIX).  You might want to install the \`Texinfo' package or
-         the \`GNU make' package.  Grab either from any GNU archive site."
+         call might also be the consequence of using a buggy 'make' (AIX,
+         DU, IRIX).  You might want to install the Texinfo package or
+         the GNU make package.  Grab either from any GNU archive site."
     # The file to touch is that specified with -o ...
     file=`echo "$*" | sed -n "$sed_output"`
     test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
@@ -318,49 +307,14 @@ WARNING: \`$1' is $msg.  You should only need it if
     touch $file
     ;;
 
-  tar*)
-    shift
-
-    # We have already tried tar in the generic part.
-    # Look for gnutar/gtar before invocation to avoid ugly error
-    # messages.
-    if (gnutar --version > /dev/null 2>&1); then
-       gnutar "$@" && exit 0
-    fi
-    if (gtar --version > /dev/null 2>&1); then
-       gtar "$@" && exit 0
-    fi
-    firstarg="$1"
-    if shift; then
-	case $firstarg in
-	*o*)
-	    firstarg=`echo "$firstarg" | sed s/o//`
-	    tar "$firstarg" "$@" && exit 0
-	    ;;
-	esac
-	case $firstarg in
-	*h*)
-	    firstarg=`echo "$firstarg" | sed s/h//`
-	    tar "$firstarg" "$@" && exit 0
-	    ;;
-	esac
-    fi
-
-    echo 1>&2 "\
-WARNING: I can't seem to be able to run \`tar' with the given arguments.
-         You may want to install GNU tar or Free paxutils, or check the
-         command line arguments."
-    exit 1
-    ;;
-
   *)
     echo 1>&2 "\
-WARNING: \`$1' is needed, and is $msg.
+WARNING: '$1' is needed, and is $msg.
          You might have modified some files without having the
-         proper tools for further handling them.  Check the \`README' file,
+         proper tools for further handling them.  Check the 'README' file,
          it often tells you about the needed prerequisites for installing
          this package.  You may also peek at any GNU archive site, in case
-         some other package would contain this missing \`$1' program."
+         some other package would contain this missing '$1' program."
     exit 1
     ;;
 esac
diff --git a/configure b/configure
index d72d39b..e0e44b8 100755
--- a/configure
+++ b/configure
@@ -1,11 +1,9 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for ssm 1.1.20120701.
+# Generated by GNU Autoconf 2.69 for ssm 1.3.
 #
 #
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -134,6 +132,31 @@ export LANGUAGE
 # CDPATH.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
@@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
 else
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1"
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@@ -220,21 +244,25 @@ IFS=$as_save_IFS
 
 
       if test "x$CONFIG_SHELL" != x; then :
-  # We cannot yet assume a decent shell, so we have to provide a
-	# neutralization value for shells without unset; and this also
-	# works around shells that cannot unset nonexistent variables.
-	# Preserve -v and -x to the replacement shell.
-	BASH_ENV=/dev/null
-	ENV=/dev/null
-	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-	export CONFIG_SHELL
-	case $- in # ((((
-	  *v*x* | *x*v* ) as_opts=-vx ;;
-	  *v* ) as_opts=-v ;;
-	  *x* ) as_opts=-x ;;
-	  * ) as_opts= ;;
-	esac
-	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
 fi
 
     if test x$as_have_required = xno; then :
@@ -336,6 +364,14 @@ $as_echo X"$as_dir" |
 
 
 } # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
 # as_fn_append VAR VALUE
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
@@ -457,6 +493,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
   chmod +x "$as_me.lineno" ||
     { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
   # original and so on.  Autoconf is especially sensitive to this).
@@ -491,16 +531,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -512,28 +552,8 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -567,12 +587,12 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='ssm'
 PACKAGE_TARNAME='ssm'
-PACKAGE_VERSION='1.1.20120701'
-PACKAGE_STRING='ssm 1.1.20120701'
+PACKAGE_VERSION='1.3'
+PACKAGE_STRING='ssm 1.3'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
-ac_unique_file="ss_vxedge.h"
+ac_unique_file="ssm_vxedge.h"
 # Factoring default headers for most tests.
 ac_includes_default="\
 #include <stdio.h>
@@ -619,12 +639,6 @@ MAINT
 MAINTAINER_MODE_FALSE
 MAINTAINER_MODE_TRUE
 CXXCPP
-am__fastdepCXX_FALSE
-am__fastdepCXX_TRUE
-CXXDEPMODE
-ac_ct_CXX
-CXXFLAGS
-CXX
 CPP
 OTOOL64
 OTOOL
@@ -633,8 +647,6 @@ NMEDIT
 DSYMUTIL
 MANIFEST_TOOL
 RANLIB
-ac_ct_AR
-AR
 LN_S
 NM
 ac_ct_DUMPBIN
@@ -644,9 +656,29 @@ FGREP
 EGREP
 GREP
 SED
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+LIBTOOL
+OBJDUMP
+DLLTOOL
+AS
 am__fastdepCC_FALSE
 am__fastdepCC_TRUE
 CCDEPMODE
+ac_ct_CC
+CFLAGS
+CC
+ac_ct_AR
+AR
+am__fastdepCXX_FALSE
+am__fastdepCXX_TRUE
+CXXDEPMODE
 am__nodep
 AMDEPBACKSLASH
 AMDEP_FALSE
@@ -656,23 +688,11 @@ am__include
 DEPDIR
 OBJEXT
 EXEEXT
-ac_ct_CC
+ac_ct_CXX
 CPPFLAGS
 LDFLAGS
-CFLAGS
-CC
-host_os
-host_vendor
-host_cpu
-host
-build_os
-build_vendor
-build_cpu
-build
-LIBTOOL
-OBJDUMP
-DLLTOOL
-AS
+CXXFLAGS
+CXX
 AM_BACKSLASH
 AM_DEFAULT_VERBOSITY
 AM_DEFAULT_V
@@ -742,11 +762,11 @@ ac_subst_files=''
 ac_user_opts='
 enable_option_checking
 enable_silent_rules
+enable_dependency_tracking
 enable_shared
 enable_static
 with_pic
 enable_fast_install
-enable_dependency_tracking
 with_gnu_ld
 with_sysroot
 enable_libtool_lock
@@ -756,15 +776,15 @@ enable_ccp4
       ac_precious_vars='build_alias
 host_alias
 target_alias
-CC
-CFLAGS
+CXX
+CXXFLAGS
 LDFLAGS
 LIBS
 CPPFLAGS
-CPP
-CXX
-CXXFLAGS
 CCC
+CC
+CFLAGS
+CPP
 CXXCPP'
 
 
@@ -1221,8 +1241,6 @@ target=$target_alias
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1308,7 +1326,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures ssm 1.1.20120701 to adapt to many kinds of systems.
+\`configure' configures ssm 1.3 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1378,7 +1396,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of ssm 1.1.20120701:";;
+     short | recursive ) echo "Configuration of ssm 1.3:";;
    esac
   cat <<\_ACEOF
 
@@ -1386,39 +1404,42 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --enable-silent-rules          less verbose build output (undo: `make V=1')
-  --disable-silent-rules         verbose build output (undo: `make V=0')
+  --enable-silent-rules   less verbose build output (undo: "make V=1")
+  --disable-silent-rules  verbose build output (undo: "make V=0")
+  --enable-dependency-tracking
+                          do not reject slow dependency extractors
+  --disable-dependency-tracking
+                          speeds up one-time build
   --enable-shared[=PKGS]  build shared libraries [default=no]
   --enable-static[=PKGS]  build static libraries [default=yes]
   --enable-fast-install[=PKGS]
                           optimize for fast installation [default=yes]
-  --disable-dependency-tracking  speeds up one-time build
-  --enable-dependency-tracking   do not reject slow dependency extractors
   --disable-libtool-lock  avoid locking (might break parallel builds)
-  --enable-maintainer-mode  enable make rules and dependencies not useful
-			  (and sometimes confusing) to the casual installer
+  --enable-maintainer-mode
+                          enable make rules and dependencies not useful (and
+                          sometimes confusing) to the casual installer
   --enable-ccp4           link superpose with libccp4 library
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --with-pic              try to use only PIC/non-PIC objects [default=use
+  --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-sysroot=DIR Search for dependent libraries within DIR
                         (or the compiler's sysroot if not specified).
 
 Some influential environment variables:
-  CC          C compiler command
-  CFLAGS      C compiler flags
+  CXX         C++ compiler command
+  CXXFLAGS    C++ compiler flags
   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
               nonstandard directory <lib dir>
   LIBS        libraries to pass to the linker, e.g. -l<library>
   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
+  CC          C compiler command
+  CFLAGS      C compiler flags
   CPP         C preprocessor
-  CXX         C++ compiler command
-  CXXFLAGS    C++ compiler flags
   CXXCPP      C++ preprocessor
 
 Use these variables to override the choices made by `configure' or to help
@@ -1487,10 +1508,10 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-ssm configure 1.1.20120701
-generated by GNU Autoconf 2.68
+ssm configure 1.3
+generated by GNU Autoconf 2.69
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1501,6 +1522,44 @@ fi
 ## Autoconf initialization. ##
 ## ------------------------ ##
 
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_compile
+
 # ac_fn_c_try_compile LINENO
 # --------------------------
 # Try to compile conftest.$ac_ext, and return whether this succeeded.
@@ -1566,7 +1625,7 @@ $as_echo "$ac_try_echo"; } >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -1762,44 +1821,6 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_func
 
-# ac_fn_cxx_try_compile LINENO
-# ----------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_cxx_try_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_cxx_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_cxx_try_compile
-
 # ac_fn_cxx_try_cpp LINENO
 # ------------------------
 # Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -1864,7 +1885,7 @@ $as_echo "$ac_try_echo"; } >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -2060,8 +2081,8 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by ssm $as_me 1.1.20120701, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+It was created by ssm $as_me 1.3, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
 
@@ -2408,7 +2429,6 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-
 ac_aux_dir=
 for ac_dir in build-aux "$srcdir"/build-aux; do
   if test -f "$ac_dir/install-sh"; then
@@ -2442,7 +2462,7 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
 ac_config_headers="$ac_config_headers config.h"
 
-am__api_version='1.11'
+am__api_version='1.12'
 
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
@@ -2481,7 +2501,7 @@ case $as_dir/ in #((
     # by default.
     for ac_prog in ginstall scoinst install; do
       for ac_exec_ext in '' $ac_executable_extensions; do
-	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
 	  if test $ac_prog = install &&
 	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
 	    # AIX install.  It has an incompatible calling convention.
@@ -2539,9 +2559,6 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
 $as_echo_n "checking whether build environment is sane... " >&6; }
-# Just in case
-sleep 1
-echo timestamp > conftest.file
 # Reject unsafe characters in $srcdir or the absolute working directory
 # name.  Accept space and tab only in the latter.
 am_lf='
@@ -2552,32 +2569,40 @@ case `pwd` in
 esac
 case $srcdir in
   *[\\\"\#\$\&\'\`$am_lf\ \	]*)
-    as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
+    as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
 esac
 
-# Do `set' in a subshell so we don't clobber the current shell's
+# Do 'set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
-   if test "$*" = "X"; then
-      # -L didn't work.
-      set X `ls -t "$srcdir/configure" conftest.file`
-   fi
-   rm -f conftest.file
-   if test "$*" != "X $srcdir/configure conftest.file" \
-      && test "$*" != "X conftest.file $srcdir/configure"; then
-
-      # If neither matched, then we have a broken ls.  This can happen
-      # if, for instance, CONFIG_SHELL is bash and it inherits a
-      # broken ls alias from the environment.  This has actually
-      # happened.  Such a system could not be considered "sane".
-      as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
-alias in your environment" "$LINENO" 5
-   fi
-
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$*" = "X"; then
+	# -L didn't work.
+	set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$*" != "X $srcdir/configure conftest.file" \
+	&& test "$*" != "X conftest.file $srcdir/configure"; then
+
+	# If neither matched, then we have a broken ls.  This can happen
+	# if, for instance, CONFIG_SHELL is bash and it inherits a
+	# broken ls alias from the environment.  This has actually
+	# happened.  Such a system could not be considered "sane".
+	as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment" "$LINENO" 5
+     fi
+     if test "$2" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
    test "$2" = conftest.file
    )
 then
@@ -2589,6 +2614,16 @@ Check your system clock" "$LINENO" 5
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+
+rm -f conftest.file
+
 test "$program_prefix" != NONE &&
   program_transform_name="s&^&$program_prefix&;$program_transform_name"
 # Use a double $ so make ignores it.
@@ -2615,8 +2650,8 @@ if eval "$MISSING --run true"; then
   am_missing_run="$MISSING --run "
 else
   am_missing_run=
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
-$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
 fi
 
 if test x"${install_sh}" != xset; then
@@ -2628,10 +2663,10 @@ if test x"${install_sh}" != xset; then
   esac
 fi
 
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'.  However `strip' might not be the right
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
 # tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
+# will honor the 'STRIP' environment variable to overrule this program.
 if test "$cross_compiling" != no; then
   if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
@@ -2650,7 +2685,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_STRIP="${ac_tool_prefix}strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2690,7 +2725,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_STRIP="strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2741,7 +2776,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_prog in mkdir gmkdir; do
 	 for ac_exec_ext in '' $ac_executable_extensions; do
-	   { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+	   as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
 	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
 	     'mkdir (GNU coreutils) '* | \
 	     'mkdir (coreutils) '* | \
@@ -2770,12 +2805,6 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
 $as_echo "$MKDIR_P" >&6; }
 
-mkdir_p="$MKDIR_P"
-case $mkdir_p in
-  [\\/$]* | ?:[\\/]*) ;;
-  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
-esac
-
 for ac_prog in gawk mawk nawk awk
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -2794,7 +2823,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_AWK="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2863,10 +2892,10 @@ if test "${enable_silent_rules+set}" = set; then :
   enableval=$enable_silent_rules;
 fi
 
-case $enable_silent_rules in
-yes) AM_DEFAULT_VERBOSITY=0;;
-no)  AM_DEFAULT_VERBOSITY=1;;
-*)   AM_DEFAULT_VERBOSITY=1;;
+case $enable_silent_rules in # (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=1;;
 esac
 am_make=${MAKE-make}
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
@@ -2919,7 +2948,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='ssm'
- VERSION='1.1.20120701'
+ VERSION='1.3'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2947,6 +2976,12 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
 
 MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+mkdir_p='$(MKDIR_P)'
+
 # We need awk for the "check" target.  The system "awk" is bad on
 # some platforms.
 # Always define AMTAR for backward compatibility.  Yes, it's still used
@@ -2959,171 +2994,512 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
 
-case `pwd` in
-  *\ * | *\	*)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
-$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
-esac
-
-
-
-macro_version='2.4.2'
-macro_revision='1.3337'
-
-
-
-
-
-
-
-
-
-
-
-
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-ltmain="$ac_aux_dir/ltmain.sh"
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-# Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
-$as_echo_n "checking build system type... " >&6; }
-if ${ac_cv_build+:} false; then :
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CXX+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_build_alias=$build_alias
-test "x$ac_build_alias" = x &&
-  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-test "x$ac_build_alias" = x &&
-  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
-$as_echo "$ac_cv_build" >&6; }
-case $ac_cv_build in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
 esac
-build=$ac_cv_build
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_build
-shift
-build_cpu=$1
-build_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-build_os=$*
-IFS=$ac_save_IFS
-case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+    CXX=$ac_ct_CXX
+  fi
+fi
 
+  fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5
+$as_echo_n "checking whether the C++ compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+	;;
+    [ab].out )
+	# We found the default executable, but exeext='' is most
+	# certainly right.
+	break;;
+    *.* )
+	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	then :; else
+	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	fi
+	# We set ac_cv_exeext here because the later test for it is not
+	# safe: cross compilers may not add the suffix if given an `-o'
+	# argument, so we may need to know it at that point already.
+	# Even if this section looks crufty: it has the advantage of
+	# actually working.
+	break;;
+    * )
+	break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
-$as_echo_n "checking host system type... " >&6; }
-if ${ac_cv_host+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$host_alias" = x; then
-  ac_cv_host=$ac_cv_build
 else
-  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+  ac_file=''
 fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C++ compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
-$as_echo "$ac_cv_host" >&6; }
-case $ac_cv_host in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5
+$as_echo_n "checking for C++ compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
 esac
-host=$ac_cv_host
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_host
-shift
-host_cpu=$1
-host_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-host_os=$*
-IFS=$ac_save_IFS
-case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	  break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
 
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
 
-# Backslashify metacharacters that are still active within
-# double-quoted strings.
-sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C++ compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
 
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\(["`\\]\)/\\\1/g'
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+int
+main ()
+{
 
-# Sed substitution to delay expansion of an escaped single quote.
-delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if ${ac_cv_cxx_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
 
-ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
-ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
-$as_echo_n "checking how to print strings... " >&6; }
-# Test print first, because it will be a builtin if present.
-if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
-   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
-  ECHO='print -r --'
-elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
-  ECHO='printf %s\n'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GXX=yes
 else
-  # Use this function as a fallback that always works.
-  func_fallback_echo ()
-  {
-    eval 'cat <<_LTECHO_EOF
-$1
-_LTECHO_EOF'
-  }
-  ECHO='func_fallback_echo'
+  GXX=
 fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if ${ac_cv_prog_cxx_g+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-# func_echo_all arg...
-# Invoke $ECHO with all args, space-separated.
-func_echo_all ()
+int
+main ()
 {
-    $ECHO ""
-}
-
-case "$ECHO" in
-  printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
-$as_echo "printf" >&6; } ;;
-  print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
-$as_echo "print -r" >&6; } ;;
-  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
-$as_echo "cat" >&6; } ;;
-esac
-
-
-
-
-
-
-
-
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+else
+  CXXFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main ()
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
 
+else
+  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main ()
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 DEPDIR="${am__leading_dot}deps"
 
 ac_config_commands="$ac_config_commands depfiles"
@@ -3143,7 +3519,7 @@ am__quote=
 _am_result=none
 # First try GNU make style include.
 echo "include confinc" > confmf
-# Ignore all kinds of additional output from `make'.
+# Ignore all kinds of additional output from 'make'.
 case `$am_make -s -f confmf 2> /dev/null` in #(
 *the\ am__doit\ target*)
   am__include=include
@@ -3173,20 +3549,150 @@ if test "${enable_dependency_tracking+set}" = set; then :
   enableval=$enable_dependency_tracking;
 fi
 
-if test "x$enable_dependency_tracking" != xno; then
-  am_depcomp="$ac_aux_dir/depcomp"
-  AMDEPBACKSLASH='\'
-  am__nodep='_no'
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+  am__nodep='_no'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+depcc="$CXX"  am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok '-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CXX_dependencies_compiler_type=none
+fi
+
 fi
- if test "x$enable_dependency_tracking" != xno; then
-  AMDEP_TRUE=
-  AMDEP_FALSE='#'
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
 else
-  AMDEP_TRUE='#'
-  AMDEP_FALSE=
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
 fi
 
 
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3209,7 +3715,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3249,7 +3755,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3302,7 +3808,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3343,7 +3849,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
@@ -3401,7 +3907,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3445,7 +3951,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3487,284 +3993,34 @@ fi
 
 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5; }
-
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-$as_echo_n "checking whether the C compiler works... " >&6; }
-ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-
-# The possible output files:
-ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
-
-ac_rmfiles=
-for ac_file in $ac_files
-do
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
-    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
-  esac
-done
-rm -f $ac_rmfiles
-
-if { { ac_try="$ac_link_default"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link_default") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
-# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
-# in a Makefile.  We should not override ac_cv_exeext if it was cached,
-# so that the user can short-circuit this test for compilers unknown to
-# Autoconf.
-for ac_file in $ac_files ''
-do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
-	;;
-    [ab].out )
-	# We found the default executable, but exeext='' is most
-	# certainly right.
-	break;;
-    *.* )
-	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
-	then :; else
-	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	fi
-	# We set ac_cv_exeext here because the later test for it is not
-	# safe: cross compilers may not add the suffix if given an `-o'
-	# argument, so we may need to know it at that point already.
-	# Even if this section looks crufty: it has the advantage of
-	# actually working.
-	break;;
-    * )
-	break;;
-  esac
-done
-test "$ac_cv_exeext" = no && ac_cv_exeext=
-
-else
-  ac_file=''
-fi
-if test -z "$ac_file"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-$as_echo_n "checking for C compiler default output file name... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
-ac_exeext=$ac_cv_exeext
-
-rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
-$as_echo_n "checking for suffix of executables... " >&6; }
-if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
-    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	  break;;
-    * ) break;;
-  esac
-done
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f conftest conftest$ac_cv_exeext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
-$as_echo "$ac_cv_exeext" >&6; }
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-int
-main ()
-{
-FILE *f = fopen ("conftest.out", "w");
- return ferror (f) || fclose (f) != 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files="$ac_clean_files conftest.out"
-# Check that the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
-if test "$cross_compiling" != yes; then
-  { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-  if { ac_try='./conftest$ac_cv_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then
-    cross_compiling=no
-  else
-    if test "$cross_compiling" = maybe; then
-	cross_compiling=yes
-    else
-	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5; }
-    fi
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
-
-rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
-$as_echo_n "checking for suffix of object files... " >&6; }
-if ${ac_cv_objext+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { { ac_try="$ac_compile"
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 $as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
   ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  for ac_file in conftest.o conftest.obj conftest.*; do
-  test -f "$ac_file" || continue;
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
-    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
-       break;;
-  esac
+  test $ac_status = 0; }
 done
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
-$as_echo "$ac_cv_objext" >&6; }
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
 if ${ac_cv_c_compiler_gnu+:} false; then :
@@ -3891,8 +4147,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -3988,8 +4243,8 @@ else
   # We make a subdir and do the tests there.  Otherwise we can end up
   # making bogus files that we don't know about and never remove.  For
   # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
   rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
@@ -4024,16 +4279,16 @@ else
     : > sub/conftest.c
     for i in 1 2 3 4 5 6; do
       echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
     # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
     am__obj=sub/conftest.${OBJEXT-o}
     am__minus_obj="-o $am__obj"
     case $depmode in
@@ -4042,8 +4297,8 @@ else
       test "$am__universal" = false || continue
       ;;
     nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
       if test "x$enable_dependency_tracking" = xyes; then
 	continue
       else
@@ -4051,7 +4306,7 @@ else
       fi
       ;;
     msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
+      # This compiler won't grok '-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
       am__obj=conftest.${OBJEXT-o}
@@ -4086,24 +4341,350 @@ else
   cd ..
   rm -rf conftest.dir
 else
-  am_cv_CC_dependencies_compiler_type=none
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in ar lib "link -lib"
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$AR" && break
+  done
+fi
+if test -z "$AR"; then
+  ac_ct_AR=$AR
+  for ac_prog in ar lib "link -lib"
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_AR="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_AR" && break
+done
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+fi
+
+: ${AR=ar}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5
+$as_echo_n "checking the archiver ($AR) interface... " >&6; }
+if ${am_cv_ar_interface+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  am_cv_ar_interface=ar
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int some_variable = 0;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5'
+      { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
+  (eval $am_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+      if test "$ac_status" -eq 0; then
+        am_cv_ar_interface=ar
+      else
+        am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5'
+        { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
+  (eval $am_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+        if test "$ac_status" -eq 0; then
+          am_cv_ar_interface=lib
+        else
+          am_cv_ar_interface=unknown
+        fi
+      fi
+      rm -f conftest.lib libconftest.a
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5
+$as_echo "$am_cv_ar_interface" >&6; }
+
+case $am_cv_ar_interface in
+ar)
+  ;;
+lib)
+  # Microsoft lib, so override with the ar-lib wrapper script.
+  # FIXME: It is wrong to rewrite AR.
+  # But if we don't then we get into trouble of one sort or another.
+  # A longer-term fix would be to have automake use am__AR in this case,
+  # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something
+  # similar.
+  AR="$am_aux_dir/ar-lib $AR"
+  ;;
+unknown)
+  as_fn_error $? "could not determine $AR interface" "$LINENO" 5
+  ;;
+esac
+
+case `pwd` in
+  *\ * | *\	*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.4.2'
+macro_revision='1.3337'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if ${ac_cv_build+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if ${ac_cv_host+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
 fi
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
-$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
-CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
 
- if
-  test "x$enable_dependency_tracking" != xno \
-  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
-  am__fastdepCC_TRUE=
-  am__fastdepCC_FALSE='#'
+
+# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
+$as_echo_n "checking how to print strings... " >&6; }
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='printf %s\n'
 else
-  am__fastdepCC_TRUE='#'
-  am__fastdepCC_FALSE=
+  # Use this function as a fallback that always works.
+  func_fallback_echo ()
+  {
+    eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+  }
+  ECHO='func_fallback_echo'
 fi
 
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO ""
+}
+
+case "$ECHO" in
+  printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
+$as_echo "printf" >&6; } ;;
+  print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
+$as_echo "print -r" >&6; } ;;
+  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
+$as_echo "cat" >&6; } ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
 $as_echo_n "checking for a sed that does not truncate output... " >&6; }
@@ -4127,7 +4708,7 @@ do
     for ac_prog in sed gsed; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
+      as_fn_executable_p "$ac_path_SED" || continue
 # Check for GNU ac_path_SED and select it if it is found.
   # Check for GNU $ac_path_SED
 case `"$ac_path_SED" --version 2>&1` in
@@ -4203,7 +4784,7 @@ do
     for ac_prog in grep ggrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+      as_fn_executable_p "$ac_path_GREP" || continue
 # Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
 case `"$ac_path_GREP" --version 2>&1` in
@@ -4269,7 +4850,7 @@ do
     for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+      as_fn_executable_p "$ac_path_EGREP" || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
 case `"$ac_path_EGREP" --version 2>&1` in
@@ -4336,7 +4917,7 @@ do
     for ac_prog in fgrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
+      as_fn_executable_p "$ac_path_FGREP" || continue
 # Check for GNU ac_path_FGREP and select it if it is found.
   # Check for GNU $ac_path_FGREP
 case `"$ac_path_FGREP" --version 2>&1` in
@@ -4592,7 +5173,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4636,7 +5217,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4794,6 +5375,11 @@ else
     lt_cv_sys_max_cmd_len=196608
     ;;
 
+  os2*)
+    # The test takes a long time on OS/2.
+    lt_cv_sys_max_cmd_len=8192
+    ;;
+
   osf*)
     # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
     # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
@@ -4833,7 +5419,7 @@ else
       # If test is not a shell built-in, we'll probably end up computing a
       # maximum length that is only half of the actual maximum length, but
       # we can't tell.
-      while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \
+      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
 	      test $i != 17 # 1/2 MB should be enough
       do
@@ -5055,7 +5641,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5095,7 +5681,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OBJDUMP="objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5259,7 +5845,7 @@ irix5* | irix6* | nonstopux*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-# This must be Linux ELF.
+# This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu)
   lt_cv_deplibs_check_method=pass_all
   ;;
@@ -5398,7 +5984,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5438,7 +6024,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DLLTOOL="dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5519,7 +6105,6 @@ test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
 
 
 
-
 if test -n "$ac_tool_prefix"; then
   for ac_prog in ar
   do
@@ -5539,7 +6124,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5583,7 +6168,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_AR="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5708,7 +6293,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_STRIP="${ac_tool_prefix}strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5748,7 +6333,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_STRIP="strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5807,7 +6392,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5847,7 +6432,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_RANLIB="ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5897,13 +6482,13 @@ old_postuninstall_cmds=
 if test -n "$RANLIB"; then
   case $host_os in
   openbsd*)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
     ;;
   esac
-  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
 fi
 
 case $host_os in
@@ -6050,6 +6635,7 @@ for ac_symprfx in "" "_"; do
     # which start with @ or ?.
     lt_cv_sys_global_symbol_pipe="$AWK '"\
 "     {last_section=section; section=\$ 3};"\
+"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
 "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
@@ -6438,7 +7024,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
     CFLAGS="$SAVE_CFLAGS"
   fi
   ;;
-sparc*-*solaris*)
+*-*solaris*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
@@ -6449,7 +7035,20 @@ sparc*-*solaris*)
     case `/usr/bin/file conftest.o` in
     *64-bit*)
       case $lt_cv_prog_gnu_ld in
-      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      yes*)
+        case $host in
+        i?86-*-solaris*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        sparc*-*-solaris*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+        esac
+        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
+        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+          LD="${LD-ld}_sol2"
+        fi
+        ;;
       *)
 	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
 	  LD="${LD-ld} -64"
@@ -6482,7 +7081,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6522,7 +7121,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6602,7 +7201,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6642,7 +7241,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6694,7 +7293,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6734,7 +7333,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_NMEDIT="nmedit"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6786,7 +7385,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6826,7 +7425,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_LIPO="lipo"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6878,7 +7477,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6918,7 +7517,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OTOOL="otool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6970,7 +7569,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7010,7 +7609,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OTOOL64="otool64"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7089,7 +7688,13 @@ else
 	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
 	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
         _lt_result=$?
-	if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+	# If there is a non-empty error log, and "single_module"
+	# appears in it, assume the flag caused a linker warning
+        if test -s conftest.err && $GREP single_module conftest.err; then
+	  cat conftest.err >&5
+	# Otherwise, if the output was created with a 0 exit code from
+	# the compiler, it worked.
+	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&5
@@ -7100,6 +7705,7 @@ else
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
 $as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
 if ${lt_cv_ld_exported_symbols_list+:} false; then :
@@ -7132,6 +7738,7 @@ rm -f core conftest.err conftest.$ac_objext \
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
 $as_echo_n "checking for -force_load linker flag... " >&6; }
 if ${lt_cv_ld_force_load+:} false; then :
@@ -7153,7 +7760,9 @@ _LT_EOF
       echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
       $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
       _lt_result=$?
-      if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then
+      if test -s conftest.err && $GREP force_load conftest.err; then
+	cat conftest.err >&5
+      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&5
@@ -7482,6 +8091,17 @@ done
 
 
 
+func_stripname_cnf ()
+{
+  case ${2} in
+  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  esac
+} # func_stripname_cnf
+
+
+
+
 
 # Set options
 # Check whether --enable-shared was given.
@@ -7534,7 +8154,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_AS="${ac_tool_prefix}as"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7574,7 +8194,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_AS="as"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7626,7 +8246,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7666,7 +8286,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DLLTOOL="dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7718,7 +8338,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7758,7 +8378,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OBJDUMP="objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7855,7 +8475,22 @@ fi
 
 # Check whether --with-pic was given.
 if test "${with_pic+set}" = set; then :
-  withval=$with_pic; pic_mode="$withval"
+  withval=$with_pic; lt_p=${PACKAGE-default}
+    case $withval in
+    yes|no) pic_mode=$withval ;;
+    *)
+      pic_mode=default
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for lt_pkg in $withval; do
+	IFS="$lt_save_ifs"
+	if test "X$lt_pkg" = "X$lt_p"; then
+	  pic_mode=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
 else
   pic_mode=default
 fi
@@ -7933,6 +8568,10 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool'
 
 
 
+
+
+
+
 test -z "$LN_S" && LN_S="ln -s"
 
 
@@ -8392,7 +9031,9 @@ lt_prog_compiler_static=
     case $cc_basename in
     nvcc*) # Cuda Compiler Driver 2.2
       lt_prog_compiler_wl='-Xlinker '
-      lt_prog_compiler_pic='-Xcompiler -fPIC'
+      if test -n "$lt_prog_compiler_pic"; then
+        lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
+      fi
       ;;
     esac
   else
@@ -8483,18 +9124,33 @@ lt_prog_compiler_static=
 	;;
       *)
 	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ F* | *Sun*Fortran*)
+	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
 	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
 	  lt_prog_compiler_pic='-KPIC'
 	  lt_prog_compiler_static='-Bstatic'
 	  lt_prog_compiler_wl=''
 	  ;;
+	*Sun\ F* | *Sun*Fortran*)
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl='-Qoption ld '
+	  ;;
 	*Sun\ C*)
 	  # Sun C 5.9
 	  lt_prog_compiler_pic='-KPIC'
 	  lt_prog_compiler_static='-Bstatic'
 	  lt_prog_compiler_wl='-Wl,'
 	  ;;
+        *Intel*\ [CF]*Compiler*)
+	  lt_prog_compiler_wl='-Wl,'
+	  lt_prog_compiler_pic='-fPIC'
+	  lt_prog_compiler_static='-static'
+	  ;;
+	*Portland\ Group*)
+	  lt_prog_compiler_wl='-Wl,'
+	  lt_prog_compiler_pic='-fpic'
+	  lt_prog_compiler_static='-Bstatic'
+	  ;;
 	esac
 	;;
       esac
@@ -8856,7 +9512,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   hardcode_direct=no
   hardcode_direct_absolute=no
   hardcode_libdir_flag_spec=
-  hardcode_libdir_flag_spec_ld=
   hardcode_libdir_separator=
   hardcode_minus_L=no
   hardcode_shlibpath_var=unsupported
@@ -9106,8 +9761,7 @@ _LT_EOF
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
-	  hardcode_libdir_flag_spec=
-	  hardcode_libdir_flag_spec_ld='-rpath $libdir'
+	  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
 	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
 	  if test "x$supports_anon_versioning" = xyes; then
 	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
@@ -9486,6 +10140,7 @@ fi
 	# The linker will not automatically build a static lib if we build a DLL.
 	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
 	enable_shared_with_static_runtimes=yes
+	exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
 	export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
 	# Don't use ranlib
 	old_postinstall_cmds='chmod 644 $oldlib'
@@ -9531,6 +10186,7 @@ fi
   hardcode_shlibpath_var=unsupported
   if test "$lt_cv_ld_force_load" = "yes"; then
     whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+
   else
     whole_archive_flag_spec=''
   fi
@@ -9559,10 +10215,6 @@ fi
       hardcode_shlibpath_var=no
       ;;
 
-    freebsd1*)
-      ld_shlibs=no
-      ;;
-
     # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
     # support.  Future versions do this automatically, but an explicit c++rt0.o
     # does not break anything, and helps significantly (at the cost of a little
@@ -9575,7 +10227,7 @@ fi
       ;;
 
     # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
+    freebsd2.*)
       archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
       hardcode_direct=yes
       hardcode_minus_L=yes
@@ -9614,7 +10266,6 @@ fi
       fi
       if test "$with_gnu_ld" = no; then
 	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-	hardcode_libdir_flag_spec_ld='+b $libdir'
 	hardcode_libdir_separator=:
 	hardcode_direct=yes
 	hardcode_direct_absolute=yes
@@ -10238,11 +10889,6 @@ esac
 
 
 
-
-
-
-
-
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
 $as_echo_n "checking dynamic linker characteristics... " >&6; }
 
@@ -10332,7 +10978,7 @@ need_version=unknown
 
 case $host_os in
 aix3*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
@@ -10341,7 +10987,7 @@ aix3*)
   ;;
 
 aix[4-9]*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
@@ -10406,7 +11052,7 @@ beos*)
   ;;
 
 bsdi[45]*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
@@ -10545,7 +11191,7 @@ darwin* | rhapsody*)
   ;;
 
 dgux*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
@@ -10553,10 +11199,6 @@ dgux*)
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
-freebsd1*)
-  dynamic_linker=no
-  ;;
-
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
@@ -10564,7 +11206,7 @@ freebsd* | dragonfly*)
     objformat=`/usr/bin/objformat`
   else
     case $host_os in
-    freebsd[123]*) objformat=aout ;;
+    freebsd[23].*) objformat=aout ;;
     *) objformat=elf ;;
     esac
   fi
@@ -10582,7 +11224,7 @@ freebsd* | dragonfly*)
   esac
   shlibpath_var=LD_LIBRARY_PATH
   case $host_os in
-  freebsd2*)
+  freebsd2.*)
     shlibpath_overrides_runpath=yes
     ;;
   freebsd3.[01]* | freebsdelf3.[01]*)
@@ -10602,17 +11244,18 @@ freebsd* | dragonfly*)
   ;;
 
 gnu*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
   shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   ;;
 
 haiku*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
@@ -10673,7 +11316,7 @@ hpux9* | hpux10* | hpux11*)
   ;;
 
 interix[3-9]*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
@@ -10689,7 +11332,7 @@ irix5* | irix6* | nonstopux*)
     nonstopux*) version_type=nonstopux ;;
     *)
 	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
+		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
 	fi ;;
@@ -10726,9 +11369,9 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
-# This must be Linux ELF.
+# This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -10814,7 +11457,7 @@ netbsd*)
   ;;
 
 newsos6)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
@@ -10883,7 +11526,7 @@ rdos*)
   ;;
 
 solaris*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -10908,7 +11551,7 @@ sunos4*)
   ;;
 
 sysv4 | sysv4.3*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
   shlibpath_var=LD_LIBRARY_PATH
@@ -10932,7 +11575,7 @@ sysv4 | sysv4.3*)
 
 sysv4*MP*)
   if test -d /usr/nec ;then
-    version_type=linux
+    version_type=linux # correct to gnu/linux during the next big refactor
     library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
     soname_spec='$libname${shared_ext}.$major'
     shlibpath_var=LD_LIBRARY_PATH
@@ -10963,7 +11606,7 @@ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
 
 tpf*)
   # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -10973,7 +11616,7 @@ tpf*)
   ;;
 
 uts4*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
   shlibpath_var=LD_LIBRARY_PATH
@@ -11620,130 +12263,22 @@ fi
 $as_echo "$lt_cv_dlopen_self_static" >&6; }
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
-    ;;
-  esac
-
-  case $lt_cv_dlopen_self in
-  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
-  *) enable_dlopen_self=unknown ;;
-  esac
-
-  case $lt_cv_dlopen_self_static in
-  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
-  *) enable_dlopen_self_static=unknown ;;
-  esac
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-striplib=
-old_striplib=
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
-$as_echo_n "checking whether stripping libraries is possible... " >&6; }
-if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
-  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
-  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-# FIXME - insert some real tests, host_os isn't really good enough
-  case $host_os in
-  darwin*)
-    if test -n "$STRIP" ; then
-      striplib="$STRIP -x"
-      old_striplib="$STRIP -S"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-    fi
-    ;;
-  *)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-    ;;
-  esac
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-  # Report which library types will actually be built
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
-$as_echo_n "checking if libtool supports shared libraries... " >&6; }
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
-$as_echo "$can_build_shared" >&6; }
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
-$as_echo_n "checking whether to build shared libraries... " >&6; }
-  test "$can_build_shared" = "no" && enable_shared=no
-
-  # On AIX, shared libraries and static libraries use the same namespace, and
-  # are all built from PIC.
-  case $host_os in
-  aix3*)
-    test "$enable_shared" = yes && enable_static=no
-    if test -n "$RANLIB"; then
-      archive_cmds="$archive_cmds~\$RANLIB \$lib"
-      postinstall_cmds='$RANLIB $lib'
-    fi
-    ;;
-
-  aix[4-9]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
-    fi
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
     ;;
   esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
-$as_echo "$enable_shared" >&6; }
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
-$as_echo_n "checking whether to build static libraries... " >&6; }
-  # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
-$as_echo "$enable_static" >&6; }
-
-
 
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
 
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
 fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
-
 
 
 
@@ -11755,408 +12290,101 @@ CC="$lt_save_CC"
 
 
 
-        ac_config_commands="$ac_config_commands libtool"
-
 
 
 
-# Only expand once:
 
 
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -z "$CXX"; then
-  if test -n "$CCC"; then
-    CXX=$CCC
-  else
-    if test -n "$ac_tool_prefix"; then
-  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CXX"; then
-  ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
-$as_echo "$CXX" >&6; }
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-fi
-
-
-    test -n "$CXX" && break
-  done
-fi
-if test -z "$CXX"; then
-  ac_ct_CXX=$CXX
-  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CXX"; then
-  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CXX="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
-$as_echo "$ac_ct_CXX" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+    fi
+    ;;
+  *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
+    ;;
+  esac
 fi
 
 
-  test -n "$ac_ct_CXX" && break
-done
-
-  if test "x$ac_ct_CXX" = x; then
-    CXX="g++"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CXX=$ac_ct_CXX
-  fi
-fi
-
-  fi
-fi
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
-$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
-if ${ac_cv_cxx_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  ac_compiler_gnu=yes
-else
-  ac_compiler_gnu=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
-$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
-if test $ac_compiler_gnu = yes; then
-  GXX=yes
-else
-  GXX=
-fi
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
-$as_echo_n "checking whether $CXX accepts -g... " >&6; }
-if ${ac_cv_prog_cxx_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
-   ac_cxx_werror_flag=yes
-   ac_cv_prog_cxx_g=no
-   CXXFLAGS="-g"
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  ac_cv_prog_cxx_g=yes
-else
-  CXXFLAGS=""
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
 
-else
-  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
-	 CXXFLAGS="-g"
-	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-int
-main ()
-{
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  ac_cv_prog_cxx_g=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
-$as_echo "$ac_cv_prog_cxx_g" >&6; }
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-depcc="$CXX"  am_compiler_list=
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
-$as_echo_n "checking dependency style of $depcc... " >&6; }
-if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
-  # We make a subdir and do the tests there.  Otherwise we can end up
-  # making bogus files that we don't know about and never remove.  For
-  # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
-  rm -rf conftest.dir
-  mkdir conftest.dir
-  # Copy depcomp to subdir because otherwise we won't find it if we're
-  # using a relative directory.
-  cp "$am_depcomp" conftest.dir
-  cd conftest.dir
-  # We will build objects and dependencies in a subdirectory because
-  # it helps to detect inapplicable dependency modes.  For instance
-  # both Tru64's cc and ICC support -MD to output dependencies as a
-  # side effect of compilation, but ICC will put the dependencies in
-  # the current directory while Tru64 will put them in the object
-  # directory.
-  mkdir sub
 
-  am_cv_CXX_dependencies_compiler_type=none
-  if test "$am_compiler_list" = ""; then
-     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
-  fi
-  am__universal=false
-  case " $depcc " in #(
-     *\ -arch\ *\ -arch\ *) am__universal=true ;;
-     esac
 
-  for depmode in $am_compiler_list; do
-    # Setup a source with many dependencies, because some compilers
-    # like to wrap large dependency lists on column 80 (with \), and
-    # we should not choose a depcomp mode which is confused by this.
-    #
-    # We need to recreate these files for each test, as the compiler may
-    # overwrite some of them when testing with obscure command lines.
-    # This happens at least with the AIX C compiler.
-    : > sub/conftest.c
-    for i in 1 2 3 4 5 6; do
-      echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
-    done
-    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
-    # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
-    am__obj=sub/conftest.${OBJEXT-o}
-    am__minus_obj="-o $am__obj"
-    case $depmode in
-    gcc)
-      # This depmode causes a compiler race in universal mode.
-      test "$am__universal" = false || continue
-      ;;
-    nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
-      if test "x$enable_dependency_tracking" = xyes; then
-	continue
-      else
-	break
-      fi
-      ;;
-    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
-      # not run yet.  These depmodes are late enough in the game, and
-      # so weak that their functioning should not be impacted.
-      am__obj=conftest.${OBJEXT-o}
-      am__minus_obj=
-      ;;
-    none) break ;;
-    esac
-    if depmode=$depmode \
-       source=sub/conftest.c object=$am__obj \
-       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
-       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
-         >/dev/null 2>conftest.err &&
-       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
-       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
-      # icc doesn't choke on unknown options, it will just issue warnings
-      # or remarks (even with -Werror).  So we grep stderr for any message
-      # that says an option was ignored or not supported.
-      # When given -MP, icc 7.0 and 7.1 complain thusly:
-      #   icc: Command line warning: ignoring option '-M'; no argument required
-      # The diagnosis changed in icc 8.0:
-      #   icc: Command line remark: option '-MP' not supported
-      if (grep 'ignoring option' conftest.err ||
-          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
-        am_cv_CXX_dependencies_compiler_type=$depmode
-        break
-      fi
+
+
+  # Report which library types will actually be built
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+  test "$can_build_shared" = "no" && enable_shared=no
+
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
     fi
-  done
+    ;;
 
-  cd ..
-  rm -rf conftest.dir
-else
-  am_cv_CXX_dependencies_compiler_type=none
-fi
+  aix[4-9]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
-$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
-CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
 
- if
-  test "x$enable_dependency_tracking" != xno \
-  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
-  am__fastdepCXX_TRUE=
-  am__fastdepCXX_FALSE='#'
-else
-  am__fastdepCXX_TRUE='#'
-  am__fastdepCXX_FALSE=
-fi
 
 
 
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-func_stripname_cnf ()
-{
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
-  esac
-} # func_stripname_cnf
+CC="$lt_save_CC"
 
       if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
     ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
@@ -12313,7 +12541,6 @@ export_dynamic_flag_spec_CXX=
 hardcode_direct_CXX=no
 hardcode_direct_absolute_CXX=no
 hardcode_libdir_flag_spec_CXX=
-hardcode_libdir_flag_spec_ld_CXX=
 hardcode_libdir_separator_CXX=
 hardcode_minus_L_CXX=no
 hardcode_shlibpath_var_CXX=unsupported
@@ -12897,6 +13124,7 @@ fi
   hardcode_shlibpath_var_CXX=unsupported
   if test "$lt_cv_ld_force_load" = "yes"; then
     whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+
   else
     whole_archive_flag_spec_CXX=''
   fi
@@ -12941,7 +13169,7 @@ fi
         esac
         ;;
 
-      freebsd[12]*)
+      freebsd2.*)
         # C++ shared libraries reported to be fairly broken before
 	# switch to ELF
         ld_shlibs_CXX=no
@@ -13617,6 +13845,7 @@ _lt_libdeps_save_CFLAGS=$CFLAGS
 case "$CC $CFLAGS " in #(
 *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
 *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
 esac
 
 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
@@ -14406,7 +14635,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
-    cl*) ;;
+    cl*)
+      exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+      ;;
     *)
       export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
       exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
@@ -14559,8 +14790,6 @@ esac
 
 
 
-
-
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
 $as_echo_n "checking dynamic linker characteristics... " >&6; }
 
@@ -14586,7 +14815,7 @@ need_version=unknown
 
 case $host_os in
 aix3*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
@@ -14595,7 +14824,7 @@ aix3*)
   ;;
 
 aix[4-9]*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
@@ -14660,7 +14889,7 @@ beos*)
   ;;
 
 bsdi[45]*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
@@ -14797,7 +15026,7 @@ darwin* | rhapsody*)
   ;;
 
 dgux*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
@@ -14805,10 +15034,6 @@ dgux*)
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
-freebsd1*)
-  dynamic_linker=no
-  ;;
-
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
@@ -14816,7 +15041,7 @@ freebsd* | dragonfly*)
     objformat=`/usr/bin/objformat`
   else
     case $host_os in
-    freebsd[123]*) objformat=aout ;;
+    freebsd[23].*) objformat=aout ;;
     *) objformat=elf ;;
     esac
   fi
@@ -14834,7 +15059,7 @@ freebsd* | dragonfly*)
   esac
   shlibpath_var=LD_LIBRARY_PATH
   case $host_os in
-  freebsd2*)
+  freebsd2.*)
     shlibpath_overrides_runpath=yes
     ;;
   freebsd3.[01]* | freebsdelf3.[01]*)
@@ -14854,17 +15079,18 @@ freebsd* | dragonfly*)
   ;;
 
 gnu*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
   shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   ;;
 
 haiku*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
@@ -14925,7 +15151,7 @@ hpux9* | hpux10* | hpux11*)
   ;;
 
 interix[3-9]*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
@@ -14941,7 +15167,7 @@ irix5* | irix6* | nonstopux*)
     nonstopux*) version_type=nonstopux ;;
     *)
 	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
+		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
 	fi ;;
@@ -14978,9 +15204,9 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
-# This must be Linux ELF.
+# This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -15066,7 +15292,7 @@ netbsd*)
   ;;
 
 newsos6)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
@@ -15135,7 +15361,7 @@ rdos*)
   ;;
 
 solaris*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -15160,7 +15386,7 @@ sunos4*)
   ;;
 
 sysv4 | sysv4.3*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
   shlibpath_var=LD_LIBRARY_PATH
@@ -15184,7 +15410,7 @@ sysv4 | sysv4.3*)
 
 sysv4*MP*)
   if test -d /usr/nec ;then
-    version_type=linux
+    version_type=linux # correct to gnu/linux during the next big refactor
     library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
     soname_spec='$libname${shared_ext}.$major'
     shlibpath_var=LD_LIBRARY_PATH
@@ -15215,7 +15441,7 @@ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
 
 tpf*)
   # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -15225,7 +15451,7 @@ tpf*)
   ;;
 
 uts4*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
   shlibpath_var=LD_LIBRARY_PATH
@@ -15356,6 +15582,26 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+
+
+
+
+
+
+
+
+
+        ac_config_commands="$ac_config_commands libtool"
+
+
+
+
+# Only expand once:
+
+
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
     # Check whether --enable-maintainer-mode was given.
@@ -15681,6 +15927,14 @@ LIBOBJS=$ac_libobjs
 LTLIBOBJS=$ac_ltlibobjs
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
+$as_echo_n "checking that generated files are newer than configure... " >&6; }
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
+$as_echo "done" >&6; }
  if test -n "$EXEEXT"; then
   am__EXEEXT_TRUE=
   am__EXEEXT_FALSE='#'
@@ -15693,14 +15947,14 @@ if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
   as_fn_error $? "conditional \"AMDEP\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
-if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
-  as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
 if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
   as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -16007,16 +16261,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -16076,28 +16330,16 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -16118,8 +16360,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by ssm $as_me 1.1.20120701, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+This file was extended by ssm $as_me 1.3, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -16184,11 +16426,11 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-ssm config.status 1.1.20120701
-configured by $0, generated by GNU Autoconf 2.68,
+ssm config.status 1.3
+configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -16279,7 +16521,7 @@ fi
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
@@ -16324,6 +16566,7 @@ pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
 enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
 SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
 ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
+PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
 host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'
 host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'
 host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'
@@ -16404,7 +16647,6 @@ with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`'
 allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'
 no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'
 hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'
-hardcode_libdir_flag_spec_ld='`$ECHO "$hardcode_libdir_flag_spec_ld" | $SED "$delay_single_quote_subst"`'
 hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'
 hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'
 hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'
@@ -16476,7 +16718,6 @@ with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`'
 allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
 no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
 hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
-hardcode_libdir_flag_spec_ld_CXX='`$ECHO "$hardcode_libdir_flag_spec_ld_CXX" | $SED "$delay_single_quote_subst"`'
 hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`'
 hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`'
 hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`'
@@ -16518,6 +16759,7 @@ DLLTOOL \
 OBJDUMP \
 SHELL \
 ECHO \
+PATH_SEPARATOR \
 SED \
 GREP \
 EGREP \
@@ -16566,7 +16808,6 @@ with_gnu_ld \
 allow_undefined_flag \
 no_undefined_flag \
 hardcode_libdir_flag_spec \
-hardcode_libdir_flag_spec_ld \
 hardcode_libdir_separator \
 exclude_expsyms \
 include_expsyms \
@@ -16600,7 +16841,6 @@ with_gnu_ld_CXX \
 allow_undefined_flag_CXX \
 no_undefined_flag_CXX \
 hardcode_libdir_flag_spec_CXX \
-hardcode_libdir_flag_spec_ld_CXX \
 hardcode_libdir_separator_CXX \
 exclude_expsyms_CXX \
 include_expsyms_CXX \
@@ -17305,7 +17545,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
     # Strip MF so we end up with the name of the file.
     mf=`echo "$mf" | sed -e 's/:.*$//'`
     # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named `Makefile.in', but
+    # We used to match only the files named 'Makefile.in', but
     # some people rename them; so instead we look at the file content.
     # Grep'ing the first line is not enough: some people post-process
     # each Makefile.in and add a new line on top of each file to say so.
@@ -17339,21 +17579,19 @@ $as_echo X"$mf" |
       continue
     fi
     # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running `make'.
+    # from the Makefile without running 'make'.
     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     test -z "$DEPDIR" && continue
     am__include=`sed -n 's/^am__include = //p' < "$mf"`
     test -z "am__include" && continue
     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # When using ansi2knr, U may be empty or an underscore; expand it
-    U=`sed -n 's/^U = //p' < "$mf"`
     # Find all dependency output files, they are included files with
     # $(DEPDIR) in their names.  We invoke sed twice because it is the
     # simplest approach to changing $(DEPDIR) to its actual value in the
     # expansion.
     for file in `sed -n "
       s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
       # Make sure the directory exists.
       test -f "$dirpart/$file" && continue
       fdir=`$as_dirname -- "$file" ||
@@ -17407,8 +17645,8 @@ $as_echo X"$file" |
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 #
 #   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
-#                 Inc.
+#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+#                 Foundation, Inc.
 #   Written by Gordon Matzigkeit, 1996
 #
 #   This file is part of GNU Libtool.
@@ -17471,6 +17709,9 @@ SHELL=$lt_SHELL
 # An echo program that protects backslashes.
 ECHO=$lt_ECHO
 
+# The PATH separator for the build system.
+PATH_SEPARATOR=$lt_PATH_SEPARATOR
+
 # The host system.
 host_alias=$host_alias
 host=$host
@@ -17766,10 +18007,6 @@ no_undefined_flag=$lt_no_undefined_flag
 # This must work even if \$libdir does not exist
 hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
 
-# If ld is used when linking, flag to hardcode \$libdir into a binary
-# during linking.  This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
-
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator
 
@@ -18112,10 +18349,6 @@ no_undefined_flag=$lt_no_undefined_flag_CXX
 # This must work even if \$libdir does not exist
 hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
 
-# If ld is used when linking, flag to hardcode \$libdir into a binary
-# during linking.  This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
-
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
 
diff --git a/configure.ac b/configure.ac
index 17f16df..25fc0ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,14 +1,15 @@
 
-AC_INIT(ssm, 1.1.20120701)
+AC_INIT(ssm, 1.3) dnl should be the same as in ssm_defs.h
 
 AC_CONFIG_AUX_DIR(build-aux)
 AC_CONFIG_MACRO_DIR(m4)
-AC_CONFIG_SRCDIR(ss_vxedge.h)
+AC_CONFIG_SRCDIR(ssm_vxedge.h)
 AC_CONFIG_HEADERS(config.h)
 AM_INIT_AUTOMAKE([1.11 foreign subdir-objects silent-rules -Wall])
-LT_INIT([disable-shared win32-dll])
 AC_PROG_CXX
 AC_PROG_INSTALL
+AM_PROG_AR
+LT_INIT([disable-shared win32-dll])
 
 AM_MAINTAINER_MODE dnl disable (by default) maintainer mode
 
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 88de383..56666f0 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -1,8 +1,8 @@
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
 #
 #   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
-#                 Inc.
+#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+#                 Foundation, Inc.
 #   Written by Gordon Matzigkeit, 1996
 #
 # This file is free software; the Free Software Foundation gives
@@ -11,8 +11,8 @@
 
 m4_define([_LT_COPYING], [dnl
 #   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
-#                 Inc.
+#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+#                 Foundation, Inc.
 #   Written by Gordon Matzigkeit, 1996
 #
 #   This file is part of GNU Libtool.
@@ -146,6 +146,8 @@ AC_REQUIRE([AC_CANONICAL_BUILD])dnl
 AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
 AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
 
+_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl
+dnl
 _LT_DECL([], [host_alias], [0], [The host system])dnl
 _LT_DECL([], [host], [0])dnl
 _LT_DECL([], [host_os], [0])dnl
@@ -637,7 +639,7 @@ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
 m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
 configured by $[0], generated by m4_PACKAGE_STRING.
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2011 Free Software Foundation, Inc.
 This config.lt script is free software; the Free Software Foundation
 gives unlimited permision to copy, distribute and modify it."
 
@@ -801,6 +803,7 @@ AC_DEFUN([LT_LANG],
 m4_case([$1],
   [C],			[_LT_LANG(C)],
   [C++],		[_LT_LANG(CXX)],
+  [Go],			[_LT_LANG(GO)],
   [Java],		[_LT_LANG(GCJ)],
   [Fortran 77],		[_LT_LANG(F77)],
   [Fortran],		[_LT_LANG(FC)],
@@ -822,6 +825,31 @@ m4_defun([_LT_LANG],
 ])# _LT_LANG
 
 
+m4_ifndef([AC_PROG_GO], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_GO.  When it is available in    #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+############################################################
+m4_defun([AC_PROG_GO],
+[AC_LANG_PUSH(Go)dnl
+AC_ARG_VAR([GOC],     [Go compiler command])dnl
+AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+AC_CHECK_TOOL(GOC, gccgo)
+if test -z "$GOC"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo])
+  fi
+fi
+if test -z "$GOC"; then
+  AC_CHECK_PROG(GOC, gccgo, gccgo, false)
+fi
+])#m4_defun
+])#m4_ifndef
+
+
 # _LT_LANG_DEFAULT_CONFIG
 # -----------------------
 m4_defun([_LT_LANG_DEFAULT_CONFIG],
@@ -852,6 +880,10 @@ AC_PROVIDE_IFELSE([AC_PROG_GCJ],
        m4_ifdef([LT_PROG_GCJ],
 	[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
 
+AC_PROVIDE_IFELSE([AC_PROG_GO],
+  [LT_LANG(GO)],
+  [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])
+
 AC_PROVIDE_IFELSE([LT_PROG_RC],
   [LT_LANG(RC)],
   [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
@@ -954,7 +986,13 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
 	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
         _lt_result=$?
-	if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+	# If there is a non-empty error log, and "single_module"
+	# appears in it, assume the flag caused a linker warning
+        if test -s conftest.err && $GREP single_module conftest.err; then
+	  cat conftest.err >&AS_MESSAGE_LOG_FD
+	# Otherwise, if the output was created with a 0 exit code from
+	# the compiler, it worked.
+	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -962,6 +1000,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 	rm -rf libconftest.dylib*
 	rm -f conftest.*
       fi])
+
     AC_CACHE_CHECK([for -exported_symbols_list linker flag],
       [lt_cv_ld_exported_symbols_list],
       [lt_cv_ld_exported_symbols_list=no
@@ -973,6 +1012,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 	[lt_cv_ld_exported_symbols_list=no])
 	LDFLAGS="$save_LDFLAGS"
     ])
+
     AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
       [lt_cv_ld_force_load=no
       cat > conftest.c << _LT_EOF
@@ -990,7 +1030,9 @@ _LT_EOF
       echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
       $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
       _lt_result=$?
-      if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then
+      if test -s conftest.err && $GREP force_load conftest.err; then
+	cat conftest.err >&AS_MESSAGE_LOG_FD
+      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1035,8 +1077,8 @@ _LT_EOF
 ])
 
 
-# _LT_DARWIN_LINKER_FEATURES
-# --------------------------
+# _LT_DARWIN_LINKER_FEATURES([TAG])
+# ---------------------------------
 # Checks for linker and compiler features on darwin
 m4_defun([_LT_DARWIN_LINKER_FEATURES],
 [
@@ -1047,6 +1089,8 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
   _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
   if test "$lt_cv_ld_force_load" = "yes"; then
     _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+    m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
+                  [FC],  [_LT_TAGVAR(compiler_needs_object, $1)=yes])
   else
     _LT_TAGVAR(whole_archive_flag_spec, $1)=''
   fi
@@ -1330,14 +1374,27 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
     CFLAGS="$SAVE_CFLAGS"
   fi
   ;;
-sparc*-*solaris*)
+*-*solaris*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
     *64-bit*)
       case $lt_cv_prog_gnu_ld in
-      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      yes*)
+        case $host in
+        i?86-*-solaris*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        sparc*-*-solaris*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+        esac
+        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
+        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+          LD="${LD-ld}_sol2"
+        fi
+        ;;
       *)
 	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
 	  LD="${LD-ld} -64"
@@ -1414,13 +1471,13 @@ old_postuninstall_cmds=
 if test -n "$RANLIB"; then
   case $host_os in
   openbsd*)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
     ;;
   esac
-  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
 fi
 
 case $host_os in
@@ -1600,6 +1657,11 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     lt_cv_sys_max_cmd_len=196608
     ;;
 
+  os2*)
+    # The test takes a long time on OS/2.
+    lt_cv_sys_max_cmd_len=8192
+    ;;
+
   osf*)
     # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
     # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
@@ -1639,7 +1701,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
       # If test is not a shell built-in, we'll probably end up computing a
       # maximum length that is only half of the actual maximum length, but
       # we can't tell.
-      while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \
+      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
 	      test $i != 17 # 1/2 MB should be enough
       do
@@ -2185,7 +2247,7 @@ need_version=unknown
 
 case $host_os in
 aix3*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
@@ -2194,7 +2256,7 @@ aix3*)
   ;;
 
 aix[[4-9]]*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
@@ -2259,7 +2321,7 @@ beos*)
   ;;
 
 bsdi[[45]]*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
@@ -2398,7 +2460,7 @@ m4_if([$1], [],[
   ;;
 
 dgux*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
@@ -2406,10 +2468,6 @@ dgux*)
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
-freebsd1*)
-  dynamic_linker=no
-  ;;
-
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
@@ -2417,7 +2475,7 @@ freebsd* | dragonfly*)
     objformat=`/usr/bin/objformat`
   else
     case $host_os in
-    freebsd[[123]]*) objformat=aout ;;
+    freebsd[[23]].*) objformat=aout ;;
     *) objformat=elf ;;
     esac
   fi
@@ -2435,7 +2493,7 @@ freebsd* | dragonfly*)
   esac
   shlibpath_var=LD_LIBRARY_PATH
   case $host_os in
-  freebsd2*)
+  freebsd2.*)
     shlibpath_overrides_runpath=yes
     ;;
   freebsd3.[[01]]* | freebsdelf3.[[01]]*)
@@ -2455,17 +2513,18 @@ freebsd* | dragonfly*)
   ;;
 
 gnu*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
   shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   ;;
 
 haiku*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
@@ -2526,7 +2585,7 @@ hpux9* | hpux10* | hpux11*)
   ;;
 
 interix[[3-9]]*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
@@ -2542,7 +2601,7 @@ irix5* | irix6* | nonstopux*)
     nonstopux*) version_type=nonstopux ;;
     *)
 	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
+		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
 	fi ;;
@@ -2579,9 +2638,9 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
-# This must be Linux ELF.
+# This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -2648,7 +2707,7 @@ netbsd*)
   ;;
 
 newsos6)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
@@ -2717,7 +2776,7 @@ rdos*)
   ;;
 
 solaris*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -2742,7 +2801,7 @@ sunos4*)
   ;;
 
 sysv4 | sysv4.3*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
   shlibpath_var=LD_LIBRARY_PATH
@@ -2766,7 +2825,7 @@ sysv4 | sysv4.3*)
 
 sysv4*MP*)
   if test -d /usr/nec ;then
-    version_type=linux
+    version_type=linux # correct to gnu/linux during the next big refactor
     library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
     soname_spec='$libname${shared_ext}.$major'
     shlibpath_var=LD_LIBRARY_PATH
@@ -2797,7 +2856,7 @@ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
 
 tpf*)
   # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -2807,7 +2866,7 @@ tpf*)
   ;;
 
 uts4*)
-  version_type=linux
+  version_type=linux # correct to gnu/linux during the next big refactor
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
   shlibpath_var=LD_LIBRARY_PATH
@@ -3229,7 +3288,7 @@ irix5* | irix6* | nonstopux*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-# This must be Linux ELF.
+# This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu)
   lt_cv_deplibs_check_method=pass_all
   ;;
@@ -3649,6 +3708,7 @@ for ac_symprfx in "" "_"; do
     # which start with @ or ?.
     lt_cv_sys_global_symbol_pipe="$AWK ['"\
 "     {last_section=section; section=\$ 3};"\
+"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
 "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
@@ -4233,7 +4293,9 @@ m4_if([$1], [CXX], [
     case $cc_basename in
     nvcc*) # Cuda Compiler Driver 2.2
       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '
-      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC'
+      if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)"
+      fi
       ;;
     esac
   else
@@ -4325,18 +4387,33 @@ m4_if([$1], [CXX], [
 	;;
       *)
 	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ F* | *Sun*Fortran*)
+	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*)
 	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
 	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	  _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
 	  ;;
+	*Sun\ F* | *Sun*Fortran*)
+	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	  ;;
 	*Sun\ C*)
 	  # Sun C 5.9
 	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	  ;;
+        *Intel*\ [[CF]]*Compiler*)
+	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	  ;;
+	*Portland\ Group*)
+	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  ;;
 	esac
 	;;
       esac
@@ -4496,7 +4573,9 @@ m4_if([$1], [CXX], [
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
-    cl*) ;;
+    cl*)
+      _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+      ;;
     *)
       _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
       _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
@@ -4521,7 +4600,6 @@ m4_if([$1], [CXX], [
   _LT_TAGVAR(hardcode_direct, $1)=no
   _LT_TAGVAR(hardcode_direct_absolute, $1)=no
   _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
   _LT_TAGVAR(hardcode_libdir_separator, $1)=
   _LT_TAGVAR(hardcode_minus_L, $1)=no
   _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
@@ -4772,8 +4850,7 @@ _LT_EOF
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-	  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
 	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
 	  if test "x$supports_anon_versioning" = xyes; then
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
@@ -5068,6 +5145,7 @@ _LT_EOF
 	# The linker will not automatically build a static lib if we build a DLL.
 	# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
 	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+	_LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
 	_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
 	# Don't use ranlib
 	_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
@@ -5114,10 +5192,6 @@ _LT_EOF
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
 
-    freebsd1*)
-      _LT_TAGVAR(ld_shlibs, $1)=no
-      ;;
-
     # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
     # support.  Future versions do this automatically, but an explicit c++rt0.o
     # does not break anything, and helps significantly (at the cost of a little
@@ -5130,7 +5204,7 @@ _LT_EOF
       ;;
 
     # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
+    freebsd2.*)
       _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
       _LT_TAGVAR(hardcode_direct, $1)=yes
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
@@ -5169,7 +5243,6 @@ _LT_EOF
       fi
       if test "$with_gnu_ld" = no; then
 	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
@@ -5611,9 +5684,6 @@ _LT_TAGDECL([], [no_undefined_flag], [1],
 _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
     [Flag to hardcode $libdir into a binary during linking.
     This must work even if $libdir does not exist])
-_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
-    [[If ld is used when linking, flag to hardcode $libdir into a binary
-    during linking.  This must work even if $libdir does not exist]])
 _LT_TAGDECL([], [hardcode_libdir_separator], [1],
     [Whether we need a single "-rpath" flag with a separated argument])
 _LT_TAGDECL([], [hardcode_direct], [0],
@@ -5771,7 +5841,6 @@ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
 _LT_TAGVAR(hardcode_direct, $1)=no
 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
 _LT_TAGVAR(hardcode_libdir_separator, $1)=
 _LT_TAGVAR(hardcode_minus_L, $1)=no
 _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
@@ -6141,7 +6210,7 @@ if test "$_lt_caught_CXX_error" != yes; then
         esac
         ;;
 
-      freebsd[[12]]*)
+      freebsd2.*)
         # C++ shared libraries reported to be fairly broken before
 	# switch to ELF
         _LT_TAGVAR(ld_shlibs, $1)=no
@@ -6902,12 +6971,18 @@ public class foo {
   }
 };
 _LT_EOF
+], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF
+package foo
+func foo() {
+}
+_LT_EOF
 ])
 
 _lt_libdeps_save_CFLAGS=$CFLAGS
 case "$CC $CFLAGS " in #(
 *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
 *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
 esac
 
 dnl Parse the compiler output and extract the necessary
@@ -7104,7 +7179,6 @@ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
 _LT_TAGVAR(hardcode_direct, $1)=no
 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
 _LT_TAGVAR(hardcode_libdir_separator, $1)=
 _LT_TAGVAR(hardcode_minus_L, $1)=no
 _LT_TAGVAR(hardcode_automatic, $1)=no
@@ -7237,7 +7311,6 @@ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
 _LT_TAGVAR(hardcode_direct, $1)=no
 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
 _LT_TAGVAR(hardcode_libdir_separator, $1)=
 _LT_TAGVAR(hardcode_minus_L, $1)=no
 _LT_TAGVAR(hardcode_automatic, $1)=no
@@ -7424,6 +7497,77 @@ CFLAGS=$lt_save_CFLAGS
 ])# _LT_LANG_GCJ_CONFIG
 
 
+# _LT_LANG_GO_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Go compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GO_CONFIG],
+[AC_REQUIRE([LT_PROG_GO])dnl
+AC_LANG_SAVE
+
+# Source file extension for Go test sources.
+ac_ext=go
+
+# Object file extension for compiled Go test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="package main; func main() { }"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='package main; func main() { }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GOC-"gccgo"}
+CFLAGS=$GOFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# Go did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+
+  _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GO_CONFIG
+
+
 # _LT_LANG_RC_CONFIG([TAG])
 # -------------------------
 # Ensure that the configuration variables for the Windows resource compiler
@@ -7493,6 +7637,13 @@ dnl aclocal-1.4 backwards compatibility:
 dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
 
 
+# LT_PROG_GO
+# ----------
+AC_DEFUN([LT_PROG_GO],
+[AC_CHECK_TOOL(GOC, gccgo,)
+])
+
+
 # LT_PROG_RC
 # ----------
 AC_DEFUN([LT_PROG_RC],
diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4
index 17cfd51..5d9acd8 100644
--- a/m4/ltoptions.m4
+++ b/m4/ltoptions.m4
@@ -326,9 +326,24 @@ dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
 # MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
 m4_define([_LT_WITH_PIC],
 [AC_ARG_WITH([pic],
-    [AS_HELP_STRING([--with-pic],
+    [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
 	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
-    [pic_mode="$withval"],
+    [lt_p=${PACKAGE-default}
+    case $withval in
+    yes|no) pic_mode=$withval ;;
+    *)
+      pic_mode=default
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for lt_pkg in $withval; do
+	IFS="$lt_save_ifs"
+	if test "X$lt_pkg" = "X$lt_p"; then
+	  pic_mode=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
     [pic_mode=default])
 
 test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
diff --git a/ss_csia.h b/ss_csia.h
deleted file mode 100644
index a459402..0000000
--- a/ss_csia.h
+++ /dev/null
@@ -1,162 +0,0 @@
-// $Id: ss_csia.h,v 1.5 2011/11/21 16:56:16 ekr Exp $
-// =================================================================
-//
-//    27.04.04   <--  Date of Last Modification.
-//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// -----------------------------------------------------------------
-//
-//  **** Module  :  ss_csia       <interface>
-//       ~~~~~~~~~
-//  **** Classes :  CSSGraphMatch ( matching SS graphs )
-//       ~~~~~~~~~
-//
-//  E. Krissinel 2001-2004
-//
-//  When used, please cite:
-//
-//   Krissinel, E. and Henrick, K. (2004)
-//   Common subgraph isomorphism detection by backtracking search.
-//   Software - Practice and Experience, 34, 591-607.
-//
-// =================================================================
-//
-
-#ifndef  __SS_CSIA__
-#define  __SS_CSIA__
-
-#include "ss_graph.h"
-
-
-//  =========================  CSSMatch  ===========================
-
-DefineClass(CSSMatch)
-
-class CSSMatch : public CStream  {
-
-  friend class CSSGraphMatch;
-
-  public :
-
-    CSSMatch ();
-    CSSMatch ( RPCStream Object );
-    CSSMatch ( ivector FV1, ivector FV2, int nv, int n, int m );
-    ~CSSMatch();
-
-    void SetMatch ( ivector FV1, ivector FV2,
-                    int nv, int n, int m );   // FV1[], FV2[] are copied
-
-    void    Swap();
-
-    Boolean isMatch ( ivector FV1, ivector FV2, int nv );
-
-    int  isSubMatch ( ivector FV1, ivector FV2, int nv );
-    // return 0 <=> no submatch relations
-    //        1 <=> "this" is submatch of (FV1,FV2)
-    //       -1 <=> (FV1,FV2) is submatch of "this"
-
-    void GetMatch ( ivector  & FV1,  // do not allocate or
-                    ivector  & FV2,  // dispose FV1 and FV2 in
-                    int      & nv ); // application!
-
-    void GetMatch ( ivector  & FV1, // do not allocate or
-                    ivector  & FV2, // dispose FV1 and FV2 in
-                    int      & nv,  // application!
-                    realtype & p1,
-                    realtype & p2 );
-
-    void read  ( RCFile f );
-    void write ( RCFile f );
-
-  protected :
-    int     mlength,n1,n2;
-    ivector F1,F2;
-
-    void InitSSMatch();
-
-  private :
-    int nAlloc;
-
-};
-
-DefineStreamFunctions(CSSMatch)
-
-
-
-//  =========================  CSSGraphMatch  ===========================
-
-#define SSMF_UniqueMatch       0x00000001
-#define SSMF_BestMatch         0x00000002
-#define SSMF_WrongConnectOnly  0x00000004
-
-
-DefineClass(CSSGraphMatch)
-
-class CSSGraphMatch : public CStream  {
-
-  public :
-
-    CSSGraphMatch ();
-    CSSGraphMatch ( RPCStream Object );
-    ~CSSGraphMatch();
-
-    void  SetUniqueMatch ( Boolean unique_match );
-    void  SetBestMatch   ( Boolean best_match   );
-    void  SetMatchBufferLength ( int matchBufLen );
-    void  SetFlags       ( word Flags );
-    void  RemoveFlags    ( word Flags );
-
-    void  MatchGraphs    ( PCSSGraph Gh1, PCSSGraph Gh2, int minMatch );
-
-    PCSSGraph  GetGraph1 ();
-    PCSSGraph  GetGraph2 ();
-    void  GetMatches     ( PPCSSMatch & SSMatch, int & nOfMatches );
-    int   GetMaxRecursionLevel() { return maxRecursionLevel; }
-
-    int   CheckConnectivity ( int matchNo );
-
-    void  read  ( RCFile f );
-    void  write ( RCFile f );
-
-
-  protected :
-
-    PCSSGraph   G1,G2;
-    PPCSSVertex V1;
-    PPCSSVertex V2;
-    PPCSSEdge   E1;
-    PPCSSEdge   E2;
-    imatrix     c1,c2;
-    Boolean     swap;
-    word        flags;
-    int         n,m;
-
-    imatrix3    P;
-    imatrix     iF1;
-    ivector     F1,F2,ix;
-
-    int         nMatches,maxNofMatches;
-    PPCSSMatch  Match;
-    Boolean     UniqueMatch,BestMatch,wasFullMatch,Stop;
-    int         maxMatch,maxCollectedMatch,maxRecursionLevel;
-
-    void  InitSSGraphMatch ();
-    void  FreeMemory       ();
-    void  FreeRecHeap      ();
-    void  GetMemory        ();
-    void  GetRecHeap       ();
-    int   Initialize       ();
-    void  DoMatch          ( int minMatch );
-    void  MatchSingleVertex();
-    void  Backtrack        ( int i );
-    void  Backtrack1       ( int i, int k0 );
-    void  CollectMatch     ( int nm );
-
-  private :
-    int nAlloc,mAlloc,nMAlloc;
-
-};
-
-DefineStreamFunctions(CSSGraphMatch)
-
-
-#endif
diff --git a/ss_graph.h b/ss_graph.h
deleted file mode 100644
index 0531c41..0000000
--- a/ss_graph.h
+++ /dev/null
@@ -1,266 +0,0 @@
-// $Id: ss_graph.h,v 1.5 2011/11/21 16:56:16 ekr Exp $
-// =================================================================
-//
-//    28.09.04   <--  Date of Last Modification.
-//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// -----------------------------------------------------------------
-//
-//  **** Module  :  ss_graph  <interface>
-//       ~~~~~~~~~
-//  **** Classes :  CSSGraph  ( secondary structure graph )
-//       ~~~~~~~~~  
-//
-//  E. Krissinel 2002-2004
-//
-// =================================================================
-//
-
-
-#ifndef  __SS_Graph__
-#define  __SS_Graph__
-
-#include "mmdb/mmdb_manager.h"
-
-#include "ss_vxedge.h"
-
-
-//  ==========================  CSSGraph  ===========================
-
-#define SSGP_Distance   0
-#define SSGP_Alpha1     1
-#define SSGP_Alpha2     2 
-#define SSGP_Alpha3     3 
-#define SSGP_Alpha4     4 
-#define SSGP_dAlpha1    5 
-#define SSGP_dAlpha2    6
-#define SSGP_dAlpha3    7
-#define SSGP_dAlpha4    8
-
-#define SSGE_Ok                     0
-#define SSGE_NoVertices             70
-#define SSGE_UnmatchedConnectivity  5001
-#define SSGE_AlignError             5002
-#define SSGE_WrongSelLine1          5003
-#define SSGE_WrongSelLine2          5004
-#define SSGE_WrongSelLine3          5005
-
-#define SSGT_None       0
-#define SSGT_PDB        1
-#define SSGT_SCOP       2
-#define SSGT_PDBDOMAIN  3
-#define SSGT_PDBRANGE   4
-#define SSGT_CFDOMAIN   5
-#define SSGT_CFRANGE    6
-
-
-DefineClass(CSSGraph)
-DefineStreamFunctions(CSSGraph)
-
-class CSSGraph : public CStream  {
-
-  friend class CSSGraphMatch;
-
-  public :
-
-    CSSGraph ();
-    CSSGraph ( RPCStream Object );
-    ~CSSGraph();
-
-    void  Reset();  // must be called before building a graph
-                    // The sequence of calls is:
-                    //    SSGraph.Reset();
-                    //    for (....)  {
-                    //      V = new CSSVertex();
-                    //      .....
-                    //      SSGraph.AddVertex ( V );
-                    //    }
-                    //    SSGraph.Build();
-
-    void  SetGraphName  ( pstr gname     );
-
-    void  SelectCalphas ( PCMMDBManager MMDB, int & selHnd,
-                          pstr selstring );
-
-    //   AddVertex(..) do not copy the objects, but take them over.
-    // This means that application should forget about pointers to
-    // V once they were given to CSSGraph. All vertices must be
-    // allocated newly prior each call to AddVertex(..).
-    void  AddVertex  ( PCSSVertex V );
-
-    int   MakeGraph ( PCMMDBManager MMDB );
-
-    void  CalcVertexOrder();
-    void  RepairSS ( PCMMDBManager MMDB );
-
-    //   BuildGraph() calculates all edges and builds the graph.
-    void    BuildGraph();
-    Boolean isBuild   ();
-
-    void  calcVTypes();  // calculates nHelices and nStrands only
-
-    //   ReleaseEdges() deallocates all graph edges and
-    //  the connectivity matrix 
-    void  ReleaseEdges();
-
-    void  RemoveShortVertices   ( int nmin_hx, int nmin_sd );
-
-    //   LeaveVertices(..) removes all vertices from the graph
-    // except those having numbers listed in vector vlist. Thus,
-    // if vlist[i]=j, 1<=i<=vllen,  1<=j, then jth vertex will
-    // not be removed.
-    void  LeaveVertices         ( ivector vlist, int vllen );
-
-    //   LeaveVertices(..) removes all vertices from the graph
-    // except those found in the specified range. 'select' is of
-    // the following format:
-    //    "*", "(all)"            - take all file
-    //    "-"                     - take chain without chain ID
-    //    "a:Ni-Mj,b:Kp-Lq,..."   - take chain a residue number N
-    //                              insertion code i to residue number M
-    //                              insertion code j plus chain b
-    //                              residue number K insertion code p to
-    //                              residue number L insertion code q and
-    //                              so on.
-    //    "a:,b:..."              - take whole chains a and b and so on
-    //    "a:,b:Kp-Lq,..."        - any combination of the above.
-    void  LeaveVertices ( pstr select, PCMMDBManager M );
-
-    //    LeaveVertices ( selHnd,MMDB ) leaves only vertices that are
-    // covered by the given selection. selHnd may refer to the
-    // selection of atoms, residues or chains.
-    void  LeaveVertices ( int selHnd, PCMMDBManager M );
-
-    void  RemoveVertex          ( int vertex_no );  // 1..nVertices
-
-    Boolean    inRange          ( pstr chainID, int initPos,
-                                                int endPos );
-    pstr       GetGraphName     () { return name;        }
-    pstr       GetDevChain      () { return devChain;    }
-    pstr       GetChainList     ( pstr S );
-    int        GetNofVertices   () { return nVertices;   }
-    PPCSSVertex GetVertices     () { return Vertex;      }
-    int        GetNofEdges      () { return nEdges;      }
-    int        GetNofHelices    () { return nHelices;    }
-    int        GetNofStrands    () { return nStrands;    }
-    void       GetAllChains     ( PChainID & chain, int & nchains );
-    int        GetNofChains     ();
-    Boolean    GetEdgeDirection ( int v1, int v2, vect3 & v );
-    int        GetVertexType    ( int vertex_no  ); // 1..nVertices
-    int        GetVertexClass   ( int vertex_no  ); // 1..nVertices
-    Boolean    GetVertexDirection ( int vertex_no, vect3 & v );
-    int        GetSeqLength     ( int vertex_no  ); // 1..nVertices
-    realtype   GetMass          ( int vertex_no  ); // 1..nVertices
-    PCSSVertex GetGraphVertex   ( int vertex_no  ); // 1..nVertices
-    pstr       GetVertexChainID ( int vertex_no  ); // 1..nVertices
-    pstr       GetVertexInitRes ( int vertex_no  ); // 1..nVertices
-    pstr       GetVertexEndRes  ( int vertex_no  ); // 1..nVertices
-    void       GetVertexRange   ( int     vertex_no,  // 1..nVertices
-                                  ChainID chID,
-                                  int &   initSeqNum,
-                                  InsCode initICode,
-                                  int &   endSeqNum,
-                                  InsCode endICode  );  
-    void       GetVertexRange   ( int     vertex_no,  // 1..nVertices
-                                  ChainID chID,
-                                  int &   initPos,
-                                  int &   endPos );
-    int        GetSSEType       ( pstr chainID, int atomPos );
-    int        GetSSEType       ( PCAtom A );
-
-    PCSSEdge   GetGraphEdge   ( int edge_no );     // 1..nEdges
-    PCSSEdge   GetGraphEdge   ( int v1, int v2 );  // 1..nVertices
-
-    realtype CalcCombinations ( ivector F, int nm );
-
-    void  DevelopChainGraphs ( PPCSSGraph & G, int & nGraphs );
-
-    //  Superpose(..) returns TMatrix - a transformation matrix for
-    // G's coordinates, such that TMatrix*{G} ~= {this}
-    //  F1 is for 'this' graph, F2 = for G.
-    void  Superpose          ( PCSSGraph G, ivector F1, ivector F2,
-                               int nMatch, mat44 & TMatrix );
-
-
-    void  Copy  ( PCSSGraph G );
-
-    void  read  ( RCFile f );
-    void  write ( RCFile f );
-
-  protected :
-    pstr        name;        // graph name
-    ChainID     devChain;    // chain of a developed graph
-    int         nVertices,nEdges;
-    int         nHelices,nStrands;
-
-    PPCSSVertex Vertex;
-    PPCSSEdge   Edge;
-    imatrix     graph;
-
-    void  InitSSGraph    ();
-    void  FreeMemory     ();
-    void  _leaveVertices ( PCMMDBManager M, int selHnd1 );
-
-    //   CompareEdges(..) compares edge (ij) of the graph with
-    // edge (kl) of graph G. i may be either less or greater
-    // than j, same about k and l. If edges compare, the function
-    // returns 0. Edges with equal indices (i.e. (ii) and (kk))
-    // are considered as comparable (returns 0).
-    //   The function may be used only after both graphs have
-    // been built.
-    int   CompareEdges ( int i, int j, PCSSGraph G,
-                         int k, int l );
-
-    int   CheckEdgeConnectivity ( int i, int j, PCSSGraph G,
-                                  int k, int l );
-
-  private :
-    int  nVAlloc,nEAlloc,nGAlloc;
-
-};
-
-
-
-//  ==================================================================
-
-//   In SelectDomain(..) and CutOutDomain(..), select is of the
-// following format:
-//    "*", "(all)"            - take all file
-//    "-"                     - take chain without chain ID
-//    "a:Ni-Mj,b:Kp-Lq,..."   - take chain a residue number N
-//                              insertion code i to residue number M
-//                              insertion code j plus chain b
-//                              residue number K insertion code p to
-//                              residue number L insertion code q and
-//                              so on.
-//    "a:,b:..."              - take whole chains a and b and so on
-//    "a:,b:Kp-Lq,..."        - any combination of the above.
-extern int SelectDomain ( PCMMDBManager MMDB, int & selHnd, pstr select,
-                          int selType );
-extern int CutOutDomain ( PCMMDBManager MMDB, pstr select );
-
-extern void DisposeSSGraphs ( PPCSSGraph & G, int & nGraphs );
-
-extern int  SuperposeSSGraphs ( PCSSGraph G1, ivector F1,
-                                PCSSGraph G2, ivector F2,
-                                int     matchlen,
-                                mat44 & TMatrix );
-
-
-/*
-
-extern realtype  GetTorsion ( rvector U, rvector W, rvector V );
-//      U     W      V
-//   o<----o----->o----->o
-//
-
-extern realtype  GetAngle   ( rvector v1, rvector v2 );
-//  returns angle between v1 and v2
-
-
-
-extern void  CalcCombinations ( rvector & combs, int & vlen,
-                                PCSSGraph G1, PCSSGraph G2 );
-
-*/
-
-#endif
diff --git a/ss_vxedge.h b/ss_vxedge.h
deleted file mode 100644
index 249e5b7..0000000
--- a/ss_vxedge.h
+++ /dev/null
@@ -1,232 +0,0 @@
-// $Id: ss_vxedge.h,v 1.5 2011/11/21 16:56:16 ekr Exp $
-// =================================================================
-//
-//    19.01.04   <--  Date of Last Modification.
-//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// -----------------------------------------------------------------
-//
-//  **** Module  :  ss_vxedge  <interface>
-//       ~~~~~~~~~
-//  **** Classes :  CSSVertex  ( secondary structure graph vertex )
-//       ~~~~~~~~~  CSSEdge    ( secondary structure graph edge   )
-//
-//  E. Krissinel 2002-2004
-//
-// =================================================================
-//
-
-
-#ifndef  __SS_VxEdge__
-#define  __SS_VxEdge__
-
-#include "mmdb/mmdb_manager.h"
-
-//  ==========================  Tune-up  ============================
-
-extern int hx_min_len;
-extern int sd_min_len;
-
-extern void InitSSGraph();  // should be called on top of application
-
-//  precision level conatsnts
-#define SSMP_Highest   1
-#define SSMP_High      2
-#define SSMP_Normal    3
-#define SSMP_Low       4
-#define SSMP_Lowest    5
-
-//  regimes of checking the SS connectivity
-#define CSSC_None      0
-#define CSSC_Flexible  1
-#define CSSC_Strict    2
-
-extern void SetSSMatchPrecision    ( int  precision );
-extern void writeSSMatchParameters ( pstr FileName  );
-extern int  readSSMatchParameters  ( pstr FileName  );
-extern void SetSSConnectivityCheck ( int  checkMode );
-
-
-//  =========================  CSSVertex  ===========================
-
-#define  V_UNKNOWN  -1
-#define  V_HELIX     0
-#define  V_STRAND    1
-
-DefineClass(CSSVertex)
-DefineStreamFunctions(CSSVertex)
-
-class CSSVertex : public CStream  {
-
-  friend class CSSEdge;
-  friend class CSSGraph;
-
-  public :
-
-    CSSVertex ();
-    CSSVertex ( RPCStream Object );
-    ~CSSVertex();
-
-    int  SetVertex ( PCMMDBManager MMDB, PCHelix  Helix  );
-    int  SetVertex ( PCMMDBManager MMDB, PCStrand Strand );
-    int  SetVertex ( PCMMDBManager MMDB, int v_type, int sNum,
-                     int  iclass, ChainID chID,
-                     int seqNum1, InsCode iCode1,
-                     int seqNum2, InsCode iCode2 );
-
-    void SetID ( int vid ) { id = vid; }
-
-    realtype GetAngle  ( PCSSVertex v );
-    realtype GetCosine ( PCSSVertex v );
-    realtype GetAngle  ( realtype vx, realtype vy, realtype vz );
-
-    pstr     GetShortVertexDesc ( pstr S );
-    pstr     GetFullVertexDesc  ( pstr S );
-
-    Boolean  Compare ( PCSSVertex v ); // True if vertices compare
-
-    realtype GetLengthDeviation ( PCSSVertex v );
-
-    void     GetDirection ( vect3 & v );
-    void     GetPosition  ( vect3 & p );
-    void     GetPosition  ( realtype & vx0, realtype & vy0,
-                            realtype & vz0 );
-
-    realtype GetLength    () { return length; }
-    int      GetSeqLength () { return nres;   }
-    realtype GetMass      () { return mass;   }
-
-    realtype GetX1        () { return x1;     };
-    realtype GetX2        () { return x2;     };
-    realtype GetY1        () { return y1;     };
-    realtype GetY2        () { return y2;     };
-    realtype GetZ1        () { return z1;     };
-    realtype GetZ2        () { return z2;     };
-
-    Boolean  inRange      ( pstr chID, int Pos1, int Pos2 );
-
-    int   GetVertexType   () { return type;    }
-    int   GetVertexChainNo() { return VNo;     }
-    pstr  GetChainID      () { return chainID; }
-    void  GetVertexRange  ( ChainID chID,
-                            ResName name1,
-                            int &   seqNum1,
-                            InsCode insCode1,
-                            ResName name2,
-                            int &   seqNum2,
-                            InsCode insCode2 );  
-
-    void  Copy  ( PCSSVertex v );
-
-    void  read  ( RCFile f );
-    void  write ( RCFile f );
-
-  protected :
-    
-    //  matching info
-    int      id;          // unique identifier that MUST be the vertex
-                          // number starting from 1 on
-    int      type;        // a V_XXXXX constant
-    int      classID;     // class ID for helices
-    int      nres;        // number of residues
-    realtype x0,y0,z0;    // center of mass
-    realtype mass;        // the mass
-    realtype ex,ey,ez;    // direction vector
-    realtype dalpha;      // uncertainty angle
-    realtype length;      // vertex length
-
-    //  identification info
-    pstr     name;        // composed name for short identification
-    int      serNum;      // helix serial number
-    int      strandNo;    // strand number
-    maxMMDBName vertexID; // helix ID or sheet ID
-    ChainID  chainID;     // chain ID (only for identification)
-    ResName  initResName; // name of the strand's initial residue
-    int      initSeqNum;  // sequence number of the initial residue
-    int      initPos;     // sequence position of the initial residue
-    InsCode  initICode;   // insertion code of the initial residue
-    ResName  endResName;  // name of the strand's terminal residue
-    int      endSeqNum;   // sequence number of the terminal residue
-    int      endPos;      // sequence position of the terminal residue
-    InsCode  endICode;    // insertion code of the terminal residue
-    int      VNo;         // number of vertex in the chain
-
-    realtype x1,x2;       // coordinates
-    realtype y1,y2;       //   SSE
-    realtype z1,z2;       //     ends
-
-    void  InitSSVertex ();
-    void  FreeMemory   ();
-    void  CalcGeometry ( PPCAtom CA );
-    int   GetPositions ( PCMMDBManager MMDB, int minlen );
-    realtype  GetCoor1 ( PPCAtom CA, int coor_key );
-    realtype  GetCoor2 ( PPCAtom CA, int coor_key );
-
-};
-
-
-
-//  ==========================  CSSEdge  ============================
-
-DefineClass(CSSEdge)
-DefineStreamFunctions(CSSEdge)
-
-class CSSEdge : public CStream  {
-
-  friend class CSSGraph;
-  friend class CSSGraphMatch;
-
-  public :
-
-    CSSEdge ();
-    CSSEdge ( RPCStream Object );
-    ~CSSEdge();
-
-    void     SetEdge  ( PCSSVertex v1, PCSSVertex v2 );
-
-    realtype GetAngle ( PCSSVertex v );  // returns angle between
-                                         // the edge and vertex
-    realtype GetCosine ( PCSSEdge E );   // returns cosine angle between
-                                         // the edges
-    realtype GetAngle ( rvector V1, rvector V2 );
-
-    // Compare(..) returns 0 if edges compare, that is:
-    //   1. edge lengths compare within relative precision
-    //      edge_len_tol
-    //   2. angles alpha1, alpha2 and alpha3 compare within
-    //      absolute deviations edge_alphaX_tol .
-    int   Compare ( Boolean swap_this, PCSSEdge edge,
-                    Boolean swap_edge );
-
-    int   CheckConnectivity ( Boolean swap_this, PCSSEdge edge,
-                              Boolean swap_edge );
-
-    void  GetDirection ( vect3 & v );
-    realtype GetLength () { return length; }
-
-    void  read  ( RCFile f );
-    void  write ( RCFile f );
- 
-  protected :
-    int      id1,id2;  // linked vertices
-    int      vtype1;   // type of 1st linked vertex
-    int      vtype2;   // type of 2nd linked vertex
-    int      bdir;     // bond direction along the chain
-    realtype length;   // length of edge (between v1 and v2 mass centers)
-    realtype ex,ey,ez; // direction vector from v1 to v2
-    realtype alpha1;   // angle V1E between v1 and the edge
-    realtype alpha2;   // angle V2E between v2 and the edge
-    realtype alpha3;   // angle V1V2 between v1 and v2
-    realtype alpha4;   // torsion angle V1EV2 of v1, edge and v2
-    realtype dalpha1;  // uncertainty in alpha1
-    realtype dalpha2;  // uncertainty in alpha2
-    realtype dalpha3;  // uncertainty in alpha3
-    realtype dalpha4;  // uncertainty in alpha4
-    realtype dr12;
-    Boolean  GoodTorsion; // True if the VEV torsion angle is well defined
-
-    void  InitSSEdge();
-
-};
-
-
-#endif
diff --git a/ssm_align.cpp b/ssm_align.cpp
index 792c252..71bd5eb 100644
--- a/ssm_align.cpp
+++ b/ssm_align.cpp
@@ -1,4 +1,4 @@
-// $Id: ssm_align.cpp,v 1.9 2011/12/01 13:53:40 gxg60988 Exp $
+// $Id: ssm_align.cpp,v 1.7 2008/07/08 15:51:03 keb Exp $
 // =================================================================
 //
 //    26.06.06   <--  Date of Last Modification.
@@ -9,8 +9,8 @@
 //       ~~~~~~~~~
 //  **** Project :  Structure alignment in 3D
 //       ~~~~~~~~~
-//  **** Classes :  CSSMAlign ( Secondary Structure Matching )
-//       ~~~~~~~~~  CXAlign   ( Output alignment             ) 
+//  **** Classes :  ssm::Align ( Secondary Structure Matching )
+//       ~~~~~~~~~  ssm::XAlign   ( Output alignment             )
 //                  CXTAlign  ( Text output alignment        )
 //
 //  E. Krissinel, 2002-2006
@@ -25,21 +25,21 @@
 #include "ssm_align.h"
 
 
-//  ---------------------------  CSSMAlign ------------------------
+//  ---------------------------  ssm::Align ------------------------
 
-CSSMAlign::CSSMAlign() : CStream()  {
-  InitSSMAlign();
+ssm::Align::Align() : CStream()  {
+  InitAlign();
 }
 
-CSSMAlign::CSSMAlign ( RPCStream Object ) : CStream ( Object )  {
-  InitSSMAlign();
+ssm::Align::Align ( RPCStream Object ) : CStream ( Object )  {
+  InitAlign();
 }
 
-CSSMAlign::~CSSMAlign()  {
+ssm::Align::~Align()  {
   FreeMemory();
 }
 
-void CSSMAlign::FreeMemory()  {
+void ssm::Align::FreeMemory()  {
   FreeVectorMemory ( Ca1     ,0 );
   FreeVectorMemory ( dist1   ,0 );
   FreeVectorMemory ( Ca2     ,0 );
@@ -51,11 +51,11 @@ void CSSMAlign::FreeMemory()  {
   nMatches = 0;
 }
 
-void CSSMAlign::InitSSMAlign()  {
+void ssm::Align::InitAlign()  {
 
   Mat4Init ( TMatrix ); // transformation matrix
-  
-  cnCheck     = CSSC_Flexible;
+
+  cnCheck     = CONNECT_Flexible;
   rmsd        = 0.0;  // core rmsd achieved
   Qscore      = 0.0;  // core Q achieved
   nres1       = 0;    // number of residues in query  structure
@@ -88,9 +88,9 @@ void CSSMAlign::InitSSMAlign()  {
 }
 
 
-void CSSMAlign::MapSelections ( int & selHndCa, PCMMDBManager M,
-                                PCSSGraph G, int selHnd,
-                                ivector & newID )  {
+void ssm::Align::MapSelections ( int & selHndCa, PCMMDBManager M,
+                                 PGraph G, int selHnd,
+                                 ivector & newID )  {
 PPCAtom a;
 int     nr,i,k;
   G->SelectCalphas ( M,selHndCa,NULL );
@@ -107,7 +107,7 @@ int     nr,i,k;
 }
 
 
-void CSSMAlign::MakeSelections ( PCMMDBManager M1, int selHnd1,
+void ssm::Align::MakeSelections ( PCMMDBManager M1, int selHnd1,
                                  PCMMDBManager M2, int selHnd2 )  {
 ivector newID1,newID2;
 int     i,k;
@@ -158,44 +158,19 @@ int     i,k;
 }
 
 
-PCSSGraph CSSMAlign::GetSSGraph ( PCMMDBManager M, int selHnd,
-                                  int & rc )  {
-PCSSGraph G;
-
-  G  = new CSSGraph();
-  rc = G->MakeGraph ( M );
-  if (!rc)  {
-    if (selHnd>0)  {
-      G->LeaveVertices ( selHnd,M );
-      if (G->GetNofVertices()<=0)  {
-        delete G;
-        rc = SSM_noVertices;
-        return NULL;
-      }
-    }
-    G->BuildGraph();
-    return G;
-  } else  {
-    rc = SSM_noGraph;
-    if (G)  delete G;
-    return NULL;
-  }
-
-}
-
-
-int CSSMAlign::Align ( PCMMDBManager M1, PCMMDBManager M2,
-                       int precision, int connectivity,
-                       int selHnd1,   int selHnd2 )  {
-PPCSSMatch Match;
-ivector    F1,F2;
-realtype   Q1;
-int        i,nm;
+int ssm::Align::align ( PCMMDBManager M1, PCMMDBManager M2,
+                        PRECISION     precision,
+                        CONNECTIVITY  connectivity,
+                        int selHnd1,  int selHnd2 )  {
+PPMatch  Match;
+ivector  F1,F2;
+realtype Q1;
+int      i,nm;
 
   FreeMemory();
 
-  SetSSMatchPrecision    ( precision    );
-  SetSSConnectivityCheck ( connectivity );
+  SetMatchPrecision    ( precision    );
+  SetConnectivityCheck ( connectivity );
   cnCheck = connectivity;
 
   U.SetUniqueMatch ( True );
@@ -210,8 +185,7 @@ int        i,nm;
   U.MatchGraphs ( G1,G2,1 );
 
   U.GetMatches ( Match,nMatches );
-  if (nMatches<=0)  return SSM_noHits;
-
+  if (nMatches<=0)  return RC_NoHits;
 
   GetVectorMemory ( pqvalues,nMatches,0 );
   for (i=0;i<nMatches;i++)
@@ -221,12 +195,12 @@ int        i,nm;
   for (i=0;i<nMatches;i++)
     if (Match[i])  {
       Match[i]->GetMatch ( F1,F2,nm );
-      Superpose.SuperposeCalphas ( G1,G2,F1,F2,nm,M1,M2,
+      superpose.SuperposeCalphas ( G1,G2,F1,F2,nm,M1,M2,
                                    selHnd1,selHnd2 );
-      Q1 = Superpose.GetCalphaQ();
+      Q1 = superpose.GetCalphaQ();
       if ((Q1>0.0) && (Q1>Qscore))  {
         Qscore = Q1;
-        Superpose.GetSuperposition ( Ca1,dist1,nres1,Ca2,nres2,
+        superpose.GetSuperposition ( Ca1,dist1,nres1,Ca2,nres2,
                                      TMatrix,rmsd,nalgn,ngaps,
                                      seqIdentity, nmd,ncombs );
       }
@@ -235,30 +209,30 @@ int        i,nm;
 
   if (Qscore>0.0)  {
     MakeSelections ( M1,selHnd1, M2,selHnd2 );
-    return SSM_Ok;
+    return RC_Ok;
   }
 
-  return SSM_noSPSN;
+  return RC_NoSuperposition;
 
 }
 
 
-int CSSMAlign::AlignSelectedMatch ( PCMMDBManager M1,
-                                    PCMMDBManager M2,
-                                    int    precision,
-                                    int connectivity,
-                                    int      selHnd1,
-                                    int      selHnd2,
-                                    int      nselect )  {
-PPCSSMatch Match;
-ivector    F1,F2;
-realtype   Q1;
-int        i,nGMatches,nm;
+int ssm::Align::AlignSelectedMatch ( PCMMDBManager M1,
+                                     PCMMDBManager M2,
+                                     PRECISION    precision,
+                                     CONNECTIVITY connectivity,
+                                     int          selHnd1,
+                                     int          selHnd2,
+                                     int          nselect )  {
+PPMatch   Match;
+ivector   F1,F2;
+realtype  Q1;
+int       i,nGMatches,nm;
 
   FreeMemory();
 
-  SetSSMatchPrecision    ( precision    );
-  SetSSConnectivityCheck ( connectivity );
+  SetMatchPrecision    ( precision    );
+  SetConnectivityCheck ( connectivity );
   cnCheck = connectivity;
 
   U.SetUniqueMatch ( True );
@@ -273,11 +247,11 @@ int        i,nGMatches,nm;
   U.MatchGraphs ( G1,G2,1 );
 
   U.GetMatches ( Match,nGMatches );
-  if (nGMatches<=0)  return SSM_noHits;
+  if (nGMatches<=0)  return RC_NoHits;
 
   if (nselect>=nGMatches)  {
 //  printf(" There are only %d matches for this alignment", nGMatches);
-    return SSM_tooFewMatches;
+    return RC_TooFewMatches;
   }
 
   Qscore = -0.5;
@@ -285,32 +259,32 @@ int        i,nGMatches,nm;
   if (Match[nselect])  {
 
     Match[nselect]->GetMatch   ( F1,F2,nm );
-    Superpose.SuperposeCalphas ( G1,G2,F1,F2,nm,M1,M2,
+    superpose.SuperposeCalphas ( G1,G2,F1,F2,nm,M1,M2,
                                  selHnd1,selHnd2 );
 
-    Q1 = Superpose.GetCalphaQ();
+    Q1 = superpose.GetCalphaQ();
     if (Q1>0.0)  {
-      Superpose.GetSuperposition ( Ca1,dist1,nres1,Ca2,nres2,TMatrix,
+      superpose.GetSuperposition ( Ca1,dist1,nres1,Ca2,nres2,TMatrix,
                                    rmsd,nalgn,ngaps,seqIdentity,
                                    nmd,ncombs );
       MakeSelections ( M1,selHnd1, M2,selHnd2 );
-      return SSM_Ok;
+      return RC_Ok;
     }
 
   }
 
-  return SSM_noSPSN;
+  return RC_NoSuperposition;
 
 }
 
 
-void CSSMAlign::write ( RCFile f )  {
+void ssm::Align::write ( RCFile f )  {
 int i,j;
 
   for (i=0;i<4;i++)
     for (j=0;j<4;j++)
       f.WriteReal ( &(TMatrix[i][j]) );
-  
+
   f.WriteInt  ( &cnCheck     );
   f.WriteReal ( &rmsd        );
   f.WriteInt  ( &nres1       );
@@ -337,7 +311,7 @@ int i,j;
 
 }
 
-void CSSMAlign::read ( RCFile f )  {
+void ssm::Align::read ( RCFile f )  {
 int i,j;
 
   FreeMemory();
@@ -345,7 +319,7 @@ int i,j;
   for (i=0;i<4;i++)
     for (j=0;j<4;j++)
       f.ReadReal ( &(TMatrix[i][j]) );
-  
+
   f.ReadInt  ( &cnCheck     );
   f.ReadReal ( &rmsd        );
   f.ReadInt  ( &nres1       );
@@ -377,13 +351,14 @@ int i,j;
 
 }
 
-MakeStreamFunctions(CSSMAlign)
-
+namespace ssm  {
+  MakeStreamFunctions(Align)
+}
 
 
-//  -----------------------------  CXAlign --------------------------
+//  -----------------------------  ssm::XAlign --------------------------
 
-CXAlign::CXAlign()  {
+ssm::XAlign::XAlign()  {
   XBlock1 = NULL;
   nBlock1 = 0;
   XBlock2 = NULL;
@@ -391,11 +366,11 @@ CXAlign::CXAlign()  {
   algnLen = 0;
 }
 
-CXAlign::~CXAlign()  {
+ssm::XAlign::~XAlign()  {
   FreeMemory();
 }
 
-void CXAlign::FreeMemory()  {
+void ssm::XAlign::FreeMemory()  {
   if (XBlock1)  delete[] XBlock1;
   if (XBlock2)  delete[] XBlock2;
   XBlock1 = NULL;
@@ -406,12 +381,12 @@ void CXAlign::FreeMemory()  {
 }
 
 
-void CXAlign::customInit() {}
+void ssm::XAlign::customInit() {}
 
-void CXAlign::XAlign (
-                PCSSGraph g1, PPCAtom Calpha1, ivector Ca1, int nat1,
-                PCSSGraph g2, PPCAtom Calpha2, ivector Ca2, int nat2,
-               rvector dist1, int & nr )  {
+void ssm::XAlign::align (
+                PGraph g1, PPCAtom Calpha1, ivector Ca1, int nat1,
+                PGraph g2, PPCAtom Calpha2, ivector Ca2, int nat2,
+                rvector dist1, int & nr )  {
 int i,j;
 
   FreeMemory();
@@ -448,8 +423,8 @@ int i,j;
 }
 
 
-int  CXAlign::makeXBlocks ( ivector Ca, int nat, RPSXBlock XBlock,
-                            int & nBlocks )  {
+int  ssm::XAlign::makeXBlocks ( ivector Ca, int nat, RPXBlock xBlock,
+                                int & nBlocks )  {
 //    Ca is considered as blocks of non-negative,
 //  increasing-by-one numbers Ca[i]>=0, and negative
 //  Ca[i]<0 surrounding them. Block boundaries are drawn
@@ -458,12 +433,12 @@ int  CXAlign::makeXBlocks ( ivector Ca, int nat, RPSXBlock XBlock,
 //  identified by the initial and final indices i1 and i2, and
 //  by "index mass center" mc used for sorting.
 //    Returns the number of fold-columns.
-PSXBlock XB1;
+PXBlock  XB1;
 int      nAlloc,i,j,i1,i2,ip1,ip2,iv,k,icol;
 realtype mc;
 
-  if (XBlock)  delete[] XBlock;
-  XBlock  = NULL;
+  if (xBlock)  delete[] xBlock;
+  xBlock  = NULL;
   nBlocks = 0;
   nAlloc  = 0;
 
@@ -505,24 +480,24 @@ realtype mc;
     // create new block
     if (nBlocks>=nAlloc)  {
       nAlloc += 20;
-      XB1 = new SXBlock[nAlloc];
+      XB1 = new XBlock[nAlloc];
       for (j=0;j<nBlocks;j++)  {
-        XB1[j].i1   = XBlock[j].i1;
-        XB1[j].i2   = XBlock[j].i2;
-        XB1[j].ip1  = XBlock[j].ip1;
-        XB1[j].ip2  = XBlock[j].ip2;
-        XB1[j].mc   = XBlock[j].mc;
-        XB1[j].icol = XBlock[j].icol;
+        XB1[j].i1   = xBlock[j].i1;
+        XB1[j].i2   = xBlock[j].i2;
+        XB1[j].ip1  = xBlock[j].ip1;
+        XB1[j].ip2  = xBlock[j].ip2;
+        XB1[j].mc   = xBlock[j].mc;
+        XB1[j].icol = xBlock[j].icol;
       }
-      delete[] XBlock;
-      XBlock = XB1;
+      delete[] xBlock;
+      xBlock = XB1;
     }
-    XBlock[nBlocks].i1   = i1;
-    XBlock[nBlocks].i2   = i2;
-    XBlock[nBlocks].ip1  = ip1;
-    XBlock[nBlocks].ip2  = ip2;
-    XBlock[nBlocks].mc   = mc;
-    XBlock[nBlocks].icol = 0;
+    xBlock[nBlocks].i1   = i1;
+    xBlock[nBlocks].i2   = i2;
+    xBlock[nBlocks].ip1  = ip1;
+    xBlock[nBlocks].ip2  = ip2;
+    xBlock[nBlocks].mc   = mc;
+    xBlock[nBlocks].icol = 0;
     nBlocks++;
     i1 = i2+1;
   } while (i<nat);
@@ -537,12 +512,12 @@ realtype mc;
       mc = MaxReal;
       k  = -1;
       for (j=i;j<nBlocks;j++)
-        if ((XBlock[j].icol==0) && (XBlock[j].mc<mc))  {
-          mc = XBlock[j].mc;
+        if ((xBlock[j].icol==0) && (xBlock[j].mc<mc))  {
+          mc = xBlock[j].mc;
           k  = j;
         }
       if (k>=0)  {
-        XBlock[k].icol = icol;
+        xBlock[k].icol = icol;
         i  = k+1;
         iv = 1;
       } else
@@ -555,12 +530,12 @@ realtype mc;
 }
 
 
-void CXAlign::alignXBlocks ( RSXBlock B1, RSXBlock B2, int & nr )  {
+void ssm::XAlign::alignXBlocks ( RXBlock B1, RXBlock B2, int & nr )  {
 int  l1,l2, i1,i2, sseType1,sseType2, icol;
 
-  if (((a1[B1.ip1]>=B2.ip1) && (a1[B1.ip1]<=B2.ip2)) || 
-      ((a1[B1.ip2]>=B2.ip1) && (a1[B1.ip2]<=B2.ip2)) || 
-      ((a2[B2.ip1]>=B1.ip1) && (a2[B2.ip1]<=B1.ip2)) || 
+  if (((a1[B1.ip1]>=B2.ip1) && (a1[B1.ip1]<=B2.ip2)) ||
+      ((a1[B1.ip2]>=B2.ip1) && (a1[B1.ip2]<=B2.ip2)) ||
+      ((a2[B2.ip1]>=B1.ip1) && (a2[B2.ip1]<=B1.ip2)) ||
       ((a2[B2.ip2]>=B1.ip1) && (a2[B2.ip2]<=B1.ip2)))  {
 
     if (a1[B1.ip1]<B2.ip1)  {
@@ -672,7 +647,7 @@ int  l1,l2, i1,i2, sseType1,sseType2, icol;
 }
 
 
-void CXAlign::makeRow ( PCAtom A1, int sseType1,
+void ssm::XAlign::makeRow ( PCAtom A1, int sseType1,
                         PCAtom A2, int sseType2,
                         realtype dist, int rowNo,
                         int icol, Boolean aligned )  {
@@ -690,39 +665,42 @@ UNUSED_ARGUMENT(aligned);
 
 //  ----------------------------  CXTAlign --------------------------
 
+namespace ssm  {
 
-void  PrintAtom ( RCFile f, int sseType, realtype hydropathy,
-                  ChainID chID, ResName resName, int seqNum,
-                  InsCode insCode )  {
-char sse[2],hp[2],ch[3],S[200];
+  void  PrintAtom ( RCFile f, int sseType, realtype hydropathy,
+                    ChainID chID, ResName resName, int seqNum,
+                    InsCode insCode )  {
+  char sse[2],hp[2],ch[3],S[200];
 
-  if (sseType==V_HELIX)       sse[0] = 'H';
-  else if (sseType==V_STRAND) sse[0] = 'S';
-                         else sse[0] = ' ';
-  sse[1] = char(0);
+    if (sseType==V_HELIX)       sse[0] = 'H';
+    else if (sseType==V_STRAND) sse[0] = 'S';
+                           else sse[0] = ' ';
+    sse[1] = char(0);
 
-  if ((-5.0<hydropathy) && (hydropathy<5.0))  {
-    if (hydropathy>=-0.5)      hp[0] = '-';
-    else if (hydropathy<=-1.5) hp[0] = '+';
-                          else hp[0] = '.';
-  } else
-    hp[0] = ' ';
-  hp[1] = char(0);
+    if ((-5.0<hydropathy) && (hydropathy<5.0))  {
+      if (hydropathy>=-0.5)      hp[0] = '-';
+      else if (hydropathy<=-1.5) hp[0] = '+';
+                            else hp[0] = '.';
+    } else
+      hp[0] = ' ';
+    hp[1] = char(0);
 
-  if ((!chID[0]) || (chID[0]==' '))  {
-    ch[0] = ' ';      ch[1] = ' ';
-  } else  {
-    ch[0] = chID[0];  ch[1] = ':';
-  }
-  ch[2] = char(0);
+    if ((!chID[0]) || (chID[0]==' '))  {
+      ch[0] = ' ';      ch[1] = ' ';
+    } else  {
+      ch[0] = chID[0];  ch[1] = ':';
+    }
+    ch[2] = char(0);
 
-  sprintf ( S,"|%1s%1s %2s%3s%4i%1s|",
-              sse,hp,ch,resName,seqNum,insCode );
-  f.Write ( S );
+    sprintf ( S," |%1s%1s %2s%3s%4i%1s|",
+                sse,hp,ch,resName,seqNum,insCode );
+    f.Write ( S );
+
+  }
 
 }
 
-void  SXTAlign::Print ( RCFile f )  {
+void  ssm::XTAlign::Print ( RCFile f )  {
 char S[100],SI[10];
 int  i;
 
@@ -732,7 +710,7 @@ int  i;
       PrintAtom ( f,sseType1,hydropathy1,chID1,
                     resName1,seqNum1,insCode1 );
     else
-      f.Write ( "|             |" );
+      f.Write ( " |             |" );
 
     if (alignKey==0)  {
       switch (simindex)  {
@@ -745,23 +723,23 @@ int  i;
         case 0 :  strcpy ( SI,"....." );  break;
       }
       SI[1] = char(0);
-      sprintf ( S," <%1s%5.2f%1s%1s",SI,dist,SI,SI );
+      sprintf ( S," %1s%5.2f%1s%1s",SI,dist,SI,SI );
       if (S[3]==' ')  S[3] = SI[0];
       f.Write ( S );
       SI[1] = SI[0];
       for (i=1;i<loopNo;i++)  f.Write ( SI );
-      f.Write ( "> " );
+//      f.Write ( " " );
     } else  {
-      f.Write ( "          " );
+      f.Write ( "        " );
       for (i=1;i<loopNo;i++)  f.Write ( "     " );
-      f.Write ( "  " );
+      f.Write ( " " );
     }
 
     if (alignKey!=3)
       PrintAtom ( f,sseType2,hydropathy2,chID2,
                     resName2,seqNum2,insCode2 );
     else
-      f.Write ( "|             |" );
+      f.Write ( " |             |" );
 
     f.LF();
 
@@ -770,32 +748,32 @@ int  i;
 }
 
 
-CXAlignText::CXAlignText() : CXAlign() {
+ssm::XAlignText::XAlignText() : ssm::XAlign() {
   R = NULL;
 }
 
-CXAlignText::~CXAlignText() {
+ssm::XAlignText::~XAlignText() {
   customFree();
 }
 
-void CXAlignText::customFree()  {
+void ssm::XAlignText::customFree()  {
   if (R)  delete[] R;
   R = NULL;
 }
 
-void CXAlignText::customInit()  {
+void ssm::XAlignText::customInit()  {
 int i;
   customFree();
-  R = new SXTAlign[nRows];
+  R = new ssm::XTAlign[nRows];
   for (i=0;i<nRows;i++)
     R[i].alignKey = 5;
 }
 
-void  CXAlignText::WipeTextRows()  {
+void  ssm::XAlignText::WipeTextRows()  {
   R = NULL;
 }
 
-void CXAlignText::makeRow ( PCAtom A1, int sseType1,
+void ssm::XAlignText::makeRow ( PCAtom A1, int sseType1,
                             PCAtom A2, int sseType2,
                             realtype dist, int rowNo, int icol,
                             Boolean aligned )  {
@@ -824,7 +802,7 @@ void CXAlignText::makeRow ( PCAtom A1, int sseType1,
     R[rowNo].alignKey = 3;
 
   if ((!A1) && (!A2))  R[rowNo].alignKey = 4;
-  
+
   R[rowNo].simindex = -5;
   R[rowNo].dist     = -1.0;
   if (aligned)  {
@@ -837,7 +815,7 @@ void CXAlignText::makeRow ( PCAtom A1, int sseType1,
 
 }
 
-void  CXAlignText::GetAlignments ( pstr & algn1, pstr & algn2 )  {
+void  ssm::XAlignText::GetAlignments ( pstr & algn1, pstr & algn2 )  {
 char rn1[10];
 char rn2[10];
 int i;
@@ -877,52 +855,57 @@ int i;
 }
 
 
+namespace ssm  {
 
-void PrintSSMAlignTable ( RCFile f, PCMMDBManager M1, PCMMDBManager M2,
-                                    PCSSMAlign SSMAlign )  {
-CXAlignText CXA;
-PSXTAlign   XTA;
-PPCAtom     Calpha1,Calpha2;
-int         nat1,nat2,nr,j;
+  void PrintAlignTable ( RCFile f, PCMMDBManager M1, PCMMDBManager M2,
+                                   PAlign SSMAlign )  {
+  XAlignText CXA;
+  PXTAlign   XTA;
+  PPCAtom     Calpha1,Calpha2;
+  int         nat1,nat2,nr,j;
 
-  M1->GetSelIndex ( SSMAlign->selHndCa1,Calpha1,nat1 );
-  M2->GetSelIndex ( SSMAlign->selHndCa2,Calpha2,nat2 );
+    M1->GetSelIndex ( SSMAlign->selHndCa1,Calpha1,nat1 );
+    M2->GetSelIndex ( SSMAlign->selHndCa2,Calpha2,nat2 );
 
-  CXA.XAlign ( SSMAlign->G1,Calpha1,SSMAlign->Ca1,nat1,
-               SSMAlign->G2,Calpha2,SSMAlign->Ca2,nat2,
-               SSMAlign->dist1,nr );
-  f.LF();
-  if (SSMAlign->cnCheck!=CSSC_None)  {
-    f.WriteLine ( ".-------------.------------.-------------." );
-    f.WriteLine ( "|    Query    |  Dist.(A)  |   Target    |" );
-    f.WriteLine ( "|-------------+------------+-------------|" );
-  } else  {
-    f.WriteLine (
-    ".-------------.------------.-----------------------------------");
-    f.WriteLine (
-    "|    Query    |  Dist.(A)  |   Target"                          );
-    f.WriteLine (
-    "|-------------+------------+-----------------------------------");
-  }
-  XTA = CXA.GetTextRows();
-  for (j=0;j<nr;j++)
-    XTA[j].Print ( f );
-  if (SSMAlign->cnCheck!=CSSC_None)
-    f.WriteLine ( "`-------------'------------'-------------'" );
-  else
-    f.WriteLine (
-    "`-------------'------------'-----------------------------------");
-  f.LF();
-  f.WriteLine ( " Notations:" );
-  f.WriteLine ( " S/H   residue belongs to a strand/helix" );
-  f.WriteLine ( " +/-/. hydrophylic/hydrophobic/neutral residue" );
-  f.WriteLine ( " **    identical residues matched: similarity 5" );
-  f.WriteLine ( " ++    similarity 4" );
-  f.WriteLine ( " ==    similarity 3" );
-  f.WriteLine ( " --    similarity 2" );
-  f.WriteLine ( " ::    similarity 1" );
-  f.WriteLine ( " ..    dissimilar residues: similarity 0" );
+    CXA.align ( SSMAlign->G1,Calpha1,SSMAlign->Ca1,nat1,
+                SSMAlign->G2,Calpha2,SSMAlign->Ca2,nat2,
+                SSMAlign->dist1,nr );
+    f.LF();
 
-}
+    if (SSMAlign->cnCheck!=CONNECT_None)  {
+      f.WriteLine ( " .-------------.----------.-------------." );
+      f.WriteLine ( " |    Query    | Dist.(A) |   Target    |" );
+      f.WriteLine ( " |-------------+----------+-------------|" );
+    } else  {
+      f.WriteLine (
+      " .-------------.----------.-----------------------------------");
+      f.WriteLine (
+      " |    Query    | Dist.(A) |   Target"                          );
+      f.WriteLine (
+      " |-------------+----------+-----------------------------------");
+    }
+
+    XTA = CXA.GetTextRows();
+    for (j=0;j<nr;j++)
+      XTA[j].Print ( f );
 
+    if (SSMAlign->cnCheck!=CONNECT_None)
+      f.WriteLine ( " `-------------'----------'-------------'" );
+    else
+      f.WriteLine (
+      " `-------------'----------'-----------------------------------");
+    f.LF();
 
+    f.WriteLine ( " Notations:" );
+    f.WriteLine ( " S/H   residue belongs to a strand/helix" );
+    f.WriteLine ( " +/-/. hydrophylic/hydrophobic/neutral residue" );
+    f.WriteLine ( " **    identical residues matched: similarity 5" );
+    f.WriteLine ( " ++    similarity 4" );
+    f.WriteLine ( " ==    similarity 3" );
+    f.WriteLine ( " --    similarity 2" );
+    f.WriteLine ( " ::    similarity 1" );
+    f.WriteLine ( " ..    dissimilar residues: similarity 0" );
+
+  }
+
+}
diff --git a/ssm_align.h b/ssm_align.h
index db2e28b..4f34d70 100644
--- a/ssm_align.h
+++ b/ssm_align.h
@@ -1,7 +1,7 @@
-// $Id: ssm_align.h,v 1.5 2011/11/21 16:56:16 ekr Exp $
+// $Id: ssm_align.h,v 1.1.1.1 2004/11/23 16:24:37 keb Exp $
 // =================================================================
 //
-//    22.04.04   <--  Date of Last Modification.
+//    05.04.13   <--  Date of Last Modification.
 //                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //  ----------------------------------------------------------------
 //
@@ -9,198 +9,185 @@
 //       ~~~~~~~~~
 //  **** Project :  Structure alignment in 3D
 //       ~~~~~~~~~
-//  **** Classes :  CSSMAlign ( Secondary Structure Matching )
-//       ~~~~~~~~~  CXAlign   ( Output alignment             ) 
-//                  CXTAlign  ( Text output alignment        )
+//  **** Classes :  ssm::Align   ( Secondary Structure Matching )
+//       ~~~~~~~~~  ssm::XAlign  ( Output alignment             )
+//                  ssm::XTAlign ( Text output alignment        )
 //
-//  E. Krissinel, 2002-2004
+//  E. Krissinel, 2002-2013
 //
 // =================================================================
 //
- 
+
 #ifndef  __SSM_Align__
 #define  __SSM_Align__
 
 #include "mmdb/mmdb_manager.h"
 
 #include "ssm_superpose.h"
-#include "ss_csia.h"
+#include "ssm_csia.h"
 
 
 //  ---------------------------  CSSMAlign  ------------------------
 
-#define SSM_Ok            0
-#define SSM_noHits        1
-#define SSM_noSPSN        2
-#define SSM_noGraph       3
-#define SSM_noVertices    4
-#define SSM_noGraph2      5
-#define SSM_noVertices2   6
-#define SSM_tooFewMatches 7
-
-DefineClass(CSSMAlign)
-DefineStreamFunctions(CSSMAlign)
-
-class CSSMAlign : public CStream  {
-
-  public :
-    mat44    TMatrix; //!< superposition matrix to be applied to 1st structure
-    realtype rmsd;         //!< core rmsd achieved
-    realtype Qscore;       //!< core Q achieved
-    int      cnCheck;      //!< connectivity option used
-    int      nres1,nres2;  //!< number of residues in structures
-    int      nsel1,nsel2;  //!< number of residues in aligned selections
-    int      nalgn;        //!< number of aligned residues
-    int      ngaps;        //!< number of gaps
-    int      nmd;          //!< number of misdirections
-    realtype ncombs;       //!< number of SSE combinations
-    realtype seqIdentity;  //!< sequence identity
-    int      selHndCa1,selHndCa2; //!< selection handles to used C-alphas
-    ivector  Ca1,Ca2;      //!< C-alpha correspondence vectors
-                           //!< Ca1[i] corresponds to a[i], where a is
-                           //!< selection identified by selHndCa1
-    rvector  dist1;        //!< optimizedd distances between the query
-                           //!< and target C-alphas
-    PCSSGraph G1,G2;       //!< retained SSE graphs
-
-    CSSMAlign ();
-    CSSMAlign ( RPCStream Object );
-    ~CSSMAlign();
-
-    int Align ( PCMMDBManager M1, PCMMDBManager M2,
-                int precision, int connectivity,
-                int selHnd1=0, int selHnd2=0 );
-
-
-
-    int AlignSelectedMatch ( PCMMDBManager M1, PCMMDBManager M2,
-                             int precision, int connectivity,
-                             int selHnd1=0, int selHnd2=0,
-                             int nselect=0 );
-
-    rvector GetQvalues () const { return pqvalues; }
-    int     GetNMatches() const { return nMatches; }
-
-
-    PCSSGraph GetSSGraph ( PCMMDBManager M, int selHnd, int & rc );
-
-    PCSuperpose GetSuperpose() { return &Superpose; }
-
-    void  read  ( RCFile f );
-    void  write ( RCFile f );
-
-  protected :
-    CSSGraphMatch U;
-    CSuperpose    Superpose;
-    rvector       pqvalues;
-    int           nMatches;
-
-    void  InitSSMAlign();
-    void  FreeMemory  ();
-    void  MapSelections  ( int & selHndCa, PCMMDBManager M,
-                           PCSSGraph G, int selHnd,
-                           ivector & newID );
-    void  MakeSelections ( PCMMDBManager M1, int selHnd1,
-                           PCMMDBManager M2, int selHnd2 );
-
-};
-
-   
-
-//  -----------------------------  CXAlign --------------------------
-
-DefineStructure(SXBlock)
-
-struct SXBlock  {
-  int      i1,i2;    // the outer block boundaries
-  int      ip1,ip2;  // the alignment boundaries (ip1>=i1, ip2<=i2)
-  int      icol;     // the block "column" number
-  realtype mc;       // center of "index mass"
-};
-
-
-DefineClass(CXAlign)
-
-class CXAlign  {
-
-  public :
-    CXAlign();
-    ~CXAlign();
-
-    void XAlign ( PCSSGraph g1, PPCAtom Calpha1, ivector Ca1, int nat1,
-                  PCSSGraph g2, PPCAtom Calpha2, ivector Ca2, int nat2,
-                  rvector dist1, int & nr );
-
-    int  GetNCols2() { return nCols2; }
-
-  protected :
-    PSXBlock  XBlock1,XBlock2;
-    int       nBlock1,nBlock2;
-    int       na1,na2,nCols1,nCols2,nRows,algnLen;
-
-    ivector   a1,a2;
-    PPCAtom   alpha1,alpha2;
-    PCSSGraph sg1,sg2;
-    rvector   d1;
-    realtype  maxdist;
-
-    virtual void FreeMemory();
-    virtual void customInit();
-    int   makeXBlocks  ( ivector Ca, int nat, RPSXBlock XBlock,
-                         int & nBlocks );
-    void  alignXBlocks ( RSXBlock B1, RSXBlock B2, int & nr );
-
-    virtual void makeRow ( PCAtom A1, int sseType1,
-                           PCAtom A2, int sseType2,
-                           realtype dist, int rowNo, int icol,
-                           Boolean aligned );
-};
-
+namespace ssm {
 
-//  ----------------------------  CXTAlign --------------------------
+  DefineClass(Align);
+  DefineStreamFunctions(Align)
 
-DefineStructure(SXTAlign)
+  class Align : public CStream  {
+
+    public :
+      mat44    TMatrix; //!< superposition matrix to be applied to 1st structure
+      realtype rmsd;         //!< core rmsd achieved
+      realtype Qscore;       //!< core Q achieved
+      int      cnCheck;      //!< connectivity option used
+      int      nres1,nres2;  //!< number of residues in structures
+      int      nsel1,nsel2;  //!< number of residues in aligned selections
+      int      nalgn;        //!< number of aligned residues
+      int      ngaps;        //!< number of gaps
+      int      nmd;          //!< number of misdirections
+      realtype ncombs;       //!< number of SSE combinations
+      realtype seqIdentity;  //!< sequence identity
+      int      selHndCa1,selHndCa2; //!< selection handles to used C-alphas
+      ivector  Ca1,Ca2;      //!< C-alpha correspondence vectors
+                             /// Ca1[i] corresponds to a[i], where a is
+                             /// selection identified by selHndCa1
+      rvector  dist1;        //!< optimizedd distances between the query
+                             /// and target C-alphas
+      PGraph   G1,G2;        //!< retained SSE graphs
+
+      Align ();
+      Align ( RPCStream Object );
+      ~Align();
+
+      int align ( PCMMDBManager M1, PCMMDBManager M2,
+                  PRECISION     precision,
+                  CONNECTIVITY  connectivity,
+                  int selHnd1=0, int selHnd2=0 );
+
+      int AlignSelectedMatch ( PCMMDBManager M1, PCMMDBManager M2,
+                               PRECISION     precision,
+                               CONNECTIVITY  connectivity,
+                               int selHnd1=0, int selHnd2=0,
+                               int nselect=0 );
 
-struct SXTAlign  {
-  realtype hydropathy1,hydropathy2,dist;
-  ChainID  chID1,chID2;
-  ResName  resName1,resName2;
-  InsCode  insCode1,insCode2;
-  int      alignKey; // 0: aligned, 1: not aligned, 2: NULL 1, 3: NULL 2
-  int      loopNo;
-  int      sseType1,sseType2;
-  int      seqNum1,seqNum2;
-  int      simindex;
-  void  Print ( RCFile f );
-};
+      rvector GetQvalues () const { return pqvalues; }
+      int     GetNMatches() const { return nMatches; }
 
+      PSuperpose GetSuperpose() { return &superpose; }
+
+      void  read  ( RCFile f );
+      void  write ( RCFile f );
 
-DefineClass(CXAlignText)
+    protected :
+      GraphMatch U;
+      Superpose  superpose;
+      rvector    pqvalues;
+      int        nMatches;
+
+      void  InitAlign ();
+      void  FreeMemory();
+      void  MapSelections  ( int & selHndCa, PCMMDBManager M,
+                             PGraph G, int selHnd, ivector & newID );
+      void  MakeSelections ( PCMMDBManager M1, int selHnd1,
+                             PCMMDBManager M2, int selHnd2 );
+
+  };
+
+
+  //  -----------------------------  CXAlign --------------------------
+
+  DefineStructure(XBlock);
+
+  struct XBlock  {
+    int      i1,i2;    //!< the outer block boundaries
+    int      ip1,ip2;  //!< the alignment boundaries (ip1>=i1, ip2<=i2)
+    int      icol;     //!< the block "column" number
+    realtype mc;       //!< center of "index mass"
+  };
+
+
+  DefineClass(XAlign);
+
+  class XAlign  {
+
+    public :
+      XAlign();
+      virtual ~XAlign();
+
+      void align ( PGraph g1, PPCAtom Calpha1, ivector Ca1, int nat1,
+                   PGraph g2, PPCAtom Calpha2, ivector Ca2, int nat2,
+                   rvector dist1, int & nr );
+
+      int  GetNCols2() { return nCols2; }
+
+    protected :
+      PXBlock  XBlock1,XBlock2;
+      int       nBlock1,nBlock2;
+      int       na1,na2,nCols1,nCols2,nRows,algnLen;
+
+      ivector   a1,a2;
+      PPCAtom   alpha1,alpha2;
+      PGraph sg1,sg2;
+      rvector   d1;
+      realtype  maxdist;
+
+      virtual void FreeMemory();
+      virtual void customInit();
+      int   makeXBlocks  ( ivector Ca, int nat, RPXBlock xBlock,
+                           int & nBlocks );
+      void  alignXBlocks ( RXBlock B1, RXBlock B2, int & nr );
+
+      virtual void makeRow ( PCAtom A1, int sseType1,
+                             PCAtom A2, int sseType2,
+                             realtype dist, int rowNo, int icol,
+                             Boolean aligned );
+  };
+
+
+  //  ----------------------------  CXTAlign --------------------------
+
+  DefineStructure(XTAlign);
+
+  struct XTAlign  {
+    realtype hydropathy1,hydropathy2,dist;
+    ChainID  chID1,chID2;
+    ResName  resName1,resName2;
+    InsCode  insCode1,insCode2;
+    int      alignKey; //!< 0: aligned, 1: not aligned, 2: NULL 1, 3: NULL 2
+    int      loopNo;
+    int      sseType1,sseType2;
+    int      seqNum1,seqNum2;
+    int      simindex;
+    void  Print ( RCFile f );
+  };
 
-class CXAlignText : public CXAlign  {
+  DefineClass(XAlignText);
 
-  public :
-    CXAlignText ();
-    ~CXAlignText();
+  class XAlignText : public XAlign  {
 
-    PSXTAlign GetTextRows   () { return R; }
-    void      GetAlignments ( pstr & algn1, pstr & algn2 );
-    void      WipeTextRows  ();
+    public :
+      XAlignText ();
+      ~XAlignText();
 
-  protected :
-    PSXTAlign R;
+      PXTAlign GetTextRows   () { return R; }
+      void     GetAlignments ( pstr & algn1, pstr & algn2 );
+      void     WipeTextRows  ();
 
-    void customFree();
-    void customInit();
-    void makeRow   ( PCAtom A1, int sseType1,
-                     PCAtom A2, int sseType2,
-                     realtype dist, int rowNo, int icol,
-                     Boolean aligned );
-};
+    protected :
+      PXTAlign R;
 
+      void customFree();
+      void customInit();
+      void makeRow   ( PCAtom A1, int sseType1,
+                       PCAtom A2, int sseType2,
+                       realtype dist, int rowNo, int icol,
+                       Boolean aligned );
+  };
 
-extern void PrintSSMAlignTable ( RCFile f,
-                                 PCMMDBManager M1, PCMMDBManager M2,
-                                 PCSSMAlign SSMAlign );
+  extern void PrintAlignTable ( RCFile f,
+                                PCMMDBManager M1, PCMMDBManager M2,
+                                PAlign SSMAlign );
+}
 
 #endif
diff --git a/ss_csia.cpp b/ssm_csia.cpp
similarity index 75%
rename from ss_csia.cpp
rename to ssm_csia.cpp
index 39f2b17..e05b760 100644
--- a/ss_csia.cpp
+++ b/ssm_csia.cpp
@@ -1,16 +1,16 @@
-// $Id: ss_csia.cpp,v 1.5 2011/11/21 16:56:16 ekr Exp $
+// $Id: ssm_csia.cpp,v 1.1.1.1 2004/11/23 16:24:37 keb Exp $
 // =================================================================
 //
-//    27.09.04   <--  Date of Last Modification.
+//    05.04.13   <--  Date of Last Modification.
 //                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // -----------------------------------------------------------------
 //
 //  **** Module  :  ssm_csia  <implementation>
 //       ~~~~~~~~~
-//  **** Classes :  CSSGraphMatch ( matching SS graphs )
+//  **** Classes :  ssm::GraphMatch ( matching SS graphs )
 //       ~~~~~~~~~
 //
-//  E. Krissinel 2001-2004
+//  E. Krissinel 2001-2013
 //
 //  When used, please cite:
 //
@@ -22,22 +22,22 @@
 //
 
 
-#include "ss_csia.h"
+#include "ssm_csia.h"
 
 
-//  =========================  CSSMatch  ===========================
+//  =========================  ssm::Match  ===========================
 
-CSSMatch::CSSMatch() : CStream()  {
-  InitSSMatch();
+ssm::Match::Match() : CStream()  {
+  InitMatch();
 }
 
-CSSMatch::CSSMatch ( RPCStream Object ) : CStream ( Object )  {
-  InitSSMatch();
+ssm::Match::Match ( RPCStream Object ) : CStream ( Object )  {
+  InitMatch();
 }
 
-CSSMatch::CSSMatch ( ivector FV1, ivector FV2, int nv, int n, int m )  {
+ssm::Match::Match ( ivector FV1, ivector FV2, int nv, int n, int m )  {
 int i;
-  if (FV1 && FV2)  {    
+  if (FV1 && FV2)  {
     n1     = n;
     n2     = m;
     nAlloc = n;
@@ -49,10 +49,10 @@ int i;
       F2[i] = FV2[i];
     }
   } else
-    InitSSMatch();
+    InitMatch();
 }
 
-void  CSSMatch::InitSSMatch()  {
+void  ssm::Match::InitMatch()  {
   mlength = 0;
   n1      = 0;
   n2      = 0;
@@ -61,12 +61,12 @@ void  CSSMatch::InitSSMatch()  {
   F2      = NULL;
 }
 
-CSSMatch::~CSSMatch()  {
+ssm::Match::~Match()  {
   FreeVectorMemory ( F1,1 );
   FreeVectorMemory ( F2,1 );
 }
 
-void  CSSMatch::Swap()  {
+void  ssm::Match::Swap()  {
 ivector F;
 int     n;
   n  = n1;
@@ -77,7 +77,7 @@ int     n;
   F2 = F;
 }
 
-void CSSMatch::SetMatch ( ivector FV1, ivector FV2, int nv, int n, int m )  {
+void ssm::Match::SetMatch ( ivector FV1, ivector FV2, int nv, int n, int m )  {
 int i,j,k;
   if (FV1 && FV2)  {
     if (nv>nAlloc)  {
@@ -110,7 +110,7 @@ int i,j,k;
 }
 
 
-Boolean CSSMatch::isMatch ( ivector FV1, ivector FV2, int nv )  {
+Boolean ssm::Match::isMatch ( ivector FV1, ivector FV2, int nv )  {
 //   Returns True if all pairs (FV1[i],FV2[i]), i=1..nv are
 // found in the match
 int     i,j;
@@ -127,7 +127,7 @@ Boolean B;
   return False;
 }
 
-int CSSMatch::isSubMatch ( ivector FV1, ivector FV2, int nv )  {
+int ssm::Match::isSubMatch ( ivector FV1, ivector FV2, int nv )  {
 //   Returns True if all match's pairs (F1[i],F2[i]), i=1..mlength
 // are found in (FV1,FV2)
 int     i,j;
@@ -159,13 +159,13 @@ Boolean B;
 }
 
 
-void CSSMatch::GetMatch ( ivector  & FV1, ivector  & FV2, int & nv )  {
+void ssm::Match::GetMatch ( ivector  & FV1, ivector  & FV2, int & nv )  {
   FV1 = F1;
   FV2 = F2;
   nv  = mlength;
 }
 
-void CSSMatch::GetMatch ( ivector  & FV1, ivector  & FV2, int & nv,
+void ssm::Match::GetMatch ( ivector  & FV1, ivector  & FV2, int & nv,
                           realtype & p1,  realtype & p2 )  {
   FV1 = F1;
   FV2 = F2;
@@ -176,7 +176,7 @@ void CSSMatch::GetMatch ( ivector  & FV1, ivector  & FV2, int & nv,
   if (p2>0.0)  p2 /= n2;
 }
 
-void CSSMatch::write ( RCFile f )  {
+void ssm::Match::write ( RCFile f )  {
 int i;
 int Version=1;
   f.WriteInt ( &Version );
@@ -189,7 +189,7 @@ int Version=1;
   }
 }
 
-void CSSMatch::read ( RCFile f )  {
+void ssm::Match::read ( RCFile f )  {
 int i,Version;
   FreeVectorMemory ( F1,1 );
   FreeVectorMemory ( F2,1 );
@@ -208,25 +208,26 @@ int i,Version;
   }
 }
 
-MakeStreamFunctions(CSSMatch)
-
+namespace ssm  {
+  MakeStreamFunctions(Match)
+}
 
 
-//  =========================  CSSGraphMatch  ===========================
+//  =========================  ssm::GraphMatch  ===========================
 
-CSSGraphMatch::CSSGraphMatch() : CStream()  {
-  InitSSGraphMatch();
+ssm::GraphMatch::GraphMatch() : CStream()  {
+  InitGraphMatch();
 }
 
-CSSGraphMatch::CSSGraphMatch ( RPCStream Object ) : CStream ( Object )  {
-  InitSSGraphMatch();
+ssm::GraphMatch::GraphMatch ( RPCStream Object ) : CStream ( Object )  {
+  InitGraphMatch();
 }
 
-CSSGraphMatch::~CSSGraphMatch()  {
+ssm::GraphMatch::~GraphMatch()  {
   FreeMemory();
 }
 
-void  CSSGraphMatch::InitSSGraphMatch()  {
+void  ssm::GraphMatch::InitGraphMatch()  {
   G1            = NULL;
   G2            = NULL;
   n             = 0;
@@ -240,7 +241,7 @@ void  CSSGraphMatch::InitSSGraphMatch()  {
   mAlloc        = 0;
   nMatches      = 0;
   maxNofMatches = 40;
-  Match         = NULL;
+  match         = NULL;
   nMAlloc       = 0;
   UniqueMatch   = True;
   BestMatch     = True;
@@ -252,14 +253,14 @@ void  CSSGraphMatch::InitSSGraphMatch()  {
   flags         = 0;
 }
 
-void  CSSGraphMatch::FreeMemory()  {
+void  ssm::GraphMatch::FreeMemory()  {
 int i;
 
   if (P) {
     FreeMatrixMemory ( P[1],nAlloc,1,0 );
     FreeRecHeap      ();
     for (i=2;i<=nAlloc;i++)
-      if (P[i])  { 
+      if (P[i])  {
         P[i] = P[i] + 1;
         delete[] P[i];
       }
@@ -276,18 +277,18 @@ int i;
   nAlloc = 0;
   mAlloc = 0;
 
-  if (Match)  {
+  if (match)  {
     for (i=0;i<nMAlloc;i++)
-      if (Match[i])  delete Match[i];
-    delete[] Match;
+      if (match[i])  delete match[i];
+    delete[] match;
   }
-  Match    = NULL;
+  match    = NULL;
   nMatches = 0;
   nMAlloc  = 0;
 
 }
 
-void  CSSGraphMatch::FreeRecHeap()  {
+void  ssm::GraphMatch::FreeRecHeap()  {
 int i,j;
   if (P)
     for (i=2;i<=nAlloc;i++)
@@ -296,7 +297,7 @@ int i,j;
           FreeVectorMemory ( P[i][j],0 );
 }
 
-void  CSSGraphMatch::GetMemory()  {
+void  ssm::GraphMatch::GetMemory()  {
 int i,j;
 
   FreeMemory();
@@ -322,7 +323,7 @@ int i,j;
 
 }
 
-void  CSSGraphMatch::GetRecHeap()  {
+void  ssm::GraphMatch::GetRecHeap()  {
 int i,j;
   for (i=2;i<=n;i++)
     for (j=1;j<=n;j++)
@@ -330,48 +331,48 @@ int i,j;
 }
 
 
-void  CSSGraphMatch::SetUniqueMatch ( Boolean unique_match )  {
+void  ssm::GraphMatch::SetUniqueMatch ( Boolean unique_match )  {
   UniqueMatch = unique_match;
   if (UniqueMatch)  flags |=  SSMF_UniqueMatch;
               else  flags &= ~SSMF_UniqueMatch;
 }
 
-void  CSSGraphMatch::SetBestMatch ( Boolean best_match )  {
+void  ssm::GraphMatch::SetBestMatch ( Boolean best_match )  {
   BestMatch = best_match;
   if (BestMatch)  flags |=  SSMF_BestMatch;
             else  flags &= ~SSMF_BestMatch;
 }
 
-void  CSSGraphMatch::SetFlags ( word Flags )  {
+void  ssm::GraphMatch::SetFlags ( word Flags )  {
   flags |= Flags;
   if (Flags & SSMF_UniqueMatch)  UniqueMatch = True;
   if (Flags & SSMF_BestMatch)    BestMatch   = True;
 }
 
-void  CSSGraphMatch::SetMatchBufferLength ( int matchBufLen )  {
+void  ssm::GraphMatch::SetMatchBufferLength ( int matchBufLen )  {
   maxNofMatches = matchBufLen;
 }
-  
 
-void  CSSGraphMatch::RemoveFlags ( word Flags )  {
+
+void  ssm::GraphMatch::RemoveFlags ( word Flags )  {
   flags &= ~Flags;
   if (Flags & SSMF_UniqueMatch)  UniqueMatch = False;
   if (Flags & SSMF_BestMatch)    BestMatch   = False;
 }
 
 
-PCSSGraph  CSSGraphMatch::GetGraph1()  {
+ssm::PGraph  ssm::GraphMatch::GetGraph1()  {
   if (swap)  return G2;
        else  return G1;
 }
 
-PCSSGraph  CSSGraphMatch::GetGraph2()  {
+ssm::PGraph  ssm::GraphMatch::GetGraph2()  {
   if (swap)  return G1;
        else  return G2;
 }
 
-void  CSSGraphMatch::MatchGraphs ( PCSSGraph Gh1, PCSSGraph Gh2,
-                                   int minMatch )  {
+void  ssm::GraphMatch::MatchGraphs ( PGraph Gh1, PGraph Gh2,
+                                     int minMatch )  {
 int  i,j;
 
   nMatches = 0;
@@ -381,7 +382,7 @@ int  i,j;
   if ((!Gh1) || (!Gh2))  return;
 
   if (Gh1->nVertices<=Gh2->nVertices)  {
-    G1   = Gh1; 
+    G1   = Gh1;
     G2   = Gh2;
     swap = False;
   } else  {
@@ -391,10 +392,10 @@ int  i,j;
   }
   n  = G1->nVertices; // n <= m
   m  = G2->nVertices;
-  V1 = G1->Vertex;
-  V2 = G2->Vertex;
-  E1 = G1->Edge;
-  E2 = G2->Edge;
+  V1 = G1->V;
+  V2 = G2->V;
+  E1 = G1->E;
+  E2 = G2->E;
   c1 = G1->graph;     // c[i][j] is the ordinal number of edge connecting
   c2 = G2->graph;     // vertices i and j; c[i][i]==-1.
 
@@ -402,7 +403,7 @@ int  i,j;
     MatchSingleVertex();
     if (swap)  {
       for (i=0;i<nMatches;i++)
-        if (Match[i])  Match[i]->Swap();
+        if (match[i])  match[i]->Swap();
     }
     return;
   }
@@ -418,15 +419,15 @@ int  i,j;
   if (flags & SSMF_WrongConnectOnly)  {
     for (i=0;i<nMatches;i++)
       if (CheckConnectivity(i)<2)  {
-        if (Match[i])  delete Match[i];
-        Match[i] = NULL;
+        if (match[i])  delete match[i];
+        match[i] = NULL;
       }
     j = 0;
     for (i=0;i<nMatches;i++)
-      if (Match[i])  {
+      if (match[i])  {
         if (j!=i)  {
-          Match[j] = Match[i];
-          Match[i] = NULL;
+          match[j] = match[i];
+          match[i] = NULL;
         }
         j++;
       }
@@ -435,13 +436,13 @@ int  i,j;
 
   if (swap)  {
     for (i=0;i<nMatches;i++)
-      if (Match[i])  Match[i]->Swap();
+      if (match[i])  match[i]->Swap();
   }
 
 }
 
 
-void  CSSGraphMatch::MatchSingleVertex()  {
+void  ssm::GraphMatch::MatchSingleVertex()  {
 int     i, BF1[3],BF2[3];
 ivector SF1,SF2;
 
@@ -450,7 +451,7 @@ ivector SF1,SF2;
 
   F1  = BF1;
   F2  = BF2;
-  
+
   V1[0]->SetID ( 1 );
   if (m<=1)
     V2[0]->SetID ( 1 );
@@ -469,7 +470,7 @@ ivector SF1,SF2;
 
 
 
-void  CSSGraphMatch::DoMatch ( int minMatch )  {
+void  ssm::GraphMatch::DoMatch ( int minMatch )  {
 //    Use of Bactrack(..) and Ullman() is completely
 //  equivalent. One of them should be commented.
 int n1;
@@ -491,7 +492,7 @@ int n1;
 }
 
 
-int  CSSGraphMatch::Initialize()  {
+int  ssm::GraphMatch::Initialize()  {
 ivector jF1;
 int     i,j,iW,pl;
 
@@ -536,7 +537,7 @@ int     i,j,iW,pl;
 }
 
 
-void  CSSGraphMatch::Backtrack ( int i )  {
+void  ssm::GraphMatch::Backtrack ( int i )  {
 //   Recursive version of Ullman's algorithm for full
 // (structure-to-structure or structure-to-substructure)
 // match.
@@ -591,7 +592,7 @@ ivector c1i,c2j, p1,p2;
 }
 
 
-void  CSSGraphMatch::Backtrack1 ( int i, int k0 )  {
+void  ssm::GraphMatch::Backtrack1 ( int i, int k0 )  {
 //   Recursive version of CSIA algorithm for partial
 // (substructure-to-substructure) match.
 int     pl0,i1,cntj,j,pl1,pl2,k,cntl,l,c1ik,iW,ii, k1;
@@ -727,11 +728,11 @@ ivector jF1,c1i,c2j, p0,p1,p2;
 }
 
 
-void  CSSGraphMatch::CollectMatch ( int nm )  {
-PCSSMatch  M;
-PPCSSMatch M1;
-int        i,j,k;
-Boolean    B;
+void  ssm::GraphMatch::CollectMatch ( int nm )  {
+PMatch  M;
+PPMatch M1;
+int     i,j,k;
+Boolean B;
 
   // Find out if this should be a new match. The present code
   // works such that all stored matches have the same length
@@ -746,13 +747,13 @@ Boolean    B;
         k = nm-1;
         i = 0;
         while (i<nMatches)  {
-          if (Match[i]->mlength<k)  {
-            // Match[i] is unlikely to become the best one, remove it
-            M = Match[i];
+          if (match[i]->mlength<k)  {
+            // match[i] is unlikely to become the best one, remove it
+            M = match[i];
             for (j=i+1;j<nMatches;j++)
-              Match[j-1] = Match[j];
+              match[j-1] = match[j];
             nMatches--;
-            Match[nMatches] = M;
+            match[nMatches] = M;
           } else
             i++;
         }
@@ -763,25 +764,25 @@ Boolean    B;
       i = 0;
       k = 0;
       while ((i<nMatches) && (k>=0))  {
-        k = Match[i]->isSubMatch ( F1,F2,nm );
+        k = match[i]->isSubMatch ( F1,F2,nm );
         if (k>0)  {
-          // Match[i] is a submatch of (F1,F2). Remove Match[i].
-          M = Match[i];
+          // match[i] is a submatch of (F1,F2). Remove match[i].
+          M = match[i];
           for (j=i+1;j<nMatches;j++)
-            Match[j-1] = Match[j];
+            match[j-1] = match[j];
           nMatches--;
-          Match[nMatches] = M;
+          match[nMatches] = M;
         } else
           i++;
       }
-      if (k<0)  // (F1,F2) is a submatch of Match[i-1]. Quit.
+      if (k<0)  // (F1,F2) is a submatch of match[i-1]. Quit.
         return;
     }
     if (UniqueMatch)  {
       // check if such a match was already found
       k = 0;
       for (i=0;(i<nMatches) && (k>=0);i++)
-        k = Match[i]->isSubMatch(F1,F2,nm);
+        k = match[i]->isSubMatch(F1,F2,nm);
       if (k<0)  return;  // repeating match -- just quit.
     }
   }
@@ -793,35 +794,35 @@ Boolean    B;
       B    = False;
     }
     j = 0;
-    k = Match[0]->mlength;
+    k = match[0]->mlength;
     for (i=1;i<nMatches;i++)
-      if (Match[i]->mlength<k)  {
-        k = Match[i]->mlength;
+      if (match[i]->mlength<k)  {
+        k = match[i]->mlength;
         j = i;
       }
     if (k<nm)  {
       nMatches--;
-      M = Match[j];
-      Match[j] = Match[nMatches];
-      Match[nMatches] = M;
+      M = match[j];
+      match[j] = match[nMatches];
+      match[nMatches] = M;
     } else
       B = False;
   } else if (nMatches>=nMAlloc)  {
     nMAlloc += 100;
-    M1 = new PCSSMatch[nMAlloc];
+    M1 = new PMatch[nMAlloc];
     for (i=0;i<nMatches;i++)
-      M1[i] = Match[i];
+      M1[i] = match[i];
     for (i=nMatches;i<nMAlloc;i++)
       M1[i] = NULL;
-    if (Match)  delete[] Match;
-    Match = M1;
+    if (match)  delete[] match;
+    match = M1;
   }
 
   if (B)  {
 
-    if (!Match[nMatches])
-          Match[nMatches] = new CSSMatch ( F1,F2,nm,n,m );
-    else  Match[nMatches]->SetMatch ( F1,F2,nm,n,m );
+    if (!match[nMatches])
+          match[nMatches] = new ssm::Match ( F1,F2,nm,n,m );
+    else  match[nMatches]->SetMatch ( F1,F2,nm,n,m );
 
     if (nm>maxCollectedMatch)  maxCollectedMatch = nm;
 
@@ -834,19 +835,56 @@ Boolean    B;
 }
 
 
-void CSSGraphMatch::GetMatches ( PPCSSMatch & SSMatch, int & nOfMatches ) {
-  SSMatch    = Match;
+void ssm::GraphMatch::GetMatches ( PPMatch & SSMatch, int & nOfMatches ) {
+  SSMatch    = match;
   nOfMatches = nMatches;
 }
 
-int  CSSGraphMatch::CheckConnectivity ( int matchNo )  {
+
+int ssm::GraphMatch::GetNofMatches ( realtype p1, realtype p2 )  {
+realtype pp1,pp2;
+ivector  FV1,FV2;
+int      i,n,nm;
+  if ((p1==0.0) && (p2==0.0))
+    n = nMatches;
+  else  {
+    n = 0;
+    for (i=0;i<nMatches;i++)  {
+      match[i]->GetMatch ( FV1,FV2,nm,pp1,pp2 );
+      if ((pp1>=p1) && (pp2>=p2))  n++;
+    }
+  }
+  return n;
+}
+
+void ssm::GraphMatch::GetMatch ( int   matchNo, int & matchLen,
+                               ivector  & F1, ivector  & F2,
+                               realtype & p1, realtype & p2 )  {
+  if ((matchNo<0) && (matchNo>=nMatches))  {
+    matchLen = -1;
+    F1       = NULL;
+    F2       = NULL;
+    p1       = -1.0;
+    p2       = -1.0;
+  } else if (!match[matchNo]) {
+    matchLen = -2;
+    F1       = NULL;
+    F2       = NULL;
+    p1       = -2.0;
+    p2       = -2.0;
+  } else
+    match[matchNo]->GetMatch ( F1,F2,matchLen,p1,p2 );
+}
+
+
+int  ssm::GraphMatch::CheckConnectivity ( int matchNo )  {
 ivector  v1,v2;
 realtype p1,p2;
 int      mlength, i,j, conn;
   if ((0<=matchNo) && (matchNo<nMatches))  {
     // we don't need a swap here as we reference to already swapped
     // G1 and G2 anyway
-    Match[matchNo]->GetMatch ( v1,v2,mlength,p1,p2 );
+    match[matchNo]->GetMatch ( v1,v2,mlength,p1,p2 );
     conn = 0;
     for (i=1;i<mlength;i++)
       for (j=i+1;j<=mlength;j++)
@@ -859,7 +897,7 @@ int      mlength, i,j, conn;
   return -1;
 }
 
-void  CSSGraphMatch::write ( RCFile f )  {
+void  ssm::GraphMatch::write ( RCFile f )  {
 int i;
 int Version=1;
   f.WriteInt  ( &Version     );
@@ -867,11 +905,11 @@ int Version=1;
   f.WriteBool ( &UniqueMatch );
   f.WriteBool ( &swap        );
   for (i=0;i<nMatches;i++)
-    Match[i]->write ( f );
+    match[i]->write ( f );
   f.WriteWord ( &flags       );
 }
 
-void  CSSGraphMatch::read ( RCFile f )  {
+void  ssm::GraphMatch::read ( RCFile f )  {
 int i,Version;
   FreeMemory ();
   f.ReadInt  ( &Version      );
@@ -879,16 +917,16 @@ int i,Version;
   f.ReadBool ( &UniqueMatch  );
   f.ReadBool ( &swap         );
   if (nMatches>0)  {
-    Match = new PCSSMatch[nMatches];
+    match = new PMatch[nMatches];
     for (i=0;i<nMatches;i++)  {
-      Match[i] = new CSSMatch();
-      Match[i]->read ( f );
+      match[i] = new Match();
+      match[i]->read ( f );
     }
   }
   f.ReadWord ( &flags       );
 }
 
-
-MakeStreamFunctions(CSSGraphMatch)
-
+namespace ssm {
+  MakeStreamFunctions(GraphMatch)
+}
 
diff --git a/ssm_csia.h b/ssm_csia.h
new file mode 100644
index 0000000..ece8f12
--- /dev/null
+++ b/ssm_csia.h
@@ -0,0 +1,162 @@
+// $Id: ssm_csia.h,v 1.1.1.1 2004/11/23 16:24:37 keb Exp $
+// =================================================================
+//
+//    05.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// -----------------------------------------------------------------
+//
+//  **** Module  :  ssm_csia       <interface>
+//       ~~~~~~~~~
+//  **** Classes :  ssm::GraphMatch ( matching SS graphs )
+//       ~~~~~~~~~
+//
+//  E. Krissinel 2001-2013
+//
+//  When used, please cite:
+//
+//   Krissinel, E. and Henrick, K. (2004)
+//   Common subgraph isomorphism detection by backtracking search.
+//   Software - Practice and Experience, 34, 591-607.
+//
+// =================================================================
+//
+
+#ifndef  __SSM_CSIA__
+#define  __SSM_CSIA__
+
+#include "ssm_graph.h"
+
+namespace ssm  {
+
+  //  =========================  Match  ===========================
+
+  DefineClass(Match);
+
+  class Match : public CStream  {
+
+    friend class GraphMatch;
+
+    public :
+
+      Match ();
+      Match ( RPCStream Object );
+      Match ( ivector FV1, ivector FV2, int nv, int n, int m );
+      ~Match();
+
+      void SetMatch ( ivector FV1, ivector FV2,
+                      int nv, int n, int m );   // FV1[], FV2[] are copied
+
+      void    Swap();
+
+      Boolean isMatch ( ivector FV1, ivector FV2, int nv );
+
+      int  isSubMatch ( ivector FV1, ivector FV2, int nv );
+      // return 0 <=> no submatch relations
+      //        1 <=> "this" is submatch of (FV1,FV2)
+      //       -1 <=> (FV1,FV2) is submatch of "this"
+
+      void GetMatch ( ivector  & FV1,  // do not allocate or
+                      ivector  & FV2,  // dispose FV1 and FV2 in
+                      int      & nv ); // application!
+
+      void GetMatch ( ivector  & FV1, // do not allocate or
+                      ivector  & FV2, // dispose FV1 and FV2 in
+                      int      & nv,  // application!
+                      realtype & p1,
+                      realtype & p2 );
+
+      void read  ( RCFile f );
+      void write ( RCFile f );
+
+    protected :
+      int     mlength,n1,n2;
+      ivector F1,F2;
+
+      void InitMatch();
+
+    private :
+      int nAlloc;
+
+  };
+
+  DefineStreamFunctions(Match)
+
+  //  =========================  GraphMatch  ===========================
+
+
+  DefineClass(GraphMatch);
+
+  class GraphMatch : public CStream  {
+
+    public :
+
+      GraphMatch ();
+      GraphMatch ( RPCStream Object );
+      ~GraphMatch();
+
+      void  SetUniqueMatch ( Boolean unique_match );
+      void  SetBestMatch   ( Boolean best_match   );
+      void  SetMatchBufferLength ( int matchBufLen );
+      void  SetFlags       ( word Flags );
+      void  RemoveFlags    ( word Flags );
+
+      void  MatchGraphs    ( PGraph Gh1, PGraph Gh2, int minMatch );
+
+      PGraph  GetGraph1 ();
+      PGraph  GetGraph2 ();
+      void  GetMatches     ( PPMatch & SSMatch, int & nOfMatches );
+      void  GetMatch       ( int   matchNo, int & matchLen,
+                             ivector  & F1, ivector  & F2,
+                             realtype & p1, realtype & p2 );
+      inline int GetMaxRecursionLevel()  { return maxRecursionLevel; }
+      inline int GetNofMatches       ()  { return nMatches;          }
+      int   GetNofMatches     ( realtype p1, realtype p2 );
+
+      int   CheckConnectivity ( int matchNo );
+
+      void  read  ( RCFile f );
+      void  write ( RCFile f );
+
+    protected :
+
+      PGraph    G1,G2;
+      PPVertex  V1;
+      PPVertex  V2;
+      PPEdge    E1;
+      PPEdge    E2;
+      imatrix   c1,c2;
+      Boolean   swap;
+      word      flags;
+      int       n,m;
+
+      imatrix3  P;
+      imatrix   iF1;
+      ivector   F1,F2,ix;
+
+      int       nMatches,maxNofMatches;
+      PPMatch   match;
+      Boolean   UniqueMatch,BestMatch,wasFullMatch,Stop;
+      int       maxMatch,maxCollectedMatch,maxRecursionLevel;
+
+      void  InitGraphMatch   ();
+      void  FreeMemory       ();
+      void  FreeRecHeap      ();
+      void  GetMemory        ();
+      void  GetRecHeap       ();
+      int   Initialize       ();
+      void  DoMatch          ( int minMatch );
+      void  MatchSingleVertex();
+      void  Backtrack        ( int i );
+      void  Backtrack1       ( int i, int k0 );
+      void  CollectMatch     ( int nm );
+
+    private :
+      int nAlloc,mAlloc,nMAlloc;
+
+  };
+
+  DefineStreamFunctions(GraphMatch)
+
+}
+
+#endif
diff --git a/ssm_defs.h b/ssm_defs.h
new file mode 100644
index 0000000..45ffe12
--- /dev/null
+++ b/ssm_defs.h
@@ -0,0 +1,89 @@
+// $Id: ssm_defs.h,v 1.2 2005/12/20 12:09:14 keb Exp $
+// =================================================================
+//
+//    30.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// -----------------------------------------------------------------
+//
+//  **** Module  :  ssm_defs  <interface>
+//       ~~~~~~~~~
+//
+//  E. Krissinel 2002-2013
+//
+// =================================================================
+//
+
+
+#ifndef __SSM_Defs__
+#define __SSM_Defs__
+
+#define SSM_MAJOR_VERSION    (1)
+#define SSM_MINOR_VERSION    (3)
+#define SSM_MICRO_VERSION    (0)
+
+#define SSM_DATE             "30-04-2013"
+
+namespace ssm  {
+
+  #define SSGP_Distance   0
+  #define SSGP_Alpha1     1
+  #define SSGP_Alpha2     2
+  #define SSGP_Alpha3     3
+  #define SSGP_Alpha4     4
+  #define SSGP_dAlpha1    5
+  #define SSGP_dAlpha2    6
+  #define SSGP_dAlpha3    7
+  #define SSGP_dAlpha4    8
+
+  #define SSGE_Ok                     0
+  #define SSGE_NoVertices             70
+  #define SSGE_UnmatchedConnectivity  5001
+  #define SSGE_AlignError             5002
+  #define SSGE_WrongSelLine1          5003
+  #define SSGE_WrongSelLine2          5004
+  #define SSGE_WrongSelLine3          5005
+
+  #define SSGT_None       0
+  #define SSGT_PDB        1
+  #define SSGT_SCOP       2
+  #define SSGT_PDBDOMAIN  3
+  #define SSGT_PDBRANGE   4
+  #define SSGT_CFDOMAIN   5
+  #define SSGT_CFRANGE    6
+
+  #define SSMF_UniqueMatch       0x00000001
+  #define SSMF_BestMatch         0x00000002
+  #define SSMF_WrongConnectOnly  0x00000004
+
+  #define MALIGN_Ok             0
+  #define MALIGN_BadInput       1
+  #define MALIGN_NoStructure    2
+  #define MALIGN_NoAlignment    3
+  #define MALIGN_NoGraph     1000
+
+  #define UNMAP_YES          (-2)
+  #define UNMAP_NO           (-1)
+
+  enum SUPERPOSITION_RESULT {
+    SPOSE_Ok,SPOSE_BadData,SPOSE_NoCalphas1,SPOSE_NoCalphas2,
+    SPOSE_RemoteStruct,SPOSE_SVDFail
+  };
+
+  enum RETURN_CODE {
+    RC_Ok,RC_NoHits,RC_NoSuperposition,RC_NoGraph,RC_NoVertices,
+    RC_NoGraph2,RC_NoVertices2,RC_TooFewMatches
+  };
+
+  //  precision level conatsnts
+  enum PRECISION { PREC_Highest,PREC_High,PREC_Normal,
+                   PREC_Low,PREC_Lowest };
+
+  //  regimes of checking the SS connectivity
+  enum CONNECTIVITY { CONNECT_None,CONNECT_Flexible,CONNECT_Strict };
+
+  enum VERTEX_TYPE { V_UNKNOWN=-1,V_HELIX,V_STRAND };
+
+}
+
+
+#endif
diff --git a/ss_graph.cpp b/ssm_graph.cpp
similarity index 50%
rename from ss_graph.cpp
rename to ssm_graph.cpp
index a2ee512..bca3315 100644
--- a/ss_graph.cpp
+++ b/ssm_graph.cpp
@@ -1,16 +1,16 @@
-// $Id: ss_graph.cpp,v 1.5 2011/11/21 16:56:16 ekr Exp $
+// $Id: ssm_graph.cpp,v 1.2 2008/07/08 15:51:03 keb Exp $
 // =================================================================
 //
-//    29.04.04   <--  Date of Last Modification.
+//   10.04.13   <--  Date of Last Modification.
 //                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // -----------------------------------------------------------------
 //
-//  **** Module  :  ss_graph  <implementation>
+//  **** Module  :  ssm_graph  <implementation>
+//       ~~~~~~~~~
+//  **** Classes :  ssm::Graph  ( secondary structure graph )
 //       ~~~~~~~~~
-//  **** Classes :  CSSGraph  ( secondary structure graph )
-//       ~~~~~~~~~  
 //
-//  (C) E. Krissinel 2002-2004
+//  (C) E. Krissinel 2002-2013
 //
 // =================================================================
 //
@@ -18,31 +18,31 @@
 
 #include <string.h>
 
-#include "ss_graph.h"
+#include "ssm_graph.h"
 #include "mmdb/linalg_.h"
 
 
-//  ==========================  CSSGraph  ===========================
+//  ==========================  ssm::Graph  ===========================
 
-CSSGraph::CSSGraph() : CStream()  {
-  InitSSGraph();
+ssm::Graph::Graph() : CStream()  {
+  InitGraph();
 }
 
-CSSGraph::CSSGraph ( RPCStream Object ) : CStream(Object)  {
-  InitSSGraph();
+ssm::Graph::Graph ( RPCStream Object ) : CStream(Object)  {
+  InitGraph();
 }
 
-CSSGraph::~CSSGraph() {
+ssm::Graph::~Graph() {
   FreeMemory();
 }
 
-void  CSSGraph::InitSSGraph()  {
+void  ssm::Graph::InitGraph()  {
 
   name = NULL;
   CreateCopy ( name,"" );
 
-  Vertex    = NULL;
-  Edge      = NULL;
+  V         = NULL;
+  E         = NULL;
   graph     = NULL;
   nVertices = 0;
   nEdges    = 0;
@@ -58,7 +58,7 @@ void  CSSGraph::InitSSGraph()  {
 
 }
 
-void  CSSGraph::FreeMemory()  {
+void  ssm::Graph::FreeMemory()  {
 int i;
 
   if (name)  {
@@ -66,11 +66,11 @@ int i;
     name = NULL;
   }
 
-  if (Vertex)  {
+  if (V)  {
     for (i=0;i<nVAlloc;i++)
-      if (Vertex[i])  delete Vertex[i];
-    delete[] Vertex;
-    Vertex = NULL;
+      if (V[i])  delete V[i];
+    delete[] V;
+    V = NULL;
   }
   nVertices = 0;
   nVAlloc   = 0;
@@ -79,75 +79,78 @@ int i;
 
 }
 
-void  CSSGraph::SetGraphName ( pstr gname )  {
+void  ssm::Graph::SetGraphName ( cpstr gname )  {
   CreateCopy ( name,gname );
 }
 
 
-int  SelectDomain ( PCMMDBManager MMDB, int & selHnd, pstr select,
-                    int selType )  {
-// select is of the following format:
-//    "*", "(all)"            - take all file
-//    "-"                     - take chain without chain ID
-//    "a:Ni-Mj,b:Kp-Lq,..."   - take chain a residue number N
-//                              insertion code i to residue number M
-//                              insertion code j plus chain b
-//                              residue number K insertion code p to
-//                              residue number L insertion code q and
-//                              so on.
-//    "a:,b:..."              - take whole chains a and b and so on
-//    "a:,b:Kp-Lq,..."        - any combination of the above.
-int rc;
-
-  selHnd = MMDB->NewSelection();
-  rc = MMDB->SelectDomain ( selHnd,select,selType,SKEY_NEW,1 );
-  if ((!rc) && (selType==STYPE_ATOM))  {
-    // only C-alphas are needed
-    MMDB->Select ( selHnd,selType,1,"*",ANY_RES,"*",ANY_RES,"*",
-                         "*","[ CA ]","*","*",SKEY_AND );
-  }
-
-  return rc;
-
-}
+namespace ssm  {
+
+  int  SelectDomain ( PCMMDBManager MMDB, int & selHnd, cpstr select,
+                      int selType )  {
+  // select is of the following format:
+  //    "*", "(all)"            - take all file
+  //    "-"                     - take chain without chain ID
+  //    "a:Ni-Mj,b:Kp-Lq,..."   - take chain a residue number N
+  //                              insertion code i to residue number M
+  //                              insertion code j plus chain b
+  //                              residue number K insertion code p to
+  //                              residue number L insertion code q and
+  //                              so on.
+  //    "a:,b:..."              - take whole chains a and b and so on
+  //    "a:,b:Kp-Lq,..."        - any combination of the above.
+  int rc;
+
+    selHnd = MMDB->NewSelection();
+    rc = MMDB->SelectDomain ( selHnd,select,selType,SKEY_NEW,1 );
+    if ((!rc) && (selType==STYPE_ATOM))  {
+      // only C-alphas are needed
+      MMDB->Select ( selHnd,selType,MMDB->GetFirstModelNum(),
+                     "*",ANY_RES,"*",ANY_RES,"*",
+                     "*","[ CA ]","*","*",SKEY_AND );
+    }
 
+    return rc;
 
-int CutOutDomain ( PCMMDBManager MMDB, pstr select )  {
-// select is of the following format:
-//    "*", "(all)"            - take all file
-//    "-"                     - chain without chain ID
-//    "a:Ni-Mj,b:Kp-Lq,..."   - take chain a residue number N
-//                              insertion code i to residue number M
-//                              insertion code j plus chain b
-//                              residue number K insertion code p to
-//                              residue number L insertion code q and
-//                              so on.
-//    "a:,b:..."              - take whole chains a and b and so on
-//    "a:,b:Kp-Lq,..."        - any combination of the above.
-int selHnd,rc;
+  }
 
-  if (!select)   return 0;
-  if ((!select[0]) || (select[0]=='*'))  return 0;
-  else if (!strcasecmp(select,"(all)"))  return 0;
+  int CutOutDomain ( PCMMDBManager MMDB, cpstr select )  {
+  // select is of the following format:
+  //    "*", "(all)"            - take all file
+  //    "-"                     - chain without chain ID
+  //    "a:Ni-Mj,b:Kp-Lq,..."   - take chain a residue number N
+  //                              insertion code i to residue number M
+  //                              insertion code j plus chain b
+  //                              residue number K insertion code p to
+  //                              residue number L insertion code q and
+  //                              so on.
+  //    "a:,b:..."              - take whole chains a and b and so on
+  //    "a:,b:Kp-Lq,..."        - any combination of the above.
+  int selHnd,rc;
+
+    if (!select)   return 0;
+    if ((!select[0]) || (select[0]=='*'))  return 0;
+    else if (!strcasecmp(select,"(all)"))  return 0;
+
+    rc = SelectDomain ( MMDB,selHnd,select,STYPE_RESIDUE );
+
+    if (!rc)  {
+      MMDB->Select ( selHnd,STYPE_RESIDUE,0,"*",
+                     ANY_RES,"*",ANY_RES,"*",
+                     "*","*","*","*",SKEY_XOR );
+      MMDB->DeleteSelObjects ( selHnd );
+      MMDB->FinishStructEdit ();
+      MMDB->DeleteSelection  ( selHnd );
+    }
 
-  rc = SelectDomain ( MMDB,selHnd,select,STYPE_RESIDUE );
+    return rc;
 
-  if (!rc)  {
-    MMDB->Select ( selHnd,STYPE_RESIDUE,0,"*",
-                   ANY_RES,"*",ANY_RES,"*",
-                   "*","*","*","*",SKEY_XOR );
-    MMDB->DeleteSelObjects ( selHnd );
-    MMDB->FinishStructEdit ();
-    MMDB->DeleteSelection  ( selHnd );
   }
 
-  return rc;
-
 }
 
-
-void  CSSGraph::SelectCalphas ( PCMMDBManager MMDB, int & selHnd,
-                                pstr selstring )  {
+void  ssm::Graph::SelectCalphas ( PCMMDBManager MMDB, int & selHnd,
+                                  cpstr selstring )  {
 PChainID chain;
 PPCAtom  A;
 ChainID  chID;
@@ -244,24 +247,24 @@ Boolean  B;
 
 }
 
-Boolean CSSGraph::inRange ( pstr chainID, int initPos, int endPos )  {
+Boolean ssm::Graph::inRange ( cpstr chainID, int initPos, int endPos )  {
 int i;
   for (i=0;i<nVertices;i++)
-    if (Vertex[i]->inRange(chainID,initPos,endPos))  return True;
+    if (V[i]->inRange(chainID,initPos,endPos))  return True;
   return False;
 }
 
-pstr  CSSGraph::GetChainList ( pstr S )  {
+pstr  ssm::Graph::GetChainList ( pstr S )  {
 //  returns comma-separated list of chains in graph's vertices
 char N[100];
 int  i;
   if (nVertices>0)  {
-    if (!Vertex[0]->chainID[0])  strcpy ( S,"''" );
-                           else  strcpy ( S,Vertex[0]->chainID );
+    if (!V[0]->chainID[0])  strcpy ( S,"''" );
+                      else  strcpy ( S,V[0]->chainID );
     strcat ( S,"," );
     for (i=1;i<nVertices;i++)  {
-      if (!Vertex[i]->chainID[0])  strcpy ( N,"''" );
-                             else  strcpy ( N,Vertex[i]->chainID );
+      if (!V[i]->chainID[0])  strcpy ( N,"''" );
+                        else  strcpy ( N,V[i]->chainID );
       strcat ( N,"," );
       if (!strstr(S,N))  strcat ( S,N );
     }
@@ -272,56 +275,58 @@ int  i;
   return S;
 }
 
-void  CSSGraph::Reset()  {
+void  ssm::Graph::Reset()  {
   FreeMemory();
 }
 
-void  CSSGraph::AddVertex ( PCSSVertex V )  {
-int         i,nV1;
-PPCSSVertex V1;
+void  ssm::Graph::AddVertex ( PVertex Vx )  {
+int      i,nV1;
+PPVertex V1;
   if (nVertices>=nVAlloc)  {
     nV1 = nVertices + 20;
-    V1  = new PCSSVertex[nV1];
+    V1  = new PVertex[nV1];
     for (i=0;i<nVAlloc;i++)
-      V1[i] = Vertex[i];
+      V1[i] = V[i];
     for (i=nVAlloc;i<nV1;i++)
       V1[i] = NULL;
-    if (Vertex)  delete[] Vertex;
-    Vertex  = V1;
+    if (V)  delete[] V;
+    V       = V1;
     nVAlloc = nV1;
   }
-  Vertex[nVertices++] = V;
+  V[nVertices++] = Vx;
 }
 
-int  CSSGraph::GetSSEType ( pstr chainID, int atomPos )  {
+ssm::VERTEX_TYPE ssm::Graph::GetSSEType ( pstr chainID, int atomPos )  {
 //  Returns SSE type (V_HELIX or V_STRAND) for atom at atomPos
 //  sequence position (0.. on ).
-int  i,sse;
+int         i;
+VERTEX_TYPE sse;
   sse = V_UNKNOWN;
   for (i=0;i<nVertices;i++)
-    if ((!strcmp(Vertex[i]->chainID,chainID)) &&
-        (Vertex[i]->initPos<=atomPos)         &&
-        (atomPos<=Vertex[i]->endPos))  {
-      sse = Vertex[i]->type;
+    if ((!strcmp(V[i]->chainID,chainID)) &&
+        (V[i]->initPos<=atomPos)         &&
+        (atomPos<=V[i]->endPos))  {
+      sse = V[i]->type;
       break;
     }
   return sse;
 }
 
-int  CSSGraph::GetSSEType ( PCAtom A )  {
+ssm::VERTEX_TYPE ssm::Graph::GetSSEType ( PCAtom A )  {
 //  Returns SSE type (V_HELIX or V_STRAND) for the atom
-pstr chID;
-int  i,sse,apos;
+pstr        chID;
+int         i,apos;
+VERTEX_TYPE sse;
   sse = V_UNKNOWN;
   if (A)  {
     chID = A->GetChainID();
     if (chID)  {
       apos = A->GetResidueNo();
       for (i=0;i<nVertices;i++)
-        if ((!strcmp(Vertex[i]->chainID,chID)) &&
-            (Vertex[i]->initPos<=apos)         &&
-            (apos<=Vertex[i]->endPos))  {
-          sse = Vertex[i]->type;
+        if ((!strcmp(V[i]->chainID,chID)) &&
+            (V[i]->initPos<=apos)         &&
+            (apos<=V[i]->endPos))  {
+          sse = V[i]->type;
           break;
         }
     }
@@ -329,18 +334,24 @@ int  i,sse,apos;
   return sse;
 }
 
-int  CSSGraph::MakeGraph ( PCMMDBManager MMDB )  {
-PPCResidue res;
-PCSSVertex vertex;
-int        rc,nresidues,i,j,k,vtype;
+int  ssm::Graph::MakeGraph ( PCMMDBManager MMDB )  {
+PCModel     model;
+PPCResidue  res;
+PVertex     vertex;
+int         rc,nresidues,i,j,k;
+VERTEX_TYPE vtype;
 
   FreeMemory();
 
-  rc = MMDB->GetModel(1)->CalcSecStructure ( True );
+  model = MMDB->GetModel(MMDB->GetFirstModelNum());
+  if (!model)  return SSERC_noResidues;
+
+  rc = model->CalcSecStructure ( True );
   if (rc!=SSERC_Ok)  return rc;
 
   res = NULL;
-  MMDB->GetResidueTable ( res,nresidues );
+// #### was   MMDB->GetResidueTable ( res,nresidues );
+  model->GetResidueTable ( res,nresidues );
 
   i = 0;
   k = 0;
@@ -355,7 +366,7 @@ int        rc,nresidues,i,j,k,vtype;
       if (res[j]->SSE==SSE_Strand)  vtype = V_STRAND;
                               else  vtype = V_HELIX;
       k++;
-      vertex = new CSSVertex();
+      vertex = new ssm::Vertex();
       if (vertex->SetVertex(MMDB,vtype,k,1,res[j]->GetChainID(),
                     res[j  ]->GetSeqNum(),res[j  ]->GetInsCode(),
                     res[i-1]->GetSeqNum(),res[i-1]->GetInsCode()))  {
@@ -377,29 +388,29 @@ int        rc,nresidues,i,j,k,vtype;
 }
 
 
-void  CSSGraph::CalcVertexOrder()  {
+void  ssm::Graph::CalcVertexOrder()  {
 int     i,i0,VNo;
 Boolean Done;
 
   for (i=0;i<nVertices;i++)
-    Vertex[i]->VNo = 0;
+    V[i]->VNo = 0;
 
   do  {
     i0 = 0;
     while (i0<nVertices)
-      if (Vertex[i0]->VNo==0)  break;
-                         else  i0++;
+      if (V[i0]->VNo==0)  break;
+                    else  i0++;
     Done = (i0>=nVertices);
     if (!Done)  {
       VNo  = 0;
       for (i=0;i<nVertices;i++)
-        if (!strcmp(Vertex[i]->chainID,Vertex[i0]->chainID))  {
-          if (Vertex[i]->VNo>VNo)  VNo = Vertex[i]->VNo;
-          if ((Vertex[i]->VNo==0) &&
-              (Vertex[i]->endPos<=Vertex[i0]->initPos))
+        if (!strcmp(V[i]->chainID,V[i0]->chainID))  {
+          if (V[i]->VNo>VNo)  VNo = V[i]->VNo;
+          if ((V[i]->VNo==0) &&
+              (V[i]->endPos<=V[i0]->initPos))
             i0 = i;
         }
-      Vertex[i0]->VNo = VNo + 1;
+      V[i0]->VNo = VNo + 1;
     }
   } while (!Done);
 
@@ -410,44 +421,44 @@ Boolean Done;
 #define  VXREP_DEV1  (Pi/9.0)
 #define  VXREP_DEV2  (Pi/3.0)
 
-void  CSSGraph::RepairSS ( PCMMDBManager MMDB )  {
+void  ssm::Graph::RepairSS ( PCMMDBManager MMDB )  {
 // Reunites strands and helices separated by just a few
 // residues if there are indications that that could
 // be a single strand or helix.
-PPCSSVertex Vx;
-ChainID     chID;
-realtype    adev1,adev2, vx,vy,vz;
-int         i,j,k,j0,k0,k1,iPos;
-Boolean     B;
+PPVertex Vx;
+ChainID  chID;
+realtype adev1,adev2, vx,vy,vz;
+int      i,j,k,j0,k0,k1,iPos;
+Boolean  B;
 
   if (nVertices<=1)  return;
 
   adev1 = VXREP_DEV1;
   adev2 = VXREP_DEV2;
 
-  Vx = new PCSSVertex[nVAlloc];
+  Vx = new PVertex[nVAlloc];
   k  = 0;
 
   for (i=0;i<nVertices;i++)
-    if (Vertex[i])  {
+    if (V[i])  {
       k0 = k;  // starting vertex for the chain
-      strcpy ( chID,Vertex[i]->chainID );
+      strcpy ( chID,V[i]->chainID );
       // Put all vertices of this chain into order
       // of increasing their position in the chain
       do  {
         j0   = -1;
         iPos = MaxInt;
         for (j=i;j<nVertices;j++)
-          if (Vertex[j])  {
-            if ((!strcmp(chID,Vertex[j]->chainID)) &&
-                (Vertex[j]->initPos<=iPos))  {
-              iPos = Vertex[j]->initPos;
+          if (V[j])  {
+            if ((!strcmp(chID,V[j]->chainID)) &&
+                (V[j]->initPos<=iPos))  {
+              iPos = V[j]->initPos;
               j0   = j;
             }
           }
         if (j0>=0)  {
-          Vx[k++]    = Vertex[j0];
-          Vertex[j0] = NULL;
+          Vx[k++]    = V[j0];
+          V[j0] = NULL;
         }
       } while (j0>=0);
       // Check pairs of neighbouring vertices for gaps
@@ -489,17 +500,17 @@ Boolean     B;
       }
     }
 
-  delete[] Vertex;
+  delete[] V;
 
   nVertices = k;
   while (k<nVAlloc)
     Vx[k++] = NULL;
 
-  Vertex = Vx;
+  V = Vx;
 
 }
 
-void  CSSGraph::BuildGraph()  {
+void  ssm::Graph::BuildGraph()  {
 int i,j;
 
   ReleaseEdges   ();
@@ -516,8 +527,8 @@ int i,j;
     //   Connect all vertices with edges. The following
     // is unsophisticated, but simple and reliable:
     for (i=1;i<=nVertices;i++)  {
-      Vertex[i-1]->id = i;
-      if (Vertex[i-1]->type==V_HELIX)  nHelices++;
+      V[i-1]->id = i;
+      if (V[i-1]->type==V_HELIX)  nHelices++;
                                  else  nStrands++;
       graph[i][i] = -1;
       for (j=i+1;j<=nVertices;j++)  {
@@ -528,58 +539,58 @@ int i,j;
 
     if (nEdges>0)  {
       nEAlloc = nEdges;
-      Edge    = new PCSSEdge[nEAlloc];
+      E       = new PEdge[nEAlloc];
       nEdges  = 0;
       for (i=1;i<=nVertices;i++)
         for (j=i+1;j<=nVertices;j++)  {
-          Edge[nEdges] = new CSSEdge();
-          Edge[nEdges]->SetEdge ( Vertex[i-1],Vertex[j-1] );
+          E[nEdges] = new ssm::Edge();
+          E[nEdges]->SetEdge ( V[i-1],V[j-1] );
           nEdges++;
         }
       if (nEdges!=nEAlloc)
-        printf ( "\n #### PROGRAM ERROR IN CSSGraph::BuildGraph()\n" );
+        printf ( "\n #### PROGRAM ERROR IN ssm::Graph::BuildGraph()\n" );
     }
 
   }
 
 }
 
-Boolean CSSGraph::isBuild()  {
+Boolean ssm::Graph::isBuild()  {
   if (!graph)  return False;
-  if (!Edge)   return False;
+  if (!E)      return False;
   return True;
 }
 
 
-void  CSSGraph::calcVTypes() {
+void  ssm::Graph::calcVTypes() {
 int i;
   nHelices = 0;
   nStrands = 0;
   for (i=0;i<nVertices;i++)
-    if (Vertex[i]->type==V_HELIX)  nHelices++;
+    if (V[i]->type==V_HELIX)  nHelices++;
                              else  nStrands++;
 }
 
-void  CSSGraph::ReleaseEdges()  {
+void  ssm::Graph::ReleaseEdges()  {
 int i;
 
   FreeMatrixMemory ( graph,nGAlloc,1,1 );
   nGAlloc = 0;
 
   for (i=0;i<nEAlloc;i++)
-    if (Edge[i])  delete Edge[i];
-  if (Edge)  delete[] Edge;
-  Edge    = NULL;
+    if (E[i])  delete E[i];
+  if (E)  delete[] E;
+  E       = NULL;
   nEdges  = 0;
   nEAlloc = 0;
 
 }
 
-Boolean  CSSGraph::GetEdgeDirection ( int v1, int v2, vect3 & v )  {
+Boolean  ssm::Graph::GetEdgeDirection ( int v1, int v2, vect3 & v )  {
   if (graph)  {
     if ((1<=v1) && (v1<=nVertices) &&
         (1<=v2) && (v2<=nVertices) && (v1!=v2))  {
-      Edge[graph[v1][v2]]->GetDirection ( v );
+      E[graph[v1][v2]]->GetDirection ( v );
       if (v1>v2)  {
         v[0] = -v[0];
         v[1] = -v[1];
@@ -591,8 +602,8 @@ Boolean  CSSGraph::GetEdgeDirection ( int v1, int v2, vect3 & v )  {
   return False;
 }
 
-int  CSSGraph::CompareEdges ( int i, int j, PCSSGraph G,
-                              int k, int l )  {
+int  ssm::Graph::CompareEdges ( int i, int j, PGraph G,
+                                int k, int l )  {
 //   CompareEdges(..) compares edge (ij) of the graph with
 // edge (kl) of graph G. i may be either less or greater
 // than j, same about k and l. If edges compare, the function
@@ -605,50 +616,51 @@ int  CSSGraph::CompareEdges ( int i, int j, PCSSGraph G,
          else  return 7;
   } else if (k==l)
                return 7;
-  return  Edge[graph[i][j]]->Compare (
-                    (i>j),G->Edge[G->graph[k][l]],(k>l) );
+  return  E[graph[i][j]]->Compare (
+                    (i>j),G->E[G->graph[k][l]],(k>l) );
 }
 
-int  CSSGraph::CheckEdgeConnectivity ( int i, int j, PCSSGraph G,
-                                       int k, int l )  {
+int  ssm::Graph::CheckEdgeConnectivity ( int i, int j, PGraph G,
+                                         int k, int l )  {
   if (i==j)  return -1;
   if (k==l)  return -1;
-  return  Edge[graph[i][j]]->CheckConnectivity (
-                    (i>j),G->Edge[G->graph[k][l]],(k>l) );
+  return  E[graph[i][j]]->CheckConnectivity (
+                    (i>j),G->E[G->graph[k][l]],(k>l) );
 }
 
-void  CSSGraph::RemoveShortVertices ( int nmin_hx, int nmin_sd )  {
-PPCSSVertex V;
-int         i,n;
+void  ssm::Graph::RemoveShortVertices ( int nmin_hx, int nmin_sd )  {
+PPVertex Vx;
+int      i,n;
   n = 0;
   for (i=0;i<nVertices;i++)
-    if (Vertex[i])  {
-      if (((Vertex[i]->type==V_HELIX)  && (Vertex[i]->nres>nmin_hx)) ||
-          ((Vertex[i]->type==V_STRAND) && (Vertex[i]->nres>nmin_sd)))
+    if (V[i])  {
+      if (((V[i]->type==V_HELIX)  && (V[i]->nres>nmin_hx)) ||
+          ((V[i]->type==V_STRAND) && (V[i]->nres>nmin_sd)))
         n++;
     }
   if (n<nVertices)  {
     if (n>0)  {
-      V = new PCSSVertex[n];
-      n = 0;
+      Vx = new PVertex[n];
+      n  = 0;
       for (i=0;i<nVertices;i++)
-        if (Vertex[i])  {
-          if (((Vertex[i]->type==V_HELIX)  && (Vertex[i]->nres>nmin_hx)) ||
-              ((Vertex[i]->type==V_STRAND) && (Vertex[i]->nres>nmin_sd)))
-                V[n++] = Vertex[i];
-          else  delete Vertex[i];
+        if (V[i])  {
+          if (((V[i]->type==V_HELIX)  && (V[i]->nres>nmin_hx)) ||
+              ((V[i]->type==V_STRAND) && (V[i]->nres>nmin_sd)))
+                Vx[n++] = V[i];
+          else  delete V[i];
+          V[i] = NULL;
         }
       for (i=nVertices;i<nVAlloc;i++)
-        if (Vertex[i])  delete Vertex[i];
-      delete[] Vertex;
-      Vertex    = V;
+        if (V[i])  delete V[i];
+      delete[] V;
+      V         = Vx;
       nVertices = n;
       nVAlloc   = 0;
-    } else if (Vertex)  {
+    } else if (V)  {
       for (i=0;i<nVAlloc;i++)
-        if (Vertex[i])  delete Vertex[i];
-      delete[] Vertex;
-      Vertex    = NULL;
+        if (V[i])  delete V[i];
+      delete[] V;
+      V         = NULL;
       nVertices = 0;
       nVAlloc   = 0;
     }
@@ -657,7 +669,7 @@ int         i,n;
 }
 
 
-void  CSSGraph::LeaveVertices ( ivector vlist, int vllen )  {
+void  ssm::Graph::LeaveVertices ( ivector vlist, int vllen )  {
 int         i,j,n;
 Boolean     B;
   n = 0;
@@ -666,12 +678,12 @@ Boolean     B;
     for (j=1;(j<=vllen) && (!B);j++)
       B = (vlist[j]==i+1);
     if (!B)  {
-      if (Vertex[i])
-        delete Vertex[i];
-      Vertex[i] = NULL;
+      if (V[i])
+        delete V[i];
+      V[i] = NULL;
     } else if (n<i)  {
-      Vertex[n++] = Vertex[i];
-      Vertex[i]   = NULL;
+      V[n++] = V[i];
+      V[i]   = NULL;
     } else
       n++;
   }
@@ -679,7 +691,7 @@ Boolean     B;
 }
 
 
-void  CSSGraph::LeaveVertices ( pstr select, PCMMDBManager M )  {
+void  ssm::Graph::LeaveVertices ( cpstr select, PCMMDBManager M )  {
 // select is of the following format:
 //    "*", "(all)"            - take all file
 //    "-"                     - take chain without chain ID
@@ -692,13 +704,13 @@ void  CSSGraph::LeaveVertices ( pstr select, PCMMDBManager M )  {
 //    "a:,b:..."              - take whole chains a and b and so on
 //    "a:,b:Kp-Lq,..."        - any combination of the above.
 int  rc,selHnd1;
-  rc = SelectDomain ( M,selHnd1,select,STYPE_RESIDUE );
+  rc = ssm::SelectDomain ( M,selHnd1,select,STYPE_RESIDUE );
   if (!rc)  _leaveVertices ( M,selHnd1 );
   M->DeleteSelection ( selHnd1 );
 }
 
 
-void  CSSGraph::LeaveVertices ( int selHnd, PCMMDBManager M )  {
+void  ssm::Graph::LeaveVertices ( int selHnd, PCMMDBManager M )  {
 //  Leaves only vertices that are covered by the given selection.
 //  selHnd may refer to the selection of atoms, residues or chains.
 int  stype,selHnd1;
@@ -720,25 +732,26 @@ int  stype,selHnd1;
 }
 
 
-void  CSSGraph::_leaveVertices ( PCMMDBManager M, int selHnd1 )  {
-int  selHnd2, i,n;
+void  ssm::Graph::_leaveVertices ( PCMMDBManager M, int selHnd1 )  {
+int  selHnd2, i,mdl,n;
 
+  mdl = M->GetFirstModelNum();
   selHnd2 = M->NewSelection();
 
   n = 0;
   for (i=0;i<nVertices;i++)
-    if (Vertex[i])  {
-      M->Select ( selHnd2,STYPE_RESIDUE,1,Vertex[i]->chainID,
-                  Vertex[i]->initSeqNum,Vertex[i]->initICode,
-                  Vertex[i]->endSeqNum ,Vertex[i]->endICode ,
+    if (V[i])  {
+      M->Select ( selHnd2,STYPE_RESIDUE,mdl,V[i]->chainID,
+                  V[i]->initSeqNum,V[i]->initICode,
+                  V[i]->endSeqNum ,V[i]->endICode ,
                   "*","*","*","*",SKEY_NEW );
       M->Select ( selHnd2,STYPE_RESIDUE,selHnd1,SKEY_AND );
       if (M->GetSelLength(selHnd2)<=0)  {
-        delete Vertex[i];
-        Vertex[i] = NULL;
+        delete V[i];
+        V[i] = NULL;
       } else if (n<i)  {
-        Vertex[n++] = Vertex[i];
-        Vertex[i]   = NULL;
+        V[n++] = V[i];
+        V[i]   = NULL;
       } else
         n++;
     }
@@ -750,95 +763,95 @@ int  selHnd2, i,n;
 }
 
 
-void  CSSGraph::RemoveVertex ( int vertex_no )  {
+void  ssm::Graph::RemoveVertex ( int vertex_no )  {
 int  i;
   if ((0<vertex_no) && (vertex_no<=nVertices))  {
-    if (Vertex[vertex_no-1])  delete Vertex[vertex_no-1];
+    if (V[vertex_no-1])  delete V[vertex_no-1];
     for (i=vertex_no;i<nVertices;i++)
-      Vertex[i-1] = Vertex[i];
-    Vertex[nVertices-1] = NULL;
+      V[i-1] = V[i];
+    V[nVertices-1] = NULL;
     nVertices--;
   }
 }
 
 
-int  CSSGraph::GetVertexType ( int vertex_no )  {
+ssm::VERTEX_TYPE  ssm::Graph::GetVertexType ( int vertex_no )  {
   if ((vertex_no>0) && (vertex_no<=nVertices))  {
-    if (Vertex[vertex_no-1])  return Vertex[vertex_no-1]->type;
+    if (V[vertex_no-1])  return V[vertex_no-1]->type;
   }
   return V_UNKNOWN;
 }
 
-int  CSSGraph::GetVertexClass ( int vertex_no )  {
+int  ssm::Graph::GetVertexClass ( int vertex_no )  {
   if ((vertex_no>0) && (vertex_no<=nVertices))  {
-    if (Vertex[vertex_no-1])  return Vertex[vertex_no-1]->classID;
+    if (V[vertex_no-1])  return V[vertex_no-1]->classID;
   }
   return 0;
 }
 
-Boolean  CSSGraph::GetVertexDirection ( int vertex_no, vect3 & v )  {
+Boolean  ssm::Graph::GetVertexDirection ( int vertex_no, vect3 & v )  {
   if ((vertex_no>0) && (vertex_no<=nVertices))  {
-    if (Vertex[vertex_no-1])  {
-      Vertex[vertex_no-1]->GetDirection ( v );
+    if (V[vertex_no-1])  {
+      V[vertex_no-1]->GetDirection ( v );
       return True;
     }
   }
   return False;
 }
 
-int  CSSGraph::GetSeqLength ( int vertex_no )  {
+int  ssm::Graph::GetSeqLength ( int vertex_no )  {
   if ((vertex_no>0) && (vertex_no<=nVertices))  {
-    if (Vertex[vertex_no-1])  return Vertex[vertex_no-1]->nres;
+    if (V[vertex_no-1])  return V[vertex_no-1]->nres;
   }
   return V_UNKNOWN;
 }
 
-realtype CSSGraph::GetMass ( int vertex_no )  {
+realtype ssm::Graph::GetMass ( int vertex_no )  {
   if ((vertex_no>0) && (vertex_no<=nVertices))  {
-    if (Vertex[vertex_no-1])  return Vertex[vertex_no-1]->mass;
+    if (V[vertex_no-1])  return V[vertex_no-1]->mass;
   }
   return 0.0;
 }
 
-PCSSVertex  CSSGraph::GetGraphVertex ( int vertex_no )  {
+ssm::PVertex  ssm::Graph::GetGraphVertex ( int vertex_no )  {
   if ((vertex_no>0) && (vertex_no<=nVertices))
-        return Vertex[vertex_no-1];
+        return V[vertex_no-1];
   else  return NULL;
 }
 
-pstr CSSGraph::GetVertexChainID ( int vertex_no )  {
+pstr ssm::Graph::GetVertexChainID ( int vertex_no )  {
   if ((vertex_no>0) && (vertex_no<=nVertices))  {
-    if (Vertex[vertex_no-1])  return Vertex[vertex_no-1]->chainID;
+    if (V[vertex_no-1])  return V[vertex_no-1]->chainID;
   }
   return NULL;
 }
 
-pstr CSSGraph::GetVertexInitRes ( int vertex_no )  {
+pstr ssm::Graph::GetVertexInitRes ( int vertex_no )  {
   if ((vertex_no>0) && (vertex_no<=nVertices))  {
-    if (Vertex[vertex_no-1])  return Vertex[vertex_no-1]->initResName;
+    if (V[vertex_no-1])  return V[vertex_no-1]->initResName;
   }
   return NULL;
 }
 
-pstr CSSGraph::GetVertexEndRes ( int vertex_no )  {
+pstr ssm::Graph::GetVertexEndRes ( int vertex_no )  {
   if ((vertex_no>0) && (vertex_no<=nVertices))  {
-    if (Vertex[vertex_no-1])  return Vertex[vertex_no-1]->endResName;
+    if (V[vertex_no-1])  return V[vertex_no-1]->endResName;
   }
   return NULL;
 }
 
-void CSSGraph::GetVertexRange ( int vertex_no, ChainID chID,
+void ssm::Graph::GetVertexRange ( int vertex_no, ChainID chID,
                                 int & initSeqNum, InsCode initICode,
                                 int & endSeqNum,  InsCode endICode )  {
 int vn;
   if ((vertex_no>0) && (vertex_no<=nVertices))  {
     vn = vertex_no - 1;
-    if (Vertex[vn])  {
-      strcpy ( chID,Vertex[vn]->chainID );
-      initSeqNum = Vertex[vn]->initSeqNum;
-      endSeqNum  = Vertex[vn]->endSeqNum;
-      strcpy ( initICode,Vertex[vn]->initICode );
-      strcpy ( endICode ,Vertex[vn]->endICode  );
+    if (V[vn])  {
+      strcpy ( chID,V[vn]->chainID );
+      initSeqNum = V[vn]->initSeqNum;
+      endSeqNum  = V[vn]->endSeqNum;
+      strcpy ( initICode,V[vn]->initICode );
+      strcpy ( endICode ,V[vn]->endICode  );
       return;
     }
   }
@@ -849,15 +862,15 @@ int vn;
   endICode[0]  = char(0);
 }
 
-void CSSGraph::GetVertexRange ( int vertex_no, ChainID chID,
+void ssm::Graph::GetVertexRange ( int vertex_no, ChainID chID,
                                 int & initPos, int & endPos )  {
 int vn;
   if ((vertex_no>0) && (vertex_no<=nVertices))  {
     vn = vertex_no - 1;
-    if (Vertex[vn])  {
-      strcpy ( chID,Vertex[vn]->chainID );
-      initPos = Vertex[vn]->initPos;
-      endPos  = Vertex[vn]->endPos;
+    if (V[vn])  {
+      strcpy ( chID,V[vn]->chainID );
+      initPos = V[vn]->initPos;
+      endPos  = V[vn]->endPos;
       return;
     }
   }
@@ -866,22 +879,22 @@ int vn;
   endPos  = ANY_RES;
 }
 
-PCSSEdge CSSGraph::GetGraphEdge ( int edge_no )  {
+ssm::PEdge ssm::Graph::GetGraphEdge ( int edge_no )  {
   if ((edge_no>0) && (edge_no<=nEdges))
-        return Edge[edge_no-1];
+        return E[edge_no-1];
   else  return NULL;
 }
 
-PCSSEdge CSSGraph::GetGraphEdge ( int v1, int v2 )  {
+ssm::PEdge ssm::Graph::GetGraphEdge ( int v1, int v2 )  {
   if (graph && (1<=v1) && (v1<=nVertices) &&
                (1<=v2) && (v2<=nVertices) &&
                (v1!=v2))
-       return Edge[graph[v1][v2]];
+       return E[graph[v1][v2]];
   else return NULL;
 }
 
 
-realtype CSSGraph::CalcCombinations ( ivector F, int nm )  {
+realtype ssm::Graph::CalcCombinations ( ivector F, int nm )  {
 //
 //   F contains list of nm graph vertices (e.g. those matched),
 // the function returns the number of combinations these
@@ -908,7 +921,7 @@ int      i,j,k,k0;
       k0 = k;
       k--;
       for (j=i;j<=nVertices-nm+i;j++)
-        if (Vertex[k]->Compare(Vertex[j-1]))  C[i][j] = 1.0;
+        if (V[k]->Compare(V[j-1]))  C[i][j] = 1.0;
     }
   }
 
@@ -929,7 +942,7 @@ int      i,j,k,k0;
 }
 
 
-void  CSSGraph::GetAllChains ( PChainID & chain, int & nchains )  {
+void  ssm::Graph::GetAllChains ( PChainID & chain, int & nchains )  {
 //  returns all chain IDs found in the graph's vertices
 int  i,j,k;
   nchains = 0;
@@ -943,10 +956,10 @@ int  i,j,k;
       k = 0;
       // is chain of this vertex already counted?
       for (j=0;(j<nchains) && (k==0);j++)
-        if (!strcmp(chain[j],Vertex[i]->chainID))  k = 1;
+        if (!strcmp(chain[j],V[i]->chainID))  k = 1;
       if (k==0)  {
         // register the chain
-        strcpy ( chain[nchains],Vertex[i]->chainID );
+        strcpy ( chain[nchains],V[i]->chainID );
         nchains++;
       }
     }
@@ -954,7 +967,7 @@ int  i,j,k;
 }
 
 
-int  CSSGraph::GetNofChains()  {
+int  ssm::Graph::GetNofChains()  {
 // counts number of chains == number of single-chain graphs
 PChainID  chain;
 int       nchains;
@@ -963,12 +976,12 @@ int       nchains;
   return nchains;
 }
 
-void  CSSGraph::DevelopChainGraphs ( PPCSSGraph & G, int & nGraphs )  {
-PChainID   S;
-int        i,j,k;
-PCSSVertex V;
+void  ssm::Graph::DevelopChainGraphs ( PPGraph & G, int & nGraphs )  {
+PChainID S;
+int      i,j,k;
+PVertex  Vx;
 
-  DisposeSSGraphs ( G,nGraphs );
+  DisposeGraphs ( G,nGraphs );
 
   if (nVertices>0)  {
 
@@ -978,26 +991,26 @@ PCSSVertex V;
       k = 0;
       // is chain of this vertex already counted?
       for (j=0;(j<nGraphs) && (k==0);j++)
-        if (!strcmp(S[j],Vertex[i]->chainID))  k = 1;
+        if (!strcmp(S[j],V[i]->chainID))  k = 1;
       if (k==0)  {
         // register the chain
-        strcpy ( S[nGraphs],Vertex[i]->chainID );
+        strcpy ( S[nGraphs],V[i]->chainID );
         nGraphs++;
       }
     }
 
     if (nGraphs>0)  {
-      G = new PCSSGraph[nGraphs];
+      G = new PGraph[nGraphs];
       for (i=0;i<nGraphs;i++)  {
-        G[i] = new CSSGraph();
+        G[i] = new ssm::Graph();
         CreateCopy   ( G[i]->name    ,name     );
         CreateConcat ( G[i]->name    ,":",S[i] );
         strcpy       ( G[i]->devChain,S[i]     );
         for (j=0;j<nVertices;j++)
-          if (!strcmp(S[i],Vertex[j]->chainID))  {
-            V = new CSSVertex();
-            V->Copy ( Vertex[j] );
-            G[i]->AddVertex ( V );
+          if (!strcmp(S[i],V[j]->chainID))  {
+            Vx = new Vertex();
+            Vx->Copy ( V[j] );
+            G[i]->AddVertex ( Vx );
           }
         G[i]->BuildGraph();
       }
@@ -1010,16 +1023,16 @@ PCSSVertex V;
 }
 
 
-void  CSSGraph::Superpose ( PCSSGraph G, ivector F1, ivector F2,
-                            int nMatch, mat44 & TMatrix )  {
+void  ssm::Graph::Superpose ( PGraph G, ivector F1, ivector F2,
+                              int nMatch, mat44 & TMatrix )  {
 //  Returns TMatrix - a transformation matrix for G's coordinates,
 //  such that TMatrix*{G} ~= {this}
 //    F1 is for this graph, F2 = for G.
-  SuperposeSSGraphs ( G,F2,this,F1,nMatch,TMatrix );
+  SuperposeGraphs ( G,F2,this,F1,nMatch,TMatrix );
 }
 
 
-void  CSSGraph::Copy ( PCSSGraph G )  {
+void  ssm::Graph::Copy ( PGraph G )  {
 int i;
 
   FreeMemory();
@@ -1030,17 +1043,17 @@ int i;
   nVertices = G->nVertices;
   if (nVertices>0)  {
     nVAlloc = nVertices;
-    Vertex  = new PCSSVertex[nVertices];
+    V       = new PVertex[nVertices];
     for (i=0;i<nVertices;i++)  {
-      Vertex[i] = new CSSVertex();
-      Vertex[i]->Copy ( G->Vertex[i] );
+      V[i] = new ssm::Vertex();
+      V[i]->Copy ( G->V[i] );
     }
   }
 
 }
 
 
-void  CSSGraph::write ( RCFile f )  {
+void  ssm::Graph::write ( RCFile f )  {
 int i;
 int Version=1;
 
@@ -1049,11 +1062,11 @@ int Version=1;
   f.WriteTerLine ( devChain,False );
   f.WriteInt     ( &nVertices     );
   for (i=0;i<nVertices;i++)
-    StreamWrite ( f,Vertex[i] );
+    StreamWrite ( f,V[i] );
 
 }
 
-void  CSSGraph::read ( RCFile f )  {
+void  ssm::Graph::read ( RCFile f )  {
 int i,Version;
 
   FreeMemory();
@@ -1064,230 +1077,258 @@ int i,Version;
   f.ReadInt     ( &nVertices     );
   if (nVertices>0)  {
     nVAlloc = nVertices;
-    Vertex  = new PCSSVertex[nVertices];
+    V       = new PVertex[nVertices];
     for (i=0;i<nVertices;i++)  {
-      Vertex[i] = NULL;
-      StreamRead ( f,Vertex[i] );
+      V[i] = NULL;
+      StreamRead ( f,V[i] );
     }
   }
 
 }
 
-MakeStreamFunctions(CSSGraph)
-
+namespace ssm {
+  MakeStreamFunctions(Graph)
+}
 
 
 //  ==================================================================
 
 
-void  DisposeSSGraphs ( PPCSSGraph & G, int & nGraphs )  {
-int i;
-  if (G)  {
-    for (i=0;i<nGraphs;i++)
-      if (G[i])  delete G[i];
-    delete[] G;
+namespace ssm  {
+
+  PGraph GetSSGraph ( PCMMDBManager M, int selHnd, int & rc )  {
+  PGraph G;
+
+    G  = new Graph();
+    rc = G->MakeGraph ( M );
+    if (!rc)  {
+      if (selHnd>0)  {
+        G->LeaveVertices ( selHnd,M );
+        if (G->GetNofVertices()<=0)  {
+          delete G;
+          rc = RC_NoVertices;
+          return NULL;
+        }
+      }
+      G->BuildGraph();
+      return G;
+    } else  {
+      rc = RC_NoGraph;
+      if (G)  delete G;
+      return NULL;
+    }
+
   }
-  G       = NULL;
-  nGraphs = 0;
-}
 
+  void  DisposeGraphs ( PPGraph & G, int & nGraphs )  {
+  int i;
+    if (G)  {
+      for (i=0;i<nGraphs;i++)
+        if (G[i])  delete G[i];
+      delete[] G;
+    }
+    G       = NULL;
+    nGraphs = 0;
+  }
 
 
-int  SuperposeSSGraphs ( PCSSGraph G1, ivector F1,
-                         PCSSGraph G2, ivector F2,
+  int  SuperposeGraphs ( PGraph G1, ivector F1,
+                         PGraph G2, ivector F2,
                          int     matchlen,
                          mat44 & TMatrix )  {
-PCSSVertex Vx;
-rmatrix    A,U,V;
-rvector    W,RV1;
-vect3      v1,v2;
-realtype   det,B, x01,y01,z01, x02,y02,z02, mass,mass1,mass2;
-int        i,j,k,l, nE1,nE2;
-
-  nE1 = G1->GetNofEdges();
-  if (!nE1)  G1->BuildGraph();
-
-  nE2 = G2->GetNofEdges();
-  if (!nE2)  G2->BuildGraph();
-
-  GetMatrixMemory ( A,3,3,1,1 );
-  GetMatrixMemory ( U,3,3,1,1 );
-  GetMatrixMemory ( V,3,3,1,1 );
-  GetVectorMemory ( W,3,1 );
-  GetVectorMemory ( RV1,3,1 );
-
-  for (j=1;j<=3;j++)
-    for (k=1;k<=3;k++)
-      A[j][k] = 0.0;
-
-  for (i=1;i<=matchlen;i++)  {
-    Vx = G1->GetGraphVertex ( F1[i] );
-    Vx->GetDirection ( v1 );
-    Vx = G2->GetGraphVertex ( F2[i] );
-    Vx->GetDirection ( v2 );
+  PVertex   Vx;
+  rmatrix   A,U,V;
+  rvector   W,RV1;
+  vect3     v1,v2;
+  realtype  det,B, x01,y01,z01, x02,y02,z02, mass,mass1,mass2;
+  int       i,j,k,l, nE1,nE2;
+
+    nE1 = G1->GetNofEdges();
+    if (!nE1)  G1->BuildGraph();
+
+    nE2 = G2->GetNofEdges();
+    if (!nE2)  G2->BuildGraph();
+
+    GetMatrixMemory ( A  ,3,3,1,1 );
+    GetMatrixMemory ( U  ,3,3,1,1 );
+    GetMatrixMemory ( V  ,3,3,1,1 );
+    GetVectorMemory ( W  ,3,1 );
+    GetVectorMemory ( RV1,3,1 );
+
     for (j=1;j<=3;j++)
       for (k=1;k<=3;k++)
-        A[j][k] += v1[k-1]*v2[j-1];
-  }
-
-  for (i=1;i<matchlen;i++)
-    for (l=i+1;l<=matchlen;l++)
-      if (G1->GetEdgeDirection(F1[i],F1[l],v1) &&
-          G2->GetEdgeDirection(F2[i],F2[l],v2))
-        for (j=1;j<=3;j++)
-          for (k=1;k<=3;k++)
-            A[j][k] += v1[k-1]*v2[j-1];
-
-  det = A[1][1]*A[2][2]*A[3][3] + 
-        A[1][2]*A[2][3]*A[3][1] +
-        A[2][1]*A[3][2]*A[1][3] -
-        A[1][3]*A[2][2]*A[3][1] -
-        A[1][1]*A[2][3]*A[3][2] -
-        A[3][3]*A[1][2]*A[2][1];
-
-  SVD ( 3,3,3,A,U,V,W,RV1,True,True,i );
-
-  if (i!=0) {
-    for (j=0;j<4;j++)  {
-      for (k=0;k<4;k++)
-        TMatrix[j][k] = 0.0;
-      TMatrix[j][j] = 1.0;
+        A[j][k] = 0.0;
+
+    for (i=1;i<=matchlen;i++)  {
+      Vx = G1->GetGraphVertex ( F1[i] );
+      Vx->GetDirection ( v1 );
+      Vx = G2->GetGraphVertex ( F2[i] );
+      Vx->GetDirection ( v2 );
+      for (j=1;j<=3;j++)
+        for (k=1;k<=3;k++)
+          A[j][k] += v1[k-1]*v2[j-1];
     }
-    return 1;
-  }
 
-  if (det<0.0)  {
-    k = 0;
-    B = MaxReal;
-    for (j=1;j<=3;j++)
-      if (W[j]<B)  {
-        B = W[j];
-        k = j;
+    for (i=1;i<matchlen;i++)
+      for (l=i+1;l<=matchlen;l++)
+        if (G1->GetEdgeDirection(F1[i],F1[l],v1) &&
+            G2->GetEdgeDirection(F2[i],F2[l],v2))
+          for (j=1;j<=3;j++)
+            for (k=1;k<=3;k++)
+              A[j][k] += v1[k-1]*v2[j-1];
+
+    det = A[1][1]*A[2][2]*A[3][3] +
+          A[1][2]*A[2][3]*A[3][1] +
+          A[2][1]*A[3][2]*A[1][3] -
+          A[1][3]*A[2][2]*A[3][1] -
+          A[1][1]*A[2][3]*A[3][2] -
+          A[3][3]*A[1][2]*A[2][1];
+
+    SVD ( 3,3,3,A,U,V,W,RV1,True,True,i );
+
+    if (i!=0) {
+      for (j=0;j<4;j++)  {
+        for (k=0;k<4;k++)
+          TMatrix[j][k] = 0.0;
+        TMatrix[j][j] = 1.0;
       }
-    for (j=1;j<=3;j++)
-      V[k][j] = -V[k][j];
-  }
-
-  for (j=1;j<=3;j++)
-    for (k=1;k<=3;k++)  {
-      B = 0.0;
-      for (i=1;i<=3;i++)
-        B += U[j][i]*V[k][i];
-      TMatrix[j-1][k-1] = B;
+      return 1;
     }
 
+    if (det<0.0)  {
+      k = 0;
+      B = MaxReal;
+      for (j=1;j<=3;j++)
+        if (W[j]<B)  {
+          B = W[j];
+          k = j;
+        }
+      for (j=1;j<=3;j++)
+        V[k][j] = -V[k][j];
+    }
 
-  //  9. Add translation
-  x01 = 0.0;   y01 = 0.0;   z01 = 0.0;  mass1 = 0.0;
-  x02 = 0.0;   y02 = 0.0;   z02 = 0.0;  mass2 = 0.0;
-  for (i=1;i<=matchlen;i++)  {
-    Vx     = G1->GetGraphVertex ( F1[i] );
-    mass   = Vx->GetMass();
-    Vx->GetPosition ( v1 );
-    x01   += v1[0]*mass;
-    y01   += v1[1]*mass;
-    z01   += v1[2]*mass;
-    mass1 += mass;
-    Vx     = G2->GetGraphVertex ( F2[i] );
-    mass   = Vx->GetMass();
-    Vx->GetPosition ( v2 );
-    x02   += v2[0]*mass;
-    y02   += v2[1]*mass;
-    z02   += v2[2]*mass;
-    mass2 += mass;
-  }
-  x01 /= mass1;   y01 /= mass1;  z01 /= mass1;
-  x02 /= mass2;   y02 /= mass2;  z02 /= mass2;
-  TMatrix[0][3] = x02 - TMatrix[0][0]*x01 - TMatrix[0][1]*y01 -
-                        TMatrix[0][2]*z01;
-  TMatrix[1][3] = y02 - TMatrix[1][0]*x01 - TMatrix[1][1]*y01 -
-                        TMatrix[1][2]*z01;
-  TMatrix[2][3] = z02 - TMatrix[2][0]*x01 - TMatrix[2][1]*y01 -
-                        TMatrix[2][2]*z01;
-
-  FreeMatrixMemory ( A,1,1 );
-  FreeMatrixMemory ( U,1,1 );
-  FreeMatrixMemory ( V,1,1 );
-  FreeVectorMemory ( W,1 );
-  FreeVectorMemory ( RV1,1 );
-
-  if (!nE1)  G1->ReleaseEdges();
-  if (!nE2)  G2->ReleaseEdges();
-
-  return 0;
+   for (j=1;j<=3;j++)
+       for (k=1;k<=3;k++)  {
+        B = 0.0;
+        for (i=1;i<=3;i++)
+          B += U[j][i]*V[k][i];
+        TMatrix[j-1][k-1] = B;
+      }
 
-}
 
+   //  9. Add translation
+     x01 = 0.0;   y01 = 0.0;   z01 = 0.0;  mass1 = 0.0;
+    x02 = 0.0;   y02 = 0.0;   z02 = 0.0;  mass2 = 0.0;
+    for (i=1;i<=matchlen;i++)  {
+      Vx     = G1->GetGraphVertex ( F1[i] );
+      mass   = Vx->GetMass();
+      Vx->GetPosition ( v1 );
+      x01   += v1[0]*mass;
+      y01   += v1[1]*mass;
+      z01   += v1[2]*mass;
+      mass1 += mass;
+      Vx     = G2->GetGraphVertex ( F2[i] );
+      mass   = Vx->GetMass();
+      Vx->GetPosition ( v2 );
+      x02   += v2[0]*mass;
+      y02   += v2[1]*mass;
+      z02   += v2[2]*mass;
+      mass2 += mass;
+    }
+    x01 /= mass1;   y01 /= mass1;  z01 /= mass1;
+    x02 /= mass2;   y02 /= mass2;  z02 /= mass2;
+    TMatrix[0][3] = x02 - TMatrix[0][0]*x01 - TMatrix[0][1]*y01 -
+                          TMatrix[0][2]*z01;
+    TMatrix[1][3] = y02 - TMatrix[1][0]*x01 - TMatrix[1][1]*y01 -
+                          TMatrix[1][2]*z01;
+    TMatrix[2][3] = z02 - TMatrix[2][0]*x01 - TMatrix[2][1]*y01 -
+                          TMatrix[2][2]*z01;
+
+    FreeMatrixMemory ( A  ,1,1 );
+    FreeMatrixMemory ( U  ,1,1 );
+    FreeMatrixMemory ( V  ,1,1 );
+    FreeVectorMemory ( W  ,1 );
+    FreeVectorMemory ( RV1,1 );
+
+    if (!nE1)  G1->ReleaseEdges();
+    if (!nE2)  G2->ReleaseEdges();
+
+    return 0;
 
-void CalcCombinations ( rvector & combs, int & vlen,
-                        PCSSGraph G1, PCSSGraph G2 )  {
-//  combs[i], i=1..vlen, returns the number of common
-//  substructures of size i of graphs G1 and G2. The
-//  sequential order of graph vertices is taken into
-//  account, however the actual edges are completely
-//  neglected.
-PPCSSVertex V1,V2;
-rmatrix3    P;
-imatrix     C;
-realtype    q;
-int         n,m, i,j,k;
-
-  n = G1->GetNofVertices();
-  m = G2->GetNofVertices();
-  if (n<=m)  {
-    V1 = G1->GetVertices();
-    V2 = G2->GetVertices();
-  } else  {
-    m  = G1->GetNofVertices();
-    n  = G2->GetNofVertices();
-    V2 = G1->GetVertices();
-    V1 = G2->GetVertices();
   }
 
-  vlen = 0;
-  FreeVectorMemory ( combs,1 );
-  if (n<=0)  return;
 
-  GetMatrix3Memory ( P,n,m,n,1,1,1 );
-  GetMatrixMemory  ( C,n,m,1,1 );
-  for (i=1;i<=n;i++)
-    for (j=1;j<=m;j++)  {
-      if (V1[i-1]->Compare(V2[j-1]))  C[i][j] = 1;
-                                else  C[i][j] = 0;
-      for (k=1;k<=n;k++)
-        P[i][j][k] = 0.0;
+  void CalcCombinations ( rvector & combs, int & vlen,
+                          PGraph G1, PGraph G2 )  {
+  //  combs[i], i=1..vlen, returns the number of common
+  //  substructures of size i of graphs G1 and G2. The
+  //  sequential order of graph vertices is taken into
+  //  account, however the actual edges are completely
+  //  neglected.
+  PPVertex   V1,V2;
+  rmatrix3   P;
+  imatrix    C;
+  realtype   q;
+  int        n,m, i,j,k;
+
+    n = G1->GetNofVertices();
+    m = G2->GetNofVertices();
+    if (n<=m)  {
+      V1 = G1->GetVertices();
+      V2 = G2->GetVertices();
+    } else  {
+      m  = G1->GetNofVertices();
+      n  = G2->GetNofVertices();
+      V2 = G1->GetVertices();
+      V1 = G2->GetVertices();
     }
 
-  q = 0.0;
-  for (j=1;j<=m;j++)  {
-    q += C[1][j];
-    P[1][j][1] = q;
-  }
-
-  for (i=2;i<=n;i++)  {
+    vlen = 0;
+    FreeVectorMemory ( combs,1 );
+    if (n<=0)  return;
+
+    GetMatrix3Memory ( P,n,m,n,1,1,1 );
+    GetMatrixMemory  ( C,n,m,1,1 );
+    for (i=1;i<=n;i++)
+      for (j=1;j<=m;j++)  {
+        if (V1[i-1]->Compare(V2[j-1]))  C[i][j] = 1;
+                                  else  C[i][j] = 0;
+        for (k=1;k<=n;k++)
+          P[i][j][k] = 0.0;
+      }
 
     q = 0.0;
     for (j=1;j<=m;j++)  {
-      q += C[i][j];
-      P[i][j][1] = P[i-1][j][1] + q;
+      q += C[1][j];
+      P[1][j][1] = q;
     }
 
-    for (k=2;k<=i;k++)  {
-      for (j=k;j<=m;j++)
-        if (C[i][j]==0)  P[i][j][k] = P[i][j-1][k];
-                   else  P[i][j][k] = P[i][j-1][k] + P[i-1][j-1][k-1];
-      for (j=k;j<=m;j++)
-        P[i][j][k] += P[i-1][j][k];
+    for (i=2;i<=n;i++)  {
+
+      q = 0.0;
+      for (j=1;j<=m;j++)  {
+        q += C[i][j];
+        P[i][j][1] = P[i-1][j][1] + q;
+      }
+
+      for (k=2;k<=i;k++)  {
+        for (j=k;j<=m;j++)
+          if (C[i][j]==0)  P[i][j][k] = P[i][j-1][k];
+                     else  P[i][j][k] = P[i][j-1][k] + P[i-1][j-1][k-1];
+        for (j=k;j<=m;j++)
+          P[i][j][k] += P[i-1][j][k];
+      }
+
     }
 
-  }
+    vlen = n;
+    GetVectorMemory ( combs,n,1 );
+    for (k=1;k<=n;k++)
+      combs[k] = P[n][m][k];
 
-  vlen = n;
-  GetVectorMemory ( combs,n,1 );
-  for (k=1;k<=n;k++)
-    combs[k] = P[n][m][k];
+    FreeMatrix3Memory ( P,n,m,1,1,1 );
+    FreeMatrixMemory  ( C,n,1,1 );
 
-  FreeMatrix3Memory ( P,n,m,1,1,1 );
-  FreeMatrixMemory  ( C,n,1,1 );
+  }
 
 }
diff --git a/ssm_graph.h b/ssm_graph.h
new file mode 100644
index 0000000..4e9b8b2
--- /dev/null
+++ b/ssm_graph.h
@@ -0,0 +1,238 @@
+// $Id: ssm_graph.h,v 1.2 2005/12/20 12:09:14 keb Exp $
+// =================================================================
+//
+//    10.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// -----------------------------------------------------------------
+//
+//  **** Module  :  ssm_graph  <interface>
+//       ~~~~~~~~~
+//  **** Classes :  ssm::Graph  ( secondary structure graph )
+//       ~~~~~~~~~
+//
+//  E. Krissinel 2002-2013
+//
+// =================================================================
+//
+
+
+#ifndef  __SSM_Graph__
+#define  __SSM_Graph__
+
+#include "mmdb/mmdb_manager.h"
+
+#include "ssm_vxedge.h"
+
+namespace ssm  {
+
+  //  ==========================  Graph  ===========================
+
+  DefineClass(Graph);
+  DefineStreamFunctions(Graph)
+
+  class Graph : public CStream  {
+
+    friend class GraphMatch;
+
+    public :
+
+      Graph ();
+      Graph ( RPCStream Object );
+      ~Graph();
+
+      void  Reset();  // must be called before building a graph
+                      // The sequence of calls is:
+                      //    Graph.Reset();
+                      //    for (....)  {
+                      //      V = new CSSVertex();
+                      //      .....
+                      //      SSGraph.AddVertex ( V );
+                      //    }
+                      //    SSGraph.Build();
+
+      void  SetGraphName  ( cpstr gname );
+
+      void  SelectCalphas ( PCMMDBManager MMDB, int & selHnd,
+                            cpstr selstring );
+
+      //   AddVertex(..) do not copy the objects, but take them over.
+      // This means that application should forget about pointers to
+      // V once they were given to CSSGraph. All vertices must be
+      // allocated newly prior each call to AddVertex(..).
+      void  AddVertex  ( PVertex Vx );
+
+      int   MakeGraph ( PCMMDBManager MMDB );
+
+      void  CalcVertexOrder();
+      void  RepairSS ( PCMMDBManager MMDB );
+
+      //   BuildGraph() calculates all edges and builds the graph.
+      void    BuildGraph();
+      Boolean isBuild   ();
+
+      void  calcVTypes();  // calculates nHelices and nStrands only
+
+      //   ReleaseEdges() deallocates all graph edges and
+      //  the connectivity matrix
+      void  ReleaseEdges();
+
+      void  RemoveShortVertices   ( int nmin_hx, int nmin_sd );
+
+      //   LeaveVertices(..) removes all vertices from the graph
+      // except those having numbers listed in vector vlist. Thus,
+      // if vlist[i]=j, 1<=i<=vllen,  1<=j, then jth vertex will
+      // not be removed.
+      void  LeaveVertices         ( ivector vlist, int vllen );
+
+      //   LeaveVertices(..) removes all vertices from the graph
+      // except those found in the specified range. 'select' is of
+      // the following format:
+      //    "*", "(all)"            - take all file
+      //    "-"                     - take chain without chain ID
+      //    "a:Ni-Mj,b:Kp-Lq,..."   - take chain a residue number N
+      //                              insertion code i to residue number M
+      //                              insertion code j plus chain b
+      //                              residue number K insertion code p to
+      //                              residue number L insertion code q and
+      //                              so on.
+      //    "a:,b:..."              - take whole chains a and b and so on
+      //    "a:,b:Kp-Lq,..."        - any combination of the above.
+      void  LeaveVertices ( cpstr select, PCMMDBManager M );
+
+      //    LeaveVertices ( selHnd,MMDB ) leaves only vertices that are
+      // covered by the given selection. selHnd may refer to the
+      // selection of atoms, residues or chains.
+      void  LeaveVertices ( int selHnd, PCMMDBManager M );
+
+      void  RemoveVertex  ( int vertex_no );  // 1..nVertices
+
+      Boolean    inRange  ( cpstr chainID, int initPos, int endPos );
+      inline cpstr    GetGraphName   () { return name;        }
+      inline cpstr    GetDevChain    () { return devChain;    }
+      pstr            GetChainList   ( pstr S );
+      inline int      GetNofVertices () { return nVertices;   }
+      inline PPVertex GetVertices    () { return V;           }
+      inline int      GetNofEdges    () { return nEdges;      }
+      inline int      GetNofHelices  () { return nHelices;    }
+      inline int      GetNofStrands  () { return nStrands;    }
+      void     GetAllChains     ( PChainID & chain, int & nchains );
+      int      GetNofChains     ();
+      Boolean  GetEdgeDirection ( int v1, int v2, vect3 & v );
+      VERTEX_TYPE GetVertexType ( int vertex_no  ); // 1..nVertices
+      int      GetVertexClass   ( int vertex_no  ); // 1..nVertices
+      Boolean  GetVertexDirection ( int vertex_no, vect3 & v );
+      int      GetSeqLength     ( int vertex_no  ); // 1..nVertices
+      realtype GetMass          ( int vertex_no  ); // 1..nVertices
+      PVertex  GetGraphVertex   ( int vertex_no  ); // 1..nVertices
+      pstr     GetVertexChainID ( int vertex_no  ); // 1..nVertices
+      pstr     GetVertexInitRes ( int vertex_no  ); // 1..nVertices
+      pstr     GetVertexEndRes  ( int vertex_no  ); // 1..nVertices
+      void     GetVertexRange   ( int     vertex_no,  // 1..nVertices
+                                  ChainID chID,
+                                  int &   initSeqNum,
+                                  InsCode initICode,
+                                  int &   endSeqNum,
+                                  InsCode endICode  );
+      void     GetVertexRange   ( int     vertex_no,  // 1..nVertices
+                                  ChainID chID,
+                                  int &   initPos,
+                                  int &   endPos );
+      VERTEX_TYPE GetSSEType    ( pstr chainID, int atomPos );
+      VERTEX_TYPE GetSSEType    ( PCAtom A );
+
+      PEdge   GetGraphEdge   ( int edge_no );     // 1..nEdges
+      PEdge   GetGraphEdge   ( int v1, int v2 );  // 1..nVertices
+
+      realtype CalcCombinations ( ivector F, int nm );
+
+      void  DevelopChainGraphs ( PPGraph & G, int & nGraphs );
+
+      //  Superpose(..) returns TMatrix - a transformation matrix for
+      // G's coordinates, such that TMatrix*{G} ~= {this}
+      //  F1 is for 'this' graph, F2 = for G.
+      void  Superpose   ( PGraph G, ivector F1, ivector F2,
+                          int nMatch, mat44 & TMatrix );
+
+      void  Copy  ( PGraph G );
+
+      void  read  ( RCFile f );
+      void  write ( RCFile f );
+
+    protected :
+      pstr     name;        // graph name
+      ChainID  devChain;    // chain of a developed graph
+      int      nVertices,nEdges;
+      int      nHelices,nStrands;
+
+      PPVertex V;
+      PPEdge   E;
+      imatrix  graph;
+
+      void  InitGraph      ();
+      void  FreeMemory     ();
+      void  _leaveVertices ( PCMMDBManager M, int selHnd1 );
+
+      //   CompareEdges(..) compares edge (ij) of the graph with
+      // edge (kl) of graph G. i may be either less or greater
+      // than j, same about k and l. If edges compare, the function
+      // returns 0. Edges with equal indices (i.e. (ii) and (kk))
+      // are considered as comparable (returns 0).
+      //   The function may be used only after both graphs have
+      // been built.
+      int CompareEdges ( int i, int j, PGraph G, int k, int l );
+
+      int CheckEdgeConnectivity ( int i, int j, PGraph G, int k, int l );
+
+    private :
+      int  nVAlloc,nEAlloc,nGAlloc;
+
+  };
+
+
+  //  ==================================================================
+
+  //   In SelectDomain(..) and CutOutDomain(..), select is of the
+  // following format:
+  //    "*", "(all)"            - take all file
+  //    "-"                     - take chain without chain ID
+  //    "a:Ni-Mj,b:Kp-Lq,..."   - take chain a residue number N
+  //                              insertion code i to residue number M
+  //                              insertion code j plus chain b
+  //                              residue number K insertion code p to
+  //                              residue number L insertion code q and
+  //                              so on.
+  //    "a:,b:..."              - take whole chains a and b and so on
+  //    "a:,b:Kp-Lq,..."        - any combination of the above.
+  extern int SelectDomain ( PCMMDBManager MMDB, int & selHnd,
+                            cpstr select, int selType );
+  extern int CutOutDomain ( PCMMDBManager MMDB, cpstr select );
+
+  extern PGraph GetSSGraph ( PCMMDBManager M, int selHnd, int & rc );
+
+  extern void DisposeGraphs ( PPGraph & G, int & nGraphs );
+
+  extern int  SuperposeGraphs ( PGraph G1, ivector F1,
+                                PGraph G2, ivector F2,
+                                int     matchlen,
+                                mat44 & TMatrix );
+
+}
+
+/*
+
+extern realtype  GetTorsion ( rvector U, rvector W, rvector V );
+//      U     W      V
+//   o<----o----->o----->o
+//
+
+extern realtype  GetAngle   ( rvector v1, rvector v2 );
+//  returns angle between v1 and v2
+
+
+
+extern void  CalcCombinations ( rvector & combs, int & vlen,
+                                PCSSGraph G1, PCSSGraph G2 );
+
+*/
+
+#endif
diff --git a/ssm_malign.cpp b/ssm_malign.cpp
new file mode 100644
index 0000000..cf1b462
--- /dev/null
+++ b/ssm_malign.cpp
@@ -0,0 +1,2525 @@
+// $Id: ssm_malign.cpp,v 1.15 2008/07/08 15:50:52 keb Exp $
+// =================================================================
+//
+//    10.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//  ----------------------------------------------------------------
+//
+//  **** Module  :  SSM_MAlign <implementation>
+//       ~~~~~~~~~
+//  **** Project :  SSM
+//       ~~~~~~~~~
+//  **** Classes :  ssm::MultAlign
+//       ~~~~~~~~~
+//
+//  E. Krissinel, 2003-2013
+//
+// =================================================================
+//
+
+#include <string.h>
+#include <math.h>
+
+#include "ssm_malign.h"
+#include "mmdb/linalg_.h"
+
+// ---------------------------  ssm::MAStruct  -------------------------
+
+void  ssm::MAStruct::Init ( PCMMDBManager MMDB, PGraph graph,
+                            int serNo, int nStruct )  {
+
+  SD.Init();
+
+  G   = NULL;
+  P   = NULL;
+  Q   = NULL;
+  F   = NULL;
+  nV  = 0;
+  sNo = 0;
+  n   = 0;
+
+  x0  = NULL;    // original C-alpha X-coordinates
+  y0  = NULL;    // original C-alpha Y-coordinates
+  z0  = NULL;    // original C-alpha Z-coordinates
+
+  nalign = 0;    // number of aligned residues
+  Rmsd0  = 3.0;  // Q-score parameter
+
+  Set ( MMDB,graph,serNo,nStruct );
+
+}
+
+void  ssm::MAStruct::Set ( PCMMDBManager MMDB, PGraph graph,
+                           int serNo, int nStruct )  {
+int i;
+
+  Dispose();
+
+  if (MMDB && graph)  {
+    SD.M = MMDB;
+    SD.G = graph;
+    G  = new Graph();         // reduceable copy of SSE graph
+    G->Copy ( graph );
+    G->BuildGraph();
+    nV = G->GetNofVertices();    // number of vertices
+    GetVectorMemory ( P,nV,1 );  // SSE matching probabilities
+    GetVectorMemory ( Q,nV,1 );  // SSE matching scores
+    GetVectorMemory ( F,nV,1 );  // original vertex numbering
+    for (i=1;i<=nV;i++)  {
+      P[i] = 0.0;
+      Q[i] = 0.0;
+      F[i] = i;
+    }
+  }
+
+  sNo     = serNo;   // serial number
+  n       = 0;       // used locally
+  nSAlloc = nStruct;
+
+}
+
+void ssm::MAStruct::Dispose() {
+
+  SD.Dispose();
+
+  if (G)  delete G;
+  G = NULL;
+
+  FreeVectorMemory ( P,1 );
+  FreeVectorMemory ( Q,1 );
+  FreeVectorMemory ( F,1 );
+  nV = 0;
+  n  = 0;
+
+  FreeVectorMemory ( x0,0 );
+  FreeVectorMemory ( y0,0 );
+  FreeVectorMemory ( z0,0 );
+
+}
+
+
+void  ssm::MAStruct::PrepareSSEMatching() {
+int i;
+  n = 0;
+  for (i=1;i<=nV;i++)  {
+    if (P[i]>0.99999)  n++;
+    P[i] = 0.0;  // reset accumulators
+    Q[i] = 0.0;
+  }
+  if (n<=0)  n = 1;
+}
+
+
+Boolean  ssm::MAStruct::Refine ( int maxdel, realtype P0,
+                                 ivector v1, ivector v2 ) {
+realtype Qmin;
+int      i,j,k;
+
+  for (i=1;i<=maxdel;i++)  {
+    Qmin = MaxReal;
+    k    = 0;
+    for (j=1;j<=nV;j++)
+      if ((P[j]>0.00001) && (P[j]<P0) && (Q[j]<Qmin))  {
+        Qmin = Q[j];
+        k    = j;
+      }
+    if (k>0) P[k] = 0.0;
+  }
+
+  k = 0;
+  for (j=1;j<=nV;j++)
+    if (P[j]>=0.00001)  {
+      k++;
+      v1[k] = j;
+      v2[k] = F[j];
+    }
+
+  if (k<nV)  {
+    G->LeaveVertices ( v1,k );
+    G->BuildGraph();
+    nV = G->GetNofVertices();
+    for (j=1;j<=nV;j++)
+      F[j] = v2[j];
+    return False;
+  }
+
+  return True;
+
+}
+
+void  ssm::MAStruct::SaveCoordinates()  {
+int i;
+
+  FreeVectorMemory ( x0,0 );
+  FreeVectorMemory ( y0,0 );
+  FreeVectorMemory ( z0,0 );
+
+  GetVectorMemory ( x0,SD.nres,0 );
+  GetVectorMemory ( y0,SD.nres,0 );
+  GetVectorMemory ( z0,SD.nres,0 );
+
+  for (i=0;i<SD.nres;i++)  {
+    x0[i] = SD.Calpha[i]->x;
+    y0[i] = SD.Calpha[i]->y;
+    z0[i] = SD.Calpha[i]->z;
+  }
+
+}
+
+void  ssm::MAStruct::RestoreCoordinates()  {
+int i;
+  for (i=0;i<SD.nres;i++)  {
+    SD.Calpha[i]->x = x0[i];
+    SD.Calpha[i]->y = y0[i];
+    SD.Calpha[i]->z = z0[i];
+  }
+}
+
+void  ssm::MAStruct::Transform()  {
+//   This function applies the rotation-translation transformation,
+// given by matrix RT, to the structure. The function also
+// initializes atom structures used for C-alpha matching.
+int i;
+
+  for (i=0;i<SD.nres;i++)
+    SD.Calpha[i]->Transform ( RT );
+  for (i=0;i<SD.nSSEs;i++)
+    SD.SSED[i].Transform ( RT );
+
+}
+
+void  ssm::MAStruct::CalcCorrelationMatrix ( rmatrix & A, rvector xc,
+                                             rvector  yc, rvector zc ) {
+vect3 vc1,vc2;
+int   i,j,i1,i2;
+
+  for (i=1;i<=3;i++)
+    for (j=1;j<=3;j++)
+      A[i][j] = 0.0;
+
+  xm = 0.0;
+  ym = 0.0;
+  zm = 0.0;
+  cx = 0.0;
+  cy = 0.0;
+  cz = 0.0;
+  nalign = 0;
+  for (i1=0;i1<SD.nres;i1++)  {
+    i2 = SD.a[i1].c;
+    if (i2>=0)  {
+      xm += x0[i1];
+      ym += y0[i1];
+      zm += z0[i1];
+      cx += xc[i2];
+      cy += yc[i2];
+      cz += zc[i2];
+      nalign++;
+    }
+  }
+  xm /= nalign;
+  ym /= nalign;
+  zm /= nalign;
+  cx /= nalign;
+  cy /= nalign;
+  cz /= nalign;
+
+  for (i1=0;i1<SD.nres;i1++)  {
+    i2 = SD.a[i1].c;
+    if (i2>=0)  {
+      vc1[0] = x0[i1] - xm;
+      vc1[1] = y0[i1] - ym;
+      vc1[2] = z0[i1] - zm;
+      vc2[0] = xc[i2] - cx;
+      vc2[1] = yc[i2] - cy;
+      vc2[2] = zc[i2] - cz;
+      for (i=1;i<=3;i++)
+        for (j=1;j<=3;j++)
+          A[i][j] += vc1[j-1]*vc2[i-1];
+    }
+  }
+
+}
+
+void ssm::MAStruct::CalcTranslation()  {
+  RT[0][3] = cx - RT[0][0]*xm - RT[0][1]*ym - RT[0][2]*zm;
+  RT[1][3] = cy - RT[1][0]*xm - RT[1][1]*ym - RT[1][2]*zm;
+  RT[2][3] = cz - RT[2][0]*xm - RT[2][1]*ym - RT[2][2]*zm;
+}
+
+void ssm::MAStruct::GetDirection ( int atompos, vect3 & v )  {
+int p1,p2;
+  p1 = IMax ( 0,atompos-1 );
+  p2 = IMin ( SD.nres-1,atompos+1 );
+  v[0] = SD.Calpha[p2]->x - SD.Calpha[p1]->x;
+  v[1] = SD.Calpha[p2]->y - SD.Calpha[p1]->y;
+  v[2] = SD.Calpha[p2]->z - SD.Calpha[p1]->z;
+}
+
+Boolean ssm::MAStruct::isMC ( int pos1, PMAStruct S, int pos2 )  {
+//   Returns True if matching the Calpha pair in the positions
+// (pos1,pos2) of the chains would contradict to the already
+// aligned pairs and allowMC is set False.
+int i;
+
+//  if (allowMC)  return False;
+
+  i = pos1 + 1;
+  while (i<SD.nres)
+    if (SD.a[i].c>=0)  break;
+                 else  i++;
+  if (i<SD.nres) {
+    if (pos2>=SD.a[i].c)  {
+      if ((!strcmp(SD.a[pos1].chID,SD.a[i].chID)) &&
+          (!strcmp(S->SD.a[pos2].chID,S->SD.a[SD.a[i].c].chID)))
+        return True;
+    }
+  }
+
+  i = pos1 - 1;
+  while (i>=0)
+    if (SD.a[i].c>=0)  break;
+                 else  i--;
+  if (i>=0) {
+    if (pos2<=SD.a[i].c)  {
+      if ((!strcmp(SD.a[pos1].chID,SD.a[i].chID)) &&
+          (!strcmp(S->SD.a[pos2].chID,S->SD.a[SD.a[i].c].chID)))
+        return True;
+    }
+  }
+
+  return False;
+
+}
+
+
+// ----------------------------  ssm::MSSEOutput -------------------------
+
+void  ssm::MSSEOutput::Init()  {
+  name1[0]    = char(0);
+  name2[0]    = char(0);
+  chID [0]    = char(0);
+  seqNum1     = ANY_RES;
+  seqNum2     = ANY_RES;
+  sseType     = V_UNKNOWN;
+  loopNo      = 1;
+  insCode1[0] = char(0);
+  insCode2[0] = char(0);
+  aligned     = False;
+}
+
+void ssm::MSSEOutput::SetSSERange ( PVertex V )  {
+  V->GetVertexRange  ( chID,name1,seqNum1,insCode1,name2,seqNum2,insCode2 );
+  sseType = V->GetVertexType();
+}
+
+void  ssm::MSSEOutput::Copy ( RMSSEOutput M )  {
+  strcpy ( name1,M.name1 );
+  strcpy ( name2,M.name2 );
+  strcpy ( chID ,M.chID  );
+  seqNum1 = M.seqNum1;
+  seqNum2 = M.seqNum2;
+  sseType = M.sseType;
+  loopNo  = M.loopNo;
+  strcpy ( insCode1,M.insCode1 );
+  strcpy ( insCode2,M.insCode2 );
+  aligned = M.aligned;
+}
+
+void  ssm::MSSEOutput::write ( RCFile f )  {
+  f.WriteFile ( name1,sizeof(name1) );
+  f.WriteFile ( name2,sizeof(name2) );
+  f.WriteFile ( chID ,sizeof(chID)  );
+  f.WriteInt  ( &seqNum1 );
+  f.WriteInt  ( &seqNum2 );
+  f.WriteInt  ( &sseType );
+  f.WriteInt  ( &loopNo  );
+  f.WriteFile ( insCode1,sizeof(insCode1) );
+  f.WriteFile ( insCode2,sizeof(insCode2) );
+  f.WriteBool ( &aligned );
+}
+
+void  ssm::MSSEOutput::read ( RCFile f )  {
+  f.ReadFile ( name1,sizeof(name1) );
+  f.ReadFile ( name2,sizeof(name2) );
+  f.ReadFile ( chID ,sizeof(chID)  );
+  f.ReadInt  ( &seqNum1 );
+  f.ReadInt  ( &seqNum2 );
+  f.ReadInt  ( &sseType );
+  f.ReadInt  ( &loopNo  );
+  f.ReadFile ( insCode1,sizeof(insCode1) );
+  f.ReadFile ( insCode2,sizeof(insCode2) );
+  f.ReadBool ( &aligned );
+}
+
+
+
+// ---------------------------  ssm::MAOutput  -------------------------
+
+void ssm::MAOutput::Init()  {
+  name[0]    = char(0);
+  chID[0]    = char(0);
+  seqNum     = 0;
+  insCode[0] = char(0);
+  rmsd       = 0.0;
+  sseType    = V_UNKNOWN;
+  aligned    = False;
+}
+
+void ssm::MAOutput::Fill ( PCAtom A, PGraph G, Boolean align )  {
+PCResidue res;
+  res = A->GetResidue();
+  if (res)  {
+    strcpy ( name,res->GetResName() );
+    strcpy ( chID,res->GetChainID() );
+    if (!chID[0])  strcpy ( chID," " );
+    seqNum = res->GetSeqNum();
+    strcpy ( insCode,res->GetInsCode() );
+  }
+  sseType = G->GetSSEType ( A );
+  aligned = align;
+}
+
+void  ssm::MAOutput::Copy ( RMAOutput M )  {
+  strcpy ( name,M.name );
+  strcpy ( chID,M.chID );
+  seqNum  = M.seqNum;
+  sseType = M.sseType;
+  strcpy ( insCode,M.insCode );
+  rmsd    = M.rmsd;
+  aligned = M.aligned;
+}
+
+void  ssm::MAOutput::write ( RCFile f )  {
+  f.WriteFile ( name,sizeof(name) );
+  f.WriteFile ( chID,sizeof(chID) );
+  f.WriteInt  ( &seqNum  );
+  f.WriteInt  ( &sseType );
+  f.WriteFile ( insCode,sizeof(insCode) );
+  f.WriteReal ( &rmsd    );
+  f.WriteBool ( &aligned );
+}
+
+void  ssm::MAOutput::read ( RCFile f )  {
+  f.ReadFile ( name,sizeof(name) );
+  f.ReadFile ( chID,sizeof(chID) );
+  f.ReadInt  ( &seqNum  );
+  f.ReadInt  ( &sseType );
+  f.ReadFile ( insCode,sizeof(insCode) );
+  f.ReadReal ( &rmsd    );
+  f.ReadBool ( &aligned );
+}
+
+
+namespace ssm  {
+
+  void FreeMSOutput ( PPMAOutput & MAOutput, int & nrows )  {
+  int i;
+    if (MAOutput)  {
+      for (i=0;i<nrows;i++)
+        if (MAOutput[i])  delete[] MAOutput[i];
+      delete[] MAOutput;
+    }
+    MAOutput = NULL;
+    nrows    = 0;
+  }
+
+
+  void FreeMSOutput ( PPMSSEOutput & MSSEOutput, int & nrows )  {
+  int i;
+    if (MSSEOutput)  {
+      for (i=0;i<nrows;i++)
+        if (MSSEOutput[i])  delete[] MSSEOutput[i];
+      delete[] MSSEOutput;
+    }
+    MSSEOutput = NULL;
+    nrows      = 0;
+  }
+
+}
+
+
+// ---------------------------  ssm::PAMatch ---------------------------
+
+ssm::PAMatch::PAMatch()  {
+  F1     = NULL;
+  F2     = NULL;
+  Q      = NULL;
+  mlen   = 0;
+  Qscore = 0.0;
+}
+
+ssm::PAMatch::~PAMatch()  {
+  FreeMemory();
+}
+
+void  ssm::PAMatch::FreeMemory()  {
+  FreeVectorMemory ( F1,1 );
+  FreeVectorMemory ( F2,1 );
+  FreeVectorMemory ( Q ,1 );
+}
+
+void  ssm::PAMatch::Set ( ivector v1, ivector v2, int matchlen,
+                          realtype matchQ, rvector SSEQ )  {
+int i;
+
+  FreeMemory();
+
+  mlen = matchlen;
+  GetVectorMemory ( F1,mlen,1 );
+  GetVectorMemory ( F2,mlen,1 );
+  GetVectorMemory ( Q ,mlen,1 );
+  for (i=1;i<=mlen;i++)  {
+    F1[i] = v1  [i];
+    F2[i] = v2  [i];
+    Q [i] = SSEQ[i];
+  }
+
+  Qscore = matchQ;
+
+}
+
+Boolean ssm::PAMatch::GetMatch ( ivector v1, ivector v2, int matchlen,
+                             realtype & matchQ, rvector SSEQ )  {
+int  i,j,k;
+
+  matchQ = Qscore;
+
+  if (matchlen<=mlen)  k = 1;
+
+  for (i=1;(i<=matchlen) && (k==1);i++)  {
+    k = 2;
+    for (j=1;(j<=mlen) && (k==2);j++)
+      if (v1[i]==F1[j])  {
+        if (v2[i]!=F2[j])  k = 3;
+        else  {
+          SSEQ[i] = Q[j];
+          k = 1;
+        }
+      }
+  }
+
+  return (k==1);
+
+}
+
+
+// --------------------------  ssm::PAMatches --------------------------
+
+ssm::PAMatches::PAMatches()  {
+  PA       = NULL;
+  nMatches = 0;
+  nAlloc   = 0;
+  nBest    = -1;
+}
+
+ssm::PAMatches::~PAMatches()  {
+int i;
+  if (PA)  {
+    for (i=0;i<nAlloc;i++)
+      if (PA[i]) delete PA[i];
+    delete[] PA;
+  }
+}
+
+int  ssm::PAMatches::AddMatch ( ivector v1, ivector v2, int matchlen,
+                                realtype matchQ, rvector SSEQ )  {
+PPPAMatch PA1;
+int        i;
+  if (nMatches>=nAlloc)  {
+    nAlloc += 30;
+    PA1 = new PPAMatch[nAlloc];
+    for (i=0;i<nMatches;i++)
+      PA1[i] = PA[i];
+    for (i=nMatches;i<nAlloc;i++)
+      PA1[i] = NULL;
+    if (PA)  delete[] PA;
+    PA = PA1;
+  }
+  PA[nMatches] = new PAMatch();
+  PA[nMatches]->Set ( v1,v2,matchlen,matchQ,SSEQ );
+  nMatches++;
+  return nMatches-1;
+}
+
+int  ssm::PAMatches::GetMatch ( ivector v1, ivector v2, int matchlen,
+                                realtype & matchQ, rvector SSEQ )  {
+int i,mNo;
+  mNo = -1;
+  for (i=0;i<nMatches;i++)
+    if (PA[i]->GetMatch(v1,v2,matchlen,matchQ,SSEQ))  {
+      mNo = i;
+      break;
+    }
+  return mNo;
+}
+
+void  ssm::PAMatches::SetBestMatch ( int mNo )  {
+  nBest = mNo;
+}
+
+realtype ssm::PAMatches::GetBestQscore()  {
+  if (nBest>=0)  return PA[nBest]->Qscore;
+           else  return 0.0;
+}
+
+void  ssm::PAMatches::GetBestMatch ( ivector & v1, ivector & v2,
+                                 int & matchlen )  {
+  if (nBest>=0)  {
+    v1 = PA[nBest]->F1;
+    v2 = PA[nBest]->F2;
+    matchlen = PA[nBest]->mlen;
+  } else  {
+    v1 = NULL;
+    v2 = NULL;
+    matchlen = 0;
+  }
+}
+
+
+// ----------------------------  SMAMap ----------------------------
+
+void  ssm::MAMap::Init ( int nStruct )  {
+  rmsd = 0.0;
+  GetVectorMemory ( map,nStruct,1 );
+}
+
+void  ssm::MAMap::Dispose()  {
+  FreeVectorMemory ( map,1 );
+}
+
+
+// ---------------------------  ssm::MultAlign -------------------------
+
+namespace ssm  {
+  MakeStreamFunctions(MultAlign)
+}
+
+ssm::MultAlign::MultAlign() : CStream()  {
+  InitMultAlign();
+}
+
+ssm::MultAlign::MultAlign ( RPCStream Object ) : CStream ( Object )  {
+  InitMultAlign();
+}
+
+ssm::MultAlign::~MultAlign()  {
+
+  FreeMemory();
+
+  FreeMatrixMemory ( A,3,1,1 );  // correlation matrix
+  FreeMatrixMemory ( Z,3,1,1 );  // left SVD vectors
+  FreeMatrixMemory ( V,3,1,1 );  // right SVD vectors
+  FreeVectorMemory ( W,1     );  // singular values
+
+}
+
+void  ssm::MultAlign::FreeMemory()  {
+
+  DeletePAMatches  ();
+  DeleteStructures ();
+
+  FreeVectorMemory ( vq,1 );
+  FreeVectorMemory ( v1,1 );
+  FreeVectorMemory ( v2,1 );
+
+  FreeVectorMemory ( xc,0 );
+  FreeVectorMemory ( yc,0 );
+  FreeVectorMemory ( zc,0 );
+
+  FreeMatrixMemory ( mx_rmsd  ,nStructAlloc,0,0 );
+  FreeMatrixMemory ( mx_Qscore,nStructAlloc,0,0 );
+  FreeMatrixMemory ( mx_seqId ,nStructAlloc,0,0 );
+  nStructAlloc = 0;
+
+  DeleteMap        ();
+
+}
+
+void  ssm::MultAlign::DeleteStructures()  {
+int i;
+  if (S)  {
+    for (i=0;i<nStruct;i++)
+      S[i]->Dispose();
+    delete[] S;
+    S = NULL;
+  }
+  nStruct = 0;
+}
+
+void  ssm::MultAlign::DeselectCalphas()  {
+int i;
+  for (i=0;i<nStruct;i++)
+    S[i]->SD.DeselectCalphas();
+}
+
+void  ssm::MultAlign::SelectCalphas()  {
+int i;
+  for (i=0;i<nStruct;i++)
+    S[i]->SD.SelectCalphas();
+}
+
+
+void  ssm::MultAlign::DeletePAMatches()  {
+int i,j;
+  if (PM)  {
+    for (i=0;i<nStruct-1;i++)
+      if (PM[i])  {
+        for (j=i+1;j<nStruct;j++)
+          if (PM[i][j])  delete PM[i][j];
+        PM[i] += i+1;
+        delete[] PM[i];
+      }
+    delete[] PM;
+  }
+  PM = NULL;
+}
+
+void  ssm::MultAlign::DeleteMap()  {
+int i;
+  if (Map)  {
+    for (i=0;i<Map_nrows;i++)
+      Map[i].Dispose();
+    delete[] Map;
+    Map = NULL;
+  }
+  Map_nrows = 0;
+}
+
+void  ssm::MultAlign::AllocateMap()  {
+int i;
+  DeleteMap();
+  Map_nrows = S[0]->SD.nres;
+  Map = new MAMap[Map_nrows];
+  for (i=0;i<Map_nrows;i++)
+    Map[i].Init ( nStruct-1 );
+}
+
+void  ssm::MultAlign::InitMultAlign()  {
+
+  S            = NULL;  // working structure array
+  PM           = NULL;  // pairwise matches database
+  nStruct      = 0;     // number of structures
+  ProgressFunc = NULL;
+  ProgFuncData = NULL;
+
+  vq           = NULL;  // working array [1..maxNV]
+  v1           = NULL;  // working array [1..maxNV]
+  v2           = NULL;  // working array [1..maxNV]
+  maxNV        = 0;     // maximal number of vertices
+
+  precision    = PREC_Normal;       // SSE matching specificity
+  connectivity = CONNECT_Flexible;  // SSE matching connectivity flag
+
+  minCont      = 3.0;  // angstrom; minimal contact distance
+  maxCont      = 8.0;  // angstrom; maximal contact distance
+  Rmsd0        = 3.0;  // parameter of Q-score
+
+  minIter      =  3;   // minimal number of iterations
+  maxIter      = 30;   // maximal number of iterations
+  maxHollowIt  =  3;   // maximal allowed number of consequtive
+                       // iterations without quality improvement
+
+  GetMatrixMemory ( A,3,3,1,1 );  // correlation matrix
+  GetMatrixMemory ( Z,3,3,1,1 );  // left SVD vectors
+  GetMatrixMemory ( V,3,3,1,1 );  // right SVD vectors
+  GetVectorMemory ( W,3,1     );  // singular values
+
+  Map     = NULL;  // 0:i is mapped onto j:Map[i].map[j]
+  Map_nrows =  0;  // number of rows in Map;
+
+  Nalign        = 0;   // number of multiply-aligned rows
+  minNres       = -1;  // minimal number of residues
+  maxNres       = -1;  // maximal number of residues
+  nSSEalign     = 0;   // number of multiply-aligned SSEs
+  rmsd_achieved = 0.0; // achieved RMSD
+  Q_achieved    = 0.0; // achieved Q
+
+  xc           = NULL; // consensus X-coordinates
+  yc           = NULL; // consensus Y-coordinates
+  zc           = NULL; // consensus Z-coordinates
+  mx_rmsd      = NULL; // matrix of inter-structure rmsds
+  mx_Qscore    = NULL; // matrix of inter-structure Q-scores
+  mx_seqId     = NULL; // matrix of inter-structure sequence identities
+  nStructAlloc = 0;    // number of structures allocated
+
+}
+
+void  ssm::MultAlign::setProgressFunction ( void * UserData,
+                                            PMAProgressFunc Fnc )  {
+  ProgressFunc = Fnc;
+  ProgFuncData = UserData;
+}
+
+
+int  ssm::MultAlign::align ( PPCMMDBManager MMDB,
+                             psvector  selstring,
+                             PPGraph       Graph,
+                             int     nStructures )  {
+char L[100];
+int  i,j,rc;
+
+  FreeMemory();
+
+  if ((nStructures<1) || (!MMDB))  return MALIGN_BadInput;
+
+  //   Allocate an dinitialize structures
+
+  nStruct = nStructures;
+  S       = new PMAStruct[nStruct];
+  for (i=0;i<nStruct;i++)  {
+    S[i] = NULL;
+    if (!Graph[i]->GetGraphName()) {
+      sprintf ( L,"S%03i",i+1 );
+      Graph[i]->SetGraphName ( L );
+    }
+  }
+
+  rc    = 0;
+  maxNV = 0;
+  for (i=0;(i<nStruct) && (!rc);i++)
+    if (MMDB[i])  {
+      if (Graph[i])  {
+        S[i] = new MAStruct();
+        S[i]->Init ( MMDB[i],Graph[i],i,nStruct );
+        S[i]->Rmsd0 = Rmsd0;
+        if (S[i]->nV>maxNV)  maxNV = S[i]->nV;
+        if (selstring)  CreateCopy ( S[i]->SD.selstring,selstring[i] );
+      } else
+        rc = MALIGN_NoGraph+i;
+    } else
+      rc = MALIGN_NoStructure;
+
+  if (rc)  {
+    FreeMemory();
+    return rc;
+  }
+
+  //  Allocate and initialize database of matches
+
+  PM = new PPPAMatches[nStruct-1];
+  for (i=0;i<nStruct-1;i++)  {
+    PM[i]  = new PPAMatches[nStruct-i-1];
+    PM[i] -= (i+1);
+    for (j=i+1;j<nStruct;j++)
+      PM[i][j] = new ssm::PAMatches();
+  }
+
+  GetVectorMemory ( vq,IMax(3,maxNV)      ,1 );
+  GetVectorMemory ( v1,IMax(nStruct,maxNV),1 );
+  GetVectorMemory ( v2,IMax(nStruct,maxNV),1 );
+
+  if (ProgressFunc)  (*ProgressFunc)(ProgFuncData,1,0);
+  AlignSSEs();
+
+  if (ProgressFunc)  (*ProgressFunc)(ProgFuncData,2,0);
+
+  if (nSSEalign>0)  rc = AlignCalphas();
+              else  rc = MALIGN_NoAlignment;
+
+  return rc;
+
+}
+
+#ifndef __debug
+
+void  ssm::MultAlign::printStats()  {
+// used for debugging only
+char L[10];
+int  i,j,k;
+  printf ( "\n\n =======================================\n   " );
+  for (i=0;i<nStruct;i++)
+    printf ( "     %s   ",S[i]->G->GetGraphName() );
+  printf ( "\n" );
+  i = 1;
+  do {
+    k = 0;
+    printf ( "%2i.",i );
+    for (j=0;j<nStruct;j++)
+      if (S[j]->nV>=i)  {
+        if (S[j]->G->GetVertexType(i)==V_HELIX)
+             strcpy ( L,"H" );
+        else strcpy ( L,"S" );
+        printf ( " %5.3g|%s%s:%2i",S[j]->P[i],
+                 S[j]->G->GetVertexChainID(i),L,S[j]->F[i] );
+        k = 1;
+      } else
+        printf ( "            " );
+    printf ( "\n" );
+    i++;
+  } while (k);
+}
+
+#else
+
+void  ssm::MultAlign::printStats()  {
+// used for debugging only
+char L[10],SS[500],N[300];
+int  i,j,k,k1;
+  writeDebug ( "\n\n =======================================" );
+  strcpy ( SS,"" );
+  k1 = 0;
+  for (i=0;i<nStruct;i++)  {
+    strcat ( SS,"     " );
+    strcat ( SS,S[i]->G->GetGraphName() );
+    strcat ( SS,"   "   );
+    k1++;
+    if (k1>3)  {
+      writeDebug ( SS );
+      writeDebug ( " ---------------------------------------" );
+      strcpy ( SS,"" );
+      k1 = 0;
+    }
+  }
+  if (SS[0])  writeDebug ( SS );
+  i = 1;
+  do {
+    k  = 0;
+    k1 = 0;
+    sprintf ( SS,"%2i.",i );
+    for (j=0;j<nStruct;j++)  {
+      if (S[j]->nV>=i)  {
+        if (S[j]->G->GetVertexType(i)==V_HELIX)
+             strcpy ( L,"H" );
+        else strcpy ( L,"S" );
+        sprintf ( N," %5.3g|%s%s:%2i",S[j]->P[i],
+                    S[j]->G->GetVertexChainID(i),L,S[j]->F[i] );
+        strcat ( SS,N );
+        k = 1;
+      } else
+        strcat ( SS,"            " );
+      k1++;
+      if (k1>3)  {
+        writeDebug ( SS );
+        writeDebug ( " ---------------------------------------" );
+        strcpy ( SS,"  " );
+        k1 = 0;
+      }
+    }
+    if (strlen(SS)>2)  writeDebug ( SS );
+    i++;
+  } while (k);
+}
+
+#endif
+
+void  ssm::MultAlign::WriteMatchedSSEs ( RCFile f,
+                                         Boolean shortTable )  {
+PPMSSEOutput MSSEOutput;
+ChainID      chID;
+InsCode      initICode,endICode;
+int          initSeqNum,endSeqNum;
+char         N[200],L[20];
+int          i,j,vno, nrows,ncols;
+
+  j = 1;
+  for (i=1;(i<nStruct) && (j);i++)
+    if (S[i]->nV!=S[0]->nV)  j = 0;
+
+  if (!j)  {
+
+    f.WriteLine ( "  SSE Alignment is not complete." );
+    f.LF();
+
+  } else  {
+
+    MSSEOutput = NULL;
+    nrows      = 0;
+    ncols      = 0;
+    GetMSSEOutput ( MSSEOutput,nrows,ncols );
+
+    f.Write ( " " );
+    for (i=0;i<nStruct;i++)  {
+      if (i>0)  f.Write ( "|" );
+      sprintf ( N,"     %4s       ",S[i]->G->GetGraphName() );
+      f.Write ( N );
+    }
+    f.LF();
+    f.Write ( " " );
+    for (i=0;i<nStruct;i++)  {
+      if (i>0)  f.Write ( "+" );
+      f.Write ( "----------------" );
+    }
+    f.LF();
+
+    for (i=0;i<nrows;i++)  {
+      f.Write ( " " );
+      for (j=0;j<ncols;j++)  {
+        if (j>0) f.Write ( "|" );
+        if (!MSSEOutput[i][j].name1[0])
+          strcpy ( N,"                " );
+        else {
+          strcpy ( chID,MSSEOutput[i][j].chID );
+          switch (MSSEOutput[i][j].sseType)  {
+            case V_HELIX  :  strcpy ( L,"H" );  break;
+            case V_STRAND :  strcpy ( L,"S" );  break;
+            default       :  strcpy ( L,"X" );  break;
+          }
+          sprintf ( N,"%1s[%1s:%i-%i]",L,chID,
+                      MSSEOutput[i][j].seqNum1,
+                      MSSEOutput[i][j].seqNum2 );
+          if (j<ncols-1) {
+            if (MSSEOutput[i][j].aligned)
+                  while (strlen(N)<16)  strcat ( N,"*" );
+            else  while (strlen(N)<16)  strcat ( N," " );
+          }
+        }
+        f.Write ( N );
+      }
+      f.LF();
+    }
+
+    FreeMSOutput  ( MSSEOutput,nrows );
+
+    if (shortTable)  {
+
+      f.Write ( "-" );
+      for (i=0;i<nStruct;i++)
+        f.Write ( "-----------------" );
+      f.LF();
+
+      f.Write ( " " );
+      for (i=0;i<nStruct;i++)  {
+        sprintf ( N,"       %s      ",S[i]->G->GetGraphName() );
+        f.Write ( N );
+      }
+      f.LF();
+
+      f.Write ( "-" );
+      for (i=0;i<nStruct;i++)
+        f.Write ( "-----------------" );
+      f.LF();
+
+      for (i=1;i<=S[0]->nV;i++)  {
+        if (S[0]->SD.G->GetVertexType(S[0]->F[i])==V_HELIX)
+             f.Write ( "H" );
+        else f.Write ( "S" );
+        for (j=0;j<nStruct;j++)  {
+          vno = S[j]->F[i];
+          S[j]->SD.G->GetVertexRange ( vno,chID,initSeqNum,initICode,
+                                       endSeqNum,endICode );
+          sprintf ( N,"|%2i:%1s%4i%1s-%4i%1s|",vno,chID,
+                    initSeqNum,initICode,endSeqNum,endICode );
+          f.Write ( N );
+        }
+        f.LF();
+      }
+
+      f.Write ( "-" );
+      for (i=0;i<nStruct;i++)
+        f.Write ( "-----------------" );
+      f.LF();
+
+    }
+
+  }
+
+}
+
+
+void  ssm::MultAlign::AlignSSEs()  {
+PMAStruct D;
+int       i,j,itn;
+Boolean   done;
+
+  itn = 1;
+  do {
+
+    //  Sort graphs by increasing the number of vertices
+    for (i=0;i<nStruct-1;i++)
+      for (j=i+1;j<nStruct;j++)
+        if (S[i]->nV>S[j]->nV)  {
+          D = S[j];  S[j] = S[i];  S[i] = D;
+        }
+
+    //  Get matching statistics
+    GetSSEMatchingStats();
+//    printStats();
+
+    done = RefineGraphs();
+
+    if (ProgressFunc)  (*ProgressFunc)(ProgFuncData,1,itn++);
+
+  } while (!done);
+
+}
+
+void  ssm::MultAlign::GetSSEMatchingStats()  {
+realtype  B;
+int       i,j;
+
+  for (i=0;i<nStruct;i++)
+    S[i]->PrepareSSEMatching();
+
+  SetMatchPrecision    ( precision    );
+  SetConnectivityCheck ( connectivity );
+
+  U.SetUniqueMatch ( True );
+  U.SetBestMatch   ( True );
+
+//  Superpose.SetIterationLimits ( 8,8,4 );
+
+  for (i=nStruct-2;i>=0;i--)
+    for (j=i+1;j<nStruct;j++)  {
+      //      U.MatchGraphs ( G[i],G[j],IMax(1,IMin(n0[i],n0[j])-2) );
+      /*
+writeDebug ( " mstat 4.1 i=",i );
+ if (!S[i]->G)  writeDebug ( " no G[i]" );
+ if (!S[j]->G)  writeDebug ( " no G[j]" );
+      */
+      U.MatchGraphs ( S[i]->G,S[j]->G,1 );
+      GetBestMatch  ( S[i],S[j] );
+    }
+
+  // Take the averages
+  B = nStruct - 1.0;
+  for (i=0;i<nStruct;i++)
+    for (j=1;j<=S[i]->nV;j++)  {
+      S[i]->P[j] /= B;
+      S[i]->Q[j] /= B;
+    }
+
+}
+
+Boolean  betterMatch ( int len1, realtype Q1, int len, realtype Q )  {
+  if (len<=3)  {
+    if (len1>len)   return True;
+    if (len1==len)  return (Q1>Q);
+  } else if (len1>len+1)  return True;
+    else if (len1>=len-1) return (Q1>Q);
+  return False;
+}
+
+void  ssm::MultAlign::GetBestMatch ( PMAStruct S1, PMAStruct S2 )  {
+ivector  F1,F2, FF1,FF2;
+realtype p1,p2,Q,Q1;
+int      i1,i2,i,j,n,ml,mlen,mNo;
+
+  i1 = S1->sNo;
+  i2 = S2->sNo;
+
+  n = U.GetNofMatches ( 0.0,0.0 );
+
+  if (n>0)  {
+    Q    = -0.5;
+    mlen = 0;
+    for (i=0;i<n;i++)  {
+      // get match
+      U.GetMatch ( i,ml,F1,F2,p1,p2 );
+      // get original vertex indices
+      for (j=1;j<=ml;j++)  {
+        v1[j] = S1->F[F1[j]];
+        v2[j] = S2->F[F2[j]];
+      }
+      // check if such a match is already in the database
+      if (i2>i1)  mNo = PM[i1][i2]->GetMatch ( v1,v2,ml,Q1,vq );
+            else  mNo = PM[i2][i1]->GetMatch ( v2,v1,ml,Q1,vq );
+      if (mNo>=0)  {
+        // match found, check whether it is the best one
+        if (betterMatch(ml,Q1,mlen,Q))  {
+          Q    = Q1;
+          mlen = ml;
+          FF1  = F1;
+          FF2  = F2;
+          if (i2>i1)  PM[i1][i2]->SetBestMatch ( mNo );
+                else  PM[i2][i1]->SetBestMatch ( mNo );
+        }
+      } else  {
+        // a new SSE match
+        superpose.SuperposeCalphas ( &(S1->SD),&(S2->SD),
+                                     v1,v2,ml );
+        Q1 = superpose.GetCalphaQ();
+        for (j=1;j<=ml;j++)
+          vq[j] = S1->SD.SSED[F1[j]-1].Qscore;
+        //  store the match
+        if (i2>i1)  mNo = PM[i1][i2]->AddMatch ( v1,v2,ml,Q1,vq );
+              else  mNo = PM[i2][i1]->AddMatch ( v2,v1,ml,Q1,vq );
+        if ((Q1>0.0) && betterMatch(ml,Q1,mlen,Q))  {
+          Q    = Q1;
+          mlen = ml;
+          FF1   = F1;
+          FF2   = F2;
+          if (i2>i1)  PM[i1][i2]->SetBestMatch ( mNo );
+                else  PM[i2][i1]->SetBestMatch ( mNo );
+        }
+      }
+    }
+    for (i=1;i<=mlen;i++)  {
+      S1->P[FF1[i]] += 1.0;
+      S2->P[FF2[i]] += 1.0;
+      S1->Q[FF1[i]] += vq[i];
+      S2->Q[FF2[i]] += vq[i];
+    }
+  }
+
+}
+
+
+Boolean  ssm::MultAlign::RefineGraphs()  {
+PMAStruct D;
+realtype  Pmin,dP,P0,B;
+int       i,j;
+Boolean   done;
+
+  dP   = 1.0/realtype(nStruct);
+  Pmin = MaxReal;
+  nSSEalign = MaxInt4; // number of multiply-aligned SSEs
+  for (i=0;i<nStruct;i++)  {
+    S[i]->n = 0; // counts non-zero probs
+    if (S[i]->nV<nSSEalign)  nSSEalign = S[i]->nV;
+    for (j=1;j<=S[i]->nV;j++)
+      if (S[i]->P[j]>dP)  {
+        S[i]->n++;
+        if (S[i]->P[j]<Pmin)  Pmin = S[i]->P[j];
+      }
+  }
+
+  //  Sort graphs by increasing the number of vertices
+  for (i=0;i<nStruct-1;i++)
+    for (j=i+1;j<nStruct;j++)
+      if (S[i]->n>S[j]->n)  {
+        D = S[j];  S[j] = S[i];  S[i] = D;
+      }
+
+  if (S[0]->n<=0)  return True;  // all-zero, no solution
+
+  P0 = RMin(1.0-dP,Pmin+dP);   // probability cut-off
+
+  // we now dispose all vertices below the probability cut-off
+  done = True;
+  for (i=0;i<nStruct;i++)  {
+    B = S[i]->n - S[0]->n;
+    j = IMax ( 1, mround(B-B/(sqrt(B)/10.0+2.0)) );
+    if (!S[i]->Refine(j,P0,v1,v2))  done = False;
+  }
+
+  return done;
+
+}
+
+void ssm::MultAlign::WriteSuperposed ( cpstr fileName )  {
+PCMMDBManager MMDB;
+PCModel       model;
+PCChain       chain;
+ChainID       chID;
+int           i;
+
+  model = newCModel();
+
+  strcpy ( chID,"A" );
+  for (i=0;i<nStruct;i++)  {
+    model->AddChain ( S[i]->SD.M->GetChain(1,0) );
+    chain = model->GetChain ( i );
+    if (chain)  {
+      chain->SetChainID ( chID );
+      chID[0] = char(int(chID[0])+1);
+      chain->ApplyTransform ( S[i]->RT );
+    }
+  }
+
+  MMDB = new CMMDBManager();
+  MMDB->AddModel ( model );
+  MMDB->WritePDBASCII ( fileName );
+  delete MMDB;
+
+}
+
+int ssm::MultAlign::MakeFirstGuess()  {
+//   Using the results of multiple graph matching, this function
+// simply chooses a structure which makes a highest quality
+// superposition with all other structures. The other structures
+// are then oriented to the chosen one.
+PMAStruct MAS;
+ivector   F1,F2;
+realtype  Q,Qmax;
+int       i,i1,j,k,m,rc;
+
+  rc = MALIGN_Ok;
+
+  //  1. Find structure showing highest sum of Q-scores
+
+  Qmax = -MaxReal;
+  k    = -1;
+  for (i=0;i<nStruct;i++)  {
+    i1 = S[i]->sNo;
+    Q  = 0.0;
+    for (j=0;j<i1;j++)
+      Q += PM[j][i1]->GetBestQscore();
+    for (j=i1+1;j<nStruct;j++)
+      Q += PM[i1][j]->GetBestQscore();
+    if (Q>Qmax)  {
+      Qmax = Q;
+      k    = i;
+    }
+    S[i]->Qsum = Q;
+  }
+
+  if (k<0)  k = 0;
+
+  //  2. Sort structures by decreasing their Q-scores
+
+  if (k>0)  {
+    MAS = S[k];  S[k] = S[0];  S[0] = MAS;
+  }
+  for (i=1;i<nStruct-1;i++)
+    for (j=i+1;j<nStruct;j++)
+      if (S[j]->Qsum>S[i]->Qsum)  {
+        MAS = S[j];  S[j] = S[i];  S[i] = MAS;
+      }
+
+  //  3. Make 3D alignments to the central (1st) structure
+  i1 = S[0]->sNo;
+  Mat4Init ( S[0]->RT0 );
+  for (i=1;(i<nStruct) && (rc==MALIGN_Ok);i++)  {
+    j = S[i]->sNo;
+    if (j>i1)  PM[i1][j]->GetBestMatch ( F1,F2,m );
+         else  PM[j][i1]->GetBestMatch ( F2,F1,m );
+    if (m>0)  {
+      superpose.SuperposeCalphas ( &(S[i]->SD),&(S[0]->SD),F2,F1,m );
+      superpose.GetTMatrix       ( S[i]->RT0 );
+    } else
+      rc = MALIGN_NoAlignment;
+  }
+
+  if (rc!=MALIGN_Ok)  return rc;
+
+  //  4. Make a first-guess C-alpha alignment: leave only
+  //     mappings that are common for all structures
+
+  for (i=0;i<S[0]->SD.nres;i++)
+    S[0]->SD.a[i].c0 = 0;  // use this as a counter of mapped atoms
+
+  //     count atoms mapped on each atom of 1st structure
+  for (i=1;i<nStruct;i++)
+    for (j=0;j<S[i]->SD.nres;j++)  {
+      m = S[i]->SD.a[j].c0;  // i:j is mapped on 0:m
+      if (m>=0)  S[0]->SD.a[m].c0++;  // count atoms mapped on this one
+    }
+
+  Nalign = 0;
+  for (i=0;i<S[0]->SD.nres;i++)  {
+    if (S[0]->SD.a[i].c0<nStruct-1)  {
+      S[0]->SD.a[i].c0 = -1;  // unmap this atom as not all structures
+                              // have atoms mapped on it
+    } else  {
+      S[0]->SD.a[i].c0 = i;   // map on itself for consensus calcs
+      Nalign++;
+    }
+    S[0]->SD.a[i].c = S[0]->SD.a[i].c0;
+  }
+
+  for (i=1;i<nStruct;i++)  {
+    for (j=0;j<S[i]->SD.nres;j++)  {
+      m = S[i]->SD.a[j].c0;
+      if (m>=0)  {
+        if (S[0]->SD.a[m].c0<0)
+          S[i]->SD.a[j].c0 = -1;
+      }
+      S[i]->SD.a[j].c = S[i]->SD.a[j].c0;
+    }
+  }
+
+  return rc;
+
+}
+
+
+int  ssm::MultAlign::CalcRotation ( mat44 & R )  {
+//   Given the correlation matrix A, this function calculates rotation
+// matrix R, optimally excluding the rotoinversion if occured
+realtype det,B;
+int      i,j,k;
+
+  det = A[1][1]*A[2][2]*A[3][3] +
+        A[1][2]*A[2][3]*A[3][1] +
+        A[2][1]*A[3][2]*A[1][3] -
+        A[1][3]*A[2][2]*A[3][1] -
+        A[1][1]*A[2][3]*A[3][2] -
+        A[3][3]*A[1][2]*A[2][1];
+
+  SVD ( 3,3,3,A,Z,V,W,vq,True,True,i );
+
+  if (i!=0) {
+    for (i=0;i<4;i++)  {
+      for (j=0;j<4;j++)
+        R[i][j] = 0.0;
+      R[i][i] = 1.0;
+    }
+    return 1;
+  }
+
+  if (det<=0.0)  {
+    k = 0;
+    B = MaxReal;
+    for (j=1;j<=3;j++)
+      if (W[j]<B)  {
+        B = W[j];
+        k = j;
+      }
+    for (j=1;j<=3;j++)
+      V[j][k] = -V[j][k];
+  }
+
+  for (j=1;j<=3;j++)
+    for (k=1;k<=3;k++)  {
+      B = 0.0;
+      for (i=1;i<=3;i++)
+        B += Z[j][i]*V[k][i];
+      R[j-1][k-1] = B;
+    }
+
+  R[3][0] = 0.0;
+  R[3][1] = 0.0;
+  R[3][2] = 0.0;
+  R[3][3] = 1.0;
+
+  return 0;
+
+}
+
+
+//  ==============================================================
+
+namespace ssm {
+
+  DefineClass(SortMappings);
+
+  class SortMappings : public CQuickSort  {
+    public :
+      SortMappings() : CQuickSort() {}
+      int  Compare ( int i, int j );
+      void Sort    ( ivector ci, int nc, PMAMap Map );
+    protected :
+      PMAMap M;
+  };
+
+  int SortMappings::Compare ( int i, int j )  {
+  realtype ri,rj;
+    ri = M[((ivector)data)[i]].rmsd;
+    rj = M[((ivector)data)[j]].rmsd;
+    if (ri<rj)  return  1;
+    if (ri>rj)  return -1;
+    return 0;
+  }
+
+  void SortMappings::Sort ( ivector ci, int nc, PMAMap Map )  {
+    M = Map;
+    CQuickSort::Sort ( &(ci[0]),nc );
+  }
+
+}
+
+//  ==============================================================
+
+
+Boolean ssm::MultAlign::EvaluateMapping ( PCMContact C )  {
+//  Calculates optimal mapping for the contact, but does not
+//  do the actual mapping
+PCAtom   a0;
+realtype d,dmin;
+int      i0,i,j,j0;
+
+
+  i0 = C->contactID;
+  a0 = S[0]->SD.Calpha[i0];  // the reference atom
+  if (!a0)  return False;
+
+  // now simply choose, from all atoms contacting the reference one,
+  // those still available, fitting by chainline and closest
+  Map[i0].rmsd = 0.0;
+  for (i=0;i<C->nStruct;i++)  {
+    dmin = MaxReal;
+    j0   = -1;
+    for (j=0;j<C->nAtoms[i];j++)
+      if ((S[i+1]->SD.a[C->id[i][j]].c<0) &&
+          (!S[i+1]->isMC(C->id[i][j],S[0],i0)))  {
+        d = a0->GetDist2 ( C->Atom[i][j] );
+        if (d<dmin)  {
+          dmin = d;
+          j0   = j;
+        }
+      }
+    if (j0>=0)  {
+      Map[i0].map[i+1] = C->id[i][j0];
+      Map[i0].rmsd    += dmin;
+    } else
+      break;
+  }
+  if (j0<0)  return False;
+
+  for (i=1;i<nStruct-1;i++)
+    for (j=i+1;j<nStruct;j++)
+      Map[i0].rmsd += S[i]->SD.Calpha[Map[i0].map[i]]->GetDist2 (
+                                  S[j]->SD.Calpha[Map[i0].map[j]] );
+
+  return True;
+
+}
+
+
+void ssm::MultAlign::CalcRMSD ( int mappos )  {
+int i,j,k;
+
+  Map[mappos].rmsd = 0.0;
+
+  for (i=1;i<nStruct;i++)  {
+    k = Map[mappos].map[i];
+    Map[mappos].rmsd +=
+      S[0]->SD.Calpha[mappos]->GetDist2 ( S[i]->SD.Calpha[k] );
+    for (j=i+1;j<nStruct;j++)
+      Map[mappos].rmsd += S[i]->SD.Calpha[k]->GetDist2 (
+                                 S[j]->SD.Calpha[Map[mappos].map[j]] );
+  }
+
+  Map[mappos].rmsd /= (nStruct*(nStruct-1))/2;
+
+}
+
+void ssm::MultAlign::CorrespondContacts ( realtype contDist )  {
+PPCAtom *   AIndex;
+PPCMContact contact;
+realtype    dmin;
+int         i,j,k,mpos, nconts;
+
+  //  1. Prepare array of atom indices for contact seeking
+
+  AIndex = new PPCAtom[nStruct];
+  for (i=0;i<nStruct;i++)  {
+    AIndex[i] = new PCAtom[S[i]->SD.nres];
+    for (j=0;j<S[i]->SD.nres;j++)
+      if (S[i]->SD.a[j].c<0)
+           AIndex[i][j] = S[i]->SD.Calpha[j];
+      else AIndex[i][j] = NULL;
+    if (i>0)  v1[i] = S[i]->SD.nres;
+  }
+
+  //  2. Find multiple contacts
+  contact = NULL;
+  S[0]->SD.M->SeekContacts ( AIndex[0],S[0]->SD.nres,
+                             &(AIndex[1]),&(v1[1]),
+                             nStruct-1,0.0,contDist,
+                             contact,0 );
+
+  //  3. Remove incomlete contacts
+
+  nconts = 0;
+  for (i=0;i<S[0]->SD.nres;i++)
+    if (contact[i])  {
+      k = 1;
+      if (contact[i]->nAtoms)
+        for (j=0;j<contact[i]->nStruct;j++)
+          if (contact[i]->nAtoms[j]>0)  k++;
+      if (k>=nStruct)  {
+        if (i>nconts)  {
+          contact[nconts] = contact[i];
+          contact[i]      = NULL;
+        }
+        nconts++;
+      } else  {
+        delete contact[i];
+        contact[i] = NULL;
+      }
+    }
+
+
+  //  4. Cover contacts one-by-one in order of increasing
+  //     the optimal mapping rmsd
+
+  do  {
+
+    //  4.1 As any new contact affects the optimal mapping,
+    //      calculate the shortest contact each time before
+    //      the mapping
+    dmin = MaxReal;
+    k    = -1;
+    for (i=0;i<nconts;i++)
+      if (contact[i])  {
+        if (EvaluateMapping(contact[i]))  {
+          if (Map[contact[i]->contactID].rmsd<dmin)  {
+            dmin = Map[contact[i]->contactID].rmsd<dmin;
+            k = i;
+          }
+        } else  {
+          mpos = contact[i]->contactID;
+          for (j=1;j<nStruct;j++)
+            Map[mpos].map[j] = -1;
+          delete contact[i];
+          contact[i] = NULL;
+        }
+      }
+
+    if (k>=0)  {
+      mpos = contact[k]->contactID;
+      S[0]->SD.a[mpos].c = mpos;
+      for (i=1;i<nStruct;i++)
+        S[i]->SD.a[Map[mpos].map[i]].c = mpos;
+      delete contact[k];
+      contact[k] = NULL;
+    }
+
+  } while (k>=0);
+
+  DeleteMContacts ( contact,S[0]->SD.nres );
+
+  for (i=0;i<nStruct;i++)
+    if (AIndex[i])  delete[] AIndex[i];
+  delete[] AIndex;
+
+}
+
+void  ssm::MultAlign::CalcConsensus()  {
+int i,j,k;
+  for (i=0;i<maxNres;i++)  {
+    xc[i] = 0.0;
+    yc[i] = 0.0;
+    zc[i] = 0.0;
+  }
+  for (i=0;i<nStruct;i++)
+    for (j=0;j<S[i]->SD.nres;j++)  {
+      k = S[i]->SD.a[j].c;
+      if (k>=0)  {
+        xc[k] += S[i]->SD.Calpha[j]->x;
+        yc[k] += S[i]->SD.Calpha[j]->y;
+        zc[k] += S[i]->SD.Calpha[j]->z;
+      }
+    }
+  for (i=0;i<maxNres;i++)  {
+    xc[i] /= nStruct;
+    yc[i] /= nStruct;
+    zc[i] /= nStruct;
+  }
+}
+
+
+realtype  ssm::MultAlign::MatchQuality2 ( int Nalgn, realtype dist2 )  {
+realtype  NormN,Na2,NormR;
+  NormN = minNres*maxNres;
+  if (NormN<=0.0) return 0.0;
+  Na2   = Nalgn*Nalgn;
+  NormR = dist2/(Nalgn*Rmsd0*Rmsd0);
+  return  Na2/((1.0+NormR)*NormN);
+}
+
+realtype  ssm::MultAlign::MatchQuality  ( int Nalgn, int N1, int N2,
+                                      realtype dist2 )  {
+realtype  NormN,Na2,NormR;
+  NormN = N1*N2;
+  if (NormN<=0.0) return 0.0;
+  Na2   = Nalgn*Nalgn;
+  NormR = dist2/(Nalgn*Rmsd0*Rmsd0);
+  return  Na2/((1.0+NormR)*NormN);
+}
+
+int  ssm::MultAlign::OptimizeAlignments()  {
+SortMappings sortMappings;
+rvector      rmsd0;
+ivector      ci;
+realtype     rmsd,Qscore,r1,Q1;
+int          i,j,k, nc, nalgn,nalgn1, rc, iter;
+int          nobetter_cnt;
+Boolean      done;
+
+  rc = SPOSE_Ok;
+
+  FreeVectorMemory ( xc,0 );
+  FreeVectorMemory ( yc,0 );
+  FreeVectorMemory ( zc,0 );
+
+  minNres = MaxInt4;
+  maxNres = MinInt4;
+  for (i=0;i<nStruct;i++)  {
+    S[i]->SaveCoordinates();
+    if (S[i]->SD.nres<minNres)  minNres = S[i]->SD.nres;
+    if (S[i]->SD.nres>maxNres)  maxNres = S[i]->SD.nres;
+    Mat4Copy ( S[i]->RT0,S[i]->RT );
+  }
+
+  GetVectorMemory ( xc,maxNres,0 );
+  GetVectorMemory ( yc,maxNres,0 );
+  GetVectorMemory ( zc,maxNres,0 );
+  GetVectorMemory ( ci   ,S[0]->SD.nres,0 );
+  GetVectorMemory ( rmsd0,S[0]->SD.nres,0 );
+
+  AllocateMap();
+
+  Nalign        = 0;
+  rmsd_achieved = MaxReal;
+  Q_achieved    = -1.0;
+
+  iter         = 0;
+  nobetter_cnt = 0;
+  do  {
+
+    //  1. Bring structures to the best mutual positions
+    for (i=0;i<nStruct;i++)  {
+      S[i]->Transform();
+      for (j=0;j<S[i]->SD.nres;j++)  {
+        S[i]->SD.a[j].c = S[i]->SD.a[j].c0;
+        if (S[i]->SD.a[j].c>=0)
+             S[i]->SD.a[j].unmap1 = UNMAP_NO;
+        else S[i]->SD.a[j].unmap1 = UNMAP_YES;
+      }
+    }
+
+    //  2. Set initial mappings
+
+    for (i=0;i<S[0]->SD.nres;i++)
+      for (j=1;j<nStruct;j++)
+        Map[i].map[j] = -1;
+
+    // 0:i is mapped onto j:SMAMap[i].map[j]
+    for (i=1;i<nStruct;i++)
+      for (j=0;j<S[i]->SD.nres;j++)  {
+        k = S[i]->SD.a[j].c;
+        if (k>=0)  Map[k].map[i] = j;
+      }
+
+    //  3. Try to expand the mappings
+
+    CorrespondContacts ( maxCont );
+
+    //    RecoverGaps();
+
+    nalgn = 0;
+    rmsd  = 0.0;
+    nc    = 0;
+    for (i=0;i<S[0]->SD.nres;i++)
+      if (S[0]->SD.a[i].c>=0)  {
+        k = 0;
+        for (j=1;(j<nStruct) && (k>=0);j++)
+          k = Map[i].map[j];
+        if (k>=0)  {
+          nalgn++;
+          CalcRMSD ( i );
+          rmsd += Map[i].rmsd;
+          if (S[0]->SD.a[i].unmap1!=UNMAP_NO)
+            ci[nc++] = i;
+        } else  {
+          S[0]->SD.a[i].c = -1;
+          for (j=1;j<nStruct;j++)
+            if (Map[i].map[j]>=0)  {
+              S[j]->SD.a[Map[i].map[j]].c = -1;
+              Map[i].map[j] = -1;
+            }
+        }
+      }
+
+    Qscore = MatchQuality2 ( nalgn,rmsd );
+
+    if (nc>0)  {
+      // unmap atoms for increasing the Q-score
+      sortMappings.Sort ( ci,nc,Map );
+      nalgn1 = nalgn;
+      r1     = rmsd;
+      k      = -1;
+      for (i=0;i<nc;i++)  {
+        r1 -= Map[ci[i]].rmsd;
+        nalgn1--;
+        Q1  = MatchQuality2 ( nalgn1,r1 );
+        if (Q1>Qscore)  {
+          Qscore = Q1;
+          rmsd   = r1;
+          nalgn  = nalgn1;
+          k      = i;
+        }
+      }
+      for (i=0;i<=k;i++)  {
+        S[0]->SD.a[ci[i]].c = -1;
+        for (j=1;j<nStruct;j++)
+          S[j]->SD.a[Map[ci[i]].map[j]].c = -1;
+      }
+    }
+
+    //  4. Calculate consensus coordinates
+
+    CalcConsensus();
+
+    if (nalgn>0)  rmsd /= nalgn;
+
+    if (Qscore>Q_achieved)  {
+      Q_achieved    = Qscore;
+      rmsd_achieved = rmsd;  // square root is taken once before return
+      Nalign        = nalgn;
+      for (i=0;i<nStruct;i++)
+        for (j=0;j<S[i]->SD.nres;j++)
+          S[i]->SD.a[j].c0 = S[i]->SD.a[j].c;
+      for (i=0;i<S[0]->SD.nres;i++)
+        rmsd0[i] = Map[i].rmsd;
+      for (i=0;i<nStruct;i++)
+        Mat4Copy ( S[i]->RT,S[i]->RT0 );
+      nobetter_cnt = 0;
+    } else
+      nobetter_cnt++;
+
+    done = (nalgn==0) || (iter>maxIter) ||
+           ((iter>minIter) && (nobetter_cnt>maxHollowIt));
+
+    if (!done)  {
+
+      //  5. Optimize superposition
+
+      for (i=0;(i<nStruct) && (rc==SPOSE_Ok);i++)  {
+        S[i]->CalcCorrelationMatrix ( A,xc,yc,zc );
+        if (CalcRotation(S[i]->RT))  rc = SPOSE_SVDFail;
+                               else  S[i]->CalcTranslation();
+      }
+
+      done = (rc!=SPOSE_Ok);
+
+    }
+
+    iter++;
+    if (ProgressFunc)  (*ProgressFunc)(ProgFuncData,2,iter);
+
+    for (i=0;i<nStruct;i++)
+      S[i]->RestoreCoordinates();
+
+  } while (!done);
+
+  for (i=0;i<nStruct;i++)  {
+    Mat4Copy ( S[i]->RT0,S[i]->RT );
+    for (j=0;j<S[i]->SD.nres;j++)
+      S[i]->SD.a[j].c = S[i]->SD.a[j].c0;
+  }
+
+  for (i=0;i<S[0]->SD.nres;i++)  {
+    Map[i].rmsd = rmsd0[i];
+    for (j=1;j<nStruct;j++)
+      Map[i].map[j] = -1;
+  }
+  for (i=1;i<nStruct;i++)
+    for (j=0;j<S[i]->SD.nres;j++)  {
+      k = S[i]->SD.a[j].c0;
+      if (k>=0)  Map[k].map[i] = j;
+    }
+
+  FreeVectorMemory ( ci   ,0 );
+  FreeVectorMemory ( rmsd0,0 );
+
+  rmsd_achieved = sqrt(rmsd_achieved);
+
+  return rc;
+
+}
+
+void  ssm::MultAlign::SortStructures()  {
+//  sorts structures in the original order
+PMAStruct MAS;
+int       i,j,k,m;
+
+  k = 0;
+  j = S[0]->sNo;
+  for (i=1;i<nStruct;i++)
+    if (S[i]->sNo<j)  {
+      k = i;
+      j = S[i]->sNo;
+    }
+
+  if (k>0)  {
+
+    //  All alignments are mapped as i->0.
+    //  Make inverse mapping 0->k
+    for (i=0;i<S[0]->SD.nres;i++)  {
+      S[0]->SD.a[i].c0 = -1;  // unmap 1st structure completely
+      S[0]->SD.a[i].c  = -1;
+    }
+
+    for (i=0;i<S[k]->SD.nres;i++)  {
+      j = S[k]->SD.a[i].c0;    // k:i is mapped to 0:j
+      if (j>=0)  {
+        S[0]->SD.a[j].c0 = i;  // now 0:j is mapped to k:i
+        S[0]->SD.a[j].c  = i;
+      }
+    }
+
+    //  Remap all other alignments as i->0->k
+    for (i=1;i<nStruct;i++)
+      if (i!=k)  {
+        for (j=0;j<S[i]->SD.nres;j++)  {
+          m = S[i]->SD.a[j].c0;    // i:j is mapped on 0:m
+          if (m>=0)  {
+            m = S[0]->SD.a[m].c0;
+            if (m>=0)  S[i]->SD.a[j].c0 = m;
+                 else  S[i]->SD.a[j].c0 = -1;
+          }
+          S[i]->SD.a[j].c = S[i]->SD.a[j].c0;
+        }
+      }
+
+  }
+
+  //  Sort structures by serial numbers
+
+  if (k>0)  {
+    MAS = S[k];  S[k] = S[0];  S[0] = MAS;
+  }
+  for (i=1;i<nStruct-1;i++)
+    for (j=i+1;j<nStruct;j++)
+      if (S[j]->sNo<S[i]->sNo)  {
+        MAS = S[j];  S[j] = S[i];  S[i] = MAS;
+      }
+
+  //  Map 0th structure onto itself
+  for (i=0;i<S[0]->SD.nres;i++)
+    if (S[0]->SD.a[i].c0>=0)  {
+      S[0]->SD.a[i].c0 = i;
+      S[0]->SD.a[i].c  = i;
+    }
+
+  //  Set mappings
+  if (Map)  {
+    DeleteMap  ();
+    AllocateMap();
+    for (i=0;i<S[0]->SD.nres;i++)
+      for (j=1;j<nStruct;j++)
+        Map[i].map[j] = -1;
+    for (i=1;i<nStruct;i++)
+      for (j=0;j<S[i]->SD.nres;j++)  {
+        k = S[i]->SD.a[j].c;
+        if (k>=0)  Map[k].map[i] = j;
+      }
+  }
+
+}
+
+
+void ssm::MultAlign::CalcConsensusScores()  {
+ivector  ix;
+bvector  sc;
+realtype B,nid;
+int      i,j,k,m;
+
+  FreeMatrixMemory ( mx_rmsd  ,nStructAlloc,0,0 );
+  FreeMatrixMemory ( mx_Qscore,nStructAlloc,0,0 );
+  FreeMatrixMemory ( mx_seqId ,nStructAlloc,0,0 );
+
+  GetMatrixMemory ( mx_rmsd  ,nStruct,nStruct,0,0 );
+  GetMatrixMemory ( mx_Qscore,nStruct,nStruct,0,0 );
+  GetMatrixMemory ( mx_seqId ,nStruct,nStruct,0,0 );
+  nStructAlloc = nStruct;
+
+  GetVectorMemory ( ix,maxNres,0 );
+  GetVectorMemory ( sc,maxNres,0 );
+
+  for (i=0;i<maxNres;i++)
+    sc[i] = False;
+
+  //  Bring structures to the best mutual positions
+  for (i=0;i<nStruct;i++)
+    S[i]->Transform();
+
+  //  Calculate consensus coordinates
+  CalcConsensus();
+
+  //  Calculate relative and consensus-related scores
+  for (i=0;i<nStruct;i++)  {
+    B = 0.0;
+    for (j=0;j<S[i]->SD.nres;j++)  {
+      k = S[i]->SD.a[j].c0;
+      if (k>=0)  {
+        ix[k] = j;
+        sc[k] = True;
+        B    += S[i]->SD.Calpha[j]->GetDist2 ( xc[k],yc[k],zc[k] );
+      }
+    }
+    mx_rmsd  [i][i] = sqrt(B/Nalign);
+    mx_Qscore[i][i] = MatchQuality ( Nalign,S[i]->SD.nres,Nalign,B );
+    mx_seqId [i][i] = 1.0;
+    for (m=i+1;m<nStruct;m++)  {
+      B   = 0.0;
+      nid = 0.0;
+      for (j=0;j<S[m]->SD.nres;j++)  {
+        k = S[m]->SD.a[j].c0;
+        if (k>=0)  {
+          B += S[m]->SD.Calpha[j]->GetDist2 ( S[i]->SD.Calpha[ix[k]] );
+          if (!strcmp(S[m]->SD.Calpha[j]->GetResName(),
+                      S[i]->SD.Calpha[ix[k]]->GetResName()))  nid += 1.0;
+        }
+      }
+      mx_rmsd  [i][m] = sqrt(B/Nalign);
+      mx_Qscore[i][m] = MatchQuality ( Nalign,S[i]->SD.nres,
+                                              S[m]->SD.nres,B );
+      mx_seqId [i][m] = nid/realtype(Nalign);
+      mx_rmsd  [m][i] = mx_rmsd  [i][m];
+      mx_Qscore[m][i] = mx_Qscore[i][m];
+      mx_seqId [m][i] = mx_seqId [i][m];
+    }
+  }
+
+  //  Mark unoccupied consensus positions
+  for (i=0;i<maxNres;i++)
+    if (!sc[i])  {
+      xc[i] = -MaxReal;
+      yc[i] = -MaxReal;
+      zc[i] = -MaxReal;
+    }
+
+  //  Restore original coordinates
+  for (i=0;i<nStruct;i++)
+    S[i]->RestoreCoordinates();
+
+  FreeVectorMemory ( sc,0 );
+
+}
+
+
+namespace ssm  {
+
+  void ExpandSSEOut ( PPMSSEOutput & MSSEOutput, int nrows1,
+                      int ncols, int & nrows0 )  {
+  PPMSSEOutput M;
+  int           i,j;
+    M = new PMSSEOutput[nrows1];
+    for (i=0;i<nrows0;i++)
+      if (MSSEOutput[i])  {
+        M[i] = new ssm::MSSEOutput[ncols];
+        for (j=0;j<ncols;j++)
+          M[i][j].Copy ( MSSEOutput[i][j] );
+      } else
+        M[i] = NULL;
+    for (i=nrows0;i<nrows1;i++)
+      M[i] = NULL;
+    FreeMSOutput ( MSSEOutput,nrows0 );
+    MSSEOutput = M;
+    nrows0 = nrows1;
+  }
+
+}
+
+void ssm::MultAlign::GetMSSEOutput ( PPMSSEOutput & MSSEOutput,
+                                     int & nrows, int & ncols )  {
+ivector    nvert,ic1,ic2;
+bmatrix    d;
+int        i,j,j1,k,m,n,n0;
+PPVertex * GV;
+
+  FreeMSOutput ( MSSEOutput,nrows );
+
+  ncols = nStruct;
+  if (nStruct<=0)  return;
+
+  n0 = -1;
+  for (i=0;i<nStruct;i++)  {
+    j = S[i]->SD.G->GetNofVertices();
+    if (j>n0)  n0 = j;  // maximal number of vertices
+  }
+
+  if (n0<=0)  return;
+
+  GV = new PPVertex[nStruct];       // pointers to graph vertices
+  GetVectorMemory ( nvert,nStruct,0 ); // numbers of vertices
+  k = 0;
+  for (i=0;i<nStruct;i++)  {
+    GV   [i] = S[i]->SD.G->GetVertices   ();
+    nvert[i] = S[i]->SD.G->GetNofVertices();
+    if (nvert[i]>k)  k = nvert[i];
+  }
+  GetMatrixMemory ( d,nStruct,k,0,0 );
+  for (i=0;i<nStruct;i++)
+    for (j=0;j<k;j++)
+      d[i][j] = False;
+
+  n0 = 2*n0+1;   // maximal length of SSE output table
+  MSSEOutput = new PMSSEOutput[n0];
+  for (i=0;i<n0;i++)
+    MSSEOutput[i] = NULL;
+
+  //  allocate vertex cursors
+  GetVectorMemory ( ic1,nStruct,0 );
+  GetVectorMemory ( ic2,nStruct,0 );
+  for (j=0;j<nStruct;j++)
+    ic1[j] = 0;
+
+  // loop over all matched SSEs
+  nrows = 0;
+  for (i=1;i<=S[0]->nV;i++)  {
+    // find the number of leading unmatched SSEs
+    m = 0;
+    for (j=0;j<nStruct;j++)  {
+      ic2[j] = S[j]->F[i]-1;
+      j1     = i-1;
+      while (j1>=1)  {
+        k = S[j]->F[j1]-1;
+        if (!strcmp(GV[j][k]->GetChainID(),
+                    GV[j][ic2[j]]->GetChainID()))  {
+          ic1[j] = (ic2[j]+k)/2 + 1;
+          break;
+        } else
+          j1--;
+      }
+      if ((j1<1) && (i<=1))
+            n = ic2[j];
+      else  n = GV[j][ic2[j]]->GetVertexChainNo() -
+                GV[j][ic1[j]]->GetVertexChainNo();
+      m = IMax ( m,n );
+    }
+    // ith aligned vertex should be placed into (nrows+m)th position
+    n = nrows+m;
+    if (n+1>n0)  {
+//      n0 = n*3/2;
+      ExpandSSEOut ( MSSEOutput,n*3/2,ncols,n0 );
+    }
+    for (j=n;j>=nrows;j--)  {
+      MSSEOutput[j] = new ssm::MSSEOutput[nStruct];
+      for (j1=0;j1<nStruct;j1++)  {
+        MSSEOutput[j][j1].Init();
+        if (ic2[j1]>=ic1[j1])  {
+          MSSEOutput[j][j1].SetSSERange ( GV[j1][ic2[j1]] );
+          MSSEOutput[j][j1].aligned = (j==n);
+          d[j1][ic2[j1]] = True;
+        }
+        ic2[j1]--;
+      }
+    }
+    nrows = n+1;  // number of completed rows
+    // find the number of following unmatched SSEs
+    m = 0;
+    for (j=0;j<nStruct;j++)  {
+      ic1[j] = S[j]->F[i]-1;
+      n      = GV[j][ic1[j]]->GetVertexChainNo();
+      j1     = i+1;
+      while (j1<=S[0]->nV)  {
+        k = S[j]->F[j1]-1;
+        if (!strcmp(GV[j][k]->GetChainID(),
+                    GV[j][ic1[j]]->GetChainID()))  {
+          ic2[j] = (ic1[j]+k)/2;
+          n      = GV[j][ic2[j]]->GetVertexChainNo() - n;
+          break;
+        } else
+          j1++;
+      }
+      if (j1>S[0]->nV)  {
+        k = ic1[j]+1;
+        while (k<nvert[j])
+          if (strcmp(GV[j][k]->GetChainID(),
+                     GV[j][ic1[j]]->GetChainID()))  break;
+                                              else  k++;
+        ic2[j] = k-1;
+        n = ic2[j]-ic1[j];
+      }
+      m = IMax ( m,n );
+    }
+    n = nrows+m;
+    if (n>n0)  {
+//      n0 = n*3/2;
+      ExpandSSEOut ( MSSEOutput,n*3/2,ncols,n0 );
+    }
+    for (j=nrows;j<n;j++)  {
+      MSSEOutput[j] = new ssm::MSSEOutput[nStruct];
+      for (j1=0;j1<nStruct;j1++)  {
+        ic1[j1]++;
+        MSSEOutput[j][j1].Init();
+        if (ic1[j1]<=ic2[j1])  {
+          MSSEOutput[j][j1].SetSSERange ( GV[j1][ic1[j1]] );
+          d[j1][ic1[j1]] = True;
+        }
+      }
+    }
+    for (j1=0;j1<nStruct;j1++)
+      ic1[j1]++;
+    nrows = n;
+  }
+
+  k = nrows;
+  for (i=0;i<nStruct;i++)  {
+    n = nrows;
+    for (j=0;j<nvert[i];j++)
+      if (!d[i][j])  {
+        if (n>n0)  {
+//          n0 = n+nvert[i];
+          ExpandSSEOut ( MSSEOutput,n+nvert[i],ncols,n0 );
+        }
+        if (!MSSEOutput[n])  {
+          MSSEOutput[n] = new ssm::MSSEOutput[nStruct];
+          for (j1=0;j1<nStruct;j1++)
+            MSSEOutput[n][j1].Init();
+        }
+        MSSEOutput[n][i].SetSSERange ( GV[i][j] );
+        n++;
+        if (n>k)  k = n;
+      }
+  }
+  nrows = k;
+
+  if (nrows>0)  {
+    for (j=0;j<nStruct;j++)  {
+      MSSEOutput[0][j].loopNo = 1;
+      for (i=1;i<nrows;i++)
+        if (MSSEOutput[i][j].name1[0])  {
+          m = 0;
+          k = 0;
+          for (j1=0;(j1<i) && (!m);j1++)
+            if (MSSEOutput[j1][j].name1[0])  {
+              if (!strcmp(MSSEOutput[i][j].chID,
+                          MSSEOutput[j1][j].chID))
+                m = MSSEOutput[j1][j].loopNo;
+              else if (MSSEOutput[j1][j].loopNo>k)
+                k = MSSEOutput[j1][j].loopNo;
+            }
+          if (!m)  m = k+1;
+          MSSEOutput[i][j].loopNo = m;
+        } else
+          MSSEOutput[i][j].loopNo = MSSEOutput[i-1][j].loopNo;
+    }
+  }
+
+  if (GV)  delete[] GV;
+  FreeMatrixMemory ( d,nStruct,0,0 );
+  FreeVectorMemory ( nvert,0 );
+  FreeVectorMemory ( ic1,0 );
+  FreeVectorMemory ( ic2,0 );
+
+}
+
+namespace ssm  {
+
+  void ExpandMAOut ( PPMAOutput & MAOutput, int nrows1,
+                     int ncols, int & nrows0 )  {
+  PPMAOutput M;
+  int         i,j;
+    M = new PMAOutput[nrows1];
+    for (i=0;i<nrows0;i++)
+      if (MAOutput[i])  {
+        M[i] = new ssm::MAOutput[ncols];
+        for (j=0;j<ncols;j++)
+          M[i][j].Copy ( MAOutput[i][j] );
+      } else
+        M[i] = NULL;
+    for (i=nrows0;i<nrows1;i++)
+      M[i] = NULL;
+    FreeMSOutput ( MAOutput,nrows0 );
+    MAOutput = M;
+    nrows0   = nrows1;
+  }
+
+}
+
+void ssm::MultAlign::GetMAOutput ( PPMAOutput & MAOut,
+                                   int & nrows, int & ncols )  {
+ivector ic1,ic2;
+int     i,j,k,m,ic,n0;
+Boolean done;
+
+  FreeMSOutput ( MAOut,nrows );
+
+  ncols = nStruct;
+  if (nStruct<=0)  return;
+
+  SelectCalphas();
+
+  n0 = -1;
+  for (i=0;i<nStruct;i++)
+    if (S[i]->SD.nres>n0)
+      n0 = S[i]->SD.nres;
+
+  if (n0<=0)  {
+    DeselectCalphas();
+    return;
+  }
+
+  n0 = 2*n0+1;
+  MAOut = new PMAOutput[n0];
+  for (i=0;i<n0;i++)
+    MAOut[i] = NULL;
+
+  GetVectorMemory ( ic1,nStruct,0 );
+  GetVectorMemory ( ic2,nStruct,0 );
+  for (i=0;i<nStruct;i++)  {
+    ic1[i] = 0;  // structure cursors
+    ic2[i] = 0;  // structure cursors
+  }
+
+  nrows = 0;
+
+  do  {
+
+    done = False;
+
+    // Align last C-alphas in the gap to the begining of the block.
+    // Non-aligned C-alphas are skipped in all structures, and
+    // cursors ic2 are set to the first aligned row, which starts
+    // a block of aligned residues.
+    k  = 0; // k counts the maximal number of non-aligned residues
+            // between the bloacks.
+    ic = 0; // ic counts the number of structures for which cursors
+            // have run out of range
+    for (i=0;i<nStruct;i++)  {
+      j = ic1[i];
+      while (j<S[i]->SD.nres)
+        if (S[i]->SD.a[j].c<0)  j++;
+                          else  break;
+      if (j>=S[i]->SD.nres)  ic++;
+      m = j-ic1[i];
+      if (m>k)  k = m;
+      ic2[i] = j;  // cursor set on first aligned C-alpha in the block
+    }
+//    if (ic>=nStruct)  done = True;
+
+    if (ic>0)  done = True;  // quit if any cursor is out of range
+
+    if (!done)  {
+
+      if (k>0)  {
+        m      = nrows;
+        nrows += k;
+        if (nrows>n0)
+          ExpandMAOut ( MAOut,nrows*3/2,ncols,n0 );
+        for (i=m;i<nrows;i++)  {
+          MAOut[i] = new ssm::MAOutput[nStruct];
+          for (j=0;j<nStruct;j++)
+            MAOut[i][j].Init();
+        }
+        for (i=0;i<nStruct;i++)  {
+          j = ic2[i]-1;  // last non-aligned C-alpha before the block
+          k = nrows-1;   // and its position in the aligned table
+          while (j>=ic1[i])  {
+            MAOut[k][i].Fill(S[i]->SD.Calpha[j],S[i]->SD.G,False);
+            k--;
+            j--;
+          }
+        }
+      }
+
+      // align C-alphas in the block
+      k = MaxInt4;
+      ic = 0;
+      for (i=0;i<nStruct;i++)  {
+        ic1[i] = ic2[i];
+        j      = ic1[i];
+        while (j<S[i]->SD.nres)
+          if (S[i]->SD.a[j].c>=0)  j++;
+                            else  break;
+        if (j>=S[i]->SD.nres)  ic++;
+        m = j-ic1[i];
+        if ((m>=0) && (m<k))  k = m;
+      }
+      // quit only if all cursors ran to the end
+      if (ic>=nStruct)  done = True;
+//      if (ic>0)  done = True;
+      if (k>0)  {
+        m = nrows+k;
+        if (m>n0)
+          ExpandMAOut ( MAOut,m*3/2,ncols,n0 );
+        for (i=nrows;i<m;i++)  {
+          MAOut[i] = new MAOutput[nStruct];
+          for (j=0;j<nStruct;j++)
+            MAOut[i][j].Init();
+        }
+        for (i=0;i<nStruct;i++)  {
+          j = ic1[i];
+          ic2[i] = IMin(S[i]->SD.nres,j+k);
+          m = nrows;
+          for (j=ic1[i];j<ic2[i];j++)  {
+            MAOut[m][i].Fill ( S[i]->SD.Calpha[j],S[i]->SD.G,True );
+            m++;
+          }
+          ic1[i] = ic2[i];
+        }
+        nrows += k;
+      }
+
+    }
+
+    // align C-alphas in the following gap to the end of the block
+    k = 0;
+    ic = 0;
+    for (i=0;i<nStruct;i++)  {
+      j = ic1[i];
+      while (j<S[i]->SD.nres)
+        if (S[i]->SD.a[j].c<0)  j++;
+                          else  break;
+      if (j>=S[i]->SD.nres)  ic++;
+                       else  j = mround((j+ic1[i]+0.25)/2.0);
+      m = j-ic1[i];
+      if (m>k)  k = m;
+      ic2[i] = j;  // cursor set on between the aligned blocks
+    }
+//    if (ic>=nStruct)  done = True;
+    if (ic>0)  done = True;   // quit if any cursor is out of range
+    if (k>0)  {
+      m      = nrows;
+      nrows += k;
+      if (nrows>n0)
+        ExpandMAOut ( MAOut,nrows*3/2,ncols,n0 );
+      for (i=m;i<nrows;i++)  {
+        MAOut[i] = new MAOutput[nStruct];
+        for (j=0;j<nStruct;j++)
+          MAOut[i][j].Init();
+      }
+      for (i=0;i<nStruct;i++)  {
+        k = m;
+        for (j=ic1[i];j<ic2[i];j++)  {
+          MAOut[k][i].Fill ( S[i]->SD.Calpha[j],S[i]->SD.G,False );
+          k++;
+        }
+        ic1[i] = ic2[i];
+      }
+    }
+
+  } while (!done);
+
+  FreeVectorMemory ( ic1,0 );
+  FreeVectorMemory ( ic2,0 );
+
+  DeselectCalphas();
+
+}
+
+
+void ssm::MultAlign::WriteMultAlign ( RCFile f )  {
+PPMAOutput MAOut;
+char       L[100],SS[4];
+int        nrows,ncols, i,j;
+
+  MAOut = NULL;
+  nrows = 0;
+  ncols = 0;
+  GetMAOutput ( MAOut,nrows,ncols );
+
+  f.Write ( " " );
+  for (i=0;i<nStruct;i++)  {
+    if (i>0)  f.Write ( "| |" );
+    sprintf ( L,"    %4s    ",S[i]->G->GetGraphName() );
+    f.Write ( L );
+  }
+  f.LF();
+  f.Write ( " " );
+  for (i=0;i<nStruct;i++)  {
+    if (i>0)  f.Write ( "+-+" );
+      f.Write ( "------------" );
+  }
+  f.LF();
+
+  for (i=0;i<nrows;i++)  {
+    f.Write ( " " );
+    for (j=0;j<ncols;j++)  {
+      if (j>0)  {
+        if (MAOut[i][j].aligned)  f.Write ( "|*|" );
+                            else  f.Write ( "| |" );
+      }
+      if (MAOut[i][j].name[0]) {
+        if (MAOut[i][j].sseType==V_HELIX)
+             strcpy ( SS,"H|" );
+        else if (MAOut[i][j].sseType==V_STRAND)
+             strcpy ( SS,"S|" );
+        else strcpy ( SS,"  " );
+        sprintf ( L,"%2s%1s:%3s%4i%1s",SS,MAOut[i][j].chID,
+                  MAOut[i][j].name,MAOut[i][j].seqNum,
+                  MAOut[i][j].insCode );
+      } else
+        strcpy ( L,"            " );
+      f.Write ( L );
+    }
+    f.LF();
+  }
+
+  f.Write ( " " );
+  for (i=0;i<nStruct;i++)  {
+    if (i>0)  f.Write ( "'-'" );
+      f.Write ( "------------" );
+  }
+  f.LF();
+
+  FreeMSOutput ( MAOut,nrows );
+
+}
+
+
+int  ssm::MultAlign::AlignCalphas()  {
+//   Given the results of multiple graph matching, this function
+// calculates the multiple superposition of C-alphas.
+int rc;
+
+  //  1. Obtain first approximation to optimal superposition
+  rc = MakeFirstGuess();
+
+  if (rc==MALIGN_Ok)  {
+
+    //  2. Iteratively improve C-alpha alignments
+    OptimizeAlignments();
+
+    //  3. Restore original order of structures
+    SortStructures();
+
+    //  4. Calculate consensus scores
+    CalcConsensusScores();
+
+  }
+
+  DeselectCalphas();
+
+  return rc;
+
+}
+
+void  ssm::MultAlign::getAlignScores ( int      & n_align,
+                                       int      & n_SSEs,
+                                       realtype & rmsd,
+                                       realtype & Qscore )  {
+  n_align = Nalign;        // number of multuply-aligned rows
+  n_SSEs  = nSSEalign;     // number of aligned SSEs
+  rmsd    = rmsd_achieved; // achieved RMSD
+  Qscore  = Q_achieved;    // achieved Q
+}
+
+void  ssm::MultAlign::getConsensusScores ( rvector & cons_x,
+                                           rvector & cons_y,
+                                           rvector & cons_z,
+                                           int     & cons_len,
+                                           rmatrix & m_rmsd,
+                                           rmatrix & m_Qscore,
+                                           rmatrix & m_seqId )  {
+//  The function does not allocate the vectors, it simply
+// returns pointers to the internal fields:
+// cons_x,y,z[0..conslen-1], m_rmsd,Qscore[0..nStruct][0..nStruct]
+  cons_x   = xc;
+  cons_y   = yc;
+  cons_z   = zc;
+  cons_len = maxNres;
+  m_rmsd   = mx_rmsd;
+  m_Qscore = mx_Qscore;
+  m_seqId  = mx_seqId;
+}
+
+int   ssm::MultAlign::getNres ( int structNo )  {
+  if ((structNo<0) || (structNo>=nStruct))  return 0;
+  if (S[structNo])  return S[structNo]->SD.nres;
+  return 0;
+}
+
+Boolean ssm::MultAlign::getAlignment ( int structNo, ivector & Ca,
+                                       int & nres )  {
+int i;
+  FreeVectorMemory ( Ca,0 );
+  nres = 0;
+  if ((structNo<0) || (structNo>=nStruct))  return False;
+  if (S[structNo])  {
+    if (S[structNo]->SD.a)  {
+      nres = S[structNo]->SD.nres;
+      GetVectorMemory ( Ca,nres,0 );
+      for (i=0;i<nres;i++)
+        Ca[i] = S[structNo]->SD.a[i].c0;
+      return True;
+    }
+  }
+  return False;
+}
+
+Boolean ssm::MultAlign::getTMatrix ( mat44 & TMatrix, int structNo )  {
+  if ((structNo>=0) && (structNo<nStruct))  {
+    if (S[structNo])  {
+      Mat4Copy ( S[structNo]->RT0,TMatrix );
+      return True;
+    }
+  }
+  Mat4Init ( TMatrix );
+  return False;
+}
+
+void  ssm::MultAlign::read  ( RCFile )  {
+}
+
+void  ssm::MultAlign::write ( RCFile )  {
+}
+
+
+
diff --git a/ssm_malign.h b/ssm_malign.h
new file mode 100644
index 0000000..4710cd1
--- /dev/null
+++ b/ssm_malign.h
@@ -0,0 +1,313 @@
+// $Id: ssm_malign.h,v 1.5 2006/06/14 15:13:06 keb Exp $
+// =================================================================
+//
+//    10.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//  ----------------------------------------------------------------
+//
+//  **** Module  :  SSM_MAlign <interface>
+//       ~~~~~~~~~
+//  **** Project :  SSM
+//       ~~~~~~~~~
+//  **** Classes :  CSSMMultAlign
+//       ~~~~~~~~~
+//
+//  E. Krissinel, 2003-2013
+//
+// =================================================================
+//
+
+#ifndef  __SSM_MAlign__
+#define  __SSM_MAlign__
+
+#include "mmdb/mmdb_manager.h"
+
+#include "ssm_csia.h"
+#include "ssm_superpose.h"
+
+
+namespace ssm  {
+
+  // --------------------------- SMAStruct ---------------------------
+
+  DefineStructure(MAStruct);
+
+  struct MAStruct  {
+
+    SuperposeData  SD;  //!< data for pairwise superposition
+    PGraph          G;  //!< reduceable copy of SSE graph
+    rvector         P;  //!< SSE matching probabilities
+    rvector         Q;  //!< SSE matching scores
+    ivector         F;  //!< original vertex numbering
+    int           sNo;  //!< serial number of the structure
+    int            nV;  //!< number of vertices in G
+    int             n;  //!< number of non-zero SSE matchings
+    int       nSAlloc;  //!< memory allocation size
+    mat44          RT;  //!< rotation-translation matrix
+    mat44         RT0;  //!< best rotation-translation matrix
+    realtype     Qsum;  //!< sum of Q-scores with other structures
+    rvector        x0;  //!< original C-alpha X-coordinates
+    rvector        y0;  //!< original C-alpha Y-coordinates
+    rvector        z0;  //!< original C-alpha Z-coordinates
+    realtype xm,ym,zm;  //!< center of mass
+    realtype cx,cy,cz;  //!< consensus center of mass
+
+    int        nalign;  //!< number of aligned residues
+    realtype    Rmsd0;  //!< parameter of Q-score
+
+    void    Init ( PCMMDBManager MMDB, PGraph graph,
+                   int serNo, int nStruct );
+    void    Set  ( PCMMDBManager MMDB, PGraph graph,
+                   int serNo, int nStruct );
+    void    PrepareSSEMatching();
+    Boolean Refine            ( int maxdel, realtype P0,
+                                ivector v1, ivector v2 );
+    void    Transform         ();
+    void    SaveCoordinates   ();
+    void    RestoreCoordinates();
+    void    CalcCorrelationMatrix ( rmatrix & A, rvector xc,
+                                    rvector  yc, rvector zc );
+    void    CalcTranslation   ();
+    void    GetDirection      ( int atompos, vect3 & v );
+    Boolean isMC              ( int pos1, PMAStruct S, int pos2 );
+    void    Dispose           ();
+
+  };
+
+
+  // ----------------------------  MSSEOutput -------------------------
+
+  DefineStructure(MSSEOutput);
+
+  struct MSSEOutput {
+    ResName  name1,name2;
+    ChainID  chID;
+    int      seqNum1,seqNum2;
+    int      sseType,loopNo;
+    InsCode  insCode1,insCode2;
+    Boolean  aligned;
+    void  Init        ();
+    void  SetSSERange ( PVertex     V );
+    void  Copy        ( RMSSEOutput M );
+    void  write       ( RCFile f );
+    void  read        ( RCFile f );
+  };
+
+
+  // ----------------------------  SMAOutput -------------------------
+
+  DefineStructure(MAOutput);
+
+  struct MAOutput {
+    ResName  name;
+    ChainID  chID;
+    int      seqNum;
+    int      sseType;
+    InsCode  insCode;
+    realtype rmsd;      // not used
+    Boolean  aligned;
+    void  Init  ();
+    void  Fill  ( PCAtom A, PGraph G, Boolean align );
+    void  Copy  ( RMAOutput M );
+    void  write ( RCFile f );
+    void  read  ( RCFile f );
+  };
+
+  extern void FreeMSOutput ( PPMAOutput   & MAOut,   int & nrows );
+  extern void FreeMSOutput ( PPMSSEOutput & MSSEOut, int & nrows );
+
+  // ---------------------------  CPAMatch ---------------------------
+
+  DefineClass(PAMatch);
+
+  class PAMatch  {
+
+    public :
+      ivector  F1,F2;
+      rvector  Q;
+      realtype Qscore;
+      int      mlen;
+
+      PAMatch();
+      ~PAMatch();
+
+      void   FreeMemory();
+      void    Set      ( ivector v1, ivector v2, int matchlen,
+                         realtype matchQ, rvector SSEQ );
+      Boolean GetMatch ( ivector v1, ivector v2, int matchlen,
+                         realtype & matchQ, rvector SSEQ );
+  };
+
+
+  // --------------------------  PAMatches --------------------------
+
+  DefineClass(PAMatches);
+
+  class PAMatches  {
+
+    public :
+      PPPAMatch PA;
+      int       nMatches;
+      int       nBest;
+
+      PAMatches ();
+      ~PAMatches();
+
+      int  AddMatch ( ivector v1, ivector v2, int matchlen,
+                      realtype matchQ, rvector SSEQ );
+      int  GetMatch ( ivector v1, ivector v2, int matchlen,
+                      realtype & matchQ, rvector SSEQ );
+      void SetBestMatch ( int mNo );
+      realtype GetBestQscore();
+      void GetBestMatch ( ivector & v1, ivector & v2, int & matchlen );
+
+    private :
+      int nAlloc;
+
+  };
+
+
+  // ----------------------------  MAMap ----------------------------
+
+ DefineStructure(MAMap);
+
+  struct MAMap  {
+    realtype rmsd;
+    ivector  map;   // 0:i is mapped onto j:SMAMap[i].map[j]
+    void Init   ( int nStruct );
+    void Dispose();
+  };
+
+
+  // ---------------------------  MultAlign -------------------------
+
+  typedef void MAProgressFunc ( void * UserData, int stagekey,
+                                int progress );
+  typedef MAProgressFunc * PMAProgressFunc;
+
+  DefineClass(MultAlign);
+  DefineStreamFunctions(MultAlign)
+
+  class MultAlign : public CStream  {
+
+    public :
+
+      MultAlign ();
+      MultAlign ( RPCStream Object );
+      ~MultAlign();
+
+      void  setProgressFunction  ( void * UserData,
+                                   PMAProgressFunc Fnc );
+
+      int   align ( PPCMMDBManager MMDB, psvector selstring,
+                    PPGraph Graph, int  nStructures );
+
+      inline int getMaxNofIter() { return maxIter; }
+
+      void  getAlignScores     ( int & n_align, int & n_SSEs,
+                                 realtype & rmsd, realtype & Qscore );
+      void  getConsensusScores ( rvector & cons_x,
+                                 rvector & cons_y,
+                                 rvector & cons_z,
+                                 int     & cons_len,
+                                 rmatrix & m_rmsd,
+                                 rmatrix & m_Qscore,
+                                 rmatrix & m_seqId );
+
+      int     getNres      ( int structNo );
+      Boolean getAlignment ( int structNo, ivector & Ca, int & nres );
+      Boolean getTMatrix   ( mat44 & TMatrix, int structNo );
+
+      void   GetMAOutput   ( PPMAOutput & MAOut,
+                             int & nrows, int & ncols );
+      void   GetMSSEOutput ( PPMSSEOutput & MSSEOut,
+                             int & nrows, int & ncols );
+
+      void  WriteMultAlign   ( RCFile f );
+      void  WriteSuperposed  ( cpstr fileName );
+
+      void  WriteMatchedSSEs ( RCFile f, Boolean shortTable=False );
+
+      void  read  ( RCFile f );
+      void  write ( RCFile f );
+
+    protected :
+      PPMAStruct      S; //!< molecular structure data
+      PPPAMatches  * PM; //!< pairwise matches database
+      int       nStruct; //!< number of structures
+
+      PMAProgressFunc ProgressFunc;
+      void *          ProgFuncData;
+
+      rvector        vq; //!< working array  [1..maxNV]
+      ivector     v1,v2; //!< working arrays [1..maxNV]
+      int         maxNV; //!< maximal number of vertices
+
+      PRECISION    precision;    //!< SSE matching specificity
+      CONNECTIVITY connectivity; //!< SSE matching connectivity flag
+
+      realtype  minCont; //!< minimal contact distance
+      realtype  maxCont; //!< maximal contact distance
+      realtype    Rmsd0; //!< parameter of Q-score
+      int       minIter; //!< minimal number of iterations
+      int       maxIter; //!< minimal number of iterations
+      int   maxHollowIt; //!< maximal allowed number of consequtive
+                         /// iterations without quality improvement
+
+      rmatrix     A,Z,V; //!< corr-n matrix, left and right SVD vectors
+      rvector         W; //!< singular values
+
+      PMAMap        Map; //!< Map maps 0:i<->j:Map[i].map[j]
+
+      int             Nalign; //!< number of multuply-aligned rows
+      int    minNres,maxNres;
+      int          nSSEalign; //!< number of multiply-aligned SSEs
+      realtype rmsd_achieved; //!< achieved RMSD
+      realtype    Q_achieved; //!< achieved Q
+
+      rvector        xc;  //!< consensus X-coordinates
+      rvector        yc;  //!< consensus Y-coordinates
+      rvector        zc;  //!< consensus Z-coordinates
+      rmatrix   mx_rmsd;  //!< matrix of inter-structure rmsds
+      rmatrix mx_Qscore;  //!< matrix of inter-structure Q-scores
+      rmatrix  mx_seqId;  //!< matrix of inter-structure seq identities
+
+      GraphMatch U;
+      Superpose  superpose;
+
+      void     InitMultAlign      ();
+      void     FreeMemory         ();
+      void     DeleteStructures   ();
+      void     DeselectCalphas    ();
+      void     SelectCalphas      ();
+      void     DeletePAMatches    ();
+      void     DeleteMap          ();
+      void     AllocateMap        ();
+      void     printStats         ();
+      void     AlignSSEs          ();
+      void     GetSSEMatchingStats();
+      void     GetBestMatch       ( PMAStruct S1, PMAStruct S2 );
+      Boolean  RefineGraphs       ();
+      int      MakeFirstGuess     ();
+      void     CalcRMSD           ( int mappos   );
+      Boolean  EvaluateMapping    ( PCMContact C );
+      void     CorrespondContacts ( realtype contDist );
+      void     CalcConsensus      ();
+      realtype MatchQuality2      ( int Nalgn, realtype dist2 );
+      realtype MatchQuality       ( int Nalgn, int N1, int N2,
+                                               realtype dist2 );
+      int      OptimizeAlignments ();
+      void     SortStructures     ();
+      void     CalcConsensusScores();
+      int      AlignCalphas       ();
+      int      CalcRotation       ( mat44 & R );
+
+    protected :
+      int Map_nrows;     // number of rows in Map;
+      int nStructAlloc;  // allocated number of structures
+
+  };
+
+}
+
+#endif
diff --git a/ssm_superpose.cpp b/ssm_superpose.cpp
index 8147d09..32ad8dc 100644
--- a/ssm_superpose.cpp
+++ b/ssm_superpose.cpp
@@ -1,4 +1,4 @@
-// $Id: ssm_superpose.cpp,v 1.7 2011/11/21 16:56:16 ekr Exp $
+// $Id: ssm_superpose.cpp,v 1.2 2008/07/08 15:51:03 keb Exp $
 // =================================================================
 //
 //    26.06.06   <--  Date of Last Modification.
@@ -24,13 +24,13 @@
 //  =================================================================
 
 
-Boolean SSpAtom::CompatibleSSE ( RSSpAtom a )  {
+Boolean ssm::SpAtom::CompatibleSSE ( RSpAtom a )  {
   if (sse==V_HELIX)   return  (a.sse==V_HELIX);
   return (a.sse!=V_HELIX);
 }
 
 
-void SSectionDist::Copy ( RSSectionDist D )  {
+void ssm::SectionDist::Copy ( RSectionDist D )  {
   dist      = D.dist;
   rmsd      = D.rmsd;
   cosine    = D.cosine;
@@ -50,7 +50,7 @@ void SSectionDist::Copy ( RSSectionDist D )  {
 
 //  ==================================================================
 
-void SSSEDesc::Transform ( mat44 & T )  {
+void ssm::SSEDesc::Transform ( mat44 & T )  {
   x1 = T[0][0]*xs1 + T[0][1]*ys1 + T[0][2]*zs1 + T[0][3];
   y1 = T[1][0]*xs1 + T[1][1]*ys1 + T[1][2]*zs1 + T[1][3];
   z1 = T[2][0]*xs1 + T[2][1]*ys1 + T[2][2]*zs1 + T[2][3];
@@ -59,7 +59,7 @@ void SSSEDesc::Transform ( mat44 & T )  {
   z2 = T[2][0]*xs2 + T[2][1]*ys2 + T[2][2]*zs2 + T[2][3];
 }
 
-void SSSEDesc::CalcScore ( RSSSEDesc D )  {
+void ssm::SSEDesc::CalcScore ( RSSEDesc D )  {
 // Don't change this procedure without appropriate changing
 // ChooseFirstRotation().
 realtype dx,dy,dz;
@@ -142,10 +142,10 @@ int      i;
   dl2 = dl2*dl2*vl2;
 
   return  dr2 + dl2;
-  
+
 }
 
-realtype SSSEDesc::Cosine ( RSSSEDesc D )  {
+realtype ssm::SSEDesc::Cosine ( RSSEDesc D )  {
 realtype dx1,dy1,dz1, dx2,dy2,dz2, d1,d2,r;
 
   dx1 = x2 - x1;
@@ -164,7 +164,7 @@ realtype dx1,dy1,dz1, dx2,dy2,dz2, d1,d2,r;
 
 }
 
-void SSSEDesc::Copy ( RSSSEDesc D )  {
+void ssm::SSEDesc::Copy ( RSSEDesc D )  {
   x1  = D.x1;    y1  = D.y1;    z1  = D.z1;
   x2  = D.x2;    y2  = D.y2;    z2  = D.z2;
   xs1 = D.xs1;   ys1 = D.ys1;   zs1 = D.zs1;
@@ -185,7 +185,7 @@ void SSSEDesc::Copy ( RSSSEDesc D )  {
 
 //  ==================================================================
 
-CSuperpose::CSuperpose()  {
+ssm::Superpose::Superpose()  {
   InitSuperpose();
   GetMatrixMemory ( A  ,3,3,1,1 );
   GetMatrixMemory ( U  ,3,3,1,1 );
@@ -194,7 +194,7 @@ CSuperpose::CSuperpose()  {
   GetVectorMemory ( RV1,3,1     );
 }
 
-CSuperpose::~CSuperpose()  {
+ssm::Superpose::~Superpose()  {
   FreeMemory();
   FreeMatrixMemory ( A  ,3,1,1 );
   FreeMatrixMemory ( U  ,3,1,1 );
@@ -209,7 +209,7 @@ CSuperpose::~CSuperpose()  {
 
 
 
-void CSuperpose::InitSuperpose()  {
+void ssm::Superpose::InitSuperpose()  {
 
   Rmsd0         = 3.0;   // quality optimization parameter
   minContact    = 3.0;   // minimal Calpha-pair contact parameter
@@ -271,7 +271,7 @@ void CSuperpose::InitSuperpose()  {
 
 }
 
-void CSuperpose::FreeMemory()  {
+void ssm::Superpose::FreeMemory()  {
 int i;
 
   if (a1)  {
@@ -315,46 +315,46 @@ int i;
 
 }
 
-void CSuperpose::SetAllowMC ( Boolean allowMisconnections )  {
+void ssm::Superpose::SetAllowMC ( Boolean allowMisconnections )  {
   allowMC = allowMisconnections;
 }
 
-void CSuperpose::SetIterationLimits ( int iter_max, int iter_min,
+void ssm::Superpose::SetIterationLimits ( int iter_max, int iter_min,
                                       int max_hollow )  {
   iterMax     = iter_max;
   iterMin     = iter_min;
   maxHollowIt = max_hollow;
 }
 
-void  CSuperpose::SetCaSelections ( pstr selection1,
-                                    pstr selection2 )  {
+void  ssm::Superpose::SetCaSelections ( cpstr selection1,
+                                        cpstr selection2 )  {
   CreateCopy ( selString1,selection1 );
   CreateCopy ( selString2,selection2 );
 }
 
-void  CSuperpose::GetTMatrix ( mat44 & TMat )  {
+void  ssm::Superpose::GetTMatrix ( mat44 & TMat )  {
 int i,j;
   for (i=0;i<4;i++)
     for (j=0;j<4;j++)
       TMat[i][j] = TMatrix[i][j];
 }
 
-mat44 * CSuperpose::GetTMatrix()  {
+mat44 * ssm::Superpose::GetTMatrix()  {
   return &TMatrix;
 }
 
-realtype CSuperpose::GetRMSD()  {
+realtype ssm::Superpose::GetRMSD()  {
   if (a1 && a2)  return rmsd_achieved;
            else  return -1.0;
 }
 
-int  CSuperpose::GetNAlign()  {
+int  ssm::Superpose::GetNAlign()  {
   if (a1 && a2)  return nalgn;
            else  return -1;
 }
 
 
-void  CSuperpose::GetSuperposition ( ivector  & Ca1  ,
+void  ssm::Superpose::GetSuperposition ( ivector  & Ca1  ,
                                      rvector  & dist1,
                                      int      & nCa1 ,
                                      ivector  & Ca2  ,
@@ -424,44 +424,44 @@ int i,j;
 }
 
 
-void CSuperpose::GetCalphas1 ( PPCAtom & Calpha, int & numRes )  {
+void ssm::Superpose::GetCalphas1 ( PPCAtom & Calpha, int & numRes )  {
   Calpha = Calpha1;
   numRes = nres1;
 }
 
-void CSuperpose::GetCalphas2 ( PPCAtom & Calpha, int & numRes )  {
+void ssm::Superpose::GetCalphas2 ( PPCAtom & Calpha, int & numRes )  {
   Calpha = Calpha2;
   numRes = nres2;
 }
 
 
-void CSuperpose::GetSSEDesc1 ( RPSSSEDesc SSEDesc, int & numSSEs )  {
+void ssm::Superpose::GetSSEDesc1 ( RPSSEDesc sseDesc, int & numSSEs )  {
 int i;
-  if (SSEDesc)  delete[] SSEDesc;
-  SSEDesc = new SSSEDesc[nSSEs1];
+  if (sseDesc)  delete[] sseDesc;
+  sseDesc = new SSEDesc[nSSEs1];
   for (i=0;i<nSSEs1;i++)
-    SSEDesc[i].Copy ( SSED1[i] );
+    sseDesc[i].Copy ( SSED1[i] );
   numSSEs = nSSEs1;
 }
 
-PSSSEDesc CSuperpose::GetSSEDesc1()  {
+ssm::PSSEDesc ssm::Superpose::GetSSEDesc1()  {
   return SSED1;
 }
 
-void CSuperpose::GetSSEDesc2 ( RPSSSEDesc SSEDesc, int & numSSEs )  {
+void ssm::Superpose::GetSSEDesc2 ( RPSSEDesc sseDesc, int & numSSEs )  {
 int i;
-  if (SSEDesc)  delete[] SSEDesc;
-  SSEDesc = new SSSEDesc[nSSEs2];
+  if (sseDesc)  delete[] sseDesc;
+  sseDesc = new SSEDesc[nSSEs2];
   for (i=0;i<nSSEs2;i++)
-    SSEDesc[i].Copy ( SSED2[i] );
+    sseDesc[i].Copy ( SSED2[i] );
   numSSEs = nSSEs2;
 }
 
-PSSSEDesc CSuperpose::GetSSEDesc2()  {
+ssm::PSSEDesc ssm::Superpose::GetSSEDesc2()  {
   return SSED2;
 }
 
-void CSuperpose::GetSuperposedSSEs ( ivector v1, ivector v2,
+void ssm::Superpose::GetSuperposedSSEs ( ivector v1, ivector v2,
                                      int & nSupSSEs )  {
 int i;
   nSupSSEs = 0;
@@ -473,11 +473,11 @@ int i;
     }
 }
 
-int  CSuperpose::CalculateTMatrix()  {
+int  ssm::Superpose::CalculateTMatrix()  {
 realtype det,B;
 int      i,j,k;
 
-  det = A[1][1]*A[2][2]*A[3][3] + 
+  det = A[1][1]*A[2][2]*A[3][3] +
         A[1][2]*A[2][3]*A[3][1] +
         A[2][1]*A[3][2]*A[1][3] -
         A[1][3]*A[2][2]*A[3][1] -
@@ -592,13 +592,13 @@ int        i,j,k;
   }
 }
 
-int  CSuperpose::SuperposeSSGraphs ( PCSSGraph G1, ivector F1,
-                                     PCSSGraph G2, ivector F2,
-                                     int matchlen )  {
+int  ssm::Superpose::SuperposeSSGraphs ( PGraph G1, ivector F1,
+                                         PGraph G2, ivector F2,
+                                         int matchlen )  {
 PCBFGSMin  BFGS;
 SMinTFunc  SMTF;
-PCSSVertex Vx;
-mat33      erm,trm;
+PVertex    Vx;
+//mat33      erm,trm;
 vect3      v1,v2;
 realtype   T[7],TypT[7];
 realtype   B,B1, x01,y01,z01, x02,y02,z02, mass,mass1,mass2;
@@ -741,6 +741,7 @@ Boolean    AddEdges1,AddEdges2;
 
   SMTF.Dispose();
 
+  /*
   GetEulerRotMatrix ( erm,T[4],T[5],T[6] );
 
   for (i=0;i<3;i++)
@@ -750,6 +751,7 @@ Boolean    AddEdges1,AddEdges2;
         B += erm[i][k]*TMatrix[k][j];
       trm[i][j] = B;
     }
+*/
 
   TMatrix[0][3] = x02 - TMatrix[0][0]*x01 - TMatrix[0][1]*y01 -
                         TMatrix[0][2]*z01 - T[1];
@@ -766,10 +768,10 @@ Boolean    AddEdges1,AddEdges2;
 }
 
 
-void CSuperpose::SelectCalphas ( PCMMDBManager MMDB, PCSSGraph G,
-                                 PPCAtom & Calpha, PSSpAtom & a,
-                                 int & nres, int & selHnd,
-                                 int selInclHnd, pstr selString )  {
+void ssm::Superpose::SelectCalphas ( PCMMDBManager MMDB, PGraph G,
+                                     PPCAtom & Calpha, PSpAtom & a,
+                                     int & nres, int & selHnd,
+                                     int selInclHnd, cpstr selString ) {
 int i;
 
   if (a && (driverID!=2))  {
@@ -784,7 +786,7 @@ int i;
 
   if (nres>0)  {
     if (!a)  {
-      a = new SSpAtom[nres];
+      a = new SpAtom[nres];
       for (i=0;i<nres;i++)  {
         strcpy ( a[i].chID,Calpha[i]->GetChainID() );
         a[i].sse   = V_UNKNOWN;
@@ -810,18 +812,18 @@ int i;
 }
 
 
-void CSuperpose::MapSSEs ( PPCAtom Calpha, PSSpAtom a, int nres,
-                           PCSSGraph G, RPSSSEDesc SSED,
-                           int & nSSEs )  {
+void ssm::Superpose::MapSSEs ( PPCAtom Calpha, PSpAtom a, int nres,
+                               PGraph G, RPSSEDesc SSED,
+                               int & nSSEs )  {
 //  Returns vector SSED.pos containing the origin of SSE sequences in
 //  array a, and vector SSED.len containing the SSEs' lengths.
 //  nSSEs returns the number of SSEs.
-PCSSVertex V;
-ChainID    chID;
-int        initSeqNum,endSeqNum,seqNum;
-InsCode    initICode,endICode;
-pstr       iCode;
-int        i,j,vtype,k, p1,p2, c1,c2;
+PVertex  V;
+ChainID  chID;
+int      initSeqNum,endSeqNum,seqNum;
+InsCode  initICode,endICode;
+pstr     iCode;
+int      i,j,vtype,k, p1,p2, c1,c2;
 
   if (SSED && (driverID!=2))  {
     delete[] SSED;
@@ -833,8 +835,8 @@ int        i,j,vtype,k, p1,p2, c1,c2;
 
   if (!SSED)  {
 
-    SSED = new SSSEDesc[nSSEs];
-  
+    SSED = new SSEDesc[nSSEs];
+
     for (i=1;i<=nSSEs;i++)  {
       G->GetVertexRange ( i,chID,initSeqNum,initICode,
                                  endSeqNum,endICode );
@@ -851,7 +853,7 @@ int        i,j,vtype,k, p1,p2, c1,c2;
           iCode  = Calpha[j]->GetInsCode();
           if ((p1<0) && (initSeqNum==seqNum) &&
               (!strcmp(initICode,iCode)))    p1 = j;
-          if ((p2<0) && (endSeqNum==seqNum) && 
+          if ((p2<0) && (endSeqNum==seqNum) &&
               (!strcmp(endICode,iCode)))     p2 = j;
         }
       }
@@ -922,10 +924,10 @@ int        i,j,vtype,k, p1,p2, c1,c2;
 }
 
 
-void  CSuperpose::IdentifyUnmatchedSSEs ( ivector & FH, int & nFH,
+void  ssm::Superpose::IdentifyUnmatchedSSEs ( ivector & FH, int & nFH,
                                           ivector & FS, int & nFS,
                                           ivector F, int mlen,
-                                          PCSSGraph G )  {
+                                          PGraph G )  {
 int i,j,k,nSSEs;
 
   FreeVectorMemory ( FH,1 );
@@ -951,8 +953,8 @@ int i,j,k,nSSEs;
 }
 
 
-void  CSuperpose::CalcDistance ( int SSE1, int SSE2,
-                                 RSSectionDist D )  {
+void  ssm::Superpose::CalcDistance ( int SSE1, int SSE2,
+                                 RSectionDist D )  {
 //    Calculates the minimal distance between SSEs number SSE1
 //  and SSE2 from pos1 to pos1+len1-1 and pos2 to pos2+len2-1,
 //  as given in the SSE description arrays, SSED1 and SSED2,
@@ -1073,7 +1075,7 @@ int      p1,p2;
 }
 
 
-void  CSuperpose::AlignSSEs ( RSSectionDist D, int unmap )  {
+void  ssm::Superpose::AlignSSEs ( RSectionDist D, int unmap )  {
 //    Makes correspondence between sections of atoms in arrays Calpha1
 //  and Calpha2 from pos1 to pos1+len1-1 and pos2 to pos2+len2-1,
 //  respectively using data obtained from calcDistance.
@@ -1140,7 +1142,7 @@ int  i1,i2, c1;
 
 }
 
-Boolean  CSuperpose::isMC ( int pos1, int pos2 )  {
+Boolean  ssm::Superpose::isMC ( int pos1, int pos2 )  {
 //   Returns True if matching the Calpha pair in the positions
 // (pos1,pos2) of the chains would contradict to the already
 // aligned pairs and allowMC is set False.
@@ -1176,7 +1178,7 @@ int i;
 
 }
 
-void  CSuperpose::CorrespondSSEs ( ivector F1, int nF1,
+void  ssm::Superpose::CorrespondSSEs ( ivector F1, int nF1,
                                    ivector F2, int nF2,
                                    realtype rmsd_est )  {
 realtype rmsd,rmsd2;
@@ -1194,7 +1196,7 @@ int      i,j, k1,k2, i1,j1;
           (SSED1[k1].classID==SSED2[k2].classID) &&
           (!isMC(SSED1[k1].pos,SSED2[k2].pos)))  {
         CalcDistance ( F1[i],F2[j],SDist[i1][j1] );
-        if ((SDist[i1][j1].na<=0) || 
+        if ((SDist[i1][j1].na<=0) ||
             (SDist[i1][j1].cosine<minCosine) ||
             (SDist[i1][j1].rmsd>rmsd2))
           SDist[i1][j1].rmsd = -1.0;
@@ -1227,7 +1229,7 @@ int      i,j, k1,k2, i1,j1;
 }
 
 
-void  CSuperpose::ExpandContact ( RSContact c, int & ip, int & im,
+void  ssm::Superpose::ExpandContact ( RSContact c, int & ip, int & im,
                                   realtype maxDist2 )  {
 //  ip expands contact (c.id1,c.id2) in positive direction of indices
 //  im expands contact (c.id1,c.id2) in negative direction of indices
@@ -1241,7 +1243,7 @@ int      i1,i2;
     i2 = c.id2 + ip;
     if (!isMC(i1,i2))  {
       while ((i1<nres1) && (i2<nres2))
-        if ((a1[i1].c<0) && (a2[i2].c<0) && 
+        if ((a1[i1].c<0) && (a2[i2].c<0) &&
              a1[i1].CompatibleSSE(a2[i2])) {
           dist = Calpha1[i1]->GetDist2 ( Calpha2[i2] );
           if (dist<maxDist2)  {
@@ -1290,7 +1292,7 @@ int      i1,i2;
 
 
 
-void  CSuperpose::CorrespondContacts ( PCMMDBManager M1,
+void  ssm::Superpose::CorrespondContacts ( PCMMDBManager M1,
                                        realtype rmsd_est )  {
 //  Find the closest contacts between yet unmapped atoms
 //  and gradually expand them
@@ -1409,8 +1411,8 @@ int       ncontacts,i,j,m1,m2,n1,n2,i1,i2;
 }
 
 
-void  CSuperpose::RecoverGaps ( PPCAtom Ca1, PSSpAtom at1, int nat1,
-                                PPCAtom Ca2, PSSpAtom at2, int nat2,
+void  ssm::Superpose::RecoverGaps ( PPCAtom Ca1, PSpAtom at1, int nat1,
+                                PPCAtom Ca2, PSpAtom at2, int nat2,
                                 realtype thresh )  {
 //   Checks if additional mappings may be made when moving
 // from sides of gaps to their centers.
@@ -1534,14 +1536,14 @@ Boolean  B1,B2;
 
     }
 
-  }     
+  }
 
 }
 
 
 
-void  CSuperpose::CleanShortSections ( PSSpAtom at1, int nat1,
-                                       PSSpAtom at2 )  {
+void  ssm::Superpose::CleanShortSections ( PSpAtom at1, int nat1,
+                                       PSpAtom at2 )  {
 //    Checks if continuous mapped sections of sequences c1 and c2
 //  follow the same direction (along protein section) and are
 //  long enough to be significant. If sections are too short
@@ -1558,13 +1560,13 @@ int  i,j,j2,k,shortSect;
       if (k<0)  k = i;  // begining of a continuous section
       else if (at1[i].c<=at1[i-1].c)  {
         // a misdirection has been found
-        nmisdr++; 
+        nmisdr++;
         if (i-k<=shortSect)  {
           // the previous section is too short to be significant;
           // waste it:
           for (j=k;j<i;j++)  {
             j2 = at1[j].c;
-            if ((at1[j ].unmap1!=UNMAP_NO) && 
+            if ((at1[j ].unmap1!=UNMAP_NO) &&
                 (at2[j2].unmap1!=UNMAP_NO))  {
               at2[j2].c = -1;
               at1[j ].c = -1;
@@ -1579,7 +1581,7 @@ int  i,j,j2,k,shortSect;
         // the section is too short - dispose of it:
         for (j=k;j<i;j++)  {
           j2 = at1[j].c;
-          if ((at1[j ].unmap1!=UNMAP_NO) && 
+          if ((at1[j ].unmap1!=UNMAP_NO) &&
               (at2[j2].unmap1!=UNMAP_NO))  {
             at2[j2].c = -1;
             at1[j ].c = -1;
@@ -1595,7 +1597,7 @@ int  i,j,j2,k,shortSect;
       // the section is too short - dispose of it:
       for (j=k;j<nat1;j++)  {
         j2 = at1[j].c;
-        if ((at1[j ].unmap1!=UNMAP_NO) && 
+        if ((at1[j ].unmap1!=UNMAP_NO) &&
             (at2[j2].unmap1!=UNMAP_NO))  {
           at2[j2].c = -1;
           at1[j ].c = -1;
@@ -1607,7 +1609,7 @@ int  i,j,j2,k,shortSect;
 }
 
 
-void CSuperpose::CalcNGaps ( PSSpAtom a, int nres,
+void ssm::Superpose::CalcNGaps ( PSpAtom a, int nres,
                              int & Ng, int & Nm )  {
 int  i,k,m;
 
@@ -1636,8 +1638,8 @@ int  i,k,m;
 
 }
 
-realtype CSuperpose::CalcNCombs ( PCSSGraph G, PSSSEDesc SSED,
-                                  int nSSEs, PSSpAtom  a, int nres ) {
+realtype ssm::Superpose::CalcNCombs ( PGraph G, PSSEDesc SSED,
+                                  int nSSEs, PSpAtom  a, int nres ) {
 UNUSED_ARGUMENT(nres);
 ivector  F;
 realtype nc;
@@ -1679,7 +1681,7 @@ Boolean  matched;
 
 //  -----------------------------------------------------------------
 
-int CSortDist::Compare ( int i, int j )  {
+int ssm::SortDist::Compare ( int i, int j )  {
 //  sort by decreasing: rd[i+1]<=rd[i]
 
   if ((sd[i].unmap1<=sd[j].index) &&
@@ -1694,7 +1696,7 @@ int CSortDist::Compare ( int i, int j )  {
 
 }
 
-void CSortDist::Swap ( int i, int j )  {
+void ssm::SortDist::Swap ( int i, int j )  {
 realtype r;
 int      k;
   r = sd[i].dist;   sd[i].dist   = sd[j].dist;   sd[j].dist   = r;
@@ -1704,17 +1706,17 @@ int      k;
 }
 
 
-void CSortDist::Sort ( PSSortDistData sdata, int len )  {
+void ssm::SortDist::Sort ( PSortDistData sdata, int len )  {
   sd = sdata;
   CQuickSort::Sort ( sdata,len );
 }
 
 //  -----------------------------------------------------------------
 
-void CSuperpose::GetSSESpseCenters ( RSSSEDesc Q1, RSSSEDesc Q2,
-                                     RSSSEDesc T1, RSSSEDesc T2,
-                                     realtype & qc1, realtype & qc2,
-                                     realtype & tc1, realtype & tc2 ) {
+void ssm::Superpose::GetSSESpseCenters ( RSSEDesc Q1, RSSEDesc Q2,
+                                         RSSEDesc T1, RSSEDesc T2,
+                                         realtype & qc1, realtype & qc2,
+                                         realtype & tc1, realtype & tc2 ) {
 realtype d2, dq,dt, quality,quality0;
 int      iq1,pq1,eq1,lq1, it1,pt1,et1, l1;
 int      iq2,pq2,eq2,lq2, it2,pt2,et2, l2;
@@ -1777,7 +1779,7 @@ int      i,j;
 }
 
 
-int  CSuperpose::FirstGuess ( ivector F1, ivector F2, int mlen )  {
+int  ssm::Superpose::FirstGuess ( ivector F1, ivector F2, int mlen )  {
 rvector  c1,c2;
 realtype xc1,yc1,zc1, xc2,yc2,zc2, r1,r2;
 vect3    vc1,vc2;
@@ -1833,7 +1835,7 @@ int      i,j, i1,i2, j1,j2, l, na;
   xc2 = 0.0;
   yc2 = 0.0;
   zc2 = 0.0;
-  for (i=1;i<=mlen;i++)  {  
+  for (i=1;i<=mlen;i++)  {
     i1 = F1[i] - 1;
     i2 = F2[i] - 1;
     SSED1[i1].m = F2[i];
@@ -1872,7 +1874,7 @@ int      i,j, i1,i2, j1,j2, l, na;
   xc2 /= na;
   yc2 /= na;
   zc2 /= na;
-  
+
   //  3.  Calculate the correlation matrix
 
   for (i=1;i<=3;i++)
@@ -1899,11 +1901,11 @@ int      i,j, i1,i2, j1,j2, l, na;
 
   if (CalculateTMatrix())  return 2;
 
-  TMatrix[0][3] = xc2 - TMatrix[0][0]*xc1 - 
+  TMatrix[0][3] = xc2 - TMatrix[0][0]*xc1 -
                         TMatrix[0][1]*yc1 - TMatrix[0][2]*zc1;
-  TMatrix[1][3] = yc2 - TMatrix[1][0]*xc1 - 
+  TMatrix[1][3] = yc2 - TMatrix[1][0]*xc1 -
                         TMatrix[1][1]*yc1 - TMatrix[1][2]*zc1;
-  TMatrix[2][3] = zc2 - TMatrix[2][0]*xc1 - 
+  TMatrix[2][3] = zc2 - TMatrix[2][0]*xc1 -
                         TMatrix[2][1]*yc1 - TMatrix[2][2]*zc1;
 
   return 0;
@@ -1912,7 +1914,7 @@ int      i,j, i1,i2, j1,j2, l, na;
 
 
 
-void  CSuperpose::ChooseFirstRotation ( int rotSSE1, int rotSSE2 )  {
+void  ssm::Superpose::ChooseFirstRotation ( int rotSSE1, int rotSSE2 )  {
 //  In case when only one SSE is matched, the initial rotation
 // matrix is defined only up to rotation about that SSE.
 // Given that matched SSE from 1st structure, this procedure
@@ -2046,22 +2048,27 @@ int       ia1,ia2,nrot,i,j,k,l,ncontacts,na,na0, i1,i2;
 }
 
 
-realtype  CSuperpose::MatchQuality ( int Nalign, realtype Rmsd )  {
+realtype  ssm::Superpose::MatchQuality ( int Nalign, realtype Rmsd )  {
   if (Nalign==0)  return 0.0;
   return MatchQuality2 ( Nalign,Rmsd*Rmsd*Nalign );
 }
 
-realtype  CSuperpose::MatchQuality2 ( int Nalign, realtype dist2 )  {
+realtype  ssm::Superpose::MatchQuality2 ( int Nalign, realtype dist2 )  {
 realtype  NormN,Na2,NormR;
+
+  if (Nalign<=0)  return 0.0;
+
   NormN = nres1*nres2;
   if (NormN<=0.0) return 0.0;
   Na2   = Nalign*Nalign;
   NormR = dist2/(Nalign*Rmsd0*Rmsd0);
+
   return  Na2/((1.0+NormR)*NormN);
+
 }
 
 
-void CSuperpose::UnmapExcluded ( PSSpAtom a1, PSSpAtom a2,
+void ssm::Superpose::UnmapExcluded ( PSpAtom a1, PSpAtom a2,
                                  int nres1 )  {
 int i;
   for (i=0;i<nres1;i++)
@@ -2072,9 +2079,9 @@ int i;
 }
 
 
-int  CSuperpose::OptimizeNalign()  {
+int  ssm::Superpose::OptimizeNalign()  {
 //  Finds maximal Nalign such that RMSD does not exceed the given Rmsd
-SSectionDist D;
+SectionDist D;
 vect3        vc1,vc2;
 realtype     xc1,yc1,zc1, xc2,yc2,zc2, B;
 realtype     dist2,Q,Q1,maxRMSD2, contDist;
@@ -2162,7 +2169,7 @@ Boolean      Done;
 
     //   1.7  Unmap atoms for optimizing the quality function
     if ((nl>0) && (na>3))  {
-      SortDist.Sort ( sdata,nl );
+      sortDist.Sort ( sdata,nl );
       i = 0;
       if (dist2<=na*maxRMSD2)  {
         Q1 = MatchQuality2 ( na,dist2 );
@@ -2254,7 +2261,7 @@ Boolean      Done;
       nalgn = na;
     }
 
-    Done = (na<=0) || (iter>iterMax) || 
+    Done = (na<=0) || (iter>iterMax) ||
            ((iter>iterMin) && (nobetter_cnt>maxHollowIt));
 
     if (!Done)  {
@@ -2266,7 +2273,7 @@ Boolean      Done;
       xc2 /= na;
       yc2 /= na;
       zc2 /= na;
-  
+
       for (i=1;i<=3;i++)
         for (j=1;j<=3;j++)
           A[i][j] = 0.0;
@@ -2291,11 +2298,11 @@ Boolean      Done;
       else  {
 
         //  5.3.e add translation
-        TMatrix[0][3] = xc2 - TMatrix[0][0]*xc1 - 
+        TMatrix[0][3] = xc2 - TMatrix[0][0]*xc1 -
                         TMatrix[0][1]*yc1 - TMatrix[0][2]*zc1;
-        TMatrix[1][3] = yc2 - TMatrix[1][0]*xc1 - 
+        TMatrix[1][3] = yc2 - TMatrix[1][0]*xc1 -
                         TMatrix[1][1]*yc1 - TMatrix[1][2]*zc1;
-        TMatrix[2][3] = zc2 - TMatrix[2][0]*xc1 - 
+        TMatrix[2][3] = zc2 - TMatrix[2][0]*xc1 -
                         TMatrix[2][1]*yc1 - TMatrix[2][2]*zc1;
 
       }
@@ -2317,7 +2324,7 @@ Boolean      Done;
 }
 
 
-void  CSuperpose::CalcQScore ( RSSSEDesc SSE1 )  {
+void  ssm::Superpose::CalcQScore ( RSSEDesc SSE1 )  {
 //  Calculates Q-score of overlaping SSE1 with matched SSE
 realtype  NormN,dist2;
 int       p1,p2,na,i;
@@ -2363,9 +2370,9 @@ int       p1,p2,na,i;
 }
 
 
-int  CSuperpose::SuperposeCalphas (
-            PCSSGraph     G1,   //  SSE graph of 1st structure
-            PCSSGraph     G2,   //  SSE graph of 2nd structure
+int  ssm::Superpose::SuperposeCalphas (
+            PGraph     G1,   //  SSE graph of 1st structure
+            PGraph     G2,   //  SSE graph of 2nd structure
             ivector       F1,   //  matched vertices of G1 [1..mlen]
             ivector       F2,   //  matched vertices of G2 [1..mlen]
             int         mlen,   //  length of match (F1,F2)
@@ -2394,7 +2401,7 @@ int  selHnd1,selHnd2;
 
   FreeMemory();
 
-  if ((!G1) || (!G2) || 
+  if ((!G1) || (!G2) ||
       (!F1) || (!F2) || (mlen<=0) ||
       (!M1) || (!M2))  return SPOSE_BadData;
 
@@ -2451,9 +2458,9 @@ int  selHnd1,selHnd2;
 }
 
 
-//  -----------------------  SSuperposeData  -----------------------
+//  -----------------------  ssm::SuperposeData  -----------------------
 
-void SSuperposeData::Init()  {
+void ssm::SuperposeData::Init()  {
   G          = NULL;
   M          = NULL;
   a          = NULL;
@@ -2466,7 +2473,7 @@ void SSuperposeData::Init()  {
   nSSEs      = 0;
 }
 
-void SSuperposeData::Dispose()  {
+void ssm::SuperposeData::Dispose()  {
 //   This DOES NOT dispose the graph and MMDB instance, however
 //  selected C-alphas are deselected
 
@@ -2484,12 +2491,12 @@ void SSuperposeData::Dispose()  {
 
 }
 
-void  SSuperposeData::DeselectCalphas()  {
+void  ssm::SuperposeData::DeselectCalphas()  {
   if (M && (selHnd>0))  M->DeleteSelection ( selHnd );
   selHnd = 0;
 }
 
-void  SSuperposeData::SelectCalphas()  {
+void  ssm::SuperposeData::SelectCalphas()  {
   if (G && M && (selHnd<=0))  {
     G->SelectCalphas ( M,selHnd,selstring );
     M->GetSelIndex   ( selHnd,Calpha,nres );
@@ -2498,9 +2505,9 @@ void  SSuperposeData::SelectCalphas()  {
 
 //  ----------------------------------------------------------------
 
-int  CSuperpose::SuperposeCalphas (
-           PSSuperposeData SD1,  // superposition data of 1st structure
-           PSSuperposeData SD2,  // superposition data of 2nd structure
+int  ssm::Superpose::SuperposeCalphas (
+           PSuperposeData SD1,  // superposition data of 1st structure
+           PSuperposeData SD2,  // superposition data of 2nd structure
            ivector          F1,  // matched vertices of SD1.G [1..mlen]
            ivector          F2,  // matched vertices of SD2.G [1..mlen]
            int            mlen   // length of match (F1,F2)
@@ -2524,7 +2531,7 @@ int  i,j, rc;
 
   FreeMemory();
 
-  if ((!SD1->G) || (!SD2->G) || 
+  if ((!SD1->G) || (!SD2->G) ||
       (!SD1->M) || (!SD2->M) ||
       (!F1) || (!F2) || (mlen<=0))
     return SPOSE_BadData;
@@ -2578,8 +2585,8 @@ int  i,j, rc;
 
 
   //  4. Prevent external data from being lost
-  //     NOTE that "CSuperpose::GetSuperposition()" and 
-  //     "CSuperpose::GetSSEDescX();" do not work with this driver.
+  //     NOTE that "ssm::Superpose::GetSuperposition()" and
+  //     "ssm::Superpose::GetSSEDescX();" do not work with this driver.
   //     The superposition data are to be read directly from
   //     returned SD's
 
@@ -2597,7 +2604,7 @@ int  i,j, rc;
 }
 
 
-void  CSuperpose::_superpose ( PCSSGraph G1, PCSSGraph G2,
+void  ssm::Superpose::_superpose ( PGraph G1, PGraph G2,
                                int & rc )  {
 mat44 TMx0;
 int   i,j,i1,i2,AD_alloc;
@@ -2607,7 +2614,7 @@ int   i,j,i1,i2,AD_alloc;
 
   //  3. Allocate memory for corresponding atoms and shortest contacts
 
-  sdata = new SSortDistData[nres1];
+  sdata = new SortDistData[nres1];
 
   GetVectorMemory ( cax0,nres1,0 );
   GetVectorMemory ( cay0,nres1,0 );
@@ -2631,9 +2638,9 @@ int   i,j,i1,i2,AD_alloc;
   SDistAlloc = IMax ( nFH1,nFS1 );
   j          = IMax ( nFH2,nFS2 );
   if ((SDistAlloc>0) && (j>0))  {
-    SDist = new PSSectionDist[SDistAlloc];
+    SDist = new PSectionDist[SDistAlloc];
     for (i=0;i<SDistAlloc;i++)
-      SDist[i] = new SSectionDist[j];
+      SDist[i] = new SectionDist[j];
   }
 
 
diff --git a/ssm_superpose.h b/ssm_superpose.h
index 8851ebd..61861d4 100644
--- a/ssm_superpose.h
+++ b/ssm_superpose.h
@@ -1,7 +1,7 @@
-// $Id: ssm_superpose.h,v 1.6 2011/11/21 16:56:16 ekr Exp $
+// $Id: ssm_superpose.h,v 1.3 2008/07/08 15:51:03 keb Exp $
 // =================================================================
 //
-//    30.04.04   <--  Date of Last Modification.
+//    05.04.13   <--  Date of Last Modification.
 //                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // -----------------------------------------------------------------
 //
@@ -10,7 +10,7 @@
 //  **** Functions : SuperposeCalphas ( superposing protein structures )
 //       ~~~~~~~~~~~
 //
-//  E. Krissinel 2002-2004
+//  E. Krissinel 2002-2013
 //
 // =================================================================
 //
@@ -19,259 +19,250 @@
 #ifndef  __SSM_Superpose__
 #define  __SSM_Superpose__
 
-#include "ss_graph.h"
+#include "ssm_graph.h"
 
 
 //  =================================================================
 
-#define  SPOSE_Ok            0
-#define  SPOSE_BadData       1
-#define  SPOSE_NoCalphas1    2
-#define  SPOSE_NoCalphas2    3
-#define  SPOSE_RemoteStruct  4
-#define  SPOSE_SVDFail       5
-
-
-DefineStructure(SSpAtom)
-
-struct SSpAtom  {
-  ChainID  chID;
-  int      c,sse,c0;
-  realtype dist,dist0;
-  int      unmap1,unmap2;
-  Boolean  excluded;
-  Boolean  CompatibleSSE ( RSSpAtom a );
-};
-
-
-DefineStructure(SSectionDist)
-
-struct SSectionDist  {
-  realtype dist,rmsd,cosine;
-  int      core_pos1,core_pos2,core_e1,core_e2;
-  int      na,pos1,pos2,e1,e2;
-  int      sse1,sse2;
-  void Copy ( RSSectionDist D );
-};
-
-
-DefineStructure(SSSEDesc)
-
-struct SSSEDesc  {
-  realtype x1,y1,z1,x2,y2,z2;      // transformed start/end coordinates
-  realtype xs1,ys1,zs1,xs2,ys2,zs2;   // original start/end coordinates
-  realtype score,Qscore,Rscore,Xscore; // overlaping scores
-  int      pos,len,pend, type,classID;
-  int      m,match;
-  void  Transform ( mat44   & T );
-  void  CalcScore ( RSSSEDesc D );
-  realtype Cosine ( RSSSEDesc D );
-  void       Copy ( RSSSEDesc D );
-};
-
-
-DefineStructure(SSortDistData)
-
-struct SSortDistData  {
-  realtype dist;
-  int      index,unmap1,unmap2;
-};
-
-DefineClass(CSortDist)
-
-class CSortDist : public CQuickSort  {
-  public :
-    CSortDist() : CQuickSort() {}
-    int  Compare ( int i, int j );
-    void Swap    ( int i, int j );
-    void Sort    ( PSSortDistData sdata, int len );
-  protected :
-    PSSortDistData sd;
-};
-
-
-DefineStructure(SSuperposeData)
-
-struct SSuperposeData  {
-  PCSSGraph     G;  // SSE graph 
-  PCMMDBManager M;  // the structure
-  PSSpAtom      a;  // atom superposition vector
-  PPCAtom  Calpha;  // selected C-alphas
-  PSSSEDesc  SSED;  // SSE description vector
-  pstr  selstring;  // C-alpha selection string
-  int      selHnd;  // C-alpha selection handle
-  int  selHndIncl;  // selection handle of inculded C-alphas
-  int        nres;  // number of residues (C-alphas)
-  int       nSSEs;  // number of SSEs
-  void  Init   ();
-  void  Dispose();
-  void  DeselectCalphas();
-  void  SelectCalphas  ();
-};
-
-
-#define  UNMAP_YES  (-2)
-#define  UNMAP_NO   (-1)
-
-DefineClass(CSuperpose)
-
-class CSuperpose  {
-
-  public :
-    CSuperpose();
-    ~CSuperpose();
-
-    void SetAllowMC         ( Boolean allowMisconnections );
-    void SetIterationLimits ( int iter_max, int iter_min,
-                              int max_hollow );
-    void SetCaSelections    ( pstr selection1, pstr selection2 );
-
-    int  SuperposeSSGraphs  ( PCSSGraph G1, ivector F1,
-                              PCSSGraph G2, ivector F2,
-                              int matchlen );
-
-    //  driver #1
-    int  SuperposeCalphas  (
-            PCSSGraph     G1,   // SSE graph of 1st structure
-            PCSSGraph     G2,   // SSE graph of 2nd structure
-            ivector       F1,   // matched vertices of G1 [1..mlen]
-            ivector       F2,   // matched vertices of G2 [1..mlen]
-            int         mlen,   // length of match (F1,F2)
-            PCMMDBManager M1,   // 1st structure
-            PCMMDBManager M2,   // 2nd structure
-            int  selHndIncl1=0, // sel handle to include atoms from M1
-            int  selHndIncl2=0  // sel handle to include atoms from M2
-                           );
-
-    //  driver #2
-    int  SuperposeCalphas  (
-            PSSuperposeData SD1, // superposition data of 1st structure
-            PSSuperposeData SD2, // superposition data of 2nd structure
-            ivector          F1, // matched vertices of SD1.G [1..mlen]
-            ivector          F2, // matched vertices of SD2.G [1..mlen]
-            int            mlen  // length of match (F1,F2)
-                           );
-
-    void  GetTMatrix ( mat44 & TMat ); // to be applied to 1st struct.
-    mat44 *  GetTMatrix    ();    // to be applied to 1st structure
-    realtype GetRMSD       ();
-    int      GetNAlign     ();
-    void  GetSuperposition ( ivector  & Ca1  ,
-                             rvector  & dist1, int & nCa1,
-                             ivector  & Ca2  , int & nCa2,
-                             mat44    & TMat ,
-                             realtype & rmsdAchieved,
-                             int & nAligned,   int & nGaps,
-                             realtype & seqIdentity,
-                             int & nMisD, realtype & nCombs );
-
-    void GetCalphas1 ( PPCAtom & Calpha, int & numRes );
-    void GetCalphas2 ( PPCAtom & Calpha, int & numRes );
-
-    void GetSSEDesc1 ( RPSSSEDesc SSEDesc, int & numSSEs );
-    void GetSSEDesc2 ( RPSSSEDesc SSEDesc, int & numSSEs );
-    PSSSEDesc GetSSEDesc1();
-    PSSSEDesc GetSSEDesc2();
-
-    void GetSuperposedSSEs ( ivector v1, ivector v2,
-                             int & nSupSSEs );
-
-    realtype GetCalphaQ   ()  { return Q_achieved; }
-    realtype MatchQuality ( int Nalign, realtype Rmsd );
-
-  protected :
-    mat44     TMatrix,TMx;
-    PSSpAtom  a1,a2;
-    realtype  Rmsd0;       // optimization parameter
-    realtype  minContact;  // minimal Calpha-pair contact parameter
-    realtype  maxContact;  // maximal Calpha-pair contact parameter
-    realtype  maxRMSD;     // maximal RMSD allowed
-    realtype  minQStep;    // minimal quality improvement that counts
-    realtype  minCosine;   // min cosine between co-directional SSEs
-    realtype  SSEweight;   // additional weight for SSE atoms
-    int       sseGray;     // gray zone on the ends of SSEs allowed for
-                           // matching to non-SSE atoms
-    int       selInclHnd1; // selection handle for included Calpha1
-    int       selInclHnd2; // selection handle for included Calpha2
-    int       driverID;    // ID of the used Superpose driver
-    pstr      selString1;  // optional sel-n string for 1st structure
-    pstr      selString2;  // optional sel-n string for 2nd structure
-
-
-    realtype  rmsd_achieved,Q_achieved,ncombs,seqIdent;
-    int       shortSect1,shortSect2;
-    int       iterMax,iterMin;
-    int       maxHollowIt;  // maximal allowed number of consequtive
-                            // iterations without quality improvement
-
-    int       nres1,nres2,nalgn,ngaps,nmd,nmisdr;
-    Boolean   allowMC;     // allowing for misconnection
-
-    rmatrix   A,U,V, AD;
-    rvector   W,RV1;
-
-    ivector   copyF1,copyF2;   // copy pointers to input F1,F2
-    int       copyFlen;        // length of FF1,FF2
-    rvector   cax0,cay0,caz0;  // working arrays
-    PSSortDistData sdata;
-
-    PCMMDBManager MMDB1,MMDB2; // copies of 1st and 2nd structure MMDBs
-
-    PPCAtom   Calpha1,Calpha2;
-    PSSSEDesc SSED1,SSED2;
-    ivector   FH1,FS1,FH2,FS2;
-    int       nSSEs1,nSSEs2;
-    int       nFH1,nFS1,nFH2,nFS2;
-    PPSSectionDist SDist;
-    int       SDistAlloc;
-
-    CSortDist SortDist;
-
-
-    void  InitSuperpose       ();
-    void  FreeMemory          ();
-    void  SelectCalphas       ( PCMMDBManager MMDB, PCSSGraph G,
-                                PPCAtom & Calpha, PSSpAtom & a,
-                                int & nres, int & selHnd,
-                                int selInclHnd, pstr selString );
-    void  MapSSEs             ( PPCAtom Calpha, PSSpAtom a, int nres,
-                                PCSSGraph G, RPSSSEDesc SSED,
-                                int & nSSEs );
-    void  IdentifyUnmatchedSSEs ( ivector & FH, int & nFH,
-                                ivector & FS, int & nFS,
-                                ivector F, int mlen,
-                                PCSSGraph G );
-    void  GetSSESpseCenters   ( RSSSEDesc Q1, RSSSEDesc Q2,
-                                RSSSEDesc T1, RSSSEDesc T2,
-                                realtype & qc1, realtype & qc2,
-                                realtype & tc1, realtype & tc2 );
-    int   FirstGuess          ( ivector F1, ivector F2, int mlen );
-    void  ChooseFirstRotation ( int rotSSE1, int rotSSE2 );
-    void  CalcDistance        ( int SSE1, int SSSE2, RSSectionDist D );
-    void  AlignSSEs           ( RSSectionDist D, int unmap );
-    Boolean isMC              ( int pos1, int pos2 );
-    void  CorrespondSSEs      ( ivector F1, int nF1, ivector F2, int nF2,
-                                realtype rmsd_est );
-    void  CorrespondContacts  ( PCMMDBManager M1, realtype rmsd_est );
-    void  ExpandContact       ( RSContact c, int & ip, int & im,
-                                realtype maxDist2 );
-    void  RecoverGaps         ( PPCAtom Ca1, PSSpAtom at1, int nat1,
-                                PPCAtom Ca2, PSSpAtom at2, int nat2,
-                                realtype thresh );
-    void  CleanShortSections  ( PSSpAtom at1, int nat1, PSSpAtom at2 );
-
-    int   CalculateTMatrix    ();
-    void     CalcNGaps        ( PSSpAtom a, int nres, int & Ng, int & Nm );
-    realtype CalcNCombs       ( PCSSGraph G, PSSSEDesc SSED, int nSSEs,
-                                PSSpAtom  a, int nres );
-    realtype MatchQuality2    ( int Nalign, realtype dist2 );
-    void     CalcQScore       ( RSSSEDesc SSE1 );
-    int   OptimizeNalign      ();
-    void  UnmapExcluded       ( PSSpAtom a1, PSSpAtom a2, int nres1 );
-
-    void  _superpose ( PCSSGraph G1, PCSSGraph G2, int & rc );
-
-};
-
+namespace ssm  {
+
+  DefineStructure(SpAtom);
+
+  struct SpAtom  {
+    ChainID  chID;
+    int      c,sse,c0;
+    realtype dist,dist0;
+    int      unmap1,unmap2;
+    Boolean  excluded;
+    Boolean  CompatibleSSE ( RSpAtom a );
+  };
+
+
+  DefineStructure(SectionDist);
+
+  struct SectionDist  {
+    realtype dist,rmsd,cosine;
+    int      core_pos1,core_pos2,core_e1,core_e2;
+    int      na,pos1,pos2,e1,e2;
+    int      sse1,sse2;
+    void Copy ( RSectionDist D );
+  };
+
+
+  DefineStructure(SSEDesc);
+
+  struct SSEDesc  {
+    realtype x1,y1,z1,x2,y2,z2;      // transformed start/end coordinates
+    realtype xs1,ys1,zs1,xs2,ys2,zs2;   // original start/end coordinates
+    realtype score,Qscore,Rscore,Xscore; // overlaping scores
+    int      pos,len,pend, type,classID;
+    int      m,match;
+    void  Transform ( mat44  & T );
+    void  CalcScore ( RSSEDesc D );
+    realtype Cosine ( RSSEDesc D );
+    void       Copy ( RSSEDesc D );
+  };
+
+
+  DefineStructure(SortDistData);
+
+  struct SortDistData  {
+    realtype dist;
+    int      index,unmap1,unmap2;
+  };
+
+  DefineClass(SortDist);
+
+  class SortDist : public CQuickSort  {
+    public :
+      SortDist() : CQuickSort() {}
+      int  Compare ( int i, int j );
+      void Swap    ( int i, int j );
+      void Sort    ( PSortDistData sdata, int len );
+    protected :
+      PSortDistData sd;
+  };
+
+
+  DefineStructure(SuperposeData);
+
+  struct SuperposeData  {
+    PGraph        G;  // SSE graph
+    PCMMDBManager M;  // the structure
+    PSpAtom       a;  // atom superposition vector
+    PPCAtom  Calpha;  // selected C-alphas
+    PSSEDesc   SSED;  // SSE description vector
+    pstr  selstring;  // C-alpha selection string
+    int      selHnd;  // C-alpha selection handle
+    int  selHndIncl;  // selection handle of inculded C-alphas
+    int        nres;  // number of residues (C-alphas)
+    int       nSSEs;  // number of SSEs
+    void  Init   ();
+    void  Dispose();
+    void  DeselectCalphas();
+    void  SelectCalphas  ();
+  };
+
+
+  DefineClass(Superpose);
+
+  class Superpose  {
+
+    public :
+      Superpose();
+      ~Superpose();
+
+      void SetAllowMC         ( Boolean allowMisconnections );
+      void SetIterationLimits ( int iter_max, int iter_min,
+                                int max_hollow );
+      void SetCaSelections    ( cpstr selection1, cpstr selection2 );
+
+      int  SuperposeSSGraphs  ( PGraph G1, ivector F1,
+                                PGraph G2, ivector F2,
+                                int matchlen );
+
+      //  driver #1
+      int  SuperposeCalphas  (
+              PGraph        G1,   // SSE graph of 1st structure
+              PGraph        G2,   // SSE graph of 2nd structure
+              ivector       F1,   // matched vertices of G1 [1..mlen]
+              ivector       F2,   // matched vertices of G2 [1..mlen]
+              int         mlen,   // length of match (F1,F2)
+              PCMMDBManager M1,   // 1st structure
+              PCMMDBManager M2,   // 2nd structure
+              int  selHndIncl1=0, // sel handle to include atoms from M1
+              int  selHndIncl2=0  // sel handle to include atoms from M2
+                             );
+
+      //  driver #2
+      int  SuperposeCalphas  (
+              PSuperposeData SD1, // superposition data of 1st structure
+              PSuperposeData SD2, // superposition data of 2nd structure
+              ivector        F1, // matched vertices of SD1.G [1..mlen]
+              ivector        F2, // matched vertices of SD2.G [1..mlen]
+              int            mlen  // length of match (F1,F2)
+                             );
+
+      void  GetTMatrix ( mat44 & TMat ); // to be applied to 1st struct.
+      mat44 *  GetTMatrix    ();    // to be applied to 1st structure
+      realtype GetRMSD       ();
+      int      GetNAlign     ();
+      void  GetSuperposition ( ivector  & Ca1  ,
+                               rvector  & dist1, int & nCa1,
+                               ivector  & Ca2  , int & nCa2,
+                               mat44    & TMat ,
+                               realtype & rmsdAchieved,
+                               int & nAligned,   int & nGaps,
+                               realtype & seqIdentity,
+                               int & nMisD, realtype & nCombs );
+
+      void GetCalphas1 ( PPCAtom & Calpha, int & numRes );
+      void GetCalphas2 ( PPCAtom & Calpha, int & numRes );
+
+      void GetSSEDesc1 ( RPSSEDesc sseDesc, int & numSSEs );
+      void GetSSEDesc2 ( RPSSEDesc sseDesc, int & numSSEs );
+      PSSEDesc GetSSEDesc1();
+      PSSEDesc GetSSEDesc2();
+
+      void GetSuperposedSSEs ( ivector v1, ivector v2, int & nSupSSEs );
+
+      realtype GetCalphaQ   ()  { return Q_achieved; }
+      realtype MatchQuality ( int Nalign, realtype Rmsd );
+
+    protected :
+      mat44     TMatrix,TMx;
+      PSpAtom   a1,a2;
+      realtype  Rmsd0;       // optimization parameter
+      realtype  minContact;  // minimal Calpha-pair contact parameter
+      realtype  maxContact;  // maximal Calpha-pair contact parameter
+      realtype  maxRMSD;     // maximal RMSD allowed
+      realtype  minQStep;    // minimal quality improvement that counts
+      realtype  minCosine;   // min cosine between co-directional SSEs
+      realtype  SSEweight;   // additional weight for SSE atoms
+      int       sseGray;     // gray zone on the ends of SSEs allowed for
+                             // matching to non-SSE atoms
+      int       selInclHnd1; // selection handle for included Calpha1
+      int       selInclHnd2; // selection handle for included Calpha2
+      int       driverID;    // ID of the used Superpose driver
+      pstr      selString1;  // optional sel-n string for 1st structure
+      pstr      selString2;  // optional sel-n string for 2nd structure
+
+
+      realtype  rmsd_achieved,Q_achieved,ncombs,seqIdent;
+      int       shortSect1,shortSect2;
+      int       iterMax,iterMin;
+      int       maxHollowIt;  // maximal allowed number of consequtive
+                              // iterations without quality improvement
+
+      int       nres1,nres2,nalgn,ngaps,nmd,nmisdr;
+      Boolean   allowMC;     // allowing for misconnection
+
+      rmatrix   A,U,V, AD;
+      rvector   W,RV1;
+
+      ivector   copyF1,copyF2;   // copy pointers to input F1,F2
+      int       copyFlen;        // length of FF1,FF2
+      rvector   cax0,cay0,caz0;  // working arrays
+      PSortDistData sdata;
+
+      PCMMDBManager MMDB1,MMDB2; // copies of 1st and 2nd structure MMDBs
+
+      PPCAtom   Calpha1,Calpha2;
+      PSSEDesc  SSED1,SSED2;
+      ivector   FH1,FS1,FH2,FS2;
+      int       nSSEs1,nSSEs2;
+      int       nFH1,nFS1,nFH2,nFS2;
+      PPSectionDist SDist;
+      int       SDistAlloc;
+
+      SortDist sortDist;
+
+
+      void  InitSuperpose       ();
+      void  FreeMemory          ();
+      void  SelectCalphas       ( PCMMDBManager MMDB, PGraph G,
+                                  PPCAtom & Calpha, PSpAtom & a,
+                                  int & nres, int & selHnd,
+                                  int selInclHnd, cpstr selString );
+      void  MapSSEs             ( PPCAtom Calpha, PSpAtom a, int nres,
+                                  PGraph G, RPSSEDesc SSED,
+                                  int & nSSEs );
+      void  IdentifyUnmatchedSSEs ( ivector & FH, int & nFH,
+                                  ivector & FS, int & nFS,
+                                  ivector F, int mlen,
+                                  PGraph G );
+      void  GetSSESpseCenters   ( RSSEDesc Q1, RSSEDesc Q2,
+                                  RSSEDesc T1, RSSEDesc T2,
+                                  realtype & qc1, realtype & qc2,
+                                  realtype & tc1, realtype & tc2 );
+      int   FirstGuess          ( ivector F1, ivector F2, int mlen );
+      void  ChooseFirstRotation ( int rotSSE1, int rotSSE2 );
+      void  CalcDistance        ( int SSE1, int SSSE2, RSectionDist D );
+      void  AlignSSEs           ( RSectionDist D, int unmap );
+      Boolean isMC              ( int pos1, int pos2 );
+      void  CorrespondSSEs      ( ivector F1, int nF1, ivector F2,
+                                  int nF2, realtype rmsd_est );
+      void  CorrespondContacts  ( PCMMDBManager M1, realtype rmsd_est );
+      void  ExpandContact       ( RSContact c, int & ip, int & im,
+                                  realtype maxDist2 );
+      void  RecoverGaps         ( PPCAtom Ca1, PSpAtom at1, int nat1,
+                                  PPCAtom Ca2, PSpAtom at2, int nat2,
+                                  realtype thresh );
+      void  CleanShortSections  ( PSpAtom at1, int nat1, PSpAtom at2 );
+
+      int   CalculateTMatrix    ();
+      void     CalcNGaps        ( PSpAtom a, int nres, int & Ng, int & Nm );
+      realtype CalcNCombs       ( PGraph G, PSSEDesc SSED, int nSSEs,
+                                  PSpAtom  a, int nres );
+      realtype MatchQuality2    ( int Nalign, realtype dist2 );
+      void     CalcQScore       ( RSSEDesc SSE1 );
+      int   OptimizeNalign      ();
+      void  UnmapExcluded       ( PSpAtom a1, PSpAtom a2, int nres1 );
+
+      void  _superpose ( PGraph G1, PGraph G2, int & rc );
+
+  };
+
+}
 
 #endif
diff --git a/ss_vxedge.cpp b/ssm_vxedge.cpp
similarity index 67%
rename from ss_vxedge.cpp
rename to ssm_vxedge.cpp
index 04063c8..044942b 100644
--- a/ss_vxedge.cpp
+++ b/ssm_vxedge.cpp
@@ -1,4 +1,4 @@
-// $Id: ss_vxedge.cpp,v 1.8 2011/11/21 16:56:16 ekr Exp $
+// $Id: ss_vxedge.cpp,v 1.2 2005/11/17 18:07:38 keb Exp $
 // =================================================================
 //
 //    29.04.04   <--  Date of Last Modification.
@@ -7,8 +7,8 @@
 //
 //  **** Module  :  ss_vxedge  <implementation>
 //       ~~~~~~~~~
-//  **** Classes :  CSSVertex  ( secondary structure graph vertex )
-//       ~~~~~~~~~  CSSEdge    ( secondary structure graph edge   )
+//  **** Classes :  ssm::Vertex  ( secondary structure graph vertex )
+//       ~~~~~~~~~  ssm::Edge    ( secondary structure graph edge   )
 //
 //  E. Krissinel 2002-2004
 //
@@ -20,216 +20,218 @@
 #include <math.h>
 #include <string.h>
 
-#include "ss_vxedge.h"
+#include "ssm_vxedge.h"
 #include "mmdb/math_.h"
 
 
 
 // ==========================  Tune-up  ============================
 
-// estimate for distance between residues in a strand, in angstroms
-#define InterResidueSpace  3.7
+namespace ssm  {
 
-int      hx_min_len    = 5;       // minimal length of helices
-int      sd_min_len    = 3;       // minimal length of strands
+  // estimate for distance between residues in a strand, in angstroms
+  #define InterResidueSpace  3.7
 
-realtype hx_nres_rtol  = 0.2;     // rel tolerance for length of helices
-realtype sd_nres_rtol  = 0.2;     // rel tolerance for length of strands
-int      hx_nres_atol  = 6;       // abs tolerance for length of helices
-int      sd_nres_atol  = 3;       // abs tolerance for length of strands
+  int      hx_min_len    = 5;       // minimal length of helices
+  int      sd_min_len    = 3;       // minimal length of strands
 
-realtype length_rtol   = 0.2;     // rel tol-ce for edge lengths
-realtype length_atol   = 1.75;    // abs tol-ce for edge lengths
-realtype ev_uncert_min = Pi/9.0;  // min unc-ty in edge-vertex angles
-realtype vv_uncert_min = Pi/12.0; // min unc-ty in vertex-vertex angles
-realtype tn_uncert_min = Pi/12.0; // min unc-ty in torsion angles
-realtype ev_uncert_max = Pi/6.0;  // max unc-ty in edge-vertex angles
-realtype vv_uncert_max = Pi/8.0;  // max unc-ty in vertex-vertex angles
-realtype tn_uncert_max = Pi/9.0;  // max unc-ty in torsion angles
+  realtype hx_nres_rtol  = 0.2;     // rel tolerance for length of helices
+  realtype sd_nres_rtol  = 0.2;     // rel tolerance for length of strands
+  int      hx_nres_atol  = 6;       // abs tolerance for length of helices
+  int      sd_nres_atol  = 3;       // abs tolerance for length of strands
 
-int CheckSSConnectivity = CSSC_None;
+  realtype length_rtol   = 0.2;     // rel tol-ce for edge lengths
+  realtype length_atol   = 1.75;    // abs tol-ce for edge lengths
+  realtype ev_uncert_min = Pi/9.0;  // min unc-ty in edge-vertex angles
+  realtype vv_uncert_min = Pi/12.0; // min unc-ty in vertex-vertex angles
+  realtype tn_uncert_min = Pi/12.0; // min unc-ty in torsion angles
+  realtype ev_uncert_max = Pi/6.0;  // max unc-ty in edge-vertex angles
+  realtype vv_uncert_max = Pi/8.0;  // max unc-ty in vertex-vertex angles
+  realtype tn_uncert_max = Pi/9.0;  // max unc-ty in torsion angles
 
+  int CheckSSConnectivity = CONNECT_None;
 
-void InitSSGraph()  {
-  SetSSMatchPrecision ( SSMP_Normal );
-  CheckSSConnectivity = CSSC_None;
-}
-
-void SetSSConnectivityCheck ( int checkMode )  {
-  CheckSSConnectivity = checkMode;
-}
 
-void  SetSSMatchPrecision ( int precision )  {
-
-  switch (precision)  {
-
-    case SSMP_Highest : hx_min_len    = 5;
-                        sd_min_len    = 3;
-                        hx_nres_rtol  = 0.125;
-                        sd_nres_rtol  = 0.125;
-                        hx_nres_atol  = 2;
-                        sd_nres_atol  = 0;
-                        length_rtol   = 0.10;
-                        length_atol   = 0.75;
-                        ev_uncert_min = 0.0;
-                        vv_uncert_min = 0.0;
-                        tn_uncert_min = 0.0;
-                        ev_uncert_max = Pi/12.0;
-                        vv_uncert_max = Pi/16.0;
-                        tn_uncert_max = Pi/16.0;
-                      break;
-
-    case SSMP_High    : hx_min_len    = 5;
-                        sd_min_len    = 3;
-                        hx_nres_rtol  = 0.15;
-                        sd_nres_rtol  = 0.15;
-                        hx_nres_atol  = 3;
-                        sd_nres_atol  = 1;
-                        length_rtol   = 0.15;
-                        length_atol   = 1.25;
-                        ev_uncert_min = Pi/12.0;
-                        vv_uncert_min = Pi/16.0;
-                        tn_uncert_min = Pi/16.0;
-                        ev_uncert_max = Pi/9.0;
-                        vv_uncert_max = Pi/12.0;
-                        tn_uncert_max = Pi/12.0;
-                      break;
-    default           :
-    case SSMP_Normal  : hx_min_len    = 5;
-                        sd_min_len    = 3;
-                        hx_nres_rtol  = 0.2;     // 0.2
-                        sd_nres_rtol  = 0.2;     // 0.2
-                        hx_nres_atol  = 6;       // 6
-                        sd_nres_atol  = 3;       // 2
-                        length_rtol   = 0.2;     // 0.2
-                        length_atol   = 1.75;    // 1.5
-                        ev_uncert_min = Pi/9.0;  // Pi/9.0
-                        vv_uncert_min = Pi/12.0; // Pi/12.0
-                        tn_uncert_min = Pi/12.0; // Pi/12.0
-                        ev_uncert_max = Pi/6.0;  // Pi/6.0
-                        vv_uncert_max = Pi/8.0;  // Pi/9.0
-                        tn_uncert_max = Pi/9.0;  // Pi/9.0
-                      break;
-
-    case SSMP_Low     : hx_min_len    = 5;
-                        sd_min_len    = 3;
-                        hx_nres_rtol  = 0.30;
-                        sd_nres_rtol  = 0.30;
-                        hx_nres_atol  = 6;
-                        sd_nres_atol  = 3;
-                        length_rtol   = 0.30;
-                        length_atol   = 2.0;
-                        ev_uncert_min = Pi/5.0;
-                        vv_uncert_min = Pi/8.0;
-                        tn_uncert_min = Pi/8.0;
-                        ev_uncert_max = Pi/5.0;
-                        vv_uncert_max = Pi/6.0;
-                        tn_uncert_max = Pi/6.0;
-                      break;
-
-    case SSMP_Lowest  : hx_min_len    = 5;
-                        sd_min_len    = 3;
-                        hx_nres_rtol  = 0.35;
-                        sd_nres_rtol  = 0.35;
-                        hx_nres_atol  = 9;
-                        sd_nres_atol  = 3;
-                        length_rtol   = 0.5;
-                        length_atol   = 2.5;
-                        ev_uncert_min = Pi/5.0;
-                        vv_uncert_min = Pi/6.0;
-                        tn_uncert_min = Pi/6.0;
-                        ev_uncert_max = Pi/4.0;
-                        vv_uncert_max = Pi/5.0;
-                        tn_uncert_max = Pi/5.0;
-                      break;
+  void InitGraph()  {
+    SetMatchPrecision ( PREC_Normal );
+    CheckSSConnectivity = CONNECT_None;
+  }
 
+  void SetConnectivityCheck ( CONNECTIVITY checkMode )  {
+    CheckSSConnectivity = checkMode;
   }
 
-}
+  void  SetMatchPrecision ( PRECISION precision )  {
+
+    switch (precision)  {
+
+      case PREC_Highest : hx_min_len    = 5;
+                          sd_min_len    = 3;
+                          hx_nres_rtol  = 0.125;
+                          sd_nres_rtol  = 0.125;
+                          hx_nres_atol  = 2;
+                          sd_nres_atol  = 0;
+                          length_rtol   = 0.10;
+                          length_atol   = 0.75;
+                          ev_uncert_min = 0.0;
+                          vv_uncert_min = 0.0;
+                          tn_uncert_min = 0.0;
+                          ev_uncert_max = Pi/12.0;
+                          vv_uncert_max = Pi/16.0;
+                          tn_uncert_max = Pi/16.0;
+                        break;
+
+      case PREC_High    : hx_min_len    = 5;
+                          sd_min_len    = 3;
+                          hx_nres_rtol  = 0.15;
+                          sd_nres_rtol  = 0.15;
+                          hx_nres_atol  = 3;
+                          sd_nres_atol  = 1;
+                          length_rtol   = 0.15;
+                          length_atol   = 1.25;
+                          ev_uncert_min = Pi/12.0;
+                          vv_uncert_min = Pi/16.0;
+                          tn_uncert_min = Pi/16.0;
+                          ev_uncert_max = Pi/9.0;
+                          vv_uncert_max = Pi/12.0;
+                          tn_uncert_max = Pi/12.0;
+                        break;
+      default           :
+      case PREC_Normal  : hx_min_len    = 5;
+                          sd_min_len    = 3;
+                          hx_nres_rtol  = 0.2;     // 0.2
+                          sd_nres_rtol  = 0.2;     // 0.2
+                          hx_nres_atol  = 6;       // 6
+                          sd_nres_atol  = 3;       // 2
+                          length_rtol   = 0.2;     // 0.2
+                          length_atol   = 1.75;    // 1.5
+                          ev_uncert_min = Pi/9.0;  // Pi/9.0
+                          vv_uncert_min = Pi/12.0; // Pi/12.0
+                          tn_uncert_min = Pi/12.0; // Pi/12.0
+                          ev_uncert_max = Pi/6.0;  // Pi/6.0
+                          vv_uncert_max = Pi/8.0;  // Pi/9.0
+                          tn_uncert_max = Pi/9.0;  // Pi/9.0
+                        break;
+
+      case PREC_Low     : hx_min_len    = 5;
+                          sd_min_len    = 3;
+                          hx_nres_rtol  = 0.30;
+                          sd_nres_rtol  = 0.30;
+                          hx_nres_atol  = 6;
+                          sd_nres_atol  = 3;
+                          length_rtol   = 0.30;
+                          length_atol   = 2.0;
+                          ev_uncert_min = Pi/5.0;
+                          vv_uncert_min = Pi/8.0;
+                          tn_uncert_min = Pi/8.0;
+                          ev_uncert_max = Pi/5.0;
+                          vv_uncert_max = Pi/6.0;
+                          tn_uncert_max = Pi/6.0;
+                        break;
+
+      case PREC_Lowest  : hx_min_len    = 5;
+                          sd_min_len    = 3;
+                          hx_nres_rtol  = 0.35;
+                          sd_nres_rtol  = 0.35;
+                          hx_nres_atol  = 9;
+                          sd_nres_atol  = 3;
+                          length_rtol   = 0.5;
+                          length_atol   = 2.5;
+                          ev_uncert_min = Pi/5.0;
+                          vv_uncert_min = Pi/6.0;
+                          tn_uncert_min = Pi/6.0;
+                          ev_uncert_max = Pi/4.0;
+                          vv_uncert_max = Pi/5.0;
+                          tn_uncert_max = Pi/5.0;
+                        break;
 
-void  writeSSMatchParameters ( pstr FileName )  {
-CMMCIFData CIF;
-realtype   Deg;
-  Deg = 180.0/Pi;
-  CIF.PutReal    ( hx_nres_rtol,"_helix" ,"rel_length_tolerance" );
-  CIF.PutReal    ( sd_nres_rtol,"_strand","rel_length_tolerance" );
-  CIF.PutInteger ( hx_nres_atol,"_helix" ,"abs_length_tolerance" );
-  CIF.PutInteger ( sd_nres_atol,"_strand","abs_length_tolerance" );
-  CIF.PutReal    ( length_rtol      ,"_bond_length"  ,"relative_tolerance"  );
-  CIF.PutReal    ( length_atol      ,"_bond_length"  ,"absolute_tolerance"  );
-  CIF.PutReal    ( ev_uncert_min*Deg,"_edge_vertex"  ,"minimal_uncertainty" );
-  CIF.PutReal    ( ev_uncert_max*Deg,"_edge_vertex"  ,"maximal_uncertainty" );
-  CIF.PutReal    ( vv_uncert_min*Deg,"_vertex_vertex","minimal_uncertainty" );
-  CIF.PutReal    ( vv_uncert_max*Deg,"_vertex_vertex","maximal_uncertainty" );
-  CIF.PutReal    ( tn_uncert_min*Deg,"_edge_torsion" ,"minimal_uncertainty" );
-  CIF.PutReal    ( tn_uncert_max*Deg,"_edge_torsion" ,"maximal_uncertainty" );
-  CIF.PutInteger ( CheckSSConnectivity,"_check" ,"connectivity" );
-  CIF.WriteMMCIFData ( FileName );
-}
+    }
 
-int  readSSMatchParameters ( pstr FileName )  {
-CMMCIFData CIF;
-int        RC,i;
-realtype   Deg,r;
-
-  CIF.SetFlag ( CIFFL_PrintWarnings );
-  RC = CIF.ReadMMCIFData ( FileName );
-  if (RC)  return RC;
-
-  if (!CIF.GetReal(r,"_helix" ,"rel_length_tolerance"))     hx_nres_rtol = r;
-  if (!CIF.GetReal(r,"_strand","rel_length_tolerance"))     sd_nres_rtol = r;
-  if (!CIF.GetInteger(i,"_helix" ,"abs_length_tolerance"))  hx_nres_atol = i;
-  if (!CIF.GetInteger(i,"_strand","abs_length_tolerance"))  sd_nres_atol = i;
-  if (!CIF.GetReal(r,"_bond_length","relative_tolerance"))  length_rtol  = r;
-  if (!CIF.GetReal(r,"_bond_length","absolute_tolerance"))  length_atol  = r;
-  if (!CIF.GetInteger(i,"_check" ,"connectivity"))   CheckSSConnectivity = i;
-
-  Deg = Pi/180.0;
-
-  if (!CIF.GetReal(r,"_edge_vertex","minimal_uncertainty"))
-                    ev_uncert_min = r*Deg;
-  if (!CIF.GetReal(r,"_edge_vertex","maximal_uncertainty"))
-                    ev_uncert_max = r*Deg;
-  if (!CIF.GetReal(r,"_vertex_vertex","minimal_uncertainty"))
-                    vv_uncert_min = r*Deg;
-  if (!CIF.GetReal(r,"_vertex_vertex","maximal_uncertainty"))
-                    vv_uncert_max = r*Deg;
-  if (!CIF.GetReal(r,"_edge_torsion" ,"minimal_uncertainty"))
-                    tn_uncert_min = r*Deg;
-  if (!CIF.GetReal(r,"_edge_torsion" ,"maximal_uncertainty"))
-                    tn_uncert_max = r*Deg;
+  }
 
-  return 0;
+  void  writeMatchParameters ( pstr FileName )  {
+  CMMCIFData CIF;
+  realtype   Deg;
+    Deg = 180.0/Pi;
+    CIF.PutReal    ( hx_nres_rtol,"_helix" ,"rel_length_tolerance" );
+    CIF.PutReal    ( sd_nres_rtol,"_strand","rel_length_tolerance" );
+    CIF.PutInteger ( hx_nres_atol,"_helix" ,"abs_length_tolerance" );
+    CIF.PutInteger ( sd_nres_atol,"_strand","abs_length_tolerance" );
+    CIF.PutReal    ( length_rtol      ,"_bond_length"  ,"relative_tolerance"  );
+    CIF.PutReal    ( length_atol      ,"_bond_length"  ,"absolute_tolerance"  );
+    CIF.PutReal    ( ev_uncert_min*Deg,"_edge_vertex"  ,"minimal_uncertainty" );
+    CIF.PutReal    ( ev_uncert_max*Deg,"_edge_vertex"  ,"maximal_uncertainty" );
+    CIF.PutReal    ( vv_uncert_min*Deg,"_vertex_vertex","minimal_uncertainty" );
+    CIF.PutReal    ( vv_uncert_max*Deg,"_vertex_vertex","maximal_uncertainty" );
+    CIF.PutReal    ( tn_uncert_min*Deg,"_edge_torsion" ,"minimal_uncertainty" );
+    CIF.PutReal    ( tn_uncert_max*Deg,"_edge_torsion" ,"maximal_uncertainty" );
+    CIF.PutInteger ( CheckSSConnectivity,"_check" ,"connectivity" );
+    CIF.WriteMMCIFData ( FileName );
+  }
 
-}
+  int  readMatchParameters ( pstr FileName )  {
+  CMMCIFData CIF;
+  int        RC,i;
+  realtype   Deg,r;
+
+    CIF.SetFlag ( CIFFL_PrintWarnings );
+    RC = CIF.ReadMMCIFData ( FileName );
+    if (RC)  return RC;
+
+    if (!CIF.GetReal(r,"_helix" ,"rel_length_tolerance"))     hx_nres_rtol = r;
+    if (!CIF.GetReal(r,"_strand","rel_length_tolerance"))     sd_nres_rtol = r;
+    if (!CIF.GetInteger(i,"_helix" ,"abs_length_tolerance"))  hx_nres_atol = i;
+    if (!CIF.GetInteger(i,"_strand","abs_length_tolerance"))  sd_nres_atol = i;
+    if (!CIF.GetReal(r,"_bond_length","relative_tolerance"))  length_rtol  = r;
+    if (!CIF.GetReal(r,"_bond_length","absolute_tolerance"))  length_atol  = r;
+    if (!CIF.GetInteger(i,"_check" ,"connectivity"))   CheckSSConnectivity = i;
+
+    Deg = Pi/180.0;
+
+    if (!CIF.GetReal(r,"_edge_vertex","minimal_uncertainty"))
+                      ev_uncert_min = r*Deg;
+    if (!CIF.GetReal(r,"_edge_vertex","maximal_uncertainty"))
+                      ev_uncert_max = r*Deg;
+    if (!CIF.GetReal(r,"_vertex_vertex","minimal_uncertainty"))
+                      vv_uncert_min = r*Deg;
+    if (!CIF.GetReal(r,"_vertex_vertex","maximal_uncertainty"))
+                      vv_uncert_max = r*Deg;
+    if (!CIF.GetReal(r,"_edge_torsion" ,"minimal_uncertainty"))
+                      tn_uncert_min = r*Deg;
+    if (!CIF.GetReal(r,"_edge_torsion" ,"maximal_uncertainty"))
+                      tn_uncert_max = r*Deg;
+
+    return 0;
 
+  }
 
+}
 
-// =========================  CSSVertex  ===========================
+// =========================  ssm::Vertex  ===========================
 
 
-CSSVertex::CSSVertex() : CStream()  {
-  InitSSVertex();
+ssm::Vertex::Vertex() : CStream()  {
+  InitVertex();
 }
 
-CSSVertex::CSSVertex ( RPCStream Object ) : CStream(Object)  {
-  InitSSVertex();
+ssm::Vertex::Vertex ( RPCStream Object ) : CStream(Object)  {
+  InitVertex();
 }
 
-CSSVertex::~CSSVertex()  {
+ssm::Vertex::~Vertex()  {
   FreeMemory();
 }
 
-void  CSSVertex::FreeMemory()  {
+void  ssm::Vertex::FreeMemory()  {
   if (name)  delete[] name;
   name = NULL;
   nres = 0;
 }
 
-void  CSSVertex::InitSSVertex()  {
+void  ssm::Vertex::InitVertex()  {
 
   id      = 0;     // a unique id
-  type    = -1;    // type: helix or strand
+  type    = V_UNKNOWN; // type: helix or strand
   classID = 0;     // class for helix
   nres    = 0;     // number of residues in the structure
   x0      = 0.0;   // x-center of mass
@@ -264,26 +266,26 @@ void  CSSVertex::InitSSVertex()  {
 
 }
 
-void CSSVertex::GetDirection ( vect3 & v )  {
+void ssm::Vertex::GetDirection ( vect3 & v )  {
   v[0] = ex;
   v[1] = ey;
   v[2] = ez;
 }
 
-void CSSVertex::GetPosition ( vect3 & v )  {
+void ssm::Vertex::GetPosition ( vect3 & v )  {
   v[0] = x0;
   v[1] = y0;
   v[2] = z0;
 }
 
-void CSSVertex::GetPosition ( realtype & vx0, realtype & vy0,
+void ssm::Vertex::GetPosition ( realtype & vx0, realtype & vy0,
                               realtype & vz0 )  {
   vx0 = x0;
   vy0 = y0;
   vz0 = z0;
 }
 
-int CSSVertex::GetPositions ( PCMMDBManager MMDB, int minlen )  {
+int ssm::Vertex::GetPositions ( PCMMDBManager MMDB, int minlen )  {
 int        selHnd_ca;
 PPCAtom    CA;
 
@@ -321,14 +323,14 @@ PPCAtom    CA;
 
 }
 
-Boolean CSSVertex::inRange ( pstr chID, int Pos1, int Pos2 )  {
+Boolean ssm::Vertex::inRange ( cpstr chID, int Pos1, int Pos2 )  {
   if (strcmp(chID,chainID))    return False;
   if (IMax(Pos1,Pos2)<initPos) return False;
   if (IMin(Pos1,Pos2)>endPos)  return False;
   return True;
 }
 
-int  CSSVertex::SetVertex ( PCMMDBManager MMDB, PCHelix Helix  )  {
+int  ssm::Vertex::SetVertex ( PCMMDBManager MMDB, PCHelix Helix  )  {
 char  S[200];
 
   FreeMemory();
@@ -356,7 +358,7 @@ char  S[200];
 }
 
 
-int  CSSVertex::SetVertex ( PCMMDBManager MMDB, PCStrand Strand )  {
+int  ssm::Vertex::SetVertex ( PCMMDBManager MMDB, PCStrand Strand )  {
 char S[200];
 
   FreeMemory();
@@ -383,10 +385,10 @@ char S[200];
 
 }
 
-int  CSSVertex::SetVertex ( PCMMDBManager MMDB, int v_type, int sNum,
-                            int iclass,  ChainID chID,
-                            int seqNum1, InsCode iCode1,
-                            int seqNum2, InsCode iCode2 )  {
+int  ssm::Vertex::SetVertex ( PCMMDBManager MMDB, VERTEX_TYPE v_type,
+                              int sNum, int iclass,  ChainID chID,
+                              int seqNum1, InsCode iCode1,
+                              int seqNum2, InsCode iCode2 )  {
 char S[200];
 
   FreeMemory();
@@ -426,7 +428,7 @@ char S[200];
 }
 
 
-void  CSSVertex::CalcGeometry ( PPCAtom CA )  {
+void  ssm::Vertex::CalcGeometry ( PPCAtom CA )  {
 int  i;
 
   //  1. Calculate the center of mass
@@ -471,7 +473,7 @@ int  i;
 
 }
 
-realtype CSSVertex::GetCoor1 ( PPCAtom CA, int coor_key )  {
+realtype ssm::Vertex::GetCoor1 ( PPCAtom CA, int coor_key )  {
 realtype c0,c1,c2,c3;
 
   c1 = 0.0; // only to keep compiler happy
@@ -507,7 +509,7 @@ realtype c0,c1,c2,c3;
 
 }
 
-realtype CSSVertex::GetCoor2 ( PPCAtom CA, int coor_key )  {
+realtype ssm::Vertex::GetCoor2 ( PPCAtom CA, int coor_key )  {
 realtype c1,c2,c3,c4;
 
   c2 = 0.0;  // only to keep compiler happy
@@ -543,41 +545,41 @@ realtype c1,c2,c3,c4;
 
 }
 
-realtype CSSVertex::GetAngle ( PCSSVertex v )  {
+realtype ssm::Vertex::GetAngle ( PVertex v )  {
   return  acos(v->ex*ex+v->ey*ey+v->ez*ez);
 }
 
-realtype CSSVertex::GetCosine ( PCSSVertex v )  {
+realtype ssm::Vertex::GetCosine ( PVertex v )  {
 // returns cosine angle between the vertices
   return  v->ex*ex+v->ey*ey+v->ez*ez;
 }
 
-realtype CSSVertex::GetAngle ( realtype vx, realtype vy, realtype vz )  {
+realtype ssm::Vertex::GetAngle ( realtype vx, realtype vy, realtype vz )  {
 realtype l;
   l = vx*vx + vy*vy + vz*vz;
   if (l>0.0)  return  acos((ex*vx+ey*vy+ez*vz)/sqrt(l));
         else  return  0.0;
 }
 
-Boolean CSSVertex::Compare ( PCSSVertex v )  {
+Boolean ssm::Vertex::Compare ( PVertex v )  {
 int  dn;
   if (v->type!=type)  return False;
   switch (type)  {
     case V_HELIX  : if (v->classID!=classID)  return False;
-                    dn = mround(((nres+v->nres)*hx_nres_rtol)/2.0) + 
+                    dn = mround(((nres+v->nres)*hx_nres_rtol)/2.0) +
                                 hx_nres_atol;
                     if (abs(v->nres-nres)>dn)  return False;
                   break;
-    case V_STRAND : dn = mround((nres+v->nres)*sd_nres_rtol/2.0) + 
+    case V_STRAND : dn = mround((nres+v->nres)*sd_nres_rtol/2.0) +
                                 sd_nres_atol;
                     if (abs(v->nres-nres)>dn)  return False;
                   break;
-    default : ;  
+    default : ;
   }
   return True;
 }
 
-realtype CSSVertex::GetLengthDeviation ( PCSSVertex v )  {
+realtype ssm::Vertex::GetLengthDeviation ( PVertex v )  {
 int dn;
   if (v->type!=type)  return -1.0;
   switch (type)  {
@@ -588,12 +590,12 @@ int dn;
     case V_STRAND : dn = nres + v->nres;
                     if (dn>0)  return 2.0*fabs(realtype(v->nres-nres))/dn;
                          else  return 0.0;
-    default : ;  
+    default : ;
   }
   return 0.0;
 }
 
-pstr  CSSVertex::GetShortVertexDesc ( pstr S )  {
+pstr  ssm::Vertex::GetShortVertexDesc ( pstr S )  {
   switch (type)  {
     case V_HELIX  : sprintf ( S,"%3i HELIX  %8s %2i %3i",
                               id,name,classID,nres );
@@ -601,12 +603,12 @@ pstr  CSSVertex::GetShortVertexDesc ( pstr S )  {
     case V_STRAND : sprintf ( S,"%3i STRAND %8s    %3i",
                               id,name,nres );
                   break;
-    default       : strcpy  ( S,"" );  
+    default       : strcpy  ( S,"" );
   }
   return S;
 }
 
-pstr  CSSVertex::GetFullVertexDesc ( pstr S )  {
+pstr  ssm::Vertex::GetFullVertexDesc ( pstr S )  {
 char  HType[5];
   switch (type)  {
     case V_HELIX  :
@@ -625,12 +627,12 @@ char  HType[5];
                 id,nres,chainID,initResName,initSeqNum,initICode,
                 endResName,endSeqNum,endICode );
               break;
-    default       : strcpy  ( S,"" );  
+    default       : strcpy  ( S,"" );
   }
   return S;
 }
 
-void  CSSVertex::GetVertexRange  ( ChainID chID,
+void  ssm::Vertex::GetVertexRange  ( ChainID chID,
                                    ResName name1,
                                    int &   seqNum1,
                                    InsCode insCode1,
@@ -658,7 +660,7 @@ void  CompareStr ( pstr s1, pstr s2, pstr name )  {
   if (strcmp(s1,s2))  printf ( "  %s1='%s'  %s2='%s'\n",name,s1,name,s2 );
 }
 
-void  CSSVertex::Copy ( PCSSVertex v )  {
+void  ssm::Vertex::Copy ( PVertex v )  {
 
   FreeMemory();
 
@@ -696,13 +698,14 @@ void  CSSVertex::Copy ( PCSSVertex v )  {
 
 }
 
-void  CSSVertex::write ( RCFile f )  {
+void  ssm::Vertex::write ( RCFile f )  {
 int Version=3;
+int vtype = type;
 
   f.WriteInt     ( &Version  );
 
   f.WriteInt     ( &id       );
-  f.WriteInt     ( &type     );
+  f.WriteInt     ( &vtype    );
   f.WriteInt     ( &classID  );
   f.WriteInt     ( &nres     );
   f.WriteFloat   ( &x0       );
@@ -740,15 +743,17 @@ int Version=3;
 }
 
 
-void  CSSVertex::read ( RCFile f )  {
+void  ssm::Vertex::read ( RCFile f )  {
 int Version;
+int vtype;
 
   FreeMemory();
 
   f.ReadInt     ( &Version  );
 
   f.ReadInt     ( &id       );
-  f.ReadInt     ( &type     );
+  f.ReadInt     ( &vtype    );
+  type = VERTEX_TYPE(vtype);
   f.ReadInt     ( &classID  );
   f.ReadInt     ( &nres     );
   f.ReadFloat   ( &x0       );
@@ -785,24 +790,25 @@ int Version;
 
 }
 
-MakeStreamFunctions(CSSVertex)
-
+namespace ssm  {
+  MakeStreamFunctions(Vertex)
+}
 
 
-//  ==========================  CSSEdge  ============================
+//  ==========================  ssm::Edge  ============================
 
 
-CSSEdge::CSSEdge() : CStream()  {
-  InitSSEdge();
+ssm::Edge::Edge() : CStream()  {
+  InitEdge();
 }
 
-CSSEdge::CSSEdge ( RPCStream Object ) : CStream(Object)  {
-  InitSSEdge();
+ssm::Edge::Edge ( RPCStream Object ) : CStream(Object)  {
+  InitEdge();
 }
 
-CSSEdge::~CSSEdge() {}
+ssm::Edge::~Edge() {}
 
-void  CSSEdge::InitSSEdge()  {
+void ssm::Edge::InitEdge()  {
 
   id1          = 0;
   id2          = 0;
@@ -826,19 +832,19 @@ void  CSSEdge::InitSSEdge()  {
 
 }
 
-realtype CSSEdge::GetAngle ( PCSSVertex v )  {
+realtype ssm::Edge::GetAngle ( PVertex v )  {
 //  returns angle between the edge and given vertex
   return  acos(v->ex*ex+v->ey*ey+v->ez*ez);
 }
 
 
-realtype CSSEdge::GetCosine ( PCSSEdge E )  {
+realtype ssm::Edge::GetCosine ( PEdge E )  {
 // returns cosine angle between the edges
   return  E->ex*ex+E->ey*ey+E->ez*ez;
 }
 
 
-realtype CSSEdge::GetAngle ( rvector V1, rvector V2 )  {
+realtype ssm::Edge::GetAngle ( rvector V1, rvector V2 )  {
 // returns angle between two vectors
 realtype l1,l2;
 
@@ -851,13 +857,13 @@ realtype l1,l2;
 
 }
 
-void CSSEdge::GetDirection ( vect3 & v )  {
+void ssm::Edge::GetDirection ( vect3 & v )  {
   v[0] = ex;
   v[1] = ey;
   v[2] = ez;
 }
 
-void  CSSEdge::SetEdge ( PCSSVertex v1, PCSSVertex v2 )  {
+void  ssm::Edge::SetEdge ( PVertex v1, PVertex v2 )  {
 realtype dx,dy,dz, r,dr1,dr2, r1,r2,dt, drx,dry,drz;
 realtype U[3],W[3],V[3];
 int      i,j,na;
@@ -1003,8 +1009,8 @@ int      i,j,na;
 }
 
 
-int  CSSEdge::Compare ( Boolean swap_this, PCSSEdge edge,
-                        Boolean swap_edge )  {
+int  ssm::Edge::Compare ( Boolean swap_this, PEdge edge,
+                          Boolean swap_edge )  {
 // Compare(..) returns True if edges compare, that is:
 //   1. edge lengths compare within relative precision
 //      edge_len_tol
@@ -1044,14 +1050,16 @@ int      v11,v12,v21,v22, bdir1,bdir2;
   }
 
   if ((bdir1!=bdir2) && (bdir1*bdir2!=0))  {
-    if (CheckSSConnectivity==CSSC_Strict)  return 6;
-    if ((CheckSSConnectivity==CSSC_Flexible) && (bdir1*bdir2<0))  return 6;
+    if (CheckSSConnectivity==CONNECT_Strict)  return 6;
+    if ((CheckSSConnectivity==CONNECT_Flexible) && (bdir1*bdir2<0))
+                                              return 6;
   }
 
   length1  = edge->length;
 
   avlength = (length+length1)/2.0;
-  if (fabs(length-length1)>avlength*length_rtol+dr12+length_atol)  return 1;
+  if (fabs(length-length1)>avlength*length_rtol+dr12+length_atol)
+                                              return 1;
 
   if ((length>0.0) && (edge->length>0.0))  {
     if (swap_this)  {
@@ -1084,8 +1092,8 @@ int      v11,v12,v21,v22, bdir1,bdir2;
 }
 
 
-int CSSEdge::CheckConnectivity ( Boolean swap_this, PCSSEdge edge,
-                                 Boolean swap_edge )  {
+int ssm::Edge::CheckConnectivity ( Boolean swap_this, PEdge edge,
+                                   Boolean swap_edge )  {
 int bdir1,bdir2;
   if (swap_this)  bdir1 = -bdir;
             else  bdir1 = bdir;
@@ -1099,7 +1107,7 @@ int bdir1,bdir2;
 }
 
 
-void  CSSEdge::write ( RCFile f )  {
+void  ssm::Edge::write ( RCFile f )  {
 int Version=1;
   f.WriteInt   ( &Version     );
   f.WriteInt   ( &id1         );
@@ -1122,7 +1130,7 @@ int Version=1;
   f.WriteBool  ( &GoodTorsion );
 }
 
-void  CSSEdge::read ( RCFile f )  {
+void  ssm::Edge::read ( RCFile f )  {
 int Version;
   f.ReadInt   ( &Version     );
   f.ReadInt   ( &id1         );
@@ -1146,7 +1154,7 @@ int Version;
 }
 
 
-
-MakeStreamFunctions(CSSEdge)
-
+namespace ssm {
+  MakeStreamFunctions(Edge)
+}
 
diff --git a/ssm_vxedge.h b/ssm_vxedge.h
new file mode 100644
index 0000000..073ddc7
--- /dev/null
+++ b/ssm_vxedge.h
@@ -0,0 +1,219 @@
+// $Id: ssm_vxedge.h,v 1.1.1.1 2004/11/23 16:24:37 keb Exp $
+// =================================================================
+//
+//    05.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// -----------------------------------------------------------------
+//
+//  **** Module  :  ssm_vxedge  <interface>
+//       ~~~~~~~~~
+//  **** Classes :  ssm::Vertex  ( secondary structure graph vertex )
+//       ~~~~~~~~~  ssm::Edge    ( secondary structure graph edge   )
+//
+//  E. Krissinel 2002-2013
+//
+// =================================================================
+//
+
+
+#ifndef  __SSM_VxEdge__
+#define  __SSM_VxEdge__
+
+#include "mmdb/mmdb_manager.h"
+#include "ssm_defs.h"
+
+//  ==========================  Tune-up  ============================
+
+namespace ssm  {
+
+  extern int hx_min_len;
+  extern int sd_min_len;
+
+  extern void InitGraph();  // should be called on top of application
+
+  extern void SetMatchPrecision    ( PRECISION    prec      );
+  extern void writeMatchParameters ( cpstr        FileName  );
+  extern int  readMatchParameters  ( cpstr        FileName  );
+  extern void SetConnectivityCheck ( CONNECTIVITY checkMode );
+
+
+  //  =========================  CSSVertex  ===========================
+
+  DefineClass(Vertex);
+  DefineStreamFunctions(Vertex)
+
+  class Vertex : public CStream  {
+
+    friend class Edge;
+    friend class Graph;
+
+    public :
+
+      Vertex ();
+      Vertex ( RPCStream Object );
+      ~Vertex();
+
+      int  SetVertex ( PCMMDBManager MMDB, PCHelix  Helix  );
+      int  SetVertex ( PCMMDBManager MMDB, PCStrand Strand );
+      int  SetVertex ( PCMMDBManager MMDB, VERTEX_TYPE v_type,
+                       int sNum, int  iclass, ChainID chID,
+                       int seqNum1, InsCode iCode1,
+                       int seqNum2, InsCode iCode2 );
+
+      inline void SetID ( int vid ) { id = vid; }
+
+      realtype GetAngle  ( PVertex v );
+      realtype GetCosine ( PVertex v );
+      realtype GetAngle  ( realtype vx, realtype vy, realtype vz );
+
+      pstr     GetShortVertexDesc ( pstr S );
+      pstr     GetFullVertexDesc  ( pstr S );
+
+      Boolean  Compare ( PVertex v ); // True if vertices compare
+
+      realtype GetLengthDeviation ( PVertex v );
+
+      void     GetDirection ( vect3 & v );
+      void     GetPosition  ( vect3 & p );
+      void     GetPosition  ( realtype & vx0, realtype & vy0,
+                              realtype & vz0 );
+
+      inline realtype GetLength    ()  { return length; }
+      inline int      GetSeqLength ()  { return nres;   }
+      inline realtype GetMass      ()  { return mass;   }
+
+      inline realtype GetX1        ()  { return x1;     };
+      inline realtype GetX2        ()  { return x2;     };
+      inline realtype GetY1        ()  { return y1;     };
+      inline realtype GetY2        ()  { return y2;     };
+      inline realtype GetZ1        ()  { return z1;     };
+      inline realtype GetZ2        ()  { return z2;     };
+
+      Boolean  inRange ( cpstr chID, int Pos1, int Pos2 );
+
+      inline int   GetVertexType   () { return type;    }
+      inline int   GetVertexChainNo() { return VNo;     }
+      inline cpstr GetChainID      () { return chainID; }
+      void  GetVertexRange  ( ChainID chID,
+                              ResName name1,
+                              int &   seqNum1,
+                              InsCode insCode1,
+                              ResName name2,
+                              int &   seqNum2,
+                              InsCode insCode2 );
+
+      void  Copy  ( PVertex v );
+
+      void  read  ( RCFile f );
+      void  write ( RCFile f );
+
+    protected :
+
+      //  matching info
+      int       id;          //!< unique identifier that MUST be the vertex
+                             /// number starting from 1 on
+      VERTEX_TYPE  type;     //!< a V_XXXXX constant
+      int       classID;     //!< class ID for helices
+      int       nres;        //!< number of residues
+      realtype  x0,y0,z0;    //!< center of mass
+      realtype  mass;        //!< the mass
+      realtype  ex,ey,ez;    //!< direction vector
+      realtype  dalpha;      //!< uncertainty angle
+      realtype  length;      //!< vertex length
+
+      //  identification info
+      pstr     name;        //!< composed name for short identification
+      int      serNum;      //!< helix serial number
+      int      strandNo;    //!< strand number
+      maxMMDBName vertexID; //!< helix ID or sheet ID
+      ChainID  chainID;     //!< chain ID (only for identification)
+      ResName  initResName; //!< name of the strand's initial residue
+      int      initSeqNum;  //!< sequence number of the initial residue
+      int      initPos;     //!< sequence position of the initial residue
+      InsCode  initICode;   //!< insertion code of the initial residue
+      ResName  endResName;  //!< name of the strand's terminal residue
+      int      endSeqNum;   //!< sequence number of the terminal residue
+      int      endPos;      //!< sequence position of the terminal residue
+      InsCode  endICode;    //!< insertion code of the terminal residue
+      int      VNo;         //!< number of vertex in the chain
+
+      realtype x1,x2;       //!< coordinates
+      realtype y1,y2;       ///   SSE
+      realtype z1,z2;       ///     ends
+
+      void  InitVertex ();
+      void  FreeMemory   ();
+      void  CalcGeometry ( PPCAtom CA );
+      int   GetPositions ( PCMMDBManager MMDB, int minlen );
+      realtype  GetCoor1 ( PPCAtom CA, int coor_key );
+      realtype  GetCoor2 ( PPCAtom CA, int coor_key );
+
+  };
+
+
+  //  ==========================  CSSEdge  ============================
+
+  DefineClass(Edge);
+  DefineStreamFunctions(Edge)
+
+  class Edge : public CStream  {
+
+    friend class Graph;
+    friend class GraphMatch;
+
+    public :
+
+      Edge ();
+      Edge ( RPCStream Object );
+      ~Edge();
+
+      void     SetEdge  ( PVertex v1, PVertex v2 );
+
+      realtype GetAngle ( PVertex v );  // returns angle between
+                                        // the edge and vertex
+      realtype GetCosine ( PEdge E );   // returns cosine angle between
+                                        // the edges
+      realtype GetAngle ( rvector V1, rvector V2 );
+
+      // Compare(..) returns 0 if edges compare, that is:
+      //   1. edge lengths compare within relative precision
+      //      edge_len_tol
+      //   2. angles alpha1, alpha2 and alpha3 compare within
+      //      absolute deviations edge_alphaX_tol .
+      int   Compare ( Boolean swap_this, PEdge edge,
+                      Boolean swap_edge );
+
+      int   CheckConnectivity ( Boolean swap_this, PEdge edge,
+                                Boolean swap_edge );
+
+      void  GetDirection ( vect3 & v );
+      inline realtype GetLength () { return length; }
+
+      void  read  ( RCFile f );
+      void  write ( RCFile f );
+
+    protected :
+      int      id1,id2;  //!< linked vertices
+      int      vtype1;   //!< type of 1st linked vertex
+      int      vtype2;   //!< type of 2nd linked vertex
+      int      bdir;     //!< bond direction along the chain
+      realtype length;   //!< length of edge (between v1 and v2 mass centers)
+      realtype ex,ey,ez; //!< direction vector from v1 to v2
+      realtype alpha1;   //!< angle V1E between v1 and the edge
+      realtype alpha2;   //!< angle V2E between v2 and the edge
+      realtype alpha3;   //!< angle V1V2 between v1 and v2
+      realtype alpha4;   //!< torsion angle V1EV2 of v1, edge and v2
+      realtype dalpha1;  //!< uncertainty in alpha1
+      realtype dalpha2;  //!< uncertainty in alpha2
+      realtype dalpha3;  //!< uncertainty in alpha3
+      realtype dalpha4;  //!< uncertainty in alpha4
+      realtype dr12;
+      Boolean  GoodTorsion; //!< True if the VEV torsion angle is well defined
+
+      void  InitEdge();
+
+  };
+
+}
+
+#endif
diff --git a/sup_defs.h b/sup_defs.h
new file mode 100644
index 0000000..6b0121d
--- /dev/null
+++ b/sup_defs.h
@@ -0,0 +1,31 @@
+// $Id: superpose_defs.h,v 1.1.1.1 2004/11/23 16:24:37 keb Exp $
+// =================================================================
+//
+//    10.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// -----------------------------------------------------------------
+//
+//  **** Module  :  superpose_defs  <interface>
+//       ~~~~~~~~~
+//
+//  E. Krissinel 2013
+//
+//  When used, please cite:
+//
+//   Krissinel, E. and Henrick, K. (2004)
+//   Common subgraph isomorphism detection by backtracking search.
+//   Software - Practice and Experience, 34, 591-607.
+//
+// =================================================================
+//
+
+#ifndef  __SUPERPOSE_DEFS__
+#define  __SUPERPOSE_DEFS__
+
+#define  superpose_version    "1.03"
+#define  superpose_date       "10-04-2013"
+
+// _ccp4_ should be defined if compiled as part of CCP4 Suite
+#undef _emulate_ccp4_
+
+#endif
diff --git a/sup_multiple.cpp b/sup_multiple.cpp
new file mode 100644
index 0000000..a8b997b
--- /dev/null
+++ b/sup_multiple.cpp
@@ -0,0 +1,258 @@
+// $Id: sup_multiple.cpp,v 1.16 2011/07/26 15:01:59 ekr Exp $
+// =================================================================
+//
+//    10.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// -----------------------------------------------------------------
+//
+//  **** Module  :  Multiple Superposer <implementation>
+//       ~~~~~~~~~
+//  **** Project :  Structure alignment in 3D
+//       ~~~~~~~~~
+//
+//  E. Krissinel, 2002-2013
+//
+// =================================================================
+//
+
+#include <string.h>
+
+#include "sup_multiple.h"
+#include "sup_pairwise.h"
+#include "ssm_malign.h"
+#include "ssm_align.h"
+
+
+void print_matrix ( cpstr name, rmatrix m, cpstr fmt, ssm::PPGraph G,
+                     int nStructures )  {
+char S[100];
+int  i,j,n,k;
+
+  printf ( "\n   " );
+  for (i=0;i<(int)strlen(name);i++)
+    printf ( "_" );
+  printf ( "\n"
+           "   %s\n\n",name );
+
+  k = strlen(G[0]->GetGraphName());
+  n = k + 2;
+  for (i=0;i<nStructures;i++)
+    for (j=0;j<nStructures;j++)  {
+      sprintf ( S,fmt,m[i][j] );
+      n = IMax ( n,strlen(S) );
+    }
+
+  printf ( "      " );
+  for (i=0;i<k;i++)
+    printf ( " " );
+  n -= k;
+  for (i=0;i<nStructures;i++)  {
+    for (j=0;j<n;j++)
+      printf ( " " );
+    printf ( " %s ",G[i]->GetGraphName() );
+  }
+  printf ( "\n" );
+
+  printf ( "      " );
+  for (i=0;i<k-1;i++)
+    printf ( " " );
+  printf ( "." );
+  for (i=0;i<nStructures;i++)  {
+    for (j=0;j<n+k+2;j++)
+      printf ( "-" );
+  }
+  printf ( "\n" );
+
+  for (i=0;i<nStructures;i++)  {
+    printf ( "     %s| ",G[i]->GetGraphName() );
+    for (j=0;j<nStructures;j++)  {
+      sprintf ( S,fmt,m[i][j] );
+      printf  ( " %s",S );
+      for (k=0;k<n;k++)
+        printf ( " " );
+    }
+    printf ( "\n" );
+  }
+
+
+}
+
+int multiple_superposition ( PPCMMDBManager M, psvector selstring,
+                             psvector    name, ivector  selHnd,
+                             int nStructures, pstr fileout  )  {
+CFile           f;
+ssm::PMultAlign multAlign;
+ssm::PPGraph    G;
+rmatrix         m_rmsd,m_Qscore,m_seqId;
+rvector         cons_x,cons_y,cons_z;
+mat44           T;
+realtype        rmsd,Qscore;
+int             i,j,nc,n_align,n_SSEs,cons_len,rc;
+
+  printf ( "\n Performing Multiple Structure Alignment"
+           "\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n" );
+
+  multAlign = NULL;
+  rc        = MALIGN_Ok;
+
+  G  = new ssm::PGraph[nStructures];
+  nc = 0;
+  for (i=0;i<nStructures;i++)  {
+    G[i] = NULL;
+    nc = IMax ( nc,strlen(name[i])+strlen(selstring[i]) );
+  }
+
+  for (i=0;(i<nStructures) && (rc==MALIGN_Ok);i++)  {
+    G[i] = ssm::GetSSGraph ( M[i],selHnd[i],rc );
+    if ((rc!=MALIGN_Ok) || (!G[i]))
+      rc = MALIGN_NoGraph + i;
+  }
+
+  if (rc==MALIGN_Ok)  {
+
+    multAlign = new ssm::MultAlign();
+    rc = multAlign->align ( M,selstring,G,nStructures );
+
+    if (rc==MALIGN_Ok)  {
+
+#ifdef _ccp4_
+      printf ( "$TEXT:Alignment results: $$ $$\n" );
+#endif
+
+      printf ( " Structures\n\n"
+               "    Ref. |  Nres  | File (selection)\n"
+               "   ------+--------+-----" );
+      for (i=0;i<nc;i++)
+        printf ( "-" );
+      printf ( "\n" );
+      for (i=0;i<nStructures;i++)
+        printf ( "    %4s | %5i  | %s (%s)\n",
+                 G[i]->GetGraphName(),multAlign->getNres(i),
+                 name[i],selstring[i] );
+      printf ( "\n have been aligned and superposed.\n\n" );
+
+      printf ( "\n"
+        " ===== Superposition matrices:\n" );
+
+      for (i=0;i<nStructures;i++)  {
+
+        multAlign->getTMatrix ( T,i );
+
+        printf ( "\n"
+                 "   ____________________________" );
+        for (j=0;j<nc;j++)  printf ( "_" );
+        printf ( "\n"
+                 "   (o) For structure %s [%s(%s)]:\n\n"
+                 "        Rx         Ry         Rz           T\n"
+                 " %10.3f %10.3f %10.3f   %10.3f\n"
+                 " %10.3f %10.3f %10.3f   %10.3f\n"
+                 " %10.3f %10.3f %10.3f   %10.3f\n",
+                 G[i]->GetGraphName(),name[i],selstring[i],
+                 T[0][0],T[0][1],T[0][2],T[0][3],
+                 T[1][0],T[1][1],T[1][2],T[1][3],
+                 T[2][0],T[2][1],T[2][2],T[2][3] );
+
+        for (j=0;j<nStructures;j++)
+          printFracAnalysis ( T,G[j]->GetGraphName(),M[j] );
+
+      }
+
+
+      multAlign->getAlignScores ( n_align,n_SSEs,rmsd,Qscore );
+
+      printf ( "\n"
+        " ===== Scores achieved:\n"
+        "\n"
+         "   quality Q:  %-7.4f (normalised to [0...1])\n"
+         "     r.m.s.d:  %-7.4f (A)\n"
+         "      Nalign:  %-6i  (residues)\n"
+         "        Nsse:  %-6i  (SSEs)\n",
+         Qscore,rmsd,n_align,n_SSEs );
+
+
+      multAlign->getConsensusScores ( cons_x,cons_y,cons_z,cons_len,
+                                      m_rmsd,m_Qscore,m_seqId );
+
+      print_matrix (
+         "(o) pairwise Q-scores (consensus Q-score on diagonal):",
+         m_Qscore,"%5.3f",G,nStructures );
+      print_matrix (
+         "(o) pairwise r.m.s.d. (consensus r.m.s.d. on diagonal):",
+         m_rmsd,"%5.3f",G,nStructures );
+      print_matrix (
+         "(o) pairwise seq. Id:",m_seqId,
+         "%5.3f",G,nStructures );
+
+      if (fileout)
+        multAlign->WriteSuperposed ( fileout );
+
+      f.assign ( "stdout" );
+      f.rewrite();
+
+
+#ifdef _ccp4_
+      f.Write ( "$$\n\n" );
+      f.Write ( "$TEXT:Secondary Structure alignment: $$ $$\n\n" );
+#else
+      f.Write ( "\n\n"
+                " ===== Secondary Structure alignment:\n\n" );
+#endif
+      multAlign->WriteMatchedSSEs ( f );
+
+#ifdef _ccp4_
+      f.Write ( "$$\n\n" );
+      f.Write ( "$TEXT:Residue alignment: $$ $$\n\n" );
+#else
+
+      f.Write ( "\n\n"
+                " ===== Residue alignment:\n\n" );
+#endif
+      multAlign->WriteMultAlign   ( f );
+
+#ifdef _ccp4_
+      f.Write ( "$$\n" );
+#endif
+      f.shut();
+
+    }
+
+  }
+
+  if (rc!=MALIGN_Ok)  {
+
+#ifdef _ccp4_
+    printf ( "$TEXT:Warning: $$Superposition was not achieved$$\n" );
+#endif
+
+    switch (rc)  {
+
+      case MALIGN_BadInput :
+              printf ( " *** Bad input (program error?).\n" );
+            break;
+
+      case MALIGN_NoStructure :
+              printf ( " *** NULL structure (program error?).\n" );
+            break;
+
+      case MALIGN_NoAlignment :
+              printf ( " *** multiple alignment was not achieved.\n" );
+            break;
+
+      default :  if (rc>=MALIGN_NoGraph)
+              printf ( " *** can't make graph for %s.\n",
+                           name[rc-MALIGN_NoGraph] );
+                 else
+              printf ( " *** unknown return code (%i).\n",rc );
+
+    }
+
+  }
+
+
+  if (multAlign)  delete multAlign;
+  ssm::DisposeGraphs ( G,nStructures );
+
+  return rc;
+
+}
+
diff --git a/sup_multiple.h b/sup_multiple.h
new file mode 100644
index 0000000..3dd6078
--- /dev/null
+++ b/sup_multiple.h
@@ -0,0 +1,34 @@
+// $Id: sup_multiple.h,v 1.1.1.1 2004/11/23 16:24:37 keb Exp $
+// =================================================================
+//
+//    10.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// -----------------------------------------------------------------
+//
+//  **** Module  :  Multiple Superposer  <interface>
+//       ~~~~~~~~~
+//
+//  E. Krissinel 2013
+//
+//  When used, please cite:
+//
+//   Krissinel, E. and Henrick, K. (2004)
+//   Common subgraph isomorphism detection by backtracking search.
+//   Software - Practice and Experience, 34, 591-607.
+//
+// =================================================================
+//
+
+#ifndef  __SUP_MULTIPLE__
+#define  __SUP_MULTIPLE__
+
+#include "mmdb/mmdb_manager.h"
+
+extern int multiple_superposition ( PPCMMDBManager   M,
+                                    psvector selstring,
+                                    psvector      name,
+                                    ivector     selHnd,
+                                    int    nStructures,
+                                    pstr       fileout  );
+
+#endif
diff --git a/sup_pairwise.cpp b/sup_pairwise.cpp
new file mode 100644
index 0000000..cbbf74f
--- /dev/null
+++ b/sup_pairwise.cpp
@@ -0,0 +1,273 @@
+// $Id: sup_pairwise.cpp,v 1.16 2011/07/26 15:01:59 ekr Exp $
+// =================================================================
+//
+//    10.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// -----------------------------------------------------------------
+//
+//  **** Module  :  Pairwise Superposer <implementation>
+//       ~~~~~~~~~
+//  **** Project :  Structure alignment in 3D
+//       ~~~~~~~~~
+//
+//  E. Krissinel, 2002-2013
+//
+// =================================================================
+//
+
+#include <string.h>
+
+#include "sup_pairwise.h"
+#include "ssm_align.h"
+
+
+void printccp4rot ( mat44 m )  {
+double w_, x_, y_, z_;
+double d = 180.0/3.14159265359;
+double tr = m[0][0] + m[1][1] + m[2][2] + 1.0;
+
+  // check the diagonal
+  if ( tr > 1.0e-8 ) {
+    double s( sqrt(tr) );
+    w_ = s * 0.5;
+    s = 0.5 / s;
+    x_ = s * ( m[2][1] - m[1][2] );
+    y_ = s * ( m[0][2] - m[2][0] );
+    z_ = s * ( m[1][0] - m[0][1] );
+  } else {
+    if ( m[0][0] > m[1][1] && m[0][0] > m[2][2] ) {
+      double s( sqrt(1.0 + m[0][0] - m[1][1] - m[2][2] ) );
+      x_ = 0.5 * s;
+      if ( s != 0.0 ) s = 0.5 / s;
+      w_ = s * ( m[2][1] - m[1][2] );
+      y_ = s * ( m[0][1] + m[1][0] );
+      z_ = s * ( m[0][2] + m[2][0] );
+    } else if ( m[1][1] > m[2][2] ) {
+      double s( sqrt(1.0 + m[1][1] - m[2][2] - m[0][0] ) );
+      y_ = 0.5 * s;
+      if ( s != 0.0 ) s = 0.5 / s;
+      w_ = s * ( m[0][2] - m[2][0] );
+      z_ = s * ( m[1][2] + m[2][1] );
+      x_ = s * ( m[1][0] + m[0][1] );
+    } else {
+      double s( sqrt(1.0 + m[2][2] - m[0][0] - m[1][1] ) );
+      z_ = 0.5 * s;
+      if ( s != 0.0 ) s = 0.5 / s;
+      w_ = s * ( m[1][0] - m[0][1] );
+      x_ = s * ( m[2][0] + m[0][2] );
+      y_ = s * ( m[2][1] + m[1][2] );
+    }
+  }
+  double om, ph, ka, al, be, ga;
+  om = ph = ka = 0.0;
+  if ( fabs(w_) < 0.999999 ) {
+    double r = sqrt( x_*x_ + y_*y_ );
+    om = d*atan2( r, z_ );
+    if ( r > 0.000001 ) ph = d*atan2( y_, x_ );
+    ka = d*2.0*acos( w_ );
+  }
+  double ca, cb, cg, sa, sb, sg;
+  cb = 1.0 - 2.0 * (x_*x_ + y_*y_);
+  sb = 2.0 * sqrt( (x_*x_ + y_*y_) * (w_*w_ + z_*z_) );
+  if ( sb > 0.0001 ) {
+    ca = 2.0 * (x_*z_ + w_*y_);
+    sa = 2.0 * (y_*z_ - w_*x_);
+    cg = 2.0 * (w_*y_ - x_*z_);
+    sg = 2.0 * (y_*z_ + w_*x_);
+  } else {
+    ca = 1.0;
+    sa = 0.0;
+    cg = cb;
+    sg = 2.0*(y_*z_ + w_*x_);
+  }
+  al = d*atan2(sa,ca);
+  be = d*atan2(sb,cb);
+  ga = d*atan2(sg,cg);
+
+#ifdef _ccp4_
+  printf ( "\n\n$TEXT:CCP4 rotation-translational operator: $$ $$\n" );
+#else
+  printf ( " CCP4 format rotation-translation operator\n" );
+#endif
+
+  printf ( " Polar angles (omega,phi,kappa) : %9.3f %9.3f %9.3f\n",
+           om,ph,ka );
+  printf ( " Euler angles (alpha,beta,gamma): %9.3f %9.3f %9.3f\n",
+           al,be,ga );
+  printf ( " Orthogonal translation (/Angst): %9.3f %9.3f %9.3f\n",
+           m[0][3],m[1][3],m[2][3] );
+
+#ifdef _ccp4_
+  printf ( "$$\n" );
+#endif
+
+}
+
+
+void printFracAnalysis ( mat44 & T, cpstr name, PCMMDBManager M )   {
+mat44 TF;
+
+  if (M->CrystReady()!=CRRDY_NoTransfMatrices)  {
+
+    if (M->Orth2Frac(T,TF))
+      printf ( "\n"
+        "      in fractional coordinates of %s:\n\n"
+        "        Rx         Ry         Rz           T\n"
+        " %10.3f %10.3f %10.3f   %10.3f\n"
+        " %10.3f %10.3f %10.3f   %10.3f\n"
+        " %10.3f %10.3f %10.3f   %10.3f\n",
+        name,
+        TF[0][0],TF[0][1],TF[0][2],TF[0][3],
+        TF[1][0],TF[1][1],TF[1][2],TF[1][3],
+        TF[2][0],TF[2][1],TF[2][2],TF[2][3] );
+    else
+      printf ( "\n"
+        " *** orthogonal-fractional transformations failed for structure\n"
+        " %s\n",name );
+
+  }
+  /* else  {
+    printf (
+      " Orthogonal-fractional transformations were not calculated\n"
+      " structure %s.\n"
+      " Possibly, cell parameters were not supplied.\n",
+      name,M->CrystReady() );
+  }*/
+
+}
+
+int pairwise_superposition ( PPCMMDBManager M, psvector name,
+                             ivector selHnd, pstr fileout  )  {
+CFile       f;
+ssm::PAlign SSMAlign;
+int         rc;
+
+  printf ( "\n Performing Multiple Structure Alignment"
+           "\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n" );
+
+  SSMAlign = new ssm::Align();
+  rc = SSMAlign->align ( M[0],M[1],
+                         ssm::PREC_Normal,ssm::CONNECT_Flexible,
+                         selHnd[0],selHnd[1] );
+
+  if (rc)  {
+#ifdef _ccp4_
+    printf ( "$TEXT:Warning: $$Superposition was not achieved$$\n" );
+#endif
+    switch (rc)  {
+      case ssm::RC_NoHits :
+         printf ( " *** secondary structure does not match.\n" );
+         break;
+      case ssm::RC_NoSuperposition :
+         printf ( " *** structures are too remote.\n" );
+         break;
+      case ssm::RC_NoGraph :
+         printf ( " *** can't make graph for %s.\n",name[0] );
+         break;
+      case ssm::RC_NoVertices :
+         printf ( " *** empty graph for %s.\n",name[0] );
+         break;
+      case ssm::RC_NoGraph2 :
+         printf ( " *** can't make graph for %s.\n",name[1] );
+         break;
+      case ssm::RC_NoVertices2 :
+         printf ( " *** empty graph for %s.\n",name[1] );
+         break;
+      default :
+        printf ( " *** undocumented return code %i.\n",rc );
+    }
+#ifdef _ccp4_
+    printf ( "$$\n" );
+#endif
+  } else  {
+
+#ifdef _ccp4_
+    printf ( "$TEXT:Alignment results: $$ $$\n" );
+#endif
+
+    printf (
+      " Query      %s\n"
+      " and Target %s\n"
+      "\n"
+      " have been superposed. Superposition matrix (to be applied\n"
+      " to %s) is\n\n"
+      "        Rx         Ry         Rz           T\n"
+      " %10.3f %10.3f %10.3f   %10.3f\n"
+      " %10.3f %10.3f %10.3f   %10.3f\n"
+      " %10.3f %10.3f %10.3f   %10.3f\n",
+      name[0],name[1],name[0],
+      SSMAlign->TMatrix[0][0],SSMAlign->TMatrix[0][1],
+      SSMAlign->TMatrix[0][2],SSMAlign->TMatrix[0][3],
+      SSMAlign->TMatrix[1][0],SSMAlign->TMatrix[1][1],
+      SSMAlign->TMatrix[1][2],SSMAlign->TMatrix[1][3],
+      SSMAlign->TMatrix[2][0],SSMAlign->TMatrix[2][1],
+      SSMAlign->TMatrix[2][2],SSMAlign->TMatrix[2][3] );
+
+    printFracAnalysis ( SSMAlign->TMatrix,name[0],M[0] );
+    printFracAnalysis ( SSMAlign->TMatrix,name[1],M[1] );
+
+    printf ( "\n"
+      " ===== Scores achieved:\n"
+      "\n"
+       "   quality Q:  %-7.4f (normalised to [0...1])\n"
+       "     r.m.s.d:  %-7.4f (A)\n"
+       "      Nalign:  %-6i  (residues)\n",
+       SSMAlign->Qscore,SSMAlign->rmsd,SSMAlign->nalgn );
+
+#ifdef _ccp4_
+    printf ( "$$\n\n" );
+    printf ( "$TEXT:Residue alignment: $$ $$\n" );
+#else
+    printf ( "\n"
+      " ===== Residue alignment:\n" );
+#endif
+
+    f.assign ( "stdout" );
+    f.rewrite();
+
+    ssm::PrintAlignTable ( f,M[0],M[1],SSMAlign );
+
+#ifdef _ccp4_
+    f.Write ( "$$\n" );
+#endif
+
+/*
+char S[200];
+int  i;
+    f.WriteLine ( " \n\n Test output for Paul Emsley:\n\n"
+                  "   i    Ca1[i]   dist1[i]" );
+    for (i=0;i<SSMAlign->nres1;i++)  {
+      sprintf ( S," %5i %5i %10.3f",i,SSMAlign->Ca1[i],
+                                      SSMAlign->dist1[i] );
+      f.WriteLine ( S );
+    }
+    f.WriteLine ( "\n\n   i    Ca2[i]" );
+    for (i=0;i<SSMAlign->nres2;i++)  {
+      sprintf ( S," %5i %5i",i,SSMAlign->Ca2[i] );
+      f.WriteLine ( S );
+    }
+*/
+
+    f.shut();
+
+    // if output file requested, apply transform to first
+    // input file (NB all file, not just requested selection)
+    // and output
+    if ( fileout ) {
+      M[0]->ApplyTransform ( SSMAlign->TMatrix );
+      M[0]->WritePDBASCII ( fileout );
+    }
+
+#ifndef _ccp4_
+    printf ( "\n"
+  " ----------------------------------------------------------------\n"
+             "\n" );
+#endif
+    printccp4rot ( SSMAlign->TMatrix );
+
+  }
+
+  return 0;
+
+}
+
diff --git a/sup_pairwise.h b/sup_pairwise.h
new file mode 100644
index 0000000..3d68319
--- /dev/null
+++ b/sup_pairwise.h
@@ -0,0 +1,33 @@
+// $Id: sup_pairwise.h,v 1.1.1.1 2004/11/23 16:24:37 keb Exp $
+// =================================================================
+//
+//    10.04.13   <--  Date of Last Modification.
+//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// -----------------------------------------------------------------
+//
+//  **** Module  :  Pairwise Superposer  <interface>
+//       ~~~~~~~~~
+//
+//  E. Krissinel 2013
+//
+//  When used, please cite:
+//
+//   Krissinel, E. and Henrick, K. (2004)
+//   Common subgraph isomorphism detection by backtracking search.
+//   Software - Practice and Experience, 34, 591-607.
+//
+// =================================================================
+//
+
+#ifndef  __SUP_PAIRWISE__
+#define  __SUP_PAIRWISE__
+
+#include "mmdb/mmdb_manager.h"
+
+extern int pairwise_superposition ( PPCMMDBManager M,
+                                    psvector name, ivector selHnd,
+                                    pstr fileout  );
+extern void printFracAnalysis     ( mat44 & T, cpstr name,
+                                    PCMMDBManager M );
+
+#endif
diff --git a/superpose.cpp b/superpose.cpp
index ca96b69..a22f03d 100644
--- a/superpose.cpp
+++ b/superpose.cpp
@@ -1,7 +1,7 @@
-// $Id: superpose.cpp,v 1.22 2012/02/17 17:24:04 gxg60988 Exp $
+// $Id: superpose.cpp,v 1.16 2011/07/26 15:01:59 ekr Exp $
 // =================================================================
 //
-//    29.09.11   <--  Date of Last Modification.
+//    10.04.13   <--  Date of Last Modification.
 //                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // -----------------------------------------------------------------
 //
@@ -10,19 +10,17 @@
 //  **** Project :  Structure alignment in 3D
 //       ~~~~~~~~~
 //
-//  E. Krissinel, 2002-2011
+//  E. Krissinel, 2002-2013
 //
 // =================================================================
 //
 
-#ifndef  __STRING_H
 #include <string.h>
-#endif
 
 #include "ssm_align.h"
-
-// _ccp4_ should be defined if compiled as part of CCP4 Suite
-//#undef _ccp4_
+#include "sup_pairwise.h"
+#include "sup_multiple.h"
+#include "sup_defs.h"
 
 #ifdef _ccp4_
 
@@ -34,6 +32,43 @@ using namespace CCP4;
 
 #endif
 
+
+#ifdef _emulate_ccp4_
+
+void ccp4ProgramName ( cpstr ) {}
+
+void ccp4_banner() {
+printf (
+"<B><FONT COLOR=\"#FF0000\"><!--SUMMARY_BEGIN-->\n"
+"<html> <!-- CCP4 HTML LOGFILE -->\n"
+"<hr>\n"
+"<!--SUMMARY_END--></FONT></B>\n"
+"<B><FONT COLOR=\"#FF0000\"><!--SUMMARY_BEGIN-->\n"
+"<pre>\n"
+"\n"
+" ###############################################################\n"
+" ###############################################################\n"
+" ###############################################################\n"
+" ### CCP4 6.3: SUPERPOSE                version 6.3 :         ##\n"
+" ###############################################################\n"
+" User: Eugene  Run date: 21/10/2012 Run time: 06:53:30 \n"
+"\n"
+"\n"
+" Please reference: Collaborative Computational Project, Number 4. 1994.\n"
+" \"The CCP4 Suite: Programs for Protein Crystallography\". Acta Cryst. D50, 760-763.\n"
+" as well as any specific reference in the program write-up.\n"
+"\n"
+"<!--SUMMARY_END--></FONT></B>\n"
+"\n" );
+}
+
+void ccperror ( int, cpstr ) {}
+
+#define _ccp4_
+
+#endif
+
+
 void printInstructions ( pstr argv0 )  {
 
   printf (
@@ -43,25 +78,28 @@ void printInstructions ( pstr argv0 )  {
 #endif
     " Protein Structure Superposition\n"
     " -------------------------------\n"
+    " v."superpose_version" from "superpose_date"\n"
     "\n"
     " USAGE:\n"
     "\n"
-    "%s s1.pdb [-s CID1] s2.pdb [-s CID2] [ foo_out.pdb ]\n"
+    " %s q.pdb [-s CIDQ] t1.pdb [-s CID1] ... tN.pdb [-s CIDN] [-o foo_out.pdb]\n"
     "\n"
-    "where  s1.pdb is the Query structure to which transformation applied,\n"
-    "       s2.pdb is the fixed Target structure,\n"
-    "       [-s CID1/2] are optional selection strings in MMDB convention, and\n"
-    "       [foo_out.pdb] is optional output file.\n"
-    "Instead of using asterisks '*' for selecting all atoms, '-all'\n"
-    "may be used, such that\n"
+    " where  q.pdb  is the Query structure to which transformation applied,\n"
+    "        ti.pdb is the ith fixed Target structure,\n"
+    "        [-s CIDi] are optional selection strings in MMDB convention, and\n"
+    "        [-o foo_out.pdb] is optional output file specification.\n"
+    " If more than one target is specified, multiple structure alignment\n"
+    " is calculated.\n"
+    "   Instead of using asterisks '*' for selecting all atoms, '-all'\n"
+    " may be used, such that\n"
     "\n"
-    "%s s1.pdb -s * s2.pdb -s * foo_out.pdb\n"
+    " %s q.pdb -s * t.pdb -s * foo_out.pdb\n"
     "\n"
-    "and \n"
+    " and \n"
     "\n"
-    "%s s1.pdb -s -all s2.pdb -s -all foo_out.pdb\n"
+    " %s q.pdb -s -all t.pdb -s -all foo_out.pdb\n"
     "\n"
-    "are equivalent.\n"
+    " are equivalent.\n"
 #ifdef _ccp4_
     "$$\n"
 #endif
@@ -110,20 +148,20 @@ int  rc,lcount;
 }
 
 int selectAtoms ( PCMMDBManager M, char ** argv, int & argNo,
-                  int & selHnd )  {
-pstr sel;
+                  pstr & sel, int & selHnd )  {
 int  nSel;
+
   selHnd = 0;
+  sel    = NULL;
+
   if (!strcasecmp(argv[argNo],"-s"))  {
     argNo++;
-    sel = NULL;
     CreateCopy ( sel,argv[argNo] );
     if (!strcmp(sel,"-all"))
-      strcpy ( sel,"*" );
+      CreateCopy ( sel,"*" );
     selHnd = M->NewSelection();
     M->Select ( selHnd,STYPE_ATOM,sel,SKEY_NEW );
     nSel = M->GetSelLength ( selHnd );
-    if (sel)  delete[] sel;
     if (nSel<=0)  {
       printf ( " *** Selection string '%s' does not cover "
                "any atoms.\n",argv[argNo] );
@@ -132,106 +170,69 @@ int  nSel;
     printf ( " ... %i atoms selected using CID '%s'\n",
              nSel,argv[argNo] );
     argNo++;
-  }
+  } else
+    CreateCopy ( sel,"*" );
+
   return 0;
-}
 
+}
 
 
-void printccp4rot ( mat44 m )
-{
-  double w_, x_, y_, z_;
-  double d = 180.0/3.14159265359;
-  double tr = m[0][0] + m[1][1] + m[2][2] + 1.0;
-  // check the diagonal
-  if ( tr > 1.0e-8 ) {
-    double s( sqrt(tr) );
-    w_ = s * 0.5;
-    s = 0.5 / s;
-    x_ = s * ( m[2][1] - m[1][2] );
-    y_ = s * ( m[0][2] - m[2][0] );
-    z_ = s * ( m[1][0] - m[0][1] );
-  } else {
-    if ( m[0][0] > m[1][1] && m[0][0] > m[2][2] ) {
-      double s( sqrt(1.0 + m[0][0] - m[1][1] - m[2][2] ) );
-      x_ = 0.5 * s;
-      if ( s != 0.0 ) s = 0.5 / s;
-      w_ = s * ( m[2][1] - m[1][2] );
-      y_ = s * ( m[0][1] + m[1][0] );
-      z_ = s * ( m[0][2] + m[2][0] );
-    } else if ( m[1][1] > m[2][2] ) {
-      double s( sqrt(1.0 + m[1][1] - m[2][2] - m[0][0] ) );
-      y_ = 0.5 * s;
-      if ( s != 0.0 ) s = 0.5 / s;
-      w_ = s * ( m[0][2] - m[2][0] );
-      z_ = s * ( m[1][2] + m[2][1] );
-      x_ = s * ( m[1][0] + m[0][1] );
-    } else {
-      double s( sqrt(1.0 + m[2][2] - m[0][0] - m[1][1] ) );
-      z_ = 0.5 * s;
-      if ( s != 0.0 ) s = 0.5 / s;
-      w_ = s * ( m[1][0] - m[0][1] );
-      x_ = s * ( m[2][0] + m[0][2] );
-      y_ = s * ( m[2][1] + m[1][2] );
+/*
+void CrystReadyState ( PCMMDBManager M, pstr S )  {
+int CRRDY = M->CrystReady();
+
+  S[0] = char(0);
+
+  if (CRRDY==CRRDY_Complete)
+    strcpy ( S,"Complete" );
+  if (CRRDY==CRRDY_NoTransfMatrices)
+    strcpy ( S,"No transormation matrices" );
+  if (CRRDY==CRRDY_Unchecked)
+    strcpy ( S,"Unchecked" );
+  if (CRRDY==CRRDY_Ambiguous)
+    strcpy ( S,"Ambiguous" );
+  if (CRRDY==CRRDY_NoCell)
+    strcpy ( S,"No cell" );
+  if (CRRDY==CRRDY_NoSpaceGroup)
+    strcpy ( S,"No space group" );
+
+  if (!S[0])  {
+
+    if (CRRDY<0)
+      sprintf ( S,"Unknown code %i",CRRDY );
+    else  {
+      if (CRRDY & CRRDY_NotPrecise)
+        strcat ( S,"Not precise;" );
+      if (CRRDY & CRRDY_isTranslation)
+        strcat ( S,"Has translation;" );
+      if (CRRDY & CRRDY_NoOrthCode)
+        strcat ( S,"No orthogonalisation code;" );
     }
-  }
-  double om, ph, ka, al, be, ga;
-  om = ph = ka = 0.0;
-  if ( fabs(w_) < 0.999999 ) {
-    double r = sqrt( x_*x_ + y_*y_ );
-    om = d*atan2( r, z_ );
-    if ( r > 0.000001 ) ph = d*atan2( y_, x_ );
-    ka = d*2.0*acos( w_ );
-  }
-  double ca, cb, cg, sa, sb, sg;
-  cb = 1.0 - 2.0 * (x_*x_ + y_*y_);
-  sb = 2.0 * sqrt( (x_*x_ + y_*y_) * (w_*w_ + z_*z_) );
-  if ( sb > 0.0001 ) {
-    ca = 2.0 * (x_*z_ + w_*y_);
-    sa = 2.0 * (y_*z_ - w_*x_);
-    cg = 2.0 * (w_*y_ - x_*z_);
-    sg = 2.0 * (y_*z_ + w_*x_);
-  } else {
-    ca = 1.0;
-    sa = 0.0;
-    cg = cb;
-    sg = 2.0*(y_*z_ + w_*x_);
-  }
-  al = d*atan2(sa,ca);
-  be = d*atan2(sb,cb);
-  ga = d*atan2(sg,cg);
-
-  printf( "\nCCP4 format rotation-translation operator\n" );
-  printf( "Polar angles (omega,phi,kappa) : %9.3f %9.3f %9.3f\n", om, ph, ka );
-  printf( "Euler angles (alpha,beta,gamma): %9.3f %9.3f %9.3f\n", al, be, ga );
-  printf( "Orthogonal translation (/Angst): %9.3f %9.3f %9.3f\n", m[0][3],m[1][3],m[2][3] );
-}
 
+  }
 
+}
+*/
 
 int main ( int argc, char ** argv, char ** env )  {
 UNUSED_ARGUMENT(env);
-CFile         f;
-PCMMDBManager M1,M2;
-PCSSMAlign    SSMAlign;
-pstr          name1,name2, fileout;
-int           argNo,selHnd1,selHnd2,rc;
-
+PPCMMDBManager M;
+psvector       name;
+psvector       selstring;
+pstr           fileout;
+ivector        selHnd;
+int            argNo,i,nStructures,rc;
 
 #ifdef _ccp4_
   ccp4ProgramName ( "SUPERPOSE" );
   ccp4_banner();
-
-  printf ( "$TEXT:Reference: $$Please cite$$\n"
-    "E. Krissinel and K. Henrick (2004). Secondary-structure matching (SSM),\n"
-    "a new tool for fast protein structure alignment in three dimensions.\n"
-    " Acta Cryst. D60, 2256-2268.\n"
-    "$$\n" );
-
-  printf ( "<!--SUMMARY_BEGIN-->\n" );
 #endif
 
   if (argc<=1)  {
+#ifdef _ccp4_
+    printf ( "<!--SUMMARY_BEGIN-->\n" );
+#endif
     printInstructions ( argv[0] );
 #ifdef _ccp4_
     printf ( "<!--SUMMARY_END-->\n" );
@@ -240,6 +241,9 @@ int           argNo,selHnd1,selHnd2,rc;
     return 1;
   }
 
+#ifdef _ccp4_
+  printf ( "<!--SUMMARY_BEGIN-->\n" );
+#endif
   if ((!strcmp(argv[1],"-?")) || (!strcasecmp(argv[1],"-help")) ||
       (!strcasecmp(argv[1],"--help")))  {
     printInstructions ( argv[0] );
@@ -250,175 +254,125 @@ int           argNo,selHnd1,selHnd2,rc;
     return 2;
   }
 
-  InitMatType();
-  InitSSGraph();
-
-
-  M1      = NULL;
-  name1   = NULL;
-  M2      = NULL;
-  name2   = NULL;
-  fileout = NULL;
-  argNo   = 1;
-
-  selHnd1 = 0;
-  selHnd2 = 0;
+  printf ( "\n"
+    " Superpose v."superpose_version" from "superpose_date" "
+                                        "(based on SSM algorithm)\n"
+    " ---------------------------------------------------------\n\n"
+   );
 
-  CreateCopy ( name1,argv[argNo] );
-  if (readCoorFile(argv[argNo++],M1))  {
-    if (name1) delete name1;
-#ifdef _ccp4_
-    printf ( "<!--SUMMARY_END-->\n" );
-    ccperror ( 3,"Wrong input" );
-#endif
-    return 3;
-  }
-  if (selectAtoms(M1,argv,argNo,selHnd1))  {
-    delete M1;
-    if (name1) delete name1;
-#ifdef _ccp4_
-    printf ( "<!--SUMMARY_END-->\n" );
-    ccperror ( 4,"Wrong input" );
-#endif
-    return 4;
-  }
+  InitMatType();
+  ssm::InitGraph();
 
-  CreateCopy ( name2,argv[argNo] );
-  if (readCoorFile(argv[argNo++],M2))  {
-    delete M1;
-    delete M2;
-    if (name1) delete name1;
-    if (name2) delete name2;
-#ifdef _ccp4_
-    printf ( "<!--SUMMARY_END-->\n" );
-    ccperror ( 5,"Wrong input" );
-#endif
-    return 5;
+  printf (
+  " ================================================================\n"
+         );
+
+  M = new PCMMDBManager[argc];
+  GetVectorMemory ( name     ,argc,0 );
+  GetVectorMemory ( selstring,argc,0 );
+  GetVectorMemory ( selHnd   ,argc,0 );
+  for (i=0;i<argc;i++)  {
+    M        [i] = NULL;
+    name     [i] = NULL;
+    selstring[i] = NULL;
+    selHnd   [i] = 0;
   }
-  if (argNo<argc)  {
-    if (selectAtoms(M2,argv,argNo,selHnd2))  {
-      delete M1;
-      delete M2;
-      if (name1) delete name1;
-      if (name2) delete name2;
-  #ifdef _ccp4_
-      printf ( "<!--SUMMARY_END-->\n" );
-      ccperror ( 6,"Wrong input" );
-  #endif
-      return 6;
+  fileout     = NULL;
+  nStructures = 0;
+
+  argNo = 1;
+  rc    = 0;
+  while ((argNo<argc) && (!rc))  {
+    if (!strcasecmp(argv[argNo],"-o"))  {
+      argNo++;
+      if (argNo<argc)
+        CreateCopy ( fileout,argv[argNo++] );
+    } else  {
+      CreateCopy ( name[nStructures],argv[argNo] );
+      if (readCoorFile(argv[argNo++],M[nStructures]))
+        rc = 3;
+      else if (argNo<argc)  {
+        if (selectAtoms(M[nStructures],argv,argNo,
+                selstring[nStructures],selHnd[nStructures]))
+          rc = 4;
+      } else
+        CreateCopy ( selstring[nStructures],"*" );
+      nStructures++;
     }
   }
 
-  if (argNo<argc)  {
-    CreateCopy ( fileout,argv[argNo] );
-    printf ( "\n Transformed coordinates will be written to file %s \n",
-             fileout );
-  }
+  if (!rc)  {
 
-  SSMAlign = new CSSMAlign();
-  rc = SSMAlign->Align ( M1,M2,SSMP_Normal,CSSC_Flexible,
-                               selHnd1,selHnd2 );
+    printf (
+  " ================================================================\n"
+      "\n" );
 
 #ifdef _ccp4_
-  printf ( "<!--SUMMARY_END-->\n" );
+    printf ( "<!--SUMMARY_END-->\n" );
 #endif
 
-  if (rc)  {
-    switch (rc)  {
-      case SSM_noHits :
-         printf ( " *** secondary structure does not match.\n" );
-         break;
-      case SSM_noSPSN :
-         printf ( " *** structures are too remote.\n" );
-         break;
-      case SSM_noGraph :
-         printf ( " *** can't make graph for %s.\n",name1 );
-         break;
-      case SSM_noVertices :
-         printf ( " *** empty graph for %s.\n",name1 );
-         break;
-      case SSM_noGraph2 :
-         printf ( " *** can't make graph for %s.\n",name2 );
-         break;
-      case SSM_noVertices2 :
-         printf ( " *** empty graph for %s.\n",name2 );
-         break;
-      default :
-        printf ( " *** undocumented return code %i.\n",rc );
-    }
+    if (nStructures<2)  {
+      printf ( " *** too few structures on input (%i).\n",nStructures );
 #ifdef _ccp4_
-    printf ( "$$\n" );
+      ccperror ( rc,"Wrong input" );
 #endif
-  } else  {
-    printf ( "\n"
-             " Query      %s\n"
-             " and Target %s\n"
-             " have been superposed. Transformation matrix "
-                                                    "(to be applied\n"
-             " to %s) is\n\n"
-             "        Rx         Ry         Rz           T\n"
-             " %10.3f %10.3f %10.3f   %10.3f\n"
-             " %10.3f %10.3f %10.3f   %10.3f\n"
-             " %10.3f %10.3f %10.3f   %10.3f\n\n"
-             " at RMSD = %10.3f, Q=%10.3f and alignment length %i\n",
-             name1,name2,name1,
-             SSMAlign->TMatrix[0][0],SSMAlign->TMatrix[0][1],
-             SSMAlign->TMatrix[0][2],SSMAlign->TMatrix[0][3],
-             SSMAlign->TMatrix[1][0],SSMAlign->TMatrix[1][1],
-             SSMAlign->TMatrix[1][2],SSMAlign->TMatrix[1][3],
-             SSMAlign->TMatrix[2][0],SSMAlign->TMatrix[2][1],
-             SSMAlign->TMatrix[2][2],SSMAlign->TMatrix[2][3],
-             SSMAlign->rmsd,SSMAlign->Qscore,SSMAlign->nalgn );
+    } else if (nStructures==2)
+      rc = pairwise_superposition ( M,name,selHnd,fileout );
+    else
+      rc = multiple_superposition ( M,selstring,name,selHnd,
+                                    nStructures,fileout );
 
+  }
 #ifdef _ccp4_
-    printf ( "$$\n" );
+    else  {
+      printf ( "<!--SUMMARY_END-->\n" );
+      ccperror ( rc,"Wrong input" );
+  }
 #endif
 
-    f.assign ( "stdout" );
-    f.rewrite();
-
-    PrintSSMAlignTable ( f,M1,M2,SSMAlign );
-
-/*
-char S[200];
-int  i;
-    f.WriteLine ( " \n\n Test output for Paul Emsley:\n\n"
-                  "   i    Ca1[i]   dist1[i]" );
-    for (i=0;i<SSMAlign->nres1;i++)  {
-      sprintf ( S," %5i %5i %10.3f",i,SSMAlign->Ca1[i],
-                                      SSMAlign->dist1[i] );
-      f.WriteLine ( S );
-    }
-    f.WriteLine ( "\n\n   i    Ca2[i]" );
-    for (i=0;i<SSMAlign->nres2;i++)  {
-      sprintf ( S," %5i %5i",i,SSMAlign->Ca2[i] );
-      f.WriteLine ( S );
-    }
-*/
-
-    f.shut();
-
-    // if output file requested, apply transform to first
-    // input file (NB all file, not just requested selection)
-    // and output
-    if ( fileout ) {
-      M1->ApplyTransform ( SSMAlign->TMatrix );
-      M1->WritePDBASCII ( fileout );
-    }
-
-    printccp4rot( SSMAlign->TMatrix );
-
+  for (i=0;i<argc;i++)  {
+    if (M[i])          delete   M[i];
+    if (selstring[i])  delete[] selstring[i];
+    if (name[i])       delete[] name[i];
   }
-
-  if (M1)       delete M1;
-  if (name1)    delete name1;
-  if (M2)       delete M2;
-  if (name2)    delete name2;
-  if (fileout)  delete fileout;
-  if (SSMAlign) delete SSMAlign;
+  delete[] M;
+  FreeVectorMemory ( selstring,0 );
+  FreeVectorMemory ( name     ,0 );
+  FreeVectorMemory ( selHnd   ,0 );
+  if (fileout)  delete[] fileout;
 
 #ifdef _ccp4_
+  if (nStructures<=2)
+    printf ( "$TEXT:Reference: $$Please cite$$\n"
+    " E. Krissinel and K. Henrick (2004). Secondary-structure matching (SSM),\n"
+    " a new tool for fast protein structure alignment in three dimensions.\n"
+    " Acta Cryst. D60, 2256-2268.\n"
+    "<a href=\"http://www.ebi.ac.uk/msd-srv/ssm/papers/ssm_reprint.pdf\">"
+    "PDF</a>\n$$\n" );
+  else
+    printf ( "$TEXT:Reference: $$Please cite$$\n"
+    " E. Krissinel and K. Henrick (2005). Multiple Alignment of Protein\n"
+    " Structures in Three Dimensions. In: M.R. Berthold et.al. (Eds.):\n"
+    " CompLife 2005, LNBI 3695, 67-78. Springer-Verlag Berlin Heidelberg.\n"
+    "<a href=\"http://www.ebi.ac.uk/msd-srv/ssm/papers/ssm-ma.pdf\">"
+    "PDF</a>\n$$\n" );
   ccperror ( 0,"Normal termination" );
+#else
+  printf ( "\n"
+  " ----------------------------------------------------------------\n"
+    "\n"
+    " Please cite:\n" );
+  if (nStructures<=2)
+    printf (
+    " E. Krissinel and K. Henrick (2004). Secondary-structure matching (SSM),\n"
+    " a new tool for fast protein structure alignment in three dimensions.\n"
+    " Acta Cryst. D60, 2256-2268.\n\n" );
+  else
+    printf (
+    " E. Krissinel and K. Henrick (2005). Multiple Alignment of Protein\n"
+    " Structures in Three Dimensions. In: M.R. Berthold et.al. (Eds.):\n"
+    " CompLife 2005, LNBI 3695, 67-78. Springer-Verlag Berlin Heidelberg.\n\n"
+           );
 #endif
 
   return 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ssm.git



More information about the debian-science-commits mailing list