[proj] 02/15: Imported Upstream version 4.9.3~rc1+ds

Bas Couwenberg sebastic at debian.org
Tue Aug 16 10:04:21 UTC 2016


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

sebastic pushed a commit to branch master
in repository proj.

commit da025dd9a81fd733ff33d4a654fc77c73d261eda
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Tue Aug 16 10:35:27 2016 +0200

    Imported Upstream version 4.9.3~rc1+ds
---
 CMakeLists.txt                |    6 +-
 ChangeLog                     |    3 +
 Makefile.in                   |   57 +-
 aclocal.m4                    |  103 +-
 cmake/Makefile.in             |   35 +-
 cmake/Proj4Mac.cmake          |    3 +-
 cmake/Proj4Test.cmake         |    4 +-
 compile                       |    2 +-
 config.guess                  |   12 +-
 config.sub                    |    8 +-
 configure                     | 4541 ++++++++++-----------------------
 configure.in => configure.ac  |   19 +-
 depcomp                       |  672 +++--
 install-sh                    |  385 ++-
 jniwrap/Makefile.in           |   35 +-
 jniwrap/org/Makefile.in       |   35 +-
 jniwrap/org/proj4/Makefile.in |   35 +-
 ltconfig                      | 3078 -----------------------
 ltmain.sh                     | 5508 ++++++++++++++++++++++++++---------------
 m4/libtool.m4                 | 2546 +++++++++++--------
 m4/ltoptions.m4               |  127 +-
 m4/ltsugar.m4                 |    7 +-
 m4/ltversion.m4               |   12 +-
 m4/lt~obsolete.m4             |    7 +-
 man/Makefile.in               |   35 +-
 man/man1/Makefile.in          |   35 +-
 man/man1/cs2cs.1              |    9 +-
 man/man1/geod.1               |    7 +-
 man/man1/proj.1               |   22 +-
 man/man3/Makefile.in          |   35 +-
 man/man3/geodesic.3           |   46 +-
 man/man3/pj_init.3            |    8 +-
 missing                       |  455 ++--
 mkinstalldirs                 |   38 -
 nad/Makefile.in               |   39 +-
 nad/epsg                      |  962 ++++++-
 nad/install.in                |   53 +
 nad/makefile.vc               |    2 +-
 nad/testvarious               |  211 +-
 nad/tv_out.dist               |  142 +-
 src/CMakeLists.txt            |    1 +
 src/Makefile.am               |   21 +-
 src/Makefile.in               |  128 +-
 src/PJ_aea.c                  |  313 ++-
 src/PJ_aeqd.c                 |  547 ++--
 src/PJ_airy.c                 |  146 +-
 src/PJ_aitoff.c               |  225 +-
 src/PJ_august.c               |   58 +-
 src/PJ_bacon.c                |  184 +-
 src/PJ_bipc.c                 |  348 ++-
 src/PJ_boggs.c                |   58 +-
 src/PJ_bonne.c                |  181 +-
 src/PJ_calcofi.c              |  166 +-
 src/PJ_cass.c                 |  243 +-
 src/PJ_cc.c                   |   87 +-
 src/PJ_cea.c                  |  214 +-
 src/PJ_chamb.c                |  275 +-
 src/PJ_collg.c                |   78 +-
 src/PJ_comill.c               |  131 +
 src/PJ_crast.c                |  112 +-
 src/PJ_denoy.c                |   82 +-
 src/PJ_eck1.c                 |  113 +-
 src/PJ_eck2.c                 |  125 +-
 src/PJ_eck3.c                 |  335 ++-
 src/PJ_eck4.c                 |  162 +-
 src/PJ_eck5.c                 |  113 +-
 src/PJ_eqc.c                  |  123 +-
 src/PJ_eqdc.c                 |  265 +-
 src/PJ_fahey.c                |  114 +-
 src/PJ_fouc_s.c               |  157 +-
 src/PJ_gall.c                 |  113 +-
 src/PJ_geos.c                 |  417 ++--
 src/PJ_gins8.c                |   87 +-
 src/PJ_gn_sinu.c              |  445 +++-
 src/PJ_gnom.c                 |  287 ++-
 src/PJ_goode.c                |  171 +-
 src/PJ_gstmerc.c              |  171 +-
 src/PJ_hammer.c               |  152 +-
 src/PJ_hatano.c               |  185 +-
 src/PJ_healpix.c              |  825 +++---
 src/PJ_igh.c                  |  348 ++-
 src/PJ_imw_p.c                |  371 +--
 src/PJ_isea.c                 | 2295 ++++++++---------
 src/PJ_krovak.c               |  370 +--
 src/PJ_labrd.c                |  287 ++-
 src/PJ_laea.c                 |  553 +++--
 src/PJ_lagrng.c               |  132 +-
 src/PJ_larr.c                 |   77 +-
 src/PJ_lask.c                 |  102 +-
 src/PJ_lcc.c                  |  291 ++-
 src/PJ_lcca.c                 |  206 +-
 src/PJ_loxim.c                |  163 +-
 src/PJ_lsat.c                 |  391 +--
 src/PJ_mbt_fps.c              |  129 +-
 src/PJ_mbtfpp.c               |  139 +-
 src/PJ_mbtfpq.c               |  159 +-
 src/PJ_merc.c                 |  167 +-
 src/PJ_mill.c                 |  101 +-
 src/PJ_misrsom.c              |  281 +++
 src/PJ_mod_ster.c             |  726 ++++--
 src/PJ_moll.c                 |  301 ++-
 src/PJ_natearth.c             |  155 +-
 src/PJ_natearth2.c            |  147 ++
 src/PJ_nell.c                 |  128 +-
 src/PJ_nell_h.c               |  129 +-
 src/PJ_nocol.c                |  130 +-
 src/PJ_nsper.c                |  420 ++--
 src/PJ_nzmg.c                 |  202 +-
 src/PJ_ob_tran.c              |  334 ++-
 src/PJ_ocea.c                 |  213 +-
 src/PJ_oea.c                  |  150 +-
 src/PJ_omerc.c                |  395 +--
 src/PJ_ortho.c                |  139 +-
 src/PJ_patterson.c            |  167 ++
 src/PJ_poly.c                 |  174 +-
 src/PJ_putp2.c                |   88 +-
 src/PJ_putp3.c                |  191 +-
 src/PJ_putp4p.c               |  200 +-
 src/PJ_putp5.c                |  192 +-
 src/PJ_putp6.c                |  247 +-
 src/PJ_qsc.c                  |  676 ++---
 src/PJ_robin.c                |  195 +-
 src/PJ_rpoly.c                |  128 +-
 src/PJ_sch.c                  |  268 ++
 src/PJ_sconics.c              |  827 +++++--
 src/PJ_somerc.c               |  219 +-
 src/PJ_stere.c                |  612 +++--
 src/PJ_sterea.c               |  205 +-
 src/PJ_sts.c                  |  367 ++-
 src/PJ_tcc.c                  |   76 +-
 src/PJ_tcea.c                 |  104 +-
 src/PJ_tmerc.c                |  395 +--
 src/PJ_tpeqd.c                |  193 +-
 src/PJ_urm5.c                 |  103 +-
 src/PJ_urmfps.c               |  176 +-
 src/PJ_vandg.c                |  226 +-
 src/PJ_vandg2.c               |  185 +-
 src/PJ_vandg4.c               |  139 +-
 src/PJ_wag2.c                 |   81 +-
 src/PJ_wag3.c                 |  103 +-
 src/PJ_wag7.c                 |   66 +-
 src/PJ_wink1.c                |  104 +-
 src/PJ_wink2.c                |   94 +-
 src/aasincos.c                |    4 +-
 src/bchgen.c                  |    8 +-
 src/dmstor.c                  |    2 +-
 src/gen_cheb.c                |   10 +-
 src/geod.c                    |    4 +-
 src/geod_interface.c          |   22 +-
 src/geod_set.c                |    2 +-
 src/geodesic.c                |  278 ++-
 src/geodesic.h                |  481 ++--
 src/lib_proj.cmake            |   17 +-
 src/makefile.vc               |   19 +-
 src/nad2bin.c                 |    5 +-
 src/nad_cvt.c                 |    2 +-
 src/pj_apply_vgridshift.c     |    6 +-
 src/pj_deriv.c                |    4 +-
 src/pj_ell_set.c              |    2 +-
 src/pj_factors.c              |    6 +-
 src/pj_fwd.c                  |   23 +-
 src/pj_fwd3d.c                |   47 +
 src/pj_gauss.c                |   12 +-
 src/pj_generic_selftest.c     |  197 ++
 src/pj_geocent.c              |   94 +-
 src/pj_gridinfo.c             |   30 +-
 src/pj_gridlist.c             |    5 +-
 src/pj_init.c                 |   96 +-
 src/pj_inv.c                  |   19 +-
 src/pj_inv3d.c                |   45 +
 src/pj_latlong.c              |  120 +-
 src/pj_list.c                 |   49 +-
 src/pj_list.h                 |    6 +
 src/pj_malloc.c               |   57 +-
 src/pj_mutex.c                |   10 +-
 src/pj_phi2.c                 |    5 +-
 src/pj_release.c              |    2 +-
 src/pj_run_selftests.c        |   78 +
 src/pj_strtod.c               |    6 +
 src/pj_transform.c            |  276 ++-
 src/pj_tsfn.c                 |    4 +-
 src/pj_utils.c                |   30 +-
 src/pj_zpoly1.c               |    2 +-
 src/proj.c                    |   15 +-
 src/proj.def                  |  165 +-
 src/proj_api.h                |   32 +-
 src/proj_config.h.in          |    5 +-
 src/proj_etmerc.c             |  354 ++-
 src/proj_rouss.c              |  258 +-
 src/projects.h                |  153 +-
 src/rtodms.c                  |   10 +-
 src/test228.c                 |    6 +-
 192 files changed, 28785 insertions(+), 18527 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 63c5d44..b6b2bf3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,9 +31,9 @@ colormsg(_HIBLUE_ "Configuring PROJ:")
 #PROJ version information
 #################################################################################
 include(Proj4Version)
-proj_version(MAJOR 4 MINOR 9 PATCH 2)
-set(PROJ_API_VERSION "9")
-set(PROJ_BUILD_VERSION "10.0.1")
+proj_version(MAJOR 4 MINOR 9 PATCH 3)
+set(PROJ_API_VERSION "12")
+set(PROJ_BUILD_VERSION "12.0.0")
 
 #################################################################################
 # Build features and variants
diff --git a/ChangeLog b/ChangeLog
index dfa6726..ece889c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2015-12-13: jswhit <https://github.com/jswhit>
+	* : Add inverse hammer transform (pull request #329).
+
 2015-09-10 sisyphus <https://github.com/sisyphus>
 	* : Rename PVALUE in pj_param.cto prevent Windows variable name clash
 
diff --git a/Makefile.in b/Makefile.in
index 7d3fbcc..1a54f5e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,17 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -79,21 +89,18 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = .
-DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
-	$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/configure $(am__configure_deps) mkinstalldirs \
-	$(srcdir)/proj.pc.in COPYING compile config.guess config.sub \
-	depcomp install-sh missing ltmain.sh ltconfig
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
+	$(am__configure_deps) $(am__DIST_COMMON)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/proj_config.h
 CONFIG_CLEAN_FILES = proj.pc
 CONFIG_CLEAN_VPATH_FILES =
@@ -182,6 +189,9 @@ ETAGS = etags
 CTAGS = ctags
 CSCOPE = cscope
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/proj.pc.in AUTHORS \
+	COPYING ChangeLog INSTALL NEWS README compile config.guess \
+	config.sub depcomp install-sh ltmain.sh missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -265,7 +275,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -354,7 +364,7 @@ all: all-recursive
 .SUFFIXES:
 am--refresh: Makefile
 	@:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -367,7 +377,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -381,9 +390,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	$(SHELL) ./config.status --recheck
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	$(am__cd) $(srcdir) && $(AUTOCONF)
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 $(am__aclocal_m4_deps):
 proj.pc: $(top_builddir)/config.status $(srcdir)/proj.pc.in
@@ -606,15 +615,15 @@ dist-xz: distdir
 	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
-	@echo WARNING: "Support for shar distribution archives is" \
-	               "deprecated." >&2
+	@echo WARNING: "Support for distribution archives compressed with" \
+		       "legacy program 'compress' is deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 	$(am__post_remove_distdir)
 
 dist-shar: distdir
-	@echo WARNING: "Support for distribution archives compressed with" \
-		       "legacy program 'compress' is deprecated." >&2
+	@echo WARNING: "Support for shar distribution archives is" \
+	               "deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 	$(am__post_remove_distdir)
@@ -649,17 +658,17 @@ distcheck: dist
 	esac
 	chmod -R a-w $(distdir)
 	chmod u+w $(distdir)
-	mkdir $(distdir)/_build $(distdir)/_inst
+	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
 	chmod a-w $(distdir)
 	test -d $(distdir)/_build || exit 0; \
 	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
 	  && am__cwd=`pwd` \
-	  && $(am__cd) $(distdir)/_build \
-	  && ../configure \
+	  && $(am__cd) $(distdir)/_build/sub \
+	  && ../../configure \
 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
-	    --srcdir=.. --prefix="$$dc_install_base" \
+	    --srcdir=../.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
@@ -839,6 +848,8 @@ uninstall-am: uninstall-pkgconfigDATA
 	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
 	uninstall-am uninstall-pkgconfigDATA
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/aclocal.m4 b/aclocal.m4
index c7f3d53..87e17ce 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.15 -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,7 @@ 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'.])])
 
-# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+# Copyright (C) 2002-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -32,10 +32,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.14'
+[am__api_version='1.15'
 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.14.1], [],
+m4_if([$1], [1.15], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -51,14 +51,14 @@ 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.14.1])dnl
+[AM_AUTOMAKE_VERSION([1.15])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -103,15 +103,14 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 # configured tree to be moved without reconfiguration.
 
 AC_DEFUN([AM_AUX_DIR_EXPAND],
-[dnl Rely on autoconf to set up CDPATH properly.
-AC_PREREQ([2.50])dnl
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
 ])
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -142,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -333,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -409,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -499,8 +498,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl
 # <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.
+# We need awk for the "check" target (and possibly the TAP driver).  The
+# system "awk" is bad on some platforms.
 AC_REQUIRE([AC_PROG_AWK])dnl
 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
@@ -573,7 +572,11 @@ to "yes", and re-run configure.
 END
     AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
   fi
-fi])
+fi
+dnl The trailing newline in this macro's definition is deliberate, for
+dnl backward compatibility and to allow trailing 'dnl'-style comments
+dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
+])
 
 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
@@ -602,7 +605,7 @@ 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-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -613,7 +616,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
 # Define $install_sh.
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-if test x"${install_sh}" != xset; then
+if test x"${install_sh+set}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -623,7 +626,7 @@ if test x"${install_sh}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -642,45 +645,9 @@ fi
 rmdir .tst 2>/dev/null
 AC_SUBST([am__leading_dot])])
 
-# Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
-# From Jim Meyering
-
-# Copyright (C) 1996-2013 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.
-
-# 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
-# can override the default with the --enable/--disable switch.
-AC_DEFUN([AM_MAINTAINER_MODE],
-[m4_case(m4_default([$1], [disable]),
-       [enable], [m4_define([am_maintainer_other], [disable])],
-       [disable], [m4_define([am_maintainer_other], [enable])],
-       [m4_define([am_maintainer_other], [enable])
-        m4_warn([syntax], [unexpected argument to AM@&t at _MAINTAINER_MODE: $1])])
-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],
-    [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
-  AC_SUBST([MAINT])dnl
-]
-)
-
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -730,7 +697,7 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -771,7 +738,7 @@ fi
 # Obsolete and "removed" macros, that must however still report explicit
 # error messages when used, to smooth transition.
 #
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -798,7 +765,7 @@ AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -827,7 +794,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -874,7 +841,7 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -893,7 +860,7 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -974,7 +941,7 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+# Copyright (C) 2009-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1034,7 +1001,7 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1062,7 +1029,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1081,7 +1048,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+# Copyright (C) 2004-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/cmake/Makefile.in b/cmake/Makefile.in
index c7108fd..f28f5dc 100644
--- a/cmake/Makefile.in
+++ b/cmake/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -78,16 +88,15 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = cmake
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/mkinstalldirs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/proj_config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
@@ -111,6 +120,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -153,7 +163,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -248,7 +258,7 @@ EXTRA_DIST = CMakeLists.txt \
 all: all-am
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -260,7 +270,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cmake/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu cmake/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -273,9 +282,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
@@ -435,6 +444,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/cmake/Proj4Mac.cmake b/cmake/Proj4Mac.cmake
index c2448e7..9032d05 100644
--- a/cmake/Proj4Mac.cmake
+++ b/cmake/Proj4Mac.cmake
@@ -15,8 +15,7 @@ endif(APPLE)
 set(PROJ_RESOURCES "" )
 
 if(APPLE)
-   option(BUILD_FRAMEWORKS_AND_BUNDLE "if set to ON, build a library framework and application bundle,
-       otherwise install classical UNIX bin/lib" OFF )
+   option(BUILD_FRAMEWORKS_AND_BUNDLE "if set to ON, build a library framework and application bundle, otherwise install classical UNIX bin/lib" OFF )
    set(DEFAULT_BINDIR ${BUNDLEDIR})
    boost_report_value(BUNDLEDIR)
    boost_report_value(PROJ_INSTALL_NAME_DIR)
diff --git a/cmake/Proj4Test.cmake b/cmake/Proj4Test.cmake
index 7a0270c..a289f0c 100644
--- a/cmake/Proj4Test.cmake
+++ b/cmake/Proj4Test.cmake
@@ -15,9 +15,9 @@ function(proj_add_test_script_sh SH_NAME BIN_USE)
          endif(EXISTS ${GRID_FULLNAME})
     endif(ARGV2)
     
-    if( CMAKE_MINOR_VERSION LESS 8  OR CMAKE_PATCH_VERSION LESS 4 )
+    if( CMAKE_VERSION VERSION_LESS 2.8.4 )
        set(TEST_OK 0)
-       message(STATUS "test with bash script need a cmake version > 2.8.3 ")
+       message(STATUS "test with bash script need a cmake version >= 2.8.4")
     endif()
  
     if(${TEST_OK})
diff --git a/compile b/compile
index 531136b..a85b723 100755
--- a/compile
+++ b/compile
@@ -3,7 +3,7 @@
 
 scriptversion=2012-10-14.11; # UTC
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey at cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/config.guess b/config.guess
index 9726d28..6c32c86 100755
--- a/config.guess
+++ b/config.guess
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2015 Free Software Foundation, Inc.
+#   Copyright 1992-2014 Free Software Foundation, Inc.
 
-timestamp='2015-02-21'
+timestamp='2014-11-04'
 
 # 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
@@ -50,7 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2015 Free Software Foundation, Inc.
+Copyright 1992-2014 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."
@@ -168,10 +168,8 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	# Note: NetBSD doesn't particularly care about the vendor
 	# portion of the name.  We always set it to "unknown".
 	sysctl="sysctl -n hw.machine_arch"
-	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
-	    /sbin/$sysctl 2>/dev/null || \
-	    /usr/sbin/$sysctl 2>/dev/null || \
-	    echo unknown)`
+	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
 	case "${UNAME_MACHINE_ARCH}" in
 	    armeb) machine=armeb-unknown ;;
 	    arm*) machine=arm-unknown ;;
diff --git a/config.sub b/config.sub
index 6d2e94c..7ffe373 100755
--- a/config.sub
+++ b/config.sub
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2015 Free Software Foundation, Inc.
+#   Copyright 1992-2014 Free Software Foundation, Inc.
 
-timestamp='2015-01-01'
+timestamp='2014-12-03'
 
 # 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
@@ -68,7 +68,7 @@ Report bugs and patches to <config-patches at gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2015 Free Software Foundation, Inc.
+Copyright 1992-2014 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."
@@ -260,7 +260,7 @@ case $basic_machine in
 	| c4x | c8051 | clipper \
 	| d10v | d30v | dlx | dsp16xx \
 	| epiphany \
-	| fido | fr30 | frv | ft32 \
+	| fido | fr30 | frv \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| hexagon \
 	| i370 | i860 | i960 | ia64 \
diff --git a/configure b/configure
index 6f5383f..401ec2a 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for PROJ.4 Projections 4.9.2.
+# Generated by GNU Autoconf 2.69 for PROJ.4 Projections 4.9.3.
 #
 # Report bugs to <warmerdam at pobox.com>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='PROJ.4 Projections'
 PACKAGE_TARNAME='proj'
-PACKAGE_VERSION='4.9.2'
-PACKAGE_STRING='PROJ.4 Projections 4.9.2'
+PACKAGE_VERSION='4.9.3'
+PACKAGE_STRING='PROJ.4 Projections 4.9.3'
 PACKAGE_BUGREPORT='warmerdam at pobox.com'
 PACKAGE_URL=''
 
@@ -639,6 +639,7 @@ THREAD_LIB
 MUTEX_SETTING
 JNI_INCLUDE
 CPP
+LT_SYS_LIBRARY_PATH
 OTOOL64
 OTOOL
 LIPO
@@ -686,9 +687,6 @@ CPPFLAGS
 LDFLAGS
 CFLAGS
 CC
-MAINT
-MAINTAINER_MODE_FALSE
-MAINTAINER_MODE_TRUE
 AM_BACKSLASH
 AM_DEFAULT_VERBOSITY
 AM_DEFAULT_V
@@ -758,12 +756,12 @@ ac_subst_files=''
 ac_user_opts='
 enable_option_checking
 enable_silent_rules
-enable_maintainer_mode
 enable_dependency_tracking
 enable_shared
 enable_static
 with_pic
 enable_fast_install
+with_aix_soname
 with_gnu_ld
 with_sysroot
 enable_libtool_lock
@@ -778,6 +776,7 @@ CFLAGS
 LDFLAGS
 LIBS
 CPPFLAGS
+LT_SYS_LIBRARY_PATH
 CPP'
 
 
@@ -1319,7 +1318,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 PROJ.4 Projections 4.9.2 to adapt to many kinds of systems.
+\`configure' configures PROJ.4 Projections 4.9.3 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1389,7 +1388,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of PROJ.4 Projections 4.9.2:";;
+     short | recursive ) echo "Configuration of PROJ.4 Projections 4.9.3:";;
    esac
   cat <<\_ACEOF
 
@@ -1399,9 +1398,6 @@ Optional Features:
   --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-maintainer-mode
-                          enable make rules and dependencies not useful (and
-                          sometimes confusing) to the casual installer
   --enable-dependency-tracking
                           do not reject slow dependency extractors
   --disable-dependency-tracking
@@ -1417,10 +1413,14 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                           both]
+  --with-aix-soname=aix|svr4|both
+                          shared library versioning (aka "SONAME") variant to
+                          provide on AIX, [default=aix].
   --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).
+  --with-sysroot[=DIR]    Search for dependent libraries within DIR (or the
+                          compiler's sysroot if not specified).
   --with-jni=dir          Include Java/JNI support, add optional include dir
+
   --without-mutex         Disable real mutex locks (lacking pthreads)
 
 Some influential environment variables:
@@ -1431,6 +1431,8 @@ Some influential environment variables:
   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>
+  LT_SYS_LIBRARY_PATH
+              User-defined run-time library search path.
   CPP         C preprocessor
 
 Use these variables to override the choices made by `configure' or to help
@@ -1499,7 +1501,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-PROJ.4 Projections configure 4.9.2
+PROJ.4 Projections configure 4.9.3
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1914,7 +1916,7 @@ 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 PROJ.4 Projections $as_me 4.9.2, which was
+It was created by PROJ.4 Projections $as_me 4.9.3, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2270,10 +2272,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-am__api_version='1.14'
-
 ac_aux_dir=
-for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+for ac_dir in . "$srcdir"/.; do
   if test -f "$ac_dir/install-sh"; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/install-sh -c"
@@ -2289,7 +2289,7 @@ for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
   fi
 done
 if test -z "$ac_aux_dir"; then
-  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+  as_fn_error $? "cannot find install-sh, install.sh, or shtool in . \"$srcdir\"/." "$LINENO" 5
 fi
 
 # These three variables are undocumented and unsupported,
@@ -2301,6 +2301,8 @@ ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
 ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
 
+am__api_version='1.15'
+
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
 # incompatible versions:
@@ -2471,8 +2473,8 @@ test "$program_suffix" != NONE &&
 ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
 program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
 
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 if test x"${MISSING+set}" != xset; then
   case $am_aux_dir in
@@ -2491,7 +2493,7 @@ else
 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
 fi
 
-if test x"${install_sh}" != xset; then
+if test x"${install_sh+set}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -2785,7 +2787,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='proj'
- VERSION='4.9.2'
+ VERSION='4.9.3'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2819,8 +2821,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 # <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.
+# We need awk for the "check" target (and possibly the TAP driver).  The
+# system "awk" is bad on some platforms.
 # Always define AMTAR for backward compatibility.  Yes, it's still used
 # in the wild :-(  We should find a proper way to deprecate it ...
 AMTAR='$${TAR-tar}'
@@ -2878,28 +2880,6 @@ END
   fi
 fi
 
-{ $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.
-if test "${enable_maintainer_mode+set}" = set; then :
-  enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
-else
-  USE_MAINTAINER_MODE=no
-fi
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5
-$as_echo "$USE_MAINTAINER_MODE" >&6; }
-   if test $USE_MAINTAINER_MODE = yes; then
-  MAINTAINER_MODE_TRUE=
-  MAINTAINER_MODE_FALSE='#'
-else
-  MAINTAINER_MODE_TRUE='#'
-  MAINTAINER_MODE_FALSE=
-fi
-
-  MAINT=$MAINTAINER_MODE_TRUE
-
-
 ac_config_headers="$ac_config_headers src/proj_config.h"
 
 
@@ -4787,8 +4767,8 @@ esac
 
 
 
-macro_version='2.4.2'
-macro_revision='1.3337'
+macro_version='2.4.6'
+macro_revision='2.4.6'
 
 
 
@@ -4802,7 +4782,7 @@ macro_revision='1.3337'
 
 
 
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 
 # Make sure we can run config.sub.
 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
@@ -4922,7 +4902,7 @@ func_echo_all ()
     $ECHO ""
 }
 
-case "$ECHO" in
+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
@@ -5245,19 +5225,19 @@ test -z "$GREP" && GREP=grep
 
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
 else
   with_gnu_ld=no
 fi
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
 $as_echo_n "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -5271,7 +5251,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -5282,7 +5262,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
 $as_echo_n "checking for GNU ld... " >&6; }
 else
@@ -5293,32 +5273,32 @@ if ${lt_cv_path_LD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi
 fi
 
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
 $as_echo "$LD" >&6; }
@@ -5361,33 +5341,38 @@ if ${lt_cv_path_NM+:} false; then :
 else
   if test -n "$NM"; then
   # Let the user override the test.
-  lt_cv_path_NM="$NM"
+  lt_cv_path_NM=$NM
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
+  lt_nm_to_check=${ac_tool_prefix}nm
   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
     lt_nm_to_check="$lt_nm_to_check nm"
   fi
   for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
     for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
 	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
 	#   nm: unknown option "B" ignored
 	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
 	  lt_cv_path_NM="$tmp_nm -B"
-	  break
+	  break 2
 	  ;;
 	*)
 	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 	  */dev/null*)
 	    lt_cv_path_NM="$tmp_nm -p"
-	    break
+	    break 2
 	    ;;
 	  *)
 	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -5398,15 +5383,15 @@ else
 	esac
       fi
     done
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
   done
   : ${lt_cv_path_NM=no}
 fi
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
 else
   # Didn't find any BSD compatible name lister, look for dumpbin.
   if test -n "$DUMPBIN"; then :
@@ -5512,9 +5497,9 @@ esac
   fi
 fi
 
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
     *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
+      DUMPBIN="$DUMPBIN -symbols -headers"
       ;;
     *)
       DUMPBIN=:
@@ -5522,8 +5507,8 @@ fi
     esac
   fi
 
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
   fi
 fi
 test -z "$NM" && NM=nm
@@ -5563,7 +5548,7 @@ if ${lt_cv_sys_max_cmd_len+:} false; then :
   $as_echo_n "(cached) " >&6
 else
     i=0
-  teststring="ABCD"
+  teststring=ABCD
 
   case $build_os in
   msdosdjgpp*)
@@ -5603,7 +5588,7 @@ else
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -5654,22 +5639,22 @@ else
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
     if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
       # Make teststring a little bigger before we do anything with it.
       # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
+      for i in 1 2 3 4 5 6 7 8; do
         teststring=$teststring$teststring
       done
       SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
       # 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"`env 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
+	      test 17 != "$i" # 1/2 MB should be enough
       do
         i=`expr $i + 1`
         teststring=$teststring$teststring
@@ -5687,7 +5672,7 @@ else
 
 fi
 
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
 $as_echo "$lt_cv_sys_max_cmd_len" >&6; }
 else
@@ -5705,30 +5690,6 @@ max_cmd_len=$lt_cv_sys_max_cmd_len
 : ${MV="mv -f"}
 : ${RM="rm -f"}
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
-$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
-$as_echo "$xsi_shell" >&6; }
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
-$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
-$as_echo "$lt_shell_append" >&6; }
-
-
 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   lt_unset=unset
 else
@@ -5851,13 +5812,13 @@ esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       reload_cmds=false
     fi
     ;;
   darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -5985,13 +5946,13 @@ lt_cv_deplibs_check_method='unknown'
 # Need to set the preceding variable on all platforms that support
 # interlibrary dependencies.
 # 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
 # 'pass_all' -- all dependencies passed with no checks.
 # 'test_compile' -- check by making test program.
 # 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
 case $host_os in
 aix[4-9]*)
@@ -6018,8 +5979,7 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+  if ( file / ) >/dev/null 2>&1; then
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
@@ -6097,7 +6057,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-netbsd* | netbsdelf*-gnu)
+netbsd*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
   else
@@ -6115,8 +6075,8 @@ newos6*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
   else
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
@@ -6169,6 +6129,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 
 fi
@@ -6326,8 +6289,8 @@ else
 
 case $host_os in
 cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
   case `$DLLTOOL --help 2>&1` in
   *--identify-strict*)
     lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -6339,7 +6302,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   ;;
 *)
   # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
   ;;
 esac
 
@@ -6493,7 +6456,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-      if test "$ac_status" -eq 0; then
+      if test 0 -eq "$ac_status"; then
 	# Ensure the archiver fails upon bogus file names.
 	rm -f conftest.$ac_objext libconftest.a
 	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
@@ -6501,7 +6464,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-	if test "$ac_status" -ne 0; then
+	if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
         fi
       fi
@@ -6514,7 +6477,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
 $as_echo "$lt_cv_ar_at_file" >&6; }
 
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
 else
   archiver_list_spec=$lt_cv_ar_at_file
@@ -6731,7 +6694,7 @@ old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
-  openbsd*)
+  bitrig* | openbsd*)
     old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
@@ -6821,7 +6784,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     symcode='[ABCDEGRST]'
   fi
   ;;
@@ -6854,14 +6817,44 @@ case `$NM -V 2>&1` in
   symcode='[ABCDGIRSTW]' ;;
 esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
+
 # Transform an extracted symbol line into a proper C declaration.
 # Some systems (esp. on ia64) link data and code symbols differently,
 # so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
 # Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
 # Handle CRLF in mingw tool chain
 opt_cr=
@@ -6879,21 +6872,24 @@ for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
   if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
     # Also find C++ and __fastcall symbols from MSVC++,
     # 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};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 "     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
 "     ' prfx=^$ac_symprfx"
   else
     lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -6941,11 +6937,11 @@ _LT_EOF
 	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 	  cat <<_LT_EOF > conftest.$ac_ext
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT_DLSYM_CONST
 #else
@@ -6971,7 +6967,7 @@ lt__PROGRAM__LTX_preloaded_symbols[] =
 {
   { "@PROGRAM@", (void *) 0 },
 _LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 	  cat <<\_LT_EOF >> conftest.$ac_ext
   {0, (void *) 0}
 };
@@ -6991,13 +6987,13 @@ _LT_EOF
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  lt_globsym_save_LIBS=$LIBS
 	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
+	  LIBS=conftstm.$ac_objext
 	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
 	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
 	    pipe_works=yes
 	  fi
 	  LIBS=$lt_globsym_save_LIBS
@@ -7018,7 +7014,7 @@ _LT_EOF
   rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
+  if test yes = "$pipe_works"; then
     break
   else
     lt_cv_sys_global_symbol_pipe=
@@ -7071,6 +7067,16 @@ fi
 
 
 
+
+
+
+
+
+
+
+
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
 $as_echo_n "checking for sysroot... " >&6; }
 
@@ -7083,9 +7089,9 @@ fi
 
 
 lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
  yes)
-   if test "$GCC" = yes; then
+   if test yes = "$GCC"; then
      lt_sysroot=`$CC --print-sysroot 2>/dev/null`
    fi
    ;; #(
@@ -7095,8 +7101,8 @@ case ${with_sysroot} in #(
  no|'')
    ;; #(
  *)
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
-$as_echo "${with_sysroot}" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5
+$as_echo "$with_sysroot" >&6; }
    as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
    ;;
 esac
@@ -7108,18 +7114,99 @@ $as_echo "${lt_sysroot:-no}" >&6; }
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5
+$as_echo_n "checking for a working dd... " >&6; }
+if ${ac_cv_path_lt_DD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+if test -z "$lt_DD"; then
+  ac_path_lt_DD_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  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_prog in dd; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_lt_DD" || continue
+if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi
+      $ac_path_lt_DD_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_lt_DD"; then
+    :
+  fi
+else
+  ac_cv_path_lt_DD=$lt_DD
+fi
+
+rm -f conftest.i conftest2.i conftest.out
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5
+$as_echo "$ac_cv_path_lt_DD" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5
+$as_echo_n "checking how to truncate binary pipes... " >&6; }
+if ${lt_cv_truncate_bin+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5
+$as_echo "$lt_cv_truncate_bin" >&6; }
+
+
+
+
+
+
+
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+
 # Check whether --enable-libtool-lock was given.
 if test "${enable_libtool_lock+set}" = set; then :
   enableval=$enable_libtool_lock;
 fi
 
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
 ia64-*-hpux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -7128,24 +7215,25 @@ ia64-*-hpux*)
   test $ac_status = 0; }; then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
-	HPUX_IA64_MODE="32"
+	HPUX_IA64_MODE=32
 	;;
       *ELF-64*)
-	HPUX_IA64_MODE="64"
+	HPUX_IA64_MODE=64
 	;;
     esac
   fi
   rm -rf conftest*
   ;;
 *-*-irix6*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo '#line '$LINENO' "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
 	*32-bit*)
 	  LD="${LD-ld} -melf32bsmip"
@@ -7174,9 +7262,50 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
+
 x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -7199,10 +7328,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  powerpc64le-*)
+	  powerpc64le-*linux*)
 	    LD="${LD-ld} -m elf32lppclinux"
 	    ;;
-	  powerpc64-*)
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -7221,10 +7350,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
+	  powerpcle-*linux*)
 	    LD="${LD-ld} -m elf64lppc"
 	    ;;
-	  powerpc-*)
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -7242,7 +7371,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
 *-*-sco3.2v5*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
+  SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
 $as_echo_n "checking whether the C compiler needs -belf... " >&6; }
@@ -7282,13 +7411,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
 $as_echo "$lt_cv_cc_needs_belf" >&6; }
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+  if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
+    CFLAGS=$SAVE_CFLAGS
   fi
   ;;
 *-*solaris*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -7300,7 +7430,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
       case $lt_cv_prog_gnu_ld in
       yes*)
         case $host in
-        i?86-*-solaris*)
+        i?86-*-solaris*|x86_64-*-solaris*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
         sparc*-*-solaris*)
@@ -7309,7 +7439,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
         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"
+          LD=${LD-ld}_sol2
         fi
         ;;
       *)
@@ -7325,7 +7455,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
@@ -7436,7 +7566,7 @@ else
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
 $as_echo "$lt_cv_path_mainfest_tool" >&6; }
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
 
@@ -7939,7 +8069,7 @@ if ${lt_cv_apple_cc_single_mod+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
+      if test -z "$LT_MULTI_MODULE"; then
 	# By default we will add the -single_module flag. You can override
 	# by either setting the environment variable LT_MULTI_MODULE
 	# non-empty at configure time, or by adding -multi_module to the
@@ -7957,7 +8087,7 @@ else
 	  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
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&5
@@ -7996,7 +8126,7 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-	LDFLAGS="$save_LDFLAGS"
+	LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
@@ -8025,7 +8155,7 @@ _LT_EOF
       _lt_result=$?
       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
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&5
@@ -8038,32 +8168,32 @@ fi
 $as_echo "$lt_cv_ld_force_load" >&6; }
     case $host_os in
     rhapsody* | darwin1.[012])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
     darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
     darwin*) # darwin 5.x on
       # if running on 10.5 or later, the deployment target defaults
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[012]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[012][,.]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
 	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
   esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
       _lt_dar_single_mod='$single_module'
     fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
     else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
     fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
       _lt_dsymutil='~$DSYMUTIL $lib || :'
     else
       _lt_dsymutil=
@@ -8071,6 +8201,41 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
     ;;
   esac
 
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -8374,14 +8539,14 @@ if test "${enable_shared+set}" = set; then :
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8405,14 +8570,14 @@ if test "${enable_static+set}" = set; then :
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8436,14 +8601,14 @@ if test "${with_pic+set}" = set; then :
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8451,8 +8616,6 @@ else
 fi
 
 
-test -z "$pic_mode" && pic_mode=default
-
 
 
 
@@ -8468,14 +8631,14 @@ if test "${enable_fast_install+set}" = set; then :
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8489,11 +8652,63 @@ fi
 
 
 
+  shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[5-9]*,yes)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5
+$as_echo_n "checking which variant of shared library versioning to provide... " >&6; }
+
+# Check whether --with-aix-soname was given.
+if test "${with_aix_soname+set}" = set; then :
+  withval=$with_aix_soname; case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname
+else
+  if ${lt_cv_with_aix_soname+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_with_aix_soname=aix
+fi
+
+    with_aix_soname=$lt_cv_with_aix_soname
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5
+$as_echo "$with_aix_soname" >&6; }
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+
+
+
+
+
+
 
 
 
 # This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
 
 # Always use our own libtool.
 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -8542,7 +8757,7 @@ test -z "$LN_S" && LN_S="ln -s"
 
 
 
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
@@ -8581,7 +8796,7 @@ aix3*)
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
+  if test set != "${COLLECT_NAMES+set}"; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -8592,14 +8807,14 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
 
 # Set sane defaults for various variables
 test -z "$CC" && CC=cc
@@ -8608,15 +8823,8 @@ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 test -z "$LD" && LD=ld
 test -z "$ac_objext" && ac_objext=o
 
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+func_cc_basename $compiler
+cc_basename=$func_cc_basename_result
 
 
 # Only perform the check for file, if the check method requires it
@@ -8631,22 +8839,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then :
 else
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/${ac_tool_prefix}file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+    if test -f "$ac_dir/${ac_tool_prefix}file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -8669,13 +8877,13 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac
 fi
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 $as_echo "$MAGIC_CMD" >&6; }
@@ -8697,22 +8905,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then :
 else
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+    if test -f "$ac_dir/file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"file"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -8735,13 +8943,13 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac
 fi
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 $as_echo "$MAGIC_CMD" >&6; }
@@ -8762,7 +8970,7 @@ esac
 
 # Use C for the default configuration in the libtool script
 
-lt_save_CC="$CC"
+lt_save_CC=$CC
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -8824,7 +9032,7 @@ if test -n "$compiler"; then
 
 lt_prog_compiler_no_builtin_flag=
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $cc_basename in
   nvcc*)
     lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
@@ -8840,7 +9048,7 @@ else
   lt_cv_prog_compiler_rtti_exceptions=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   lt_compiler_flag="-fno-rtti -fno-exceptions"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -8870,7 +9078,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
 
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then
     lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
 else
     :
@@ -8888,17 +9096,18 @@ lt_prog_compiler_pic=
 lt_prog_compiler_static=
 
 
-  if test "$GCC" = yes; then
+  if test yes = "$GCC"; then
     lt_prog_compiler_wl='-Wl,'
     lt_prog_compiler_static='-static'
 
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       fi
+      lt_prog_compiler_pic='-fPIC'
       ;;
 
     amigaos*)
@@ -8909,8 +9118,8 @@ lt_prog_compiler_static=
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -8926,6 +9135,11 @@ lt_prog_compiler_static=
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
       lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
       ;;
 
     darwin* | rhapsody*)
@@ -8996,7 +9210,7 @@ lt_prog_compiler_static=
     case $host_os in
     aix*)
       lt_prog_compiler_wl='-Wl,'
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       else
@@ -9004,10 +9218,29 @@ lt_prog_compiler_static=
       fi
       ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        lt_prog_compiler_wl='-Wl,-Wl,,'
+        lt_prog_compiler_pic='-PIC'
+        lt_prog_compiler_static='-Bstatic'
+        ;;
+      esac
+      ;;
+
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -9023,7 +9256,7 @@ lt_prog_compiler_static=
 	;;
       esac
       # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      lt_prog_compiler_static='$wl-a ${wl}archive'
       ;;
 
     irix5* | irix6* | nonstopux*)
@@ -9034,7 +9267,7 @@ lt_prog_compiler_static=
 
     linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
       case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
+      # old Intel for x86_64, which still supported -KPIC.
       ecc*)
 	lt_prog_compiler_wl='-Wl,'
 	lt_prog_compiler_pic='-KPIC'
@@ -9059,6 +9292,12 @@ lt_prog_compiler_static=
 	lt_prog_compiler_pic='-PIC'
 	lt_prog_compiler_static='-Bstatic'
 	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fPIC'
+	lt_prog_compiler_static='-static'
+	;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
@@ -9156,7 +9395,7 @@ lt_prog_compiler_static=
       ;;
 
     sysv4*MP*)
-      if test -d /usr/nec ;then
+      if test -d /usr/nec; then
 	lt_prog_compiler_pic='-Kconform_pic'
 	lt_prog_compiler_static='-Bstatic'
       fi
@@ -9185,7 +9424,7 @@ lt_prog_compiler_static=
   fi
 
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic=
     ;;
@@ -9217,7 +9456,7 @@ else
   lt_cv_prog_compiler_pic_works=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -9247,7 +9486,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+if test yes = "$lt_cv_prog_compiler_pic_works"; then
     case $lt_prog_compiler_pic in
      "" | " "*) ;;
      *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
@@ -9279,7 +9518,7 @@ if ${lt_cv_prog_compiler_static_works+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler_static_works=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -9298,13 +9537,13 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
 $as_echo "$lt_cv_prog_compiler_static_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+if test yes = "$lt_cv_prog_compiler_static_works"; then
     :
 else
     lt_prog_compiler_static=
@@ -9424,8 +9663,8 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
 $as_echo_n "checking if we can lock with hard links... " >&6; }
@@ -9437,9 +9676,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; }
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
 $as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+  if test no = "$hard_links"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -9482,9 +9721,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   # included in the symbol list
   include_expsyms=
   # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
   exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
@@ -9499,7 +9738,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       with_gnu_ld=no
     fi
     ;;
@@ -9507,12 +9746,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     # we just hope/assume this is gcc and not c89 (= MSVC++)
     with_gnu_ld=yes
     ;;
-  openbsd*)
+  openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
-  linux* | k*bsd*-gnu | gnu*)
-    link_all_deplibs=no
-    ;;
   esac
 
   ld_shlibs=yes
@@ -9520,7 +9756,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   # On some targets, GNU ld is compatible enough with the native linker
   # that we're better off using the native interface for both.
   lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     case $host_os in
       aix*)
 	# The AIX port of GNU ld has always aspired to compatibility
@@ -9542,24 +9778,24 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     esac
   fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
+  if test yes = "$lt_use_gnu_ld_interface"; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    wlarc='$wl'
 
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
     runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
+    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+    export_dynamic_flag_spec='$wl--export-dynamic'
     # ancient GNU ld didn't support --whole-archive et. al.
     if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
     else
       whole_archive_flag_spec=
     fi
     supports_anon_versioning=no
-    case `$LD -v 2>&1` in
+    case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in
       *GNU\ gold*) supports_anon_versioning=yes ;;
       *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
       *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -9572,7 +9808,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     case $host_os in
     aix[3-9]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
+      if test ia64 != "$host_cpu"; then
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
@@ -9591,7 +9827,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             archive_expsym_cmds=''
         ;;
       m68k)
@@ -9607,7 +9843,7 @@ _LT_EOF
 	allow_undefined_flag=unsupported
 	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       else
 	ld_shlibs=no
       fi
@@ -9617,7 +9853,7 @@ _LT_EOF
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
-      export_dynamic_flag_spec='${wl}--export-all-symbols'
+      export_dynamic_flag_spec='$wl--export-all-symbols'
       allow_undefined_flag=unsupported
       always_export_symbols=no
       enable_shared_with_static_runtimes=yes
@@ -9625,61 +9861,89 @@ _LT_EOF
       exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
 
       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	ld_shlibs=no
       fi
       ;;
 
     haiku*)
-      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       link_all_deplibs=yes
       ;;
 
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
     interix[3-9]*)
       hardcode_direct=no
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec='${wl}-E'
+      hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+      export_dynamic_flag_spec='$wl-E'
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
       # consuming and fragmenting process.  To avoid this, we pick a random,
       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
       ;;
 
     gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
+      if test linux-dietlibc = "$host_os"; then
 	case $cc_basename in
 	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 	esac
       fi
       if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
+	 && test no = "$tmp_diet"
       then
 	tmp_addflag=' $pic_flag'
 	tmp_sharedflag='-shared'
 	case $cc_basename,$host_cpu in
         pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
 	pgf77* | pgf90* | pgf95* | pgfortran*)
 					# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -9690,42 +9954,47 @@ _LT_EOF
 	lf95*)				# Lahey Fortran 8.1
 	  whole_archive_flag_spec=
 	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
 	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  compiler_needs_object=yes
 	  ;;
 	esac
 	case `$CC -V 2>&1 | sed 5q` in
 	*Sun\ C*)			# Sun C 5.9
-	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  compiler_needs_object=yes
 	  tmp_sharedflag='-G' ;;
 	*Sun\ F*)			# Sun Fortran 8.3
 	  tmp_sharedflag='-G' ;;
 	esac
-	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test "x$supports_anon_versioning" = xyes; then
+        if test yes = "$supports_anon_versioning"; then
           archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
         fi
 
 	case $cc_basename in
+	tcc*)
+	  export_dynamic_flag_spec='-rdynamic'
+	  ;;
 	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='${wl}-rpath ${wl}$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
+	  if test yes = "$supports_anon_versioning"; then
 	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 	  fi
 	  ;;
 	esac
@@ -9734,13 +10003,13 @@ _LT_EOF
       fi
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
       else
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -9758,8 +10027,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	ld_shlibs=no
       fi
@@ -9771,7 +10040,7 @@ _LT_EOF
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
 *** reliably create shared libraries on SCO systems.  Therefore, libtool
 *** is disabling shared libraries support.  We urge you to upgrade GNU
 *** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
@@ -9786,9 +10055,9 @@ _LT_EOF
 	  # DT_RUNPATH tag from executables and libraries.  But doing so
 	  # requires that you compile everything twice, which is a pain.
 	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	  else
 	    ld_shlibs=no
 	  fi
@@ -9805,15 +10074,15 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	ld_shlibs=no
       fi
       ;;
     esac
 
-    if test "$ld_shlibs" = no; then
+    if test no = "$ld_shlibs"; then
       runpath_var=
       hardcode_libdir_flag_spec=
       export_dynamic_flag_spec=
@@ -9829,7 +10098,7 @@ _LT_EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       hardcode_minus_L=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	hardcode_direct=unsupported
@@ -9837,34 +10106,57 @@ _LT_EOF
       ;;
 
     aix[4-9]*)
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
 	aix_use_runtimelinking=no
 	exp_sym_flag='-Bexport'
-	no_entry_flag=""
+	no_entry_flag=
       else
 	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
 	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
 	else
-	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
 	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
 	    aix_use_runtimelinking=yes
 	    break
 	  fi
 	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
 	  ;;
 	esac
 
@@ -9883,13 +10175,21 @@ _LT_EOF
       hardcode_direct_absolute=yes
       hardcode_libdir_separator=':'
       link_all_deplibs=yes
-      file_list_spec='${wl}-f,'
+      file_list_spec='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	hardcode_direct=no
+	hardcode_direct_absolute=no
+	;;
+      esac
 
-      if test "$GCC" = yes; then
+      if test yes = "$GCC"; then
 	case $host_os in aix4.[012]|aix4.[012].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -9908,36 +10208,42 @@ _LT_EOF
 	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
 	fi
-	link_all_deplibs=no
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
 	  else
-	    shared_flag='${wl}-bM:SRE'
+	    shared_flag='$wl-bM:SRE'
 	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
 	fi
       fi
 
-      export_dynamic_flag_spec='${wl}-bexpall'
+      export_dynamic_flag_spec='$wl-bexpall'
       # It seems that -bexpall does not export symbols beginning with
       # underscore (_), so it is better to generate a list of symbols to export.
       always_export_symbols=yes
-      if test "$aix_use_runtimelinking" = yes; then
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
 	# Warning - without using the other runtime loading flags (-brtl),
 	# -berok will link without error, but may produce a broken library.
 	allow_undefined_flag='-berok'
         # Determine the default libpath from the value encoded in an
         # empty executable.
-        if test "${lt_cv_aix_libpath+set}" = set; then
+        if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath_+:} false; then :
@@ -9972,7 +10278,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
+    lt_cv_aix_libpath_=/usr/lib:/lib
   fi
 
 fi
@@ -9980,17 +10286,17 @@ fi
   aix_libpath=$lt_cv_aix_libpath_
 fi
 
-        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+	if test ia64 = "$host_cpu"; then
+	  hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib'
 	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
-	 if test "${lt_cv_aix_libpath+set}" = set; then
+	 if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath_+:} false; then :
@@ -10025,7 +10331,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
+    lt_cv_aix_libpath_=/usr/lib:/lib
   fi
 
 fi
@@ -10033,21 +10339,33 @@ fi
   aix_libpath=$lt_cv_aix_libpath_
 fi
 
-	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+	 hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
 	  # Warning - without using the other run time loading flags,
 	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag=' ${wl}-bernotok'
-	  allow_undefined_flag=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
+	  no_undefined_flag=' $wl-bernotok'
+	  allow_undefined_flag=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
 	    # We only use this code for GNU lds that support --whole-archive.
-	    whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive'
 	  else
 	    # Exported symbols can be pulled into shared objects from archives
 	    whole_archive_flag_spec='$convenience'
 	  fi
 	  archive_cmds_need_lc=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) >  [...]
+	  else
+	    # used by -dlpreopen to get the symbols
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d'
 	fi
       fi
       ;;
@@ -10056,7 +10374,7 @@ fi
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             archive_expsym_cmds=''
         ;;
       m68k)
@@ -10086,16 +10404,17 @@ fi
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
+	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
 	# 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
@@ -10104,18 +10423,18 @@ fi
 	# Don't use ranlib
 	old_postinstall_cmds='chmod 644 $oldlib'
 	postlink_cmds='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -10124,7 +10443,7 @@ fi
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
 	archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 	# The linker will automatically build a .lib file if we build a DLL.
@@ -10143,24 +10462,24 @@ fi
   hardcode_direct=no
   hardcode_automatic=yes
   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\"`'
+  if test yes = "$lt_cv_ld_force_load"; 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
   link_all_deplibs=yes
-  allow_undefined_flag="$_lt_dar_allow_undefined"
+  allow_undefined_flag=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
 
   else
   ld_shlibs=no
@@ -10202,33 +10521,33 @@ fi
       ;;
 
     hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      if test yes = "$GCC"; then
+	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       else
-	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       fi
-      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl+b $wl$libdir'
       hardcode_libdir_separator=:
       hardcode_direct=yes
 
       # hardcode_minus_L: Not really in the search PATH,
       # but as the default location of the library.
       hardcode_minus_L=yes
-      export_dynamic_flag_spec='${wl}-E'
+      export_dynamic_flag_spec='$wl-E'
       ;;
 
     hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
       else
 	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
 	hardcode_libdir_separator=:
 	hardcode_direct=yes
 	hardcode_direct_absolute=yes
-	export_dynamic_flag_spec='${wl}-E'
+	export_dynamic_flag_spec='$wl-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
 	hardcode_minus_L=yes
@@ -10236,25 +10555,25 @@ fi
       ;;
 
     hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+      if test yes,no = "$GCC,$with_gnu_ld"; then
 	case $host_cpu in
 	hppa*64*)
-	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
 	hppa*64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
 
@@ -10266,7 +10585,7 @@ if ${lt_cv_prog_compiler__b+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler__b=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS -b"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -10285,14 +10604,14 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
 $as_echo "$lt_cv_prog_compiler__b" >&6; }
 
-if test x"$lt_cv_prog_compiler__b" = xyes; then
-    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+if test yes = "$lt_cv_prog_compiler__b"; then
+    archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 else
     archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
 fi
@@ -10300,8 +10619,8 @@ fi
 	  ;;
 	esac
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
 	hardcode_libdir_separator=:
 
 	case $host_cpu in
@@ -10312,7 +10631,7 @@ fi
 	*)
 	  hardcode_direct=yes
 	  hardcode_direct_absolute=yes
-	  export_dynamic_flag_spec='${wl}-E'
+	  export_dynamic_flag_spec='$wl-E'
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
@@ -10323,8 +10642,8 @@ fi
       ;;
 
     irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	# Try to use the -exported_symbol ld option, if it does not
 	# work, assume that -exports_file does not work either and
 	# implicitly export all symbols.
@@ -10334,8 +10653,8 @@ $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >
 if ${lt_cv_irix_exported_symbol+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+  save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
 	   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo (void) { return 0; }
@@ -10347,25 +10666,35 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-           LDFLAGS="$save_LDFLAGS"
+           LDFLAGS=$save_LDFLAGS
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
 $as_echo "$lt_cv_irix_exported_symbol" >&6; }
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
 	fi
       else
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
       fi
       archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       inherit_rpath=yes
       link_all_deplibs=yes
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	ld_shlibs=yes
+	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
+
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
       else
@@ -10379,7 +10708,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     newsos6)
       archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       hardcode_direct=yes
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       hardcode_shlibpath_var=no
       ;;
@@ -10387,27 +10716,19 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     *nto* | *qnx*)
       ;;
 
-    openbsd*)
+    openbsd* | bitrig*)
       if test -f /usr/libexec/ld.so; then
 	hardcode_direct=yes
 	hardcode_shlibpath_var=no
 	hardcode_direct_absolute=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
 	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	  export_dynamic_flag_spec='${wl}-E'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+	  export_dynamic_flag_spec='$wl-E'
 	else
-	  case $host_os in
-	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     hardcode_libdir_flag_spec='-R$libdir'
-	     ;;
-	   *)
-	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	     ;;
-	  esac
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
 	fi
       else
 	ld_shlibs=no
@@ -10418,33 +10739,53 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       hardcode_libdir_flag_spec='-L$libdir'
       hardcode_minus_L=yes
       allow_undefined_flag=unsupported
-      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
       ;;
 
     osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
       else
 	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
       fi
       archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       ;;
 
     osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       else
 	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec='-rpath $libdir'
@@ -10455,24 +10796,24 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
 
     solaris*)
       no_undefined_flag=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
 	  wlarc=''
-	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  wlarc='${wl}'
-	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  wlarc='$wl'
+	  archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -10482,11 +10823,11 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       solaris2.[0-5] | solaris2.[0-5].*) ;;
       *)
 	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
 	# but is careful enough not to reorder.
 	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	if test yes = "$GCC"; then
+	  whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 	else
 	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
 	fi
@@ -10496,10 +10837,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
 
     sunos4*)
-      if test "x$host_vendor" = xsequent; then
+      if test sequent = "$host_vendor"; then
 	# Use $CC to link under sequent, because it throws in some extra .o
 	# files that make .init and .fini sections work.
-	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
       else
 	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
       fi
@@ -10548,43 +10889,43 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag='${wl}-z,text'
+      no_undefined_flag='$wl-z,text'
       archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
     sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
+      # Note: We CANNOT use -z defs as we might desire, because we do not
       # link with -lc, and that would cause any symbols used from libc to
       # always be unresolved, which means just about no library would
       # ever link correctly.  If we're not using GNU ld we use -z text
       # though, which does catch some bad symbols but isn't as heavy-handed
       # as -z defs.
-      no_undefined_flag='${wl}-z,text'
-      allow_undefined_flag='${wl}-z,nodefs'
+      no_undefined_flag='$wl-z,text'
+      allow_undefined_flag='$wl-z,nodefs'
       archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-R,$libdir'
+      hardcode_libdir_flag_spec='$wl-R,$libdir'
       hardcode_libdir_separator=':'
       link_all_deplibs=yes
-      export_dynamic_flag_spec='${wl}-Bexport'
+      export_dynamic_flag_spec='$wl-Bexport'
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
@@ -10599,10 +10940,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
     esac
 
-    if test x$host_vendor = xsni; then
+    if test sni = "$host_vendor"; then
       case $host in
       sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	export_dynamic_flag_spec='${wl}-Blargedynsym'
+	export_dynamic_flag_spec='$wl-Blargedynsym'
 	;;
       esac
     fi
@@ -10610,7 +10951,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
 $as_echo "$ld_shlibs" >&6; }
-test "$ld_shlibs" = no && can_build_shared=no
+test no = "$ld_shlibs" && can_build_shared=no
 
 with_gnu_ld=$with_gnu_ld
 
@@ -10636,7 +10977,7 @@ x|xyes)
   # Assume -lc should be added
   archive_cmds_need_lc=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $archive_cmds in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -10851,14 +11192,14 @@ esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
 $as_echo_n "checking dynamic linker characteristics... " >&6; }
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
   esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
   esac
   lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
   case $lt_search_path_spec in
@@ -10874,28 +11215,35 @@ if test "$GCC" = yes; then
     ;;
   esac
   # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
+  # and add multilib dir if necessary...
   lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
   for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
       test -d "$lt_sys_path" && \
 	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
     fi
   done
   lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
   for (lt_i = NF; lt_i > 0; lt_i--) {
     if ($lt_i != "" && $lt_i != ".") {
       if ($lt_i == "..") {
         lt_count++;
       } else {
         if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
+          lt_foo = "/" $lt_i lt_foo;
         } else {
           lt_count--;
         }
@@ -10909,7 +11257,7 @@ BEGIN {RS=" "; FS="/|\n";} {
   # for these hosts.
   case $host_os in
     mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
+      $SED 's|/\([A-Za-z]:\)|\1|g'` ;;
   esac
   sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 else
@@ -10918,7 +11266,7 @@ fi
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -10935,14 +11283,16 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[4-9]*)
@@ -10950,41 +11300,91 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[01] | aix4.[01].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a(lib.so.V)'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -10994,18 +11394,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -11013,8 +11413,8 @@ beos*)
 bsdi[45]*)
   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'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -11026,7 +11426,7 @@ bsdi[45]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -11035,8 +11435,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -11052,17 +11452,17 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -11071,8 +11471,8 @@ cygwin* | mingw* | pw32* | cegcc*)
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -11099,7 +11499,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -11112,8 +11512,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -11126,7 +11526,7 @@ cygwin* | mingw* | pw32* | cegcc*)
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -11139,8 +11539,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -11153,8 +11553,8 @@ dgux*)
   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'
+  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
   ;;
 
@@ -11172,12 +11572,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -11207,10 +11608,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  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=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -11228,14 +11629,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -11243,8 +11645,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -11253,8 +11655,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -11267,8 +11669,8 @@ interix[3-9]*)
   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'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -11279,7 +11681,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -11287,8 +11689,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -11307,8 +11709,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -11317,13 +11719,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  hardcode_libdir_flag_spec='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   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'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -11367,7 +11789,12 @@ fi
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -11382,29 +11809,17 @@ fi
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-netbsdelf*-gnu)
-  version_type=linux
-  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
-  dynamic_linker='NetBSD ld.elf_so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -11414,7 +11829,7 @@ netbsd*)
 
 newsos6)
   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}'
+  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
   ;;
@@ -11423,58 +11838,68 @@ newsos6)
   version_type=qnx
   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'
+  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
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -11485,8 +11910,8 @@ solaris*)
   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'
+  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=yes
   hardcode_into_libs=yes
@@ -11496,11 +11921,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -11508,8 +11933,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   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'
+  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
   case $host_vendor in
     sni)
@@ -11530,24 +11955,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     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'
+    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
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -11565,7 +11990,7 @@ tpf*)
   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}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -11573,8 +11998,8 @@ tpf*)
 
 uts4*)
   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'
+  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
   ;;
 
@@ -11584,20 +12009,35 @@ uts4*)
 esac
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
 $as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
+
+
+
+
+
 
 
 
@@ -11694,15 +12134,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action=
 if test -n "$hardcode_libdir_flag_spec" ||
    test -n "$runpath_var" ||
-   test "X$hardcode_automatic" = "Xyes" ; then
+   test yes = "$hardcode_automatic"; then
 
   # We can hardcode non-existent directories.
-  if test "$hardcode_direct" != no &&
+  if test no != "$hardcode_direct" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
-     test "$hardcode_minus_L" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" &&
+     test no != "$hardcode_minus_L"; then
     # Linking always hardcodes the temporary library directory.
     hardcode_action=relink
   else
@@ -11717,12 +12157,12 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
 $as_echo "$hardcode_action" >&6; }
 
-if test "$hardcode_action" = relink ||
-   test "$inherit_rpath" = yes; then
+if test relink = "$hardcode_action" ||
+   test yes = "$inherit_rpath"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -11732,7 +12172,7 @@ fi
 
 
 
-  if test "x$enable_dlopen" != xyes; then
+  if test yes != "$enable_dlopen"; then
   enable_dlopen=unknown
   enable_dlopen_self=unknown
   enable_dlopen_self_static=unknown
@@ -11742,23 +12182,23 @@ else
 
   case $host_os in
   beos*)
-    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen=load_add_on
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ;;
 
   mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen=LoadLibrary
     lt_cv_dlopen_libs=
     ;;
 
   cygwin*)
-    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen=dlopen
     lt_cv_dlopen_libs=
     ;;
 
   darwin*)
-  # if libdl is installed we need to link against it
+    # if libdl is installed we need to link against it
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
 $as_echo_n "checking for dlopen in -ldl... " >&6; }
 if ${ac_cv_lib_dl_dlopen+:} false; then :
@@ -11796,10 +12236,10 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else
 
-    lt_cv_dlopen="dyld"
+    lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
 
@@ -11807,10 +12247,18 @@ fi
 
     ;;
 
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
   *)
     ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
 if test "x$ac_cv_func_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load"
+  lt_cv_dlopen=shl_load
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
 $as_echo_n "checking for shl_load in -ldld... " >&6; }
@@ -11849,11 +12297,11 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
 $as_echo "$ac_cv_lib_dld_shl_load" >&6; }
 if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+  lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld
 else
   ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
 if test "x$ac_cv_func_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen"
+  lt_cv_dlopen=dlopen
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
 $as_echo_n "checking for dlopen in -ldl... " >&6; }
@@ -11892,7 +12340,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
 $as_echo_n "checking for dlopen in -lsvld... " >&6; }
@@ -11931,7 +12379,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
 $as_echo "$ac_cv_lib_svld_dlopen" >&6; }
 if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
 $as_echo_n "checking for dld_link in -ldld... " >&6; }
@@ -11970,7 +12418,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
 $as_echo "$ac_cv_lib_dld_dld_link" >&6; }
 if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+  lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld
 fi
 
 
@@ -11991,21 +12439,21 @@ fi
     ;;
   esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
+  if test no = "$lt_cv_dlopen"; then
     enable_dlopen=no
+  else
+    enable_dlopen=yes
   fi
 
   case $lt_cv_dlopen in
   dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
+    save_LDFLAGS=$LDFLAGS
     wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
+    save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
@@ -12013,7 +12461,7 @@ $as_echo_n "checking whether a program can dlopen itself... " >&6; }
 if ${lt_cv_dlopen_self+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  	  if test "$cross_compiling" = yes; then :
+  	  if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self=cross
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -12060,9 +12508,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -12092,7 +12540,7 @@ _LT_EOF
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -12112,14 +12560,14 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
 $as_echo "$lt_cv_dlopen_self" >&6; }
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
+    if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
 if ${lt_cv_dlopen_self_static+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  	  if test "$cross_compiling" = yes; then :
+  	  if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self_static=cross
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -12166,9 +12614,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -12198,7 +12646,7 @@ _LT_EOF
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -12219,9 +12667,9 @@ fi
 $as_echo "$lt_cv_dlopen_self_static" >&6; }
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
     ;;
   esac
 
@@ -12265,7 +12713,7 @@ else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
   darwin*)
-    if test -n "$STRIP" ; then
+    if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -12293,7 +12741,7 @@ fi
 
 
 
-  # Report which library types will actually be built
+  # Report what 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
@@ -12301,13 +12749,13 @@ $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
+  test no = "$can_build_shared" && 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
+    test yes = "$enable_shared" && enable_static=no
     if test -n "$RANLIB"; then
       archive_cmds="$archive_cmds~\$RANLIB \$lib"
       postinstall_cmds='$RANLIB $lib'
@@ -12315,8 +12763,12 @@ $as_echo_n "checking whether to build shared libraries... " >&6; }
     ;;
 
   aix[4-9]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
     fi
     ;;
   esac
@@ -12326,7 +12778,7 @@ $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
+  test yes = "$enable_shared" || enable_static=yes
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
 $as_echo "$enable_static" >&6; }
 
@@ -12340,7 +12792,7 @@ 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"
+CC=$lt_save_CC
 
 
 
@@ -12736,6 +13188,12 @@ THREAD_LIB=$THREAD_LIB
 
 ac_config_files="$ac_config_files Makefile cmake/Makefile src/Makefile man/Makefile man/man1/Makefile man/man3/Makefile nad/Makefile jniwrap/Makefile jniwrap/org/Makefile jniwrap/org/proj4/Makefile"
 
+ac_config_files="$ac_config_files nad/install"
+
+
+ac_config_files="$ac_config_files proj.pc"
+
+
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -12860,10 +13318,6 @@ else
   am__EXEEXT_FALSE=
 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
-fi
 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
@@ -13273,7 +13727,7 @@ 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 PROJ.4 Projections $as_me 4.9.2, which was
+This file was extended by PROJ.4 Projections $as_me 4.9.3, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -13339,7 +13793,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-PROJ.4 Projections config.status 4.9.2
+PROJ.4 Projections config.status 4.9.3
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -13474,6 +13928,7 @@ enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
 enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
 pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
 enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
+shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $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"`'
@@ -13523,10 +13978,13 @@ compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
 GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
+lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`'
 nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
 lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
+lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`'
 objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
 MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
 lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
@@ -13591,7 +14049,8 @@ finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
 finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
 hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
 sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
-sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
+configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`'
+configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`'
 hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
 enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
 enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
@@ -13642,9 +14101,12 @@ CFLAGS \
 compiler \
 lt_cv_sys_global_symbol_pipe \
 lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_import \
 lt_cv_sys_global_symbol_to_c_name_address \
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+lt_cv_nm_interface \
 nm_file_list_spec \
+lt_cv_truncate_bin \
 lt_prog_compiler_no_builtin_flag \
 lt_prog_compiler_pic \
 lt_prog_compiler_wl \
@@ -13679,7 +14141,7 @@ old_striplib \
 striplib; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -13706,10 +14168,11 @@ postinstall_cmds \
 postuninstall_cmds \
 finish_cmds \
 sys_lib_search_path_spec \
-sys_lib_dlsearch_path_spec; do
+configure_time_dlsearch_path \
+configure_time_lt_sys_library_path; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -13718,19 +14181,16 @@ sys_lib_dlsearch_path_spec; do
 done
 
 ac_aux_dir='$ac_aux_dir'
-xsi_shell='$xsi_shell'
-lt_shell_append='$lt_shell_append'
 
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
 # commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
 
     PACKAGE='$PACKAGE'
     VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
     RM='$RM'
     ofile='$ofile'
 
@@ -13758,6 +14218,8 @@ do
     "jniwrap/Makefile") CONFIG_FILES="$CONFIG_FILES jniwrap/Makefile" ;;
     "jniwrap/org/Makefile") CONFIG_FILES="$CONFIG_FILES jniwrap/org/Makefile" ;;
     "jniwrap/org/proj4/Makefile") CONFIG_FILES="$CONFIG_FILES jniwrap/org/proj4/Makefile" ;;
+    "nad/install") CONFIG_FILES="$CONFIG_FILES nad/install" ;;
+    "proj.pc") CONFIG_FILES="$CONFIG_FILES proj.pc" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
@@ -14448,55 +14910,53 @@ $as_echo X"$file" |
  ;;
     "libtool":C)
 
-    # See if we are running on zsh, and set the options which allow our
+    # See if we are running on zsh, and set the options that allow our
     # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
+    if test -n "${ZSH_VERSION+set}"; then
       setopt NO_GLOB_SUBST
     fi
 
-    cfgfile="${ofile}T"
+    cfgfile=${ofile}T
     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
     $RM "$cfgfile"
 
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
+# Copyright (C) 2014 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.
+
+# GNU Libtool 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 of of the License, or
+# (at your option) any later version.
 #
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool 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 of
-# the License, or (at your option) any later version.
-#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the  same
+# distribution terms that you use for the rest of that program.
 #
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool 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 GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing 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/>.
 
 
 # The names of the tagged configurations supported by this script.
-available_tags=""
+available_tags=''
+
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
 
 # ### BEGIN LIBTOOL CONFIG
 
@@ -14516,6 +14976,9 @@ pic_mode=$pic_mode
 # Whether or not to optimize for fast installation.
 fast_install=$enable_fast_install
 
+# Shared archive member basename,for filename based shared library versioning on AIX.
+shared_archive_member_spec=$shared_archive_member_spec
+
 # Shell to use when invoking shell scripts.
 SHELL=$lt_SHELL
 
@@ -14633,18 +15096,27 @@ global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
 # Transform the output of nm in a proper C declaration.
 global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
 
+# Transform the output of nm into a list of symbols to manually relocate.
+global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import
+
 # Transform the output of nm in a C name address pair.
 global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
 
 # Transform the output of nm in a C name address pair when lib prefix is needed.
 global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
 
+# The name lister interface.
+nm_interface=$lt_lt_cv_nm_interface
+
 # Specify filename containing input files for \$NM.
 nm_file_list_spec=$lt_nm_file_list_spec
 
-# The root where to search for dependent libraries,and in which our libraries should be installed.
+# The root where to search for dependent libraries,and where our libraries should be installed.
 lt_sysroot=$lt_sysroot
 
+# Command to truncate a binary pipe.
+lt_truncate_bin=$lt_lt_cv_truncate_bin
+
 # The name of the directory that contains temporary libtool files.
 objdir=$objdir
 
@@ -14735,8 +15207,11 @@ hardcode_into_libs=$hardcode_into_libs
 # Compile-time system search path for libraries.
 sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 
-# Run-time system search path for libraries.
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+# Detected run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path
+
+# Explicit LT_SYS_LIBRARY_PATH set during ./configure time.
+configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path
 
 # Whether dlopen is supported.
 dlopen_support=$enable_dlopen
@@ -14829,13 +15304,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary.
 hardcode_direct=$hardcode_direct
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
-# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# "absolute",i.e impossible to change by setting \$shlibpath_var if the
 # library is relocated.
 hardcode_direct_absolute=$hardcode_direct_absolute
 
@@ -14887,13 +15362,72 @@ hardcode_action=$hardcode_action
 
 _LT_EOF
 
+    cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+
+
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
   case $host_os in
   aix3*)
     cat <<\_LT_EOF >> "$cfgfile"
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -14902,7 +15436,7 @@ _LT_EOF
   esac
 
 
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 
 
   # We use sed instead of cat because bash on DJGPP gets confused if
@@ -14912,2557 +15446,12 @@ ltmain="$ac_aux_dir/ltmain.sh"
   sed '$q' "$ltmain" >> "$cfgfile" \
      || (rm -f "$cfgfile"; exit 1)
 
-  if test x"$xsi_shell" = xyes; then
-  sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
-func_dirname ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_basename ()$/,/^} # func_basename /c\
-func_basename ()\
-{\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
-func_dirname_and_basename ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
-func_stripname ()\
-{\
-\    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
-\    # positional parameters, so assign one to ordinary parameter first.\
-\    func_stripname_result=${3}\
-\    func_stripname_result=${func_stripname_result#"${1}"}\
-\    func_stripname_result=${func_stripname_result%"${2}"}\
-} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
-func_split_long_opt ()\
-{\
-\    func_split_long_opt_name=${1%%=*}\
-\    func_split_long_opt_arg=${1#*=}\
-} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
-func_split_short_opt ()\
-{\
-\    func_split_short_opt_arg=${1#??}\
-\    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
-} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
-func_lo2o ()\
-{\
-\    case ${1} in\
-\      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
-\      *)    func_lo2o_result=${1} ;;\
-\    esac\
-} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_xform ()$/,/^} # func_xform /c\
-func_xform ()\
-{\
-    func_xform_result=${1%.*}.lo\
-} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_arith ()$/,/^} # func_arith /c\
-func_arith ()\
-{\
-    func_arith_result=$(( $* ))\
-} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_len ()$/,/^} # func_len /c\
-func_len ()\
-{\
-    func_len_result=${#1}\
-} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  sed -e '/^func_append ()$/,/^} # func_append /c\
-func_append ()\
-{\
-    eval "${1}+=\\${2}"\
-} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
-func_append_quoted ()\
-{\
-\    func_quote_for_eval "${2}"\
-\    eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
-} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
-$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
-fi
-
-
-   mv -f "$cfgfile" "$ofile" ||
-    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
-  chmod +x "$ofile"
-
- ;;
-
-  esac
-done # for ac_tag
-
-
-as_fn_exit 0
-_ACEOF
-ac_clean_files=$ac_clean_files_save
-
-test $ac_write_fail = 0 ||
-  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded.  So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status.  When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
-  ac_cs_success=:
-  ac_config_status_args=
-  test "$silent" = yes &&
-    ac_config_status_args="$ac_config_status_args --quiet"
-  exec 5>/dev/null
-  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
-  exec 5>>config.log
-  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
-  # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit 1
-fi
-if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
-fi
-
-
-ac_config_files="$ac_config_files proj.pc"
-
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems.  If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, we kill variables containing newlines.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(
-  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
-    eval ac_val=\$$ac_var
-    case $ac_val in #(
-    *${as_nl}*)
-      case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-      esac
-      case $ac_var in #(
-      _ | IFS | as_nl) ;; #(
-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
-      esac ;;
-    esac
-  done
-
-  (set) 2>&1 |
-    case $as_nl`(ac_space=' '; set) 2>&1` in #(
-    *${as_nl}ac_space=\ *)
-      # `set' does not quote correctly, so add quotes: double-quote
-      # substitution turns \\\\ into \\, and sed turns \\ into \.
-      sed -n \
-	"s/'/'\\\\''/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
-      ;; #(
-    *)
-      # `set' quotes correctly as required by POSIX, so do not add quotes.
-      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
-      ;;
-    esac |
-    sort
-) |
-  sed '
-     /^ac_cv_env_/b end
-     t clear
-     :clear
-     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
-     t end
-     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
-     :end' >>confcache
-if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
-  if test -w "$cache_file"; then
-    if test "x$cache_file" != "x/dev/null"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-$as_echo "$as_me: updating cache $cache_file" >&6;}
-      if test ! -f "$cache_file" || test -h "$cache_file"; then
-	cat confcache >"$cache_file"
-      else
-        case $cache_file in #(
-        */* | ?:*)
-	  mv -f confcache "$cache_file"$$ &&
-	  mv -f "$cache_file"$$ "$cache_file" ;; #(
-        *)
-	  mv -f confcache "$cache_file" ;;
-	esac
-      fi
-    fi
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
-$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
-  fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
-  # 1. Remove the extension, and $U if already installed.
-  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
-  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
-  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
-  #    will be set to the directory where LIBOBJS objects are built.
-  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
-  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
-done
-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='#'
-else
-  am__EXEEXT_TRUE='#'
-  am__EXEEXT_FALSE=
-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
-fi
-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__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__EXEEXT_TRUE}" && test -z "${am__EXEEXT_FALSE}"; then
-  as_fn_error $? "conditional \"am__EXEEXT\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-
-: "${CONFIG_STATUS=./config.status}"
-ac_write_fail=0
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
-$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
-as_write_fail=0
-cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-
-SHELL=\${CONFIG_SHELL-$SHELL}
-export SHELL
-_ASEOF
-cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
-      PATH_SEPARATOR=';'
-  }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
-# Find who we are.  Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
-  *[\\/]* ) as_myself=$0 ;;
-  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
-IFS=$as_save_IFS
-
-     ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
-  as_myself=$0
-fi
-if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
-  as_fn_exit $as_status
-} # as_fn_error
-
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
-
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
-
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
-  case `echo 'xy\c'` in
-  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='	';;
-  esac;;
-*)
-  ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
-  rm -f conf$$.dir/conf$$.file
-else
-  rm -f conf$$.dir
-  mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
-  if ln -s conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s='ln -s'
-    # ... 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 -pR'.
-    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
-  elif ln conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s=ln
-  else
-    as_ln_s='cp -pR'
-  fi
-else
-  as_ln_s='cp -pR'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-
-# 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'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-exec 6>&1
-## ----------------------------------- ##
-## Main body of $CONFIG_STATUS script. ##
-## ----------------------------------- ##
-_ASEOF
-test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# Save the log message, to keep $0 and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.
-ac_log="
-This file was extended by PROJ.4 Projections $as_me 4.9.2, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
-
-  CONFIG_FILES    = $CONFIG_FILES
-  CONFIG_HEADERS  = $CONFIG_HEADERS
-  CONFIG_LINKS    = $CONFIG_LINKS
-  CONFIG_COMMANDS = $CONFIG_COMMANDS
-  $ $0 $@
-
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
-"
-
-_ACEOF
-
-case $ac_config_files in *"
-"*) set x $ac_config_files; shift; ac_config_files=$*;;
-esac
-
-case $ac_config_headers in *"
-"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
-esac
-
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-# Files that config.status was made for.
-config_files="$ac_config_files"
-config_headers="$ac_config_headers"
-config_commands="$ac_config_commands"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-ac_cs_usage="\
-\`$as_me' instantiates files and other configuration actions
-from templates according to the current configuration.  Unless the files
-and actions are specified as TAGs, all are instantiated by default.
-
-Usage: $0 [OPTION]... [TAG]...
-
-  -h, --help       print this help, then exit
-  -V, --version    print version number and configuration settings, then exit
-      --config     print configuration, then exit
-  -q, --quiet, --silent
-                   do not print progress messages
-  -d, --debug      don't remove temporary files
-      --recheck    update $as_me by reconfiguring in the same conditions
-      --file=FILE[:TEMPLATE]
-                   instantiate the configuration file FILE
-      --header=FILE[:TEMPLATE]
-                   instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Configuration commands:
-$config_commands
-
-Report bugs to <warmerdam at pobox.com>."
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
-ac_cs_version="\\
-PROJ.4 Projections config.status 4.9.2
-configured by $0, generated by GNU Autoconf 2.69,
-  with options \\"\$ac_cs_config\\"
-
-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."
-
-ac_pwd='$ac_pwd'
-srcdir='$srcdir'
-INSTALL='$INSTALL'
-MKDIR_P='$MKDIR_P'
-AWK='$AWK'
-test -n "\$AWK" || AWK=awk
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# The default lists apply if the user does not specify any file.
-ac_need_defaults=:
-while test $# != 0
-do
-  case $1 in
-  --*=?*)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
-    ac_shift=:
-    ;;
-  --*=)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=
-    ac_shift=:
-    ;;
-  *)
-    ac_option=$1
-    ac_optarg=$2
-    ac_shift=shift
-    ;;
-  esac
-
-  case $ac_option in
-  # Handling of the options.
-  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    ac_cs_recheck=: ;;
-  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
-    $as_echo "$ac_cs_version"; exit ;;
-  --config | --confi | --conf | --con | --co | --c )
-    $as_echo "$ac_cs_config"; exit ;;
-  --debug | --debu | --deb | --de | --d | -d )
-    debug=: ;;
-  --file | --fil | --fi | --f )
-    $ac_shift
-    case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    '') as_fn_error $? "missing file argument" ;;
-    esac
-    as_fn_append CONFIG_FILES " '$ac_optarg'"
-    ac_need_defaults=false;;
-  --header | --heade | --head | --hea )
-    $ac_shift
-    case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    esac
-    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
-    ac_need_defaults=false;;
-  --he | --h)
-    # Conflict between --help and --header
-    as_fn_error $? "ambiguous option: \`$1'
-Try \`$0 --help' for more information.";;
-  --help | --hel | -h )
-    $as_echo "$ac_cs_usage"; exit ;;
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil | --si | --s)
-    ac_cs_silent=: ;;
-
-  # This is an error.
-  -*) as_fn_error $? "unrecognized option: \`$1'
-Try \`$0 --help' for more information." ;;
-
-  *) as_fn_append ac_config_targets " $1"
-     ac_need_defaults=false ;;
-
-  esac
-  shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
-  exec 6>/dev/null
-  ac_configure_extra_args="$ac_configure_extra_args --silent"
-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
-  shift
-  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
-  CONFIG_SHELL='$SHELL'
-  export CONFIG_SHELL
-  exec "\$@"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-exec 5>>config.log
-{
-  echo
-  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-  $as_echo "$ac_log"
-} >&5
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-#
-# INIT-COMMANDS
-#
-AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
-
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-sed_quote_subst='$sed_quote_subst'
-double_quote_subst='$double_quote_subst'
-delay_variable_subst='$delay_variable_subst'
-macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
-macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
-enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
-enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
-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"`'
-build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`'
-build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`'
-build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`'
-SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`'
-Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`'
-GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`'
-EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`'
-FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'
-LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'
-NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`'
-LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`'
-max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`'
-ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`'
-exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`'
-lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`'
-lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`'
-lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`'
-lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`'
-lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`'
-reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'
-reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'
-OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'
-deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'
-file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'
-file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`'
-want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`'
-DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`'
-sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`'
-AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'
-AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'
-archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`'
-STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'
-RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`'
-old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`'
-old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
-old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`'
-lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`'
-CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`'
-CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`'
-compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
-GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
-lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
-lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
-lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
-nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
-lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
-objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
-MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`'
-lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`'
-need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`'
-MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`'
-DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`'
-NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`'
-LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`'
-OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`'
-OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`'
-libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`'
-shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`'
-extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
-archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`'
-enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`'
-export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`'
-whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`'
-compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`'
-old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`'
-old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
-archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`'
-archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`'
-module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`'
-module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`'
-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_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"`'
-hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`'
-hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`'
-hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`'
-inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`'
-link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`'
-always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`'
-export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`'
-exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`'
-include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`'
-prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`'
-postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`'
-file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`'
-variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`'
-need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`'
-need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`'
-version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`'
-runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`'
-shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`'
-shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`'
-libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`'
-library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`'
-soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`'
-install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`'
-postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`'
-postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
-finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
-finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
-hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
-sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
-sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
-hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
-enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
-enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
-enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`'
-old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`'
-striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`'
-
-LTCC='$LTCC'
-LTCFLAGS='$LTCFLAGS'
-compiler='$compiler_DEFAULT'
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-\$1
-_LTECHO_EOF'
-}
-
-# Quote evaled strings.
-for var in SHELL \
-ECHO \
-PATH_SEPARATOR \
-SED \
-GREP \
-EGREP \
-FGREP \
-LD \
-NM \
-LN_S \
-lt_SP2NL \
-lt_NL2SP \
-reload_flag \
-OBJDUMP \
-deplibs_check_method \
-file_magic_cmd \
-file_magic_glob \
-want_nocaseglob \
-DLLTOOL \
-sharedlib_from_linklib_cmd \
-AR \
-AR_FLAGS \
-archiver_list_spec \
-STRIP \
-RANLIB \
-CC \
-CFLAGS \
-compiler \
-lt_cv_sys_global_symbol_pipe \
-lt_cv_sys_global_symbol_to_cdecl \
-lt_cv_sys_global_symbol_to_c_name_address \
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
-nm_file_list_spec \
-lt_prog_compiler_no_builtin_flag \
-lt_prog_compiler_pic \
-lt_prog_compiler_wl \
-lt_prog_compiler_static \
-lt_cv_prog_compiler_c_o \
-need_locks \
-MANIFEST_TOOL \
-DSYMUTIL \
-NMEDIT \
-LIPO \
-OTOOL \
-OTOOL64 \
-shrext_cmds \
-export_dynamic_flag_spec \
-whole_archive_flag_spec \
-compiler_needs_object \
-with_gnu_ld \
-allow_undefined_flag \
-no_undefined_flag \
-hardcode_libdir_flag_spec \
-hardcode_libdir_separator \
-exclude_expsyms \
-include_expsyms \
-file_list_spec \
-variables_saved_for_relink \
-libname_spec \
-library_names_spec \
-soname_spec \
-install_override_mode \
-finish_eval \
-old_striplib \
-striplib; do
-    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
-    *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
-      ;;
-    *)
-      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
-      ;;
-    esac
-done
-
-# Double-quote double-evaled strings.
-for var in reload_cmds \
-old_postinstall_cmds \
-old_postuninstall_cmds \
-old_archive_cmds \
-extract_expsyms_cmds \
-old_archive_from_new_cmds \
-old_archive_from_expsyms_cmds \
-archive_cmds \
-archive_expsym_cmds \
-module_cmds \
-module_expsym_cmds \
-export_symbols_cmds \
-prelink_cmds \
-postlink_cmds \
-postinstall_cmds \
-postuninstall_cmds \
-finish_cmds \
-sys_lib_search_path_spec \
-sys_lib_dlsearch_path_spec; do
-    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
-    *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
-      ;;
-    *)
-      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
-      ;;
-    esac
-done
-
-ac_aux_dir='$ac_aux_dir'
-xsi_shell='$xsi_shell'
-lt_shell_append='$lt_shell_append'
-
-# See if we are running on zsh, and set the options which allow our
-# commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
-   setopt NO_GLOB_SUBST
-fi
-
-
-    PACKAGE='$PACKAGE'
-    VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
-    RM='$RM'
-    ofile='$ofile'
-
-ac_aux_dir='$ac_aux_dir'
-
-
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-
-# Handling of arguments.
-for ac_config_target in $ac_config_targets
-do
-  case $ac_config_target in
-    "src/proj_config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/proj_config.h" ;;
-    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
-    "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
-    "cmake/Makefile") CONFIG_FILES="$CONFIG_FILES cmake/Makefile" ;;
-    "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
-    "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
-    "man/man1/Makefile") CONFIG_FILES="$CONFIG_FILES man/man1/Makefile" ;;
-    "man/man3/Makefile") CONFIG_FILES="$CONFIG_FILES man/man3/Makefile" ;;
-    "nad/Makefile") CONFIG_FILES="$CONFIG_FILES nad/Makefile" ;;
-    "jniwrap/Makefile") CONFIG_FILES="$CONFIG_FILES jniwrap/Makefile" ;;
-    "jniwrap/org/Makefile") CONFIG_FILES="$CONFIG_FILES jniwrap/org/Makefile" ;;
-    "jniwrap/org/proj4/Makefile") CONFIG_FILES="$CONFIG_FILES jniwrap/org/proj4/Makefile" ;;
-    "proj.pc") CONFIG_FILES="$CONFIG_FILES proj.pc" ;;
-
-  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
-  esac
-done
-
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used.  Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
-  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
-  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
-fi
-
-# Have a temporary directory for convenience.  Make it in the build tree
-# simply because there is no reason against having it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Hook for its removal unless debugging.
-# Note that there is a small window in which the directory will not be cleaned:
-# after its creation but before its name has been assigned to `$tmp'.
-$debug ||
-{
-  tmp= ac_tmp=
-  trap 'exit_status=$?
-  : "${ac_tmp:=$tmp}"
-  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
-' 0
-  trap 'as_fn_exit 1' 1 2 13 15
-}
-# Create a (secure) tmp directory for tmp files.
-
-{
-  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-  test -d "$tmp"
-}  ||
-{
-  tmp=./conf$$-$RANDOM
-  (umask 077 && mkdir "$tmp")
-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
-ac_tmp=$tmp
-
-# Set up the scripts for CONFIG_FILES section.
-# No need to generate them if there are no CONFIG_FILES.
-# This happens for instance with `./config.status config.h'.
-if test -n "$CONFIG_FILES"; then
-
-
-ac_cr=`echo X | tr X '\015'`
-# On cygwin, bash can eat \r inside `` if the user requested igncr.
-# But we know of no other shell where ac_cr would be empty at this
-# point, so we can use a bashism as a fallback.
-if test "x$ac_cr" = x; then
-  eval ac_cr=\$\'\\r\'
-fi
-ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
-if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\\r'
-else
-  ac_cs_awk_cr=$ac_cr
-fi
-
-echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
-_ACEOF
-
-
-{
-  echo "cat >conf$$subs.awk <<_ACEOF" &&
-  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
-  echo "_ACEOF"
-} >conf$$subs.sh ||
-  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
-ac_delim='%!_!# '
-for ac_last_try in false false false false false :; do
-  . ./conf$$subs.sh ||
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-
-  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
-  if test $ac_delim_n = $ac_delim_num; then
-    break
-  elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-  else
-    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-  fi
-done
-rm -f conf$$subs.sh
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
-_ACEOF
-sed -n '
-h
-s/^/S["/; s/!.*/"]=/
-p
-g
-s/^[^!]*!//
-:repl
-t repl
-s/'"$ac_delim"'$//
-t delim
-:nl
-h
-s/\(.\{148\}\)..*/\1/
-t more1
-s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
-p
-n
-b repl
-:more1
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t nl
-:delim
-h
-s/\(.\{148\}\)..*/\1/
-t more2
-s/["\\]/\\&/g; s/^/"/; s/$/"/
-p
-b
-:more2
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t delim
-' <conf$$subs.awk | sed '
-/^[^""]/{
-  N
-  s/\n//
-}
-' >>$CONFIG_STATUS || ac_write_fail=1
-rm -f conf$$subs.awk
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACAWK
-cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
-  for (key in S) S_is_set[key] = 1
-  FS = ""
-
-}
-{
-  line = $ 0
-  nfields = split(line, field, "@")
-  substed = 0
-  len = length(field[1])
-  for (i = 2; i < nfields; i++) {
-    key = field[i]
-    keylen = length(key)
-    if (S_is_set[key]) {
-      value = S[key]
-      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
-      len += length(value) + length(field[++i])
-      substed = 1
-    } else
-      len += 1 + keylen
-  }
-
-  print line
-}
-
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
-  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
-else
-  cat
-fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
-  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
-h
-s///
-s/^/:/
-s/[	 ]*$/:/
-s/:\$(srcdir):/:/g
-s/:\${srcdir}:/:/g
-s/:@srcdir@:/:/g
-s/^:*//
-s/:*$//
-x
-s/\(=[	 ]*\).*/\1/
-G
-s/\n//
-s/^[^=]*=[	 ]*$//
-}'
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-fi # test -n "$CONFIG_FILES"
-
-# Set up the scripts for CONFIG_HEADERS section.
-# No need to generate them if there are no CONFIG_HEADERS.
-# This happens for instance with `./config.status Makefile'.
-if test -n "$CONFIG_HEADERS"; then
-cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
-BEGIN {
-_ACEOF
-
-# Transform confdefs.h into an awk script `defines.awk', embedded as
-# here-document in config.status, that substitutes the proper values into
-# config.h.in to produce config.h.
-
-# Create a delimiter string that does not exist in confdefs.h, to ease
-# handling of long lines.
-ac_delim='%!_!# '
-for ac_last_try in false false :; do
-  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
-  if test -z "$ac_tt"; then
-    break
-  elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
-  else
-    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-  fi
-done
-
-# For the awk script, D is an array of macro values keyed by name,
-# likewise P contains macro parameters if any.  Preserve backslash
-# newline sequences.
-
-ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
-sed -n '
-s/.\{148\}/&'"$ac_delim"'/g
-t rset
-:rset
-s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
-t def
-d
-:def
-s/\\$//
-t bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3"/p
-s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
-d
-:bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3\\\\\\n"\\/p
-t cont
-s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
-t cont
-d
-:cont
-n
-s/.\{148\}/&'"$ac_delim"'/g
-t clear
-:clear
-s/\\$//
-t bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/"/p
-d
-:bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
-b cont
-' <confdefs.h | sed '
-s/'"$ac_delim"'/"\\\
-"/g' >>$CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-  for (key in D) D_is_set[key] = 1
-  FS = ""
-}
-/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
-  line = \$ 0
-  split(line, arg, " ")
-  if (arg[1] == "#") {
-    defundef = arg[2]
-    mac1 = arg[3]
-  } else {
-    defundef = substr(arg[1], 2)
-    mac1 = arg[2]
-  }
-  split(mac1, mac2, "(") #)
-  macro = mac2[1]
-  prefix = substr(line, 1, index(line, defundef) - 1)
-  if (D_is_set[macro]) {
-    # Preserve the white space surrounding the "#".
-    print prefix "define", macro P[macro] D[macro]
-    next
-  } else {
-    # Replace #undef with comments.  This is necessary, for example,
-    # in the case of _POSIX_SOURCE, which is predefined and required
-    # on some systems where configure will not decide to define it.
-    if (defundef == "undef") {
-      print "/*", prefix defundef, macro, "*/"
-      next
-    }
-  }
-}
-{ print }
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
-fi # test -n "$CONFIG_HEADERS"
-
-
-eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
-shift
-for ac_tag
-do
-  case $ac_tag in
-  :[FHLC]) ac_mode=$ac_tag; continue;;
-  esac
-  case $ac_mode$ac_tag in
-  :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
-  :[FH]-) ac_tag=-:-;;
-  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
-  esac
-  ac_save_IFS=$IFS
-  IFS=:
-  set x $ac_tag
-  IFS=$ac_save_IFS
-  shift
-  ac_file=$1
-  shift
-
-  case $ac_mode in
-  :L) ac_source=$1;;
-  :[FH])
-    ac_file_inputs=
-    for ac_f
-    do
-      case $ac_f in
-      -) ac_f="$ac_tmp/stdin";;
-      *) # Look for the file first in the build tree, then in the source tree
-	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
-	 # because $ac_f cannot contain `:'.
-	 test -f "$ac_f" ||
-	   case $ac_f in
-	   [\\/$]*) false;;
-	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
-	   esac ||
-	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
-      esac
-      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
-      as_fn_append ac_file_inputs " '$ac_f'"
-    done
-
-    # Let's still pretend it is `configure' which instantiates (i.e., don't
-    # use $as_me), people would be surprised to read:
-    #    /* config.h.  Generated by config.status.  */
-    configure_input='Generated from '`
-	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
-	`' by configure.'
-    if test x"$ac_file" != x-; then
-      configure_input="$ac_file.  $configure_input"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
-$as_echo "$as_me: creating $ac_file" >&6;}
-    fi
-    # Neutralize special characters interpreted by sed in replacement strings.
-    case $configure_input in #(
-    *\&* | *\|* | *\\* )
-       ac_sed_conf_input=`$as_echo "$configure_input" |
-       sed 's/[\\\\&|]/\\\\&/g'`;; #(
-    *) ac_sed_conf_input=$configure_input;;
-    esac
-
-    case $ac_tag in
-    *:-:* | *:-) cat >"$ac_tmp/stdin" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
-    esac
-    ;;
-  esac
-
-  ac_dir=`$as_dirname -- "$ac_file" ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_file" : 'X\(//\)[^/]' \| \
-	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-  as_dir="$ac_dir"; as_fn_mkdir_p
-  ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
-  # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
-  case $ac_top_builddir_sub in
-  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
-  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
-  esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
-  .)  # We are building in place.
-    ac_srcdir=.
-    ac_top_srcdir=$ac_top_builddir_sub
-    ac_abs_top_srcdir=$ac_pwd ;;
-  [\\/]* | ?:[\\/]* )  # Absolute name.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir
-    ac_abs_top_srcdir=$srcdir ;;
-  *) # Relative name.
-    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_build_prefix$srcdir
-    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-
-  case $ac_mode in
-  :F)
-  #
-  # CONFIG_FILE
-  #
-
-  case $INSTALL in
-  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
-  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
-  esac
-  ac_MKDIR_P=$MKDIR_P
-  case $MKDIR_P in
-  [\\/$]* | ?:[\\/]* ) ;;
-  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
-  esac
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# If the template does not know about datarootdir, expand it.
-# FIXME: This hack should be removed a few years after 2.60.
-ac_datarootdir_hack=; ac_datarootdir_seen=
-ac_sed_dataroot='
-/datarootdir/ {
-  p
-  q
-}
-/@datadir@/p
-/@docdir@/p
-/@infodir@/p
-/@localedir@/p
-/@mandir@/p'
-case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
-*datarootdir*) ac_datarootdir_seen=yes;;
-*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-  ac_datarootdir_hack='
-  s&@datadir@&$datadir&g
-  s&@docdir@&$docdir&g
-  s&@infodir@&$infodir&g
-  s&@localedir@&$localedir&g
-  s&@mandir@&$mandir&g
-  s&\\\${datarootdir}&$datarootdir&g' ;;
-esac
-_ACEOF
-
-# Neutralize VPATH when `$srcdir' = `.'.
-# Shell code in configure.ac might set extrasub.
-# FIXME: do we really want to maintain this feature?
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_sed_extra="$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s|@configure_input@|$ac_sed_conf_input|;t t
-s&@top_builddir@&$ac_top_builddir_sub&;t t
-s&@top_build_prefix@&$ac_top_build_prefix&;t t
-s&@srcdir@&$ac_srcdir&;t t
-s&@abs_srcdir@&$ac_abs_srcdir&;t t
-s&@top_srcdir@&$ac_top_srcdir&;t t
-s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
-s&@builddir@&$ac_builddir&;t t
-s&@abs_builddir@&$ac_abs_builddir&;t t
-s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
-s&@INSTALL@&$ac_INSTALL&;t t
-s&@MKDIR_P@&$ac_MKDIR_P&;t t
-$ac_datarootdir_hack
-"
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
-  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-
-test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
-  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
-      "$ac_tmp/out"`; test -z "$ac_out"; } &&
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&5
-$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&2;}
-
-  rm -f "$ac_tmp/stdin"
-  case $ac_file in
-  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
-  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
-  esac \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- ;;
-  :H)
-  #
-  # CONFIG_HEADER
-  #
-  if test x"$ac_file" != x-; then
-    {
-      $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
-    } >"$ac_tmp/config.h" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
-$as_echo "$as_me: $ac_file is unchanged" >&6;}
-    else
-      rm -f "$ac_file"
-      mv "$ac_tmp/config.h" "$ac_file" \
-	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
-    fi
-  else
-    $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
-      || as_fn_error $? "could not create -" "$LINENO" 5
-  fi
-# Compute "$ac_file"'s index in $config_headers.
-_am_arg="$ac_file"
-_am_stamp_count=1
-for _am_header in $config_headers :; do
-  case $_am_header in
-    $_am_arg | $_am_arg:* )
-      break ;;
-    * )
-      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
-  esac
-done
-echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
-$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$_am_arg" : 'X\(//\)[^/]' \| \
-	 X"$_am_arg" : 'X\(//\)$' \| \
-	 X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$_am_arg" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`/stamp-h$_am_stamp_count
- ;;
-
-  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
-$as_echo "$as_me: executing $ac_file commands" >&6;}
- ;;
-  esac
-
-
-  case $ac_file$ac_mode in
-    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
-  # Older Autoconf quotes --file arguments for eval, but not when files
-  # are listed without --file.  Let's play safe and only enable the eval
-  # if we detect the quoting.
-  case $CONFIG_FILES in
-  *\'*) eval set x "$CONFIG_FILES" ;;
-  *)   set x $CONFIG_FILES ;;
-  esac
-  shift
-  for mf
-  do
-    # 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
-    # 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.
-    # Grep'ing the whole file is not good either: AIX grep has a line
-    # limit of 2048, but all sed's we know have understand at least 4000.
-    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
-      dirpart=`$as_dirname -- "$mf" ||
-$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$mf" : 'X\(//\)[^/]' \| \
-	 X"$mf" : 'X\(//\)$' \| \
-	 X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$mf" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-    else
-      continue
-    fi
-    # Extract the definition of DEPDIR, am__include, and am__quote
-    # 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"`
-    # 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'`; do
-      # Make sure the directory exists.
-      test -f "$dirpart/$file" && continue
-      fdir=`$as_dirname -- "$file" ||
-$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$file" : 'X\(//\)[^/]' \| \
-	 X"$file" : 'X\(//\)$' \| \
-	 X"$file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-      as_dir=$dirpart/$fdir; as_fn_mkdir_p
-      # echo "creating $dirpart/$file"
-      echo '# dummy' > "$dirpart/$file"
-    done
-  done
-}
- ;;
-    "libtool":C)
-
-    # See if we are running on zsh, and set the options which allow our
-    # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
-      setopt NO_GLOB_SUBST
-    fi
-
-    cfgfile="${ofile}T"
-    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
-    $RM "$cfgfile"
-
-    cat <<_LT_EOF >> "$cfgfile"
-#! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-# 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, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool 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 of
-# the License, or (at your option) any later version.
-#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
-#
-# GNU Libtool 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 GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-
-# The names of the tagged configurations supported by this script.
-available_tags=""
-
-# ### BEGIN LIBTOOL CONFIG
-
-# Which release of libtool.m4 was used?
-macro_version=$macro_version
-macro_revision=$macro_revision
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# What type of objects to build.
-pic_mode=$pic_mode
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# Shell to use when invoking shell scripts.
-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
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# A sed program that does not truncate output.
-SED=$lt_SED
-
-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="\$SED -e 1s/^X//"
-
-# A grep program that handles long lines.
-GREP=$lt_GREP
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# A literal string matcher.
-FGREP=$lt_FGREP
-
-# A BSD- or MS-compatible name lister.
-NM=$lt_NM
-
-# Whether we need soft or hard links.
-LN_S=$lt_LN_S
-
-# What is the maximum length of a command?
-max_cmd_len=$max_cmd_len
-
-# Object file suffix (normally "o").
-objext=$ac_objext
-
-# Executable file suffix (normally "").
-exeext=$exeext
-
-# whether the shell understands "unset".
-lt_unset=$lt_unset
-
-# turn spaces into newlines.
-SP2NL=$lt_lt_SP2NL
-
-# turn newlines into spaces.
-NL2SP=$lt_lt_NL2SP
-
-# convert \$build file names to \$host format.
-to_host_file_cmd=$lt_cv_to_host_file_cmd
-
-# convert \$build files to toolchain format.
-to_tool_file_cmd=$lt_cv_to_tool_file_cmd
-
-# An object symbol dumper.
-OBJDUMP=$lt_OBJDUMP
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method = "file_magic".
-file_magic_cmd=$lt_file_magic_cmd
-
-# How to find potential files when deplibs_check_method = "file_magic".
-file_magic_glob=$lt_file_magic_glob
-
-# Find potential files using nocaseglob when deplibs_check_method = "file_magic".
-want_nocaseglob=$lt_want_nocaseglob
-
-# DLL creation program.
-DLLTOOL=$lt_DLLTOOL
-
-# Command to associate shared and link libraries.
-sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd
-
-# The archiver.
-AR=$lt_AR
-
-# Flags to create an archive.
-AR_FLAGS=$lt_AR_FLAGS
-
-# How to feed a file listing to the archiver.
-archiver_list_spec=$lt_archiver_list_spec
-
-# A symbol stripping program.
-STRIP=$lt_STRIP
-
-# Commands used to install an old-style archive.
-RANLIB=$lt_RANLIB
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Whether to use a lock for old archive extraction.
-lock_old_archive_extraction=$lock_old_archive_extraction
-
-# A C compiler.
-LTCC=$lt_CC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_CFLAGS
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration.
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair.
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# Transform the output of nm in a C name address pair when lib prefix is needed.
-global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
-
-# Specify filename containing input files for \$NM.
-nm_file_list_spec=$lt_nm_file_list_spec
-
-# The root where to search for dependent libraries,and in which our libraries should be installed.
-lt_sysroot=$lt_sysroot
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# Used to examine libraries when file_magic_cmd begins with "file".
-MAGIC_CMD=$MAGIC_CMD
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Manifest tool.
-MANIFEST_TOOL=$lt_MANIFEST_TOOL
-
-# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
-DSYMUTIL=$lt_DSYMUTIL
-
-# Tool to change global to local symbols on Mac OS X.
-NMEDIT=$lt_NMEDIT
-
-# Tool to manipulate fat objects and archives on Mac OS X.
-LIPO=$lt_LIPO
-
-# ldd/readelf like tool for Mach-O binaries on Mac OS X.
-OTOOL=$lt_OTOOL
-
-# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
-OTOOL64=$lt_OTOOL64
-
-# Old archive suffix (normally "a").
-libext=$libext
-
-# Shared library suffix (normally ".so").
-shrext_cmds=$lt_shrext_cmds
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at link time.
-variables_saved_for_relink=$lt_variables_saved_for_relink
-
-# Do we need the "lib" prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Library versioning type.
-version_type=$version_type
-
-# Shared library runtime path variable.
-runpath_var=$runpath_var
-
-# Shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names.  First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Permission mode override for installation of shared libraries.
-install_override_mode=$lt_install_override_mode
-
-# Command to use after installation of a shared archive.
-postinstall_cmds=$lt_postinstall_cmds
-
-# Command to use after uninstallation of a shared archive.
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# As "finish_cmds", except a single script fragment to be evaled but
-# not shown.
-finish_eval=$lt_finish_eval
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Compile-time system search path for libraries.
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries.
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-
-# The linker used to build libraries.
-LD=$lt_LD
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# Commands used to build an old-style archive.
-old_archive_cmds=$lt_old_archive_cmds
-
-# A language specific compiler.
-CC=$lt_compiler
-
-# Is the compiler the GNU compiler?
-with_gcc=$GCC
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc
-
-# Whether or not to disallow shared libs when runtime libs are static.
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec
-
-# Whether the compiler copes with passing no objects directly.
-compiler_needs_object=$lt_compiler_needs_object
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
-
-# Commands used to build a shared archive.
-archive_cmds=$lt_archive_cmds
-archive_expsym_cmds=$lt_archive_expsym_cmds
-
-# Commands used to build a loadable module if different from building
-# a shared archive.
-module_cmds=$lt_module_cmds
-module_expsym_cmds=$lt_module_expsym_cmds
-
-# Whether we are building with GNU ld or not.
-with_gnu_ld=$lt_with_gnu_ld
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag
-
-# Flag that enforces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
-
-# Whether we need a single "-rpath" flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator
-
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
-# DIR into the resulting binary.
-hardcode_direct=$hardcode_direct
-
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
-# DIR into the resulting binary and the resulting library dependency is
-# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
-# library is relocated.
-hardcode_direct_absolute=$hardcode_direct_absolute
-
-# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
-# into the resulting binary.
-hardcode_minus_L=$hardcode_minus_L
-
-# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
-# into the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var
-
-# Set to "yes" if building a shared library automatically hardcodes DIR
-# into the library and all subsequent libraries and executables linked
-# against it.
-hardcode_automatic=$hardcode_automatic
-
-# Set to yes if linker adds runtime paths of dependent libraries
-# to runtime path list.
-inherit_rpath=$inherit_rpath
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs
-
-# Set to "yes" if exported symbols are required.
-always_export_symbols=$always_export_symbols
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms
-
-# Commands necessary for linking programs (against libraries) with templates.
-prelink_cmds=$lt_prelink_cmds
-
-# Commands necessary for finishing linking programs.
-postlink_cmds=$lt_postlink_cmds
-
-# Specify filename containing input files.
-file_list_spec=$lt_file_list_spec
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action
-
-# ### END LIBTOOL CONFIG
-
-_LT_EOF
-
-  case $host_os in
-  aix3*)
-    cat <<\_LT_EOF >> "$cfgfile"
-# AIX sometimes has problems with the GCC collect2 program.  For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
-  COLLECT_NAMES=
-  export COLLECT_NAMES
-fi
-_LT_EOF
-    ;;
-  esac
-
-
-ltmain="$ac_aux_dir/ltmain.sh"
-
-
-  # We use sed instead of cat because bash on DJGPP gets confused if
-  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
-  # text mode, it properly converts lines to CR/LF.  This bash problem
-  # is reportedly fixed, but why not run on old versions too?
-  sed '$q' "$ltmain" >> "$cfgfile" \
-     || (rm -f "$cfgfile"; exit 1)
-
-  if test x"$xsi_shell" = xyes; then
-  sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
-func_dirname ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_basename ()$/,/^} # func_basename /c\
-func_basename ()\
-{\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
-func_dirname_and_basename ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
-func_stripname ()\
-{\
-\    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
-\    # positional parameters, so assign one to ordinary parameter first.\
-\    func_stripname_result=${3}\
-\    func_stripname_result=${func_stripname_result#"${1}"}\
-\    func_stripname_result=${func_stripname_result%"${2}"}\
-} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
-func_split_long_opt ()\
-{\
-\    func_split_long_opt_name=${1%%=*}\
-\    func_split_long_opt_arg=${1#*=}\
-} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
-func_split_short_opt ()\
-{\
-\    func_split_short_opt_arg=${1#??}\
-\    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
-} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
-func_lo2o ()\
-{\
-\    case ${1} in\
-\      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
-\      *)    func_lo2o_result=${1} ;;\
-\    esac\
-} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_xform ()$/,/^} # func_xform /c\
-func_xform ()\
-{\
-    func_xform_result=${1%.*}.lo\
-} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_arith ()$/,/^} # func_arith /c\
-func_arith ()\
-{\
-    func_arith_result=$(( $* ))\
-} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_len ()$/,/^} # func_len /c\
-func_len ()\
-{\
-    func_len_result=${#1}\
-} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  sed -e '/^func_append ()$/,/^} # func_append /c\
-func_append ()\
-{\
-    eval "${1}+=\\${2}"\
-} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
-func_append_quoted ()\
-{\
-\    func_quote_for_eval "${2}"\
-\    eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
-} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
-$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
-fi
-
-
    mv -f "$cfgfile" "$ofile" ||
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
  ;;
+    "nad/install":F) chmod +x nad/install ;;
 
   esac
 done # for ac_tag
diff --git a/configure.in b/configure.ac
similarity index 84%
rename from configure.in
rename to configure.ac
index 30f7a16..7c77490 100644
--- a/configure.in
+++ b/configure.ac
@@ -1,12 +1,12 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.59)
-AC_INIT([PROJ.4 Projections], 4.9.2, [warmerdam at pobox.com], proj)
+AC_INIT([PROJ.4 Projections], 4.9.3, [warmerdam at pobox.com], proj)
 AC_CONFIG_MACRO_DIR([m4])
 AC_LANG(C)
 
+AC_CONFIG_AUX_DIR([.])
 AM_INIT_AUTOMAKE
-AM_MAINTAINER_MODE
 AM_CONFIG_HEADER(src/proj_config.h)
 
 dnl Enable as much warnings as possible
@@ -36,7 +36,9 @@ JNI_INCLUDE=
 export JNI_INCLUDE
 
 AC_ARG_WITH(jni,
-[  --with-jni=dir          Include Java/JNI support, add optional include dir],,)
+            [AS_HELP_STRING([--with-jni=dir],
+                            [Include Java/JNI support, add optional include dir])
+            ],,)
 
 if test "$with_jni" = "yes" ; then
 
@@ -111,8 +113,11 @@ fi
 AC_SUBST(MUTEX_SETTING,$MUTEX_SETTING)
 AC_SUBST(THREAD_LIB,$THREAD_LIB)
 
-AC_OUTPUT(Makefile cmake/Makefile src/Makefile man/Makefile man/man1/Makefile \
-	man/man3/Makefile nad/Makefile \
-	jniwrap/Makefile jniwrap/org/Makefile jniwrap/org/proj4/Makefile)
+AC_CONFIG_FILES([Makefile cmake/Makefile src/Makefile
+                 man/Makefile man/man1/Makefile man/man3/Makefile nad/Makefile
+                 jniwrap/Makefile jniwrap/org/Makefile jniwrap/org/proj4/Makefile])
+AC_CONFIG_FILES([nad/install], [chmod +x nad/install])
 
-AC_OUTPUT(proj.pc)
+AC_CONFIG_FILES([proj.pc])
+
+AC_OUTPUT
diff --git a/depcomp b/depcomp
index 807b991..fc98710 100755
--- a/depcomp
+++ b/depcomp
@@ -1,7 +1,9 @@
 #! /bin/sh
-
 # depcomp - compile a program generating dependencies as side-effects
-# Copyright 1999, 2000 Free Software Foundation, Inc.
+
+scriptversion=2013-05-30.07; # UTC
+
+# Copyright (C) 1999-2014 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
@@ -14,9 +16,7 @@
 # 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., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, 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
@@ -25,26 +25,112 @@
 
 # Originally written by Alexandre Oliva <oliva at dcc.unicamp.br>.
 
+case $1 in
+  '')
+    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
+    exit 1;
+    ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  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 outputting dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake at gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+# Get the directory component of the given path, and save it in the
+# global variables '$dir'.  Note that this directory component will
+# be either empty or ending with a '/' character.  This is deliberate.
+set_dir_from ()
+{
+  case $1 in
+    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
+      *) dir=;;
+  esac
+}
+
+# Get the suffix-stripped basename of the given path, and save it the
+# global variable '$base'.
+set_base_from ()
+{
+  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
+}
+
+# If no dependency file was actually created by the compiler invocation,
+# we still have to create a dummy depfile, to avoid errors with the
+# Makefile "include basename.Plo" scheme.
+make_dummy_depfile ()
+{
+  echo "#dummy" > "$depfile"
+}
+
+# Factor out some common post-processing of the generated depfile.
+# Requires the auxiliary global variable '$tmpdepfile' to be set.
+aix_post_process_depfile ()
+{
+  # If the compiler actually managed to produce a dependency file,
+  # post-process it.
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form 'foo.o: dependency.h'.
+    # Do two passes, one to just change these to
+    #   $object: dependency.h
+    # and one to simply output
+    #   dependency.h:
+    # which is needed to avoid the deleted-header problem.
+    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
+      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
+    } > "$depfile"
+    rm -f "$tmpdepfile"
+  else
+    make_dummy_depfile
+  fi
+}
+
+# A tabulation character.
+tab='	'
+# A newline character.
+nl='
+'
+# Character ranges might be problematic outside the C locale.
+# These definitions help.
+upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
+lower=abcdefghijklmnopqrstuvwxyz
+digits=0123456789
+alpha=${upper}${lower}
+
 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
 fi
-# `libtool' can also be set to `yes' or `no'.
-
-if test -z "$depfile"; then
-   base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
-   dir=`echo "$object" | sed 's,/.*$,/,'`
-   if test "$dir" = "$object"; then
-      dir=
-   fi
-   # FIXME: should be _deps on DOS.
-   depfile="$dir.deps/$base"
-fi
 
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
 tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
 
 rm -f "$tmpdepfile"
 
+# Avoid interferences from the environment.
+gccflag= dashmflag=
+
 # Some modes work just like other modes, but use different flags.  We
 # parameterize here, but still list the modes in the big case below,
 # to make depend.m4 easier to write.  Note that we *cannot* use a case
@@ -56,9 +142,32 @@ if test "$depmode" = hp; then
 fi
 
 if test "$depmode" = dashXmstdout; then
-   # This is just like dashmstdout with a different argument.
-   dashmflag=-xM
-   depmode=dashmstdout
+  # This is just like dashmstdout with a different argument.
+  dashmflag=-xM
+  depmode=dashmstdout
+fi
+
+cygpath_u="cygpath -u -f -"
+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'
+  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 information.
+  gccflag=-qmakedep=gcc,-MF
+  depmode=gcc
 fi
 
 case "$depmode" in
@@ -66,10 +175,22 @@ gcc3)
 ## gcc 3 implements dependency tracking that does exactly what
 ## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
 ## it if -MD -MP comes after the -MF stuff.  Hmm.
-  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am.  Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -77,13 +198,17 @@ gcc3)
   ;;
 
 gcc)
+## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
+## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
+## (see the conditional assignment to $gccflag above).
 ## There are various ways to get dependency output from gcc.  Here's
 ## why we pick this rather obscure method:
 ## - Don't want to use -MD because we'd like the dependencies to end
 ##   up in a subdir.  Having to rename by hand is ugly.
 ##   (We might end up doing this anyway to support other compilers.)
 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-##   -MM, not -M (despite what the docs say).
+##   -MM, not -M (despite what the docs say).  Also, it might not be
+##   supported by the other compilers which use the 'gcc' depmode.
 ## - Using -M directly means running the compiler twice (even worse
 ##   than renaming).
   if test -z "$gccflag"; then
@@ -91,31 +216,31 @@ gcc)
   fi
   "$@" -Wp,"$gccflag$tmpdepfile"
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
-## The second -e expression handles DOS-style file names with drive letters.
+  # 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
+## 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"
+  tr ' ' "$nl" < "$tmpdepfile" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -133,8 +258,7 @@ sgi)
     "$@" -MDupdate "$tmpdepfile"
   fi
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -142,111 +266,302 @@ sgi)
 
   if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
     echo "$object : \\" > "$depfile"
-
     # Clip off the initial element (the dependent).  Don't try to be
     # 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" \
-    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
-    tr '
-' ' ' >> $depfile
-    echo >> $depfile
-
+    tr ' ' "$nl" < "$tmpdepfile" \
+      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
+      | tr "$nl" ' ' >> "$depfile"
+    echo >> "$depfile"
     # The second pass generates a dummy entry for each header file.
-    tr ' ' '
-' < "$tmpdepfile" \
-   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
-   >> $depfile
+    tr ' ' "$nl" < "$tmpdepfile" \
+      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+      >> "$depfile"
   else
-    # The sourcefile does not contain any dependencies, so just
-    # store a dummy comment line, to avoid errors with the Makefile
-    # "include basename.Plo" scheme.
-    echo "#dummy" > "$depfile"
+    make_dummy_depfile
   fi
   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.  This file always lives in the current directory.
-  # Also, the AIX compiler puts `$object:' at the start of each line;
-  # $object doesn't have directory information.
-  stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
-  tmpdepfile="$stripped.u"
-  outname="$stripped.o"
+  # in a .u file.  In older versions, this file always lives in 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.
+  set_dir_from "$object"
+  set_base_from "$object"
   if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
     "$@" -Wc,-M
   else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
     "$@" -M
   fi
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
 
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  aix_post_process_depfile
+  ;;
+
+tcc)
+  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
+  # FIXME: That version still under development at the moment of writing.
+  #        Make that this statement remains true also for stable, released
+  #        versions.
+  # It will wrap lines (doesn't matter whether long or short) with a
+  # trailing '\', as in:
+  #
+  #   foo.o : \
+  #    foo.c \
+  #    foo.h \
+  #
+  # It will put a trailing '\' even on the last line, and will use leading
+  # spaces rather than leading tabs (at least since its commit 0394caf7
+  # "Emit spaces for -MD").
+  "$@" -MD -MF "$tmpdepfile"
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
+  rm -f "$depfile"
+  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
+  # We have to change lines of the first kind to '$object: \'.
+  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
+  # And for each line of the second kind, we have to emit a 'dep.h:'
+  # dummy dependency, to avoid the deleted-header problem.
+  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
 
+## The order of this option in the case statement is important, since the
+## shell code in configure will try each of these formats in the order
+## listed in this file.  A plain '-MD' option would be understood by many
+## compilers, so we must ensure this comes after the gcc and icc options.
+pgcc)
+  # Portland's C compiler understands '-MD'.
+  # Will always output deps to 'file.d' where file is the root name of the
+  # source file under compilation, even if file resides in a subdirectory.
+  # The object file name does not affect the name of the '.d' file.
+  # pgcc 10.2 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using '\' :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+  set_dir_from "$object"
+  # Use the source, not the object, to determine the base name, since
+  # that's sadly what pgcc will do too.
+  set_base_from "$source"
+  tmpdepfile=$base.d
+
+  # For projects that build the same source file twice into different object
+  # files, the pgcc approach of using the *source* file root name can cause
+  # problems in parallel builds.  Use a locking strategy to avoid stomping on
+  # the same $tmpdepfile.
+  lockdir=$base.d-lock
+  trap "
+    echo '$0: caught signal, cleaning up...' >&2
+    rmdir '$lockdir'
+    exit 1
+  " 1 2 13 15
+  numtries=100
+  i=$numtries
+  while test $i -gt 0; do
+    # mkdir is a portable test-and-set.
+    if mkdir "$lockdir" 2>/dev/null; then
+      # This process acquired the lock.
+      "$@" -MD
+      stat=$?
+      # Release the lock.
+      rmdir "$lockdir"
+      break
+    else
+      # If the lock is being held by a different process, wait
+      # until the winning process is done or we timeout.
+      while test -d "$lockdir" && test $i -gt 0; do
+        sleep 1
+        i=`expr $i - 1`
+      done
+    fi
+    i=`expr $i - 1`
+  done
+  trap - 1 2 13 15
+  if test $i -le 0; then
+    echo "$0: failed to acquire lock after $numtries attempts" >&2
+    echo "$0: check lockdir '$lockdir'" >&2
+    exit 1
+  fi
+
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile"
+    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 \'.
+  # 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"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp2)
+  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+  # compilers, which have integrated preprocessors.  The correct option
+  # to use with these is +Maked; it writes dependencies to a file named
+  # 'foo.d', which lands next to the object file, wherever that
+  # happens to be.
+  # Much of this is similar to the tru64 case; see comments there.
+  set_dir_from  "$object"
+  set_base_from "$object"
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir.libs/$base.d
+    "$@" -Wc,+Maked
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    "$@" +Maked
+  fi
+  stat=$?
+  if test $stat -ne 0; then
+     rm -f "$tmpdepfile1" "$tmpdepfile2"
+     exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+  do
+    test -f "$tmpdepfile" && break
+  done
   if test -f "$tmpdepfile"; then
-    # 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:'.
-    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
-    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add 'dependent.h:' lines.
+    sed -ne '2,${
+               s/^ *//
+               s/ \\*$//
+               s/$/:/
+               p
+             }' "$tmpdepfile" >> "$depfile"
   else
-    # The sourcefile does not contain any dependencies, so just
-    # store a dummy comment line, to avoid errors with the Makefile
-    # "include basename.Plo" scheme.
-    echo "#dummy" > "$depfile"
+    make_dummy_depfile
   fi
-  rm -f "$tmpdepfile"
+  rm -f "$tmpdepfile" "$tmpdepfile2"
   ;;
 
 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'.
-   # 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.
-   # Subdirectories are respected.
-   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
-   test "x$dir" = "x$object" && dir=
-   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-
-   if test "$libtool" = yes; then
-      tmpdepfile1="$dir.libs/$base.lo.d"
-      tmpdepfile2="$dir.libs/$base.d"
-      "$@" -Wc,-MD
-   else
-      tmpdepfile1="$dir$base.o.d"
-      tmpdepfile2="$dir$base.d"
-      "$@" -MD
-   fi
-
-   stat=$?
-   if test $stat -eq 0; then :
-   else
-      rm -f "$tmpdepfile1" "$tmpdepfile2"
-      exit $stat
-   fi
-
-   if test -f "$tmpdepfile1"; then
-      tmpdepfile="$tmpdepfile1"
-   else
-      tmpdepfile="$tmpdepfile2"
-   fi
-   if test -f "$tmpdepfile"; then
-      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-      # That's a space and a tab in the [].
-      sed -e 's,^.*\.[a-z]*:[ 	]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
-   else
-      echo "#dummy" > "$depfile"
-   fi
-   rm -f "$tmpdepfile"
-   ;;
+  # The Tru64 compiler uses -MD to generate dependencies as a side
+  # 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.
+  # Subdirectories are respected.
+  set_dir_from  "$object"
+  set_base_from "$object"
+
+  if test "$libtool" = yes; then
+    # Libtool generates 2 separate objects for the 2 libraries.  These
+    # two compilations output dependencies in $dir.libs/$base.o.d and
+    # in $dir$base.o.d.  We have to check for both files, because
+    # one of the two compilations can be disabled.  We should prefer
+    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+    # automatically cleaned when .libs/ is deleted, while ignoring
+    # the former would cause a distcleancheck panic.
+    tmpdepfile1=$dir$base.o.d          # libtool 1.5
+    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
+    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
+    "$@" -Wc,-MD
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    tmpdepfile3=$dir$base.d
+    "$@" -MD
+  fi
+
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  # Same post-processing that is required for AIX mode.
+  aix_post_process_depfile
+  ;;
+
+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 -ne 0; then
+    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"
+  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
+  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
@@ -254,20 +569,18 @@ tru64)
 
 dashmstdout)
   # Important note: in order to support this mode, a compiler *must*
-  # always write the proprocessed file to stdout, regardless of -o.
+  # always write the preprocessed file to stdout, regardless of -o.
   "$@" || exit $?
 
   # Remove the call to Libtool.
   if test "$libtool" = yes; then
-    while test $1 != '--mode=compile'; do
+    while test "X$1" != 'X--mode=compile'; do
       shift
     done
     shift
   fi
 
-  # Remove `-o $object'.  We will use -o /dev/null later,
-  # however we can't do the remplacement now because
-  # `-o $object' might simply not be used
+  # Remove '-o $object'.
   IFS=" "
   for arg
   do
@@ -287,14 +600,18 @@ dashmstdout)
   done
 
   test -z "$dashmflag" && dashmflag=-M
-  "$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ 	]*:'"$object"'\: :' > "$tmpdepfile"
+  # 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.
+  "$@" $dashmflag |
+    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
   rm -f "$depfile"
   cat < "$tmpdepfile" > "$depfile"
-  tr ' ' '
-' < "$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"
+  # Some versions of the HPUX 10.20 sed can't process this sed invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  tr ' ' "$nl" < "$tmpdepfile" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -306,51 +623,70 @@ dashXmstdout)
 
 makedepend)
   "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
   # X makedepend
   shift
-  cleared=no
-  for arg in "$@"; do
+  cleared=no eat=no
+  for arg
+  do
     case $cleared in
     no)
       set ""; shift
       cleared=yes ;;
     esac
+    if test $eat = yes; then
+      eat=no
+      continue
+    fi
     case "$arg" in
     -D*|-I*)
       set fnord "$@" "$arg"; shift ;;
-    -*)
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -arch)
+      eat=yes ;;
+    -*|$object)
       ;;
     *)
       set fnord "$@" "$arg"; shift ;;
     esac
   done
-  obj_suffix="`echo $object | sed 's/^.*\././'`"
+  obj_suffix=`echo "$object" | sed 's/^.*\././'`
   touch "$tmpdepfile"
   ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
   rm -f "$depfile"
-  cat < "$tmpdepfile" > "$depfile"
-  sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
-## 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"
+  # 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"
+  # Some versions of the HPUX 10.20 sed can't process the last invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed '1,2d' "$tmpdepfile" \
+    | tr ' ' "$nl" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile" "$tmpdepfile".bak
   ;;
 
 cpp)
   # Important note: in order to support this mode, a compiler *must*
-  # always write the proprocessed file to stdout.
+  # always write the preprocessed file to stdout.
   "$@" || exit $?
 
   # Remove the call to Libtool.
   if test "$libtool" = yes; then
-    while test $1 != '--mode=compile'; do
+    while test "X$1" != 'X--mode=compile'; do
       shift
     done
     shift
   fi
 
-  # Remove `-o $object'.
+  # Remove '-o $object'.
   IFS=" "
   for arg
   do
@@ -369,9 +705,10 @@ cpp)
     esac
   done
 
-  "$@" -E |
-    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
-    sed '$ s: \\$::' > "$tmpdepfile"
+  "$@" -E \
+    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+    | sed '$ s: \\$::' > "$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
   cat < "$tmpdepfile" >> "$depfile"
@@ -381,35 +718,56 @@ cpp)
 
 msvisualcpp)
   # Important note: in order to support this mode, a compiler *must*
-  # always write the proprocessed file to stdout, regardless of -o,
-  # because we must use -o when running libtool.
+  # always write the preprocessed file to stdout.
   "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
   IFS=" "
   for arg
   do
     case "$arg" in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
     "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
-	set fnord "$@"
-	shift
-	shift
-	;;
+        set fnord "$@"
+        shift
+        shift
+        ;;
     *)
-	set fnord "$@" "$arg"
-	shift
-	shift
-	;;
+        set fnord "$@" "$arg"
+        shift
+        shift
+        ;;
     esac
   done
-  "$@" -E |
-  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+  "$@" -E 2>/dev/null |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
-  echo "	" >> "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$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"
   ;;
 
+msvcmsys)
+  # 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
+  ;;
+
 none)
   exec "$@"
   ;;
@@ -421,3 +779,13 @@ none)
 esac
 
 exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/install-sh b/install-sh
index 6781b98..0b0fdcb 100755
--- a/install-sh
+++ b/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2009-04-28.21; # UTC
+scriptversion=2013-12-25.23; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -35,25 +35,21 @@ 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
 # from scratch.
 
+tab='	'
 nl='
 '
-IFS=" ""	$nl"
+IFS=" $tab$nl"
 
-# set DOITPROG to echo to test this script
+# Set DOITPROG to "echo" to test this script.
 
-# Don't use :- since 4.3BSD and earlier shells don't like it.
 doit=${DOITPROG-}
-if test -z "$doit"; then
-  doit_exec=exec
-else
-  doit_exec=$doit
-fi
+doit_exec=${doit:-exec}
 
 # Put in absolute file names if you don't have them in your path;
 # or use environment vars.
@@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
 rmprog=${RMPROG-rm}
 stripprog=${STRIPPROG-strip}
 
-posix_glob='?'
-initialize_posix_glob='
-  test "$posix_glob" != "?" || {
-    if (set -f) 2>/dev/null; then
-      posix_glob=
-    else
-      posix_glob=:
-    fi
-  }
-'
-
 posix_mkdir=
 
 # Desired mode of installed file.
@@ -97,7 +82,7 @@ dir_arg=
 dst_arg=
 
 copy_on_change=false
-no_target_directory=
+is_target_a_directory=possibly
 
 usage="\
 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@@ -137,42 +122,57 @@ while test $# -ne 0; do
     -d) dir_arg=true;;
 
     -g) chgrpcmd="$chgrpprog $2"
-	shift;;
+        shift;;
 
     --help) echo "$usage"; exit $?;;
 
     -m) mode=$2
-	case $mode in
-	  *' '* | *'	'* | *'
-'*	  | *'*'* | *'?'* | *'['*)
-	    echo "$0: invalid mode: $mode" >&2
-	    exit 1;;
-	esac
-	shift;;
+        case $mode in
+          *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
+            echo "$0: invalid mode: $mode" >&2
+            exit 1;;
+        esac
+        shift;;
 
     -o) chowncmd="$chownprog $2"
-	shift;;
+        shift;;
 
     -s) stripcmd=$stripprog;;
 
-    -t) dst_arg=$2
-	shift;;
+    -t)
+        is_target_a_directory=always
+        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;;
+    -T) is_target_a_directory=never;;
 
     --version) echo "$0 $scriptversion"; exit $?;;
 
-    --)	shift
-	break;;
+    --) shift
+        break;;
 
-    -*)	echo "$0: invalid option: $1" >&2
-	exit 1;;
+    -*) echo "$0: invalid option: $1" >&2
+        exit 1;;
 
     *)  break;;
   esac
   shift
 done
 
+# We allow the use of options -d and -T together, by making -d
+# take the precedence; this is for compatibility with GNU install.
+
+if test -n "$dir_arg"; then
+  if test -n "$dst_arg"; then
+    echo "$0: target directory not allowed when installing a directory." >&2
+    exit 1
+  fi
+fi
+
 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
   # When -d is used, all remaining arguments are directories to create.
   # When -t is used, the destination is already specified.
@@ -186,6 +186,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 +198,26 @@ 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
+  if test $# -gt 1 || test "$is_target_a_directory" = always; then
+    if test ! -d "$dst_arg"; then
+      echo "$0: $dst_arg: Is not a directory." >&2
+      exit 1
+    fi
+  fi
+fi
+
+if test -z "$dir_arg"; then
+  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.
@@ -211,16 +228,16 @@ if test -z "$dir_arg"; then
 
     *[0-7])
       if test -z "$stripcmd"; then
-	u_plus_rw=
+        u_plus_rw=
       else
-	u_plus_rw='% 200'
+        u_plus_rw='% 200'
       fi
       cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
     *)
       if test -z "$stripcmd"; then
-	u_plus_rw=
+        u_plus_rw=
       else
-	u_plus_rw=,u+rw
+        u_plus_rw=,u+rw
       fi
       cp_umask=$mode$u_plus_rw;;
   esac
@@ -228,9 +245,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,51 +269,20 @@ 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.
     if test -d "$dst"; then
-      if test -n "$no_target_directory"; then
-	echo "$0: $dst_arg: Is a directory" >&2
-	exit 1
+      if test "$is_target_a_directory" = never; then
+        echo "$0: $dst_arg: Is a directory" >&2
+        exit 1
       fi
       dstdir=$dst
       dst=$dstdir/`basename "$src"`
       dstdir_status=0
     else
-      # Prefer dirname, but fall back on a substitute if dirname fails.
-      dstdir=`
-	(dirname "$dst") 2>/dev/null ||
-	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	     X"$dst" : 'X\(//\)[^/]' \| \
-	     X"$dst" : 'X\(//\)$' \| \
-	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
-	echo X"$dst" |
-	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)[^/].*/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\).*/{
-		   s//\1/
-		   q
-		 }
-		 s/.*/./; q'
-      `
-
+      dstdir=`dirname "$dst"`
       test -d "$dstdir"
       dstdir_status=$?
     fi
@@ -307,74 +293,74 @@ do
   if test $dstdir_status != 0; then
     case $posix_mkdir in
       '')
-	# Create intermediate dirs using mode 755 as modified by the umask.
-	# This is like FreeBSD 'install' as of 1997-10-28.
-	umask=`umask`
-	case $stripcmd.$umask in
-	  # Optimize common cases.
-	  *[2367][2367]) mkdir_umask=$umask;;
-	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
-	  *[0-7])
-	    mkdir_umask=`expr $umask + 22 \
-	      - $umask % 100 % 40 + $umask % 20 \
-	      - $umask % 10 % 4 + $umask % 2
-	    `;;
-	  *) mkdir_umask=$umask,go-w;;
-	esac
-
-	# With -d, create the new directory with the user-specified mode.
-	# Otherwise, rely on $mkdir_umask.
-	if test -n "$dir_arg"; then
-	  mkdir_mode=-m$mode
-	else
-	  mkdir_mode=
-	fi
-
-	posix_mkdir=false
-	case $umask in
-	  *[123567][0-7][0-7])
-	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
-	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
-	    ;;
-	  *)
-	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
-	    if (umask $mkdir_umask &&
-		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
-	    then
-	      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.
-		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
-		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
-		   case $ls_ld_tmpdir in
-		     d????-?r-*) different_mode=700;;
-		     d????-?--*) different_mode=755;;
-		     *) false;;
-		   esac &&
-		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
-		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
-		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-		   }
-		 }
-	      then posix_mkdir=:
-	      fi
-	      rmdir "$tmpdir/d" "$tmpdir"
-	    else
-	      # Remove any dirs left behind by ancient mkdir implementations.
-	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
-	    fi
-	    trap '' 0;;
-	esac;;
+        # Create intermediate dirs using mode 755 as modified by the umask.
+        # This is like FreeBSD 'install' as of 1997-10-28.
+        umask=`umask`
+        case $stripcmd.$umask in
+          # Optimize common cases.
+          *[2367][2367]) mkdir_umask=$umask;;
+          .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+          *[0-7])
+            mkdir_umask=`expr $umask + 22 \
+              - $umask % 100 % 40 + $umask % 20 \
+              - $umask % 10 % 4 + $umask % 2
+            `;;
+          *) mkdir_umask=$umask,go-w;;
+        esac
+
+        # With -d, create the new directory with the user-specified mode.
+        # Otherwise, rely on $mkdir_umask.
+        if test -n "$dir_arg"; then
+          mkdir_mode=-m$mode
+        else
+          mkdir_mode=
+        fi
+
+        posix_mkdir=false
+        case $umask in
+          *[123567][0-7][0-7])
+            # POSIX mkdir -p sets u+wx bits regardless of umask, which
+            # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+            ;;
+          *)
+            tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+            trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+            if (umask $mkdir_umask &&
+                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+            then
+              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-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
+                     d????-?r-*) different_mode=700;;
+                     d????-?--*) different_mode=755;;
+                     *) false;;
+                   esac &&
+                   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+                     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+                     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+                   }
+                 }
+              then posix_mkdir=:
+              fi
+              rmdir "$tmpdir/d" "$tmpdir"
+            else
+              # Remove any dirs left behind by ancient mkdir implementations.
+              rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+            fi
+            trap '' 0;;
+        esac;;
     esac
 
     if
       $posix_mkdir && (
-	umask $mkdir_umask &&
-	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+        umask $mkdir_umask &&
+        $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
       )
     then :
     else
@@ -384,53 +370,51 @@ do
       # directory the slow way, step by step, checking for races as we go.
 
       case $dstdir in
-	/*) prefix='/';;
-	-*) prefix='./';;
-	*)  prefix='';;
+        /*) prefix='/';;
+        [-=\(\)!]*) prefix='./';;
+        *)  prefix='';;
       esac
 
-      eval "$initialize_posix_glob"
-
       oIFS=$IFS
       IFS=/
-      $posix_glob set -f
+      set -f
       set fnord $dstdir
       shift
-      $posix_glob set +f
+      set +f
       IFS=$oIFS
 
       prefixes=
 
       for d
       do
-	test -z "$d" && continue
-
-	prefix=$prefix$d
-	if test -d "$prefix"; then
-	  prefixes=
-	else
-	  if $posix_mkdir; then
-	    (umask=$mkdir_umask &&
-	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
-	    # Don't fail if two instances are running concurrently.
-	    test -d "$prefix" || exit 1
-	  else
-	    case $prefix in
-	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
-	      *) qprefix=$prefix;;
-	    esac
-	    prefixes="$prefixes '$qprefix'"
-	  fi
-	fi
-	prefix=$prefix/
+        test X"$d" = X && continue
+
+        prefix=$prefix$d
+        if test -d "$prefix"; then
+          prefixes=
+        else
+          if $posix_mkdir; then
+            (umask=$mkdir_umask &&
+             $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+            # Don't fail if two instances are running concurrently.
+            test -d "$prefix" || exit 1
+          else
+            case $prefix in
+              *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+              *) qprefix=$prefix;;
+            esac
+            prefixes="$prefixes '$qprefix'"
+          fi
+        fi
+        prefix=$prefix/
       done
 
       if test -n "$prefixes"; then
-	# Don't fail if two instances are running concurrently.
-	(umask $mkdir_umask &&
-	 eval "\$doit_exec \$mkdirprog $prefixes") ||
-	  test -d "$dstdir" || exit 1
-	obsolete_mkdir_used=true
+        # Don't fail if two instances are running concurrently.
+        (umask $mkdir_umask &&
+         eval "\$doit_exec \$mkdirprog $prefixes") ||
+          test -d "$dstdir" || exit 1
+        obsolete_mkdir_used=true
       fi
     fi
   fi
@@ -465,15 +449,12 @@ do
 
     # If -C, don't bother to copy if it wouldn't change the file.
     if $copy_on_change &&
-       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
-       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
-
-       eval "$initialize_posix_glob" &&
-       $posix_glob set -f &&
+       old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
+       set -f &&
        set X $old && old=:$2:$4:$5:$6 &&
        set X $new && new=:$2:$4:$5:$6 &&
-       $posix_glob set +f &&
-
+       set +f &&
        test "$old" = "$new" &&
        $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
     then
@@ -486,24 +467,24 @@ do
       # to itself, or perhaps because mv is so ancient that it does not
       # support -f.
       {
-	# Now remove or move aside any old file at destination location.
-	# We try this two ways since rm can't unlink itself on some
-	# systems and the destination file might be busy for other
-	# reasons.  In this case, the final cleanup might fail but the new
-	# file should still install successfully.
-	{
-	  test ! -f "$dst" ||
-	  $doit $rmcmd -f "$dst" 2>/dev/null ||
-	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
-	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
-	  } ||
-	  { echo "$0: cannot unlink or rename $dst" >&2
-	    (exit 1); exit 1
-	  }
-	} &&
-
-	# Now rename the file to the real destination.
-	$doit $mvcmd "$dsttmp" "$dst"
+        # Now remove or move aside any old file at destination location.
+        # We try this two ways since rm can't unlink itself on some
+        # systems and the destination file might be busy for other
+        # reasons.  In this case, the final cleanup might fail but the new
+        # file should still install successfully.
+        {
+          test ! -f "$dst" ||
+          $doit $rmcmd -f "$dst" 2>/dev/null ||
+          { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+            { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+          } ||
+          { echo "$0: cannot unlink or rename $dst" >&2
+            (exit 1); exit 1
+          }
+        } &&
+
+        # Now rename the file to the real destination.
+        $doit $mvcmd "$dsttmp" "$dst"
       }
     fi || exit 1
 
diff --git a/jniwrap/Makefile.in b/jniwrap/Makefile.in
index 4b1dc5c..98434f2 100644
--- a/jniwrap/Makefile.in
+++ b/jniwrap/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -78,16 +88,15 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = jniwrap
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/mkinstalldirs README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/proj_config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
@@ -146,6 +155,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -213,7 +223,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -296,7 +306,7 @@ SUBDIRS = org
 all: all-recursive
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -308,7 +318,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu jniwrap/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu jniwrap/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -321,9 +330,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
@@ -604,6 +613,8 @@ uninstall-am:
 	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
 	uninstall-am
 
+.PRECIOUS: Makefile
+
 
 install-data-local:
 	echo In jniwrap
diff --git a/jniwrap/org/Makefile.in b/jniwrap/org/Makefile.in
index 289f9b7..c82b36f 100644
--- a/jniwrap/org/Makefile.in
+++ b/jniwrap/org/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -78,16 +88,15 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = jniwrap/org
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/mkinstalldirs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/proj_config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
@@ -146,6 +155,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -213,7 +223,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -295,7 +305,7 @@ SUBDIRS = proj4
 all: all-recursive
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -307,7 +317,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu jniwrap/org/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu jniwrap/org/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -320,9 +329,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
@@ -602,6 +611,8 @@ uninstall-am:
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
 	ps ps-am tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/jniwrap/org/proj4/Makefile.in b/jniwrap/org/proj4/Makefile.in
index b3465be..c2a170e 100644
--- a/jniwrap/org/proj4/Makefile.in
+++ b/jniwrap/org/proj4/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -78,16 +88,15 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = jniwrap/org/proj4
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/mkinstalldirs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/proj_config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
@@ -111,6 +120,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -153,7 +163,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -235,7 +245,7 @@ EXTRA_DIST = PJ.java PJException.java package-info.java
 all: all-am
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -247,7 +257,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu jniwrap/org/proj4/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu jniwrap/org/proj4/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -260,9 +269,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
@@ -422,6 +431,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/ltconfig b/ltconfig
deleted file mode 100755
index a01334f..0000000
--- a/ltconfig
+++ /dev/null
@@ -1,3078 +0,0 @@
-#! /bin/sh
-
-# ltconfig - Create a system-specific libtool.
-# Copyright (C) 1996-1999 Free Software Foundation, Inc.
-# Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
-#
-# 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
-# the Free Software Foundation; either version 2 of the License, 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, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# 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.
-
-# A lot of this script is taken from autoconf-2.10.
-
-# Check that we are running under the correct shell.
-SHELL=${CONFIG_SHELL-/bin/sh}
-echo=echo
-if test "X$1" = X--no-reexec; then
-  # Discard the --no-reexec flag, and continue.
-  shift
-elif test "X$1" = X--fallback-echo; then
-  # Avoid inline document here, it may be left over
-  :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
-  # Yippee, $echo works!
-  :
-else
-  # Restart under the correct shell.
-  exec "$SHELL" "$0" --no-reexec ${1+"$@"}
-fi
-
-if test "X$1" = X--fallback-echo; then
-  # used as fallback echo
-  shift
-  cat <<EOF
-$*
-EOF
-  exit 0
-fi
-
-# Find the correct PATH separator.  Usually this is `:', but
-# DJGPP uses `;' like DOS.
-if test "X${PATH_SEPARATOR+set}" != Xset; then
-  UNAME=${UNAME-`uname 2>/dev/null`}
-  case X$UNAME in
-    *-DOS) PATH_SEPARATOR=';' ;;
-    *)     PATH_SEPARATOR=':' ;;
-  esac
-fi
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
-
-if test "X${echo_test_string+set}" != Xset; then
-  # find a string as large as possible, as long as the shell can cope with it
-  for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
-    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
-    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
-       echo_test_string="`eval $cmd`" &&
-       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null; then
-      break
-    fi
-  done
-fi
-
-if test "X`($echo '\t') 2>/dev/null`" != 'X\t' ||
-   test "X`($echo "$echo_test_string") 2>/dev/null`" != X"$echo_test_string"; then
-  # The Solaris, AIX, and Digital Unix default echo programs unquote
-  # backslashes.  This makes it impossible to quote backslashes using
-  #   echo "$something" | sed 's/\\/\\\\/g'
-  #
-  # So, first we look for a working echo in the user's PATH.
-
-  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
-  for dir in $PATH /usr/ucb; do
-    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
-       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
-       test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
-      echo="$dir/echo"
-      break
-    fi
-  done
-  IFS="$save_ifs"
-
-  if test "X$echo" = Xecho; then
-    # We didn't find a better echo, so look for alternatives.
-    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
-       test "X`(print -r "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
-      # This shell has a builtin print -r that does the trick.
-      echo='print -r'
-    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
-	 test "X$CONFIG_SHELL" != X/bin/ksh; then
-      # If we have ksh, try running ltconfig again with it.
-      ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}"
-      export ORIGINAL_CONFIG_SHELL
-      CONFIG_SHELL=/bin/ksh
-      export CONFIG_SHELL
-      exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"}
-    else
-      # Try using printf.
-      echo='printf "%s\n"'
-      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
-	 test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
-	# Cool, printf works
-	:
-      elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' &&
-	   test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
-	CONFIG_SHELL="$ORIGINAL_CONFIG_SHELL"
-	export CONFIG_SHELL
-	SHELL="$CONFIG_SHELL"
-	export SHELL
-	echo="$CONFIG_SHELL $0 --fallback-echo"
-      elif test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' &&
-	   test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
-	echo="$CONFIG_SHELL $0 --fallback-echo"
-      else
-	# maybe with a smaller string...
-	prev=:
-
-	for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
-	  if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null; then
-	    break
-	  fi
-	  prev="$cmd"
-	done
-
-	if test "$prev" != 'sed 50q "$0"'; then
-	  echo_test_string=`eval $prev`
-	  export echo_test_string
-	  exec "${ORIGINAL_CONFIG_SHELL}" "$0" ${1+"$@"}
-	else
-	  # Oops.  We lost completely, so just stick with echo.
-	  echo=echo
-	fi
-      fi
-    fi
-  fi
-fi
-
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e s/^X//'
-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'
-
-# The name of this program.
-progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'`
-
-# Constants:
-PROGRAM=ltconfig
-PACKAGE=libtool
-VERSION=1.3.4
-TIMESTAMP=" (1.385.2.196 1999/12/07 21:47:57)"
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-rm="rm -f"
-
-help="Try \`$progname --help' for more information."
-
-# Global variables:
-default_ofile=libtool
-can_build_shared=yes
-enable_shared=yes
-# All known linkers require a `.a' archive for static linking (except M$VC,
-# which needs '.lib').
-enable_static=yes
-enable_fast_install=yes
-enable_dlopen=unknown
-enable_win32_dll=no
-ltmain=
-silent=
-srcdir=
-ac_config_guess=
-ac_config_sub=
-host=
-nonopt=
-ofile="$default_ofile"
-verify_host=yes
-with_gcc=no
-with_gnu_ld=no
-need_locks=yes
-ac_ext=c
-objext=o
-libext=a
-exeext=
-cache_file=
-
-old_AR="$AR"
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-old_CPPFLAGS="$CPPFLAGS"
-old_LDFLAGS="$LDFLAGS"
-old_LD="$LD"
-old_LN_S="$LN_S"
-old_LIBS="$LIBS"
-old_NM="$NM"
-old_RANLIB="$RANLIB"
-old_DLLTOOL="$DLLTOOL"
-old_OBJDUMP="$OBJDUMP"
-old_AS="$AS"
-
-# Parse the command line options.
-args=
-prev=
-for option
-do
-  case "$option" in
-  -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-  *) optarg= ;;
-  esac
-
-  # If the previous option needs an argument, assign it.
-  if test -n "$prev"; then
-    eval "$prev=\$option"
-    prev=
-    continue
-  fi
-
-  case "$option" in
-  --help) cat <<EOM
-Usage: $progname [OPTION]... [HOST [LTMAIN]]
-
-Generate a system-specific libtool script.
-
-    --debug                enable verbose shell tracing
-    --disable-shared       do not build shared libraries
-    --disable-static       do not build static libraries
-    --disable-fast-install do not optimize for fast installation
-    --enable-dlopen        enable dlopen support
-    --enable-win32-dll     enable building dlls on win32 hosts
-    --help                 display this help and exit
-    --no-verify            do not verify that HOST is a valid host type
--o, --output=FILE          specify the output file [default=$default_ofile]
-    --quiet                same as \`--silent'
-    --silent               do not print informational messages
-    --srcdir=DIR           find \`config.guess' in DIR
-    --version              output version information and exit
-    --with-gcc             assume that the GNU C compiler will be used
-    --with-gnu-ld          assume that the C compiler uses the GNU linker
-    --disable-lock         disable file locking
-    --cache-file=FILE      configure cache file
-
-LTMAIN is the \`ltmain.sh' shell script fragment or \`ltmain.c' program
-that provides basic libtool functionality.
-
-HOST is the canonical host system name [default=guessed].
-EOM
-  exit 0
-  ;;
-
-  --debug)
-    echo "$progname: enabling shell trace mode"
-    set -x
-    ;;
-
-  --disable-shared) enable_shared=no ;;
-
-  --disable-static) enable_static=no ;;
-
-  --disable-fast-install) enable_fast_install=no ;;
-
-  --enable-dlopen) enable_dlopen=yes ;;
-
-  --enable-win32-dll) enable_win32_dll=yes ;;
-
-  --quiet | --silent) silent=yes ;;
-
-  --srcdir) prev=srcdir ;;
-  --srcdir=*) srcdir="$optarg" ;;
-
-  --no-verify) verify_host=no ;;
-
-  --output | -o) prev=ofile ;;
-  --output=*) ofile="$optarg" ;;
-
-  --version) echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"; exit 0 ;;
-
-  --with-gcc) with_gcc=yes ;;
-  --with-gnu-ld) with_gnu_ld=yes ;;
-
-  --disable-lock) need_locks=no ;;
-
-  --cache-file=*) cache_file="$optarg" ;;
-
-  -*)
-    echo "$progname: unrecognized option \`$option'" 1>&2
-    echo "$help" 1>&2
-    exit 1
-    ;;
-
-  *)
-    if test -z "$ltmain"; then
-      ltmain="$option"
-    elif test -z "$host"; then
-# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1
-#      if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then
-#        echo "$progname: warning \`$option' is not a valid host type" 1>&2
-#      fi
-      host="$option"
-    else
-      echo "$progname: too many arguments" 1>&2
-      echo "$help" 1>&2
-      exit 1
-    fi ;;
-  esac
-done
-
-if test -z "$ltmain"; then
-  echo "$progname: you must specify a LTMAIN file" 1>&2
-  echo "$help" 1>&2
-  exit 1
-fi
-
-if test ! -f "$ltmain"; then
-  echo "$progname: \`$ltmain' does not exist" 1>&2
-  echo "$help" 1>&2
-  exit 1
-fi
-
-# Quote any args containing shell metacharacters.
-ltconfig_args=
-for arg
-do
-  case "$arg" in
-  *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
-  ltconfig_args="$ltconfig_args '$arg'" ;;
-  *) ltconfig_args="$ltconfig_args $arg" ;;
-  esac
-done
-
-# A relevant subset of AC_INIT.
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 5 compiler messages saved in config.log
-# 6 checking for... messages and results
-if test "$silent" = yes; then
-  exec 6>/dev/null
-else
-  exec 6>&1
-fi
-exec 5>>./config.log
-
-# NLS nuisances.
-# Only set LANG and LC_ALL to C if already set.
-# These must not be set unconditionally because not all systems understand
-# e.g. LANG=C (notably SCO).
-if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi
-if test "X${LANG+set}"   = Xset; then LANG=C;   export LANG;   fi
-
-if test -n "$cache_file" && test -r "$cache_file"; then
-  echo "loading cache $cache_file within ltconfig"
-  . $cache_file
-fi
-
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
-  # Stardent Vistra SVR4 grep lacks -e, says ghazi at caip.rutgers.edu.
-  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
-    ac_n= ac_c='
-' ac_t='	'
-  else
-    ac_n=-n ac_c= ac_t=
-  fi
-else
-  ac_n= ac_c='\c' ac_t=
-fi
-
-if test -z "$srcdir"; then
-  # Assume the source directory is the same one as the path to LTMAIN.
-  srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'`
-  test "$srcdir" = "$ltmain" && srcdir=.
-fi
-
-trap "$rm conftest*; exit 1" 1 2 15
-if test "$verify_host" = yes; then
-  # Check for config.guess and config.sub.
-  ac_aux_dir=
-  for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
-    if test -f $ac_dir/config.guess; then
-      ac_aux_dir=$ac_dir
-      break
-    fi
-  done
-  if test -z "$ac_aux_dir"; then
-    echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2
-    echo "$help" 1>&2
-    exit 1
-  fi
-  ac_config_guess=$ac_aux_dir/config.guess
-  ac_config_sub=$ac_aux_dir/config.sub
-
-  # Make sure we can run config.sub.
-  if $SHELL $ac_config_sub sun4 >/dev/null 2>&1; then :
-  else
-    echo "$progname: cannot run $ac_config_sub" 1>&2
-    echo "$help" 1>&2
-    exit 1
-  fi
-
-  echo $ac_n "checking host system type""... $ac_c" 1>&6
-
-  host_alias=$host
-  case "$host_alias" in
-  "")
-    if host_alias=`$SHELL $ac_config_guess`; then :
-    else
-      echo "$progname: cannot guess host type; you must specify one" 1>&2
-      echo "$help" 1>&2
-      exit 1
-    fi ;;
-  esac
-  host=`$SHELL $ac_config_sub $host_alias`
-  echo "$ac_t$host" 1>&6
-
-  # Make sure the host verified.
-  test -z "$host" && exit 1
-
-elif test -z "$host"; then
-  echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2
-  echo "$help" 1>&2
-  exit 1
-else
-  host_alias=$host
-fi
-
-# Transform linux* to *-*-linux-gnu*, to support old configure scripts.
-case "$host_os" in
-linux-gnu*) ;;
-linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
-esac
-
-host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-case "$host_os" in
-aix3*)
-  # AIX sometimes has problems with the GCC collect2 program.  For some
-  # reason, if we set the COLLECT_NAMES environment variable, the problems
-  # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
-    COLLECT_NAMES=
-    export COLLECT_NAMES
-  fi
-  ;;
-esac
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR cru $oldlib$oldobjs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-# Set a sane default for `AR'.
-test -z "$AR" && AR=ar
-
-# Set a sane default for `OBJDUMP'.
-test -z "$OBJDUMP" && OBJDUMP=objdump
-
-# If RANLIB is not set, then run the test.
-if test "${RANLIB+set}" != "set"; then
-  result=no
-
-  echo $ac_n "checking for ranlib... $ac_c" 1>&6
-  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
-  for dir in $PATH; do
-    test -z "$dir" && dir=.
-    if test -f $dir/ranlib || test -f $dir/ranlib$ac_exeext; then
-      RANLIB="ranlib"
-      result="ranlib"
-      break
-    fi
-  done
-  IFS="$save_ifs"
-
-  echo "$ac_t$result" 1>&6
-fi
-
-if test -n "$RANLIB"; then
-  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
-  old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
-fi
-
-# Set sane defaults for `DLLTOOL', `OBJDUMP', and `AS', used on cygwin.
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-test -z "$OBJDUMP" && OBJDUMP=objdump
-test -z "$AS" && AS=as
-
-# Check to see if we are using GCC.
-if test "$with_gcc" != yes || test -z "$CC"; then
-  # If CC is not set, then try to find GCC or a usable CC.
-  if test -z "$CC"; then
-    echo $ac_n "checking for gcc... $ac_c" 1>&6
-    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
-    for dir in $PATH; do
-      test -z "$dir" && dir=.
-      if test -f $dir/gcc || test -f $dir/gcc$ac_exeext; then
-	CC="gcc"
-	break
-      fi
-    done
-    IFS="$save_ifs"
-
-    if test -n "$CC"; then
-      echo "$ac_t$CC" 1>&6
-    else
-      echo "$ac_t"no 1>&6
-    fi
-  fi
-
-  # Not "gcc", so try "cc", rejecting "/usr/ucb/cc".
-  if test -z "$CC"; then
-    echo $ac_n "checking for cc... $ac_c" 1>&6
-    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
-    cc_rejected=no
-    for dir in $PATH; do
-      test -z "$dir" && dir=.
-      if test -f $dir/cc || test -f $dir/cc$ac_exeext; then
-	if test "$dir/cc" = "/usr/ucb/cc"; then
-	  cc_rejected=yes
-	  continue
-	fi
-	CC="cc"
-	break
-      fi
-    done
-    IFS="$save_ifs"
-    if test $cc_rejected = yes; then
-      # We found a bogon in the path, so make sure we never use it.
-      set dummy $CC
-      shift
-      if test $# -gt 0; then
-	# We chose a different compiler from the bogus one.
-	# However, it has the same name, so the bogon will be chosen
-	# first if we set CC to just the name; use the full file name.
-	shift
-	set dummy "$dir/cc" "$@"
-	shift
-	CC="$@"
-      fi
-    fi
-
-    if test -n "$CC"; then
-      echo "$ac_t$CC" 1>&6
-    else
-      echo "$ac_t"no 1>&6
-    fi
-
-    if test -z "$CC"; then
-      echo "$progname: error: no acceptable cc found in \$PATH" 1>&2
-      exit 1
-    fi
-  fi
-
-  # Now see if the compiler is really GCC.
-  with_gcc=no
-  echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6
-  echo "$progname:581: checking whether we are using GNU C" >&5
-
-  $rm conftest.c
-  cat > conftest.c <<EOF
-#ifdef __GNUC__
-  yes;
-#endif
-EOF
-  if { ac_try='${CC-cc} -E conftest.c'; { (eval echo $progname:589: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
-    with_gcc=yes
-  fi
-  $rm conftest.c
-  echo "$ac_t$with_gcc" 1>&6
-fi
-
-# Allow CC to be a program name with arguments.
-set dummy $CC
-compiler="$2"
-
-echo $ac_n "checking for object suffix... $ac_c" 1>&6
-$rm conftest*
-echo 'int i = 1;' > conftest.c
-echo "$progname:603: checking for object suffix" >& 5
-if { (eval echo $progname:604: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then
-  # Append any warnings to the config.log.
-  cat conftest.err 1>&5
-
-  for ac_file in conftest.*; do
-    case $ac_file in
-    *.c) ;;
-    *) objext=`echo $ac_file | sed -e s/conftest.//` ;;
-    esac
-  done
-else
-  cat conftest.err 1>&5
-  echo "$progname: failed program was:" >&5
-  cat conftest.c >&5
-fi
-$rm conftest*
-echo "$ac_t$objext" 1>&6
-
-echo $ac_n "checking for executable suffix... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_cv_exeext="no"
-  $rm conftest*
-  echo 'main () { return 0; }' > conftest.c
-  echo "$progname:629: checking for executable suffix" >& 5
-  if { (eval echo $progname:630: \"$ac_link\") 1>&5; (eval $ac_link) 2>conftest.err; }; then
-    # Append any warnings to the config.log.
-    cat conftest.err 1>&5
-
-    for ac_file in conftest.*; do
-      case $ac_file in
-      *.c | *.err | *.$objext ) ;;
-      *) ac_cv_exeext=.`echo $ac_file | sed -e s/conftest.//` ;;
-      esac
-    done
-  else
-    cat conftest.err 1>&5
-    echo "$progname: failed program was:" >&5
-    cat conftest.c >&5
-  fi
-  $rm conftest*
-fi
-if test "X$ac_cv_exeext" = Xno; then
-  exeext=""
-else
-  exeext="$ac_cv_exeext"
-fi
-echo "$ac_t$ac_cv_exeext" 1>&6
-
-echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6
-pic_flag=
-special_shlib_compile_flags=
-wl=
-link_static_flag=
-no_builtin_flag=
-
-if test "$with_gcc" = yes; then
-  wl='-Wl,'
-  link_static_flag='-static'
-
-  case "$host_os" in
-  beos* | irix5* | irix6* | osf3* | osf4* | osf5*)
-    # PIC is the default for these OSes.
-    ;;
-  aix*)
-    # Below there is a dirty hack to force normal static linking with -ldl
-    # The problem is because libdl dynamically linked with both libc and
-    # libC (AIX C++ library), which obviously doesn't included in libraries
-    # list by gcc. This cause undefined symbols with -static flags.
-    # This hack allows C programs to be linked with "-static -ldl", but
-    # we not sure about C++ programs.
-    link_static_flag="$link_static_flag ${wl}-lC"
-    ;;
-  cygwin* | mingw* | os2*)
-    # We can build DLLs from non-PIC.
-    ;;
-  amigaos*)
-    # FIXME: we need at least 68020 code to build shared libraries, but
-    # adding the `-m68020' flag to GCC prevents building anything better,
-    # like `-m68040'.
-    pic_flag='-m68020 -resident32 -malways-restore-a4'
-    ;;
-  sysv4*MP*)
-    if test -d /usr/nec; then
-       pic_flag=-Kconform_pic
-    fi
-    ;;
-  *)
-    pic_flag='-fPIC'
-    ;;
-  esac
-else
-  # PORTME Check for PIC flags for the system compiler.
-  case "$host_os" in
-  aix3* | aix4*)
-    # All AIX code is PIC.
-    link_static_flag='-bnso -bI:/lib/syscalls.exp'
-    ;;
-
-  hpux9* | hpux10* | hpux11*)
-    # Is there a better link_static_flag that works with the bundled CC?
-    wl='-Wl,'
-    link_static_flag="${wl}-a ${wl}archive"
-    pic_flag='+Z'
-    ;;
-
-  irix5* | irix6*)
-    wl='-Wl,'
-    link_static_flag='-non_shared'
-    # PIC (with -KPIC) is the default.
-    ;;
-
-  cygwin* | mingw* | os2*)
-    # We can build DLLs from non-PIC.
-    ;;
-
-  osf3* | osf4* | osf5*)
-    # All OSF/1 code is PIC.
-    wl='-Wl,'
-    link_static_flag='-non_shared'
-    ;;
-
-  sco3.2v5*)
-    pic_flag='-Kpic'
-    link_static_flag='-dn'
-    special_shlib_compile_flags='-belf'
-    ;;
-
-  solaris*)
-    pic_flag='-KPIC'
-    link_static_flag='-Bstatic'
-    wl='-Wl,'
-    ;;
-
-  sunos4*)
-    pic_flag='-PIC'
-    link_static_flag='-Bstatic'
-    wl='-Qoption ld '
-    ;;
-
-  sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-    pic_flag='-KPIC'
-    link_static_flag='-Bstatic'
-    wl='-Wl,'
-    ;;
-
-  uts4*)
-    pic_flag='-pic'
-    link_static_flag='-Bstatic'
-    ;;
-  sysv4*MP*)
-    if test -d /usr/nec ;then
-      pic_flag='-Kconform_pic'
-      link_static_flag='-Bstatic'
-    fi
-    ;;
-  *)
-    can_build_shared=no
-    ;;
-  esac
-fi
-
-if test -n "$pic_flag"; then
-  echo "$ac_t$pic_flag" 1>&6
-
-  # Check to make sure the pic_flag actually works.
-  echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6
-  $rm conftest*
-  echo "int some_variable = 0;" > conftest.c
-  save_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS $pic_flag -DPIC"
-  echo "$progname:776: checking if $compiler PIC flag $pic_flag works" >&5
-  if { (eval echo $progname:777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then
-    # Append any warnings to the config.log.
-    cat conftest.err 1>&5
-    
-    case "$host_os" in
-    hpux9* | hpux10* | hpux11*)
-      # On HP-UX, both CC and GCC only warn that PIC is supported... then they
-      # create non-PIC objects.  So, if there were any warnings, we assume that
-      # PIC is not supported.
-      if test -s conftest.err; then
-	echo "$ac_t"no 1>&6
-	can_build_shared=no
-	pic_flag=
-      else
-	echo "$ac_t"yes 1>&6
-	pic_flag=" $pic_flag"
-      fi
-      ;;
-    *)
-      echo "$ac_t"yes 1>&6
-      pic_flag=" $pic_flag"
-      ;;
-    esac
-  else
-    # Append any errors to the config.log.
-    cat conftest.err 1>&5
-    can_build_shared=no
-    pic_flag=
-    echo "$ac_t"no 1>&6
-  fi
-  CFLAGS="$save_CFLAGS"
-  $rm conftest*
-else
-  echo "$ac_t"none 1>&6
-fi
-
-# Check to see if options -o and -c are simultaneously supported by compiler
-echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6
-$rm -r conftest 2>/dev/null
-mkdir conftest
-cd conftest
-$rm conftest*
-echo "int some_variable = 0;" > conftest.c
-mkdir out
-# According to Tom Tromey, Ian Lance Taylor reported there are C compilers
-# that will create temporary files in the current directory regardless of
-# the output directory.  Thus, making CWD read-only will cause this test
-# to fail, enabling locking or at least warning the user not to do parallel
-# builds.
-chmod -w .
-save_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -o out/conftest2.o"
-echo "$progname:829: checking if $compiler supports -c -o file.o" >&5
-if { (eval echo $progname:830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.o; then
-
-  # The compiler can only warn and ignore the option if not recognized
-  # So say no if there are warnings
-    if test -s out/conftest.err; then
-      echo "$ac_t"no 1>&6
-      compiler_c_o=no
-    else
-      echo "$ac_t"yes 1>&6
-      compiler_c_o=yes
-    fi
-else
-  # Append any errors to the config.log.
-  cat out/conftest.err 1>&5
-  compiler_c_o=no
-  echo "$ac_t"no 1>&6
-fi
-CFLAGS="$save_CFLAGS"
-chmod u+w .
-$rm conftest* out/*
-rmdir out
-cd ..
-rmdir conftest
-$rm -r conftest 2>/dev/null
-
-if test x"$compiler_c_o" = x"yes"; then
-  # Check to see if we can write to a .lo
-  echo $ac_n "checking if $compiler supports -c -o file.lo... $ac_c" 1>&6
-  $rm conftest*
-  echo "int some_variable = 0;" > conftest.c
-  save_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -c -o conftest.lo"
-  echo "$progname:862: checking if $compiler supports -c -o file.lo" >&5
-if { (eval echo $progname:863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then
-
-    # The compiler can only warn and ignore the option if not recognized
-    # So say no if there are warnings
-      if test -s conftest.err; then
-	echo "$ac_t"no 1>&6
-	compiler_o_lo=no
-      else
-	echo "$ac_t"yes 1>&6
-	compiler_o_lo=yes
-      fi
-  else
-    # Append any errors to the config.log.
-    cat conftest.err 1>&5
-    compiler_o_lo=no
-    echo "$ac_t"no 1>&6
-  fi
-  CFLAGS="$save_CFLAGS"
-  $rm conftest*
-else
-  compiler_o_lo=no
-fi
-
-# Check to see if we can do hard links to lock some files if needed
-hard_links="nottested"
-if test "$compiler_c_o" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  echo $ac_n "checking if we can lock with hard links... $ac_c" 1>&6
-  hard_links=yes
-  $rm conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  echo "$ac_t$hard_links" 1>&6
-  $rm conftest*
-  if test "$hard_links" = no; then
-    echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
-
-if test "$with_gcc" = yes; then
-  # Check to see if options -fno-rtti -fno-exceptions are supported by compiler
-  echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions ... $ac_c" 1>&6
-  $rm conftest*
-  echo "int some_variable = 0;" > conftest.c
-  save_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c"
-  echo "$progname:914: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-  if { (eval echo $progname:915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then
-
-    # The compiler can only warn and ignore the option if not recognized
-    # So say no if there are warnings
-      if test -s conftest.err; then
-	echo "$ac_t"no 1>&6
-	compiler_rtti_exceptions=no
-      else
-	echo "$ac_t"yes 1>&6
-	compiler_rtti_exceptions=yes
-      fi
-  else
-    # Append any errors to the config.log.
-    cat conftest.err 1>&5
-    compiler_rtti_exceptions=no
-    echo "$ac_t"no 1>&6
-  fi
-  CFLAGS="$save_CFLAGS"
-  $rm conftest*
-
-  if test "$compiler_rtti_exceptions" = "yes"; then
-    no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions'
-  else
-    no_builtin_flag=' -fno-builtin'
-  fi
-  
-fi
-
-# Check for any special shared library compilation flags.
-if test -n "$special_shlib_compile_flags"; then
-  echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2
-  if echo "$old_CC $old_CFLAGS " | egrep -e "[ 	]$special_shlib_compile_flags[ 	]" >/dev/null; then :
-  else
-    echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2
-    can_build_shared=no
-  fi
-fi
-
-echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6
-$rm conftest*
-echo 'main(){return(0);}' > conftest.c
-save_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS $link_static_flag"
-echo "$progname:958: checking if $compiler static flag $link_static_flag works" >&5
-if { (eval echo $progname:959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  echo "$ac_t$link_static_flag" 1>&6
-else
-  echo "$ac_t"none 1>&6
-  link_static_flag=
-fi
-LDFLAGS="$save_LDFLAGS"
-$rm conftest*
-
-if test -z "$LN_S"; then
-  # Check to see if we can use ln -s, or we need hard links.
-  echo $ac_n "checking whether ln -s works... $ac_c" 1>&6
-  $rm conftest.dat
-  if ln -s X conftest.dat 2>/dev/null; then
-    $rm conftest.dat
-    LN_S="ln -s"
-  else
-    LN_S=ln
-  fi
-  if test "$LN_S" = "ln -s"; then
-    echo "$ac_t"yes 1>&6
-  else
-    echo "$ac_t"no 1>&6
-  fi
-fi
-
-# Make sure LD is an absolute path.
-if test -z "$LD"; then
-  ac_prog=ld
-  if test "$with_gcc" = yes; then
-    # Check if gcc -print-prog-name=ld gives a path.
-    echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6
-    echo "$progname:991: checking for ld used by GCC" >&5
-    ac_prog=`($CC -print-prog-name=ld) 2>&5`
-    case "$ac_prog" in
-    # Accept absolute paths.
-    [\\/]* | [A-Za-z]:[\\/]*)
-      re_direlt='/[^/][^/]*/\.\./'
-      # Canonicalize the path of ld
-      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
-      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
-      done
-      test -z "$LD" && LD="$ac_prog"
-      ;;
-    "")
-      # If it fails, then pretend we are not using GCC.
-      ac_prog=ld
-      ;;
-    *)
-      # If it is relative, then search for the first ld in PATH.
-      with_gnu_ld=unknown
-      ;;
-    esac
-  elif test "$with_gnu_ld" = yes; then
-    echo $ac_n "checking for GNU ld... $ac_c" 1>&6
-    echo "$progname:1015: checking for GNU ld" >&5
-  else
-    echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-    echo "$progname:1018: checking for non-GNU ld" >&5
-  fi
-
-  if test -z "$LD"; then
-    IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
-    for ac_dir in $PATH; do
-      test -z "$ac_dir" && ac_dir=.
-      if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-	LD="$ac_dir/$ac_prog"
-	# Check to see if the program is GNU ld.  I'd rather use --version,
-	# but apparently some GNU ld's only accept -v.
-	# Break only if it was the GNU/non-GNU ld that we prefer.
-	if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
-	  test "$with_gnu_ld" != no && break
-	else
-	  test "$with_gnu_ld" != yes && break
-	fi
-      fi
-    done
-    IFS="$ac_save_ifs"
-  fi
-
-  if test -n "$LD"; then
-    echo "$ac_t$LD" 1>&6
-  else
-    echo "$ac_t"no 1>&6
-  fi
-
-  if test -z "$LD"; then
-    echo "$progname: error: no acceptable ld found in \$PATH" 1>&2
-    exit 1
-  fi
-fi
-
-# Check to see if it really is or is not GNU ld.
-echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6
-# I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
-  with_gnu_ld=yes
-else
-  with_gnu_ld=no
-fi
-echo "$ac_t$with_gnu_ld" 1>&6
-
-# See if the linker supports building shared libraries.
-echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6
-
-allow_undefined_flag=
-no_undefined_flag=
-need_lib_prefix=unknown
-need_version=unknown
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-archive_cmds=
-archive_expsym_cmds=
-old_archive_from_new_cmds=
-export_dynamic_flag_spec=
-whole_archive_flag_spec=
-thread_safe_flag_spec=
-hardcode_libdir_flag_spec=
-hardcode_libdir_separator=
-hardcode_direct=no
-hardcode_minus_L=no
-hardcode_shlibpath_var=unsupported
-runpath_var=
-always_export_symbols=no
-export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols'
-# include_expsyms should be a list of space-separated symbols to be *always*
-# included in the symbol list
-include_expsyms=
-# exclude_expsyms can be an egrep regular expression of symbols to exclude
-# it will be wrapped by ` (' and `)$', so one must not match beginning or
-# end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-# as well as any symbol that contains `d'.
-exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
-# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-# platforms (ab)use it in PIC code, but their linkers get confused if
-# the symbol is explicitly referenced.  Since portable code cannot
-# rely on this symbol name, it's probably fine to never include it in
-# preloaded symbol tables.
-
-case "$host_os" in
-cygwin* | mingw*)
-  # FIXME: the MSVC++ port hasn't been tested in a loooong time
-  # When not using gcc, we currently assume that we are using
-  # Microsoft Visual C++.
-  if test "$with_gcc" != yes; then
-    with_gnu_ld=no
-  fi
-  ;;
-
-esac
-
-ld_shlibs=yes
-if test "$with_gnu_ld" = yes; then
-  # If archive_cmds runs LD, not CC, wlarc should be empty
-  wlarc='${wl}'
-
-  # See if GNU ld supports shared libraries.
-  case "$host_os" in
-  aix3* | aix4*)
-    # On AIX, the GNU linker is very broken
-    ld_shlibs=no
-    cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
-    ;;
-
-  amigaos*)
-    archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)'
-    hardcode_libdir_flag_spec='-L$libdir'
-    hardcode_minus_L=yes
-
-    # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
-    # that the semantics of dynamic libraries on AmigaOS, at least up
-    # to version 4, is to share data among multiple programs linked
-    # with the same dynamic library.  Since this doesn't match the
-    # behavior of shared libraries on other platforms, we can use
-    # them.
-    ld_shlibs=no
-    ;;
-
-  beos*)
-    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
-      allow_undefined_flag=unsupported
-      # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-      # support --undefined.  This deserves some investigation.  FIXME
-      archive_cmds='$CC -nostart $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
-    else
-      ld_shlibs=no
-    fi
-    ;;
-
-  cygwin* | mingw*)
-    # hardcode_libdir_flag_spec is actually meaningless, as there is
-    # no search path for DLLs.
-    hardcode_libdir_flag_spec='-L$libdir'
-    allow_undefined_flag=unsupported
-    always_export_symbols=yes
-
-    # Extract the symbol export list from an `--export-all' def file,
-    # then regenerate the def file from the symbol export list, so that
-    # the compiled dll only exports the symbol export list.
-    export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
-      test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~
-      $DLLTOOL --export-all --exclude-symbols DllMain at 12,_cygwin_dll_entry at 12,_cygwin_noncygwin_dll_entry at 12 --output-def $objdir/$soname-def  $objdir/$soname-ltdll.$objext $libobjs $convenience~
-      sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]* ; *//" < $objdir/$soname-def > $export_symbols'
-
-    archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~
-      _lt_hint=1;
-      for symbol in `cat $export_symbols`; do
-	echo "	\$symbol @ \$_lt_hint ; " >> $objdir/$soname-def;
-	_lt_hint=`expr 1 + \$_lt_hint`;
-      done~
-      test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
-      test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~
-      $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry at 12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
-      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain at 12,_cygwin_dll_entry at 12,_cygwin_noncygwin_dll_entry at 12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~
-      $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry at 12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
-      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain at 12,_cygwin_dll_entry at 12,_cygwin_noncygwin_dll_entry at 12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~
-      $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry at 12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts'
-
-      old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a' 
-    ;;
-
-  netbsd*)
-    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
-      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-    else
-      archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib'
-      # can we support soname and/or expsyms with a.out? -oliva
-    fi
-    ;;
-
-  solaris* | sysv5*)
-    if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
-      ld_shlibs=no
-      cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
-    elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
-      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
-      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-    else
-      ld_shlibs=no
-    fi
-    ;;      
-
-  sunos4*)
-    archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linkopts'
-    wlarc=
-    hardcode_direct=yes
-    hardcode_shlibpath_var=no
-    ;;
-
-  *)
-    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
-      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
-      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-    else
-      ld_shlibs=no
-    fi
-    ;;
-  esac
-
-  if test "$ld_shlibs" = yes; then
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
-    case $host_os in
-    cygwin* | mingw*)
-      # dlltool doesn't understand --whole-archive et. al.
-      whole_archive_flag_spec=
-      ;;
-    *)
-      # ancient GNU ld didn't support --whole-archive et. al.
-      if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then
-        whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-        whole_archive_flag_spec=
-      fi
-      ;;
-    esac
-  fi
-else
-  # PORTME fill in a description of your system's linker (not GNU ld)
-  case "$host_os" in
-  aix3*)
-    allow_undefined_flag=unsupported
-    always_export_symbols=yes
-    archive_expsym_cmds='$LD -o $objdir/$soname $libobjs $deplibs $linkopts -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname'
-    # Note: this linker hardcodes the directories in LIBPATH if there
-    # are no directories specified by -L.
-    hardcode_minus_L=yes
-    if test "$with_gcc" = yes && test -z "$link_static_flag"; then
-      # Neither direct hardcoding nor static linking is supported with a
-      # broken collect2.
-      hardcode_direct=unsupported
-    fi
-    ;;
-
-  aix4*)
-    hardcode_libdir_flag_spec='${wl}-b ${wl}nolibpath ${wl}-b ${wl}libpath:$libdir:/usr/lib:/lib'
-    hardcode_libdir_separator=':'
-    if test "$with_gcc" = yes; then
-      collect2name=`${CC} -print-prog-name=collect2`
-      if test -f "$collect2name" && \
-	 strings "$collect2name" | grep resolve_lib_name >/dev/null
-      then
-	# We have reworked collect2
-	hardcode_direct=yes
-      else
-	# We have old collect2
-	hardcode_direct=unsupported
-	# It fails to find uninstalled libraries when the uninstalled
-	# path is not listed in the libpath.  Setting hardcode_minus_L
-	# to unsupported forces relinking
-	hardcode_minus_L=yes
-	hardcode_libdir_flag_spec='-L$libdir'
-	hardcode_libdir_separator=
-      fi
-      shared_flag='-shared'
-    else
-      shared_flag='${wl}-bM:SRE'
-      hardcode_direct=yes
-    fi
-    allow_undefined_flag=' ${wl}-berok'
-    archive_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bexpall ${wl}-bnoentry${allow_undefined_flag}'
-    archive_expsym_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}'
-    case "$host_os" in aix4.[01]|aix4.[01].*)
-      # According to Greg Wooledge, -bexpall is only supported from AIX 4.2 on
-      always_export_symbols=yes ;;
-    esac
-   ;;
-
-  amigaos*)
-    archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)'
-    hardcode_libdir_flag_spec='-L$libdir'
-    hardcode_minus_L=yes
-    # see comment about different semantics on the GNU ld section
-    ld_shlibs=no
-    ;;
-
-  cygwin* | mingw*)
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    # hardcode_libdir_flag_spec is actually meaningless, as there is
-    # no search path for DLLs.
-    hardcode_libdir_flag_spec=' '
-    allow_undefined_flag=unsupported
-    # Tell ltmain to make .lib files, not .a files.
-    libext=lib
-    # FIXME: Setting linknames here is a bad hack.
-    archive_cmds='$CC -o $lib $libobjs $linkopts `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames='
-    # The linker will automatically build a .lib file if we build a DLL.
-    old_archive_from_new_cmds='true'
-    # FIXME: Should let the user specify the lib program.
-    old_archive_cmds='lib /OUT:$oldlib$oldobjs'
-    fix_srcfile_path='`cygpath -w $srcfile`'
-    ;;
-
-  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
-  # extra space).
-  freebsd2.2*)
-    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts /usr/lib/c++rt0.o'
-    hardcode_libdir_flag_spec='-R$libdir'
-    hardcode_direct=yes
-    hardcode_shlibpath_var=no
-    ;;
-
-  # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-  freebsd2*)
-    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
-    hardcode_direct=yes
-    hardcode_minus_L=yes
-    hardcode_shlibpath_var=no
-    ;;
-
-  # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-  freebsd*)
-    archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linkopts'
-    hardcode_libdir_flag_spec='-R$libdir'
-    hardcode_direct=yes
-    hardcode_shlibpath_var=no
-    ;;
-
-  hpux9* | hpux10* | hpux11*)
-    case "$host_os" in
-    hpux9*) archive_cmds='$rm $objdir/$soname~$LD -b +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linkopts~test $objdir/$soname = $lib || mv $objdir/$soname $lib' ;;
-    *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linkopts' ;;
-    esac
-    hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-    hardcode_libdir_separator=:
-    hardcode_direct=yes
-    hardcode_minus_L=yes # Not in the search PATH, but as the default
-			 # location of the library.
-    export_dynamic_flag_spec='${wl}-E'
-    ;;
-
-  irix5* | irix6*)
-    if test "$with_gcc" = yes; then
-      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
-    else
-      archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
-    fi
-    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-    hardcode_libdir_separator=:
-    ;;
-
-  netbsd*)
-    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'  # a.out
-    else
-      archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linkopts'      # ELF
-    fi
-    hardcode_libdir_flag_spec='${wl}-R$libdir'
-    hardcode_direct=yes
-    hardcode_shlibpath_var=no
-    ;;
-
-  openbsd*)
-    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
-    hardcode_libdir_flag_spec='-R$libdir'
-    hardcode_direct=yes
-    hardcode_shlibpath_var=no
-    ;;
-
-  os2*)
-    hardcode_libdir_flag_spec='-L$libdir'
-    hardcode_minus_L=yes
-    allow_undefined_flag=unsupported
-    archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def'
-    old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def'
-    ;;
-
-  osf3*)
-    if test "$with_gcc" = yes; then
-      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
-    else
-      allow_undefined_flag=' -expect_unresolved \*'
-      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
-    fi
-    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-    hardcode_libdir_separator=:
-    ;;
-
-  osf4* | osf5*)  # As osf3* with the addition of the -msym flag
-    if test "$with_gcc" = yes; then
-      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
-    else
-      allow_undefined_flag=' -expect_unresolved \*'
-      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
-    fi
-    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-    hardcode_libdir_separator=:
-    ;;
-
-  sco3.2v5*)
-    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
-    hardcode_shlibpath_var=no
-    runpath_var=LD_RUN_PATH
-    hardcode_runpath_var=yes
-    ;;
-
-  solaris*)
-    no_undefined_flag=' -z text'
-    # $CC -shared without GNU ld will not create a library from C++
-    # object files and a static libstdc++, better avoid it by now
-    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
-    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
-    hardcode_libdir_flag_spec='-R$libdir'
-    hardcode_shlibpath_var=no
-    case "$host_os" in
-    solaris2.[0-5] | solaris2.[0-5].*) ;;
-    *) # Supported since Solaris 2.6 (maybe 2.5.1?)
-      whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
-    esac
-    ;;
-
-  sunos4*)
-    archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts'
-    hardcode_libdir_flag_spec='-L$libdir'
-    hardcode_direct=yes
-    hardcode_minus_L=yes
-    hardcode_shlibpath_var=no
-    ;;
-
-  sysv4)
-    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
-    runpath_var='LD_RUN_PATH'
-    hardcode_shlibpath_var=no
-    hardcode_direct=no #Motorola manual says yes, but my tests say they lie 
-    ;;  
-
-  sysv4.3*)
-    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
-    hardcode_shlibpath_var=no
-    export_dynamic_flag_spec='-Bexport'
-    ;;
-
-  sysv5*)
-    no_undefined_flag=' -z text'
-    # $CC -shared without GNU ld will not create a library from C++
-    # object files and a static libstdc++, better avoid it by now
-    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
-    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
-    hardcode_libdir_flag_spec=
-    hardcode_shlibpath_var=no
-    runpath_var='LD_RUN_PATH'
-    ;;
-
-  uts4*)
-    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
-    hardcode_libdir_flag_spec='-L$libdir'
-    hardcode_shlibpath_var=no
-    ;;
-
-  dgux*)
-    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
-    hardcode_libdir_flag_spec='-L$libdir'
-    hardcode_shlibpath_var=no
-    ;;
-
-  sysv4*MP*)
-    if test -d /usr/nec; then
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
-      hardcode_shlibpath_var=no
-      runpath_var=LD_RUN_PATH
-      hardcode_runpath_var=yes
-      ld_shlibs=yes
-    fi
-    ;;
-
-  sysv4.2uw2*)
-    archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts'
-    hardcode_direct=yes
-    hardcode_minus_L=no
-    hardcode_shlibpath_var=no
-    hardcode_runpath_var=yes
-    runpath_var=LD_RUN_PATH
-    ;;
-
-  unixware7*)
-    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
-    runpath_var='LD_RUN_PATH'
-    hardcode_shlibpath_var=no
-    ;;
-
-  *)
-    ld_shlibs=no
-    ;;
-  esac
-fi
-echo "$ac_t$ld_shlibs" 1>&6
-test "$ld_shlibs" = no && can_build_shared=no
-
-if test -z "$NM"; then
-  echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6
-  case "$NM" in
-  [\\/]* | [A-Za-z]:[\\/]*) ;; # Let the user override the test with a path.
-  *)
-    IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
-    for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do
-      test -z "$ac_dir" && ac_dir=.
-      if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
-	  NM="$ac_dir/nm -B"
-	  break
-	elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
-	  NM="$ac_dir/nm -p"
-	  break
-	else
-	  NM=${NM="$ac_dir/nm"} # keep the first match, but
-	  continue # so that we can try to find one that supports BSD flags
-	fi
-      fi
-    done
-    IFS="$ac_save_ifs"
-    test -z "$NM" && NM=nm
-    ;;
-  esac
-  echo "$ac_t$NM" 1>&6
-fi
-
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6
-
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[BCDEGRST]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
-
-# Transform the above into a raw symbol and a C symbol.
-symxfrm='\1 \2\3 \3'
-
-# Transform an extracted symbol line into a proper C declaration
-global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
-
-# Define system-specific variables.
-case "$host_os" in
-aix*)
-  symcode='[BCDT]'
-  ;;
-cygwin* | mingw*)
-  symcode='[ABCDGISTW]'
-  ;;
-hpux*) # Its linker distinguishes data from code symbols
-  global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'"
-  ;;
-irix*)
-  symcode='[BCDEGRST]'
-  ;;
-solaris*)
-  symcode='[BDT]'
-  ;;
-sysv4)
-  symcode='[DFNSTU]'
-  ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
-  symcode='[ABCDGISTW]'
-fi
-
-# Try without a prefix undercore, then with it.
-for ac_symprfx in "" "_"; do
-
-  # Write the raw and C identifiers.
-  global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode\)[ 	][ 	]*\($ac_symprfx\)$sympat$/$symxfrm/p'"
-
-  # Check to see that the pipe works correctly.
-  pipe_works=no
-  $rm conftest*
-  cat > conftest.c <<EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(){}
-#ifdef __cplusplus
-}
-#endif
-main(){nm_test_var='a';nm_test_func();return(0);}
-EOF
-
-  echo "$progname:1635: checking if global_symbol_pipe works" >&5
-  if { (eval echo $progname:1636: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then
-    # Now try to grab the symbols.
-    nlist=conftest.nm
-    if { echo "$progname:1639: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then
-
-      # Try sorting and uniquifying the output.
-      if sort "$nlist" | uniq > "$nlist"T; then
-	mv -f "$nlist"T "$nlist"
-      else
-	rm -f "$nlist"T
-      fi
-
-      # Make sure that we snagged all the symbols we need.
-      if egrep ' nm_test_var$' "$nlist" >/dev/null; then
-	if egrep ' nm_test_func$' "$nlist" >/dev/null; then
-	  cat <<EOF > conftest.c
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-EOF
-	  # Now generate the symbol file.
-	  eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c'
-
-	  cat <<EOF >> conftest.c
-#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
-#else
-# define lt_ptr_t char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-const struct {
-  const char *name;
-  lt_ptr_t address;
-}
-lt_preloaded_symbols[] =
-{
-EOF
-	  sed 's/^. \(.*\) \(.*\)$/  {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c
-	  cat <<\EOF >> conftest.c
-  {0, (lt_ptr_t) 0}
-};
-
-#ifdef __cplusplus
-}
-#endif
-EOF
-	  # Now try linking the two files.
-	  mv conftest.$objext conftstm.$objext
-	  save_LIBS="$LIBS"
-	  save_CFLAGS="$CFLAGS"
-	  LIBS="conftstm.$objext"
-	  CFLAGS="$CFLAGS$no_builtin_flag"
-	  if { (eval echo $progname:1691: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-	    pipe_works=yes
-	  else
-	    echo "$progname: failed program was:" >&5
-	    cat conftest.c >&5
-	  fi
-	  LIBS="$save_LIBS"
-	else
-	  echo "cannot find nm_test_func in $nlist" >&5
-	fi
-      else
-	echo "cannot find nm_test_var in $nlist" >&5
-      fi
-    else
-      echo "cannot run $global_symbol_pipe" >&5
-    fi
-  else
-    echo "$progname: failed program was:" >&5
-    cat conftest.c >&5
-  fi
-  $rm conftest* conftst*
-
-  # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
-    break
-  else
-    global_symbol_pipe=
-  fi
-done
-if test "$pipe_works" = yes; then
-  echo "${ac_t}ok" 1>&6
-else
-  echo "${ac_t}failed" 1>&6
-fi
-
-if test -z "$global_symbol_pipe"; then
-  global_symbol_to_cdecl=
-fi
-
-# Check hardcoding attributes.
-echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6
-hardcode_action=
-if test -n "$hardcode_libdir_flag_spec" || \
-   test -n "$runpath_var"; then
-
-  # We can hardcode non-existant directories.
-  if test "$hardcode_direct" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$hardcode_shlibpath_var" != no &&
-     test "$hardcode_minus_L" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action=unsupported
-fi
-echo "$ac_t$hardcode_action" 1>&6
-
-
-reload_flag=
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6
-# PORTME Some linkers may need a different reload flag.
-reload_flag='-r'
-echo "$ac_t$reload_flag" 1>&6
-test -n "$reload_flag" && reload_flag=" $reload_flag"
-
-# PORTME Fill in your ld.so characteristics
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-file_magic_cmd=
-file_magic_test_file=
-deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [regex]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given egrep regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6
-case "$host_os" in
-aix3*)
-  version_type=linux
-  library_names_spec='${libname}${release}.so$versuffix $libname.a'
-  shlibpath_var=LIBPATH
-
-  # AIX has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}.so$major'
-  ;;
-
-aix4*)
-  version_type=linux
-  # AIX has no versioning support, so currently we can not hardcode correct
-  # soname into executable. Probably we can add versioning support to
-  # collect2, so additional links can be useful in future.
-  # We preserve .a as extension for shared libraries though AIX4.2
-  # and later linker supports .so
-  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.a'
-  shlibpath_var=LIBPATH
-  deplibs_check_method=pass_all
-  ;;
-
-amigaos*)
-  library_names_spec='$libname.ixlibrary $libname.a'
-  # Create ${libname}_ixlibrary.a entries in /sys/libs.
-  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done'
-  ;;
-
-beos*)
-  library_names_spec='${libname}.so'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  deplibs_check_method=pass_all
-  lt_cv_dlopen="load_add_on"
-  lt_cv_dlopen_libs=
-  lt_cv_dlopen_self=yes
-  ;;
-
-bsdi4*)
-  version_type=linux
-  need_version=no
-  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
-  soname_spec='${libname}${release}.so$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
-  file_magic_cmd=/usr/bin/file
-  file_magic_test_file=/shlib/libc.so
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  export_dynamic_flag_spec=-rdynamic
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
-
-cygwin* | mingw*)
-  version_type=windows
-  need_version=no
-  need_lib_prefix=no
-  if test "$with_gcc" = yes; then
-    library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.a'
-  else
-    library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib'
-  fi
-  dynamic_linker='Win32 ld.exe'
-  deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
-  file_magic_cmd='${OBJDUMP} -f'
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  lt_cv_dlopen="LoadLibrary"
-  lt_cv_dlopen_libs=
-  ;;
-
-freebsd1*)
-  dynamic_linker=no
-  ;;
-  
-freebsd*)
-  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
-  version_type=freebsd-$objformat
-  case "$version_type" in
-    freebsd-elf*)
-      deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object'
-      file_magic_cmd=/usr/bin/file
-      file_magic_test_file=`echo /usr/lib/libc.so*`
-      library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      deplibs_check_method=unknown
-      library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case "$host_os" in
-  freebsd2* | freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  *) # from 3.2 on
-    shlibpath_overrides_runpath=no
-    ;;
-  esac
-  ;;
-
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so'
-  soname_spec='${libname}${release}.so$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  dynamic_linker="$host_os dld.sl"
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  shlibpath_var=SHLIB_PATH
-  shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-  library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl'
-  soname_spec='${libname}${release}.sl$major'
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
-  postinstall_cmds='chmod 555 $lib'
-  ;;
-
-irix5* | irix6*)
-  version_type=irix
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}.so.$major'
-  library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major ${libname}${release}.so $libname.so'
-  case "$host_os" in
-  irix5*)
-    libsuff= shlibsuff=
-    # this will be overridden with pass_all, but let us keep it just in case
-    deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1"
-    ;;
-  *)
-    case "$LD" in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  file_magic_cmd=/usr/bin/file
-  file_magic_test_file=`echo /lib${libsuff}/libc.so*`
-  deplibs_check_method='pass_all'
-  ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*)
-  dynamic_linker=no
-  ;;
-
-# This must be Linux ELF.
-linux-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
-  soname_spec='${libname}${release}.so$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
-  file_magic_cmd=/usr/bin/file
-  file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
-
-  if test -f /lib/ld.so.1; then
-    dynamic_linker='GNU ld.so'
-  else
-    # Only the GNU ld.so supports shared libraries on MkLinux.
-    case "$host_cpu" in
-    powerpc*) dynamic_linker=no ;;
-    *) dynamic_linker='Linux ld.so' ;;
-    esac
-  fi
-  ;;
-
-netbsd*)
-  version_type=sunos
-  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so'
-    soname_spec='${libname}${release}.so$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-openbsd*)
-  version_type=sunos
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-    need_version=no
-  fi
-  library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-os2*)
-  libname_spec='$name'
-  need_lib_prefix=no
-  library_names_spec='$libname.dll $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
-
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_version=no
-  soname_spec='${libname}${release}.so'
-  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
-  shlibpath_var=LD_LIBRARY_PATH
-  # this will be overridden with pass_all, but let us keep it just in case
-  deplibs_check_method='file_magic COFF format alpha shared library'
-  file_magic_cmd=/usr/bin/file
-  file_magic_test_file=/shlib/libc.so
-  deplibs_check_method='pass_all'
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
-
-sco3.2v5*)
-  version_type=osf
-  soname_spec='${libname}${release}.so$major'
-  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-solaris*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
-  soname_spec='${libname}${release}.so$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  deplibs_check_method="file_magic ELF [0-9][0-9]-bit [LM]SB dynamic lib"
-  file_magic_cmd=/usr/bin/file
-  file_magic_test_file=/lib/libc.so
-  ;;
-
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
-
-sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-  version_type=linux
-  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
-  soname_spec='${libname}${release}.so$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case "$host_vendor" in
-    ncr)
-      deplibs_check_method='pass_all'
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
-      file_magic_cmd=/usr/bin/file
-      file_magic_test_file=`echo /usr/lib/libc.so*`
-      ;;
-  esac
-  ;;
-
-uts4*)
-  version_type=linux
-  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
-  soname_spec='${libname}${release}.so$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-dgux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
-  soname_spec='${libname}${release}.so$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux
-    library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so'
-    soname_spec='$libname.so.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
-
-*)
-  dynamic_linker=no
-  ;;
-esac
-echo "$ac_t$dynamic_linker" 1>&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-# Report the final consequences.
-echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6
-
-# Only try to build win32 dlls if AC_LIBTOOL_WIN32_DLL was used in
-# configure.in, otherwise build static only libraries.
-case "$host_os" in
-cygwin* | mingw* | os2*)
-  if test x$can_build_shared = xyes; then
-    test x$enable_win32_dll = xno && can_build_shared=no
-    echo "checking if package supports dlls... $can_build_shared" 1>&6
-  fi
-;;
-esac
-
-if test -n "$file_magic_test_file" && test -n "$file_magic_cmd"; then
-  case "$deplibs_check_method" in
-  "file_magic "*)
-    file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
-    if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-       egrep "$file_magic_regex" > /dev/null; then
-      :
-    else
-      cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool at gnu.org
-
-EOF
-    fi ;;
-  esac
-fi
-
-echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&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
-  ;;
-
-aix4*)
-  test "$enable_shared" = yes && enable_static=no
-  ;;
-esac
-
-echo "$ac_t$enable_shared" 1>&6
-
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-
-echo "checking whether to build static libraries... $enable_static" 1>&6
-
-if test "$hardcode_action" = relink; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
-
-echo $ac_n "checking for objdir... $ac_c" 1>&6
-rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
-  objdir=.libs
-else
-  # MS-DOS does not allow filenames that begin with a dot.
-  objdir=_libs
-fi
-rmdir .libs 2>/dev/null
-echo "$ac_t$objdir" 1>&6
-
-if test "x$enable_dlopen" != xyes; then
-  enable_dlopen=unknown
-  enable_dlopen_self=unknown
-  enable_dlopen_self_static=unknown
-else
-if eval "test \"`echo '$''{'lt_cv_dlopen'+set}'`\" != set"; then
-  lt_cv_dlopen=no lt_cv_dlopen_libs=
-echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "$progname:2212: checking for dlopen in -ldl" >&5
-ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-ldl  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2220 "ltconfig"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dlopen();
-
-int main() {
-dlopen()
-; return 0; }
-EOF
-if { (eval echo $progname:2233: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "$progname: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "$progname:2252: checking for dlopen" >&5
-if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 2257 "ltconfig"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char dlopen(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dlopen();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_dlopen) || defined (__stub___dlopen)
-choke me
-#else
-dlopen();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo $progname:2282: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_func_dlopen=yes"
-else
-  echo "$progname: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func_dlopen=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="dlopen"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6
-echo "$progname:2299: checking for dld_link in -ldld" >&5
-ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-ldld  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2307 "ltconfig"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dld_link();
-
-int main() {
-dld_link()
-; return 0; }
-EOF
-if { (eval echo $progname:2320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "$progname: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for shl_load""... $ac_c" 1>&6
-echo "$progname:2339: checking for shl_load" >&5
-if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 2344 "ltconfig"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char shl_load(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char shl_load();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_shl_load) || defined (__stub___shl_load)
-choke me
-#else
-shl_load();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo $progname:2369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_func_shl_load=yes"
-else
-  echo "$progname: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func_shl_load=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="shl_load"
-else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
-echo "$progname:2387: checking for shl_load in -ldld" >&5
-ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-ldld  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2395 "ltconfig"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char shl_load();
-
-int main() {
-shl_load()
-; return 0; }
-EOF
-if { (eval echo $progname:2409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "$progname: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-
-fi
-
-    
-fi
-
-  
-fi
-
-
-fi
-
-fi
-
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  fi
-
-  case "$lt_cv_dlopen" in
-  dlopen)
-for ac_hdr in dlfcn.h; do
-ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "$progname:2452: checking for $ac_hdr" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 2457 "ltconfig"
-#include <$ac_hdr>
-int fnord = 0;
-EOF
-ac_try="$ac_compile >/dev/null 2>conftest.out"
-{ (eval echo $progname:2462: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
-else
-  echo "$ac_err" >&5
-  echo "$progname: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-done
-
-    if test "x$ac_cv_header_dlfcn_h" = xyes; then
-      CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-    fi
-    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-    LIBS="$lt_cv_dlopen_libs $LIBS"
-
-  echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6
-echo "$progname:2490: checking whether a program can dlopen itself" >&5
-if test "${lt_cv_dlopen_self+set}" = set; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test "$cross_compiling" = yes; then
-    lt_cv_dlopen_self=cross
-  else
-    cat > conftest.c <<EOF
-#line 2498 "ltconfig"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LTDL_GLOBAL	RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-#  define LTDL_GLOBAL	DL_GLOBAL
-# else
-#  define LTDL_GLOBAL	0
-# endif
-#endif
-
-/* We may have to define LTDL_LAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LTDL_LAZY_OR_NOW
-# ifdef RTLD_LAZY
-#  define LTDL_LAZY_OR_NOW	RTLD_LAZY
-# else
-#  ifdef DL_LAZY
-#   define LTDL_LAZY_OR_NOW	DL_LAZY
-#  else
-#   ifdef RTLD_NOW
-#    define LTDL_LAZY_OR_NOW	RTLD_NOW
-#   else
-#    ifdef DL_NOW
-#     define LTDL_LAZY_OR_NOW	DL_NOW
-#    else
-#     define LTDL_LAZY_OR_NOW	0
-#    endif
-#   endif
-#  endif
-# endif
-#endif
-
-fnord() { int i=42;}
-main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW);
-    if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
-	       if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } 
-
-EOF
-if { (eval echo $progname:2544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
-then
-  lt_cv_dlopen_self=yes
-else
-  echo "$progname: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  lt_cv_dlopen_self=no
-fi
-rm -fr conftest*
-fi
-
-fi
-
-echo "$ac_t""$lt_cv_dlopen_self" 1>&6
-
-  if test "$lt_cv_dlopen_self" = yes; then
-    LDFLAGS="$LDFLAGS $link_static_flag"
-  echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6
-echo "$progname:2563: checking whether a statically linked program can dlopen itself" >&5
-if test "${lt_cv_dlopen_self_static+set}" = set; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test "$cross_compiling" = yes; then
-    lt_cv_dlopen_self_static=cross
-  else
-    cat > conftest.c <<EOF
-#line 2571 "ltconfig"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LTDL_GLOBAL	RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-#  define LTDL_GLOBAL	DL_GLOBAL
-# else
-#  define LTDL_GLOBAL	0
-# endif
-#endif
-
-/* We may have to define LTDL_LAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LTDL_LAZY_OR_NOW
-# ifdef RTLD_LAZY
-#  define LTDL_LAZY_OR_NOW	RTLD_LAZY
-# else
-#  ifdef DL_LAZY
-#   define LTDL_LAZY_OR_NOW	DL_LAZY
-#  else
-#   ifdef RTLD_NOW
-#    define LTDL_LAZY_OR_NOW	RTLD_NOW
-#   else
-#    ifdef DL_NOW
-#     define LTDL_LAZY_OR_NOW	DL_NOW
-#    else
-#     define LTDL_LAZY_OR_NOW	0
-#    endif
-#   endif
-#  endif
-# endif
-#endif
-
-fnord() { int i=42;}
-main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW);
-    if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
-    if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } 
-
-EOF
-if { (eval echo $progname:2617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
-then
-  lt_cv_dlopen_self_static=yes
-else
-  echo "$progname: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  lt_cv_dlopen_self_static=no
-fi
-rm -fr conftest*
-fi
-
-fi
-
-echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6
-fi
-    ;;
-  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
-
-# Copy echo and quote the copy, instead of the original, because it is
-# used later.
-ltecho="$echo"
-if test "X$ltecho" = "X$CONFIG_SHELL $0 --fallback-echo"; then
-   ltecho="$CONFIG_SHELL \$0 --fallback-echo"
-fi
-LTSHELL="$SHELL"
-
-LTCONFIG_VERSION="$VERSION"
-
-# Only quote variables if we're using ltmain.sh.
-case "$ltmain" in
-*.sh)
-  # Now quote all the things that may contain metacharacters.
-  for var in ltecho old_CC old_CFLAGS old_CPPFLAGS \
-    old_LD old_LDFLAGS old_LIBS \
-    old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS \
-    AR CC LD LN_S NM LTSHELL LTCONFIG_VERSION \
-    reload_flag reload_cmds wl \
-    pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \
-    thread_safe_flag_spec whole_archive_flag_spec libname_spec \
-    library_names_spec soname_spec \
-    RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \
-    old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds postuninstall_cmds \
-    file_magic_cmd export_symbols_cmds deplibs_check_method allow_undefined_flag no_undefined_flag \
-    finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \
-    hardcode_libdir_flag_spec hardcode_libdir_separator  \
-    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do
-
-    case "$var" in
-    reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \
-    old_postinstall_cmds | old_postuninstall_cmds | \
-    export_symbols_cmds | archive_cmds | archive_expsym_cmds | \
-    postinstall_cmds | postuninstall_cmds | \
-    finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
-      # Double-quote double-evaled strings.
-      eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
-      ;;
-    *)
-      eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
-      ;;
-    esac
-  done
-
-  case "$ltecho" in
-  *'\$0 --fallback-echo"')
-    ltecho=`$echo "X$ltecho" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
-    ;;
-  esac
-
-  trap "$rm \"$ofile\"; exit 1" 1 2 15
-  echo "creating $ofile"
-  $rm "$ofile"
-  cat <<EOF > "$ofile"
-#! $SHELL
-
-# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
-# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh.
-#
-# Copyright (C) 1996-1999 Free Software Foundation, Inc.
-# Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
-#
-# 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 of the License, 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, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# 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.
-
-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="sed -e s/^X//"
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
-
-### BEGIN LIBTOOL CONFIG
-EOF
-  cfgfile="$ofile"
-  ;;
-
-*)
-  # Double-quote the variables that need it (for aesthetics).
-  for var in old_CC old_CFLAGS old_CPPFLAGS \
-    old_LD old_LDFLAGS old_LIBS \
-    old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS; do
-    eval "$var=\\\"\$var\\\""
-  done
-
-  # Just create a config file.
-  cfgfile="$ofile.cfg"
-  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
-  echo "creating $cfgfile"
-  $rm "$cfgfile"
-  cat <<EOF > "$cfgfile"
-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Libtool configuration file.
-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
-EOF
-  ;;
-esac
-
-cat <<EOF >> "$cfgfile"
-# Libtool was configured as follows, on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# CC=$old_CC CFLAGS=$old_CFLAGS CPPFLAGS=$old_CPPFLAGS \\
-# LD=$old_LD LDFLAGS=$old_LDFLAGS LIBS=$old_LIBS \\
-# NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\
-# DLLTOOL=$old_DLLTOOL OBJDUMP=$old_OBJDUMP AS=$old_AS \\
-#   $0$ltconfig_args
-#
-# Compiler and other test output produced by $progname, useful for
-# debugging $progname, is in ./config.log if it exists.
-
-# The version of $progname that generated this script.
-LTCONFIG_VERSION=$LTCONFIG_VERSION
-
-# Shell to use when invoking shell scripts.
-SHELL=$LTSHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-
-# An echo program that does not interpret backslashes.
-echo=$ltecho
-
-# The archiver.
-AR=$AR
-
-# The default C compiler.
-CC=$CC
-
-# The linker used to build libraries.
-LD=$LD
-
-# Whether we need hard or soft links.
-LN_S=$LN_S
-
-# A BSD-compatible nm program.
-NM=$NM
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$reload_flag
-reload_cmds=$reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$wl
-
-# Object file suffix (normally "o").
-objext="$objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$pic_flag
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$compiler_c_o
-
-# Can we write directly to a .lo ?
-compiler_o_lo=$compiler_o_lo
-
-# Must we lock files when doing compilation ?
-need_locks=$need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$link_static_flag
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$no_builtin_flag
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$export_dynamic_flag_spec
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$whole_archive_flag_spec
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$thread_safe_flag_spec
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$libname_spec
-
-# List of archive names.  First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$RANLIB
-old_archive_cmds=$old_archive_cmds
-old_postinstall_cmds=$old_postinstall_cmds
-old_postuninstall_cmds=$old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$old_archive_from_new_cmds
-
-# Commands used to build and install a shared archive.
-archive_cmds=$archive_cmds
-archive_expsym_cmds=$archive_expsym_cmds
-postinstall_cmds=$postinstall_cmds
-postuninstall_cmds=$postuninstall_cmds
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$allow_undefined_flag
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$no_undefined_flag
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$global_symbol_to_cdecl
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$hardcode_libdir_flag_spec
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$hardcode_libdir_separator
-
-# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols
-
-# The commands to list exported symbols.
-export_symbols_cmds=$export_symbols_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$exclude_expsyms
-
-# Symbols that must always be exported.
-include_expsyms=$include_expsyms
-
-EOF
-
-case "$ltmain" in
-*.sh)
-  echo '### END LIBTOOL CONFIG' >> "$ofile"
-  echo >> "$ofile"
-  case "$host_os" in
-  aix3*)
-    cat <<\EOF >> "$ofile"
-
-# AIX sometimes has problems with the GCC collect2 program.  For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
-  COLLECT_NAMES=
-  export COLLECT_NAMES
-fi
-EOF
-    ;;
-  esac
-
-  # Append the ltmain.sh script.
-  sed '$q' "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1)
-  # We use sed instead of cat because bash on DJGPP gets confused if
-  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
-  # text mode, it properly converts lines to CR/LF.  This bash problem
-  # is reportedly fixed, but why not run on old versions too?
-
-  chmod +x "$ofile"
-  ;;
-
-*)
-  # Compile the libtool program.
-  echo "FIXME: would compile $ltmain"
-  ;;
-esac
-
-test -n "$cache_file" || exit 0
-
-# AC_CACHE_SAVE
-trap '' 1 2 15
-cat > confcache <<\EOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs.  It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already.  You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
-  case `(ac_space=' '; set | grep ac_space) 2>&1` in
-  *ac_space=\ *)
-    # `set' does not quote correctly, so add quotes (double-quote substitution
-    # turns \\\\ into \\, and sed turns \\ into \).
-    sed -n \
-      -e "s/'/'\\\\''/g" \
-      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
-    ;;
-  *)
-    # `set' quotes correctly as required by POSIX, so do not add quotes.
-    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
-    ;;
-  esac >> confcache
-if cmp -s $cache_file confcache; then
-  :
-else
-  if test -w $cache_file; then
-    echo "updating cache $cache_file"
-    cat confcache > $cache_file
-  else
-    echo "not updating unwritable cache $cache_file"
-  fi
-fi
-rm -f confcache
-
-exit 0
-
-# Local Variables:
-# mode:shell-script
-# sh-indentation:2
-# End:
diff --git a/ltmain.sh b/ltmain.sh
index a356aca..0f0a2da 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -1,9 +1,12 @@
+#! /bin/sh
+## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
+##               by inline-source v2014-01-03.01
 
-# libtool (GNU libtool) 2.4.2
+# libtool (GNU libtool) 2.4.6
+# Provide generalized library-building support services.
 # Written by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
-# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 1996-2015 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.
 
@@ -23,881 +26,2112 @@
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html,
-# or obtained by writing 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/>.
 
-# Usage: $progname [OPTION]... [MODE-ARG]...
-#
-# Provide generalized library-building support services.
-#
-#       --config             show all configuration variables
-#       --debug              enable verbose shell tracing
-#   -n, --dry-run            display commands without modifying any files
-#       --features           display basic configuration information and exit
-#       --mode=MODE          use operation mode MODE
-#       --preserve-dup-deps  don't remove duplicate dependency libraries
-#       --quiet, --silent    don't print informational messages
-#       --no-quiet, --no-silent
-#                            print informational messages (default)
-#       --no-warn            don't display warning messages
-#       --tag=TAG            use configuration variables from tag TAG
-#   -v, --verbose            print more informational messages than default
-#       --no-verbose         don't print the extra informational messages
-#       --version            print version information
-#   -h, --help, --help-all   print short, long, or detailed help message
-#
-# MODE must be one of the following:
-#
-#         clean              remove files from the build directory
-#         compile            compile a source file into a libtool object
-#         execute            automatically set library path, then run a program
-#         finish             complete the installation of libtool libraries
-#         install            install libraries or executables
-#         link               create a library or an executable
-#         uninstall          remove libraries from an installed directory
-#
-# MODE-ARGS vary depending on the MODE.  When passed as first option,
-# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
-# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
-#
-# When reporting a bug, please describe a test case to reproduce it and
-# include the following information:
-#
-#         host-triplet:	$host
-#         shell:		$SHELL
-#         compiler:		$LTCC
-#         compiler flags:		$LTCFLAGS
-#         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1
-#         automake:	$automake_version
-#         autoconf:	$autoconf_version
-#
-# Report bugs to <bug-libtool at gnu.org>.
-# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
-# General help using GNU software: <http://www.gnu.org/gethelp/>.
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1"
-TIMESTAMP=""
-package_revision=1.3337
+VERSION=2.4.6
+package_revision=2.4.6
 
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# Run './libtool --help' for help with using this script from the
+# command line.
+
+
+## ------------------------------- ##
+## User overridable command paths. ##
+## ------------------------------- ##
+
+# After configure completes, it has a better idea of some of the
+# shell tools we need than the defaults used by the functions shared
+# with bootstrap, so set those here where they can still be over-
+# ridden by the user, but otherwise take precedence.
+
+: ${AUTOCONF="autoconf"}
+: ${AUTOMAKE="automake"}
+
+
+## -------------------------- ##
+## Source external libraries. ##
+## -------------------------- ##
+
+# Much of our low-level functionality needs to be sourced from external
+# libraries, which are installed to $pkgauxdir.
+
+# Set a version string for this script.
+scriptversion=2015-01-20.17; # UTC
+
+# General shell script boiler plate, and helper functions.
+# Written by Gary V. Vaughan, 2004
+
+# Copyright (C) 2004-2015 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.
+
+# 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 3 of the License, or
+# (at your option) any later version.
+
+# As a special exception to the GNU General Public License, if you distribute
+# this file as part of a program or library that is built using GNU Libtool,
+# you may include this file under the same distribution terms that you use
+# for the rest of that program.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNES 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/>.
+
+# Please report bugs or propose patches to gary at gnu.org.
+
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# Evaluate this file near the top of your script to gain access to
+# the functions and variables defined here:
+#
+#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
+#
+# If you need to override any of the default environment variable
+# settings, do that before evaluating this file.
+
+
+## -------------------- ##
+## Shell normalisation. ##
+## -------------------- ##
+
+# Some shells need a little help to be as Bourne compatible as possible.
+# Before doing anything else, make sure all that help has been provided!
+
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
   NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
 else
-  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
 fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-$1
-_LTECHO_EOF'
-}
 
-# NLS nuisances: We save the old values to restore during execute mode.
-lt_user_locale=
-lt_safe_locale=
-for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+# NLS nuisances: We save the old values in case they are required later.
+_G_user_locale=
+_G_safe_locale=
+for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
 do
-  eval "if test \"\${$lt_var+set}\" = set; then
-          save_$lt_var=\$$lt_var
-          $lt_var=C
-	  export $lt_var
-	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
-	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+  eval "if test set = \"\${$_G_var+set}\"; then
+          save_$_G_var=\$$_G_var
+          $_G_var=C
+	  export $_G_var
+	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
+	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
 	fi"
 done
-LC_ALL=C
-LANGUAGE=C
-export LANGUAGE LC_ALL
 
-$lt_unset CDPATH
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Make sure IFS has a sensible default
+sp=' '
+nl='
+'
+IFS="$sp	$nl"
+
+# There are apparently some retarded systems that use ';' as a PATH separator!
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
 
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
 
 
+## ------------------------- ##
+## Locate command utilities. ##
+## ------------------------- ##
+
+
+# func_executable_p FILE
+# ----------------------
+# Check that FILE is an executable regular file.
+func_executable_p ()
+{
+    test -f "$1" && test -x "$1"
+}
+
+
+# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
+# --------------------------------------------
+# Search for either a program that responds to --version with output
+# containing "GNU", or else returned by CHECK_FUNC otherwise, by
+# trying all the directories in PATH with each of the elements of
+# PROGS_LIST.
+#
+# CHECK_FUNC should accept the path to a candidate program, and
+# set $func_check_prog_result if it truncates its output less than
+# $_G_path_prog_max characters.
+func_path_progs ()
+{
+    _G_progs_list=$1
+    _G_check_func=$2
+    _G_PATH=${3-"$PATH"}
+
+    _G_path_prog_max=0
+    _G_path_prog_found=false
+    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
+    for _G_dir in $_G_PATH; do
+      IFS=$_G_save_IFS
+      test -z "$_G_dir" && _G_dir=.
+      for _G_prog_name in $_G_progs_list; do
+        for _exeext in '' .EXE; do
+          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
+          func_executable_p "$_G_path_prog" || continue
+          case `"$_G_path_prog" --version 2>&1` in
+            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
+            *)     $_G_check_func $_G_path_prog
+		   func_path_progs_result=$func_check_prog_result
+		   ;;
+          esac
+          $_G_path_prog_found && break 3
+        done
+      done
+    done
+    IFS=$_G_save_IFS
+    test -z "$func_path_progs_result" && {
+      echo "no acceptable sed could be found in \$PATH" >&2
+      exit 1
+    }
+}
+
+
+# We want to be able to use the functions in this file before configure
+# has figured out where the best binaries are kept, which means we have
+# to search for them ourselves - except when the results are already set
+# where we skip the searches.
+
+# Unless the user overrides by setting SED, search the path for either GNU
+# sed, or the sed that truncates its output the least.
+test -z "$SED" && {
+  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+  for _G_i in 1 2 3 4 5 6 7; do
+    _G_sed_script=$_G_sed_script$nl$_G_sed_script
+  done
+  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
+  _G_sed_script=
+
+  func_check_prog_sed ()
+  {
+    _G_path_prog=$1
+
+    _G_count=0
+    printf 0123456789 >conftest.in
+    while :
+    do
+      cat conftest.in conftest.in >conftest.tmp
+      mv conftest.tmp conftest.in
+      cp conftest.in conftest.nl
+      echo '' >> conftest.nl
+      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
+      diff conftest.out conftest.nl >/dev/null 2>&1 || break
+      _G_count=`expr $_G_count + 1`
+      if test "$_G_count" -gt "$_G_path_prog_max"; then
+        # Best one so far, save it but keep looking for a better one
+        func_check_prog_result=$_G_path_prog
+        _G_path_prog_max=$_G_count
+      fi
+      # 10*(2^10) chars as input seems more than enough
+      test 10 -lt "$_G_count" && break
+    done
+    rm -f conftest.in conftest.tmp conftest.nl conftest.out
+  }
+
+  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
+  rm -f conftest.sed
+  SED=$func_path_progs_result
+}
+
+
+# Unless the user overrides by setting GREP, search the path for either GNU
+# grep, or the grep that truncates its output the least.
+test -z "$GREP" && {
+  func_check_prog_grep ()
+  {
+    _G_path_prog=$1
+
+    _G_count=0
+    _G_path_prog_max=0
+    printf 0123456789 >conftest.in
+    while :
+    do
+      cat conftest.in conftest.in >conftest.tmp
+      mv conftest.tmp conftest.in
+      cp conftest.in conftest.nl
+      echo 'GREP' >> conftest.nl
+      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
+      diff conftest.out conftest.nl >/dev/null 2>&1 || break
+      _G_count=`expr $_G_count + 1`
+      if test "$_G_count" -gt "$_G_path_prog_max"; then
+        # Best one so far, save it but keep looking for a better one
+        func_check_prog_result=$_G_path_prog
+        _G_path_prog_max=$_G_count
+      fi
+      # 10*(2^10) chars as input seems more than enough
+      test 10 -lt "$_G_count" && break
+    done
+    rm -f conftest.in conftest.tmp conftest.nl conftest.out
+  }
+
+  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
+  GREP=$func_path_progs_result
+}
+
+
+## ------------------------------- ##
+## User overridable command paths. ##
+## ------------------------------- ##
+
+# All uppercase variable names are used for environment variables.  These
+# variables can be overridden by the user before calling a script that
+# uses them if a suitable command of that name is not already available
+# in the command search PATH.
 
 : ${CP="cp -f"}
-test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
+: ${ECHO="printf %s\n"}
+: ${EGREP="$GREP -E"}
+: ${FGREP="$GREP -F"}
+: ${LN_S="ln -s"}
 : ${MAKE="make"}
 : ${MKDIR="mkdir"}
 : ${MV="mv -f"}
 : ${RM="rm -f"}
 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
-: ${Xsed="$SED -e 1s/^X//"}
-
-# Global variables:
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
-EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
-
-exit_status=$EXIT_SUCCESS
-
-# Make sure IFS has a sensible default
-lt_nl='
-'
-IFS=" 	$lt_nl"
 
-dirname="s,/[^/]*$,,"
-basename="s,^.*/,,"
 
-# func_dirname file append nondir_replacement
-# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
-# otherwise set result to NONDIR_REPLACEMENT.
-func_dirname ()
-{
-    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
-    if test "X$func_dirname_result" = "X${1}"; then
-      func_dirname_result="${3}"
-    else
-      func_dirname_result="$func_dirname_result${2}"
-    fi
-} # func_dirname may be replaced by extended shell implementation
+## -------------------- ##
+## Useful sed snippets. ##
+## -------------------- ##
 
+sed_dirname='s|/[^/]*$||'
+sed_basename='s|^.*/||'
 
-# func_basename file
-func_basename ()
-{
-    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
-} # func_basename may be replaced by extended shell implementation
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
 
+# Same as above, but do not quote variable references.
+sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
-# func_dirname_and_basename file append nondir_replacement
-# perform func_basename and func_dirname in a single function
-# call:
-#   dirname:  Compute the dirname of FILE.  If nonempty,
-#             add APPEND to the result, otherwise set result
-#             to NONDIR_REPLACEMENT.
-#             value returned in "$func_dirname_result"
-#   basename: Compute filename of FILE.
-#             value retuned in "$func_basename_result"
-# Implementation must be kept synchronized with func_dirname
-# and func_basename. For efficiency, we do not delegate to
-# those functions but instead duplicate the functionality here.
-func_dirname_and_basename ()
-{
-    # Extract subdirectory from the argument.
-    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
-    if test "X$func_dirname_result" = "X${1}"; then
-      func_dirname_result="${3}"
-    else
-      func_dirname_result="$func_dirname_result${2}"
-    fi
-    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
-} # func_dirname_and_basename may be replaced by extended shell implementation
+# Sed substitution that turns a string into a regex matching for the
+# string literally.
+sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
 
+# Sed substitution that converts a w32 file name or path
+# that contains forward slashes, into one that contains
+# (escaped) backslashes.  A very naive implementation.
+sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+
+# Re-'\' parameter expansions in output of sed_double_quote_subst that
+# were '\'-ed in input to the same.  If an odd number of '\' preceded a
+# '$' in input to sed_double_quote_subst, that '$' was protected from
+# expansion.  Since each input '\' is now two '\'s, look for any number
+# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
+_G_bs='\\'
+_G_bs2='\\\\'
+_G_bs4='\\\\\\\\'
+_G_dollar='\$'
+sed_double_backslash="\
+  s/$_G_bs4/&\\
+/g
+  s/^$_G_bs2$_G_dollar/$_G_bs&/
+  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
+  s/\n//g"
 
-# func_stripname prefix suffix name
-# strip PREFIX and SUFFIX off of NAME.
-# PREFIX and SUFFIX must not contain globbing or regex special
-# characters, hashes, percent signs, but SUFFIX may contain a leading
-# dot (in which case that matches only a dot).
-# func_strip_suffix prefix name
-func_stripname ()
-{
-    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 may be replaced by extended shell implementation
 
+## ----------------- ##
+## Global variables. ##
+## ----------------- ##
 
-# These SED scripts presuppose an absolute path with a trailing slash.
-pathcar='s,^/\([^/]*\).*$,\1,'
-pathcdr='s,^/[^/]*,,'
-removedotparts=':dotsl
-		s@/\./@/@g
-		t dotsl
-		s,/\.$,/,'
-collapseslashes='s@/\{1,\}@/@g'
-finalslash='s,/*$,/,'
+# Except for the global variables explicitly listed below, the following
+# functions in the '^func_' namespace, and the '^require_' namespace
+# variables initialised in the 'Resource management' section, sourcing
+# this file will not pollute your global namespace with anything
+# else. There's no portable way to scope variables in Bourne shell
+# though, so actually running these functions will sometimes place
+# results into a variable named after the function, and often use
+# temporary variables in the '^_G_' namespace. If you are careful to
+# avoid using those namespaces casually in your sourcing script, things
+# should continue to work as you expect. And, of course, you can freely
+# overwrite any of the functions or variables defined here before
+# calling anything to customize them.
 
-# func_normal_abspath PATH
-# Remove doubled-up and trailing slashes, "." path components,
-# and cancel out any ".." path components in PATH after making
-# it an absolute path.
-#             value returned in "$func_normal_abspath_result"
-func_normal_abspath ()
-{
-  # Start from root dir and reassemble the path.
-  func_normal_abspath_result=
-  func_normal_abspath_tpath=$1
-  func_normal_abspath_altnamespace=
-  case $func_normal_abspath_tpath in
-    "")
-      # Empty path, that just means $cwd.
-      func_stripname '' '/' "`pwd`"
-      func_normal_abspath_result=$func_stripname_result
-      return
-    ;;
-    # The next three entries are used to spot a run of precisely
-    # two leading slashes without using negated character classes;
-    # we take advantage of case's first-match behaviour.
-    ///*)
-      # Unusual form of absolute path, do nothing.
-    ;;
-    //*)
-      # Not necessarily an ordinary path; POSIX reserves leading '//'
-      # and for example Cygwin uses it to access remote file shares
-      # over CIFS/SMB, so we conserve a leading double slash if found.
-      func_normal_abspath_altnamespace=/
-    ;;
-    /*)
-      # Absolute path, do nothing.
-    ;;
-    *)
-      # Relative path, prepend $cwd.
-      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
-    ;;
-  esac
-  # Cancel out all the simple stuff to save iterations.  We also want
-  # the path to end with a slash for ease of parsing, so make sure
-  # there is one (and only one) here.
-  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
-  while :; do
-    # Processed it all yet?
-    if test "$func_normal_abspath_tpath" = / ; then
-      # If we ascended to the root using ".." the result may be empty now.
-      if test -z "$func_normal_abspath_result" ; then
-        func_normal_abspath_result=/
-      fi
-      break
-    fi
-    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcar"`
-    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcdr"`
-    # Figure out what to do with it
-    case $func_normal_abspath_tcomponent in
-      "")
-        # Trailing empty path component, ignore it.
-      ;;
-      ..)
-        # Parent dir; strip last assembled component from result.
-        func_dirname "$func_normal_abspath_result"
-        func_normal_abspath_result=$func_dirname_result
-      ;;
-      *)
-        # Actual path component, append it.
-        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
-      ;;
-    esac
-  done
-  # Restore leading double-slash if one was found on entry.
-  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
-}
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
 
-# func_relative_path SRCDIR DSTDIR
-# generates a relative path from SRCDIR to DSTDIR, with a trailing
-# slash if non-empty, suitable for immediately appending a filename
-# without needing to append a separator.
-#             value returned in "$func_relative_path_result"
-func_relative_path ()
-{
-  func_relative_path_result=
-  func_normal_abspath "$1"
-  func_relative_path_tlibdir=$func_normal_abspath_result
-  func_normal_abspath "$2"
-  func_relative_path_tbindir=$func_normal_abspath_result
-
-  # Ascend the tree starting from libdir
-  while :; do
-    # check if we have found a prefix of bindir
-    case $func_relative_path_tbindir in
-      $func_relative_path_tlibdir)
-        # found an exact match
-        func_relative_path_tcancelled=
-        break
-        ;;
-      $func_relative_path_tlibdir*)
-        # found a matching prefix
-        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
-        func_relative_path_tcancelled=$func_stripname_result
-        if test -z "$func_relative_path_result"; then
-          func_relative_path_result=.
-        fi
-        break
-        ;;
-      *)
-        func_dirname $func_relative_path_tlibdir
-        func_relative_path_tlibdir=${func_dirname_result}
-        if test "x$func_relative_path_tlibdir" = x ; then
-          # Have to descend all the way to the root!
-          func_relative_path_result=../$func_relative_path_result
-          func_relative_path_tcancelled=$func_relative_path_tbindir
-          break
-        fi
-        func_relative_path_result=../$func_relative_path_result
-        ;;
-    esac
-  done
+# Allow overriding, eg assuming that you follow the convention of
+# putting '$debug_cmd' at the start of all your functions, you can get
+# bash to show function call trace with:
+#
+#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
+debug_cmd=${debug_cmd-":"}
+exit_cmd=:
 
-  # Now calculate path; take care to avoid doubling-up slashes.
-  func_stripname '' '/' "$func_relative_path_result"
-  func_relative_path_result=$func_stripname_result
-  func_stripname '/' '/' "$func_relative_path_tcancelled"
-  if test "x$func_stripname_result" != x ; then
-    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
-  fi
+# By convention, finish your script with:
+#
+#    exit $exit_status
+#
+# so that you can set exit_status to non-zero if you want to indicate
+# something went wrong during execution without actually bailing out at
+# the point of failure.
+exit_status=$EXIT_SUCCESS
 
-  # Normalisation. If bindir is libdir, return empty string,
-  # else relative path ending with a slash; either way, target
-  # file name can be directly appended.
-  if test ! -z "$func_relative_path_result"; then
-    func_stripname './' '' "$func_relative_path_result/"
-    func_relative_path_result=$func_stripname_result
-  fi
-}
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath=$0
 
-# The name of this program:
-func_dirname_and_basename "$progpath"
-progname=$func_basename_result
+# The name of this program.
+progname=`$ECHO "$progpath" |$SED "$sed_basename"`
 
-# Make sure we have an absolute path for reexecution:
+# Make sure we have an absolute progpath for reexecution:
 case $progpath in
   [\\/]*|[A-Za-z]:\\*) ;;
   *[\\/]*)
-     progdir=$func_dirname_result
+     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
      progdir=`cd "$progdir" && pwd`
-     progpath="$progdir/$progname"
+     progpath=$progdir/$progname
      ;;
   *)
-     save_IFS="$IFS"
+     _G_IFS=$IFS
      IFS=${PATH_SEPARATOR-:}
      for progdir in $PATH; do
-       IFS="$save_IFS"
+       IFS=$_G_IFS
        test -x "$progdir/$progname" && break
      done
-     IFS="$save_IFS"
+     IFS=$_G_IFS
      test -n "$progdir" || progdir=`pwd`
-     progpath="$progdir/$progname"
+     progpath=$progdir/$progname
      ;;
 esac
 
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed="${SED}"' -e 1s/^X//'
-sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
-# Sed substitution that turns a string into a regex matching for the
-# string literally.
-sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
+## ----------------- ##
+## Standard options. ##
+## ----------------- ##
 
-# Sed substitution that converts a w32 file name or path
-# which contains forward slashes, into one that contains
-# (escaped) backslashes.  A very naive implementation.
-lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
-
-# Re-`\' parameter expansions in output of double_quote_subst that were
-# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
-# in input to double_quote_subst, that '$' was protected from expansion.
-# Since each input `\' is now two `\'s, look for any number of runs of
-# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
-bs='\\'
-bs2='\\\\'
-bs4='\\\\\\\\'
-dollar='\$'
-sed_double_backslash="\
-  s/$bs4/&\\
-/g
-  s/^$bs2$dollar/$bs&/
-  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
-  s/\n//g"
+# The following options affect the operation of the functions defined
+# below, and should be set appropriately depending on run-time para-
+# meters passed on the command line.
 
-# Standard options:
 opt_dry_run=false
-opt_help=false
 opt_quiet=false
 opt_verbose=false
-opt_warning=:
 
-# func_echo arg...
-# Echo program name prefixed message, along with the current mode
-# name if it has been set yet.
-func_echo ()
-{
-    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
-}
+# Categories 'all' and 'none' are always available.  Append any others
+# you will pass as the first argument to func_warning from your own
+# code.
+warning_categories=
 
-# func_verbose arg...
-# Echo program name prefixed message in verbose mode only.
-func_verbose ()
-{
-    $opt_verbose && func_echo ${1+"$@"}
+# By default, display warnings according to 'opt_warning_types'.  Set
+# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
+# treat the next displayed warning as a fatal error.
+warning_func=func_warn_and_continue
 
-    # A bug in bash halts the script if the last line of a function
-    # fails when set -e is in force, so we need another command to
-    # work around that:
-    :
-}
+# Set to 'all' to display all warnings, 'none' to suppress all
+# warnings, or a space delimited list of some subset of
+# 'warning_categories' to display only the listed warnings.
+opt_warning_types=all
 
-# func_echo_all arg...
-# Invoke $ECHO with all args, space-separated.
-func_echo_all ()
-{
-    $ECHO "$*"
-}
 
-# func_error arg...
-# Echo program name prefixed message to standard error.
-func_error ()
-{
-    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
-}
+## -------------------- ##
+## Resource management. ##
+## -------------------- ##
 
-# func_warning arg...
-# Echo program name prefixed warning message to standard error.
-func_warning ()
-{
-    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
+# This section contains definitions for functions that each ensure a
+# particular resource (a file, or a non-empty configuration variable for
+# example) is available, and if appropriate to extract default values
+# from pertinent package files. Call them using their associated
+# 'require_*' variable to ensure that they are executed, at most, once.
+#
+# It's entirely deliberate that calling these functions can set
+# variables that don't obey the namespace limitations obeyed by the rest
+# of this file, in order that that they be as useful as possible to
+# callers.
 
-    # bash bug again:
-    :
-}
 
-# func_fatal_error arg...
-# Echo program name prefixed message to standard error, and exit.
-func_fatal_error ()
+# require_term_colors
+# -------------------
+# Allow display of bold text on terminals that support it.
+require_term_colors=func_require_term_colors
+func_require_term_colors ()
 {
-    func_error ${1+"$@"}
-    exit $EXIT_FAILURE
-}
+    $debug_cmd
+
+    test -t 1 && {
+      # COLORTERM and USE_ANSI_COLORS environment variables take
+      # precedence, because most terminfo databases neglect to describe
+      # whether color sequences are supported.
+      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
+
+      if test 1 = "$USE_ANSI_COLORS"; then
+        # Standard ANSI escape sequences
+        tc_reset=''
+        tc_bold='';   tc_standout=''
+        tc_red='';   tc_green=''
+        tc_blue='';  tc_cyan=''
+      else
+        # Otherwise trust the terminfo database after all.
+        test -n "`tput sgr0 2>/dev/null`" && {
+          tc_reset=`tput sgr0`
+          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
+          tc_standout=$tc_bold
+          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
+          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
+          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
+          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
+          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
+        }
+      fi
+    }
 
-# func_fatal_help arg...
-# Echo program name prefixed message to standard error, followed by
-# a help hint, and exit.
-func_fatal_help ()
-{
-    func_error ${1+"$@"}
-    func_fatal_error "$help"
+    require_term_colors=:
 }
-help="Try \`$progname --help' for more information."  ## default
 
 
-# func_grep expression filename
+## ----------------- ##
+## Function library. ##
+## ----------------- ##
+
+# This section contains a variety of useful functions to call in your
+# scripts. Take note of the portable wrappers for features provided by
+# some modern shells, which will fall back to slower equivalents on
+# less featureful shells.
+
+
+# func_append VAR VALUE
+# ---------------------
+# Append VALUE onto the existing contents of VAR.
+
+  # We should try to minimise forks, especially on Windows where they are
+  # unreasonably slow, so skip the feature probes when bash or zsh are
+  # being used:
+  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
+    : ${_G_HAVE_ARITH_OP="yes"}
+    : ${_G_HAVE_XSI_OPS="yes"}
+    # The += operator was introduced in bash 3.1
+    case $BASH_VERSION in
+      [12].* | 3.0 | 3.0*) ;;
+      *)
+        : ${_G_HAVE_PLUSEQ_OP="yes"}
+        ;;
+    esac
+  fi
+
+  # _G_HAVE_PLUSEQ_OP
+  # Can be empty, in which case the shell is probed, "yes" if += is
+  # useable or anything else if it does not work.
+  test -z "$_G_HAVE_PLUSEQ_OP" \
+    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
+    && _G_HAVE_PLUSEQ_OP=yes
+
+if test yes = "$_G_HAVE_PLUSEQ_OP"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_append ()
+  {
+    $debug_cmd
+
+    eval "$1+=\$2"
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_append ()
+  {
+    $debug_cmd
+
+    eval "$1=\$$1\$2"
+  }
+fi
+
+
+# func_append_quoted VAR VALUE
+# ----------------------------
+# Quote VALUE and append to the end of shell variable VAR, separated
+# by a space.
+if test yes = "$_G_HAVE_PLUSEQ_OP"; then
+  eval 'func_append_quoted ()
+  {
+    $debug_cmd
+
+    func_quote_for_eval "$2"
+    eval "$1+=\\ \$func_quote_for_eval_result"
+  }'
+else
+  func_append_quoted ()
+  {
+    $debug_cmd
+
+    func_quote_for_eval "$2"
+    eval "$1=\$$1\\ \$func_quote_for_eval_result"
+  }
+fi
+
+
+# func_append_uniq VAR VALUE
+# --------------------------
+# Append unique VALUE onto the existing contents of VAR, assuming
+# entries are delimited by the first character of VALUE.  For example:
+#
+#   func_append_uniq options " --another-option option-argument"
+#
+# will only append to $options if " --another-option option-argument "
+# is not already present somewhere in $options already (note spaces at
+# each end implied by leading space in second argument).
+func_append_uniq ()
+{
+    $debug_cmd
+
+    eval _G_current_value='`$ECHO $'$1'`'
+    _G_delim=`expr "$2" : '\(.\)'`
+
+    case $_G_delim$_G_current_value$_G_delim in
+      *"$2$_G_delim"*) ;;
+      *) func_append "$@" ;;
+    esac
+}
+
+
+# func_arith TERM...
+# ------------------
+# Set func_arith_result to the result of evaluating TERMs.
+  test -z "$_G_HAVE_ARITH_OP" \
+    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
+    && _G_HAVE_ARITH_OP=yes
+
+if test yes = "$_G_HAVE_ARITH_OP"; then
+  eval 'func_arith ()
+  {
+    $debug_cmd
+
+    func_arith_result=$(( $* ))
+  }'
+else
+  func_arith ()
+  {
+    $debug_cmd
+
+    func_arith_result=`expr "$@"`
+  }
+fi
+
+
+# func_basename FILE
+# ------------------
+# Set func_basename_result to FILE with everything up to and including
+# the last / stripped.
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  # If this shell supports suffix pattern removal, then use it to avoid
+  # forking. Hide the definitions single quotes in case the shell chokes
+  # on unsupported syntax...
+  _b='func_basename_result=${1##*/}'
+  _d='case $1 in
+        */*) func_dirname_result=${1%/*}$2 ;;
+        *  ) func_dirname_result=$3        ;;
+      esac'
+
+else
+  # ...otherwise fall back to using sed.
+  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
+  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
+      if test "X$func_dirname_result" = "X$1"; then
+        func_dirname_result=$3
+      else
+        func_append func_dirname_result "$2"
+      fi'
+fi
+
+eval 'func_basename ()
+{
+    $debug_cmd
+
+    '"$_b"'
+}'
+
+
+# func_dirname FILE APPEND NONDIR_REPLACEMENT
+# -------------------------------------------
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+eval 'func_dirname ()
+{
+    $debug_cmd
+
+    '"$_d"'
+}'
+
+
+# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
+# --------------------------------------------------------
+# Perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# For efficiency, we do not delegate to the functions above but instead
+# duplicate the functionality here.
+eval 'func_dirname_and_basename ()
+{
+    $debug_cmd
+
+    '"$_b"'
+    '"$_d"'
+}'
+
+
+# func_echo ARG...
+# ----------------
+# Echo program name prefixed message.
+func_echo ()
+{
+    $debug_cmd
+
+    _G_message=$*
+
+    func_echo_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_IFS
+      $ECHO "$progname: $_G_line"
+    done
+    IFS=$func_echo_IFS
+}
+
+
+# func_echo_all ARG...
+# --------------------
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO "$*"
+}
+
+
+# func_echo_infix_1 INFIX ARG...
+# ------------------------------
+# Echo program name, followed by INFIX on the first line, with any
+# additional lines not showing INFIX.
+func_echo_infix_1 ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    _G_infix=$1; shift
+    _G_indent=$_G_infix
+    _G_prefix="$progname: $_G_infix: "
+    _G_message=$*
+
+    # Strip color escape sequences before counting printable length
+    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
+    do
+      test -n "$_G_tc" && {
+        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
+        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
+      }
+    done
+    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
+
+    func_echo_infix_1_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_infix_1_IFS
+      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
+      _G_prefix=$_G_indent
+    done
+    IFS=$func_echo_infix_1_IFS
+}
+
+
+# func_error ARG...
+# -----------------
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
+}
+
+
+# func_fatal_error ARG...
+# -----------------------
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    $debug_cmd
+
+    func_error "$*"
+    exit $EXIT_FAILURE
+}
+
+
+# func_grep EXPRESSION FILENAME
+# -----------------------------
 # Check whether EXPRESSION matches any line of FILENAME, without output.
 func_grep ()
 {
+    $debug_cmd
+
     $GREP "$1" "$2" >/dev/null 2>&1
 }
 
 
-# func_mkdir_p directory-path
+# func_len STRING
+# ---------------
+# Set func_len_result to the length of STRING. STRING may not
+# start with a hyphen.
+  test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_len ()
+  {
+    $debug_cmd
+
+    func_len_result=${#1}
+  }'
+else
+  func_len ()
+  {
+    $debug_cmd
+
+    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
+  }
+fi
+
+
+# func_mkdir_p DIRECTORY-PATH
+# ---------------------------
 # Make sure the entire path to DIRECTORY-PATH is available.
 func_mkdir_p ()
 {
-    my_directory_path="$1"
-    my_dir_list=
+    $debug_cmd
+
+    _G_directory_path=$1
+    _G_dir_list=
 
-    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
 
-      # Protect directory names starting with `-'
-      case $my_directory_path in
-        -*) my_directory_path="./$my_directory_path" ;;
+      # Protect directory names starting with '-'
+      case $_G_directory_path in
+        -*) _G_directory_path=./$_G_directory_path ;;
       esac
 
       # While some portion of DIR does not yet exist...
-      while test ! -d "$my_directory_path"; do
+      while test ! -d "$_G_directory_path"; do
         # ...make a list in topmost first order.  Use a colon delimited
 	# list incase some portion of path contains whitespace.
-        my_dir_list="$my_directory_path:$my_dir_list"
+        _G_dir_list=$_G_directory_path:$_G_dir_list
 
         # If the last portion added has no slash in it, the list is done
-        case $my_directory_path in */*) ;; *) break ;; esac
+        case $_G_directory_path in */*) ;; *) break ;; esac
 
         # ...otherwise throw away the child directory and loop
-        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
+        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
       done
-      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
+      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
 
-      save_mkdir_p_IFS="$IFS"; IFS=':'
-      for my_dir in $my_dir_list; do
-	IFS="$save_mkdir_p_IFS"
-        # mkdir can fail with a `File exist' error if two processes
+      func_mkdir_p_IFS=$IFS; IFS=:
+      for _G_dir in $_G_dir_list; do
+	IFS=$func_mkdir_p_IFS
+        # mkdir can fail with a 'File exist' error if two processes
         # try to create one of the directories concurrently.  Don't
         # stop in that case!
-        $MKDIR "$my_dir" 2>/dev/null || :
+        $MKDIR "$_G_dir" 2>/dev/null || :
       done
-      IFS="$save_mkdir_p_IFS"
+      IFS=$func_mkdir_p_IFS
 
       # Bail out if we (or some other process) failed to create a directory.
-      test -d "$my_directory_path" || \
-        func_fatal_error "Failed to create \`$1'"
+      test -d "$_G_directory_path" || \
+        func_fatal_error "Failed to create '$1'"
     fi
 }
 
 
-# func_mktempdir [string]
+# func_mktempdir [BASENAME]
+# -------------------------
 # Make a temporary directory that won't clash with other running
 # libtool processes, and avoids race conditions if possible.  If
-# given, STRING is the basename for that directory.
+# given, BASENAME is the basename for that directory.
 func_mktempdir ()
 {
-    my_template="${TMPDIR-/tmp}/${1-$progname}"
+    $debug_cmd
+
+    _G_template=${TMPDIR-/tmp}/${1-$progname}
 
-    if test "$opt_dry_run" = ":"; then
+    if test : = "$opt_dry_run"; then
       # Return a directory name, but don't create it in dry-run mode
-      my_tmpdir="${my_template}-$$"
+      _G_tmpdir=$_G_template-$$
     else
 
       # If mktemp works, use that first and foremost
-      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
 
-      if test ! -d "$my_tmpdir"; then
+      if test ! -d "$_G_tmpdir"; then
         # Failing that, at least try and use $RANDOM to avoid a race
-        my_tmpdir="${my_template}-${RANDOM-0}$$"
+        _G_tmpdir=$_G_template-${RANDOM-0}$$
 
-        save_mktempdir_umask=`umask`
+        func_mktempdir_umask=`umask`
         umask 0077
-        $MKDIR "$my_tmpdir"
-        umask $save_mktempdir_umask
+        $MKDIR "$_G_tmpdir"
+        umask $func_mktempdir_umask
       fi
 
       # If we're not in dry-run mode, bomb out on failure
-      test -d "$my_tmpdir" || \
-        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+      test -d "$_G_tmpdir" || \
+        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
     fi
 
-    $ECHO "$my_tmpdir"
+    $ECHO "$_G_tmpdir"
 }
 
 
-# func_quote_for_eval arg
-# Aesthetically quote ARG to be evaled later.
-# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
-# is double-quoted, suitable for a subsequent eval, whereas
-# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
-# which are still active within double quotes backslashified.
-func_quote_for_eval ()
+# func_normal_abspath PATH
+# ------------------------
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+func_normal_abspath ()
 {
-    case $1 in
-      *[\\\`\"\$]*)
-	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
-      *)
-        func_quote_for_eval_unquoted_result="$1" ;;
-    esac
+    $debug_cmd
 
-    case $func_quote_for_eval_unquoted_result in
-      # Double-quote args containing shell metacharacters to delay
-      # word splitting, command substitution and and variable
-      # expansion for a subsequent eval.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, so we specify it separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+    # These SED scripts presuppose an absolute path with a trailing slash.
+    _G_pathcar='s|^/\([^/]*\).*$|\1|'
+    _G_pathcdr='s|^/[^/]*||'
+    _G_removedotparts=':dotsl
+		s|/\./|/|g
+		t dotsl
+		s|/\.$|/|'
+    _G_collapseslashes='s|/\{1,\}|/|g'
+    _G_finalslash='s|/*$|/|'
+
+    # Start from root dir and reassemble the path.
+    func_normal_abspath_result=
+    func_normal_abspath_tpath=$1
+    func_normal_abspath_altnamespace=
+    case $func_normal_abspath_tpath in
+      "")
+        # Empty path, that just means $cwd.
+        func_stripname '' '/' "`pwd`"
+        func_normal_abspath_result=$func_stripname_result
+        return
+        ;;
+      # The next three entries are used to spot a run of precisely
+      # two leading slashes without using negated character classes;
+      # we take advantage of case's first-match behaviour.
+      ///*)
+        # Unusual form of absolute path, do nothing.
+        ;;
+      //*)
+        # Not necessarily an ordinary path; POSIX reserves leading '//'
+        # and for example Cygwin uses it to access remote file shares
+        # over CIFS/SMB, so we conserve a leading double slash if found.
+        func_normal_abspath_altnamespace=/
+        ;;
+      /*)
+        # Absolute path, do nothing.
         ;;
       *)
-        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+        # Relative path, prepend $cwd.
+        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+        ;;
     esac
+
+    # Cancel out all the simple stuff to save iterations.  We also want
+    # the path to end with a slash for ease of parsing, so make sure
+    # there is one (and only one) here.
+    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
+    while :; do
+      # Processed it all yet?
+      if test / = "$func_normal_abspath_tpath"; then
+        # If we ascended to the root using ".." the result may be empty now.
+        if test -z "$func_normal_abspath_result"; then
+          func_normal_abspath_result=/
+        fi
+        break
+      fi
+      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_pathcar"`
+      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_pathcdr"`
+      # Figure out what to do with it
+      case $func_normal_abspath_tcomponent in
+        "")
+          # Trailing empty path component, ignore it.
+          ;;
+        ..)
+          # Parent dir; strip last assembled component from result.
+          func_dirname "$func_normal_abspath_result"
+          func_normal_abspath_result=$func_dirname_result
+          ;;
+        *)
+          # Actual path component, append it.
+          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
+          ;;
+      esac
+    done
+    # Restore leading double-slash if one was found on entry.
+    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+
+# func_notquiet ARG...
+# --------------------
+# Echo program name prefixed message only when not in quiet mode.
+func_notquiet ()
+{
+    $debug_cmd
+
+    $opt_quiet || func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+
+# func_relative_path SRCDIR DSTDIR
+# --------------------------------
+# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
+func_relative_path ()
+{
+    $debug_cmd
+
+    func_relative_path_result=
+    func_normal_abspath "$1"
+    func_relative_path_tlibdir=$func_normal_abspath_result
+    func_normal_abspath "$2"
+    func_relative_path_tbindir=$func_normal_abspath_result
+
+    # Ascend the tree starting from libdir
+    while :; do
+      # check if we have found a prefix of bindir
+      case $func_relative_path_tbindir in
+        $func_relative_path_tlibdir)
+          # found an exact match
+          func_relative_path_tcancelled=
+          break
+          ;;
+        $func_relative_path_tlibdir*)
+          # found a matching prefix
+          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+          func_relative_path_tcancelled=$func_stripname_result
+          if test -z "$func_relative_path_result"; then
+            func_relative_path_result=.
+          fi
+          break
+          ;;
+        *)
+          func_dirname $func_relative_path_tlibdir
+          func_relative_path_tlibdir=$func_dirname_result
+          if test -z "$func_relative_path_tlibdir"; then
+            # Have to descend all the way to the root!
+            func_relative_path_result=../$func_relative_path_result
+            func_relative_path_tcancelled=$func_relative_path_tbindir
+            break
+          fi
+          func_relative_path_result=../$func_relative_path_result
+          ;;
+      esac
+    done
+
+    # Now calculate path; take care to avoid doubling-up slashes.
+    func_stripname '' '/' "$func_relative_path_result"
+    func_relative_path_result=$func_stripname_result
+    func_stripname '/' '/' "$func_relative_path_tcancelled"
+    if test -n "$func_stripname_result"; then
+      func_append func_relative_path_result "/$func_stripname_result"
+    fi
+
+    # Normalisation. If bindir is libdir, return '.' else relative path.
+    if test -n "$func_relative_path_result"; then
+      func_stripname './' '' "$func_relative_path_result"
+      func_relative_path_result=$func_stripname_result
+    fi
+
+    test -n "$func_relative_path_result" || func_relative_path_result=.
+
+    :
 }
 
 
-# func_quote_for_expand arg
+# func_quote_for_eval ARG...
+# --------------------------
+# Aesthetically quote ARGs to be evaled later.
+# This function returns two values:
+#   i) func_quote_for_eval_result
+#      double-quoted, suitable for a subsequent eval
+#  ii) func_quote_for_eval_unquoted_result
+#      has all characters that are still active within double
+#      quotes backslashified.
+func_quote_for_eval ()
+{
+    $debug_cmd
+
+    func_quote_for_eval_unquoted_result=
+    func_quote_for_eval_result=
+    while test 0 -lt $#; do
+      case $1 in
+        *[\\\`\"\$]*)
+	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
+        *)
+          _G_unquoted_arg=$1 ;;
+      esac
+      if test -n "$func_quote_for_eval_unquoted_result"; then
+	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
+      else
+        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
+      fi
+
+      case $_G_unquoted_arg in
+        # Double-quote args containing shell metacharacters to delay
+        # word splitting, command substitution and variable expansion
+        # for a subsequent eval.
+        # Many Bourne shells cannot handle close brackets correctly
+        # in scan sets, so we specify it separately.
+        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+          _G_quoted_arg=\"$_G_unquoted_arg\"
+          ;;
+        *)
+          _G_quoted_arg=$_G_unquoted_arg
+	  ;;
+      esac
+
+      if test -n "$func_quote_for_eval_result"; then
+	func_append func_quote_for_eval_result " $_G_quoted_arg"
+      else
+        func_append func_quote_for_eval_result "$_G_quoted_arg"
+      fi
+      shift
+    done
+}
+
+
+# func_quote_for_expand ARG
+# -------------------------
 # Aesthetically quote ARG to be evaled later; same as above,
 # but do not quote variable references.
 func_quote_for_expand ()
 {
+    $debug_cmd
+
     case $1 in
       *[\\\`\"]*)
-	my_arg=`$ECHO "$1" | $SED \
-	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+	_G_arg=`$ECHO "$1" | $SED \
+	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
       *)
-        my_arg="$1" ;;
+        _G_arg=$1 ;;
     esac
 
-    case $my_arg in
+    case $_G_arg in
       # Double-quote args containing shell metacharacters to delay
       # word splitting and command substitution for a subsequent eval.
       # Many Bourne shells cannot handle close brackets correctly
       # in scan sets, so we specify it separately.
       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        my_arg="\"$my_arg\""
+        _G_arg=\"$_G_arg\"
         ;;
     esac
 
-    func_quote_for_expand_result="$my_arg"
+    func_quote_for_expand_result=$_G_arg
+}
+
+
+# func_stripname PREFIX SUFFIX NAME
+# ---------------------------------
+# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_stripname ()
+  {
+    $debug_cmd
+
+    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+    # positional parameters, so assign one to ordinary variable first.
+    func_stripname_result=$3
+    func_stripname_result=${func_stripname_result#"$1"}
+    func_stripname_result=${func_stripname_result%"$2"}
+  }'
+else
+  func_stripname ()
+  {
+    $debug_cmd
+
+    case $2 in
+      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
+      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
+    esac
+  }
+fi
+
+
+# func_show_eval CMD [FAIL_EXP]
+# -----------------------------
+# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    $debug_cmd
+
+    _G_cmd=$1
+    _G_fail_exp=${2-':'}
+
+    func_quote_for_expand "$_G_cmd"
+    eval "func_notquiet $func_quote_for_expand_result"
+
+    $opt_dry_run || {
+      eval "$_G_cmd"
+      _G_status=$?
+      if test 0 -ne "$_G_status"; then
+	eval "(exit $_G_status); $_G_fail_exp"
+      fi
+    }
+}
+
+
+# func_show_eval_locale CMD [FAIL_EXP]
+# ------------------------------------
+# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    $debug_cmd
+
+    _G_cmd=$1
+    _G_fail_exp=${2-':'}
+
+    $opt_quiet || {
+      func_quote_for_expand "$_G_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    $opt_dry_run || {
+      eval "$_G_user_locale
+	    $_G_cmd"
+      _G_status=$?
+      eval "$_G_safe_locale"
+      if test 0 -ne "$_G_status"; then
+	eval "(exit $_G_status); $_G_fail_exp"
+      fi
+    }
+}
+
+
+# func_tr_sh
+# ----------
+# Turn $1 into a string suitable for a shell variable name.
+# Result is stored in $func_tr_sh_result.  All characters
+# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
+# if $1 begins with a digit, a '_' is prepended as well.
+func_tr_sh ()
+{
+    $debug_cmd
+
+    case $1 in
+    [0-9]* | *[!a-zA-Z0-9_]*)
+      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
+      ;;
+    * )
+      func_tr_sh_result=$1
+      ;;
+    esac
+}
+
+
+# func_verbose ARG...
+# -------------------
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $debug_cmd
+
+    $opt_verbose && func_echo "$*"
+
+    :
+}
+
+
+# func_warn_and_continue ARG...
+# -----------------------------
+# Echo program name prefixed warning message to standard error.
+func_warn_and_continue ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
+}
+
+
+# func_warning CATEGORY ARG...
+# ----------------------------
+# Echo program name prefixed warning message to standard error. Warning
+# messages can be filtered according to CATEGORY, where this function
+# elides messages where CATEGORY is not listed in the global variable
+# 'opt_warning_types'.
+func_warning ()
+{
+    $debug_cmd
+
+    # CATEGORY must be in the warning_categories list!
+    case " $warning_categories " in
+      *" $1 "*) ;;
+      *) func_internal_error "invalid warning category '$1'" ;;
+    esac
+
+    _G_category=$1
+    shift
+
+    case " $opt_warning_types " in
+      *" $_G_category "*) $warning_func ${1+"$@"} ;;
+    esac
 }
 
 
-# func_show_eval cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.
-func_show_eval ()
+# func_sort_ver VER1 VER2
+# -----------------------
+# 'sort -V' is not generally available.
+# Note this deviates from the version comparison in automake
+# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
+# but this should suffice as we won't be specifying old
+# version formats or redundant trailing .0 in bootstrap.conf.
+# If we did want full compatibility then we should probably
+# use m4_version_compare from autoconf.
+func_sort_ver ()
+{
+    $debug_cmd
+
+    printf '%s\n%s\n' "$1" "$2" \
+      | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
+}
+
+# func_lt_ver PREV CURR
+# ---------------------
+# Return true if PREV and CURR are in the correct order according to
+# func_sort_ver, otherwise false.  Use it like this:
+#
+#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
+func_lt_ver ()
+{
+    $debug_cmd
+
+    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
+}
+
+
+# Local variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
+# time-stamp-time-zone: "UTC"
+# End:
+#! /bin/sh
+
+# Set a version string for this script.
+scriptversion=2014-01-07.03; # UTC
+
+# A portable, pluggable option parser for Bourne shell.
+# Written by Gary V. Vaughan, 2010
+
+# Copyright (C) 2010-2015 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.
+
+# 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 3 of the License, 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/>.
+
+# Please report bugs or propose patches to gary at gnu.org.
+
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# This file is a library for parsing options in your shell scripts along
+# with assorted other useful supporting features that you can make use
+# of too.
+#
+# For the simplest scripts you might need only:
+#
+#   #!/bin/sh
+#   . relative/path/to/funclib.sh
+#   . relative/path/to/options-parser
+#   scriptversion=1.0
+#   func_options ${1+"$@"}
+#   eval set dummy "$func_options_result"; shift
+#   ...rest of your script...
+#
+# In order for the '--version' option to work, you will need to have a
+# suitably formatted comment like the one at the top of this file
+# starting with '# Written by ' and ending with '# warranty; '.
+#
+# For '-h' and '--help' to work, you will also need a one line
+# description of your script's purpose in a comment directly above the
+# '# Written by ' line, like the one at the top of this file.
+#
+# The default options also support '--debug', which will turn on shell
+# execution tracing (see the comment above debug_cmd below for another
+# use), and '--verbose' and the func_verbose function to allow your script
+# to display verbose messages only when your user has specified
+# '--verbose'.
+#
+# After sourcing this file, you can plug processing for additional
+# options by amending the variables from the 'Configuration' section
+# below, and following the instructions in the 'Option parsing'
+# section further down.
+
+## -------------- ##
+## Configuration. ##
+## -------------- ##
+
+# You should override these variables in your script after sourcing this
+# file so that they reflect the customisations you have added to the
+# option parser.
+
+# The usage line for option parsing errors and the start of '-h' and
+# '--help' output messages. You can embed shell variables for delayed
+# expansion at the time the message is displayed, but you will need to
+# quote other shell meta-characters carefully to prevent them being
+# expanded when the contents are evaled.
+usage='$progpath [OPTION]...'
+
+# Short help message in response to '-h' and '--help'.  Add to this or
+# override it after sourcing this library to reflect the full set of
+# options your script accepts.
+usage_message="\
+       --debug        enable verbose shell tracing
+   -W, --warnings=CATEGORY
+                      report the warnings falling in CATEGORY [all]
+   -v, --verbose      verbosely report processing
+       --version      print version information and exit
+   -h, --help         print short or long help message and exit
+"
+
+# Additional text appended to 'usage_message' in response to '--help'.
+long_help_message="
+Warning categories include:
+       'all'          show all warnings
+       'none'         turn off all the warnings
+       'error'        warnings are treated as fatal errors"
+
+# Help message printed before fatal option parsing errors.
+fatal_help="Try '\$progname --help' for more information."
+
+
+
+## ------------------------- ##
+## Hook function management. ##
+## ------------------------- ##
+
+# This section contains functions for adding, removing, and running hooks
+# to the main code.  A hook is just a named list of of function, that can
+# be run in order later on.
+
+# func_hookable FUNC_NAME
+# -----------------------
+# Declare that FUNC_NAME will run hooks added with
+# 'func_add_hook FUNC_NAME ...'.
+func_hookable ()
+{
+    $debug_cmd
+
+    func_append hookable_fns " $1"
+}
+
+
+# func_add_hook FUNC_NAME HOOK_FUNC
+# ---------------------------------
+# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
+# first have been declared "hookable" by a call to 'func_hookable'.
+func_add_hook ()
+{
+    $debug_cmd
+
+    case " $hookable_fns " in
+      *" $1 "*) ;;
+      *) func_fatal_error "'$1' does not accept hook functions." ;;
+    esac
+
+    eval func_append ${1}_hooks '" $2"'
+}
+
+
+# func_remove_hook FUNC_NAME HOOK_FUNC
+# ------------------------------------
+# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
+func_remove_hook ()
+{
+    $debug_cmd
+
+    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
+}
+
+
+# func_run_hooks FUNC_NAME [ARG]...
+# ---------------------------------
+# Run all hook functions registered to FUNC_NAME.
+# It is assumed that the list of hook functions contains nothing more
+# than a whitespace-delimited list of legal shell function names, and
+# no effort is wasted trying to catch shell meta-characters or preserve
+# whitespace.
+func_run_hooks ()
+{
+    $debug_cmd
+
+    case " $hookable_fns " in
+      *" $1 "*) ;;
+      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
+    esac
+
+    eval _G_hook_fns=\$$1_hooks; shift
+
+    for _G_hook in $_G_hook_fns; do
+      eval $_G_hook '"$@"'
+
+      # store returned options list back into positional
+      # parameters for next 'cmd' execution.
+      eval _G_hook_result=\$${_G_hook}_result
+      eval set dummy "$_G_hook_result"; shift
+    done
+
+    func_quote_for_eval ${1+"$@"}
+    func_run_hooks_result=$func_quote_for_eval_result
+}
+
+
+
+## --------------- ##
+## Option parsing. ##
+## --------------- ##
+
+# In order to add your own option parsing hooks, you must accept the
+# full positional parameter list in your hook function, remove any
+# options that you action, and then pass back the remaining unprocessed
+# options in '<hooked_function_name>_result', escaped suitably for
+# 'eval'.  Like this:
+#
+#    my_options_prep ()
+#    {
+#        $debug_cmd
+#
+#        # Extend the existing usage message.
+#        usage_message=$usage_message'
+#      -s, --silent       don'\''t print informational messages
+#    '
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_options_prep_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_options_prep my_options_prep
+#
+#
+#    my_silent_option ()
+#    {
+#        $debug_cmd
+#
+#        # Note that for efficiency, we parse as many options as we can
+#        # recognise in a loop before passing the remainder back to the
+#        # caller on the first unrecognised argument we encounter.
+#        while test $# -gt 0; do
+#          opt=$1; shift
+#          case $opt in
+#            --silent|-s) opt_silent=: ;;
+#            # Separate non-argument short options:
+#            -s*)         func_split_short_opt "$_G_opt"
+#                         set dummy "$func_split_short_opt_name" \
+#                             "-$func_split_short_opt_arg" ${1+"$@"}
+#                         shift
+#                         ;;
+#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
+#          esac
+#        done
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_silent_option_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_parse_options my_silent_option
+#
+#
+#    my_option_validation ()
+#    {
+#        $debug_cmd
+#
+#        $opt_silent && $opt_verbose && func_fatal_help "\
+#    '--silent' and '--verbose' options are mutually exclusive."
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_option_validation_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_validate_options my_option_validation
+#
+# You'll alse need to manually amend $usage_message to reflect the extra
+# options you parse.  It's preferable to append if you can, so that
+# multiple option parsing hooks can be added safely.
+
+
+# func_options [ARG]...
+# ---------------------
+# All the functions called inside func_options are hookable. See the
+# individual implementations for details.
+func_hookable func_options
+func_options ()
 {
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
+    $debug_cmd
 
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
+    func_options_prep ${1+"$@"}
+    eval func_parse_options \
+        ${func_options_prep_result+"$func_options_prep_result"}
+    eval func_validate_options \
+        ${func_parse_options_result+"$func_parse_options_result"}
 
-    if ${opt_dry_run-false}; then :; else
-      eval "$my_cmd"
-      my_status=$?
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
+    eval func_run_hooks func_options \
+        ${func_validate_options_result+"$func_validate_options_result"}
+
+    # save modified positional parameters for caller
+    func_options_result=$func_run_hooks_result
 }
 
 
-# func_show_eval_locale cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.  Use the saved locale for evaluation.
-func_show_eval_locale ()
+# func_options_prep [ARG]...
+# --------------------------
+# All initialisations required before starting the option parse loop.
+# Note that when calling hook functions, we pass through the list of
+# positional parameters.  If a hook function modifies that list, and
+# needs to propogate that back to rest of this script, then the complete
+# modified list must be put in 'func_run_hooks_result' before
+# returning.
+func_hookable func_options_prep
+func_options_prep ()
 {
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
+    $debug_cmd
 
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
+    # Option defaults:
+    opt_verbose=false
+    opt_warning_types=
 
-    if ${opt_dry_run-false}; then :; else
-      eval "$lt_user_locale
-	    $my_cmd"
-      my_status=$?
-      eval "$lt_safe_locale"
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
+    func_run_hooks func_options_prep ${1+"$@"}
+
+    # save modified positional parameters for caller
+    func_options_prep_result=$func_run_hooks_result
 }
 
-# func_tr_sh
-# Turn $1 into a string suitable for a shell variable name.
-# Result is stored in $func_tr_sh_result.  All characters
-# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
-# if $1 begins with a digit, a '_' is prepended as well.
-func_tr_sh ()
+
+# func_parse_options [ARG]...
+# ---------------------------
+# The main option parsing loop.
+func_hookable func_parse_options
+func_parse_options ()
 {
-  case $1 in
-  [0-9]* | *[!a-zA-Z0-9_]*)
-    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
-    ;;
-  * )
-    func_tr_sh_result=$1
-    ;;
-  esac
+    $debug_cmd
+
+    func_parse_options_result=
+
+    # this just eases exit handling
+    while test $# -gt 0; do
+      # Defer to hook functions for initial option parsing, so they
+      # get priority in the event of reusing an option name.
+      func_run_hooks func_parse_options ${1+"$@"}
+
+      # Adjust func_parse_options positional parameters to match
+      eval set dummy "$func_run_hooks_result"; shift
+
+      # Break out of the loop if we already parsed every option.
+      test $# -gt 0 || break
+
+      _G_opt=$1
+      shift
+      case $_G_opt in
+        --debug|-x)   debug_cmd='set -x'
+                      func_echo "enabling shell trace mode"
+                      $debug_cmd
+                      ;;
+
+        --no-warnings|--no-warning|--no-warn)
+                      set dummy --warnings none ${1+"$@"}
+                      shift
+		      ;;
+
+        --warnings|--warning|-W)
+                      test $# = 0 && func_missing_arg $_G_opt && break
+                      case " $warning_categories $1" in
+                        *" $1 "*)
+                          # trailing space prevents matching last $1 above
+                          func_append_uniq opt_warning_types " $1"
+                          ;;
+                        *all)
+                          opt_warning_types=$warning_categories
+                          ;;
+                        *none)
+                          opt_warning_types=none
+                          warning_func=:
+                          ;;
+                        *error)
+                          opt_warning_types=$warning_categories
+                          warning_func=func_fatal_error
+                          ;;
+                        *)
+                          func_fatal_error \
+                             "unsupported warning category: '$1'"
+                          ;;
+                      esac
+                      shift
+                      ;;
+
+        --verbose|-v) opt_verbose=: ;;
+        --version)    func_version ;;
+        -\?|-h)       func_usage ;;
+        --help)       func_help ;;
+
+	# Separate optargs to long options (plugins may need this):
+	--*=*)        func_split_equals "$_G_opt"
+	              set dummy "$func_split_equals_lhs" \
+                          "$func_split_equals_rhs" ${1+"$@"}
+                      shift
+                      ;;
+
+       # Separate optargs to short options:
+        -W*)
+                      func_split_short_opt "$_G_opt"
+                      set dummy "$func_split_short_opt_name" \
+                          "$func_split_short_opt_arg" ${1+"$@"}
+                      shift
+                      ;;
+
+        # Separate non-argument short options:
+        -\?*|-h*|-v*|-x*)
+                      func_split_short_opt "$_G_opt"
+                      set dummy "$func_split_short_opt_name" \
+                          "-$func_split_short_opt_arg" ${1+"$@"}
+                      shift
+                      ;;
+
+        --)           break ;;
+        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
+        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+      esac
+    done
+
+    # save modified positional parameters for caller
+    func_quote_for_eval ${1+"$@"}
+    func_parse_options_result=$func_quote_for_eval_result
 }
 
 
-# func_version
-# Echo version message to standard output and exit.
-func_version ()
+# func_validate_options [ARG]...
+# ------------------------------
+# Perform any sanity checks on option settings and/or unconsumed
+# arguments.
+func_hookable func_validate_options
+func_validate_options ()
 {
-    $opt_debug
+    $debug_cmd
 
-    $SED -n '/(C)/!b go
-	:more
-	/\./!{
-	  N
-	  s/\n# / /
-	  b more
-	}
-	:go
-	/^# '$PROGRAM' (GNU /,/# warranty; / {
-        s/^# //
-	s/^# *$//
-        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
-        p
-     }' < "$progpath"
-     exit $?
+    # Display all warnings if -W was not given.
+    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
+
+    func_run_hooks func_validate_options ${1+"$@"}
+
+    # Bail if the options were screwed!
+    $exit_cmd $EXIT_FAILURE
+
+    # save modified positional parameters for caller
+    func_validate_options_result=$func_run_hooks_result
 }
 
-# func_usage
-# Echo short help message to standard output and exit.
-func_usage ()
+
+
+## ----------------- ##
+## Helper functions. ##
+## ----------------- ##
+
+# This section contains the helper functions used by the rest of the
+# hookable option parser framework in ascii-betical order.
+
+
+# func_fatal_help ARG...
+# ----------------------
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
 {
-    $opt_debug
+    $debug_cmd
 
-    $SED -n '/^# Usage:/,/^#  *.*--help/ {
-        s/^# //
-	s/^# *$//
-	s/\$progname/'$progname'/
-	p
-    }' < "$progpath"
-    echo
-    $ECHO "run \`$progname --help | more' for full usage"
-    exit $?
+    eval \$ECHO \""Usage: $usage"\"
+    eval \$ECHO \""$fatal_help"\"
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
 }
 
-# func_help [NOEXIT]
-# Echo long help message to standard output and exit,
-# unless 'noexit' is passed as argument.
+
+# func_help
+# ---------
+# Echo long help message to standard output and exit.
 func_help ()
 {
-    $opt_debug
-
-    $SED -n '/^# Usage:/,/# Report bugs to/ {
-	:print
-        s/^# //
-	s/^# *$//
-	s*\$progname*'$progname'*
-	s*\$host*'"$host"'*
-	s*\$SHELL*'"$SHELL"'*
-	s*\$LTCC*'"$LTCC"'*
-	s*\$LTCFLAGS*'"$LTCFLAGS"'*
-	s*\$LD*'"$LD"'*
-	s/\$with_gnu_ld/'"$with_gnu_ld"'/
-	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
-	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
-	p
-	d
-     }
-     /^# .* home page:/b print
-     /^# General help using/b print
-     ' < "$progpath"
-    ret=$?
-    if test -z "$1"; then
-      exit $ret
-    fi
+    $debug_cmd
+
+    func_usage_message
+    $ECHO "$long_help_message"
+    exit 0
 }
 
-# func_missing_arg argname
+
+# func_missing_arg ARGNAME
+# ------------------------
 # Echo program name prefixed message to standard error and set global
 # exit_cmd.
 func_missing_arg ()
 {
-    $opt_debug
+    $debug_cmd
 
-    func_error "missing argument for $1."
+    func_error "Missing argument for '$1'."
     exit_cmd=exit
 }
 
 
-# func_split_short_opt shortopt
+# func_split_equals STRING
+# ------------------------
+# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
+# splitting STRING at the '=' sign.
+test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_split_equals ()
+  {
+      $debug_cmd
+
+      func_split_equals_lhs=${1%%=*}
+      func_split_equals_rhs=${1#*=}
+      test "x$func_split_equals_lhs" = "x$1" \
+        && func_split_equals_rhs=
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_split_equals ()
+  {
+      $debug_cmd
+
+      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
+      func_split_equals_rhs=
+      test "x$func_split_equals_lhs" = "x$1" \
+        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
+  }
+fi #func_split_equals
+
+
+# func_split_short_opt SHORTOPT
+# -----------------------------
 # Set func_split_short_opt_name and func_split_short_opt_arg shell
 # variables after splitting SHORTOPT after the 2nd character.
-func_split_short_opt ()
+if test yes = "$_G_HAVE_XSI_OPS"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_split_short_opt ()
+  {
+      $debug_cmd
+
+      func_split_short_opt_arg=${1#??}
+      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_split_short_opt ()
+  {
+      $debug_cmd
+
+      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
+      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
+  }
+fi #func_split_short_opt
+
+
+# func_usage
+# ----------
+# Echo short help message to standard output and exit.
+func_usage ()
 {
-    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
-    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
+    $debug_cmd
 
-    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
-    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
-} # func_split_short_opt may be replaced by extended shell implementation
+    func_usage_message
+    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
+    exit 0
+}
 
 
-# func_split_long_opt longopt
-# Set func_split_long_opt_name and func_split_long_opt_arg shell
-# variables after splitting LONGOPT at the `=' sign.
-func_split_long_opt ()
+# func_usage_message
+# ------------------
+# Echo short help message to standard output.
+func_usage_message ()
 {
-    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
-    my_sed_long_arg='1s/^--[^=]*=//'
+    $debug_cmd
 
-    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
-    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
-} # func_split_long_opt may be replaced by extended shell implementation
+    eval \$ECHO \""Usage: $usage"\"
+    echo
+    $SED -n 's|^# ||
+        /^Written by/{
+          x;p;x
+        }
+	h
+	/^Written by/q' < "$progpath"
+    echo
+    eval \$ECHO \""$usage_message"\"
+}
 
-exit_cmd=:
 
+# func_version
+# ------------
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $debug_cmd
 
+    printf '%s\n' "$progname $scriptversion"
+    $SED -n '
+        /(C)/!b go
+        :more
+        /\./!{
+          N
+          s|\n# | |
+          b more
+        }
+        :go
+        /^# Written by /,/# warranty; / {
+          s|^# ||
+          s|^# *$||
+          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
+          p
+        }
+        /^# Written by / {
+          s|^# ||
+          p
+        }
+        /^warranty; /q' < "$progpath"
 
+    exit $?
+}
 
 
-magic="%%%MAGIC variable%%%"
-magic_exe="%%%MAGIC EXE variable%%%"
+# Local variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
+# time-stamp-time-zone: "UTC"
+# End:
 
-# Global variables.
-nonopt=
-preserve_args=
-lo2o="s/\\.lo\$/.${objext}/"
-o2lo="s/\\.${objext}\$/.lo/"
-extracted_archives=
-extracted_serial=0
+# Set a version string.
+scriptversion='(GNU libtool) 2.4.6'
 
-# If this variable is set in any of the actions, the command in it
-# will be execed at the end.  This prevents here-documents from being
-# left over by shells.
-exec_cmd=
 
-# func_append var value
-# Append VALUE to the end of shell variable VAR.
-func_append ()
+# func_echo ARG...
+# ----------------
+# Libtool also displays the current mode in messages, so override
+# funclib.sh func_echo with this custom definition.
+func_echo ()
 {
-    eval "${1}=\$${1}\${2}"
-} # func_append may be replaced by extended shell implementation
+    $debug_cmd
 
-# func_append_quoted var value
-# Quote VALUE and append to the end of shell variable VAR, separated
-# by a space.
-func_append_quoted ()
-{
-    func_quote_for_eval "${2}"
-    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
-} # func_append_quoted may be replaced by extended shell implementation
+    _G_message=$*
+
+    func_echo_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_IFS
+      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
+    done
+    IFS=$func_echo_IFS
+}
 
 
-# func_arith arithmetic-term...
-func_arith ()
+# func_warning ARG...
+# -------------------
+# Libtool warnings are not categorized, so override funclib.sh
+# func_warning with this simpler definition.
+func_warning ()
 {
-    func_arith_result=`expr "${@}"`
-} # func_arith may be replaced by extended shell implementation
+    $debug_cmd
+
+    $warning_func ${1+"$@"}
+}
+
 
+## ---------------- ##
+## Options parsing. ##
+## ---------------- ##
+
+# Hook in the functions to make sure our own options are parsed during
+# the option parsing loop.
+
+usage='$progpath [OPTION]... [MODE-ARG]...'
+
+# Short help message in response to '-h'.
+usage_message="Options:
+       --config             show all configuration variables
+       --debug              enable verbose shell tracing
+   -n, --dry-run            display commands without modifying any files
+       --features           display basic configuration information and exit
+       --mode=MODE          use operation mode MODE
+       --no-warnings        equivalent to '-Wnone'
+       --preserve-dup-deps  don't remove duplicate dependency libraries
+       --quiet, --silent    don't print informational messages
+       --tag=TAG            use configuration variables from tag TAG
+   -v, --verbose            print more informational messages than default
+       --version            print version information
+   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
+   -h, --help, --help-all   print short, long, or detailed help message
+"
 
-# func_len string
-# STRING may not start with a hyphen.
-func_len ()
+# Additional text appended to 'usage_message' in response to '--help'.
+func_help ()
 {
-    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
-} # func_len may be replaced by extended shell implementation
+    $debug_cmd
+
+    func_usage_message
+    $ECHO "$long_help_message
+
+MODE must be one of the following:
+
+       clean           remove files from the build directory
+       compile         compile a source file into a libtool object
+       execute         automatically set library path, then run a program
+       finish          complete the installation of libtool libraries
+       install         install libraries or executables
+       link            create a library or an executable
+       uninstall       remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE.  When passed as first option,
+'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
+Try '$progname --help --mode=MODE' for a more detailed description of MODE.
+
+When reporting a bug, please describe a test case to reproduce it and
+include the following information:
+
+       host-triplet:   $host
+       shell:          $SHELL
+       compiler:       $LTCC
+       compiler flags: $LTCFLAGS
+       linker:         $LD (gnu? $with_gnu_ld)
+       version:        $progname (GNU libtool) 2.4.6
+       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
+       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
+
+Report bugs to <bug-libtool at gnu.org>.
+GNU libtool home page: <http://www.gnu.org/software/libtool/>.
+General help using GNU software: <http://www.gnu.org/gethelp/>."
+    exit 0
+}
 
 
-# func_lo2o object
-func_lo2o ()
-{
-    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
-} # func_lo2o may be replaced by extended shell implementation
+# func_lo2o OBJECT-NAME
+# ---------------------
+# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
+# object suffix.
 
+lo2o=s/\\.lo\$/.$objext/
+o2lo=s/\\.$objext\$/.lo/
 
-# func_xform libobj-or-source
-func_xform ()
-{
-    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
-} # func_xform may be replaced by extended shell implementation
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_lo2o ()
+  {
+    case $1 in
+      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
+      *   ) func_lo2o_result=$1               ;;
+    esac
+  }'
+
+  # func_xform LIBOBJ-OR-SOURCE
+  # ---------------------------
+  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
+  # suffix to a '.lo' libtool-object suffix.
+  eval 'func_xform ()
+  {
+    func_xform_result=${1%.*}.lo
+  }'
+else
+  # ...otherwise fall back to using sed.
+  func_lo2o ()
+  {
+    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
+  }
+
+  func_xform ()
+  {
+    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
+  }
+fi
 
 
-# func_fatal_configuration arg...
+# func_fatal_configuration ARG...
+# -------------------------------
 # Echo program name prefixed message to standard error, followed by
 # a configuration failure hint, and exit.
 func_fatal_configuration ()
 {
-    func_error ${1+"$@"}
-    func_error "See the $PACKAGE documentation for more information."
-    func_fatal_error "Fatal configuration error."
+    func__fatal_error ${1+"$@"} \
+      "See the $PACKAGE documentation for more information." \
+      "Fatal configuration error."
 }
 
 
 # func_config
+# -----------
 # Display the configuration for all the tags in this script.
 func_config ()
 {
@@ -915,17 +2149,19 @@ func_config ()
     exit $?
 }
 
+
 # func_features
+# -------------
 # Display the features supported by this script.
 func_features ()
 {
     echo "host: $host"
-    if test "$build_libtool_libs" = yes; then
+    if test yes = "$build_libtool_libs"; then
       echo "enable shared libraries"
     else
       echo "disable shared libraries"
     fi
-    if test "$build_old_libs" = yes; then
+    if test yes = "$build_old_libs"; then
       echo "enable static libraries"
     else
       echo "disable static libraries"
@@ -934,289 +2170,297 @@ func_features ()
     exit $?
 }
 
-# func_enable_tag tagname
+
+# func_enable_tag TAGNAME
+# -----------------------
 # Verify that TAGNAME is valid, and either flag an error and exit, or
 # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
 # variable here.
 func_enable_tag ()
 {
-  # Global variable:
-  tagname="$1"
+    # Global variable:
+    tagname=$1
 
-  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
-  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
-  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+    sed_extractcf=/$re_begincf/,/$re_endcf/p
 
-  # Validate tagname.
-  case $tagname in
-    *[!-_A-Za-z0-9,/]*)
-      func_fatal_error "invalid tag name: $tagname"
-      ;;
-  esac
+    # Validate tagname.
+    case $tagname in
+      *[!-_A-Za-z0-9,/]*)
+        func_fatal_error "invalid tag name: $tagname"
+        ;;
+    esac
 
-  # Don't test for the "default" C tag, as we know it's
-  # there but not specially marked.
-  case $tagname in
-    CC) ;;
+    # Don't test for the "default" C tag, as we know it's
+    # there but not specially marked.
+    case $tagname in
+        CC) ;;
     *)
-      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
-	taglist="$taglist $tagname"
-
-	# Evaluate the configuration.  Be careful to quote the path
-	# and the sed script, to avoid splitting on whitespace, but
-	# also don't use non-portable quotes within backquotes within
-	# quotes we have to do it in 2 steps:
-	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
-	eval "$extractedcf"
-      else
-	func_error "ignoring unknown tag $tagname"
-      fi
-      ;;
-  esac
+        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+	  taglist="$taglist $tagname"
+
+	  # Evaluate the configuration.  Be careful to quote the path
+	  # and the sed script, to avoid splitting on whitespace, but
+	  # also don't use non-portable quotes within backquotes within
+	  # quotes we have to do it in 2 steps:
+	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+	  eval "$extractedcf"
+        else
+	  func_error "ignoring unknown tag $tagname"
+        fi
+        ;;
+    esac
 }
 
+
 # func_check_version_match
+# ------------------------
 # Ensure that we are using m4 macros, and libtool script from the same
 # release of libtool.
 func_check_version_match ()
 {
-  if test "$package_revision" != "$macro_revision"; then
-    if test "$VERSION" != "$macro_version"; then
-      if test -z "$macro_version"; then
-        cat >&2 <<_LT_EOF
+    if test "$package_revision" != "$macro_revision"; then
+      if test "$VERSION" != "$macro_version"; then
+        if test -z "$macro_version"; then
+          cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 $progname: definition of this LT_INIT comes from an older release.
 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 $progname: and run autoconf again.
 _LT_EOF
-      else
-        cat >&2 <<_LT_EOF
+        else
+          cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 $progname: and run autoconf again.
 _LT_EOF
-      fi
-    else
-      cat >&2 <<_LT_EOF
+        fi
+      else
+        cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
 $progname: of $PACKAGE $VERSION and run autoconf again.
 _LT_EOF
-    fi
+      fi
 
-    exit $EXIT_MISMATCH
-  fi
+      exit $EXIT_MISMATCH
+    fi
 }
 
 
-# Shorthand for --mode=foo, only valid as the first argument
-case $1 in
-clean|clea|cle|cl)
-  shift; set dummy --mode clean ${1+"$@"}; shift
-  ;;
-compile|compil|compi|comp|com|co|c)
-  shift; set dummy --mode compile ${1+"$@"}; shift
-  ;;
-execute|execut|execu|exec|exe|ex|e)
-  shift; set dummy --mode execute ${1+"$@"}; shift
-  ;;
-finish|finis|fini|fin|fi|f)
-  shift; set dummy --mode finish ${1+"$@"}; shift
-  ;;
-install|instal|insta|inst|ins|in|i)
-  shift; set dummy --mode install ${1+"$@"}; shift
-  ;;
-link|lin|li|l)
-  shift; set dummy --mode link ${1+"$@"}; shift
-  ;;
-uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
-  shift; set dummy --mode uninstall ${1+"$@"}; shift
-  ;;
-esac
+# libtool_options_prep [ARG]...
+# -----------------------------
+# Preparation for options parsed by libtool.
+libtool_options_prep ()
+{
+    $debug_mode
 
+    # Option defaults:
+    opt_config=false
+    opt_dlopen=
+    opt_dry_run=false
+    opt_help=false
+    opt_mode=
+    opt_preserve_dup_deps=false
+    opt_quiet=false
 
+    nonopt=
+    preserve_args=
 
-# Option defaults:
-opt_debug=:
-opt_dry_run=false
-opt_config=false
-opt_preserve_dup_deps=false
-opt_features=false
-opt_finish=false
-opt_help=false
-opt_help_all=false
-opt_silent=:
-opt_warning=:
-opt_verbose=:
-opt_silent=false
-opt_verbose=false
+    # Shorthand for --mode=foo, only valid as the first argument
+    case $1 in
+    clean|clea|cle|cl)
+      shift; set dummy --mode clean ${1+"$@"}; shift
+      ;;
+    compile|compil|compi|comp|com|co|c)
+      shift; set dummy --mode compile ${1+"$@"}; shift
+      ;;
+    execute|execut|execu|exec|exe|ex|e)
+      shift; set dummy --mode execute ${1+"$@"}; shift
+      ;;
+    finish|finis|fini|fin|fi|f)
+      shift; set dummy --mode finish ${1+"$@"}; shift
+      ;;
+    install|instal|insta|inst|ins|in|i)
+      shift; set dummy --mode install ${1+"$@"}; shift
+      ;;
+    link|lin|li|l)
+      shift; set dummy --mode link ${1+"$@"}; shift
+      ;;
+    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+      shift; set dummy --mode uninstall ${1+"$@"}; shift
+      ;;
+    esac
+
+    # Pass back the list of options.
+    func_quote_for_eval ${1+"$@"}
+    libtool_options_prep_result=$func_quote_for_eval_result
+}
+func_add_hook func_options_prep libtool_options_prep
 
 
-# Parse options once, thoroughly.  This comes as soon as possible in the
-# script to make things like `--version' happen as quickly as we can.
+# libtool_parse_options [ARG]...
+# ---------------------------------
+# Provide handling for libtool specific options.
+libtool_parse_options ()
 {
-  # this just eases exit handling
-  while test $# -gt 0; do
-    opt="$1"
-    shift
-    case $opt in
-      --debug|-x)	opt_debug='set -x'
-			func_echo "enabling shell trace mode"
-			$opt_debug
-			;;
-      --dry-run|--dryrun|-n)
-			opt_dry_run=:
-			;;
-      --config)
-			opt_config=:
-func_config
-			;;
-      --dlopen|-dlopen)
-			optarg="$1"
-			opt_dlopen="${opt_dlopen+$opt_dlopen
-}$optarg"
-			shift
-			;;
-      --preserve-dup-deps)
-			opt_preserve_dup_deps=:
-			;;
-      --features)
-			opt_features=:
-func_features
-			;;
-      --finish)
-			opt_finish=:
-set dummy --mode finish ${1+"$@"}; shift
-			;;
-      --help)
-			opt_help=:
-			;;
-      --help-all)
-			opt_help_all=:
-opt_help=': help-all'
-			;;
-      --mode)
-			test $# = 0 && func_missing_arg $opt && break
-			optarg="$1"
-			opt_mode="$optarg"
-case $optarg in
-  # Valid mode arguments:
-  clean|compile|execute|finish|install|link|relink|uninstall) ;;
-
-  # Catch anything else as an error
-  *) func_error "invalid argument for $opt"
-     exit_cmd=exit
-     break
-     ;;
-esac
-			shift
-			;;
-      --no-silent|--no-quiet)
-			opt_silent=false
-func_append preserve_args " $opt"
-			;;
-      --no-warning|--no-warn)
-			opt_warning=false
-func_append preserve_args " $opt"
-			;;
-      --no-verbose)
-			opt_verbose=false
-func_append preserve_args " $opt"
-			;;
-      --silent|--quiet)
-			opt_silent=:
-func_append preserve_args " $opt"
-        opt_verbose=false
-			;;
-      --verbose|-v)
-			opt_verbose=:
-func_append preserve_args " $opt"
-opt_silent=false
-			;;
-      --tag)
-			test $# = 0 && func_missing_arg $opt && break
-			optarg="$1"
-			opt_tag="$optarg"
-func_append preserve_args " $opt $optarg"
-func_enable_tag "$optarg"
-			shift
-			;;
-
-      -\?|-h)		func_usage				;;
-      --help)		func_help				;;
-      --version)	func_version				;;
-
-      # Separate optargs to long options:
-      --*=*)
-			func_split_long_opt "$opt"
-			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
-			shift
-			;;
-
-      # Separate non-argument short options:
-      -\?*|-h*|-n*|-v*)
-			func_split_short_opt "$opt"
-			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
-			shift
-			;;
-
-      --)		break					;;
-      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
-      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
-    esac
-  done
+    $debug_cmd
 
-  # Validate options:
+    # Perform our own loop to consume as many options as possible in
+    # each iteration.
+    while test $# -gt 0; do
+      _G_opt=$1
+      shift
+      case $_G_opt in
+        --dry-run|--dryrun|-n)
+                        opt_dry_run=:
+                        ;;
+
+        --config)       func_config ;;
+
+        --dlopen|-dlopen)
+                        opt_dlopen="${opt_dlopen+$opt_dlopen
+}$1"
+                        shift
+                        ;;
+
+        --preserve-dup-deps)
+                        opt_preserve_dup_deps=: ;;
+
+        --features)     func_features ;;
+
+        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
+
+        --help)         opt_help=: ;;
+
+        --help-all)     opt_help=': help-all' ;;
+
+        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
+                        opt_mode=$1
+                        case $1 in
+                          # Valid mode arguments:
+                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
+
+                          # Catch anything else as an error
+                          *) func_error "invalid argument for $_G_opt"
+                             exit_cmd=exit
+                             break
+                             ;;
+                        esac
+                        shift
+                        ;;
+
+        --no-silent|--no-quiet)
+                        opt_quiet=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --no-warnings|--no-warning|--no-warn)
+                        opt_warning=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --no-verbose)
+                        opt_verbose=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --silent|--quiet)
+                        opt_quiet=:
+                        opt_verbose=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
+                        opt_tag=$1
+                        func_append preserve_args " $_G_opt $1"
+                        func_enable_tag "$1"
+                        shift
+                        ;;
+
+        --verbose|-v)   opt_quiet=false
+                        opt_verbose=:
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+	# An option not handled by this hook function:
+        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
+      esac
+    done
 
-  # save first non-option argument
-  if test "$#" -gt 0; then
-    nonopt="$opt"
-    shift
-  fi
 
-  # preserve --debug
-  test "$opt_debug" = : || func_append preserve_args " --debug"
+    # save modified positional parameters for caller
+    func_quote_for_eval ${1+"$@"}
+    libtool_parse_options_result=$func_quote_for_eval_result
+}
+func_add_hook func_parse_options libtool_parse_options
 
-  case $host in
-    *cygwin* | *mingw* | *pw32* | *cegcc*)
-      # don't eliminate duplications in $postdeps and $predeps
-      opt_duplicate_compiler_generated_deps=:
-      ;;
-    *)
-      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
-      ;;
-  esac
 
-  $opt_help || {
-    # Sanity checks first:
-    func_check_version_match
 
-    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
-      func_fatal_configuration "not configured to build any kind of library"
+# libtool_validate_options [ARG]...
+# ---------------------------------
+# Perform any sanity checks on option settings and/or unconsumed
+# arguments.
+libtool_validate_options ()
+{
+    # save first non-option argument
+    if test 0 -lt $#; then
+      nonopt=$1
+      shift
     fi
 
-    # Darwin sucks
-    eval std_shrext=\"$shrext_cmds\"
+    # preserve --debug
+    test : = "$debug_cmd" || func_append preserve_args " --debug"
 
-    # Only execute mode is allowed to have -dlopen flags.
-    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
-      func_error "unrecognized option \`-dlopen'"
-      $ECHO "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
+    case $host in
+      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
+      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
+      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
+        # don't eliminate duplications in $postdeps and $predeps
+        opt_duplicate_compiler_generated_deps=:
+        ;;
+      *)
+        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
+        ;;
+    esac
 
-    # Change the help message to a mode-specific one.
-    generic_help="$help"
-    help="Try \`$progname --help --mode=$opt_mode' for more information."
-  }
+    $opt_help || {
+      # Sanity checks first:
+      func_check_version_match
 
+      test yes != "$build_libtool_libs" \
+        && test yes != "$build_old_libs" \
+        && func_fatal_configuration "not configured to build any kind of library"
 
-  # Bail if the options were screwed
-  $exit_cmd $EXIT_FAILURE
+      # Darwin sucks
+      eval std_shrext=\"$shrext_cmds\"
+
+      # Only execute mode is allowed to have -dlopen flags.
+      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
+        func_error "unrecognized option '-dlopen'"
+        $ECHO "$help" 1>&2
+        exit $EXIT_FAILURE
+      fi
+
+      # Change the help message to a mode-specific one.
+      generic_help=$help
+      help="Try '$progname --help --mode=$opt_mode' for more information."
+    }
+
+    # Pass back the unparsed argument list
+    func_quote_for_eval ${1+"$@"}
+    libtool_validate_options_result=$func_quote_for_eval_result
 }
+func_add_hook func_validate_options libtool_validate_options
+
 
+# Process options as early as possible so that --help and --version
+# can return quickly.
+func_options ${1+"$@"}
+eval set dummy "$func_options_result"; shift
 
 
 
@@ -1224,24 +2468,52 @@ func_enable_tag "$optarg"
 ##    Main.    ##
 ## ----------- ##
 
+magic='%%%MAGIC variable%%%'
+magic_exe='%%%MAGIC EXE variable%%%'
+
+# Global variables.
+extracted_archives=
+extracted_serial=0
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+
+# func_generated_by_libtool
+# True iff stdin has been generated by Libtool. This function is only
+# a basic sanity check; it will hardly flush out determined imposters.
+func_generated_by_libtool_p ()
+{
+  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
 # func_lalib_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
+# True iff FILE is a libtool '.la' library or '.lo' object file.
 # This function is only a basic sanity check; it will hardly flush out
 # determined imposters.
 func_lalib_p ()
 {
     test -f "$1" &&
-      $SED -e 4q "$1" 2>/dev/null \
-        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
 }
 
 # func_lalib_unsafe_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
+# True iff FILE is a libtool '.la' library or '.lo' object file.
 # This function implements the same check as func_lalib_p without
 # resorting to external programs.  To this end, it redirects stdin and
 # closes it afterwards, without saving the original file descriptor.
 # As a safety measure, use it only where a negative result would be
-# fatal anyway.  Works if `file' does not exist.
+# fatal anyway.  Works if 'file' does not exist.
 func_lalib_unsafe_p ()
 {
     lalib_p=no
@@ -1249,13 +2521,13 @@ func_lalib_unsafe_p ()
 	for lalib_p_l in 1 2 3 4
 	do
 	    read lalib_p_line
-	    case "$lalib_p_line" in
+	    case $lalib_p_line in
 		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
 	    esac
 	done
 	exec 0<&5 5<&-
     fi
-    test "$lalib_p" = yes
+    test yes = "$lalib_p"
 }
 
 # func_ltwrapper_script_p file
@@ -1264,7 +2536,8 @@ func_lalib_unsafe_p ()
 # determined imposters.
 func_ltwrapper_script_p ()
 {
-    func_lalib_p "$1"
+    test -f "$1" &&
+      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
 }
 
 # func_ltwrapper_executable_p file
@@ -1289,7 +2562,7 @@ func_ltwrapper_scriptname ()
 {
     func_dirname_and_basename "$1" "" "."
     func_stripname '' '.exe' "$func_basename_result"
-    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
 }
 
 # func_ltwrapper_p file
@@ -1308,11 +2581,13 @@ func_ltwrapper_p ()
 # FAIL_CMD may read-access the current command in variable CMD!
 func_execute_cmds ()
 {
-    $opt_debug
+    $debug_cmd
+
     save_ifs=$IFS; IFS='~'
     for cmd in $1; do
-      IFS=$save_ifs
+      IFS=$sp$nl
       eval cmd=\"$cmd\"
+      IFS=$save_ifs
       func_show_eval "$cmd" "${2-:}"
     done
     IFS=$save_ifs
@@ -1324,10 +2599,11 @@ func_execute_cmds ()
 # Note that it is not necessary on cygwin/mingw to append a dot to
 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
 # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-# `FILE.' does not work on cygwin managed mounts.
+# 'FILE.' does not work on cygwin managed mounts.
 func_source ()
 {
-    $opt_debug
+    $debug_cmd
+
     case $1 in
     */* | *\\*)	. "$1" ;;
     *)		. "./$1" ;;
@@ -1354,10 +2630,10 @@ func_resolve_sysroot ()
 # store the result into func_replace_sysroot_result.
 func_replace_sysroot ()
 {
-  case "$lt_sysroot:$1" in
+  case $lt_sysroot:$1 in
   ?*:"$lt_sysroot"*)
     func_stripname "$lt_sysroot" '' "$1"
-    func_replace_sysroot_result="=$func_stripname_result"
+    func_replace_sysroot_result='='$func_stripname_result
     ;;
   *)
     # Including no sysroot.
@@ -1374,7 +2650,8 @@ func_replace_sysroot ()
 # arg is usually of the form 'gcc ...'
 func_infer_tag ()
 {
-    $opt_debug
+    $debug_cmd
+
     if test -n "$available_tags" && test -z "$tagname"; then
       CC_quoted=
       for arg in $CC; do
@@ -1393,7 +2670,7 @@ func_infer_tag ()
 	for z in $available_tags; do
 	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
 	    # Evaluate the configuration.
-	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
 	    CC_quoted=
 	    for arg in $CC; do
 	      # Double-quote args containing other shell metacharacters.
@@ -1418,7 +2695,7 @@ func_infer_tag ()
 	# line option must be used.
 	if test -z "$tagname"; then
 	  func_echo "unable to infer tagged configuration"
-	  func_fatal_error "specify a tag with \`--tag'"
+	  func_fatal_error "specify a tag with '--tag'"
 #	else
 #	  func_verbose "using $tagname tagged configuration"
 	fi
@@ -1434,15 +2711,15 @@ func_infer_tag ()
 # but don't create it if we're doing a dry run.
 func_write_libtool_object ()
 {
-    write_libobj=${1}
-    if test "$build_libtool_libs" = yes; then
-      write_lobj=\'${2}\'
+    write_libobj=$1
+    if test yes = "$build_libtool_libs"; then
+      write_lobj=\'$2\'
     else
       write_lobj=none
     fi
 
-    if test "$build_old_libs" = yes; then
-      write_oldobj=\'${3}\'
+    if test yes = "$build_old_libs"; then
+      write_oldobj=\'$3\'
     else
       write_oldobj=none
     fi
@@ -1450,7 +2727,7 @@ func_write_libtool_object ()
     $opt_dry_run || {
       cat >${write_libobj}T <<EOF
 # $write_libobj - a libtool object file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.
@@ -1462,7 +2739,7 @@ pic_object=$write_lobj
 non_pic_object=$write_oldobj
 
 EOF
-      $MV "${write_libobj}T" "${write_libobj}"
+      $MV "${write_libobj}T" "$write_libobj"
     }
 }
 
@@ -1482,8 +2759,9 @@ EOF
 # be empty on error (or when ARG is empty)
 func_convert_core_file_wine_to_w32 ()
 {
-  $opt_debug
-  func_convert_core_file_wine_to_w32_result="$1"
+  $debug_cmd
+
+  func_convert_core_file_wine_to_w32_result=$1
   if test -n "$1"; then
     # Unfortunately, winepath does not exit with a non-zero error code, so we
     # are forced to check the contents of stdout. On the other hand, if the
@@ -1491,9 +2769,9 @@ func_convert_core_file_wine_to_w32 ()
     # *an error message* to stdout. So we must check for both error code of
     # zero AND non-empty stdout, which explains the odd construction:
     func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
-    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
+    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
       func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
-        $SED -e "$lt_sed_naive_backslashify"`
+        $SED -e "$sed_naive_backslashify"`
     else
       func_convert_core_file_wine_to_w32_result=
     fi
@@ -1514,18 +2792,19 @@ func_convert_core_file_wine_to_w32 ()
 # are convertible, then the result may be empty.
 func_convert_core_path_wine_to_w32 ()
 {
-  $opt_debug
+  $debug_cmd
+
   # unfortunately, winepath doesn't convert paths, only file names
-  func_convert_core_path_wine_to_w32_result=""
+  func_convert_core_path_wine_to_w32_result=
   if test -n "$1"; then
     oldIFS=$IFS
     IFS=:
     for func_convert_core_path_wine_to_w32_f in $1; do
       IFS=$oldIFS
       func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
-      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
+      if test -n "$func_convert_core_file_wine_to_w32_result"; then
         if test -z "$func_convert_core_path_wine_to_w32_result"; then
-          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
+          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
         else
           func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
         fi
@@ -1554,7 +2833,8 @@ func_convert_core_path_wine_to_w32 ()
 # environment variable; do not put it in $PATH.
 func_cygpath ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
     func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
     if test "$?" -ne 0; then
@@ -1563,7 +2843,7 @@ func_cygpath ()
     fi
   else
     func_cygpath_result=
-    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
+    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
   fi
 }
 #end: func_cygpath
@@ -1574,10 +2854,11 @@ func_cygpath ()
 # result in func_convert_core_msys_to_w32_result.
 func_convert_core_msys_to_w32 ()
 {
-  $opt_debug
+  $debug_cmd
+
   # awkward: cmd appends spaces to result
   func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
-    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
 }
 #end: func_convert_core_msys_to_w32
 
@@ -1588,13 +2869,14 @@ func_convert_core_msys_to_w32 ()
 # func_to_host_file_result to ARG1).
 func_convert_file_check ()
 {
-  $opt_debug
-  if test -z "$2" && test -n "$1" ; then
+  $debug_cmd
+
+  if test -z "$2" && test -n "$1"; then
     func_error "Could not determine host file name corresponding to"
-    func_error "  \`$1'"
+    func_error "  '$1'"
     func_error "Continuing, but uninstalled executables may not work."
     # Fallback:
-    func_to_host_file_result="$1"
+    func_to_host_file_result=$1
   fi
 }
 # end func_convert_file_check
@@ -1606,10 +2888,11 @@ func_convert_file_check ()
 # func_to_host_file_result to a simplistic fallback value (see below).
 func_convert_path_check ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -z "$4" && test -n "$3"; then
     func_error "Could not determine the host path corresponding to"
-    func_error "  \`$3'"
+    func_error "  '$3'"
     func_error "Continuing, but uninstalled executables may not work."
     # Fallback.  This is a deliberately simplistic "conversion" and
     # should not be "improved".  See libtool.info.
@@ -1618,7 +2901,7 @@ func_convert_path_check ()
       func_to_host_path_result=`echo "$3" |
         $SED -e "$lt_replace_pathsep_chars"`
     else
-      func_to_host_path_result="$3"
+      func_to_host_path_result=$3
     fi
   fi
 }
@@ -1630,9 +2913,10 @@ func_convert_path_check ()
 # and appending REPL if ORIG matches BACKPAT.
 func_convert_path_front_back_pathsep ()
 {
-  $opt_debug
+  $debug_cmd
+
   case $4 in
-  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
+  $1 ) func_to_host_path_result=$3$func_to_host_path_result
     ;;
   esac
   case $4 in
@@ -1646,7 +2930,7 @@ func_convert_path_front_back_pathsep ()
 ##################################################
 # $build to $host FILE NAME CONVERSION FUNCTIONS #
 ##################################################
-# invoked via `$to_host_file_cmd ARG'
+# invoked via '$to_host_file_cmd ARG'
 #
 # In each case, ARG is the path to be converted from $build to $host format.
 # Result will be available in $func_to_host_file_result.
@@ -1657,7 +2941,8 @@ func_convert_path_front_back_pathsep ()
 # in func_to_host_file_result.
 func_to_host_file ()
 {
-  $opt_debug
+  $debug_cmd
+
   $to_host_file_cmd "$1"
 }
 # end func_to_host_file
@@ -1669,7 +2954,8 @@ func_to_host_file ()
 # in (the comma separated) LAZY, no conversion takes place.
 func_to_tool_file ()
 {
-  $opt_debug
+  $debug_cmd
+
   case ,$2, in
     *,"$to_tool_file_cmd",*)
       func_to_tool_file_result=$1
@@ -1687,7 +2973,7 @@ func_to_tool_file ()
 # Copy ARG to func_to_host_file_result.
 func_convert_file_noop ()
 {
-  func_to_host_file_result="$1"
+  func_to_host_file_result=$1
 }
 # end func_convert_file_noop
 
@@ -1698,11 +2984,12 @@ func_convert_file_noop ()
 # func_to_host_file_result.
 func_convert_file_msys_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_msys_to_w32 "$1"
-    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
+    func_to_host_file_result=$func_convert_core_msys_to_w32_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1714,8 +3001,9 @@ func_convert_file_msys_to_w32 ()
 # func_to_host_file_result.
 func_convert_file_cygwin_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
     # LT_CYGPATH in this case.
@@ -1731,11 +3019,12 @@ func_convert_file_cygwin_to_w32 ()
 # and a working winepath. Returns result in func_to_host_file_result.
 func_convert_file_nix_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_file_wine_to_w32 "$1"
-    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
+    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1747,12 +3036,13 @@ func_convert_file_nix_to_w32 ()
 # Returns result in func_to_host_file_result.
 func_convert_file_msys_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_msys_to_w32 "$1"
     func_cygpath -u "$func_convert_core_msys_to_w32_result"
-    func_to_host_file_result="$func_cygpath_result"
+    func_to_host_file_result=$func_cygpath_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1765,13 +3055,14 @@ func_convert_file_msys_to_cygwin ()
 # in func_to_host_file_result.
 func_convert_file_nix_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
     func_convert_core_file_wine_to_w32 "$1"
     func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
-    func_to_host_file_result="$func_cygpath_result"
+    func_to_host_file_result=$func_cygpath_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1781,7 +3072,7 @@ func_convert_file_nix_to_cygwin ()
 #############################################
 # $build to $host PATH CONVERSION FUNCTIONS #
 #############################################
-# invoked via `$to_host_path_cmd ARG'
+# invoked via '$to_host_path_cmd ARG'
 #
 # In each case, ARG is the path to be converted from $build to $host format.
 # The result will be available in $func_to_host_path_result.
@@ -1805,10 +3096,11 @@ func_convert_file_nix_to_cygwin ()
 to_host_path_cmd=
 func_init_to_host_path_cmd ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -z "$to_host_path_cmd"; then
     func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
-    to_host_path_cmd="func_convert_path_${func_stripname_result}"
+    to_host_path_cmd=func_convert_path_$func_stripname_result
   fi
 }
 
@@ -1818,7 +3110,8 @@ func_init_to_host_path_cmd ()
 # in func_to_host_path_result.
 func_to_host_path ()
 {
-  $opt_debug
+  $debug_cmd
+
   func_init_to_host_path_cmd
   $to_host_path_cmd "$1"
 }
@@ -1829,7 +3122,7 @@ func_to_host_path ()
 # Copy ARG to func_to_host_path_result.
 func_convert_path_noop ()
 {
-  func_to_host_path_result="$1"
+  func_to_host_path_result=$1
 }
 # end func_convert_path_noop
 
@@ -1840,8 +3133,9 @@ func_convert_path_noop ()
 # func_to_host_path_result.
 func_convert_path_msys_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # Remove leading and trailing path separator characters from ARG.  MSYS
     # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
@@ -1849,7 +3143,7 @@ func_convert_path_msys_to_w32 ()
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
-    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
+    func_to_host_path_result=$func_convert_core_msys_to_w32_result
     func_convert_path_check : ";" \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
@@ -1863,8 +3157,9 @@ func_convert_path_msys_to_w32 ()
 # func_to_host_file_result.
 func_convert_path_cygwin_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
@@ -1883,14 +3178,15 @@ func_convert_path_cygwin_to_w32 ()
 # a working winepath.  Returns result in func_to_host_file_result.
 func_convert_path_nix_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
-    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
+    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
     func_convert_path_check : ";" \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
@@ -1904,15 +3200,16 @@ func_convert_path_nix_to_w32 ()
 # Returns result in func_to_host_file_result.
 func_convert_path_msys_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
     func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
-    func_to_host_path_result="$func_cygpath_result"
+    func_to_host_path_result=$func_cygpath_result
     func_convert_path_check : : \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
@@ -1927,8 +3224,9 @@ func_convert_path_msys_to_cygwin ()
 # func_to_host_file_result.
 func_convert_path_nix_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # Remove leading and trailing path separator characters from
     # ARG. msys behavior is inconsistent here, cygpath turns them
@@ -1937,7 +3235,7 @@ func_convert_path_nix_to_cygwin ()
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
     func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
-    func_to_host_path_result="$func_cygpath_result"
+    func_to_host_path_result=$func_cygpath_result
     func_convert_path_check : : \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
@@ -1946,13 +3244,31 @@ func_convert_path_nix_to_cygwin ()
 # end func_convert_path_nix_to_cygwin
 
 
+# func_dll_def_p FILE
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with _LT_DLL_DEF_P in libtool.m4
+func_dll_def_p ()
+{
+  $debug_cmd
+
+  func_dll_def_p_tmp=`$SED -n \
+    -e 's/^[	 ]*//' \
+    -e '/^\(;.*\)*$/d' \
+    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
+    -e q \
+    "$1"`
+  test DEF = "$func_dll_def_p_tmp"
+}
+
+
 # func_mode_compile arg...
 func_mode_compile ()
 {
-    $opt_debug
+    $debug_cmd
+
     # Get the compilation command and the source file.
     base_compile=
-    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
     suppress_opt=yes
     suppress_output=
     arg_mode=normal
@@ -1965,12 +3281,12 @@ func_mode_compile ()
       case $arg_mode in
       arg  )
 	# do not "continue".  Instead, add this to base_compile
-	lastarg="$arg"
+	lastarg=$arg
 	arg_mode=normal
 	;;
 
       target )
-	libobj="$arg"
+	libobj=$arg
 	arg_mode=normal
 	continue
 	;;
@@ -1980,7 +3296,7 @@ func_mode_compile ()
 	case $arg in
 	-o)
 	  test -n "$libobj" && \
-	    func_fatal_error "you cannot specify \`-o' more than once"
+	    func_fatal_error "you cannot specify '-o' more than once"
 	  arg_mode=target
 	  continue
 	  ;;
@@ -2009,12 +3325,12 @@ func_mode_compile ()
 	  func_stripname '-Wc,' '' "$arg"
 	  args=$func_stripname_result
 	  lastarg=
-	  save_ifs="$IFS"; IFS=','
+	  save_ifs=$IFS; IFS=,
 	  for arg in $args; do
-	    IFS="$save_ifs"
+	    IFS=$save_ifs
 	    func_append_quoted lastarg "$arg"
 	  done
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
 	  func_stripname ' ' '' "$lastarg"
 	  lastarg=$func_stripname_result
 
@@ -2027,8 +3343,8 @@ func_mode_compile ()
 	  # Accept the current argument as the source file.
 	  # The previous "srcfile" becomes the current argument.
 	  #
-	  lastarg="$srcfile"
-	  srcfile="$arg"
+	  lastarg=$srcfile
+	  srcfile=$arg
 	  ;;
 	esac  #  case $arg
 	;;
@@ -2043,13 +3359,13 @@ func_mode_compile ()
       func_fatal_error "you must specify an argument for -Xcompile"
       ;;
     target)
-      func_fatal_error "you must specify a target with \`-o'"
+      func_fatal_error "you must specify a target with '-o'"
       ;;
     *)
       # Get the name of the library object.
       test -z "$libobj" && {
 	func_basename "$srcfile"
-	libobj="$func_basename_result"
+	libobj=$func_basename_result
       }
       ;;
     esac
@@ -2069,7 +3385,7 @@ func_mode_compile ()
     case $libobj in
     *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
     *)
-      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      func_fatal_error "cannot determine name of library object from '$libobj'"
       ;;
     esac
 
@@ -2078,8 +3394,8 @@ func_mode_compile ()
     for arg in $later; do
       case $arg in
       -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
+	test yes = "$build_libtool_libs" \
+	  || func_fatal_configuration "cannot build a shared library"
 	build_old_libs=no
 	continue
 	;;
@@ -2105,17 +3421,17 @@ func_mode_compile ()
     func_quote_for_eval "$libobj"
     test "X$libobj" != "X$func_quote_for_eval_result" \
       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
-      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+      && func_warning "libobj name '$libobj' may not contain shell special characters."
     func_dirname_and_basename "$obj" "/" ""
-    objname="$func_basename_result"
-    xdir="$func_dirname_result"
-    lobj=${xdir}$objdir/$objname
+    objname=$func_basename_result
+    xdir=$func_dirname_result
+    lobj=$xdir$objdir/$objname
 
     test -z "$base_compile" && \
       func_fatal_help "you must specify a compilation command"
 
     # Delete any leftover library objects.
-    if test "$build_old_libs" = yes; then
+    if test yes = "$build_old_libs"; then
       removelist="$obj $lobj $libobj ${libobj}T"
     else
       removelist="$lobj $libobj ${libobj}T"
@@ -2127,16 +3443,16 @@ func_mode_compile ()
       pic_mode=default
       ;;
     esac
-    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
       # non-PIC code in shared libraries is not supported
       pic_mode=default
     fi
 
     # Calculate the filename of the output object if compiler does
     # not support -o with -c
-    if test "$compiler_c_o" = no; then
-      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
-      lockfile="$output_obj.lock"
+    if test no = "$compiler_c_o"; then
+      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
+      lockfile=$output_obj.lock
     else
       output_obj=
       need_locks=no
@@ -2145,12 +3461,12 @@ func_mode_compile ()
 
     # Lock this critical section if it is needed
     # We use this script file to make the link, it avoids creating a new file
-    if test "$need_locks" = yes; then
+    if test yes = "$need_locks"; then
       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 	func_echo "Waiting for $lockfile to be removed"
 	sleep 2
       done
-    elif test "$need_locks" = warn; then
+    elif test warn = "$need_locks"; then
       if test -f "$lockfile"; then
 	$ECHO "\
 *** ERROR, $lockfile exists and contains:
@@ -2158,7 +3474,7 @@ func_mode_compile ()
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2180,11 +3496,11 @@ compiler."
     qsrcfile=$func_quote_for_eval_result
 
     # Only build a PIC object if we are building libtool libraries.
-    if test "$build_libtool_libs" = yes; then
+    if test yes = "$build_libtool_libs"; then
       # Without this assignment, base_compile gets emptied.
       fbsd_hideous_sh_bug=$base_compile
 
-      if test "$pic_mode" != no; then
+      if test no != "$pic_mode"; then
 	command="$base_compile $qsrcfile $pic_flag"
       else
 	# Don't build PIC code
@@ -2201,7 +3517,7 @@ compiler."
       func_show_eval_locale "$command"	\
           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
 
-      if test "$need_locks" = warn &&
+      if test warn = "$need_locks" &&
 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 	$ECHO "\
 *** ERROR, $lockfile contains:
@@ -2212,7 +3528,7 @@ $srcfile
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2228,20 +3544,20 @@ compiler."
       fi
 
       # Allow error messages only from the first compilation.
-      if test "$suppress_opt" = yes; then
+      if test yes = "$suppress_opt"; then
 	suppress_output=' >/dev/null 2>&1'
       fi
     fi
 
     # Only build a position-dependent object if we build old libraries.
-    if test "$build_old_libs" = yes; then
-      if test "$pic_mode" != yes; then
+    if test yes = "$build_old_libs"; then
+      if test yes != "$pic_mode"; then
 	# Don't build PIC code
 	command="$base_compile $qsrcfile$pie_flag"
       else
 	command="$base_compile $qsrcfile $pic_flag"
       fi
-      if test "$compiler_c_o" = yes; then
+      if test yes = "$compiler_c_o"; then
 	func_append command " -o $obj"
       fi
 
@@ -2250,7 +3566,7 @@ compiler."
       func_show_eval_locale "$command" \
         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
 
-      if test "$need_locks" = warn &&
+      if test warn = "$need_locks" &&
 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 	$ECHO "\
 *** ERROR, $lockfile contains:
@@ -2261,7 +3577,7 @@ $srcfile
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2281,7 +3597,7 @@ compiler."
       func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
 
       # Unlock the critical section if it was locked
-      if test "$need_locks" != no; then
+      if test no != "$need_locks"; then
 	removelist=$lockfile
         $RM "$lockfile"
       fi
@@ -2291,7 +3607,7 @@ compiler."
 }
 
 $opt_help || {
-  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
+  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
 }
 
 func_mode_help ()
@@ -2311,7 +3627,7 @@ func_mode_help ()
 Remove files from the build directory.
 
 RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 to RM.
 
 If FILE is a libtool library, object or program, all the files associated
@@ -2330,16 +3646,16 @@ This mode accepts the following additional options:
   -no-suppress      do not suppress compiler output for multiple passes
   -prefer-pic       try to build PIC objects only
   -prefer-non-pic   try to build non-PIC objects only
-  -shared           do not build a \`.o' file suitable for static linking
-  -static           only build a \`.o' file suitable for static linking
+  -shared           do not build a '.o' file suitable for static linking
+  -static           only build a '.o' file suitable for static linking
   -Wc,FLAG          pass FLAG directly to the compiler
 
-COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+COMPILE-COMMAND is a command to be used in creating a 'standard' object file
 from the given SOURCEFILE.
 
 The output file name is determined by removing the directory component from
-SOURCEFILE, then substituting the C source code suffix \`.c' with the
-library object suffix, \`.lo'."
+SOURCEFILE, then substituting the C source code suffix '.c' with the
+library object suffix, '.lo'."
         ;;
 
       execute)
@@ -2352,7 +3668,7 @@ This mode accepts the following additional options:
 
   -dlopen FILE      add the directory containing FILE to the library path
 
-This mode sets the library path environment variable according to \`-dlopen'
+This mode sets the library path environment variable according to '-dlopen'
 flags.
 
 If any of the ARGS are libtool executable wrappers, then they are translated
@@ -2371,7 +3687,7 @@ Complete the installation of libtool libraries.
 Each LIBDIR is a directory that contains libtool libraries.
 
 The commands that this mode executes may require superuser privileges.  Use
-the \`--dry-run' option if you just want to see what would be executed."
+the '--dry-run' option if you just want to see what would be executed."
         ;;
 
       install)
@@ -2381,7 +3697,7 @@ the \`--dry-run' option if you just want to see what would be executed."
 Install executables or libraries.
 
 INSTALL-COMMAND is the installation command.  The first component should be
-either the \`install' or \`cp' program.
+either the 'install' or 'cp' program.
 
 The following components of INSTALL-COMMAND are treated specially:
 
@@ -2407,7 +3723,7 @@ The following components of LINK-COMMAND are treated specially:
   -avoid-version    do not add a version suffix if possible
   -bindir BINDIR    specify path to binaries directory (for systems where
                     libraries must be found in the PATH setting at runtime)
-  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
   -export-symbols SYMFILE
@@ -2421,7 +3737,8 @@ The following components of LINK-COMMAND are treated specially:
   -no-install       link a not-installable executable
   -no-undefined     declare that a library does not refer to external symbols
   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
-  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -objectlist FILE  use a list of object files found in FILE to specify objects
+  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
   -precious-files-regex REGEX
                     don't remove output files matching REGEX
   -release RELEASE  specify package release information
@@ -2441,20 +3758,20 @@ The following components of LINK-COMMAND are treated specially:
   -Xlinker FLAG     pass linker-specific FLAG directly to the linker
   -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
 
-All other options (arguments beginning with \`-') are ignored.
+All other options (arguments beginning with '-') are ignored.
 
-Every other argument is treated as a filename.  Files ending in \`.la' are
+Every other argument is treated as a filename.  Files ending in '.la' are
 treated as uninstalled libtool libraries, other files are standard or library
 object files.
 
-If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
-only library objects (\`.lo' files) may be specified, and \`-rpath' is
+If the OUTPUT-FILE ends in '.la', then a libtool library is created,
+only library objects ('.lo' files) may be specified, and '-rpath' is
 required, except when creating a convenience library.
 
-If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
-using \`ar' and \`ranlib', or on Windows using \`lib'.
+If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
+using 'ar' and 'ranlib', or on Windows using 'lib'.
 
-If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
 is created, otherwise an executable program is created."
         ;;
 
@@ -2465,7 +3782,7 @@ is created, otherwise an executable program is created."
 Remove libraries from an installation directory.
 
 RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 to RM.
 
 If FILE is a libtool library, all the files associated with it are deleted.
@@ -2473,17 +3790,17 @@ Otherwise, only FILE itself is deleted using RM."
         ;;
 
       *)
-        func_fatal_help "invalid operation mode \`$opt_mode'"
+        func_fatal_help "invalid operation mode '$opt_mode'"
         ;;
     esac
 
     echo
-    $ECHO "Try \`$progname --help' for more information about other modes."
+    $ECHO "Try '$progname --help' for more information about other modes."
 }
 
 # Now that we've collected a possible --mode arg, show help if necessary
 if $opt_help; then
-  if test "$opt_help" = :; then
+  if test : = "$opt_help"; then
     func_mode_help
   else
     {
@@ -2491,7 +3808,7 @@ if $opt_help; then
       for opt_mode in compile link execute install finish uninstall clean; do
 	func_mode_help
       done
-    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
+    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
     {
       func_help noexit
       for opt_mode in compile link execute install finish uninstall clean; do
@@ -2499,7 +3816,7 @@ if $opt_help; then
 	func_mode_help
       done
     } |
-    sed '1d
+    $SED '1d
       /^When reporting/,/^Report/{
 	H
 	d
@@ -2516,16 +3833,17 @@ fi
 # func_mode_execute arg...
 func_mode_execute ()
 {
-    $opt_debug
+    $debug_cmd
+
     # The first argument is the command name.
-    cmd="$nonopt"
+    cmd=$nonopt
     test -z "$cmd" && \
       func_fatal_help "you must specify a COMMAND"
 
     # Handle -dlopen flags immediately.
     for file in $opt_dlopen; do
       test -f "$file" \
-	|| func_fatal_help "\`$file' is not a file"
+	|| func_fatal_help "'$file' is not a file"
 
       dir=
       case $file in
@@ -2535,7 +3853,7 @@ func_mode_execute ()
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$lib' is not a valid libtool archive"
+	  || func_fatal_help "'$lib' is not a valid libtool archive"
 
 	# Read the libtool library.
 	dlname=
@@ -2546,18 +3864,18 @@ func_mode_execute ()
 	if test -z "$dlname"; then
 	  # Warn if it was a shared library.
 	  test -n "$library_names" && \
-	    func_warning "\`$file' was not linked with \`-export-dynamic'"
+	    func_warning "'$file' was not linked with '-export-dynamic'"
 	  continue
 	fi
 
 	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 
 	if test -f "$dir/$objdir/$dlname"; then
 	  func_append dir "/$objdir"
 	else
 	  if test ! -f "$dir/$dlname"; then
-	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
 	  fi
 	fi
 	;;
@@ -2565,18 +3883,18 @@ func_mode_execute ()
       *.lo)
 	# Just add the directory containing the .lo file.
 	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 	;;
 
       *)
-	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
 	continue
 	;;
       esac
 
       # Get the absolute pathname.
       absdir=`cd "$dir" && pwd`
-      test -n "$absdir" && dir="$absdir"
+      test -n "$absdir" && dir=$absdir
 
       # Now add the directory to shlibpath_var.
       if eval "test -z \"\$$shlibpath_var\""; then
@@ -2588,7 +3906,7 @@ func_mode_execute ()
 
     # This variable tells wrapper scripts just to set shlibpath_var
     # rather than running their programs.
-    libtool_execute_magic="$magic"
+    libtool_execute_magic=$magic
 
     # Check if any of the arguments is a wrapper script.
     args=
@@ -2601,12 +3919,12 @@ func_mode_execute ()
 	if func_ltwrapper_script_p "$file"; then
 	  func_source "$file"
 	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
+	  file=$progdir/$program
 	elif func_ltwrapper_executable_p "$file"; then
 	  func_ltwrapper_scriptname "$file"
 	  func_source "$func_ltwrapper_scriptname_result"
 	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
+	  file=$progdir/$program
 	fi
 	;;
       esac
@@ -2614,7 +3932,15 @@ func_mode_execute ()
       func_append_quoted args "$file"
     done
 
-    if test "X$opt_dry_run" = Xfalse; then
+    if $opt_dry_run; then
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+	echo "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    else
       if test -n "$shlibpath_var"; then
 	# Export the shlibpath_var.
 	eval "export $shlibpath_var"
@@ -2631,25 +3957,18 @@ func_mode_execute ()
       done
 
       # Now prepare to actually exec the command.
-      exec_cmd="\$cmd$args"
-    else
-      # Display what would be done.
-      if test -n "$shlibpath_var"; then
-	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
-	echo "export $shlibpath_var"
-      fi
-      $ECHO "$cmd$args"
-      exit $EXIT_SUCCESS
+      exec_cmd=\$cmd$args
     fi
 }
 
-test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
+test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
 
 
 # func_mode_finish arg...
 func_mode_finish ()
 {
-    $opt_debug
+    $debug_cmd
+
     libs=
     libdirs=
     admincmds=
@@ -2663,11 +3982,11 @@ func_mode_finish ()
 	if func_lalib_unsafe_p "$opt"; then
 	  func_append libs " $opt"
 	else
-	  func_warning "\`$opt' is not a valid libtool archive"
+	  func_warning "'$opt' is not a valid libtool archive"
 	fi
 
       else
-	func_fatal_error "invalid argument \`$opt'"
+	func_fatal_error "invalid argument '$opt'"
       fi
     done
 
@@ -2682,12 +4001,12 @@ func_mode_finish ()
       # Remove sysroot references
       if $opt_dry_run; then
         for lib in $libs; do
-          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
+          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
         done
       else
         tmpdir=`func_mktempdir`
         for lib in $libs; do
-	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
+	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
 	    > $tmpdir/tmp-la
 	  mv -f $tmpdir/tmp-la $lib
 	done
@@ -2712,7 +4031,7 @@ func_mode_finish ()
     fi
 
     # Exit here if they wanted silent mode.
-    $opt_silent && exit $EXIT_SUCCESS
+    $opt_quiet && exit $EXIT_SUCCESS
 
     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
       echo "----------------------------------------------------------------------"
@@ -2723,27 +4042,27 @@ func_mode_finish ()
       echo
       echo "If you ever happen to want to link against installed libraries"
       echo "in a given directory, LIBDIR, you must either use libtool, and"
-      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
       echo "flag during linking and do at least one of the following:"
       if test -n "$shlibpath_var"; then
-	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
 	echo "     during execution"
       fi
       if test -n "$runpath_var"; then
-	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+	echo "   - add LIBDIR to the '$runpath_var' environment variable"
 	echo "     during linking"
       fi
       if test -n "$hardcode_libdir_flag_spec"; then
 	libdir=LIBDIR
 	eval flag=\"$hardcode_libdir_flag_spec\"
 
-	$ECHO "   - use the \`$flag' linker flag"
+	$ECHO "   - use the '$flag' linker flag"
       fi
       if test -n "$admincmds"; then
 	$ECHO "   - have your system administrator run these commands:$admincmds"
       fi
       if test -f /etc/ld.so.conf; then
-	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
       fi
       echo
 
@@ -2762,18 +4081,20 @@ func_mode_finish ()
     exit $EXIT_SUCCESS
 }
 
-test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
+test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
 
 
 # func_mode_install arg...
 func_mode_install ()
 {
-    $opt_debug
+    $debug_cmd
+
     # There may be an optional sh(1) argument at the beginning of
     # install_prog (especially on Windows NT).
-    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
        # Allow the use of GNU shtool's install command.
-       case $nonopt in *shtool*) :;; *) false;; esac; then
+       case $nonopt in *shtool*) :;; *) false;; esac
+    then
       # Aesthetically quote it.
       func_quote_for_eval "$nonopt"
       install_prog="$func_quote_for_eval_result "
@@ -2800,7 +4121,7 @@ func_mode_install ()
     opts=
     prev=
     install_type=
-    isdir=no
+    isdir=false
     stripme=
     no_mode=:
     for arg
@@ -2813,7 +4134,7 @@ func_mode_install ()
       fi
 
       case $arg in
-      -d) isdir=yes ;;
+      -d) isdir=: ;;
       -f)
 	if $install_cp; then :; else
 	  prev=$arg
@@ -2831,7 +4152,7 @@ func_mode_install ()
       *)
 	# If the previous option needed an argument, then skip it.
 	if test -n "$prev"; then
-	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
+	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
 	    arg2=$install_override_mode
 	    no_mode=false
 	  fi
@@ -2856,7 +4177,7 @@ func_mode_install ()
       func_fatal_help "you must specify an install program"
 
     test -n "$prev" && \
-      func_fatal_help "the \`$prev' option requires an argument"
+      func_fatal_help "the '$prev' option requires an argument"
 
     if test -n "$install_override_mode" && $no_mode; then
       if $install_cp; then :; else
@@ -2878,19 +4199,19 @@ func_mode_install ()
     dest=$func_stripname_result
 
     # Check to see that the destination is a directory.
-    test -d "$dest" && isdir=yes
-    if test "$isdir" = yes; then
-      destdir="$dest"
+    test -d "$dest" && isdir=:
+    if $isdir; then
+      destdir=$dest
       destname=
     else
       func_dirname_and_basename "$dest" "" "."
-      destdir="$func_dirname_result"
-      destname="$func_basename_result"
+      destdir=$func_dirname_result
+      destname=$func_basename_result
 
       # Not a directory, so check to see that there is only one file specified.
       set dummy $files; shift
       test "$#" -gt 1 && \
-	func_fatal_help "\`$dest' is not a directory"
+	func_fatal_help "'$dest' is not a directory"
     fi
     case $destdir in
     [\\/]* | [A-Za-z]:[\\/]*) ;;
@@ -2899,7 +4220,7 @@ func_mode_install ()
 	case $file in
 	*.lo) ;;
 	*)
-	  func_fatal_help "\`$destdir' must be an absolute directory name"
+	  func_fatal_help "'$destdir' must be an absolute directory name"
 	  ;;
 	esac
       done
@@ -2908,7 +4229,7 @@ func_mode_install ()
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
-    libtool_install_magic="$magic"
+    libtool_install_magic=$magic
 
     staticlibs=
     future_libdirs=
@@ -2928,7 +4249,7 @@ func_mode_install ()
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$file' is not a valid libtool archive"
+	  || func_fatal_help "'$file' is not a valid libtool archive"
 
 	library_names=
 	old_library=
@@ -2950,7 +4271,7 @@ func_mode_install ()
 	fi
 
 	func_dirname "$file" "/" ""
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 	func_append dir "$objdir"
 
 	if test -n "$relink_command"; then
@@ -2964,7 +4285,7 @@ func_mode_install ()
 	  # are installed into $libdir/../bin (currently, that works fine)
 	  # but it's something to keep an eye on.
 	  test "$inst_prefix_dir" = "$destdir" && \
-	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
 
 	  if test -n "$inst_prefix_dir"; then
 	    # Stick the inst_prefix_dir data into the link command.
@@ -2973,29 +4294,36 @@ func_mode_install ()
 	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
 	  fi
 
-	  func_warning "relinking \`$file'"
+	  func_warning "relinking '$file'"
 	  func_show_eval "$relink_command" \
-	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
 	fi
 
 	# See the names of the shared library.
 	set dummy $library_names; shift
 	if test -n "$1"; then
-	  realname="$1"
+	  realname=$1
 	  shift
 
-	  srcname="$realname"
-	  test -n "$relink_command" && srcname="$realname"T
+	  srcname=$realname
+	  test -n "$relink_command" && srcname=${realname}T
 
 	  # Install the shared library and build the symlinks.
 	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
 	      'exit $?'
-	  tstripme="$stripme"
+	  tstripme=$stripme
 	  case $host_os in
 	  cygwin* | mingw* | pw32* | cegcc*)
 	    case $realname in
 	    *.dll.a)
-	      tstripme=""
+	      tstripme=
+	      ;;
+	    esac
+	    ;;
+	  os2*)
+	    case $realname in
+	    *_dll.a)
+	      tstripme=
 	      ;;
 	    esac
 	    ;;
@@ -3006,7 +4334,7 @@ func_mode_install ()
 
 	  if test "$#" -gt 0; then
 	    # Delete the old symlinks, and create new ones.
-	    # Try `ln -sf' first, because the `ln' binary might depend on
+	    # Try 'ln -sf' first, because the 'ln' binary might depend on
 	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
 	    # so we also need to try rm && ln -s.
 	    for linkname
@@ -3017,14 +4345,14 @@ func_mode_install ()
 	  fi
 
 	  # Do each command in the postinstall commands.
-	  lib="$destdir/$realname"
+	  lib=$destdir/$realname
 	  func_execute_cmds "$postinstall_cmds" 'exit $?'
 	fi
 
 	# Install the pseudo-library for information purposes.
 	func_basename "$file"
-	name="$func_basename_result"
-	instname="$dir/$name"i
+	name=$func_basename_result
+	instname=$dir/${name}i
 	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
 
 	# Maybe install the static library, too.
@@ -3036,11 +4364,11 @@ func_mode_install ()
 
 	# Figure out destination file name, if it wasn't already specified.
 	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
+	  destfile=$destdir/$destname
 	else
 	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
+	  destfile=$func_basename_result
+	  destfile=$destdir/$destfile
 	fi
 
 	# Deduce the name of the destination old-style object file.
@@ -3050,11 +4378,11 @@ func_mode_install ()
 	  staticdest=$func_lo2o_result
 	  ;;
 	*.$objext)
-	  staticdest="$destfile"
+	  staticdest=$destfile
 	  destfile=
 	  ;;
 	*)
-	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
+	  func_fatal_help "cannot copy a libtool object to '$destfile'"
 	  ;;
 	esac
 
@@ -3063,7 +4391,7 @@ func_mode_install ()
 	  func_show_eval "$install_prog $file $destfile" 'exit $?'
 
 	# Install the old object if enabled.
-	if test "$build_old_libs" = yes; then
+	if test yes = "$build_old_libs"; then
 	  # Deduce the name of the old-style object file.
 	  func_lo2o "$file"
 	  staticobj=$func_lo2o_result
@@ -3075,23 +4403,23 @@ func_mode_install ()
       *)
 	# Figure out destination file name, if it wasn't already specified.
 	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
+	  destfile=$destdir/$destname
 	else
 	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
+	  destfile=$func_basename_result
+	  destfile=$destdir/$destfile
 	fi
 
 	# If the file is missing, and there is a .exe on the end, strip it
 	# because it is most likely a libtool script we actually want to
 	# install
-	stripped_ext=""
+	stripped_ext=
 	case $file in
 	  *.exe)
 	    if test ! -f "$file"; then
 	      func_stripname '' '.exe' "$file"
 	      file=$func_stripname_result
-	      stripped_ext=".exe"
+	      stripped_ext=.exe
 	    fi
 	    ;;
 	esac
@@ -3119,19 +4447,19 @@ func_mode_install ()
 
 	  # Check the variables that should have been set.
 	  test -z "$generated_by_libtool_version" && \
-	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
 
-	  finalize=yes
+	  finalize=:
 	  for lib in $notinst_deplibs; do
 	    # Check to see that each library is installed.
 	    libdir=
 	    if test -f "$lib"; then
 	      func_source "$lib"
 	    fi
-	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
+	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
 	    if test -n "$libdir" && test ! -f "$libfile"; then
-	      func_warning "\`$lib' has not been installed in \`$libdir'"
-	      finalize=no
+	      func_warning "'$lib' has not been installed in '$libdir'"
+	      finalize=false
 	    fi
 	  done
 
@@ -3139,29 +4467,29 @@ func_mode_install ()
 	  func_source "$wrapper"
 
 	  outputname=
-	  if test "$fast_install" = no && test -n "$relink_command"; then
+	  if test no = "$fast_install" && test -n "$relink_command"; then
 	    $opt_dry_run || {
-	      if test "$finalize" = yes; then
+	      if $finalize; then
 	        tmpdir=`func_mktempdir`
 		func_basename "$file$stripped_ext"
-		file="$func_basename_result"
-	        outputname="$tmpdir/$file"
+		file=$func_basename_result
+	        outputname=$tmpdir/$file
 	        # Replace the output file specification.
 	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
 
-	        $opt_silent || {
+	        $opt_quiet || {
 	          func_quote_for_expand "$relink_command"
 		  eval "func_echo $func_quote_for_expand_result"
 	        }
 	        if eval "$relink_command"; then :
 	          else
-		  func_error "error: relink \`$file' with the above command before installing it"
+		  func_error "error: relink '$file' with the above command before installing it"
 		  $opt_dry_run || ${RM}r "$tmpdir"
 		  continue
 	        fi
-	        file="$outputname"
+	        file=$outputname
 	      else
-	        func_warning "cannot relink \`$file'"
+	        func_warning "cannot relink '$file'"
 	      fi
 	    }
 	  else
@@ -3198,10 +4526,10 @@ func_mode_install ()
 
     for file in $staticlibs; do
       func_basename "$file"
-      name="$func_basename_result"
+      name=$func_basename_result
 
       # Set up the ranlib parameters.
-      oldlib="$destdir/$name"
+      oldlib=$destdir/$name
       func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
       tool_oldlib=$func_to_tool_file_result
 
@@ -3216,18 +4544,18 @@ func_mode_install ()
     done
 
     test -n "$future_libdirs" && \
-      func_warning "remember to run \`$progname --finish$future_libdirs'"
+      func_warning "remember to run '$progname --finish$future_libdirs'"
 
     if test -n "$current_libdirs"; then
       # Maybe just do a dry run.
       $opt_dry_run && current_libdirs=" -n$current_libdirs"
-      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
     else
       exit $EXIT_SUCCESS
     fi
 }
 
-test "$opt_mode" = install && func_mode_install ${1+"$@"}
+test install = "$opt_mode" && func_mode_install ${1+"$@"}
 
 
 # func_generate_dlsyms outputname originator pic_p
@@ -3235,16 +4563,17 @@ test "$opt_mode" = install && func_mode_install ${1+"$@"}
 # a dlpreopen symbol table.
 func_generate_dlsyms ()
 {
-    $opt_debug
-    my_outputname="$1"
-    my_originator="$2"
-    my_pic_p="${3-no}"
-    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    $debug_cmd
+
+    my_outputname=$1
+    my_originator=$2
+    my_pic_p=${3-false}
+    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
     my_dlsyms=
 
-    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
       if test -n "$NM" && test -n "$global_symbol_pipe"; then
-	my_dlsyms="${my_outputname}S.c"
+	my_dlsyms=${my_outputname}S.c
       else
 	func_error "not configured to extract global symbols from dlpreopened files"
       fi
@@ -3255,7 +4584,7 @@ func_generate_dlsyms ()
       "") ;;
       *.c)
 	# Discover the nlist of each of the dlfiles.
-	nlist="$output_objdir/${my_outputname}.nm"
+	nlist=$output_objdir/$my_outputname.nm
 
 	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
 
@@ -3263,34 +4592,36 @@ func_generate_dlsyms ()
 	func_verbose "creating $output_objdir/$my_dlsyms"
 
 	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
-/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
-/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
 
 #ifdef __cplusplus
 extern \"C\" {
 #endif
 
-#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
+#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
 #endif
 
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT_DLSYM_CONST
 #else
 # define LT_DLSYM_CONST const
 #endif
 
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
 /* External symbol declarations for the compiler. */\
 "
 
-	if test "$dlself" = yes; then
-	  func_verbose "generating symbol list for \`$output'"
+	if test yes = "$dlself"; then
+	  func_verbose "generating symbol list for '$output'"
 
 	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
 
@@ -3298,7 +4629,7 @@ extern \"C\" {
 	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
 	  for progfile in $progfiles; do
 	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
-	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
+	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
 	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
 	  done
 
@@ -3318,10 +4649,10 @@ extern \"C\" {
 
 	  # Prepare the list of exported symbols
 	  if test -z "$export_symbols"; then
-	    export_symbols="$output_objdir/$outputname.exp"
+	    export_symbols=$output_objdir/$outputname.exp
 	    $opt_dry_run || {
 	      $RM $export_symbols
-	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
 	      case $host in
 	      *cygwin* | *mingw* | *cegcc* )
                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
@@ -3331,7 +4662,7 @@ extern \"C\" {
 	    }
 	  else
 	    $opt_dry_run || {
-	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
 	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
 	      eval '$MV "$nlist"T "$nlist"'
 	      case $host in
@@ -3345,22 +4676,22 @@ extern \"C\" {
 	fi
 
 	for dlprefile in $dlprefiles; do
-	  func_verbose "extracting global C symbols from \`$dlprefile'"
+	  func_verbose "extracting global C symbols from '$dlprefile'"
 	  func_basename "$dlprefile"
-	  name="$func_basename_result"
+	  name=$func_basename_result
           case $host in
 	    *cygwin* | *mingw* | *cegcc* )
 	      # if an import library, we need to obtain dlname
 	      if func_win32_import_lib_p "$dlprefile"; then
 	        func_tr_sh "$dlprefile"
 	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
-	        dlprefile_dlbasename=""
+	        dlprefile_dlbasename=
 	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
 	          # Use subshell, to avoid clobbering current variable values
 	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
-	          if test -n "$dlprefile_dlname" ; then
+	          if test -n "$dlprefile_dlname"; then
 	            func_basename "$dlprefile_dlname"
-	            dlprefile_dlbasename="$func_basename_result"
+	            dlprefile_dlbasename=$func_basename_result
 	          else
 	            # no lafile. user explicitly requested -dlpreopen <import library>.
 	            $sharedlib_from_linklib_cmd "$dlprefile"
@@ -3368,7 +4699,7 @@ extern \"C\" {
 	          fi
 	        fi
 	        $opt_dry_run || {
-	          if test -n "$dlprefile_dlbasename" ; then
+	          if test -n "$dlprefile_dlbasename"; then
 	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
 	          else
 	            func_warning "Could not compute DLL name from $name"
@@ -3424,6 +4755,11 @@ extern \"C\" {
 	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
 	  fi
 
+	  func_show_eval '$RM "${nlist}I"'
+	  if test -n "$global_symbol_to_import"; then
+	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
+	  fi
+
 	  echo >> "$output_objdir/$my_dlsyms" "\
 
 /* The mapping between symbol names and symbols.  */
@@ -3432,11 +4768,30 @@ typedef struct {
   void *address;
 } lt_dlsymlist;
 extern LT_DLSYM_CONST lt_dlsymlist
-lt_${my_prefix}_LTX_preloaded_symbols[];
+lt_${my_prefix}_LTX_preloaded_symbols[];\
+"
+
+	  if test -s "$nlist"I; then
+	    echo >> "$output_objdir/$my_dlsyms" "\
+static void lt_syminit(void)
+{
+  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
+  for (; symbol->name; ++symbol)
+    {"
+	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
+	    echo >> "$output_objdir/$my_dlsyms" "\
+    }
+}"
+	  fi
+	  echo >> "$output_objdir/$my_dlsyms" "\
 LT_DLSYM_CONST lt_dlsymlist
 lt_${my_prefix}_LTX_preloaded_symbols[] =
-{\
-  { \"$my_originator\", (void *) 0 },"
+{ {\"$my_originator\", (void *) 0},"
+
+	  if test -s "$nlist"I; then
+	    echo >> "$output_objdir/$my_dlsyms" "\
+  {\"@INIT@\", (void *) &lt_syminit},"
+	  fi
 
 	  case $need_lib_prefix in
 	  no)
@@ -3478,9 +4833,7 @@ static const void *lt_preloaded_setup() {
 	  *-*-hpux*)
 	    pic_flag_for_symtable=" $pic_flag"  ;;
 	  *)
-	    if test "X$my_pic_p" != Xno; then
-	      pic_flag_for_symtable=" $pic_flag"
-	    fi
+	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
 	    ;;
 	  esac
 	  ;;
@@ -3497,10 +4850,10 @@ static const void *lt_preloaded_setup() {
 	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
 
 	# Clean up the generated files.
-	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
 
 	# Transform the symbol file into the correct name.
-	symfileobj="$output_objdir/${my_outputname}S.$objext"
+	symfileobj=$output_objdir/${my_outputname}S.$objext
 	case $host in
 	*cygwin* | *mingw* | *cegcc* )
 	  if test -f "$output_objdir/$my_outputname.def"; then
@@ -3518,7 +4871,7 @@ static const void *lt_preloaded_setup() {
 	esac
 	;;
       *)
-	func_fatal_error "unknown suffix for \`$my_dlsyms'"
+	func_fatal_error "unknown suffix for '$my_dlsyms'"
 	;;
       esac
     else
@@ -3532,6 +4885,32 @@ static const void *lt_preloaded_setup() {
     fi
 }
 
+# func_cygming_gnu_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is a GNU/binutils-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_gnu_implib_p ()
+{
+  $debug_cmd
+
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
+  test -n "$func_cygming_gnu_implib_tmp"
+}
+
+# func_cygming_ms_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is an MS-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_ms_implib_p ()
+{
+  $debug_cmd
+
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
+  test -n "$func_cygming_ms_implib_tmp"
+}
+
 # func_win32_libid arg
 # return the library type of file 'arg'
 #
@@ -3541,8 +4920,9 @@ static const void *lt_preloaded_setup() {
 # Despite the name, also deal with 64 bit binaries.
 func_win32_libid ()
 {
-  $opt_debug
-  win32_libid_type="unknown"
+  $debug_cmd
+
+  win32_libid_type=unknown
   win32_fileres=`file -L $1 2>/dev/null`
   case $win32_fileres in
   *ar\ archive\ import\ library*) # definitely import
@@ -3552,16 +4932,29 @@ func_win32_libid ()
     # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
        $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
-      func_to_tool_file "$1" func_convert_file_msys_to_w32
-      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
-	$SED -n -e '
+      case $nm_interface in
+      "MS dumpbin")
+	if func_cygming_ms_implib_p "$1" ||
+	   func_cygming_gnu_implib_p "$1"
+	then
+	  win32_nmres=import
+	else
+	  win32_nmres=
+	fi
+	;;
+      *)
+	func_to_tool_file "$1" func_convert_file_msys_to_w32
+	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
+	  $SED -n -e '
 	    1,100{
 		/ I /{
-		    s,.*,import,
+		    s|.*|import|
 		    p
 		    q
 		}
 	    }'`
+	;;
+      esac
       case $win32_nmres in
       import*)  win32_libid_type="x86 archive import";;
       *)        win32_libid_type="x86 archive static";;
@@ -3593,7 +4986,8 @@ func_win32_libid ()
 #    $sharedlib_from_linklib_result
 func_cygming_dll_for_implib ()
 {
-  $opt_debug
+  $debug_cmd
+
   sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
 }
 
@@ -3610,7 +5004,8 @@ func_cygming_dll_for_implib ()
 # specified import library.
 func_cygming_dll_for_implib_fallback_core ()
 {
-  $opt_debug
+  $debug_cmd
+
   match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
   $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
     $SED '/^Contents of section '"$match_literal"':/{
@@ -3646,8 +5041,8 @@ func_cygming_dll_for_implib_fallback_core ()
       /./p' |
     # we now have a list, one entry per line, of the stringified
     # contents of the appropriate section of all members of the
-    # archive which possess that section. Heuristic: eliminate
-    # all those which have a first or second character that is
+    # archive that possess that section. Heuristic: eliminate
+    # all those that have a first or second character that is
     # a '.' (that is, objdump's representation of an unprintable
     # character.) This should work for all archives with less than
     # 0x302f exports -- but will fail for DLLs whose name actually
@@ -3658,30 +5053,6 @@ func_cygming_dll_for_implib_fallback_core ()
     $SED -e '/^\./d;/^.\./d;q'
 }
 
-# func_cygming_gnu_implib_p ARG
-# This predicate returns with zero status (TRUE) if
-# ARG is a GNU/binutils-style import library. Returns
-# with nonzero status (FALSE) otherwise.
-func_cygming_gnu_implib_p ()
-{
-  $opt_debug
-  func_to_tool_file "$1" func_convert_file_msys_to_w32
-  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
-  test -n "$func_cygming_gnu_implib_tmp"
-}
-
-# func_cygming_ms_implib_p ARG
-# This predicate returns with zero status (TRUE) if
-# ARG is an MS-style import library. Returns
-# with nonzero status (FALSE) otherwise.
-func_cygming_ms_implib_p ()
-{
-  $opt_debug
-  func_to_tool_file "$1" func_convert_file_msys_to_w32
-  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
-  test -n "$func_cygming_ms_implib_tmp"
-}
-
 # func_cygming_dll_for_implib_fallback ARG
 # Platform-specific function to extract the
 # name of the DLL associated with the specified
@@ -3695,16 +5066,17 @@ func_cygming_ms_implib_p ()
 #    $sharedlib_from_linklib_result
 func_cygming_dll_for_implib_fallback ()
 {
-  $opt_debug
-  if func_cygming_gnu_implib_p "$1" ; then
+  $debug_cmd
+
+  if func_cygming_gnu_implib_p "$1"; then
     # binutils import library
     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
-  elif func_cygming_ms_implib_p "$1" ; then
+  elif func_cygming_ms_implib_p "$1"; then
     # ms-generated import library
     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
   else
     # unknown
-    sharedlib_from_linklib_result=""
+    sharedlib_from_linklib_result=
   fi
 }
 
@@ -3712,10 +5084,11 @@ func_cygming_dll_for_implib_fallback ()
 # func_extract_an_archive dir oldlib
 func_extract_an_archive ()
 {
-    $opt_debug
-    f_ex_an_ar_dir="$1"; shift
-    f_ex_an_ar_oldlib="$1"
-    if test "$lock_old_archive_extraction" = yes; then
+    $debug_cmd
+
+    f_ex_an_ar_dir=$1; shift
+    f_ex_an_ar_oldlib=$1
+    if test yes = "$lock_old_archive_extraction"; then
       lockfile=$f_ex_an_ar_oldlib.lock
       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 	func_echo "Waiting for $lockfile to be removed"
@@ -3724,7 +5097,7 @@ func_extract_an_archive ()
     fi
     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
 		   'stat=$?; rm -f "$lockfile"; exit $stat'
-    if test "$lock_old_archive_extraction" = yes; then
+    if test yes = "$lock_old_archive_extraction"; then
       $opt_dry_run || rm -f "$lockfile"
     fi
     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
@@ -3738,22 +5111,23 @@ func_extract_an_archive ()
 # func_extract_archives gentop oldlib ...
 func_extract_archives ()
 {
-    $opt_debug
-    my_gentop="$1"; shift
+    $debug_cmd
+
+    my_gentop=$1; shift
     my_oldlibs=${1+"$@"}
-    my_oldobjs=""
-    my_xlib=""
-    my_xabs=""
-    my_xdir=""
+    my_oldobjs=
+    my_xlib=
+    my_xabs=
+    my_xdir=
 
     for my_xlib in $my_oldlibs; do
       # Extract the objects.
       case $my_xlib in
-	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
 	*) my_xabs=`pwd`"/$my_xlib" ;;
       esac
       func_basename "$my_xlib"
-      my_xlib="$func_basename_result"
+      my_xlib=$func_basename_result
       my_xlib_u=$my_xlib
       while :; do
         case " $extracted_archives " in
@@ -3765,7 +5139,7 @@ func_extract_archives ()
 	esac
       done
       extracted_archives="$extracted_archives $my_xlib_u"
-      my_xdir="$my_gentop/$my_xlib_u"
+      my_xdir=$my_gentop/$my_xlib_u
 
       func_mkdir_p "$my_xdir"
 
@@ -3778,22 +5152,23 @@ func_extract_archives ()
 	  cd $my_xdir || exit $?
 	  darwin_archive=$my_xabs
 	  darwin_curdir=`pwd`
-	  darwin_base_archive=`basename "$darwin_archive"`
+	  func_basename "$darwin_archive"
+	  darwin_base_archive=$func_basename_result
 	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
 	  if test -n "$darwin_arches"; then
 	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
 	    darwin_arch=
 	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
-	    for darwin_arch in  $darwin_arches ; do
-	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
-	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+	    for darwin_arch in  $darwin_arches; do
+	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
+	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
+	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
+	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
 	      cd "$darwin_curdir"
-	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
 	    done # $darwin_arches
             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
-	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
 	    darwin_file=
 	    darwin_files=
 	    for darwin_file in $darwin_filelist; do
@@ -3815,7 +5190,7 @@ func_extract_archives ()
       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
     done
 
-    func_extract_archives_result="$my_oldobjs"
+    func_extract_archives_result=$my_oldobjs
 }
 
 
@@ -3830,7 +5205,7 @@ func_extract_archives ()
 #
 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
 # variable will take.  If 'yes', then the emitted script
-# will assume that the directory in which it is stored is
+# will assume that the directory where it is stored is
 # the $objdir directory.  This is a cygwin/mingw-specific
 # behavior.
 func_emit_wrapper ()
@@ -3841,7 +5216,7 @@ func_emit_wrapper ()
 #! $SHELL
 
 # $output - temporary wrapper script for $objdir/$outputname
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # The $output program cannot be directly executed until all the libtool
 # libraries that it depends on are installed.
@@ -3898,9 +5273,9 @@ _LTECHO_EOF'
 
 # Very basic option parsing. These options are (a) specific to
 # the libtool wrapper, (b) are identical between the wrapper
-# /script/ and the wrapper /executable/ which is used only on
+# /script/ and the wrapper /executable/ that is used only on
 # windows platforms, and (c) all begin with the string "--lt-"
-# (application programs are unlikely to have options which match
+# (application programs are unlikely to have options that match
 # this pattern).
 #
 # There are only two supported options: --lt-debug and
@@ -3933,7 +5308,7 @@ func_parse_lt_options ()
 
   # Print the debug banner immediately:
   if test -n \"\$lt_option_debug\"; then
-    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
+    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
   fi
 }
 
@@ -3944,7 +5319,7 @@ func_lt_dump_args ()
   lt_dump_args_N=1;
   for lt_arg
   do
-    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
+    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
     lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
   done
 }
@@ -3958,7 +5333,7 @@ func_exec_program_core ()
   *-*-mingw | *-*-os2* | *-cegcc*)
     $ECHO "\
       if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
+        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
         func_lt_dump_args \${1+\"\$@\"} 1>&2
       fi
       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
@@ -3968,7 +5343,7 @@ func_exec_program_core ()
   *)
     $ECHO "\
       if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
+        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
         func_lt_dump_args \${1+\"\$@\"} 1>&2
       fi
       exec \"\$progdir/\$program\" \${1+\"\$@\"}
@@ -4043,13 +5418,13 @@ func_exec_program ()
   test -n \"\$absdir\" && thisdir=\"\$absdir\"
 "
 
-	if test "$fast_install" = yes; then
+	if test yes = "$fast_install"; then
 	  $ECHO "\
   program=lt-'$outputname'$exeext
   progdir=\"\$thisdir/$objdir\"
 
   if test ! -f \"\$progdir/\$program\" ||
-     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
 
     file=\"\$\$-\$program\"
@@ -4066,7 +5441,7 @@ func_exec_program ()
     if test -n \"\$relink_command\"; then
       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
       else
-	$ECHO \"\$relink_command_output\" >&2
+	\$ECHO \"\$relink_command_output\" >&2
 	$RM \"\$progdir/\$file\"
 	exit 1
       fi
@@ -4101,7 +5476,7 @@ func_exec_program ()
 	fi
 
 	# Export our shlibpath_var if we have one.
-	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
 	  $ECHO "\
     # Add our own library path to $shlibpath_var
     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
@@ -4121,7 +5496,7 @@ func_exec_program ()
     fi
   else
     # The program doesn't exist.
-    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
     \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
     exit 1
@@ -4140,7 +5515,7 @@ func_emit_cwrapperexe_src ()
 	cat <<EOF
 
 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
-   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 
    The $output program cannot be directly executed until all the libtool
    libraries that it depends on are installed.
@@ -4175,47 +5550,45 @@ EOF
 #include <fcntl.h>
 #include <sys/stat.h>
 
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
 /* declarations of non-ANSI functions */
-#if defined(__MINGW32__)
+#if defined __MINGW32__
 # ifdef __STRICT_ANSI__
 int _putenv (const char *);
 # endif
-#elif defined(__CYGWIN__)
+#elif defined __CYGWIN__
 # ifdef __STRICT_ANSI__
 char *realpath (const char *, char *);
 int putenv (char *);
 int setenv (const char *, const char *, int);
 # endif
-/* #elif defined (other platforms) ... */
+/* #elif defined other_platform || defined ... */
 #endif
 
 /* portability defines, excluding path handling macros */
-#if defined(_MSC_VER)
+#if defined _MSC_VER
 # define setmode _setmode
 # define stat    _stat
 # define chmod   _chmod
 # define getcwd  _getcwd
 # define putenv  _putenv
 # define S_IXUSR _S_IEXEC
-# ifndef _INTPTR_T_DEFINED
-#  define _INTPTR_T_DEFINED
-#  define intptr_t int
-# endif
-#elif defined(__MINGW32__)
+#elif defined __MINGW32__
 # define setmode _setmode
 # define stat    _stat
 # define chmod   _chmod
 # define getcwd  _getcwd
 # define putenv  _putenv
-#elif defined(__CYGWIN__)
+#elif defined __CYGWIN__
 # define HAVE_SETENV
 # define FOPEN_WB "wb"
-/* #elif defined (other platforms) ... */
+/* #elif defined other platforms ... */
 #endif
 
-#if defined(PATH_MAX)
+#if defined PATH_MAX
 # define LT_PATHMAX PATH_MAX
-#elif defined(MAXPATHLEN)
+#elif defined MAXPATHLEN
 # define LT_PATHMAX MAXPATHLEN
 #else
 # define LT_PATHMAX 1024
@@ -4234,8 +5607,8 @@ int setenv (const char *, const char *, int);
 # define PATH_SEPARATOR ':'
 #endif
 
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-  defined (__OS2__)
+#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
+  defined __OS2__
 # define HAVE_DOS_BASED_FILE_SYSTEM
 # define FOPEN_WB "wb"
 # ifndef DIR_SEPARATOR_2
@@ -4268,10 +5641,10 @@ int setenv (const char *, const char *, int);
 
 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
 #define XFREE(stale) do { \
-  if (stale) { free ((void *) stale); stale = 0; } \
+  if (stale) { free (stale); stale = 0; } \
 } while (0)
 
-#if defined(LT_DEBUGWRAPPER)
+#if defined LT_DEBUGWRAPPER
 static int lt_debug = 1;
 #else
 static int lt_debug = 0;
@@ -4300,11 +5673,16 @@ void lt_dump_script (FILE *f);
 EOF
 
 	    cat <<EOF
-volatile const char * MAGIC_EXE = "$magic_exe";
+#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
+# define externally_visible volatile
+#else
+# define externally_visible __attribute__((externally_visible)) volatile
+#endif
+externally_visible const char * MAGIC_EXE = "$magic_exe";
 const char * LIB_PATH_VARNAME = "$shlibpath_var";
 EOF
 
-	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
               func_to_host_path "$temp_rpath"
 	      cat <<EOF
 const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
@@ -4328,7 +5706,7 @@ const char * EXE_PATH_VALUE   = "";
 EOF
 	    fi
 
-	    if test "$fast_install" = yes; then
+	    if test yes = "$fast_install"; then
 	      cat <<EOF
 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
 EOF
@@ -4357,12 +5735,12 @@ main (int argc, char *argv[])
   char *actual_cwrapper_name;
   char *target_name;
   char *lt_argv_zero;
-  intptr_t rval = 127;
+  int rval = 127;
 
   int i;
 
   program_name = (char *) xstrdup (base_name (argv[0]));
-  newargz = XMALLOC (char *, argc + 1);
+  newargz = XMALLOC (char *, (size_t) argc + 1);
 
   /* very simple arg parsing; don't want to rely on getopt
    * also, copy all non cwrapper options to newargz, except
@@ -4371,10 +5749,10 @@ main (int argc, char *argv[])
   newargc=0;
   for (i = 1; i < argc; i++)
     {
-      if (strcmp (argv[i], dumpscript_opt) == 0)
+      if (STREQ (argv[i], dumpscript_opt))
 	{
 EOF
-	    case "$host" in
+	    case $host in
 	      *mingw* | *cygwin* )
 		# make stdout use "unix" line endings
 		echo "          setmode(1,_O_BINARY);"
@@ -4385,12 +5763,12 @@ EOF
 	  lt_dump_script (stdout);
 	  return 0;
 	}
-      if (strcmp (argv[i], debug_opt) == 0)
+      if (STREQ (argv[i], debug_opt))
 	{
           lt_debug = 1;
           continue;
 	}
-      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
+      if (STREQ (argv[i], ltwrapper_option_prefix))
         {
           /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
              namespace, but it is not one of the ones we know about and
@@ -4413,7 +5791,7 @@ EOF
 EOF
 	    cat <<EOF
   /* The GNU banner must be the first non-error debug message */
-  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
+  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
 EOF
 	    cat <<"EOF"
   lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
@@ -4524,7 +5902,7 @@ EOF
 		cat <<"EOF"
   /* execv doesn't actually work on mingw as expected on unix */
   newargz = prepare_spawn (newargz);
-  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
   if (rval == -1)
     {
       /* failed to start process */
@@ -4569,7 +5947,7 @@ base_name (const char *name)
 {
   const char *base;
 
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
   /* Skip over the disk name in MSDOS pathnames. */
   if (isalpha ((unsigned char) name[0]) && name[1] == ':')
     name += 2;
@@ -4628,7 +6006,7 @@ find_executable (const char *wrapper)
   const char *p_next;
   /* static buffer for getcwd */
   char tmp[LT_PATHMAX + 1];
-  int tmp_len;
+  size_t tmp_len;
   char *concat_name;
 
   lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
@@ -4638,7 +6016,7 @@ find_executable (const char *wrapper)
     return NULL;
 
   /* Absolute path? */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
   if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
     {
       concat_name = xstrdup (wrapper);
@@ -4656,7 +6034,7 @@ find_executable (const char *wrapper)
 	    return concat_name;
 	  XFREE (concat_name);
 	}
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
     }
 #endif
 
@@ -4679,7 +6057,7 @@ find_executable (const char *wrapper)
 	      for (q = p; *q; q++)
 		if (IS_PATH_SEPARATOR (*q))
 		  break;
-	      p_len = q - p;
+	      p_len = (size_t) (q - p);
 	      p_next = (*q == '\0' ? q : q + 1);
 	      if (p_len == 0)
 		{
@@ -4798,7 +6176,7 @@ strendzap (char *str, const char *pat)
   if (patlen <= len)
     {
       str += len - patlen;
-      if (strcmp (str, pat) == 0)
+      if (STREQ (str, pat))
 	*str = '\0';
     }
   return str;
@@ -4863,7 +6241,7 @@ lt_setenv (const char *name, const char *value)
     char *str = xstrdup (value);
     setenv (name, str, 1);
 #else
-    int len = strlen (name) + 1 + strlen (value) + 1;
+    size_t len = strlen (name) + 1 + strlen (value) + 1;
     char *str = XMALLOC (char, len);
     sprintf (str, "%s=%s", name, value);
     if (putenv (str) != EXIT_SUCCESS)
@@ -4880,8 +6258,8 @@ lt_extend_str (const char *orig_value, const char *add, int to_end)
   char *new_value;
   if (orig_value && *orig_value)
     {
-      int orig_value_len = strlen (orig_value);
-      int add_len = strlen (add);
+      size_t orig_value_len = strlen (orig_value);
+      size_t add_len = strlen (add);
       new_value = XMALLOC (char, add_len + orig_value_len + 1);
       if (to_end)
         {
@@ -4912,10 +6290,10 @@ lt_update_exe_path (const char *name, const char *value)
     {
       char *new_value = lt_extend_str (getenv (name), value, 0);
       /* some systems can't cope with a ':'-terminated path #' */
-      int len = strlen (new_value);
-      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+      size_t len = strlen (new_value);
+      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
         {
-          new_value[len-1] = '\0';
+          new_value[--len] = '\0';
         }
       lt_setenv (name, new_value);
       XFREE (new_value);
@@ -5082,27 +6460,47 @@ EOF
 # True if ARG is an import lib, as indicated by $file_magic_cmd
 func_win32_import_lib_p ()
 {
-    $opt_debug
+    $debug_cmd
+
     case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
     *import*) : ;;
     *) false ;;
     esac
 }
 
+# func_suncc_cstd_abi
+# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
+# Several compiler flags select an ABI that is incompatible with the
+# Cstd library. Avoid specifying it if any are in CXXFLAGS.
+func_suncc_cstd_abi ()
+{
+    $debug_cmd
+
+    case " $compile_command " in
+    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
+      suncc_use_cstd_abi=no
+      ;;
+    *)
+      suncc_use_cstd_abi=yes
+      ;;
+    esac
+}
+
 # func_mode_link arg...
 func_mode_link ()
 {
-    $opt_debug
+    $debug_cmd
+
     case $host in
     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
       # It is impossible to link a dll without this setting, and
       # we shouldn't force the makefile maintainer to figure out
-      # which system we are compiling for in order to pass an extra
+      # what system we are compiling for in order to pass an extra
       # flag for every libtool invocation.
       # allow_undefined=no
 
       # FIXME: Unfortunately, there are problems with the above when trying
-      # to make a dll which has undefined symbols, in which case not
+      # to make a dll that has undefined symbols, in which case not
       # even a static library is built.  For now, we need to specify
       # -no-undefined on the libtool link line when we can be certain
       # that all symbols are satisfied, otherwise we get a static library.
@@ -5146,10 +6544,11 @@ func_mode_link ()
     module=no
     no_install=no
     objs=
+    os2dllname=
     non_pic_objects=
     precious_files_regex=
     prefer_static_libs=no
-    preload=no
+    preload=false
     prev=
     prevarg=
     release=
@@ -5161,7 +6560,7 @@ func_mode_link ()
     vinfo=
     vinfo_number=no
     weak_libs=
-    single_module="${wl}-single_module"
+    single_module=$wl-single_module
     func_infer_tag $base_compile
 
     # We need to know -static, to get the right output filenames.
@@ -5169,15 +6568,15 @@ func_mode_link ()
     do
       case $arg in
       -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
+	test yes != "$build_libtool_libs" \
+	  && func_fatal_configuration "cannot build a shared library"
 	build_old_libs=no
 	break
 	;;
       -all-static | -static | -static-libtool-libs)
 	case $arg in
 	-all-static)
-	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
 	    func_warning "complete static linking is impossible in this configuration"
 	  fi
 	  if test -n "$link_static_flag"; then
@@ -5210,7 +6609,7 @@ func_mode_link ()
 
     # Go through the arguments, transforming them on the way.
     while test "$#" -gt 0; do
-      arg="$1"
+      arg=$1
       shift
       func_quote_for_eval "$arg"
       qarg=$func_quote_for_eval_unquoted_result
@@ -5227,21 +6626,21 @@ func_mode_link ()
 
 	case $prev in
 	bindir)
-	  bindir="$arg"
+	  bindir=$arg
 	  prev=
 	  continue
 	  ;;
 	dlfiles|dlprefiles)
-	  if test "$preload" = no; then
+	  $preload || {
 	    # Add the symbol object into the linking commands.
 	    func_append compile_command " @SYMFILE@"
 	    func_append finalize_command " @SYMFILE@"
-	    preload=yes
-	  fi
+	    preload=:
+	  }
 	  case $arg in
 	  *.la | *.lo) ;;  # We handle these cases below.
 	  force)
-	    if test "$dlself" = no; then
+	    if test no = "$dlself"; then
 	      dlself=needless
 	      export_dynamic=yes
 	    fi
@@ -5249,9 +6648,9 @@ func_mode_link ()
 	    continue
 	    ;;
 	  self)
-	    if test "$prev" = dlprefiles; then
+	    if test dlprefiles = "$prev"; then
 	      dlself=yes
-	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
 	      dlself=yes
 	    else
 	      dlself=needless
@@ -5261,7 +6660,7 @@ func_mode_link ()
 	    continue
 	    ;;
 	  *)
-	    if test "$prev" = dlfiles; then
+	    if test dlfiles = "$prev"; then
 	      func_append dlfiles " $arg"
 	    else
 	      func_append dlprefiles " $arg"
@@ -5272,14 +6671,14 @@ func_mode_link ()
 	  esac
 	  ;;
 	expsyms)
-	  export_symbols="$arg"
+	  export_symbols=$arg
 	  test -f "$arg" \
-	    || func_fatal_error "symbol file \`$arg' does not exist"
+	    || func_fatal_error "symbol file '$arg' does not exist"
 	  prev=
 	  continue
 	  ;;
 	expsyms_regex)
-	  export_symbols_regex="$arg"
+	  export_symbols_regex=$arg
 	  prev=
 	  continue
 	  ;;
@@ -5297,7 +6696,13 @@ func_mode_link ()
 	  continue
 	  ;;
 	inst_prefix)
-	  inst_prefix_dir="$arg"
+	  inst_prefix_dir=$arg
+	  prev=
+	  continue
+	  ;;
+	mllvm)
+	  # Clang does not use LLVM to link, so we can simply discard any
+	  # '-mllvm $arg' options when doing the link step.
 	  prev=
 	  continue
 	  ;;
@@ -5321,21 +6726,21 @@ func_mode_link ()
 
 		if test -z "$pic_object" ||
 		   test -z "$non_pic_object" ||
-		   test "$pic_object" = none &&
-		   test "$non_pic_object" = none; then
-		  func_fatal_error "cannot find name of object for \`$arg'"
+		   test none = "$pic_object" &&
+		   test none = "$non_pic_object"; then
+		  func_fatal_error "cannot find name of object for '$arg'"
 		fi
 
 		# Extract subdirectory from the argument.
 		func_dirname "$arg" "/" ""
-		xdir="$func_dirname_result"
+		xdir=$func_dirname_result
 
-		if test "$pic_object" != none; then
+		if test none != "$pic_object"; then
 		  # Prepend the subdirectory the object is found in.
-		  pic_object="$xdir$pic_object"
+		  pic_object=$xdir$pic_object
 
-		  if test "$prev" = dlfiles; then
-		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		  if test dlfiles = "$prev"; then
+		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
 		      func_append dlfiles " $pic_object"
 		      prev=
 		      continue
@@ -5346,7 +6751,7 @@ func_mode_link ()
 		  fi
 
 		  # CHECK ME:  I think I busted this.  -Ossama
-		  if test "$prev" = dlprefiles; then
+		  if test dlprefiles = "$prev"; then
 		    # Preload the old-style object.
 		    func_append dlprefiles " $pic_object"
 		    prev=
@@ -5354,23 +6759,23 @@ func_mode_link ()
 
 		  # A PIC object.
 		  func_append libobjs " $pic_object"
-		  arg="$pic_object"
+		  arg=$pic_object
 		fi
 
 		# Non-PIC object.
-		if test "$non_pic_object" != none; then
+		if test none != "$non_pic_object"; then
 		  # Prepend the subdirectory the object is found in.
-		  non_pic_object="$xdir$non_pic_object"
+		  non_pic_object=$xdir$non_pic_object
 
 		  # A standard non-PIC object
 		  func_append non_pic_objects " $non_pic_object"
-		  if test -z "$pic_object" || test "$pic_object" = none ; then
-		    arg="$non_pic_object"
+		  if test -z "$pic_object" || test none = "$pic_object"; then
+		    arg=$non_pic_object
 		  fi
 		else
 		  # If the PIC object exists, use it instead.
 		  # $xdir was prepended to $pic_object above.
-		  non_pic_object="$pic_object"
+		  non_pic_object=$pic_object
 		  func_append non_pic_objects " $non_pic_object"
 		fi
 	      else
@@ -5378,7 +6783,7 @@ func_mode_link ()
 		if $opt_dry_run; then
 		  # Extract subdirectory from the argument.
 		  func_dirname "$arg" "/" ""
-		  xdir="$func_dirname_result"
+		  xdir=$func_dirname_result
 
 		  func_lo2o "$arg"
 		  pic_object=$xdir$objdir/$func_lo2o_result
@@ -5386,24 +6791,29 @@ func_mode_link ()
 		  func_append libobjs " $pic_object"
 		  func_append non_pic_objects " $non_pic_object"
 	        else
-		  func_fatal_error "\`$arg' is not a valid libtool object"
+		  func_fatal_error "'$arg' is not a valid libtool object"
 		fi
 	      fi
 	    done
 	  else
-	    func_fatal_error "link input file \`$arg' does not exist"
+	    func_fatal_error "link input file '$arg' does not exist"
 	  fi
 	  arg=$save_arg
 	  prev=
 	  continue
 	  ;;
+	os2dllname)
+	  os2dllname=$arg
+	  prev=
+	  continue
+	  ;;
 	precious_regex)
-	  precious_files_regex="$arg"
+	  precious_files_regex=$arg
 	  prev=
 	  continue
 	  ;;
 	release)
-	  release="-$arg"
+	  release=-$arg
 	  prev=
 	  continue
 	  ;;
@@ -5415,7 +6825,7 @@ func_mode_link ()
 	    func_fatal_error "only absolute run-paths are allowed"
 	    ;;
 	  esac
-	  if test "$prev" = rpath; then
+	  if test rpath = "$prev"; then
 	    case "$rpath " in
 	    *" $arg "*) ;;
 	    *) func_append rpath " $arg" ;;
@@ -5430,7 +6840,7 @@ func_mode_link ()
 	  continue
 	  ;;
 	shrext)
-	  shrext_cmds="$arg"
+	  shrext_cmds=$arg
 	  prev=
 	  continue
 	  ;;
@@ -5470,7 +6880,7 @@ func_mode_link ()
 	esac
       fi # test -n "$prev"
 
-      prevarg="$arg"
+      prevarg=$arg
 
       case $arg in
       -all-static)
@@ -5484,7 +6894,7 @@ func_mode_link ()
 
       -allow-undefined)
 	# FIXME: remove this flag sometime in the future.
-	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+	func_fatal_error "'-allow-undefined' must not be used because it is the default"
 	;;
 
       -avoid-version)
@@ -5516,7 +6926,7 @@ func_mode_link ()
 	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
 	  func_fatal_error "more than one -exported-symbols argument is not allowed"
 	fi
-	if test "X$arg" = "X-export-symbols"; then
+	if test X-export-symbols = "X$arg"; then
 	  prev=expsyms
 	else
 	  prev=expsyms_regex
@@ -5550,9 +6960,9 @@ func_mode_link ()
 	func_stripname "-L" '' "$arg"
 	if test -z "$func_stripname_result"; then
 	  if test "$#" -gt 0; then
-	    func_fatal_error "require no space between \`-L' and \`$1'"
+	    func_fatal_error "require no space between '-L' and '$1'"
 	  else
-	    func_fatal_error "need path for \`-L' option"
+	    func_fatal_error "need path for '-L' option"
 	  fi
 	fi
 	func_resolve_sysroot "$func_stripname_result"
@@ -5563,8 +6973,8 @@ func_mode_link ()
 	*)
 	  absdir=`cd "$dir" && pwd`
 	  test -z "$absdir" && \
-	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
-	  dir="$absdir"
+	    func_fatal_error "cannot determine absolute directory name of '$dir'"
+	  dir=$absdir
 	  ;;
 	esac
 	case "$deplibs " in
@@ -5599,7 +7009,7 @@ func_mode_link ()
 	;;
 
       -l*)
-	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
 	  case $host in
 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
 	    # These systems don't actually have a C or math library (as such)
@@ -5607,11 +7017,11 @@ func_mode_link ()
 	    ;;
 	  *-*-os2*)
 	    # These systems don't actually have a C library (as such)
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
 	    # Do not include libc due to us having libc/libc_r.
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  *-*-rhapsody* | *-*-darwin1.[012])
 	    # Rhapsody C and math libraries are in the System framework
@@ -5620,16 +7030,16 @@ func_mode_link ()
 	    ;;
 	  *-*-sco3.2v5* | *-*-sco5v6*)
 	    # Causes problems with __ctype
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
 	    # Compiler inserts libc in the correct place for threads to work
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  esac
-	elif test "X$arg" = "X-lc_r"; then
+	elif test X-lc_r = "X$arg"; then
 	 case $host in
-	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
 	   # Do not include libc_r directly, use -pthread flag.
 	   continue
 	   ;;
@@ -5639,6 +7049,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -mllvm)
+	prev=mllvm
+	continue
+	;;
+
       -module)
 	module=yes
 	continue
@@ -5668,7 +7083,7 @@ func_mode_link ()
 	;;
 
       -multi_module)
-	single_module="${wl}-multi_module"
+	single_module=$wl-multi_module
 	continue
 	;;
 
@@ -5682,8 +7097,8 @@ func_mode_link ()
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
 	  # The PATH hackery in wrapper scripts is required on Windows
 	  # and Darwin in order for the loader to find any dlls it needs.
-	  func_warning "\`-no-install' is ignored for $host"
-	  func_warning "assuming \`-no-fast-install' instead"
+	  func_warning "'-no-install' is ignored for $host"
+	  func_warning "assuming '-no-fast-install' instead"
 	  fast_install=no
 	  ;;
 	*) no_install=yes ;;
@@ -5701,6 +7116,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -os2dllname)
+	prev=os2dllname
+	continue
+	;;
+
       -o) prev=output ;;
 
       -precious-files-regex)
@@ -5788,14 +7208,14 @@ func_mode_link ()
 	func_stripname '-Wc,' '' "$arg"
 	args=$func_stripname_result
 	arg=
-	save_ifs="$IFS"; IFS=','
+	save_ifs=$IFS; IFS=,
 	for flag in $args; do
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
           func_quote_for_eval "$flag"
 	  func_append arg " $func_quote_for_eval_result"
 	  func_append compiler_flags " $func_quote_for_eval_result"
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 	func_stripname ' ' '' "$arg"
 	arg=$func_stripname_result
 	;;
@@ -5804,15 +7224,15 @@ func_mode_link ()
 	func_stripname '-Wl,' '' "$arg"
 	args=$func_stripname_result
 	arg=
-	save_ifs="$IFS"; IFS=','
+	save_ifs=$IFS; IFS=,
 	for flag in $args; do
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
           func_quote_for_eval "$flag"
 	  func_append arg " $wl$func_quote_for_eval_result"
 	  func_append compiler_flags " $wl$func_quote_for_eval_result"
 	  func_append linker_flags " $func_quote_for_eval_result"
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 	func_stripname ' ' '' "$arg"
 	arg=$func_stripname_result
 	;;
@@ -5835,7 +7255,7 @@ func_mode_link ()
       # -msg_* for osf cc
       -msg_*)
 	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
 
       # Flags to be passed through unchanged, with rationale:
@@ -5847,25 +7267,46 @@ func_mode_link ()
       # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
       # -F/path              path to uninstalled frameworks, gcc on darwin
       # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
+      # -fstack-protector*   stack protector flags for GCC
       # @file                GCC response files
       # -tp=*                Portland pgcc target processor selection
       # --sysroot=*          for sysroot support
-      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -stdlib=*            select c++ std lib with clang
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
-      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
+      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
         func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
         func_append compile_command " $arg"
         func_append finalize_command " $arg"
         func_append compiler_flags " $arg"
         continue
         ;;
 
+      -Z*)
+        if test os2 = "`expr $host : '.*\(os2\)'`"; then
+          # OS/2 uses -Zxxx to specify OS/2-specific options
+	  compiler_flags="$compiler_flags $arg"
+	  func_append compile_command " $arg"
+	  func_append finalize_command " $arg"
+	  case $arg in
+	  -Zlinker | -Zstack)
+	    prev=xcompiler
+	    ;;
+	  esac
+	  continue
+        else
+	  # Otherwise treat like 'Some other compiler flag' below
+	  func_quote_for_eval "$arg"
+	  arg=$func_quote_for_eval_result
+        fi
+	;;
+
       # Some other compiler flag.
       -* | +*)
         func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
 
       *.$objext)
@@ -5886,21 +7327,21 @@ func_mode_link ()
 
 	  if test -z "$pic_object" ||
 	     test -z "$non_pic_object" ||
-	     test "$pic_object" = none &&
-	     test "$non_pic_object" = none; then
-	    func_fatal_error "cannot find name of object for \`$arg'"
+	     test none = "$pic_object" &&
+	     test none = "$non_pic_object"; then
+	    func_fatal_error "cannot find name of object for '$arg'"
 	  fi
 
 	  # Extract subdirectory from the argument.
 	  func_dirname "$arg" "/" ""
-	  xdir="$func_dirname_result"
+	  xdir=$func_dirname_result
 
-	  if test "$pic_object" != none; then
+	  test none = "$pic_object" || {
 	    # Prepend the subdirectory the object is found in.
-	    pic_object="$xdir$pic_object"
+	    pic_object=$xdir$pic_object
 
-	    if test "$prev" = dlfiles; then
-	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+	    if test dlfiles = "$prev"; then
+	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
 		func_append dlfiles " $pic_object"
 		prev=
 		continue
@@ -5911,7 +7352,7 @@ func_mode_link ()
 	    fi
 
 	    # CHECK ME:  I think I busted this.  -Ossama
-	    if test "$prev" = dlprefiles; then
+	    if test dlprefiles = "$prev"; then
 	      # Preload the old-style object.
 	      func_append dlprefiles " $pic_object"
 	      prev=
@@ -5919,23 +7360,23 @@ func_mode_link ()
 
 	    # A PIC object.
 	    func_append libobjs " $pic_object"
-	    arg="$pic_object"
-	  fi
+	    arg=$pic_object
+	  }
 
 	  # Non-PIC object.
-	  if test "$non_pic_object" != none; then
+	  if test none != "$non_pic_object"; then
 	    # Prepend the subdirectory the object is found in.
-	    non_pic_object="$xdir$non_pic_object"
+	    non_pic_object=$xdir$non_pic_object
 
 	    # A standard non-PIC object
 	    func_append non_pic_objects " $non_pic_object"
-	    if test -z "$pic_object" || test "$pic_object" = none ; then
-	      arg="$non_pic_object"
+	    if test -z "$pic_object" || test none = "$pic_object"; then
+	      arg=$non_pic_object
 	    fi
 	  else
 	    # If the PIC object exists, use it instead.
 	    # $xdir was prepended to $pic_object above.
-	    non_pic_object="$pic_object"
+	    non_pic_object=$pic_object
 	    func_append non_pic_objects " $non_pic_object"
 	  fi
 	else
@@ -5943,7 +7384,7 @@ func_mode_link ()
 	  if $opt_dry_run; then
 	    # Extract subdirectory from the argument.
 	    func_dirname "$arg" "/" ""
-	    xdir="$func_dirname_result"
+	    xdir=$func_dirname_result
 
 	    func_lo2o "$arg"
 	    pic_object=$xdir$objdir/$func_lo2o_result
@@ -5951,7 +7392,7 @@ func_mode_link ()
 	    func_append libobjs " $pic_object"
 	    func_append non_pic_objects " $non_pic_object"
 	  else
-	    func_fatal_error "\`$arg' is not a valid libtool object"
+	    func_fatal_error "'$arg' is not a valid libtool object"
 	  fi
 	fi
 	;;
@@ -5967,11 +7408,11 @@ func_mode_link ()
 	# A libtool-controlled library.
 
 	func_resolve_sysroot "$arg"
-	if test "$prev" = dlfiles; then
+	if test dlfiles = "$prev"; then
 	  # This library was specified with -dlopen.
 	  func_append dlfiles " $func_resolve_sysroot_result"
 	  prev=
-	elif test "$prev" = dlprefiles; then
+	elif test dlprefiles = "$prev"; then
 	  # The library was specified with -dlpreopen.
 	  func_append dlprefiles " $func_resolve_sysroot_result"
 	  prev=
@@ -5986,7 +7427,7 @@ func_mode_link ()
 	# Unknown arguments in both finalize_command and compile_command need
 	# to be aesthetically quoted because they are evaled later.
 	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
       esac # arg
 
@@ -5998,9 +7439,9 @@ func_mode_link ()
     done # argument parsing loop
 
     test -n "$prev" && \
-      func_fatal_help "the \`$prevarg' option requires an argument"
+      func_fatal_help "the '$prevarg' option requires an argument"
 
-    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
       eval arg=\"$export_dynamic_flag_spec\"
       func_append compile_command " $arg"
       func_append finalize_command " $arg"
@@ -6009,20 +7450,23 @@ func_mode_link ()
     oldlibs=
     # calculate the name of the file, without its directory
     func_basename "$output"
-    outputname="$func_basename_result"
-    libobjs_save="$libobjs"
+    outputname=$func_basename_result
+    libobjs_save=$libobjs
 
     if test -n "$shlibpath_var"; then
       # get the directories listed in $shlibpath_var
-      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
+      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
     else
       shlib_search_path=
     fi
     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
 
+    # Definition is injected by LT_CONFIG during libtool generation.
+    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
+
     func_dirname "$output" "/" ""
-    output_objdir="$func_dirname_result$objdir"
+    output_objdir=$func_dirname_result$objdir
     func_to_tool_file "$output_objdir/"
     tool_output_objdir=$func_to_tool_file_result
     # Create the object directory.
@@ -6045,7 +7489,7 @@ func_mode_link ()
     # Find all interdependent deplibs by searching for libraries
     # that are linked more than once (e.g. -la -lb -la)
     for deplib in $deplibs; do
-      if $opt_preserve_dup_deps ; then
+      if $opt_preserve_dup_deps; then
 	case "$libs " in
 	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
 	esac
@@ -6053,7 +7497,7 @@ func_mode_link ()
       func_append libs " $deplib"
     done
 
-    if test "$linkmode" = lib; then
+    if test lib = "$linkmode"; then
       libs="$predeps $libs $compiler_lib_search_path $postdeps"
 
       # Compute libraries that are listed more than once in $predeps
@@ -6085,7 +7529,7 @@ func_mode_link ()
 	  case $file in
 	  *.la) ;;
 	  *)
-	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
 	    ;;
 	  esac
 	done
@@ -6093,7 +7537,7 @@ func_mode_link ()
     prog)
 	compile_deplibs=
 	finalize_deplibs=
-	alldeplibs=no
+	alldeplibs=false
 	newdlfiles=
 	newdlprefiles=
 	passes="conv scan dlopen dlpreopen link"
@@ -6105,32 +7549,29 @@ func_mode_link ()
     for pass in $passes; do
       # The preopen pass in lib mode reverses $deplibs; put it back here
       # so that -L comes before libs that need it for instance...
-      if test "$linkmode,$pass" = "lib,link"; then
+      if test lib,link = "$linkmode,$pass"; then
 	## FIXME: Find the place where the list is rebuilt in the wrong
 	##        order, and fix it there properly
         tmp_deplibs=
 	for deplib in $deplibs; do
 	  tmp_deplibs="$deplib $tmp_deplibs"
 	done
-	deplibs="$tmp_deplibs"
+	deplibs=$tmp_deplibs
       fi
 
-      if test "$linkmode,$pass" = "lib,link" ||
-	 test "$linkmode,$pass" = "prog,scan"; then
-	libs="$deplibs"
+      if test lib,link = "$linkmode,$pass" ||
+	 test prog,scan = "$linkmode,$pass"; then
+	libs=$deplibs
 	deplibs=
       fi
-      if test "$linkmode" = prog; then
+      if test prog = "$linkmode"; then
 	case $pass in
-	dlopen) libs="$dlfiles" ;;
-	dlpreopen) libs="$dlprefiles" ;;
-	link)
-	  libs="$deplibs %DEPLIBS%"
-	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
-	  ;;
+	dlopen) libs=$dlfiles ;;
+	dlpreopen) libs=$dlprefiles ;;
+	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
 	esac
       fi
-      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+      if test lib,dlpreopen = "$linkmode,$pass"; then
 	# Collect and forward deplibs of preopened libtool libs
 	for lib in $dlprefiles; do
 	  # Ignore non-libtool-libs
@@ -6151,26 +7592,26 @@ func_mode_link ()
 	    esac
 	  done
 	done
-	libs="$dlprefiles"
+	libs=$dlprefiles
       fi
-      if test "$pass" = dlopen; then
+      if test dlopen = "$pass"; then
 	# Collect dlpreopened libraries
-	save_deplibs="$deplibs"
+	save_deplibs=$deplibs
 	deplibs=
       fi
 
       for deplib in $libs; do
 	lib=
-	found=no
+	found=false
 	case $deplib in
 	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
         |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
-	  if test "$linkmode,$pass" = "prog,link"; then
+	  if test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
 	    func_append compiler_flags " $deplib"
-	    if test "$linkmode" = lib ; then
+	    if test lib = "$linkmode"; then
 		case "$new_inherited_linker_flags " in
 		    *" $deplib "*) ;;
 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
@@ -6180,13 +7621,13 @@ func_mode_link ()
 	  continue
 	  ;;
 	-l*)
-	  if test "$linkmode" != lib && test "$linkmode" != prog; then
-	    func_warning "\`-l' is ignored for archives/objects"
+	  if test lib != "$linkmode" && test prog != "$linkmode"; then
+	    func_warning "'-l' is ignored for archives/objects"
 	    continue
 	  fi
 	  func_stripname '-l' '' "$deplib"
 	  name=$func_stripname_result
-	  if test "$linkmode" = lib; then
+	  if test lib = "$linkmode"; then
 	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
 	  else
 	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
@@ -6194,31 +7635,22 @@ func_mode_link ()
 	  for searchdir in $searchdirs; do
 	    for search_ext in .la $std_shrext .so .a; do
 	      # Search the libtool library
-	      lib="$searchdir/lib${name}${search_ext}"
+	      lib=$searchdir/lib$name$search_ext
 	      if test -f "$lib"; then
-		if test "$search_ext" = ".la"; then
-		  found=yes
+		if test .la = "$search_ext"; then
+		  found=:
 		else
-		  found=no
+		  found=false
 		fi
 		break 2
 	      fi
 	    done
 	  done
-	  if test "$found" != yes; then
-	    # deplib doesn't seem to be a libtool library
-	    if test "$linkmode,$pass" = "prog,link"; then
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    else
-	      deplibs="$deplib $deplibs"
-	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
-	    fi
-	    continue
-	  else # deplib is a libtool library
+	  if $found; then
+	    # deplib is a libtool library
 	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
 	    # We need to do some special things here, and not later.
-	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 	      case " $predeps $postdeps " in
 	      *" $deplib "*)
 		if func_lalib_p "$lib"; then
@@ -6226,19 +7658,19 @@ func_mode_link ()
 		  old_library=
 		  func_source "$lib"
 		  for l in $old_library $library_names; do
-		    ll="$l"
+		    ll=$l
 		  done
-		  if test "X$ll" = "X$old_library" ; then # only static version available
-		    found=no
+		  if test "X$ll" = "X$old_library"; then # only static version available
+		    found=false
 		    func_dirname "$lib" "" "."
-		    ladir="$func_dirname_result"
+		    ladir=$func_dirname_result
 		    lib=$ladir/$old_library
-		    if test "$linkmode,$pass" = "prog,link"; then
+		    if test prog,link = "$linkmode,$pass"; then
 		      compile_deplibs="$deplib $compile_deplibs"
 		      finalize_deplibs="$deplib $finalize_deplibs"
 		    else
 		      deplibs="$deplib $deplibs"
-		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
 		    fi
 		    continue
 		  fi
@@ -6247,15 +7679,25 @@ func_mode_link ()
 	      *) ;;
 	      esac
 	    fi
+	  else
+	    # deplib doesn't seem to be a libtool library
+	    if test prog,link = "$linkmode,$pass"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
 	  fi
 	  ;; # -l
 	*.ltframework)
-	  if test "$linkmode,$pass" = "prog,link"; then
+	  if test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
 	    deplibs="$deplib $deplibs"
-	    if test "$linkmode" = lib ; then
+	    if test lib = "$linkmode"; then
 		case "$new_inherited_linker_flags " in
 		    *" $deplib "*) ;;
 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
@@ -6268,18 +7710,18 @@ func_mode_link ()
 	  case $linkmode in
 	  lib)
 	    deplibs="$deplib $deplibs"
-	    test "$pass" = conv && continue
+	    test conv = "$pass" && continue
 	    newdependency_libs="$deplib $newdependency_libs"
 	    func_stripname '-L' '' "$deplib"
 	    func_resolve_sysroot "$func_stripname_result"
 	    func_append newlib_search_path " $func_resolve_sysroot_result"
 	    ;;
 	  prog)
-	    if test "$pass" = conv; then
+	    if test conv = "$pass"; then
 	      deplibs="$deplib $deplibs"
 	      continue
 	    fi
-	    if test "$pass" = scan; then
+	    if test scan = "$pass"; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      compile_deplibs="$deplib $compile_deplibs"
@@ -6290,13 +7732,13 @@ func_mode_link ()
 	    func_append newlib_search_path " $func_resolve_sysroot_result"
 	    ;;
 	  *)
-	    func_warning "\`-L' is ignored for archives/objects"
+	    func_warning "'-L' is ignored for archives/objects"
 	    ;;
 	  esac # linkmode
 	  continue
 	  ;; # -L
 	-R*)
-	  if test "$pass" = link; then
+	  if test link = "$pass"; then
 	    func_stripname '-R' '' "$deplib"
 	    func_resolve_sysroot "$func_stripname_result"
 	    dir=$func_resolve_sysroot_result
@@ -6314,7 +7756,7 @@ func_mode_link ()
 	  lib=$func_resolve_sysroot_result
 	  ;;
 	*.$libext)
-	  if test "$pass" = conv; then
+	  if test conv = "$pass"; then
 	    deplibs="$deplib $deplibs"
 	    continue
 	  fi
@@ -6325,21 +7767,26 @@ func_mode_link ()
 	    case " $dlpreconveniencelibs " in
 	    *" $deplib "*) ;;
 	    *)
-	      valid_a_lib=no
+	      valid_a_lib=false
 	      case $deplibs_check_method in
 		match_pattern*)
 		  set dummy $deplibs_check_method; shift
 		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
 		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
 		    | $EGREP "$match_pattern_regex" > /dev/null; then
-		    valid_a_lib=yes
+		    valid_a_lib=:
 		  fi
 		;;
 		pass_all)
-		  valid_a_lib=yes
+		  valid_a_lib=:
 		;;
 	      esac
-	      if test "$valid_a_lib" != yes; then
+	      if $valid_a_lib; then
+		echo
+		$ECHO "*** Warning: Linking the shared library $output against the"
+		$ECHO "*** static library $deplib is not portable!"
+		deplibs="$deplib $deplibs"
+	      else
 		echo
 		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
 		echo "*** I have the capability to make that library automatically link in when"
@@ -6347,18 +7794,13 @@ func_mode_link ()
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because the file extensions .$libext of this argument makes me believe"
 		echo "*** that it is just a static archive that I should not use here."
-	      else
-		echo
-		$ECHO "*** Warning: Linking the shared library $output against the"
-		$ECHO "*** static library $deplib is not portable!"
-		deplibs="$deplib $deplibs"
 	      fi
 	      ;;
 	    esac
 	    continue
 	    ;;
 	  prog)
-	    if test "$pass" != link; then
+	    if test link != "$pass"; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      compile_deplibs="$deplib $compile_deplibs"
@@ -6369,10 +7811,10 @@ func_mode_link ()
 	  esac # linkmode
 	  ;; # *.$libext
 	*.lo | *.$objext)
-	  if test "$pass" = conv; then
+	  if test conv = "$pass"; then
 	    deplibs="$deplib $deplibs"
-	  elif test "$linkmode" = prog; then
-	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	  elif test prog = "$linkmode"; then
+	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
 	      # If there is no dlopen support or we're linking statically,
 	      # we need to preload.
 	      func_append newdlprefiles " $deplib"
@@ -6385,22 +7827,20 @@ func_mode_link ()
 	  continue
 	  ;;
 	%DEPLIBS%)
-	  alldeplibs=yes
+	  alldeplibs=:
 	  continue
 	  ;;
 	esac # case $deplib
 
-	if test "$found" = yes || test -f "$lib"; then :
-	else
-	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
-	fi
+	$found || test -f "$lib" \
+	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$lib" \
-	  || func_fatal_error "\`$lib' is not a valid libtool archive"
+	  || func_fatal_error "'$lib' is not a valid libtool archive"
 
 	func_dirname "$lib" "" "."
-	ladir="$func_dirname_result"
+	ladir=$func_dirname_result
 
 	dlname=
 	dlopen=
@@ -6430,36 +7870,36 @@ func_mode_link ()
 	  done
 	fi
 	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	if test "$linkmode,$pass" = "lib,link" ||
-	   test "$linkmode,$pass" = "prog,scan" ||
-	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+	if test lib,link = "$linkmode,$pass" ||
+	   test prog,scan = "$linkmode,$pass" ||
+	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
 	  test -n "$dlopen" && func_append dlfiles " $dlopen"
 	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
 	fi
 
-	if test "$pass" = conv; then
+	if test conv = "$pass"; then
 	  # Only check for convenience libraries
 	  deplibs="$lib $deplibs"
 	  if test -z "$libdir"; then
 	    if test -z "$old_library"; then
-	      func_fatal_error "cannot find name of link library for \`$lib'"
+	      func_fatal_error "cannot find name of link library for '$lib'"
 	    fi
 	    # It is a libtool convenience library, so add in its objects.
 	    func_append convenience " $ladir/$objdir/$old_library"
 	    func_append old_convenience " $ladir/$objdir/$old_library"
-	    tmp_libs=
-	    for deplib in $dependency_libs; do
-	      deplibs="$deplib $deplibs"
-	      if $opt_preserve_dup_deps ; then
-		case "$tmp_libs " in
-		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
-		esac
-	      fi
-	      func_append tmp_libs " $deplib"
-	    done
-	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
-	    func_fatal_error "\`$lib' is not a convenience library"
+	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
+	    func_fatal_error "'$lib' is not a convenience library"
 	  fi
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    deplibs="$deplib $deplibs"
+	    if $opt_preserve_dup_deps; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+	      esac
+	    fi
+	    func_append tmp_libs " $deplib"
+	  done
 	  continue
 	fi # $pass = conv
 
@@ -6467,26 +7907,26 @@ func_mode_link ()
 	# Get the name of the library we link against.
 	linklib=
 	if test -n "$old_library" &&
-	   { test "$prefer_static_libs" = yes ||
-	     test "$prefer_static_libs,$installed" = "built,no"; }; then
+	   { test yes = "$prefer_static_libs" ||
+	     test built,no = "$prefer_static_libs,$installed"; }; then
 	  linklib=$old_library
 	else
 	  for l in $old_library $library_names; do
-	    linklib="$l"
+	    linklib=$l
 	  done
 	fi
 	if test -z "$linklib"; then
-	  func_fatal_error "cannot find name of link library for \`$lib'"
+	  func_fatal_error "cannot find name of link library for '$lib'"
 	fi
 
 	# This library was specified with -dlopen.
-	if test "$pass" = dlopen; then
-	  if test -z "$libdir"; then
-	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
-	  fi
+	if test dlopen = "$pass"; then
+	  test -z "$libdir" \
+	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
 	  if test -z "$dlname" ||
-	     test "$dlopen_support" != yes ||
-	     test "$build_libtool_libs" = no; then
+	     test yes != "$dlopen_support" ||
+	     test no = "$build_libtool_libs"
+	  then
 	    # If there is no dlname, no dlopen support or we're linking
 	    # statically, we need to preload.  We also need to preload any
 	    # dependent libraries so libltdl's deplib preloader doesn't
@@ -6500,40 +7940,40 @@ func_mode_link ()
 
 	# We need an absolute path.
 	case $ladir in
-	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
 	*)
 	  abs_ladir=`cd "$ladir" && pwd`
 	  if test -z "$abs_ladir"; then
-	    func_warning "cannot determine absolute directory name of \`$ladir'"
+	    func_warning "cannot determine absolute directory name of '$ladir'"
 	    func_warning "passing it literally to the linker, although it might fail"
-	    abs_ladir="$ladir"
+	    abs_ladir=$ladir
 	  fi
 	  ;;
 	esac
 	func_basename "$lib"
-	laname="$func_basename_result"
+	laname=$func_basename_result
 
 	# Find the relevant object directory and library name.
-	if test "X$installed" = Xyes; then
+	if test yes = "$installed"; then
 	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    func_warning "library \`$lib' was moved."
-	    dir="$ladir"
-	    absdir="$abs_ladir"
-	    libdir="$abs_ladir"
+	    func_warning "library '$lib' was moved."
+	    dir=$ladir
+	    absdir=$abs_ladir
+	    libdir=$abs_ladir
 	  else
-	    dir="$lt_sysroot$libdir"
-	    absdir="$lt_sysroot$libdir"
+	    dir=$lt_sysroot$libdir
+	    absdir=$lt_sysroot$libdir
 	  fi
-	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
 	else
 	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    dir="$ladir"
-	    absdir="$abs_ladir"
+	    dir=$ladir
+	    absdir=$abs_ladir
 	    # Remove this search path later
 	    func_append notinst_path " $abs_ladir"
 	  else
-	    dir="$ladir/$objdir"
-	    absdir="$abs_ladir/$objdir"
+	    dir=$ladir/$objdir
+	    absdir=$abs_ladir/$objdir
 	    # Remove this search path later
 	    func_append notinst_path " $abs_ladir"
 	  fi
@@ -6542,11 +7982,11 @@ func_mode_link ()
 	name=$func_stripname_result
 
 	# This library was specified with -dlpreopen.
-	if test "$pass" = dlpreopen; then
-	  if test -z "$libdir" && test "$linkmode" = prog; then
-	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+	if test dlpreopen = "$pass"; then
+	  if test -z "$libdir" && test prog = "$linkmode"; then
+	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
 	  fi
-	  case "$host" in
+	  case $host in
 	    # special handling for platforms with PE-DLLs.
 	    *cygwin* | *mingw* | *cegcc* )
 	      # Linker will automatically link against shared library if both
@@ -6590,9 +8030,9 @@ func_mode_link ()
 
 	if test -z "$libdir"; then
 	  # Link the convenience library
-	  if test "$linkmode" = lib; then
+	  if test lib = "$linkmode"; then
 	    deplibs="$dir/$old_library $deplibs"
-	  elif test "$linkmode,$pass" = "prog,link"; then
+	  elif test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$dir/$old_library $compile_deplibs"
 	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
 	  else
@@ -6602,14 +8042,14 @@ func_mode_link ()
 	fi
 
 
-	if test "$linkmode" = prog && test "$pass" != link; then
+	if test prog = "$linkmode" && test link != "$pass"; then
 	  func_append newlib_search_path " $ladir"
 	  deplibs="$lib $deplibs"
 
-	  linkalldeplibs=no
-	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
-	     test "$build_libtool_libs" = no; then
-	    linkalldeplibs=yes
+	  linkalldeplibs=false
+	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
+	     test no = "$build_libtool_libs"; then
+	    linkalldeplibs=:
 	  fi
 
 	  tmp_libs=
@@ -6621,14 +8061,14 @@ func_mode_link ()
 		 ;;
 	    esac
 	    # Need to link against all dependency_libs?
-	    if test "$linkalldeplibs" = yes; then
+	    if $linkalldeplibs; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      # Need to hardcode shared library paths
 	      # or/and link against static libraries
 	      newdependency_libs="$deplib $newdependency_libs"
 	    fi
-	    if $opt_preserve_dup_deps ; then
+	    if $opt_preserve_dup_deps; then
 	      case "$tmp_libs " in
 	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
 	      esac
@@ -6638,15 +8078,15 @@ func_mode_link ()
 	  continue
 	fi # $linkmode = prog...
 
-	if test "$linkmode,$pass" = "prog,link"; then
+	if test prog,link = "$linkmode,$pass"; then
 	  if test -n "$library_names" &&
-	     { { test "$prefer_static_libs" = no ||
-	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	     { { test no = "$prefer_static_libs" ||
+	         test built,yes = "$prefer_static_libs,$installed"; } ||
 	       test -z "$old_library"; }; then
 	    # We need to hardcode the library path
-	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
 	      # Make sure the rpath contains only unique directories.
-	      case "$temp_rpath:" in
+	      case $temp_rpath: in
 	      *"$absdir:"*) ;;
 	      *) func_append temp_rpath "$absdir:" ;;
 	      esac
@@ -6675,9 +8115,9 @@ func_mode_link ()
 	    esac
 	  fi # $linkmode,$pass = prog,link...
 
-	  if test "$alldeplibs" = yes &&
-	     { test "$deplibs_check_method" = pass_all ||
-	       { test "$build_libtool_libs" = yes &&
+	  if $alldeplibs &&
+	     { test pass_all = "$deplibs_check_method" ||
+	       { test yes = "$build_libtool_libs" &&
 		 test -n "$library_names"; }; }; then
 	    # We only need to search for static libraries
 	    continue
@@ -6686,19 +8126,19 @@ func_mode_link ()
 
 	link_static=no # Whether the deplib will be linked statically
 	use_static_libs=$prefer_static_libs
-	if test "$use_static_libs" = built && test "$installed" = yes; then
+	if test built = "$use_static_libs" && test yes = "$installed"; then
 	  use_static_libs=no
 	fi
 	if test -n "$library_names" &&
-	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
 	  case $host in
-	  *cygwin* | *mingw* | *cegcc*)
+	  *cygwin* | *mingw* | *cegcc* | *os2*)
 	      # No point in relinking DLLs because paths are not encoded
 	      func_append notinst_deplibs " $lib"
 	      need_relink=no
 	    ;;
 	  *)
-	    if test "$installed" = no; then
+	    if test no = "$installed"; then
 	      func_append notinst_deplibs " $lib"
 	      need_relink=yes
 	    fi
@@ -6708,24 +8148,24 @@ func_mode_link ()
 
 	  # Warn about portability, can't link against -module's on some
 	  # systems (darwin).  Don't bleat about dlopened modules though!
-	  dlopenmodule=""
+	  dlopenmodule=
 	  for dlpremoduletest in $dlprefiles; do
 	    if test "X$dlpremoduletest" = "X$lib"; then
-	      dlopenmodule="$dlpremoduletest"
+	      dlopenmodule=$dlpremoduletest
 	      break
 	    fi
 	  done
-	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
 	    echo
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
 	    else
 	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
 	    fi
 	    $ECHO "*** $linklib is not portable!"
 	  fi
-	  if test "$linkmode" = lib &&
-	     test "$hardcode_into_libs" = yes; then
+	  if test lib = "$linkmode" &&
+	     test yes = "$hardcode_into_libs"; then
 	    # Hardcode the library path.
 	    # Skip directories that are in the system default run-time
 	    # search path.
@@ -6753,43 +8193,43 @@ func_mode_link ()
 	    # figure out the soname
 	    set dummy $library_names
 	    shift
-	    realname="$1"
+	    realname=$1
 	    shift
 	    libname=`eval "\\$ECHO \"$libname_spec\""`
 	    # use dlname if we got it. it's perfectly good, no?
 	    if test -n "$dlname"; then
-	      soname="$dlname"
+	      soname=$dlname
 	    elif test -n "$soname_spec"; then
 	      # bleh windows
 	      case $host in
-	      *cygwin* | mingw* | *cegcc*)
+	      *cygwin* | mingw* | *cegcc* | *os2*)
 	        func_arith $current - $age
 		major=$func_arith_result
-		versuffix="-$major"
+		versuffix=-$major
 		;;
 	      esac
 	      eval soname=\"$soname_spec\"
 	    else
-	      soname="$realname"
+	      soname=$realname
 	    fi
 
 	    # Make a new name for the extract_expsyms_cmds to use
-	    soroot="$soname"
+	    soroot=$soname
 	    func_basename "$soroot"
-	    soname="$func_basename_result"
+	    soname=$func_basename_result
 	    func_stripname 'lib' '.dll' "$soname"
 	    newlib=libimp-$func_stripname_result.a
 
 	    # If the library has no export list, then create one now
 	    if test -f "$output_objdir/$soname-def"; then :
 	    else
-	      func_verbose "extracting exported symbol list from \`$soname'"
+	      func_verbose "extracting exported symbol list from '$soname'"
 	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
 	    fi
 
 	    # Create $newlib
 	    if test -f "$output_objdir/$newlib"; then :; else
-	      func_verbose "generating import library for \`$soname'"
+	      func_verbose "generating import library for '$soname'"
 	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
 	    fi
 	    # make sure the library variables are pointing to the new library
@@ -6797,58 +8237,58 @@ func_mode_link ()
 	    linklib=$newlib
 	  fi # test -n "$old_archive_from_expsyms_cmds"
 
-	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
+	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
 	    add_shlibpath=
 	    add_dir=
 	    add=
 	    lib_linked=yes
 	    case $hardcode_action in
 	    immediate | unsupported)
-	      if test "$hardcode_direct" = no; then
-		add="$dir/$linklib"
+	      if test no = "$hardcode_direct"; then
+		add=$dir/$linklib
 		case $host in
-		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
-		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
+		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
 		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
-		    *-*-unixware7*) add_dir="-L$dir" ;;
+		    *-*-unixware7*) add_dir=-L$dir ;;
 		  *-*-darwin* )
-		    # if the lib is a (non-dlopened) module then we can not
+		    # if the lib is a (non-dlopened) module then we cannot
 		    # link against it, someone is ignoring the earlier warnings
 		    if /usr/bin/file -L $add 2> /dev/null |
-			 $GREP ": [^:]* bundle" >/dev/null ; then
+			 $GREP ": [^:]* bundle" >/dev/null; then
 		      if test "X$dlopenmodule" != "X$lib"; then
 			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
-			if test -z "$old_library" ; then
+			if test -z "$old_library"; then
 			  echo
 			  echo "*** And there doesn't seem to be a static archive available"
 			  echo "*** The link will probably fail, sorry"
 			else
-			  add="$dir/$old_library"
+			  add=$dir/$old_library
 			fi
 		      elif test -n "$old_library"; then
-			add="$dir/$old_library"
+			add=$dir/$old_library
 		      fi
 		    fi
 		esac
-	      elif test "$hardcode_minus_L" = no; then
+	      elif test no = "$hardcode_minus_L"; then
 		case $host in
-		*-*-sunos*) add_shlibpath="$dir" ;;
+		*-*-sunos*) add_shlibpath=$dir ;;
 		esac
-		add_dir="-L$dir"
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = no; then
-		add_shlibpath="$dir"
-		add="-l$name"
+		add_dir=-L$dir
+		add=-l$name
+	      elif test no = "$hardcode_shlibpath_var"; then
+		add_shlibpath=$dir
+		add=-l$name
 	      else
 		lib_linked=no
 	      fi
 	      ;;
 	    relink)
-	      if test "$hardcode_direct" = yes &&
-	         test "$hardcode_direct_absolute" = no; then
-		add="$dir/$linklib"
-	      elif test "$hardcode_minus_L" = yes; then
-		add_dir="-L$absdir"
+	      if test yes = "$hardcode_direct" &&
+	         test no = "$hardcode_direct_absolute"; then
+		add=$dir/$linklib
+	      elif test yes = "$hardcode_minus_L"; then
+		add_dir=-L$absdir
 		# Try looking first in the location we're being installed to.
 		if test -n "$inst_prefix_dir"; then
 		  case $libdir in
@@ -6857,10 +8297,10 @@ func_mode_link ()
 		      ;;
 		  esac
 		fi
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = yes; then
-		add_shlibpath="$dir"
-		add="-l$name"
+		add=-l$name
+	      elif test yes = "$hardcode_shlibpath_var"; then
+		add_shlibpath=$dir
+		add=-l$name
 	      else
 		lib_linked=no
 	      fi
@@ -6868,7 +8308,7 @@ func_mode_link ()
 	    *) lib_linked=no ;;
 	    esac
 
-	    if test "$lib_linked" != yes; then
+	    if test yes != "$lib_linked"; then
 	      func_fatal_configuration "unsupported hardcode properties"
 	    fi
 
@@ -6878,15 +8318,15 @@ func_mode_link ()
 	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
 	      esac
 	    fi
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
 	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
 	    else
 	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
 	      test -n "$add" && deplibs="$add $deplibs"
-	      if test "$hardcode_direct" != yes &&
-		 test "$hardcode_minus_L" != yes &&
-		 test "$hardcode_shlibpath_var" = yes; then
+	      if test yes != "$hardcode_direct" &&
+		 test yes != "$hardcode_minus_L" &&
+		 test yes = "$hardcode_shlibpath_var"; then
 		case :$finalize_shlibpath: in
 		*":$libdir:"*) ;;
 		*) func_append finalize_shlibpath "$libdir:" ;;
@@ -6895,33 +8335,33 @@ func_mode_link ()
 	    fi
 	  fi
 
-	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
+	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
 	    add_shlibpath=
 	    add_dir=
 	    add=
 	    # Finalize command for both is simple: just hardcode it.
-	    if test "$hardcode_direct" = yes &&
-	       test "$hardcode_direct_absolute" = no; then
-	      add="$libdir/$linklib"
-	    elif test "$hardcode_minus_L" = yes; then
-	      add_dir="-L$libdir"
-	      add="-l$name"
-	    elif test "$hardcode_shlibpath_var" = yes; then
+	    if test yes = "$hardcode_direct" &&
+	       test no = "$hardcode_direct_absolute"; then
+	      add=$libdir/$linklib
+	    elif test yes = "$hardcode_minus_L"; then
+	      add_dir=-L$libdir
+	      add=-l$name
+	    elif test yes = "$hardcode_shlibpath_var"; then
 	      case :$finalize_shlibpath: in
 	      *":$libdir:"*) ;;
 	      *) func_append finalize_shlibpath "$libdir:" ;;
 	      esac
-	      add="-l$name"
-	    elif test "$hardcode_automatic" = yes; then
+	      add=-l$name
+	    elif test yes = "$hardcode_automatic"; then
 	      if test -n "$inst_prefix_dir" &&
-		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
-		add="$inst_prefix_dir$libdir/$linklib"
+		 test -f "$inst_prefix_dir$libdir/$linklib"; then
+		add=$inst_prefix_dir$libdir/$linklib
 	      else
-		add="$libdir/$linklib"
+		add=$libdir/$linklib
 	      fi
 	    else
 	      # We cannot seem to hardcode it, guess we'll fake it.
-	      add_dir="-L$libdir"
+	      add_dir=-L$libdir
 	      # Try looking first in the location we're being installed to.
 	      if test -n "$inst_prefix_dir"; then
 		case $libdir in
@@ -6930,10 +8370,10 @@ func_mode_link ()
 		    ;;
 		esac
 	      fi
-	      add="-l$name"
+	      add=-l$name
 	    fi
 
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
 	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
 	    else
@@ -6941,43 +8381,43 @@ func_mode_link ()
 	      test -n "$add" && deplibs="$add $deplibs"
 	    fi
 	  fi
-	elif test "$linkmode" = prog; then
+	elif test prog = "$linkmode"; then
 	  # Here we assume that one of hardcode_direct or hardcode_minus_L
 	  # is not unsupported.  This is valid on all known static and
 	  # shared platforms.
-	  if test "$hardcode_direct" != unsupported; then
-	    test -n "$old_library" && linklib="$old_library"
+	  if test unsupported != "$hardcode_direct"; then
+	    test -n "$old_library" && linklib=$old_library
 	    compile_deplibs="$dir/$linklib $compile_deplibs"
 	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
 	  else
 	    compile_deplibs="-l$name -L$dir $compile_deplibs"
 	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
 	  fi
-	elif test "$build_libtool_libs" = yes; then
+	elif test yes = "$build_libtool_libs"; then
 	  # Not a shared library
-	  if test "$deplibs_check_method" != pass_all; then
+	  if test pass_all != "$deplibs_check_method"; then
 	    # We're trying link a shared library against a static one
 	    # but the system doesn't support it.
 
 	    # Just print a warning and add the library to dependency_libs so
 	    # that the program can be linked against the static library.
 	    echo
-	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
+	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
 	    echo "*** I have the capability to make that library automatically link in when"
 	    echo "*** you link to this library.  But I can only do this if you have a"
 	    echo "*** shared version of the library, which you do not appear to have."
-	    if test "$module" = yes; then
+	    if test yes = "$module"; then
 	      echo "*** But as you try to build a module library, libtool will still create "
 	      echo "*** a static module, that should work as long as the dlopening application"
 	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
 	      if test -z "$global_symbol_pipe"; then
 		echo
 		echo "*** However, this would only work if libtool was able to extract symbol"
-		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
 		echo "*** not find such a program.  So, this module is probably useless."
-		echo "*** \`nm' from GNU binutils and a full rebuild may help."
+		echo "*** 'nm' from GNU binutils and a full rebuild may help."
 	      fi
-	      if test "$build_old_libs" = no; then
+	      if test no = "$build_old_libs"; then
 		build_libtool_libs=module
 		build_old_libs=yes
 	      else
@@ -6990,11 +8430,11 @@ func_mode_link ()
 	  fi
 	fi # link shared/static library?
 
-	if test "$linkmode" = lib; then
+	if test lib = "$linkmode"; then
 	  if test -n "$dependency_libs" &&
-	     { test "$hardcode_into_libs" != yes ||
-	       test "$build_old_libs" = yes ||
-	       test "$link_static" = yes; }; then
+	     { test yes != "$hardcode_into_libs" ||
+	       test yes = "$build_old_libs" ||
+	       test yes = "$link_static"; }; then
 	    # Extract -R from dependency_libs
 	    temp_deplibs=
 	    for libdir in $dependency_libs; do
@@ -7008,12 +8448,12 @@ func_mode_link ()
 	      *) func_append temp_deplibs " $libdir";;
 	      esac
 	    done
-	    dependency_libs="$temp_deplibs"
+	    dependency_libs=$temp_deplibs
 	  fi
 
 	  func_append newlib_search_path " $absdir"
 	  # Link against this library
-	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
 	  # ... and its dependency_libs
 	  tmp_libs=
 	  for deplib in $dependency_libs; do
@@ -7023,7 +8463,7 @@ func_mode_link ()
                    func_resolve_sysroot "$func_stripname_result";;
               *) func_resolve_sysroot "$deplib" ;;
             esac
-	    if $opt_preserve_dup_deps ; then
+	    if $opt_preserve_dup_deps; then
 	      case "$tmp_libs " in
 	      *" $func_resolve_sysroot_result "*)
                 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
@@ -7032,12 +8472,12 @@ func_mode_link ()
 	    func_append tmp_libs " $func_resolve_sysroot_result"
 	  done
 
-	  if test "$link_all_deplibs" != no; then
+	  if test no != "$link_all_deplibs"; then
 	    # Add the search paths of all dependency libraries
 	    for deplib in $dependency_libs; do
 	      path=
 	      case $deplib in
-	      -L*) path="$deplib" ;;
+	      -L*) path=$deplib ;;
 	      *.la)
 	        func_resolve_sysroot "$deplib"
 	        deplib=$func_resolve_sysroot_result
@@ -7045,12 +8485,12 @@ func_mode_link ()
 		dir=$func_dirname_result
 		# We need an absolute path.
 		case $dir in
-		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
 		*)
 		  absdir=`cd "$dir" && pwd`
 		  if test -z "$absdir"; then
-		    func_warning "cannot determine absolute directory name of \`$dir'"
-		    absdir="$dir"
+		    func_warning "cannot determine absolute directory name of '$dir'"
+		    absdir=$dir
 		  fi
 		  ;;
 		esac
@@ -7058,35 +8498,35 @@ func_mode_link ()
 		case $host in
 		*-*-darwin*)
 		  depdepl=
-		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
-		  if test -n "$deplibrary_names" ; then
-		    for tmp in $deplibrary_names ; do
+		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  if test -n "$deplibrary_names"; then
+		    for tmp in $deplibrary_names; do
 		      depdepl=$tmp
 		    done
-		    if test -f "$absdir/$objdir/$depdepl" ; then
-		      depdepl="$absdir/$objdir/$depdepl"
-		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+		    if test -f "$absdir/$objdir/$depdepl"; then
+		      depdepl=$absdir/$objdir/$depdepl
+		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
                       if test -z "$darwin_install_name"; then
-                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
                       fi
-		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
-		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
+		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
+		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
 		      path=
 		    fi
 		  fi
 		  ;;
 		*)
-		  path="-L$absdir/$objdir"
+		  path=-L$absdir/$objdir
 		  ;;
 		esac
 		else
-		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
 		  test -z "$libdir" && \
-		    func_fatal_error "\`$deplib' is not a valid libtool archive"
+		    func_fatal_error "'$deplib' is not a valid libtool archive"
 		  test "$absdir" != "$libdir" && \
-		    func_warning "\`$deplib' seems to be moved"
+		    func_warning "'$deplib' seems to be moved"
 
-		  path="-L$absdir"
+		  path=-L$absdir
 		fi
 		;;
 	      esac
@@ -7098,23 +8538,23 @@ func_mode_link ()
 	  fi # link_all_deplibs != no
 	fi # linkmode = lib
       done # for deplib in $libs
-      if test "$pass" = link; then
-	if test "$linkmode" = "prog"; then
+      if test link = "$pass"; then
+	if test prog = "$linkmode"; then
 	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
 	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
 	else
 	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
 	fi
       fi
-      dependency_libs="$newdependency_libs"
-      if test "$pass" = dlpreopen; then
+      dependency_libs=$newdependency_libs
+      if test dlpreopen = "$pass"; then
 	# Link the dlpreopened libraries before other libraries
 	for deplib in $save_deplibs; do
 	  deplibs="$deplib $deplibs"
 	done
       fi
-      if test "$pass" != dlopen; then
-	if test "$pass" != conv; then
+      if test dlopen != "$pass"; then
+	test conv = "$pass" || {
 	  # Make sure lib_search_path contains only unique directories.
 	  lib_search_path=
 	  for dir in $newlib_search_path; do
@@ -7124,12 +8564,12 @@ func_mode_link ()
 	    esac
 	  done
 	  newlib_search_path=
-	fi
+	}
 
-	if test "$linkmode,$pass" != "prog,link"; then
-	  vars="deplibs"
-	else
+	if test prog,link = "$linkmode,$pass"; then
 	  vars="compile_deplibs finalize_deplibs"
+	else
+	  vars=deplibs
 	fi
 	for var in $vars dependency_libs; do
 	  # Add libraries to $var in reverse order
@@ -7187,62 +8627,93 @@ func_mode_link ()
 	  eval $var=\"$tmp_libs\"
 	done # for var
       fi
+
+      # Add Sun CC postdeps if required:
+      test CXX = "$tagname" && {
+        case $host_os in
+        linux*)
+          case `$CC -V 2>&1 | sed 5q` in
+          *Sun\ C*) # Sun C++ 5.9
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+
+        solaris*)
+          func_cc_basename "$CC"
+          case $func_cc_basename_result in
+          CC* | sunCC*)
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+        esac
+      }
+
       # Last step: remove runtime libs from dependency_libs
       # (they stay in deplibs)
       tmp_libs=
-      for i in $dependency_libs ; do
+      for i in $dependency_libs; do
 	case " $predeps $postdeps $compiler_lib_search_path " in
 	*" $i "*)
-	  i=""
+	  i=
 	  ;;
 	esac
-	if test -n "$i" ; then
+	if test -n "$i"; then
 	  func_append tmp_libs " $i"
 	fi
       done
       dependency_libs=$tmp_libs
     done # for pass
-    if test "$linkmode" = prog; then
-      dlfiles="$newdlfiles"
+    if test prog = "$linkmode"; then
+      dlfiles=$newdlfiles
     fi
-    if test "$linkmode" = prog || test "$linkmode" = lib; then
-      dlprefiles="$newdlprefiles"
+    if test prog = "$linkmode" || test lib = "$linkmode"; then
+      dlprefiles=$newdlprefiles
     fi
 
     case $linkmode in
     oldlib)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for archives"
+      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
+	func_warning "'-dlopen' is ignored for archives"
       fi
 
       case " $deplibs" in
       *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for archives" ;;
+	func_warning "'-l' and '-L' are ignored for archives" ;;
       esac
 
       test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for archives"
+	func_warning "'-rpath' is ignored for archives"
 
       test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for archives"
+	func_warning "'-R' is ignored for archives"
 
       test -n "$vinfo" && \
-	func_warning "\`-version-info/-version-number' is ignored for archives"
+	func_warning "'-version-info/-version-number' is ignored for archives"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for archives"
+	func_warning "'-release' is ignored for archives"
 
       test -n "$export_symbols$export_symbols_regex" && \
-	func_warning "\`-export-symbols' is ignored for archives"
+	func_warning "'-export-symbols' is ignored for archives"
 
       # Now set the variables for building old libraries.
       build_libtool_libs=no
-      oldlibs="$output"
+      oldlibs=$output
       func_append objs "$old_deplibs"
       ;;
 
     lib)
-      # Make sure we only generate libraries of the form `libNAME.la'.
+      # Make sure we only generate libraries of the form 'libNAME.la'.
       case $outputname in
       lib*)
 	func_stripname 'lib' '.la' "$outputname"
@@ -7251,10 +8722,10 @@ func_mode_link ()
 	eval libname=\"$libname_spec\"
 	;;
       *)
-	test "$module" = no && \
-	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
+	test no = "$module" \
+	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
 
-	if test "$need_lib_prefix" != no; then
+	if test no != "$need_lib_prefix"; then
 	  # Add the "lib" prefix for modules if required
 	  func_stripname '' '.la' "$outputname"
 	  name=$func_stripname_result
@@ -7268,8 +8739,8 @@ func_mode_link ()
       esac
 
       if test -n "$objs"; then
-	if test "$deplibs_check_method" != pass_all; then
-	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+	if test pass_all != "$deplibs_check_method"; then
+	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
 	else
 	  echo
 	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
@@ -7278,21 +8749,21 @@ func_mode_link ()
 	fi
       fi
 
-      test "$dlself" != no && \
-	func_warning "\`-dlopen self' is ignored for libtool libraries"
+      test no = "$dlself" \
+	|| func_warning "'-dlopen self' is ignored for libtool libraries"
 
       set dummy $rpath
       shift
-      test "$#" -gt 1 && \
-	func_warning "ignoring multiple \`-rpath's for a libtool library"
+      test 1 -lt "$#" \
+	&& func_warning "ignoring multiple '-rpath's for a libtool library"
 
-      install_libdir="$1"
+      install_libdir=$1
 
       oldlibs=
       if test -z "$rpath"; then
-	if test "$build_libtool_libs" = yes; then
+	if test yes = "$build_libtool_libs"; then
 	  # Building a libtool convenience library.
-	  # Some compilers have problems with a `.al' extension so
+	  # Some compilers have problems with a '.al' extension so
 	  # convenience libraries should have the same extension an
 	  # archive normally would.
 	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
@@ -7301,20 +8772,20 @@ func_mode_link ()
 	fi
 
 	test -n "$vinfo" && \
-	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
 
 	test -n "$release" && \
-	  func_warning "\`-release' is ignored for convenience libraries"
+	  func_warning "'-release' is ignored for convenience libraries"
       else
 
 	# Parse the version information argument.
-	save_ifs="$IFS"; IFS=':'
+	save_ifs=$IFS; IFS=:
 	set dummy $vinfo 0 0 0
 	shift
-	IFS="$save_ifs"
+	IFS=$save_ifs
 
 	test -n "$7" && \
-	  func_fatal_help "too many parameters to \`-version-info'"
+	  func_fatal_help "too many parameters to '-version-info'"
 
 	# convert absolute version numbers to libtool ages
 	# this retains compatibility with .la files and attempts
@@ -7322,45 +8793,42 @@ func_mode_link ()
 
 	case $vinfo_number in
 	yes)
-	  number_major="$1"
-	  number_minor="$2"
-	  number_revision="$3"
+	  number_major=$1
+	  number_minor=$2
+	  number_revision=$3
 	  #
 	  # There are really only two kinds -- those that
 	  # use the current revision as the major version
 	  # and those that subtract age and use age as
 	  # a minor version.  But, then there is irix
-	  # which has an extra 1 added just for fun
+	  # that has an extra 1 added just for fun
 	  #
 	  case $version_type in
 	  # correct linux to gnu/linux during the next big refactor
-	  darwin|linux|osf|windows|none)
+	  darwin|freebsd-elf|linux|osf|windows|none)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_revision"
+	    age=$number_minor
+	    revision=$number_revision
 	    ;;
-	  freebsd-aout|freebsd-elf|qnx|sunos)
-	    current="$number_major"
-	    revision="$number_minor"
-	    age="0"
+	  freebsd-aout|qnx|sunos)
+	    current=$number_major
+	    revision=$number_minor
+	    age=0
 	    ;;
 	  irix|nonstopux)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_minor"
+	    age=$number_minor
+	    revision=$number_minor
 	    lt_irix_increment=no
 	    ;;
-	  *)
-	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
-	    ;;
 	  esac
 	  ;;
 	no)
-	  current="$1"
-	  revision="$2"
-	  age="$3"
+	  current=$1
+	  revision=$2
+	  age=$3
 	  ;;
 	esac
 
@@ -7368,30 +8836,30 @@ func_mode_link ()
 	case $current in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "CURRENT \`$current' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "CURRENT '$current' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	case $revision in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "REVISION \`$revision' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "REVISION '$revision' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	case $age in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "AGE \`$age' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "AGE '$age' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	if test "$age" -gt "$current"; then
-	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "AGE '$age' is greater than the current interface number '$current'"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	fi
 
 	# Calculate the version variables.
@@ -7406,26 +8874,36 @@ func_mode_link ()
 	  # verstring for coding it into the library header
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
+	  versuffix=$major.$age.$revision
 	  # Darwin ld doesn't like 0 for these options...
 	  func_arith $current + 1
 	  minor_current=$func_arith_result
-	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
 	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+          # On Darwin other compilers
+          case $CC in
+              nagfor*)
+                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
+                  ;;
+              *)
+                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+                  ;;
+          esac
 	  ;;
 
 	freebsd-aout)
-	  major=".$current"
-	  versuffix=".$current.$revision";
+	  major=.$current
+	  versuffix=.$current.$revision
 	  ;;
 
 	freebsd-elf)
-	  major=".$current"
-	  versuffix=".$current"
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix=$major.$age.$revision
 	  ;;
 
 	irix | nonstopux)
-	  if test "X$lt_irix_increment" = "Xno"; then
+	  if test no = "$lt_irix_increment"; then
 	    func_arith $current - $age
 	  else
 	    func_arith $current - $age + 1
@@ -7436,69 +8914,74 @@ func_mode_link ()
 	    nonstopux) verstring_prefix=nonstopux ;;
 	    *)         verstring_prefix=sgi ;;
 	  esac
-	  verstring="$verstring_prefix$major.$revision"
+	  verstring=$verstring_prefix$major.$revision
 
 	  # Add in all the interfaces that we are compatible with.
 	  loop=$revision
-	  while test "$loop" -ne 0; do
+	  while test 0 -ne "$loop"; do
 	    func_arith $revision - $loop
 	    iface=$func_arith_result
 	    func_arith $loop - 1
 	    loop=$func_arith_result
-	    verstring="$verstring_prefix$major.$iface:$verstring"
+	    verstring=$verstring_prefix$major.$iface:$verstring
 	  done
 
-	  # Before this point, $major must not contain `.'.
+	  # Before this point, $major must not contain '.'.
 	  major=.$major
-	  versuffix="$major.$revision"
+	  versuffix=$major.$revision
 	  ;;
 
 	linux) # correct to gnu/linux during the next big refactor
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
+	  versuffix=$major.$age.$revision
 	  ;;
 
 	osf)
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix=".$current.$age.$revision"
-	  verstring="$current.$age.$revision"
+	  versuffix=.$current.$age.$revision
+	  verstring=$current.$age.$revision
 
 	  # Add in all the interfaces that we are compatible with.
 	  loop=$age
-	  while test "$loop" -ne 0; do
+	  while test 0 -ne "$loop"; do
 	    func_arith $current - $loop
 	    iface=$func_arith_result
 	    func_arith $loop - 1
 	    loop=$func_arith_result
-	    verstring="$verstring:${iface}.0"
+	    verstring=$verstring:$iface.0
 	  done
 
 	  # Make executables depend on our current version.
-	  func_append verstring ":${current}.0"
+	  func_append verstring ":$current.0"
 	  ;;
 
 	qnx)
-	  major=".$current"
-	  versuffix=".$current"
+	  major=.$current
+	  versuffix=.$current
+	  ;;
+
+	sco)
+	  major=.$current
+	  versuffix=.$current
 	  ;;
 
 	sunos)
-	  major=".$current"
-	  versuffix=".$current.$revision"
+	  major=.$current
+	  versuffix=.$current.$revision
 	  ;;
 
 	windows)
 	  # Use '-' rather than '.', since we only want one
-	  # extension on DOS 8.3 filesystems.
+	  # extension on DOS 8.3 file systems.
 	  func_arith $current - $age
 	  major=$func_arith_result
-	  versuffix="-$major"
+	  versuffix=-$major
 	  ;;
 
 	*)
-	  func_fatal_configuration "unknown library version type \`$version_type'"
+	  func_fatal_configuration "unknown library version type '$version_type'"
 	  ;;
 	esac
 
@@ -7512,42 +8995,45 @@ func_mode_link ()
 	    verstring=
 	    ;;
 	  *)
-	    verstring="0.0"
+	    verstring=0.0
 	    ;;
 	  esac
-	  if test "$need_version" = no; then
+	  if test no = "$need_version"; then
 	    versuffix=
 	  else
-	    versuffix=".0.0"
+	    versuffix=.0.0
 	  fi
 	fi
 
 	# Remove version info from name if versioning should be avoided
-	if test "$avoid_version" = yes && test "$need_version" = no; then
+	if test yes,no = "$avoid_version,$need_version"; then
 	  major=
 	  versuffix=
-	  verstring=""
+	  verstring=
 	fi
 
 	# Check to see if the archive will have undefined symbols.
-	if test "$allow_undefined" = yes; then
-	  if test "$allow_undefined_flag" = unsupported; then
-	    func_warning "undefined symbols not allowed in $host shared libraries"
-	    build_libtool_libs=no
-	    build_old_libs=yes
+	if test yes = "$allow_undefined"; then
+	  if test unsupported = "$allow_undefined_flag"; then
+	    if test yes = "$build_old_libs"; then
+	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
+	      build_libtool_libs=no
+	    else
+	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
+	    fi
 	  fi
 	else
 	  # Don't allow undefined symbols.
-	  allow_undefined_flag="$no_undefined_flag"
+	  allow_undefined_flag=$no_undefined_flag
 	fi
 
       fi
 
-      func_generate_dlsyms "$libname" "$libname" "yes"
+      func_generate_dlsyms "$libname" "$libname" :
       func_append libobjs " $symfileobj"
-      test "X$libobjs" = "X " && libobjs=
+      test " " = "$libobjs" && libobjs=
 
-      if test "$opt_mode" != relink; then
+      if test relink != "$opt_mode"; then
 	# Remove our outputs, but don't remove object files since they
 	# may have been created when compiling PIC objects.
 	removelist=
@@ -7556,8 +9042,8 @@ func_mode_link ()
 	  case $p in
 	    *.$objext | *.gcno)
 	       ;;
-	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
-	       if test "X$precious_files_regex" != "X"; then
+	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
+	       if test -n "$precious_files_regex"; then
 		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
 		 then
 		   continue
@@ -7573,11 +9059,11 @@ func_mode_link ()
       fi
 
       # Now set the variables for building old libraries.
-      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
 	func_append oldlibs " $output_objdir/$libname.$libext"
 
 	# Transform .lo files to .o files.
-	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
+	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
       fi
 
       # Eliminate all temporary directories.
@@ -7598,13 +9084,13 @@ func_mode_link ()
 	  *) func_append finalize_rpath " $libdir" ;;
 	  esac
 	done
-	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
 	  dependency_libs="$temp_xrpath $dependency_libs"
 	fi
       fi
 
       # Make sure dlfiles contains only unique files that won't be dlpreopened
-      old_dlfiles="$dlfiles"
+      old_dlfiles=$dlfiles
       dlfiles=
       for lib in $old_dlfiles; do
 	case " $dlprefiles $dlfiles " in
@@ -7614,7 +9100,7 @@ func_mode_link ()
       done
 
       # Make sure dlprefiles contains only unique files
-      old_dlprefiles="$dlprefiles"
+      old_dlprefiles=$dlprefiles
       dlprefiles=
       for lib in $old_dlprefiles; do
 	case "$dlprefiles " in
@@ -7623,7 +9109,7 @@ func_mode_link ()
 	esac
       done
 
-      if test "$build_libtool_libs" = yes; then
+      if test yes = "$build_libtool_libs"; then
 	if test -n "$rpath"; then
 	  case $host in
 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
@@ -7647,7 +9133,7 @@ func_mode_link ()
 	    ;;
 	  *)
 	    # Add libc to deplibs on all other systems if necessary.
-	    if test "$build_libtool_need_lc" = "yes"; then
+	    if test yes = "$build_libtool_need_lc"; then
 	      func_append deplibs " -lc"
 	    fi
 	    ;;
@@ -7663,9 +9149,9 @@ func_mode_link ()
 	# I'm not sure if I'm treating the release correctly.  I think
 	# release should show up in the -l (ie -lgmp5) so we don't want to
 	# add it in twice.  Is that correct?
-	release=""
-	versuffix=""
-	major=""
+	release=
+	versuffix=
+	major=
 	newdeplibs=
 	droppeddeps=no
 	case $deplibs_check_method in
@@ -7694,20 +9180,20 @@ EOF
 	      -l*)
 		func_stripname -l '' "$i"
 		name=$func_stripname_result
-		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		  case " $predeps $postdeps " in
 		  *" $i "*)
 		    func_append newdeplibs " $i"
-		    i=""
+		    i=
 		    ;;
 		  esac
 		fi
-		if test -n "$i" ; then
+		if test -n "$i"; then
 		  libname=`eval "\\$ECHO \"$libname_spec\""`
 		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
 		  set dummy $deplib_matches; shift
 		  deplib_match=$1
-		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
 		    func_append newdeplibs " $i"
 		  else
 		    droppeddeps=yes
@@ -7737,20 +9223,20 @@ EOF
 		$opt_dry_run || $RM conftest
 		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
 		  ldd_output=`ldd conftest`
-		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		    case " $predeps $postdeps " in
 		    *" $i "*)
 		      func_append newdeplibs " $i"
-		      i=""
+		      i=
 		      ;;
 		    esac
 		  fi
-		  if test -n "$i" ; then
+		  if test -n "$i"; then
 		    libname=`eval "\\$ECHO \"$libname_spec\""`
 		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
 		    set dummy $deplib_matches; shift
 		    deplib_match=$1
-		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
 		      func_append newdeplibs " $i"
 		    else
 		      droppeddeps=yes
@@ -7787,24 +9273,24 @@ EOF
 	    -l*)
 	      func_stripname -l '' "$a_deplib"
 	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		case " $predeps $postdeps " in
 		*" $a_deplib "*)
 		  func_append newdeplibs " $a_deplib"
-		  a_deplib=""
+		  a_deplib=
 		  ;;
 		esac
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
 		if test -n "$file_magic_glob"; then
 		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
 		else
 		  libnameglob=$libname
 		fi
-		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
+		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  if test "$want_nocaseglob" = yes; then
+		  if test yes = "$want_nocaseglob"; then
 		    shopt -s nocaseglob
 		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
 		    $nocaseglob
@@ -7822,25 +9308,25 @@ EOF
 		      # We might still enter an endless loop, since a link
 		      # loop can be closed while we follow links,
 		      # but so what?
-		      potlib="$potent_lib"
+		      potlib=$potent_lib
 		      while test -h "$potlib" 2>/dev/null; do
-			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
 			case $potliblink in
-			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
-			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
+			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
+			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
 			esac
 		      done
 		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
 			 $SED -e 10q |
 			 $EGREP "$file_magic_regex" > /dev/null; then
 			func_append newdeplibs " $a_deplib"
-			a_deplib=""
+			a_deplib=
 			break 2
 		      fi
 		  done
 		done
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		droppeddeps=yes
 		echo
 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
@@ -7848,7 +9334,7 @@ EOF
 		echo "*** you link to this library.  But I can only do this if you have a"
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
+		if test -z "$potlib"; then
 		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
 		else
 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
@@ -7871,30 +9357,30 @@ EOF
 	    -l*)
 	      func_stripname -l '' "$a_deplib"
 	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		case " $predeps $postdeps " in
 		*" $a_deplib "*)
 		  func_append newdeplibs " $a_deplib"
-		  a_deplib=""
+		  a_deplib=
 		  ;;
 		esac
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
 		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
 		  for potent_lib in $potential_libs; do
-		    potlib="$potent_lib" # see symlink-check above in file_magic test
+		    potlib=$potent_lib # see symlink-check above in file_magic test
 		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
 		       $EGREP "$match_pattern_regex" > /dev/null; then
 		      func_append newdeplibs " $a_deplib"
-		      a_deplib=""
+		      a_deplib=
 		      break 2
 		    fi
 		  done
 		done
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		droppeddeps=yes
 		echo
 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
@@ -7902,7 +9388,7 @@ EOF
 		echo "*** you link to this library.  But I can only do this if you have a"
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
+		if test -z "$potlib"; then
 		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
 		else
 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
@@ -7918,18 +9404,18 @@ EOF
 	  done # Gone through all deplibs.
 	  ;;
 	none | unknown | *)
-	  newdeplibs=""
+	  newdeplibs=
 	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
-	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-	    for i in $predeps $postdeps ; do
+	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
+	    for i in $predeps $postdeps; do
 	      # can't use Xsed below, because $i might contain '/'
-	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
+	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
 	    done
 	  fi
 	  case $tmp_deplibs in
 	  *[!\	\ ]*)
 	    echo
-	    if test "X$deplibs_check_method" = "Xnone"; then
+	    if test none = "$deplibs_check_method"; then
 	      echo "*** Warning: inter-library dependencies are not supported in this platform."
 	    else
 	      echo "*** Warning: inter-library dependencies are not known to be supported."
@@ -7953,8 +9439,8 @@ EOF
 	  ;;
 	esac
 
-	if test "$droppeddeps" = yes; then
-	  if test "$module" = yes; then
+	if test yes = "$droppeddeps"; then
+	  if test yes = "$module"; then
 	    echo
 	    echo "*** Warning: libtool could not satisfy all declared inter-library"
 	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
@@ -7963,12 +9449,12 @@ EOF
 	    if test -z "$global_symbol_pipe"; then
 	      echo
 	      echo "*** However, this would only work if libtool was able to extract symbol"
-	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
 	      echo "*** not find such a program.  So, this module is probably useless."
-	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
+	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
 	    fi
-	    if test "$build_old_libs" = no; then
-	      oldlibs="$output_objdir/$libname.$libext"
+	    if test no = "$build_old_libs"; then
+	      oldlibs=$output_objdir/$libname.$libext
 	      build_libtool_libs=module
 	      build_old_libs=yes
 	    else
@@ -7979,14 +9465,14 @@ EOF
 	    echo "*** automatically added whenever a program is linked with this library"
 	    echo "*** or is declared to -dlopen it."
 
-	    if test "$allow_undefined" = no; then
+	    if test no = "$allow_undefined"; then
 	      echo
 	      echo "*** Since this library must not contain undefined symbols,"
 	      echo "*** because either the platform does not support them or"
 	      echo "*** it was explicitly requested with -no-undefined,"
 	      echo "*** libtool will only create a static version of it."
-	      if test "$build_old_libs" = no; then
-		oldlibs="$output_objdir/$libname.$libext"
+	      if test no = "$build_old_libs"; then
+		oldlibs=$output_objdir/$libname.$libext
 		build_libtool_libs=module
 		build_old_libs=yes
 	      else
@@ -8032,7 +9518,7 @@ EOF
 	*) func_append new_libs " $deplib" ;;
 	esac
       done
-      deplibs="$new_libs"
+      deplibs=$new_libs
 
       # All the library-specific variables (install_libdir is set above).
       library_names=
@@ -8040,25 +9526,25 @@ EOF
       dlname=
 
       # Test again, we may have decided not to build it any more
-      if test "$build_libtool_libs" = yes; then
-	# Remove ${wl} instances when linking with ld.
+      if test yes = "$build_libtool_libs"; then
+	# Remove $wl instances when linking with ld.
 	# FIXME: should test the right _cmds variable.
 	case $archive_cmds in
 	  *\$LD\ *) wl= ;;
         esac
-	if test "$hardcode_into_libs" = yes; then
+	if test yes = "$hardcode_into_libs"; then
 	  # Hardcode the library paths
 	  hardcode_libdirs=
 	  dep_rpath=
-	  rpath="$finalize_rpath"
-	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
+	  rpath=$finalize_rpath
+	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
 	  for libdir in $rpath; do
 	    if test -n "$hardcode_libdir_flag_spec"; then
 	      if test -n "$hardcode_libdir_separator"; then
 		func_replace_sysroot "$libdir"
 		libdir=$func_replace_sysroot_result
 		if test -z "$hardcode_libdirs"; then
-		  hardcode_libdirs="$libdir"
+		  hardcode_libdirs=$libdir
 		else
 		  # Just accumulate the unique libdirs.
 		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8083,7 +9569,7 @@ EOF
 	  # Substitute the hardcoded libdirs into the rpath.
 	  if test -n "$hardcode_libdir_separator" &&
 	     test -n "$hardcode_libdirs"; then
-	    libdir="$hardcode_libdirs"
+	    libdir=$hardcode_libdirs
 	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
 	  fi
 	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
@@ -8097,8 +9583,8 @@ EOF
 	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
 	fi
 
-	shlibpath="$finalize_shlibpath"
-	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+	shlibpath=$finalize_shlibpath
+	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
 	if test -n "$shlibpath"; then
 	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
 	fi
@@ -8108,19 +9594,19 @@ EOF
 	eval library_names=\"$library_names_spec\"
 	set dummy $library_names
 	shift
-	realname="$1"
+	realname=$1
 	shift
 
 	if test -n "$soname_spec"; then
 	  eval soname=\"$soname_spec\"
 	else
-	  soname="$realname"
+	  soname=$realname
 	fi
 	if test -z "$dlname"; then
 	  dlname=$soname
 	fi
 
-	lib="$output_objdir/$realname"
+	lib=$output_objdir/$realname
 	linknames=
 	for link
 	do
@@ -8134,7 +9620,7 @@ EOF
 	delfiles=
 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
 	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
-	  export_symbols="$output_objdir/$libname.uexp"
+	  export_symbols=$output_objdir/$libname.uexp
 	  func_append delfiles " $export_symbols"
 	fi
 
@@ -8143,31 +9629,31 @@ EOF
 	cygwin* | mingw* | cegcc*)
 	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
 	    # exporting using user supplied symfile
-	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+	    func_dll_def_p "$export_symbols" || {
 	      # and it's NOT already a .def file. Must figure out
 	      # which of the given symbols are data symbols and tag
 	      # them as such. So, trigger use of export_symbols_cmds.
 	      # export_symbols gets reassigned inside the "prepare
 	      # the list of exported symbols" if statement, so the
 	      # include_expsyms logic still works.
-	      orig_export_symbols="$export_symbols"
+	      orig_export_symbols=$export_symbols
 	      export_symbols=
 	      always_export_symbols=yes
-	    fi
+	    }
 	  fi
 	  ;;
 	esac
 
 	# Prepare the list of exported symbols
 	if test -z "$export_symbols"; then
-	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
-	    func_verbose "generating symbol list for \`$libname.la'"
-	    export_symbols="$output_objdir/$libname.exp"
+	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
+	    func_verbose "generating symbol list for '$libname.la'"
+	    export_symbols=$output_objdir/$libname.exp
 	    $opt_dry_run || $RM $export_symbols
 	    cmds=$export_symbols_cmds
-	    save_ifs="$IFS"; IFS='~'
+	    save_ifs=$IFS; IFS='~'
 	    for cmd1 in $cmds; do
-	      IFS="$save_ifs"
+	      IFS=$save_ifs
 	      # Take the normal branch if the nm_file_list_spec branch
 	      # doesn't work or if tool conversion is not needed.
 	      case $nm_file_list_spec~$to_tool_file_cmd in
@@ -8181,7 +9667,7 @@ EOF
 		  try_normal_branch=no
 		  ;;
 	      esac
-	      if test "$try_normal_branch" = yes \
+	      if test yes = "$try_normal_branch" \
 		 && { test "$len" -lt "$max_cmd_len" \
 		      || test "$max_cmd_len" -le -1; }
 	      then
@@ -8192,7 +9678,7 @@ EOF
 		output_la=$func_basename_result
 		save_libobjs=$libobjs
 		save_output=$output
-		output=${output_objdir}/${output_la}.nm
+		output=$output_objdir/$output_la.nm
 		func_to_tool_file "$output"
 		libobjs=$nm_file_list_spec$func_to_tool_file_result
 		func_append delfiles " $output"
@@ -8215,8 +9701,8 @@ EOF
 		break
 	      fi
 	    done
-	    IFS="$save_ifs"
-	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+	    IFS=$save_ifs
+	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
 	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
 	    fi
@@ -8224,16 +9710,16 @@ EOF
 	fi
 
 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	  tmp_export_symbols="$export_symbols"
-	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	  tmp_export_symbols=$export_symbols
+	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
 	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
 	fi
 
-	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
 	  # The given exports_symbols file has to be filtered, so filter it.
-	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
 	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	  # 's' commands which not all seds can handle. GNU sed should be fine
+	  # 's' commands, which not all seds can handle. GNU sed should be fine
 	  # though. Also, the filter scales superlinearly with the number of
 	  # global variables. join(1) would be nice here, but unfortunately
 	  # isn't a blessed tool.
@@ -8252,11 +9738,11 @@ EOF
 	    ;;
 	  esac
 	done
-	deplibs="$tmp_deplibs"
+	deplibs=$tmp_deplibs
 
 	if test -n "$convenience"; then
 	  if test -n "$whole_archive_flag_spec" &&
-	    test "$compiler_needs_object" = yes &&
+	    test yes = "$compiler_needs_object" &&
 	    test -z "$libobjs"; then
 	    # extract the archives, so we have objects to list.
 	    # TODO: could optimize this to just extract one archive.
@@ -8267,7 +9753,7 @@ EOF
 	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
 	    test "X$libobjs" = "X " && libobjs=
 	  else
-	    gentop="$output_objdir/${outputname}x"
+	    gentop=$output_objdir/${outputname}x
 	    func_append generated " $gentop"
 
 	    func_extract_archives $gentop $convenience
@@ -8276,18 +9762,18 @@ EOF
 	  fi
 	fi
 
-	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
 	  eval flag=\"$thread_safe_flag_spec\"
 	  func_append linker_flags " $flag"
 	fi
 
 	# Make a backup of the uninstalled library when relinking
-	if test "$opt_mode" = relink; then
+	if test relink = "$opt_mode"; then
 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
 	fi
 
 	# Do each of the archive commands.
-	if test "$module" = yes && test -n "$module_cmds" ; then
+	if test yes = "$module" && test -n "$module_cmds"; then
 	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
 	    eval test_cmds=\"$module_expsym_cmds\"
 	    cmds=$module_expsym_cmds
@@ -8305,7 +9791,7 @@ EOF
 	  fi
 	fi
 
-	if test "X$skipped_export" != "X:" &&
+	if test : != "$skipped_export" &&
 	   func_len " $test_cmds" &&
 	   len=$func_len_result &&
 	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
@@ -8338,8 +9824,8 @@ EOF
 	  last_robj=
 	  k=1
 
-	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
-	    output=${output_objdir}/${output_la}.lnkscript
+	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
+	    output=$output_objdir/$output_la.lnkscript
 	    func_verbose "creating GNU ld script: $output"
 	    echo 'INPUT (' > $output
 	    for obj in $save_libobjs
@@ -8351,14 +9837,14 @@ EOF
 	    func_append delfiles " $output"
 	    func_to_tool_file "$output"
 	    output=$func_to_tool_file_result
-	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
-	    output=${output_objdir}/${output_la}.lnk
+	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
+	    output=$output_objdir/$output_la.lnk
 	    func_verbose "creating linker input file list: $output"
 	    : > $output
 	    set x $save_libobjs
 	    shift
 	    firstobj=
-	    if test "$compiler_needs_object" = yes; then
+	    if test yes = "$compiler_needs_object"; then
 	      firstobj="$1 "
 	      shift
 	    fi
@@ -8373,7 +9859,7 @@ EOF
 	  else
 	    if test -n "$save_libobjs"; then
 	      func_verbose "creating reloadable object files..."
-	      output=$output_objdir/$output_la-${k}.$objext
+	      output=$output_objdir/$output_la-$k.$objext
 	      eval test_cmds=\"$reload_cmds\"
 	      func_len " $test_cmds"
 	      len0=$func_len_result
@@ -8385,13 +9871,13 @@ EOF
 		func_len " $obj"
 		func_arith $len + $func_len_result
 		len=$func_arith_result
-		if test "X$objlist" = X ||
+		if test -z "$objlist" ||
 		   test "$len" -lt "$max_cmd_len"; then
 		  func_append objlist " $obj"
 		else
 		  # The command $test_cmds is almost too long, add a
 		  # command to the queue.
-		  if test "$k" -eq 1 ; then
+		  if test 1 -eq "$k"; then
 		    # The first file doesn't have a previous command to add.
 		    reload_objs=$objlist
 		    eval concat_cmds=\"$reload_cmds\"
@@ -8401,10 +9887,10 @@ EOF
 		    reload_objs="$objlist $last_robj"
 		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
 		  fi
-		  last_robj=$output_objdir/$output_la-${k}.$objext
+		  last_robj=$output_objdir/$output_la-$k.$objext
 		  func_arith $k + 1
 		  k=$func_arith_result
-		  output=$output_objdir/$output_la-${k}.$objext
+		  output=$output_objdir/$output_la-$k.$objext
 		  objlist=" $obj"
 		  func_len " $last_robj"
 		  func_arith $len0 + $func_len_result
@@ -8416,9 +9902,9 @@ EOF
 	      # files will link in the last one created.
 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
 	      reload_objs="$objlist $last_robj"
-	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
+	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
 	      if test -n "$last_robj"; then
-	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
 	      fi
 	      func_append delfiles " $output"
 
@@ -8426,9 +9912,9 @@ EOF
 	      output=
 	    fi
 
-	    if ${skipped_export-false}; then
-	      func_verbose "generating symbol list for \`$libname.la'"
-	      export_symbols="$output_objdir/$libname.exp"
+	    ${skipped_export-false} && {
+	      func_verbose "generating symbol list for '$libname.la'"
+	      export_symbols=$output_objdir/$libname.exp
 	      $opt_dry_run || $RM $export_symbols
 	      libobjs=$output
 	      # Append the command to create the export file.
@@ -8437,16 +9923,16 @@ EOF
 	      if test -n "$last_robj"; then
 		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
 	      fi
-	    fi
+	    }
 
 	    test -n "$save_libobjs" &&
 	      func_verbose "creating a temporary reloadable object file: $output"
 
 	    # Loop through the commands generated above and execute them.
-	    save_ifs="$IFS"; IFS='~'
+	    save_ifs=$IFS; IFS='~'
 	    for cmd in $concat_cmds; do
-	      IFS="$save_ifs"
-	      $opt_silent || {
+	      IFS=$save_ifs
+	      $opt_quiet || {
 		  func_quote_for_expand "$cmd"
 		  eval "func_echo $func_quote_for_expand_result"
 	      }
@@ -8454,7 +9940,7 @@ EOF
 		lt_exit=$?
 
 		# Restore the uninstalled library and exit
-		if test "$opt_mode" = relink; then
+		if test relink = "$opt_mode"; then
 		  ( cd "$output_objdir" && \
 		    $RM "${realname}T" && \
 		    $MV "${realname}U" "$realname" )
@@ -8463,7 +9949,7 @@ EOF
 		exit $lt_exit
 	      }
 	    done
-	    IFS="$save_ifs"
+	    IFS=$save_ifs
 
 	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
@@ -8471,18 +9957,18 @@ EOF
 	    fi
 	  fi
 
-          if ${skipped_export-false}; then
+          ${skipped_export-false} && {
 	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	      tmp_export_symbols="$export_symbols"
-	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	      tmp_export_symbols=$export_symbols
+	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
 	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
 	    fi
 
 	    if test -n "$orig_export_symbols"; then
 	      # The given exports_symbols file has to be filtered, so filter it.
-	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
 	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	      # 's' commands which not all seds can handle. GNU sed should be fine
+	      # 's' commands, which not all seds can handle. GNU sed should be fine
 	      # though. Also, the filter scales superlinearly with the number of
 	      # global variables. join(1) would be nice here, but unfortunately
 	      # isn't a blessed tool.
@@ -8491,7 +9977,7 @@ EOF
 	      export_symbols=$output_objdir/$libname.def
 	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
 	    fi
-	  fi
+	  }
 
 	  libobjs=$output
 	  # Restore the value of output.
@@ -8505,7 +9991,7 @@ EOF
 	  # value of $libobjs for piecewise linking.
 
 	  # Do each of the archive commands.
-	  if test "$module" = yes && test -n "$module_cmds" ; then
+	  if test yes = "$module" && test -n "$module_cmds"; then
 	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
 	      cmds=$module_expsym_cmds
 	    else
@@ -8527,7 +10013,7 @@ EOF
 
 	# Add any objects from preloaded convenience libraries
 	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $dlprefiles
@@ -8535,11 +10021,12 @@ EOF
 	  test "X$libobjs" = "X " && libobjs=
 	fi
 
-	save_ifs="$IFS"; IFS='~'
+	save_ifs=$IFS; IFS='~'
 	for cmd in $cmds; do
-	  IFS="$save_ifs"
+	  IFS=$sp$nl
 	  eval cmd=\"$cmd\"
-	  $opt_silent || {
+	  IFS=$save_ifs
+	  $opt_quiet || {
 	    func_quote_for_expand "$cmd"
 	    eval "func_echo $func_quote_for_expand_result"
 	  }
@@ -8547,7 +10034,7 @@ EOF
 	    lt_exit=$?
 
 	    # Restore the uninstalled library and exit
-	    if test "$opt_mode" = relink; then
+	    if test relink = "$opt_mode"; then
 	      ( cd "$output_objdir" && \
 	        $RM "${realname}T" && \
 		$MV "${realname}U" "$realname" )
@@ -8556,10 +10043,10 @@ EOF
 	    exit $lt_exit
 	  }
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 
 	# Restore the uninstalled library and exit
-	if test "$opt_mode" = relink; then
+	if test relink = "$opt_mode"; then
 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
 
 	  if test -n "$convenience"; then
@@ -8579,39 +10066,39 @@ EOF
 	done
 
 	# If -module or -export-dynamic was specified, set the dlname.
-	if test "$module" = yes || test "$export_dynamic" = yes; then
+	if test yes = "$module" || test yes = "$export_dynamic"; then
 	  # On all known operating systems, these are identical.
-	  dlname="$soname"
+	  dlname=$soname
 	fi
       fi
       ;;
 
     obj)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for objects"
+      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
+	func_warning "'-dlopen' is ignored for objects"
       fi
 
       case " $deplibs" in
       *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for objects" ;;
+	func_warning "'-l' and '-L' are ignored for objects" ;;
       esac
 
       test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for objects"
+	func_warning "'-rpath' is ignored for objects"
 
       test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for objects"
+	func_warning "'-R' is ignored for objects"
 
       test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for objects"
+	func_warning "'-version-info' is ignored for objects"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for objects"
+	func_warning "'-release' is ignored for objects"
 
       case $output in
       *.lo)
 	test -n "$objs$old_deplibs" && \
-	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
 
 	libobj=$output
 	func_lo2o "$libobj"
@@ -8619,7 +10106,7 @@ EOF
 	;;
       *)
 	libobj=
-	obj="$output"
+	obj=$output
 	;;
       esac
 
@@ -8632,17 +10119,19 @@ EOF
       # the extraction.
       reload_conv_objs=
       gentop=
-      # reload_cmds runs $LD directly, so let us get rid of
-      # -Wl from whole_archive_flag_spec and hope we can get by with
-      # turning comma into space..
-      wl=
-
+      # if reload_cmds runs $LD directly, get rid of -Wl from
+      # whole_archive_flag_spec and hope we can get by with turning comma
+      # into space.
+      case $reload_cmds in
+        *\$LD[\ \$]*) wl= ;;
+      esac
       if test -n "$convenience"; then
 	if test -n "$whole_archive_flag_spec"; then
 	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
-	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
 	else
-	  gentop="$output_objdir/${obj}x"
+	  gentop=$output_objdir/${obj}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $convenience
@@ -8651,12 +10140,12 @@ EOF
       fi
 
       # If we're not building shared, we need to use non_pic_objs
-      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
+      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
 
       # Create the old-style object.
-      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
 
-      output="$obj"
+      output=$obj
       func_execute_cmds "$reload_cmds" 'exit $?'
 
       # Exit if we aren't doing a library object file.
@@ -8668,7 +10157,7 @@ EOF
 	exit $EXIT_SUCCESS
       fi
 
-      if test "$build_libtool_libs" != yes; then
+      test yes = "$build_libtool_libs" || {
 	if test -n "$gentop"; then
 	  func_show_eval '${RM}r "$gentop"'
 	fi
@@ -8678,12 +10167,12 @@ EOF
 	# $show "echo timestamp > $libobj"
 	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
 	exit $EXIT_SUCCESS
-      fi
+      }
 
-      if test -n "$pic_flag" || test "$pic_mode" != default; then
+      if test -n "$pic_flag" || test default != "$pic_mode"; then
 	# Only do commands if we really have different PIC objects.
 	reload_objs="$libobjs $reload_conv_objs"
-	output="$libobj"
+	output=$libobj
 	func_execute_cmds "$reload_cmds" 'exit $?'
       fi
 
@@ -8700,16 +10189,14 @@ EOF
 	          output=$func_stripname_result.exe;;
       esac
       test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for programs"
+	func_warning "'-version-info' is ignored for programs"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for programs"
+	func_warning "'-release' is ignored for programs"
 
-      test "$preload" = yes \
-        && test "$dlopen_support" = unknown \
-	&& test "$dlopen_self" = unknown \
-	&& test "$dlopen_self_static" = unknown && \
-	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+      $preload \
+	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
+	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
 
       case $host in
       *-*-rhapsody* | *-*-darwin1.[012])
@@ -8723,11 +10210,11 @@ EOF
       *-*-darwin*)
 	# Don't allow lazy linking, it breaks C++ global constructors
 	# But is supposedly fixed on 10.4 or later (yay!).
-	if test "$tagname" = CXX ; then
+	if test CXX = "$tagname"; then
 	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
 	    10.[0123])
-	      func_append compile_command " ${wl}-bind_at_load"
-	      func_append finalize_command " ${wl}-bind_at_load"
+	      func_append compile_command " $wl-bind_at_load"
+	      func_append finalize_command " $wl-bind_at_load"
 	    ;;
 	  esac
 	fi
@@ -8763,7 +10250,7 @@ EOF
 	*) func_append new_libs " $deplib" ;;
 	esac
       done
-      compile_deplibs="$new_libs"
+      compile_deplibs=$new_libs
 
 
       func_append compile_command " $compile_deplibs"
@@ -8787,7 +10274,7 @@ EOF
 	if test -n "$hardcode_libdir_flag_spec"; then
 	  if test -n "$hardcode_libdir_separator"; then
 	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
+	      hardcode_libdirs=$libdir
 	    else
 	      # Just accumulate the unique libdirs.
 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8810,7 +10297,7 @@ EOF
 	fi
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
-	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$libdir:"*) ;;
 	  ::) dllsearchpath=$libdir;;
@@ -8827,10 +10314,10 @@ EOF
       # Substitute the hardcoded libdirs into the rpath.
       if test -n "$hardcode_libdir_separator" &&
 	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
+	libdir=$hardcode_libdirs
 	eval rpath=\" $hardcode_libdir_flag_spec\"
       fi
-      compile_rpath="$rpath"
+      compile_rpath=$rpath
 
       rpath=
       hardcode_libdirs=
@@ -8838,7 +10325,7 @@ EOF
 	if test -n "$hardcode_libdir_flag_spec"; then
 	  if test -n "$hardcode_libdir_separator"; then
 	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
+	      hardcode_libdirs=$libdir
 	    else
 	      # Just accumulate the unique libdirs.
 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8863,45 +10350,43 @@ EOF
       # Substitute the hardcoded libdirs into the rpath.
       if test -n "$hardcode_libdir_separator" &&
 	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
+	libdir=$hardcode_libdirs
 	eval rpath=\" $hardcode_libdir_flag_spec\"
       fi
-      finalize_rpath="$rpath"
+      finalize_rpath=$rpath
 
-      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+      if test -n "$libobjs" && test yes = "$build_old_libs"; then
 	# Transform all the library objects into standard objects.
 	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
 	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
       fi
 
-      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+      func_generate_dlsyms "$outputname" "@PROGRAM@" false
 
       # template prelinking step
       if test -n "$prelink_cmds"; then
 	func_execute_cmds "$prelink_cmds" 'exit $?'
       fi
 
-      wrappers_required=yes
+      wrappers_required=:
       case $host in
       *cegcc* | *mingw32ce*)
         # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
-        wrappers_required=no
+        wrappers_required=false
         ;;
       *cygwin* | *mingw* )
-        if test "$build_libtool_libs" != yes; then
-          wrappers_required=no
-        fi
+        test yes = "$build_libtool_libs" || wrappers_required=false
         ;;
       *)
-        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
-          wrappers_required=no
+        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
+          wrappers_required=false
         fi
         ;;
       esac
-      if test "$wrappers_required" = no; then
+      $wrappers_required || {
 	# Replace the output file specification.
 	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
-	link_command="$compile_command$compile_rpath"
+	link_command=$compile_command$compile_rpath
 
 	# We have no uninstalled library dependencies, so finalize right now.
 	exit_status=0
@@ -8914,12 +10399,12 @@ EOF
 	fi
 
 	# Delete the generated files.
-	if test -f "$output_objdir/${outputname}S.${objext}"; then
-	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+	if test -f "$output_objdir/${outputname}S.$objext"; then
+	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
 	fi
 
 	exit $exit_status
-      fi
+      }
 
       if test -n "$compile_shlibpath$finalize_shlibpath"; then
 	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
@@ -8949,9 +10434,9 @@ EOF
 	fi
       fi
 
-      if test "$no_install" = yes; then
+      if test yes = "$no_install"; then
 	# We don't need to create a wrapper script.
-	link_command="$compile_var$compile_command$compile_rpath"
+	link_command=$compile_var$compile_command$compile_rpath
 	# Replace the output file specification.
 	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
 	# Delete the old output file.
@@ -8968,27 +10453,28 @@ EOF
 	exit $EXIT_SUCCESS
       fi
 
-      if test "$hardcode_action" = relink; then
-	# Fast installation is not supported
-	link_command="$compile_var$compile_command$compile_rpath"
-	relink_command="$finalize_var$finalize_command$finalize_rpath"
+      case $hardcode_action,$fast_install in
+        relink,*)
+	  # Fast installation is not supported
+	  link_command=$compile_var$compile_command$compile_rpath
+	  relink_command=$finalize_var$finalize_command$finalize_rpath
 
-	func_warning "this platform does not like uninstalled shared libraries"
-	func_warning "\`$output' will be relinked during installation"
-      else
-	if test "$fast_install" != no; then
-	  link_command="$finalize_var$compile_command$finalize_rpath"
-	  if test "$fast_install" = yes; then
-	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
-	  else
-	    # fast_install is set to needless
-	    relink_command=
-	  fi
-	else
-	  link_command="$compile_var$compile_command$compile_rpath"
-	  relink_command="$finalize_var$finalize_command$finalize_rpath"
-	fi
-      fi
+	  func_warning "this platform does not like uninstalled shared libraries"
+	  func_warning "'$output' will be relinked during installation"
+	  ;;
+        *,yes)
+	  link_command=$finalize_var$compile_command$finalize_rpath
+	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
+          ;;
+	*,no)
+	  link_command=$compile_var$compile_command$compile_rpath
+	  relink_command=$finalize_var$finalize_command$finalize_rpath
+          ;;
+	*,needless)
+	  link_command=$finalize_var$compile_command$finalize_rpath
+	  relink_command=
+          ;;
+      esac
 
       # Replace the output file specification.
       link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
@@ -9045,8 +10531,8 @@ EOF
 	    func_dirname_and_basename "$output" "" "."
 	    output_name=$func_basename_result
 	    output_path=$func_dirname_result
-	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
-	    cwrapper="$output_path/$output_name.exe"
+	    cwrappersource=$output_path/$objdir/lt-$output_name.c
+	    cwrapper=$output_path/$output_name.exe
 	    $RM $cwrappersource $cwrapper
 	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
 
@@ -9067,7 +10553,7 @@ EOF
 	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
 	    $opt_dry_run || {
 	      # note: this script will not be executed, so do not chmod.
-	      if test "x$build" = "x$host" ; then
+	      if test "x$build" = "x$host"; then
 		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
 	      else
 		func_emit_wrapper no > $func_ltwrapper_scriptname_result
@@ -9090,25 +10576,27 @@ EOF
     # See if we need to build an old-fashioned archive.
     for oldlib in $oldlibs; do
 
-      if test "$build_libtool_libs" = convenience; then
-	oldobjs="$libobjs_save $symfileobj"
-	addlibs="$convenience"
-	build_libtool_libs=no
-      else
-	if test "$build_libtool_libs" = module; then
-	  oldobjs="$libobjs_save"
+      case $build_libtool_libs in
+        convenience)
+	  oldobjs="$libobjs_save $symfileobj"
+	  addlibs=$convenience
 	  build_libtool_libs=no
-	else
+	  ;;
+	module)
+	  oldobjs=$libobjs_save
+	  addlibs=$old_convenience
+	  build_libtool_libs=no
+          ;;
+	*)
 	  oldobjs="$old_deplibs $non_pic_objects"
-	  if test "$preload" = yes && test -f "$symfileobj"; then
-	    func_append oldobjs " $symfileobj"
-	  fi
-	fi
-	addlibs="$old_convenience"
-      fi
+	  $preload && test -f "$symfileobj" \
+	    && func_append oldobjs " $symfileobj"
+	  addlibs=$old_convenience
+	  ;;
+      esac
 
       if test -n "$addlibs"; then
-	gentop="$output_objdir/${outputname}x"
+	gentop=$output_objdir/${outputname}x
 	func_append generated " $gentop"
 
 	func_extract_archives $gentop $addlibs
@@ -9116,13 +10604,13 @@ EOF
       fi
 
       # Do each command in the archive commands.
-      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
 	cmds=$old_archive_from_new_cmds
       else
 
 	# Add any objects from preloaded convenience libraries
 	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $dlprefiles
@@ -9143,7 +10631,7 @@ EOF
 	  :
 	else
 	  echo "copying selected object files to avoid basename conflicts..."
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 	  func_mkdir_p "$gentop"
 	  save_oldobjs=$oldobjs
@@ -9152,7 +10640,7 @@ EOF
 	  for obj in $save_oldobjs
 	  do
 	    func_basename "$obj"
-	    objbase="$func_basename_result"
+	    objbase=$func_basename_result
 	    case " $oldobjs " in
 	    " ") oldobjs=$obj ;;
 	    *[\ /]"$objbase "*)
@@ -9221,18 +10709,18 @@ EOF
 	    else
 	      # the above command should be used before it gets too long
 	      oldobjs=$objlist
-	      if test "$obj" = "$last_oldobj" ; then
+	      if test "$obj" = "$last_oldobj"; then
 		RANLIB=$save_RANLIB
 	      fi
 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
-	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
 	      objlist=
 	      len=$len0
 	    fi
 	  done
 	  RANLIB=$save_RANLIB
 	  oldobjs=$objlist
-	  if test "X$oldobjs" = "X" ; then
+	  if test -z "$oldobjs"; then
 	    eval cmds=\"\$concat_cmds\"
 	  else
 	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
@@ -9249,7 +10737,7 @@ EOF
     case $output in
     *.la)
       old_library=
-      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      test yes = "$build_old_libs" && old_library=$libname.$libext
       func_verbose "creating $output"
 
       # Preserve any variables that may affect compiler behavior
@@ -9264,31 +10752,31 @@ EOF
 	fi
       done
       # Quote the link command for shipping.
-      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
       relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
-      if test "$hardcode_automatic" = yes ; then
+      if test yes = "$hardcode_automatic"; then
 	relink_command=
       fi
 
       # Only create the output if not a dry run.
       $opt_dry_run || {
 	for installed in no yes; do
-	  if test "$installed" = yes; then
+	  if test yes = "$installed"; then
 	    if test -z "$install_libdir"; then
 	      break
 	    fi
-	    output="$output_objdir/$outputname"i
+	    output=$output_objdir/${outputname}i
 	    # Replace all uninstalled libtool libraries with the installed ones
 	    newdependency_libs=
 	    for deplib in $dependency_libs; do
 	      case $deplib in
 	      *.la)
 		func_basename "$deplib"
-		name="$func_basename_result"
+		name=$func_basename_result
 		func_resolve_sysroot "$deplib"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$deplib' is not a valid libtool archive"
+		  func_fatal_error "'$deplib' is not a valid libtool archive"
 		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      -L*)
@@ -9304,23 +10792,23 @@ EOF
 	      *) func_append newdependency_libs " $deplib" ;;
 	      esac
 	    done
-	    dependency_libs="$newdependency_libs"
+	    dependency_libs=$newdependency_libs
 	    newdlfiles=
 
 	    for lib in $dlfiles; do
 	      case $lib in
 	      *.la)
 	        func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		name=$func_basename_result
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		  func_fatal_error "'$lib' is not a valid libtool archive"
 		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      *) func_append newdlfiles " $lib" ;;
 	      esac
 	    done
-	    dlfiles="$newdlfiles"
+	    dlfiles=$newdlfiles
 	    newdlprefiles=
 	    for lib in $dlprefiles; do
 	      case $lib in
@@ -9330,34 +10818,34 @@ EOF
 		# didn't already link the preopened objects directly into
 		# the library:
 		func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		name=$func_basename_result
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		  func_fatal_error "'$lib' is not a valid libtool archive"
 		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      esac
 	    done
-	    dlprefiles="$newdlprefiles"
+	    dlprefiles=$newdlprefiles
 	  else
 	    newdlfiles=
 	    for lib in $dlfiles; do
 	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
 		*) abs=`pwd`"/$lib" ;;
 	      esac
 	      func_append newdlfiles " $abs"
 	    done
-	    dlfiles="$newdlfiles"
+	    dlfiles=$newdlfiles
 	    newdlprefiles=
 	    for lib in $dlprefiles; do
 	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
 		*) abs=`pwd`"/$lib" ;;
 	      esac
 	      func_append newdlprefiles " $abs"
 	    done
-	    dlprefiles="$newdlprefiles"
+	    dlprefiles=$newdlprefiles
 	  fi
 	  $RM $output
 	  # place dlname in correct position for cygwin
@@ -9373,10 +10861,9 @@ EOF
 	  case $host,$output,$installed,$module,$dlname in
 	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
 	      # If a -bindir argument was supplied, place the dll there.
-	      if test "x$bindir" != x ;
-	      then
+	      if test -n "$bindir"; then
 		func_relative_path "$install_libdir" "$bindir"
-		tdlname=$func_relative_path_result$dlname
+		tdlname=$func_relative_path_result/$dlname
 	      else
 		# Otherwise fall back on heuristic.
 		tdlname=../bin/$dlname
@@ -9385,7 +10872,7 @@ EOF
 	  esac
 	  $ECHO > $output "\
 # $outputname - a libtool library file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.
@@ -9399,7 +10886,7 @@ library_names='$library_names'
 # The name of the static archive.
 old_library='$old_library'
 
-# Linker flags that can not go in dependency_libs.
+# Linker flags that cannot go in dependency_libs.
 inherited_linker_flags='$new_inherited_linker_flags'
 
 # Libraries that this one depends upon.
@@ -9425,7 +10912,7 @@ dlpreopen='$dlprefiles'
 
 # Directory that this library needs to be installed in:
 libdir='$install_libdir'"
-	  if test "$installed" = no && test "$need_relink" = yes; then
+	  if test no,yes = "$installed,$need_relink"; then
 	    $ECHO >> $output "\
 relink_command=\"$relink_command\""
 	  fi
@@ -9440,27 +10927,29 @@ relink_command=\"$relink_command\""
     exit $EXIT_SUCCESS
 }
 
-{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
-    func_mode_link ${1+"$@"}
+if test link = "$opt_mode" || test relink = "$opt_mode"; then
+  func_mode_link ${1+"$@"}
+fi
 
 
 # func_mode_uninstall arg...
 func_mode_uninstall ()
 {
-    $opt_debug
-    RM="$nonopt"
+    $debug_cmd
+
+    RM=$nonopt
     files=
-    rmforce=
+    rmforce=false
     exit_status=0
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
-    libtool_install_magic="$magic"
+    libtool_install_magic=$magic
 
     for arg
     do
       case $arg in
-      -f) func_append RM " $arg"; rmforce=yes ;;
+      -f) func_append RM " $arg"; rmforce=: ;;
       -*) func_append RM " $arg" ;;
       *) func_append files " $arg" ;;
       esac
@@ -9473,18 +10962,18 @@ func_mode_uninstall ()
 
     for file in $files; do
       func_dirname "$file" "" "."
-      dir="$func_dirname_result"
-      if test "X$dir" = X.; then
-	odir="$objdir"
+      dir=$func_dirname_result
+      if test . = "$dir"; then
+	odir=$objdir
       else
-	odir="$dir/$objdir"
+	odir=$dir/$objdir
       fi
       func_basename "$file"
-      name="$func_basename_result"
-      test "$opt_mode" = uninstall && odir="$dir"
+      name=$func_basename_result
+      test uninstall = "$opt_mode" && odir=$dir
 
       # Remember odir for removal later, being careful to avoid duplicates
-      if test "$opt_mode" = clean; then
+      if test clean = "$opt_mode"; then
 	case " $rmdirs " in
 	  *" $odir "*) ;;
 	  *) func_append rmdirs " $odir" ;;
@@ -9499,11 +10988,11 @@ func_mode_uninstall ()
       elif test -d "$file"; then
 	exit_status=1
 	continue
-      elif test "$rmforce" = yes; then
+      elif $rmforce; then
 	continue
       fi
 
-      rmfiles="$file"
+      rmfiles=$file
 
       case $name in
       *.la)
@@ -9517,7 +11006,7 @@ func_mode_uninstall ()
 	  done
 	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
 
-	  case "$opt_mode" in
+	  case $opt_mode in
 	  clean)
 	    case " $library_names " in
 	    *" $dlname "*) ;;
@@ -9528,12 +11017,12 @@ func_mode_uninstall ()
 	  uninstall)
 	    if test -n "$library_names"; then
 	      # Do each command in the postuninstall commands.
-	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
 	    fi
 
 	    if test -n "$old_library"; then
 	      # Do each command in the old_postuninstall commands.
-	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
 	    fi
 	    # FIXME: should reinstall the best remaining shared library.
 	    ;;
@@ -9549,21 +11038,19 @@ func_mode_uninstall ()
 	  func_source $dir/$name
 
 	  # Add PIC object to the list of files to remove.
-	  if test -n "$pic_object" &&
-	     test "$pic_object" != none; then
+	  if test -n "$pic_object" && test none != "$pic_object"; then
 	    func_append rmfiles " $dir/$pic_object"
 	  fi
 
 	  # Add non-PIC object to the list of files to remove.
-	  if test -n "$non_pic_object" &&
-	     test "$non_pic_object" != none; then
+	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
 	    func_append rmfiles " $dir/$non_pic_object"
 	  fi
 	fi
 	;;
 
       *)
-	if test "$opt_mode" = clean ; then
+	if test clean = "$opt_mode"; then
 	  noexename=$name
 	  case $file in
 	  *.exe)
@@ -9590,12 +11077,12 @@ func_mode_uninstall ()
 
 	    # note $name still contains .exe if it was in $file originally
 	    # as does the version of $file that was added into $rmfiles
-	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
-	    if test "$fast_install" = yes && test -n "$relink_command"; then
+	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
+	    if test yes = "$fast_install" && test -n "$relink_command"; then
 	      func_append rmfiles " $odir/lt-$name"
 	    fi
-	    if test "X$noexename" != "X$name" ; then
-	      func_append rmfiles " $odir/lt-${noexename}.c"
+	    if test "X$noexename" != "X$name"; then
+	      func_append rmfiles " $odir/lt-$noexename.c"
 	    fi
 	  fi
 	fi
@@ -9604,7 +11091,7 @@ func_mode_uninstall ()
       func_show_eval "$RM $rmfiles" 'exit_status=1'
     done
 
-    # Try to remove the ${objdir}s in the directories where we deleted files
+    # Try to remove the $objdir's in the directories where we deleted files
     for dir in $rmdirs; do
       if test -d "$dir"; then
 	func_show_eval "rmdir $dir >/dev/null 2>&1"
@@ -9614,16 +11101,17 @@ func_mode_uninstall ()
     exit $exit_status
 }
 
-{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
-    func_mode_uninstall ${1+"$@"}
+if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
+  func_mode_uninstall ${1+"$@"}
+fi
 
 test -z "$opt_mode" && {
-  help="$generic_help"
+  help=$generic_help
   func_fatal_help "you must specify a MODE"
 }
 
 test -z "$exec_cmd" && \
-  func_fatal_help "invalid operation mode \`$opt_mode'"
+  func_fatal_help "invalid operation mode '$opt_mode'"
 
 if test -n "$exec_cmd"; then
   eval exec "$exec_cmd"
@@ -9634,7 +11122,7 @@ exit $exit_status
 
 
 # The TAGs below are defined such that we never get into a situation
-# in which we disable both kinds of libraries.  Given conflicting
+# where we disable both kinds of libraries.  Given conflicting
 # choices, we go for a static library, that is the most portable,
 # since we can't tell whether shared libraries were disabled because
 # the user asked for that or because the platform doesn't support
@@ -9657,5 +11145,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
 # mode:shell-script
 # sh-indentation:2
 # End:
-# vi:sw=2
-
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index d7c043f..a3bc337 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -1,8 +1,6 @@
 # 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, 2011 Free Software
-#                 Foundation, Inc.
+#   Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc.
 #   Written by Gordon Matzigkeit, 1996
 #
 # This file is free software; the Free Software Foundation gives
@@ -10,36 +8,30 @@
 # modifications, as long as this notice is preserved.
 
 m4_define([_LT_COPYING], [dnl
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool 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 of
-# the License, or (at your option) any later version.
+# Copyright (C) 2014 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.
+
+# GNU Libtool 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 of of the License, or
+# (at your option) any later version.
 #
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the  same
+# distribution terms that you use for the rest of that program.
 #
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool 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 GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing 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/>.
 ])
 
-# serial 57 LT_INIT
+# serial 58 LT_INIT
 
 
 # LT_PREREQ(VERSION)
@@ -67,7 +59,7 @@ esac
 # LT_INIT([OPTIONS])
 # ------------------
 AC_DEFUN([LT_INIT],
-[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK
 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
 AC_BEFORE([$0], [LT_LANG])dnl
 AC_BEFORE([$0], [LT_OUTPUT])dnl
@@ -91,7 +83,7 @@ dnl Parse OPTIONS
 _LT_SET_OPTIONS([$0], [$1])
 
 # This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
 
 # Always use our own libtool.
 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -111,26 +103,43 @@ dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
 dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
 
 
+# _LT_PREPARE_CC_BASENAME
+# -----------------------
+m4_defun([_LT_PREPARE_CC_BASENAME], [
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in @S|@*""; do
+      case $cc_temp in
+        compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+        distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+])# _LT_PREPARE_CC_BASENAME
+
+
 # _LT_CC_BASENAME(CC)
 # -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME,
+# but that macro is also expanded into generated libtool script, which
+# arranges for $SED and $ECHO to be set by different means.
 m4_defun([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+[m4_require([_LT_PREPARE_CC_BASENAME])dnl
+AC_REQUIRE([_LT_DECL_SED])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+func_cc_basename $1
+cc_basename=$func_cc_basename_result
 ])
 
 
 # _LT_FILEUTILS_DEFAULTS
 # ----------------------
 # It is okay to use these file commands and assume they have been set
-# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'.
 m4_defun([_LT_FILEUTILS_DEFAULTS],
 [: ${CP="cp -f"}
 : ${MV="mv -f"}
@@ -177,15 +186,16 @@ m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
 m4_require([_LT_WITH_SYSROOT])dnl
+m4_require([_LT_CMD_TRUNCATE])dnl
 
 _LT_CONFIG_LIBTOOL_INIT([
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
 # commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 ])
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
@@ -198,7 +208,7 @@ aix3*)
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
+  if test set != "${COLLECT_NAMES+set}"; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -209,14 +219,14 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
 
 # Set sane defaults for various variables
 test -z "$CC" && CC=cc
@@ -269,14 +279,14 @@ no_glob_subst='s/\*/\\\*/g'
 
 # _LT_PROG_LTMAIN
 # ---------------
-# Note that this code is called both from `configure', and `config.status'
+# Note that this code is called both from 'configure', and 'config.status'
 # now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
-# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# 'config.status' has no value for ac_aux_dir unless we are using Automake,
 # so we pass a copy along to make sure it has a sensible value anyway.
 m4_defun([_LT_PROG_LTMAIN],
 [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
 _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 ])# _LT_PROG_LTMAIN
 
 
@@ -286,7 +296,7 @@ ltmain="$ac_aux_dir/ltmain.sh"
 
 # So that we can recreate a full libtool script including additional
 # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
-# in macros and then make a single call at the end using the `libtool'
+# in macros and then make a single call at the end using the 'libtool'
 # label.
 
 
@@ -421,8 +431,8 @@ m4_define([_lt_decl_all_varnames],
 
 # _LT_CONFIG_STATUS_DECLARE([VARNAME])
 # ------------------------------------
-# Quote a variable value, and forward it to `config.status' so that its
-# declaration there will have the same value as in `configure'.  VARNAME
+# Quote a variable value, and forward it to 'config.status' so that its
+# declaration there will have the same value as in 'configure'.  VARNAME
 # must have a single quote delimited value for this to work.
 m4_define([_LT_CONFIG_STATUS_DECLARE],
 [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
@@ -446,7 +456,7 @@ m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
 # Output comment and list of tags supported by the script
 m4_defun([_LT_LIBTOOL_TAGS],
 [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
-available_tags="_LT_TAGS"dnl
+available_tags='_LT_TAGS'dnl
 ])
 
 
@@ -474,7 +484,7 @@ m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
 # _LT_LIBTOOL_CONFIG_VARS
 # -----------------------
 # Produce commented declarations of non-tagged libtool config variables
-# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool'
 # script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
 # section) are produced by _LT_LIBTOOL_TAG_VARS.
 m4_defun([_LT_LIBTOOL_CONFIG_VARS],
@@ -500,8 +510,8 @@ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
 # Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
 # variables for single and double quote escaping we saved from calls
 # to _LT_DECL, we can put quote escaped variables declarations
-# into `config.status', and then the shell code to quote escape them in
-# for loops in `config.status'.  Finally, any additional code accumulated
+# into 'config.status', and then the shell code to quote escape them in
+# for loops in 'config.status'.  Finally, any additional code accumulated
 # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
 m4_defun([_LT_CONFIG_COMMANDS],
 [AC_PROVIDE_IFELSE([LT_OUTPUT],
@@ -547,7 +557,7 @@ for var in lt_decl_all_varnames([[ \
 ]], lt_decl_quote_varnames); do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -560,7 +570,7 @@ for var in lt_decl_all_varnames([[ \
 ]], lt_decl_dquote_varnames); do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -576,7 +586,7 @@ _LT_OUTPUT_LIBTOOL_INIT
 # Generate a child script FILE with all initialization necessary to
 # reuse the environment learned by the parent script, and make the
 # file executable.  If COMMENT is supplied, it is inserted after the
-# `#!' sequence but before initialization text begins.  After this
+# '#!' sequence but before initialization text begins.  After this
 # macro, additional text can be appended to FILE to form the body of
 # the child script.  The macro ends with non-zero status if the
 # file could not be fully written (such as if the disk is full).
@@ -598,7 +608,7 @@ AS_SHELL_SANITIZE
 _AS_PREPARE
 exec AS_MESSAGE_FD>&1
 _ASEOF
-test $lt_write_fail = 0 && chmod +x $1[]dnl
+test 0 = "$lt_write_fail" && chmod +x $1[]dnl
 m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
 
 # LT_OUTPUT
@@ -621,7 +631,7 @@ exec AS_MESSAGE_LOG_FD>>config.log
 } >&AS_MESSAGE_LOG_FD
 
 lt_cl_help="\
-\`$as_me' creates a local libtool stub from the current configuration,
+'$as_me' creates a local libtool stub from the current configuration,
 for use in further configure time tests before the real libtool is
 generated.
 
@@ -643,7 +653,7 @@ 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."
 
-while test $[#] != 0
+while test 0 != $[#]
 do
   case $[1] in
     --version | --v* | -V )
@@ -656,10 +666,10 @@ do
       lt_cl_silent=: ;;
 
     -*) AC_MSG_ERROR([unrecognized option: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
 
     *) AC_MSG_ERROR([unrecognized argument: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
   esac
   shift
 done
@@ -685,7 +695,7 @@ chmod +x "$CONFIG_LT"
 # open by configure.  Here we exec the FD to /dev/null, effectively closing
 # config.log, so it can be properly (re)opened and appended to by config.lt.
 lt_cl_success=:
-test "$silent" = yes &&
+test yes = "$silent" &&
   lt_config_lt_args="$lt_config_lt_args --quiet"
 exec AS_MESSAGE_LOG_FD>/dev/null
 $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
@@ -705,27 +715,31 @@ m4_defun([_LT_CONFIG],
 _LT_CONFIG_SAVE_COMMANDS([
   m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
   m4_if(_LT_TAG, [C], [
-    # See if we are running on zsh, and set the options which allow our
+    # See if we are running on zsh, and set the options that allow our
     # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
+    if test -n "${ZSH_VERSION+set}"; then
       setopt NO_GLOB_SUBST
     fi
 
-    cfgfile="${ofile}T"
+    cfgfile=${ofile}T
     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
     $RM "$cfgfile"
 
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
 _LT_COPYING
 _LT_LIBTOOL_TAGS
 
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
+
 # ### BEGIN LIBTOOL CONFIG
 _LT_LIBTOOL_CONFIG_VARS
 _LT_LIBTOOL_TAG_VARS
@@ -733,13 +747,24 @@ _LT_LIBTOOL_TAG_VARS
 
 _LT_EOF
 
+    cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_PREPARE_MUNGE_PATH_LIST
+_LT_PREPARE_CC_BASENAME
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
   case $host_os in
   aix3*)
     cat <<\_LT_EOF >> "$cfgfile"
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -756,8 +781,6 @@ _LT_EOF
   sed '$q' "$ltmain" >> "$cfgfile" \
      || (rm -f "$cfgfile"; exit 1)
 
-  _LT_PROG_REPLACE_SHELLFNS
-
    mv -f "$cfgfile" "$ofile" ||
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
@@ -775,7 +798,6 @@ _LT_EOF
 [m4_if([$1], [], [
     PACKAGE='$PACKAGE'
     VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
     RM='$RM'
     ofile='$ofile'], [])
 ])dnl /_LT_CONFIG_SAVE_COMMANDS
@@ -974,7 +996,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 
     AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
       [lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
+      if test -z "$LT_MULTI_MODULE"; then
 	# By default we will add the -single_module flag. You can override
 	# by either setting the environment variable LT_MULTI_MODULE
 	# non-empty at configure time, or by adding -multi_module to the
@@ -992,7 +1014,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 	  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
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1010,7 +1032,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
       AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
 	[lt_cv_ld_exported_symbols_list=yes],
 	[lt_cv_ld_exported_symbols_list=no])
-	LDFLAGS="$save_LDFLAGS"
+	LDFLAGS=$save_LDFLAGS
     ])
 
     AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
@@ -1032,7 +1054,7 @@ _LT_EOF
       _lt_result=$?
       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
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1042,32 +1064,32 @@ _LT_EOF
     ])
     case $host_os in
     rhapsody* | darwin1.[[012]])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
     darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
     darwin*) # darwin 5.x on
       # if running on 10.5 or later, the deployment target defaults
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[[012]]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[[012]][[,.]]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
 	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
   esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
       _lt_dar_single_mod='$single_module'
     fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
     else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
     fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
       _lt_dsymutil='~$DSYMUTIL $lib || :'
     else
       _lt_dsymutil=
@@ -1087,29 +1109,29 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
   _LT_TAGVAR(hardcode_direct, $1)=no
   _LT_TAGVAR(hardcode_automatic, $1)=yes
   _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\"`'
+  if test yes = "$lt_cv_ld_force_load"; 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
   _LT_TAGVAR(link_all_deplibs, $1)=yes
-  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+  _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
     m4_if([$1], [CXX],
-[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+[   if test yes != "$lt_cv_apple_cc_single_mod"; then
+      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
     fi
 ],[])
   else
@@ -1129,7 +1151,7 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
 # Allow to override them for all tags through lt_cv_aix_libpath.
 m4_defun([_LT_SYS_MODULE_PATH_AIX],
 [m4_require([_LT_DECL_SED])dnl
-if test "${lt_cv_aix_libpath+set}" = set; then
+if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
@@ -1147,7 +1169,7 @@ else
     _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
   fi],[])
   if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
-    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
+    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib
   fi
   ])
   aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
@@ -1167,8 +1189,8 @@ m4_define([_LT_SHELL_INIT],
 # -----------------------
 # Find how we can fake an echo command that does not interpret backslash.
 # In particular, with Autoconf 2.60 or later we add some code to the start
-# of the generated configure script which will find a shell with a builtin
-# printf (which we can use as an echo command).
+# of the generated configure script that will find a shell with a builtin
+# printf (that we can use as an echo command).
 m4_defun([_LT_PROG_ECHO_BACKSLASH],
 [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
 ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
@@ -1196,10 +1218,10 @@ fi
 # Invoke $ECHO with all args, space-separated.
 func_echo_all ()
 {
-    $ECHO "$*" 
+    $ECHO "$*"
 }
 
-case "$ECHO" in
+case $ECHO in
   printf*) AC_MSG_RESULT([printf]) ;;
   print*) AC_MSG_RESULT([print -r]) ;;
   *) AC_MSG_RESULT([cat]) ;;
@@ -1225,16 +1247,17 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
 AC_DEFUN([_LT_WITH_SYSROOT],
 [AC_MSG_CHECKING([for sysroot])
 AC_ARG_WITH([sysroot],
-[  --with-sysroot[=DIR] Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).],
+[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@],
+  [Search for dependent libraries within DIR (or the compiler's sysroot
+   if not specified).])],
 [], [with_sysroot=no])
 
 dnl lt_sysroot will always be passed unquoted.  We quote it here
 dnl in case the user passed a directory name.
 lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
  yes)
-   if test "$GCC" = yes; then
+   if test yes = "$GCC"; then
      lt_sysroot=`$CC --print-sysroot 2>/dev/null`
    fi
    ;; #(
@@ -1244,14 +1267,14 @@ case ${with_sysroot} in #(
  no|'')
    ;; #(
  *)
-   AC_MSG_RESULT([${with_sysroot}])
+   AC_MSG_RESULT([$with_sysroot])
    AC_MSG_ERROR([The sysroot must be an absolute path.])
    ;;
 esac
 
  AC_MSG_RESULT([${lt_sysroot:-no}])
 _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
-[dependent libraries, and in which our libraries should be installed.])])
+[dependent libraries, and where our libraries should be installed.])])
 
 # _LT_ENABLE_LOCK
 # ---------------
@@ -1259,31 +1282,33 @@ m4_defun([_LT_ENABLE_LOCK],
 [AC_ARG_ENABLE([libtool-lock],
   [AS_HELP_STRING([--disable-libtool-lock],
     [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
 ia64-*-hpux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
-	HPUX_IA64_MODE="32"
+	HPUX_IA64_MODE=32
 	;;
       *ELF-64*)
-	HPUX_IA64_MODE="64"
+	HPUX_IA64_MODE=64
 	;;
     esac
   fi
   rm -rf conftest*
   ;;
 *-*-irix6*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
 	*32-bit*)
 	  LD="${LD-ld} -melf32bsmip"
@@ -1312,9 +1337,46 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
+
 x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
@@ -1333,10 +1395,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  powerpc64le-*)
+	  powerpc64le-*linux*)
 	    LD="${LD-ld} -m elf32lppclinux"
 	    ;;
-	  powerpc64-*)
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -1355,10 +1417,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
+	  powerpcle-*linux*)
 	    LD="${LD-ld} -m elf64lppc"
 	    ;;
-	  powerpc-*)
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -1376,19 +1438,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
 *-*-sco3.2v5*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
+  SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
     [AC_LANG_PUSH(C)
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
      AC_LANG_POP])
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+  if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
+    CFLAGS=$SAVE_CFLAGS
   fi
   ;;
 *-*solaris*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
@@ -1396,7 +1459,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
       case $lt_cv_prog_gnu_ld in
       yes*)
         case $host in
-        i?86-*-solaris*)
+        i?86-*-solaris*|x86_64-*-solaris*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
         sparc*-*-solaris*)
@@ -1405,7 +1468,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
         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"
+          LD=${LD-ld}_sol2
         fi
         ;;
       *)
@@ -1421,7 +1484,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
 ])# _LT_ENABLE_LOCK
 
 
@@ -1440,11 +1503,11 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
      [echo conftest.$ac_objext > conftest.lst
       lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
       AC_TRY_EVAL([lt_ar_try])
-      if test "$ac_status" -eq 0; then
+      if test 0 -eq "$ac_status"; then
 	# Ensure the archiver fails upon bogus file names.
 	rm -f conftest.$ac_objext libconftest.a
 	AC_TRY_EVAL([lt_ar_try])
-	if test "$ac_status" -ne 0; then
+	if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
         fi
       fi
@@ -1452,7 +1515,7 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
      ])
   ])
 
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
 else
   archiver_list_spec=$lt_cv_ar_at_file
@@ -1483,7 +1546,7 @@ old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
-  openbsd*)
+  bitrig* | openbsd*)
     old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
@@ -1519,7 +1582,7 @@ AC_CACHE_CHECK([$1], [$2],
   [$2=no
    m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$3"
+   lt_compiler_flag="$3"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -1546,7 +1609,7 @@ AC_CACHE_CHECK([$1], [$2],
    $RM conftest*
 ])
 
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
     m4_if([$5], , :, [$5])
 else
     m4_if([$6], , :, [$6])
@@ -1568,7 +1631,7 @@ AC_DEFUN([_LT_LINKER_OPTION],
 m4_require([_LT_DECL_SED])dnl
 AC_CACHE_CHECK([$1], [$2],
   [$2=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $3"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -1587,10 +1650,10 @@ AC_CACHE_CHECK([$1], [$2],
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 ])
 
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
     m4_if([$4], , :, [$4])
 else
     m4_if([$5], , :, [$5])
@@ -1611,7 +1674,7 @@ AC_DEFUN([LT_CMD_MAX_LEN],
 AC_MSG_CHECKING([the maximum length of command line arguments])
 AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
   i=0
-  teststring="ABCD"
+  teststring=ABCD
 
   case $build_os in
   msdosdjgpp*)
@@ -1651,7 +1714,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -1702,22 +1765,22 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
     if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
       # Make teststring a little bigger before we do anything with it.
       # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
+      for i in 1 2 3 4 5 6 7 8; do
         teststring=$teststring$teststring
       done
       SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
       # 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"`env 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
+	      test 17 != "$i" # 1/2 MB should be enough
       do
         i=`expr $i + 1`
         teststring=$teststring$teststring
@@ -1733,7 +1796,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     ;;
   esac
 ])
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
   AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
 else
   AC_MSG_RESULT(none)
@@ -1761,7 +1824,7 @@ m4_defun([_LT_HEADER_DLFCN],
 # ----------------------------------------------------------------
 m4_defun([_LT_TRY_DLOPEN_SELF],
 [m4_require([_LT_HEADER_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
+if test yes = "$cross_compiling"; then :
   [$4]
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -1808,9 +1871,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -1836,7 +1899,7 @@ int main ()
   return status;
 }]
 _LT_EOF
-  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+  if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -1857,7 +1920,7 @@ rm -fr conftest*
 # ------------------
 AC_DEFUN([LT_SYS_DLOPEN_SELF],
 [m4_require([_LT_HEADER_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
+if test yes != "$enable_dlopen"; then
   enable_dlopen=unknown
   enable_dlopen_self=unknown
   enable_dlopen_self_static=unknown
@@ -1867,44 +1930,52 @@ else
 
   case $host_os in
   beos*)
-    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen=load_add_on
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ;;
 
   mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen=LoadLibrary
     lt_cv_dlopen_libs=
     ;;
 
   cygwin*)
-    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen=dlopen
     lt_cv_dlopen_libs=
     ;;
 
   darwin*)
-  # if libdl is installed we need to link against it
+    # if libdl is installed we need to link against it
     AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
-    lt_cv_dlopen="dyld"
+		[lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[
+    lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ])
     ;;
 
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
   *)
     AC_CHECK_FUNC([shl_load],
-	  [lt_cv_dlopen="shl_load"],
+	  [lt_cv_dlopen=shl_load],
       [AC_CHECK_LIB([dld], [shl_load],
-	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+	    [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld],
 	[AC_CHECK_FUNC([dlopen],
-	      [lt_cv_dlopen="dlopen"],
+	      [lt_cv_dlopen=dlopen],
 	  [AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+		[lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],
 	    [AC_CHECK_LIB([svld], [dlopen],
-		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+		  [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld],
 	      [AC_CHECK_LIB([dld], [dld_link],
-		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+		    [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld])
 	      ])
 	    ])
 	  ])
@@ -1913,21 +1984,21 @@ else
     ;;
   esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
+  if test no = "$lt_cv_dlopen"; then
     enable_dlopen=no
+  else
+    enable_dlopen=yes
   fi
 
   case $lt_cv_dlopen in
   dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
+    save_LDFLAGS=$LDFLAGS
     wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
+    save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     AC_CACHE_CHECK([whether a program can dlopen itself],
@@ -1937,7 +2008,7 @@ else
 	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
     ])
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
+    if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
 	  lt_cv_dlopen_self_static, [dnl
@@ -1947,9 +2018,9 @@ else
       ])
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
     ;;
   esac
 
@@ -2041,8 +2112,8 @@ m4_defun([_LT_COMPILER_FILE_LOCKS],
 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 _LT_COMPILER_C_O([$1])
 
-hard_links="nottested"
-if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   AC_MSG_CHECKING([if we can lock with hard links])
   hard_links=yes
@@ -2052,8 +2123,8 @@ if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" !=
   ln conftest.a conftest.b 2>&5 || hard_links=no
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   AC_MSG_RESULT([$hard_links])
-  if test "$hard_links" = no; then
-    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+  if test no = "$hard_links"; then
+    AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe])
     need_locks=warn
   fi
 else
@@ -2080,8 +2151,8 @@ objdir=$lt_cv_objdir
 _LT_DECL([], [objdir], [0],
          [The name of the directory that contains temporary libtool files])dnl
 m4_pattern_allow([LT_OBJDIR])dnl
-AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
-  [Define to the sub-directory in which libtool stores uninstalled libraries.])
+AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/",
+  [Define to the sub-directory where libtool stores uninstalled libraries.])
 ])# _LT_CHECK_OBJDIR
 
 
@@ -2093,15 +2164,15 @@ m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
 _LT_TAGVAR(hardcode_action, $1)=
 if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
    test -n "$_LT_TAGVAR(runpath_var, $1)" ||
-   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+   test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then
 
   # We can hardcode non-existent directories.
-  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+  if test no != "$_LT_TAGVAR(hardcode_direct, $1)" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
-     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" &&
+     test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then
     # Linking always hardcodes the temporary library directory.
     _LT_TAGVAR(hardcode_action, $1)=relink
   else
@@ -2115,12 +2186,12 @@ else
 fi
 AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
 
-if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
-   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+if test relink = "$_LT_TAGVAR(hardcode_action, $1)" ||
+   test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -2144,7 +2215,7 @@ else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
   darwin*)
-    if test -n "$STRIP" ; then
+    if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
       AC_MSG_RESULT([yes])
@@ -2162,6 +2233,47 @@ _LT_DECL([], [striplib], [1])
 ])# _LT_CMD_STRIPLIB
 
 
+# _LT_PREPARE_MUNGE_PATH_LIST
+# ---------------------------
+# Make sure func_munge_path_list() is defined correctly.
+m4_defun([_LT_PREPARE_MUNGE_PATH_LIST],
+[[# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x at S|@2 in
+    x)
+        ;;
+    *:)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\"
+        ;;
+    x:*)
+        eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\"
+        ;;
+    *)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+]])# _LT_PREPARE_PATH_LIST
+
+
 # _LT_SYS_DYNAMIC_LINKER([TAG])
 # -----------------------------
 # PORTME Fill in your ld.so characteristics
@@ -2172,17 +2284,18 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_OBJDUMP])dnl
 m4_require([_LT_DECL_SED])dnl
 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl
 AC_MSG_CHECKING([dynamic linker characteristics])
 m4_if([$1],
 	[], [
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
   esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
   esac
   lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
   case $lt_search_path_spec in
@@ -2198,28 +2311,35 @@ if test "$GCC" = yes; then
     ;;
   esac
   # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
+  # and add multilib dir if necessary...
   lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
   for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
       test -d "$lt_sys_path" && \
 	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
     fi
   done
   lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
   for (lt_i = NF; lt_i > 0; lt_i--) {
     if ($lt_i != "" && $lt_i != ".") {
       if ($lt_i == "..") {
         lt_count++;
       } else {
         if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
+          lt_foo = "/" $lt_i lt_foo;
         } else {
           lt_count--;
         }
@@ -2233,7 +2353,7 @@ BEGIN {RS=" "; FS="/|\n";} {
   # for these hosts.
   case $host_os in
     mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+      $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;;
   esac
   sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 else
@@ -2242,7 +2362,7 @@ fi])
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -2259,14 +2379,17 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+AC_ARG_VAR([LT_SYS_LIBRARY_PATH],
+[User-defined run-time library search path.])
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[[4-9]]*)
@@ -2274,41 +2397,91 @@ aix[[4-9]]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[[01]] | aix4.[[01]].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a[(]lib.so.V[)]'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -2318,18 +2491,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -2337,8 +2510,8 @@ beos*)
 bsdi[[45]]*)
   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'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -2350,7 +2523,7 @@ bsdi[[45]]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -2359,8 +2532,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -2376,17 +2549,17 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
 m4_if([$1], [],[
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -2395,8 +2568,8 @@ m4_if([$1], [],[
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -2423,7 +2596,7 @@ m4_if([$1], [],[
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -2436,8 +2609,8 @@ m4_if([$1], [],[
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -2450,7 +2623,7 @@ m4_if([$1], [],[
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -2463,8 +2636,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -2477,8 +2650,8 @@ dgux*)
   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'
+  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
   ;;
 
@@ -2496,12 +2669,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -2531,10 +2705,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  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=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -2552,14 +2726,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -2567,8 +2742,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -2577,8 +2752,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -2591,8 +2766,8 @@ interix[[3-9]]*)
   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'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -2603,7 +2778,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -2611,8 +2786,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -2631,8 +2806,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -2641,13 +2816,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   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'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -2672,7 +2867,12 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -2687,29 +2887,17 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-netbsdelf*-gnu)
-  version_type=linux
-  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
-  dynamic_linker='NetBSD ld.elf_so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -2719,7 +2907,7 @@ netbsd*)
 
 newsos6)
   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}'
+  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
   ;;
@@ -2728,58 +2916,68 @@ newsos6)
   version_type=qnx
   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'
+  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
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[[89]] | openbsd2.[[89]].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -2790,8 +2988,8 @@ solaris*)
   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'
+  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=yes
   hardcode_into_libs=yes
@@ -2801,11 +2999,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -2813,8 +3011,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   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'
+  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
   case $host_vendor in
     sni)
@@ -2835,24 +3033,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     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'
+    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
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -2870,7 +3068,7 @@ tpf*)
   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}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -2878,8 +3076,8 @@ tpf*)
 
 uts4*)
   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'
+  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
   ;;
 
@@ -2888,20 +3086,30 @@ uts4*)
   ;;
 esac
 AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
 _LT_DECL([], [variables_saved_for_relink], [1],
     [Variables whose values should be saved in libtool wrapper scripts and
     restored at link time])
@@ -2934,39 +3142,41 @@ _LT_DECL([], [hardcode_into_libs], [0],
     [Whether we should hardcode library paths into libraries])
 _LT_DECL([], [sys_lib_search_path_spec], [2],
     [Compile-time system search path for libraries])
-_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
-    [Run-time system search path for libraries])
+_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2],
+    [Detected run-time system search path for libraries])
+_LT_DECL([], [configure_time_lt_sys_library_path], [2],
+    [Explicit LT_SYS_LIBRARY_PATH set during ./configure time])
 ])# _LT_SYS_DYNAMIC_LINKER
 
 
 # _LT_PATH_TOOL_PREFIX(TOOL)
 # --------------------------
-# find a file program which can recognize shared library
+# find a file program that can recognize shared library
 AC_DEFUN([_LT_PATH_TOOL_PREFIX],
 [m4_require([_LT_DECL_EGREP])dnl
 AC_MSG_CHECKING([for $1])
 AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
 [case $MAGIC_CMD in
 [[\\/*] |  ?:[\\/]*])
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
 dnl $ac_dummy forces splitting on constant user-supplied paths.
 dnl POSIX.2 word splitting is done only on the output of word expansions,
 dnl not every word.  This closes a longstanding sh security hole.
   ac_dummy="m4_if([$2], , $PATH, [$2])"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$1; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+    if test -f "$ac_dir/$1"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"$1"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -2989,11 +3199,11 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   AC_MSG_RESULT($MAGIC_CMD)
 else
@@ -3011,7 +3221,7 @@ dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
 
 # _LT_PATH_MAGIC
 # --------------
-# find a file program which can recognize a shared library
+# find a file program that can recognize a shared library
 m4_defun([_LT_PATH_MAGIC],
 [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
 if test -z "$lt_cv_path_MAGIC_CMD"; then
@@ -3038,16 +3248,16 @@ m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
 AC_ARG_WITH([gnu-ld],
     [AS_HELP_STRING([--with-gnu-ld],
 	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
-    [test "$withval" = no || with_gnu_ld=yes],
+    [test no = "$withval" || with_gnu_ld=yes],
     [with_gnu_ld=no])dnl
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   AC_MSG_CHECKING([for ld used by $CC])
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -3061,7 +3271,7 @@ if test "$GCC" = yes; then
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -3072,37 +3282,37 @@ if test "$GCC" = yes; then
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   AC_MSG_CHECKING([for GNU ld])
 else
   AC_MSG_CHECKING([for non-GNU ld])
 fi
 AC_CACHE_VAL(lt_cv_path_LD,
 [if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi])
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   AC_MSG_RESULT($LD)
 else
@@ -3156,13 +3366,13 @@ esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       reload_cmds=false
     fi
     ;;
   darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -3173,6 +3383,43 @@ _LT_TAGDECL([], [reload_cmds], [2])dnl
 ])# _LT_CMD_RELOAD
 
 
+# _LT_PATH_DD
+# -----------
+# find a working dd
+m4_defun([_LT_PATH_DD],
+[AC_CACHE_CHECK([for a working dd], [ac_cv_path_lt_DD],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd],
+[if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi])
+rm -f conftest.i conftest2.i conftest.out])
+])# _LT_PATH_DD
+
+
+# _LT_CMD_TRUNCATE
+# ----------------
+# find command to truncate a binary pipe
+m4_defun([_LT_CMD_TRUNCATE],
+[m4_require([_LT_PATH_DD])
+AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"])
+_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1],
+  [Command to truncate a binary pipe])
+])# _LT_CMD_TRUNCATE
+
+
 # _LT_CHECK_MAGIC_METHOD
 # ----------------------
 # how to check for library dependencies
@@ -3188,13 +3435,13 @@ lt_cv_deplibs_check_method='unknown'
 # Need to set the preceding variable on all platforms that support
 # interlibrary dependencies.
 # 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
 # 'pass_all' -- all dependencies passed with no checks.
 # 'test_compile' -- check by making test program.
 # 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
 case $host_os in
 aix[[4-9]]*)
@@ -3221,8 +3468,7 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+  if ( file / ) >/dev/null 2>&1; then
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
@@ -3300,7 +3546,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-netbsd* | netbsdelf*-gnu)
+netbsd*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
   else
@@ -3318,8 +3564,8 @@ newos6*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
   else
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
@@ -3372,6 +3618,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 ])
 
@@ -3412,33 +3661,38 @@ AC_DEFUN([LT_PATH_NM],
 AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
 [if test -n "$NM"; then
   # Let the user override the test.
-  lt_cv_path_NM="$NM"
+  lt_cv_path_NM=$NM
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
+  lt_nm_to_check=${ac_tool_prefix}nm
   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
     lt_nm_to_check="$lt_nm_to_check nm"
   fi
   for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
     for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
 	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
 	#   nm: unknown option "B" ignored
 	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
 	  lt_cv_path_NM="$tmp_nm -B"
-	  break
+	  break 2
 	  ;;
 	*)
 	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 	  */dev/null*)
 	    lt_cv_path_NM="$tmp_nm -p"
-	    break
+	    break 2
 	    ;;
 	  *)
 	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -3449,21 +3703,21 @@ else
 	esac
       fi
     done
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
   done
   : ${lt_cv_path_NM=no}
 fi])
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
 else
   # Didn't find any BSD compatible name lister, look for dumpbin.
   if test -n "$DUMPBIN"; then :
     # Let the user override the test.
   else
     AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
     *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
+      DUMPBIN="$DUMPBIN -symbols -headers"
       ;;
     *)
       DUMPBIN=:
@@ -3471,8 +3725,8 @@ else
     esac
   fi
   AC_SUBST([DUMPBIN])
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
   fi
 fi
 test -z "$NM" && NM=nm
@@ -3518,8 +3772,8 @@ lt_cv_sharedlib_from_linklib_cmd,
 
 case $host_os in
 cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
   case `$DLLTOOL --help 2>&1` in
   *--identify-strict*)
     lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -3531,7 +3785,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   ;;
 *)
   # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
   ;;
 esac
 ])
@@ -3558,13 +3812,28 @@ AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool
     lt_cv_path_mainfest_tool=yes
   fi
   rm -f conftest*])
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
 _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
 ])# _LT_PATH_MANIFEST_TOOL
 
 
+# _LT_DLL_DEF_P([FILE])
+# ---------------------
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with func_dll_def_p in the libtool script
+AC_DEFUN([_LT_DLL_DEF_P],
+[dnl
+  test DEF = "`$SED -n dnl
+    -e '\''s/^[[	 ]]*//'\'' dnl Strip leading whitespace
+    -e '\''/^\(;.*\)*$/d'\'' dnl      Delete empty lines and comments
+    -e '\''s/^\(EXPORTS\|LIBRARY\)\([[	 ]].*\)*$/DEF/p'\'' dnl
+    -e q dnl                          Only consider the first "real" line
+    $1`" dnl
+])# _LT_DLL_DEF_P
+
+
 # LT_LIB_M
 # --------
 # check for math library
@@ -3576,11 +3845,11 @@ case $host in
   # These system don't have libm, or don't need it
   ;;
 *-ncr-sysv4.3*)
-  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw)
   AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
   ;;
 *)
-  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  AC_CHECK_LIB(m, cos, LIBM=-lm)
   ;;
 esac
 AC_SUBST([LIBM])
@@ -3599,7 +3868,7 @@ m4_defun([_LT_COMPILER_NO_RTTI],
 
 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $cc_basename in
   nvcc*)
     _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
@@ -3651,7 +3920,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   symcode='[[ABCDGISTW]]'
   ;;
 hpux*)
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     symcode='[[ABCDEGRST]]'
   fi
   ;;
@@ -3684,14 +3953,44 @@ case `$NM -V 2>&1` in
   symcode='[[ABCDGIRSTW]]' ;;
 esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
+
 # Transform an extracted symbol line into a proper C declaration.
 # Some systems (esp. on ia64) link data and code symbols differently,
 # so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
 # Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
 # Handle CRLF in mingw tool chain
 opt_cr=
@@ -3709,21 +4008,24 @@ for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
   if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
     # Also find C++ and __fastcall symbols from MSVC++,
     # 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};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 "     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
 "     ' prfx=^$ac_symprfx]"
   else
     lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -3763,11 +4065,11 @@ _LT_EOF
 	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 	  cat <<_LT_EOF > conftest.$ac_ext
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT@&t at _DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT@&t at _DLSYM_CONST
 #else
@@ -3793,7 +4095,7 @@ lt__PROGRAM__LTX_preloaded_symbols[[]] =
 {
   { "@PROGRAM@", (void *) 0 },
 _LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 	  cat <<\_LT_EOF >> conftest.$ac_ext
   {0, (void *) 0}
 };
@@ -3813,9 +4115,9 @@ _LT_EOF
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  lt_globsym_save_LIBS=$LIBS
 	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
+	  LIBS=conftstm.$ac_objext
 	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
-	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+	  if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then
 	    pipe_works=yes
 	  fi
 	  LIBS=$lt_globsym_save_LIBS
@@ -3836,7 +4138,7 @@ _LT_EOF
   rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
+  if test yes = "$pipe_works"; then
     break
   else
     lt_cv_sys_global_symbol_pipe=
@@ -3863,12 +4165,16 @@ _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
     [Take the output of nm and produce a listing of raw symbols and C names])
 _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
     [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1],
+    [Transform the output of nm into a list of symbols to manually relocate])
 _LT_DECL([global_symbol_to_c_name_address],
     [lt_cv_sys_global_symbol_to_c_name_address], [1],
     [Transform the output of nm in a C name address pair])
 _LT_DECL([global_symbol_to_c_name_address_lib_prefix],
     [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
     [Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([nm_interface], [lt_cv_nm_interface], [1],
+    [The name lister interface])
 _LT_DECL([], [nm_file_list_spec], [1],
     [Specify filename containing input files for $NM])
 ]) # _LT_CMD_GLOBAL_SYMBOLS
@@ -3884,17 +4190,18 @@ _LT_TAGVAR(lt_prog_compiler_static, $1)=
 
 m4_if([$1], [CXX], [
   # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
+  if test yes = "$GXX"; then
     _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
     _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 
     case $host_os in
     aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;
 
     amigaos*)
@@ -3905,8 +4212,8 @@ m4_if([$1], [CXX], [
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -3922,6 +4229,11 @@ m4_if([$1], [CXX], [
       # (--disable-auto-import) libraries
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -3971,7 +4283,7 @@ m4_if([$1], [CXX], [
     case $host_os in
       aix[[4-9]]*)
 	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	  # AIX 5 now supports IA64 processor
 	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	else
@@ -4012,14 +4324,14 @@ m4_if([$1], [CXX], [
 	case $cc_basename in
 	  CC*)
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
+	    if test ia64 != "$host_cpu"; then
 	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -4056,7 +4368,7 @@ m4_if([$1], [CXX], [
 	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
 	    ;;
 	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    # old Intel C++ for x86_64, which still supported -KPIC.
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
@@ -4112,7 +4424,7 @@ m4_if([$1], [CXX], [
 	    ;;
 	esac
 	;;
-      netbsd* | netbsdelf*-gnu)
+      netbsd*)
 	;;
       *qnx* | *nto*)
         # QNX uses GNU C++, but need to define -shared option too, otherwise
@@ -4201,17 +4513,18 @@ m4_if([$1], [CXX], [
   fi
 ],
 [
-  if test "$GCC" = yes; then
+  if test yes = "$GCC"; then
     _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
     _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;
 
     amigaos*)
@@ -4222,8 +4535,8 @@ m4_if([$1], [CXX], [
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -4240,6 +4553,11 @@ m4_if([$1], [CXX], [
       # (--disable-auto-import) libraries
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
 
     darwin* | rhapsody*)
@@ -4310,7 +4628,7 @@ m4_if([$1], [CXX], [
     case $host_os in
     aix*)
       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       else
@@ -4318,11 +4636,30 @@ m4_if([$1], [CXX], [
       fi
       ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+        _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      esac
+      ;;
+
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -4338,7 +4675,7 @@ m4_if([$1], [CXX], [
 	;;
       esac
       # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
       ;;
 
     irix5* | irix6* | nonstopux*)
@@ -4349,7 +4686,7 @@ m4_if([$1], [CXX], [
 
     linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
       case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
+      # old Intel for x86_64, which still supported -KPIC.
       ecc*)
 	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
@@ -4374,6 +4711,12 @@ m4_if([$1], [CXX], [
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C 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'
+	;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
@@ -4471,7 +4814,7 @@ m4_if([$1], [CXX], [
       ;;
 
     sysv4*MP*)
-      if test -d /usr/nec ;then
+      if test -d /usr/nec; then
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
@@ -4500,7 +4843,7 @@ m4_if([$1], [CXX], [
   fi
 ])
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     _LT_TAGVAR(lt_prog_compiler_pic, $1)=
     ;;
@@ -4566,17 +4909,21 @@ m4_if([$1], [CXX], [
   case $host_os in
   aix[[4-9]]*)
     # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
+    # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+    # Without the "-l" option, or with the "-B" option, AIX nm treats
+    # weak defined symbols like other global defined symbols, whereas
+    # GNU nm marks them as "W".
+    # While the 'weak' keyword is ignored in the Export File, we need
+    # it in the Import File for the 'aix-soname' feature, so we have
+    # to replace the "-B" option with "-P" for AIX nm.
     if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
     else
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
     fi
     ;;
   pw32*)
-    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+    _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
@@ -4589,9 +4936,6 @@ m4_if([$1], [CXX], [
       ;;
     esac
     ;;
-  linux* | k*bsd*-gnu | gnu*)
-    _LT_TAGVAR(link_all_deplibs, $1)=no
-    ;;
   *)
     _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
     ;;
@@ -4625,9 +4969,9 @@ m4_if([$1], [CXX], [
   # included in the symbol list
   _LT_TAGVAR(include_expsyms, $1)=
   # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
   _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
@@ -4643,7 +4987,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       with_gnu_ld=no
     fi
     ;;
@@ -4651,12 +4995,9 @@ dnl Note also adjust exclude_expsyms for C++ above.
     # we just hope/assume this is gcc and not c89 (= MSVC++)
     with_gnu_ld=yes
     ;;
-  openbsd*)
+  openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
-  linux* | k*bsd*-gnu | gnu*)
-    _LT_TAGVAR(link_all_deplibs, $1)=no
-    ;;
   esac
 
   _LT_TAGVAR(ld_shlibs, $1)=yes
@@ -4664,7 +5005,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
   # On some targets, GNU ld is compatible enough with the native linker
   # that we're better off using the native interface for both.
   lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     case $host_os in
       aix*)
 	# The AIX port of GNU ld has always aspired to compatibility
@@ -4686,24 +5027,24 @@ dnl Note also adjust exclude_expsyms for C++ above.
     esac
   fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
+  if test yes = "$lt_use_gnu_ld_interface"; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    wlarc='$wl'
 
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
     runpath_var=LD_RUN_PATH
-    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
     # ancient GNU ld didn't support --whole-archive et. al.
     if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
     else
       _LT_TAGVAR(whole_archive_flag_spec, $1)=
     fi
     supports_anon_versioning=no
-    case `$LD -v 2>&1` in
+    case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in
       *GNU\ gold*) supports_anon_versioning=yes ;;
       *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
       *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -4716,7 +5057,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     case $host_os in
     aix[[3-9]]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
+      if test ia64 != "$host_cpu"; then
 	_LT_TAGVAR(ld_shlibs, $1)=no
 	cat <<_LT_EOF 1>&2
 
@@ -4735,7 +5076,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
@@ -4751,7 +5092,7 @@ _LT_EOF
 	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	# support --undefined.  This deserves some investigation.  FIXME
-	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4761,7 +5102,7 @@ _LT_EOF
       # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
       # as there is no search path for DLLs.
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_TAGVAR(always_export_symbols, $1)=no
       _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -4769,61 +5110,89 @@ _LT_EOF
       _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
 
       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
 
     haiku*)
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
+    os2*)
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      shrext_cmds=.dll
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
     interix[[3-9]]*)
       _LT_TAGVAR(hardcode_direct, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
       # consuming and fragmenting process.  To avoid this, we pick a random,
       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
       ;;
 
     gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
+      if test linux-dietlibc = "$host_os"; then
 	case $cc_basename in
 	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 	esac
       fi
       if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
+	 && test no = "$tmp_diet"
       then
 	tmp_addflag=' $pic_flag'
 	tmp_sharedflag='-shared'
 	case $cc_basename,$host_cpu in
         pgcc*)				# Portland Group C compiler
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
 	pgf77* | pgf90* | pgf95* | pgfortran*)
 					# Portland Group f77 and f90 compilers
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -4834,42 +5203,47 @@ _LT_EOF
 	lf95*)				# Lahey Fortran 8.1
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)=
 	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
 	xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
 	  ;;
 	esac
 	case `$CC -V 2>&1 | sed 5q` in
 	*Sun\ C*)			# Sun C 5.9
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
 	  tmp_sharedflag='-G' ;;
 	*Sun\ F*)			# Sun Fortran 8.3
 	  tmp_sharedflag='-G' ;;
 	esac
-	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test "x$supports_anon_versioning" = xyes; then
+        if test yes = "$supports_anon_versioning"; then
           _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
         fi
 
 	case $cc_basename in
+	tcc*)
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic'
+	  ;;
 	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)='${wl}-rpath ${wl}$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
+	  if test yes = "$supports_anon_versioning"; then
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 	  fi
 	  ;;
 	esac
@@ -4878,13 +5252,13 @@ _LT_EOF
       fi
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -4902,8 +5276,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4915,7 +5289,7 @@ _LT_EOF
 	_LT_TAGVAR(ld_shlibs, $1)=no
 	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
 *** reliably create shared libraries on SCO systems.  Therefore, libtool
 *** is disabling shared libraries support.  We urge you to upgrade GNU
 *** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
@@ -4930,9 +5304,9 @@ _LT_EOF
 	  # DT_RUNPATH tag from executables and libraries.  But doing so
 	  # requires that you compile everything twice, which is a pain.
 	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	  else
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	  fi
@@ -4949,15 +5323,15 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
     esac
 
-    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+    if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then
       runpath_var=
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
       _LT_TAGVAR(export_dynamic_flag_spec, $1)=
@@ -4973,7 +5347,7 @@ _LT_EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	_LT_TAGVAR(hardcode_direct, $1)=unsupported
@@ -4981,34 +5355,57 @@ _LT_EOF
       ;;
 
     aix[[4-9]]*)
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
 	aix_use_runtimelinking=no
 	exp_sym_flag='-Bexport'
-	no_entry_flag=""
+	no_entry_flag=
       else
 	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
 	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
 	else
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
 	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
 	    aix_use_runtimelinking=yes
 	    break
 	  fi
 	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
 	  ;;
 	esac
 
@@ -5027,13 +5424,21 @@ _LT_EOF
       _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+      _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	_LT_TAGVAR(hardcode_direct, $1)=no
+	_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+	;;
+      esac
 
-      if test "$GCC" = yes; then
+      if test yes = "$GCC"; then
 	case $host_os in aix4.[[012]]|aix4.[[012]].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -5052,62 +5457,80 @@ _LT_EOF
 	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
 	fi
-	_LT_TAGVAR(link_all_deplibs, $1)=no
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
 	  else
-	    shared_flag='${wl}-bM:SRE'
+	    shared_flag='$wl-bM:SRE'
 	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
 	fi
       fi
 
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
       # It seems that -bexpall does not export symbols beginning with
       # underscore (_), so it is better to generate a list of symbols to export.
       _LT_TAGVAR(always_export_symbols, $1)=yes
-      if test "$aix_use_runtimelinking" = yes; then
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
 	# Warning - without using the other runtime loading flags (-brtl),
 	# -berok will link without error, but may produce a broken library.
 	_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
         # Determine the default libpath from the value encoded in an
         # empty executable.
         _LT_SYS_MODULE_PATH_AIX([$1])
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
       else
-	if test "$host_cpu" = ia64; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	if test ia64 = "$host_cpu"; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
 	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
 	 _LT_SYS_MODULE_PATH_AIX([$1])
-	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 	  # Warning - without using the other run time loading flags,
 	  # -berok will link without error, but may produce a broken library.
-	  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
+	  _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+	  _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
 	    # We only use this code for GNU lds that support --whole-archive.
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	  else
 	    # Exported symbols can be pulled into shared objects from archives
 	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	  fi
 	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 3 [...]
+	  else
+	    # used by -dlpreopen to get the symbols
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
 	fi
       fi
       ;;
@@ -5116,7 +5539,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
@@ -5146,16 +5569,17 @@ _LT_EOF
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
+	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
 	# 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
@@ -5164,18 +5588,18 @@ _LT_EOF
 	# Don't use ranlib
 	_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
 	_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -5184,7 +5608,7 @@ _LT_EOF
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
 	_LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 	# The linker will automatically build a .lib file if we build a DLL.
@@ -5234,33 +5658,33 @@ _LT_EOF
       ;;
 
     hpux9*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       fi
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(hardcode_direct, $1)=yes
 
       # hardcode_minus_L: Not really in the search PATH,
       # but as the default location of the library.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
       ;;
 
     hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
       else
 	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
       fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
 	_LT_TAGVAR(hardcode_minus_L, $1)=yes
@@ -5268,25 +5692,25 @@ _LT_EOF
       ;;
 
     hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+      if test yes,no = "$GCC,$with_gnu_ld"; then
 	case $host_cpu in
 	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
 	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
 	m4_if($1, [], [
@@ -5294,14 +5718,14 @@ _LT_EOF
 	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
 	  _LT_LINKER_OPTION([if $CC understands -b],
 	    _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
-	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
 	    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
-	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
 	  ;;
 	esac
       fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	case $host_cpu in
@@ -5312,7 +5736,7 @@ _LT_EOF
 	*)
 	  _LT_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
@@ -5323,16 +5747,16 @@ _LT_EOF
       ;;
 
     irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	# Try to use the -exported_symbol ld option, if it does not
 	# work, assume that -exports_file does not work either and
 	# implicitly export all symbols.
 	# This should be the same for all languages, so no per-tag cache variable.
 	AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
 	  [lt_cv_irix_exported_symbol],
-	  [save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+	  [save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
 	   AC_LINK_IFELSE(
 	     [AC_LANG_SOURCE(
 	        [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
@@ -5345,22 +5769,32 @@ _LT_EOF
       end]])])],
 	      [lt_cv_irix_exported_symbol=yes],
 	      [lt_cv_irix_exported_symbol=no])
-           LDFLAGS="$save_LDFLAGS"])
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+           LDFLAGS=$save_LDFLAGS])
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
 	fi
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
       fi
       _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(inherit_rpath, $1)=yes
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	_LT_TAGVAR(ld_shlibs, $1)=yes
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
+
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
       else
@@ -5374,7 +5808,7 @@ _LT_EOF
     newsos6)
       _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
@@ -5382,27 +5816,19 @@ _LT_EOF
     *nto* | *qnx*)
       ;;
 
-    openbsd*)
+    openbsd* | bitrig*)
       if test -f /usr/libexec/ld.so; then
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
 	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	else
-	  case $host_os in
-	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
-	     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	     ;;
-	   *)
-	     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	     ;;
-	  esac
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
 	fi
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
@@ -5413,33 +5839,53 @@ _LT_EOF
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=.dll
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
 
     osf3*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
       else
 	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
       fi
       _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       ;;
 
     osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       else
 	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -5450,24 +5896,24 @@ _LT_EOF
 
     solaris*)
       _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
 	  wlarc=''
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  wlarc='${wl}'
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  wlarc='$wl'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -5477,11 +5923,11 @@ _LT_EOF
       solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
       *)
 	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
 	# but is careful enough not to reorder.
 	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	if test yes = "$GCC"; then
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 	else
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	fi
@@ -5491,10 +5937,10 @@ _LT_EOF
       ;;
 
     sunos4*)
-      if test "x$host_vendor" = xsequent; then
+      if test sequent = "$host_vendor"; then
 	# Use $CC to link under sequent, because it throws in some extra .o
 	# files that make .init and .fini sections work.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
       else
 	_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
       fi
@@ -5543,43 +5989,43 @@ _LT_EOF
       ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
     sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
+      # Note: We CANNOT use -z defs as we might desire, because we do not
       # link with -lc, and that would cause any symbols used from libc to
       # always be unresolved, which means just about no library would
       # ever link correctly.  If we're not using GNU ld we use -z text
       # though, which does catch some bad symbols but isn't as heavy-handed
       # as -z defs.
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+      _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
@@ -5594,17 +6040,17 @@ _LT_EOF
       ;;
     esac
 
-    if test x$host_vendor = xsni; then
+    if test sni = "$host_vendor"; then
       case $host in
       sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym'
 	;;
       esac
     fi
   fi
 ])
 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
 
 _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
 
@@ -5621,7 +6067,7 @@ x|xyes)
   # Assume -lc should be added
   _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $_LT_TAGVAR(archive_cmds, $1) in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -5701,12 +6147,12 @@ _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
 _LT_TAGDECL([], [hardcode_libdir_separator], [1],
     [Whether we need a single "-rpath" flag with a separated argument])
 _LT_TAGDECL([], [hardcode_direct], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
     DIR into the resulting binary])
 _LT_TAGDECL([], [hardcode_direct_absolute], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
     DIR into the resulting binary and the resulting library dependency is
-    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+    "absolute", i.e impossible to change by setting $shlibpath_var if the
     library is relocated])
 _LT_TAGDECL([], [hardcode_minus_L], [0],
     [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
@@ -5747,10 +6193,10 @@ dnl    [Compiler flag to generate thread safe objects])
 # ------------------------
 # Ensure that the configuration variables for a C compiler are suitably
 # defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_C_CONFIG],
 [m4_require([_LT_DECL_EGREP])dnl
-lt_save_CC="$CC"
+lt_save_CC=$CC
 AC_LANG_PUSH(C)
 
 # Source file extension for C test sources.
@@ -5790,18 +6236,18 @@ if test -n "$compiler"; then
   LT_SYS_DLOPEN_SELF
   _LT_CMD_STRIPLIB
 
-  # Report which library types will actually be built
+  # Report what library types will actually be built
   AC_MSG_CHECKING([if libtool supports shared libraries])
   AC_MSG_RESULT([$can_build_shared])
 
   AC_MSG_CHECKING([whether to build shared libraries])
-  test "$can_build_shared" = "no" && enable_shared=no
+  test no = "$can_build_shared" && 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
+    test yes = "$enable_shared" && enable_static=no
     if test -n "$RANLIB"; then
       archive_cmds="$archive_cmds~\$RANLIB \$lib"
       postinstall_cmds='$RANLIB $lib'
@@ -5809,8 +6255,12 @@ if test -n "$compiler"; then
     ;;
 
   aix[[4-9]]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
     fi
     ;;
   esac
@@ -5818,13 +6268,13 @@ if test -n "$compiler"; then
 
   AC_MSG_CHECKING([whether to build static libraries])
   # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
+  test yes = "$enable_shared" || enable_static=yes
   AC_MSG_RESULT([$enable_static])
 
   _LT_CONFIG($1)
 fi
 AC_LANG_POP
-CC="$lt_save_CC"
+CC=$lt_save_CC
 ])# _LT_LANG_C_CONFIG
 
 
@@ -5832,14 +6282,14 @@ CC="$lt_save_CC"
 # --------------------------
 # Ensure that the configuration variables for a C++ compiler are suitably
 # defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_CXX_CONFIG],
 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_EGREP])dnl
 m4_require([_LT_PATH_MANIFEST_TOOL])dnl
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
+if test -n "$CXX" && ( test no != "$CXX" &&
+    ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+    (test g++ != "$CXX"))); then
   AC_PROG_CXXCPP
 else
   _lt_caught_CXX_error=yes
@@ -5881,7 +6331,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the CXX compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="int some_variable = 0;"
 
@@ -5923,35 +6373,35 @@ if test "$_lt_caught_CXX_error" != yes; then
   if test -n "$compiler"; then
     # We don't want -fno-exception when compiling C++ code, so set the
     # no_builtin_flag separately
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
     else
       _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
     fi
 
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       # Set up default GNU C++ configuration
 
       LT_PATH_LD
 
       # Check if GNU C++ uses GNU ld as the underlying linker, since the
       # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      if test yes = "$with_gnu_ld"; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
 
         # If archive_cmds runs LD, not CC, wlarc should be empty
         # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
         #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+        wlarc='$wl'
 
         # ancient GNU ld didn't support --whole-archive et. al.
         if eval "`$CC -print-prog-name=ld` --help 2>&1" |
 	  $GREP 'no-whole-archive' > /dev/null; then
-          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+          _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
         else
           _LT_TAGVAR(whole_archive_flag_spec, $1)=
         fi
@@ -5987,18 +6437,30 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=no
         ;;
       aix[[4-9]]*)
-        if test "$host_cpu" = ia64; then
+        if test ia64 = "$host_cpu"; then
           # On IA64, the linker does run time linking by default, so we don't
           # have to do anything special.
           aix_use_runtimelinking=no
           exp_sym_flag='-Bexport'
-          no_entry_flag=""
+          no_entry_flag=
         else
           aix_use_runtimelinking=no
 
           # Test if we are trying to use run time linking or normal
           # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
+          # have runtime linking enabled, and use it for executables.
+          # For shared libraries, we enable/disable runtime linking
+          # depending on the kind of the shared library created -
+          # when "with_aix_soname,aix_use_runtimelinking" is:
+          # "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "aix,yes"  lib.so          shared, rtl:yes, for executables
+          #            lib.a           static archive
+          # "both,no"  lib.so.V(shr.o) shared, rtl:yes
+          #            lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a(lib.so.V) shared, rtl:no
+          # "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a           static archive
           case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	    for ld_flag in $LDFLAGS; do
 	      case $ld_flag in
@@ -6008,6 +6470,13 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        ;;
 	      esac
 	    done
+	    if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	      # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	      # so we don't have lib.a shared libs to link our executables.
+	      # We have to force runtime linking in this case.
+	      aix_use_runtimelinking=yes
+	      LDFLAGS="$LDFLAGS -Wl,-brtl"
+	    fi
 	    ;;
           esac
 
@@ -6026,13 +6495,21 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
-        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+        _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+        case $with_aix_soname,$aix_use_runtimelinking in
+        aix,*) ;;	# no import file
+        svr4,* | *,yes) # use import file
+          # The Import File defines what to hardcode.
+          _LT_TAGVAR(hardcode_direct, $1)=no
+          _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+          ;;
+        esac
 
-        if test "$GXX" = yes; then
+        if test yes = "$GXX"; then
           case $host_os in aix4.[[012]]|aix4.[[012]].*)
           # We only want to do this on AIX 4.2 and lower, the check
           # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -6050,64 +6527,84 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  fi
           esac
           shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag=$shared_flag' $wl-G'
 	  fi
+	  # Need to ensure runtime linking is disabled for the traditional
+	  # shared library, or the linker may eventually find shared libraries
+	  # /with/ Import File - we do not want to mix them.
+	  shared_flag_aix='-shared'
+	  shared_flag_svr4='-shared $wl-G'
         else
           # not using gcc
-          if test "$host_cpu" = ia64; then
+          if test ia64 = "$host_cpu"; then
 	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	  # chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
           else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
+	    if test yes = "$aix_use_runtimelinking"; then
+	      shared_flag='$wl-G'
 	    else
-	      shared_flag='${wl}-bM:SRE'
+	      shared_flag='$wl-bM:SRE'
 	    fi
+	    shared_flag_aix='$wl-bM:SRE'
+	    shared_flag_svr4='$wl-G'
           fi
         fi
 
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
         # It seems that -bexpall does not export symbols beginning with
         # underscore (_), so it is better to generate a list of symbols to
 	# export.
         _LT_TAGVAR(always_export_symbols, $1)=yes
-        if test "$aix_use_runtimelinking" = yes; then
+	if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
           # Warning - without using the other runtime loading flags (-brtl),
           # -berok will link without error, but may produce a broken library.
-          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+          # The "-G" linker flag allows undefined symbols.
+          _LT_TAGVAR(no_undefined_flag, $1)='-bernotok'
           # Determine the default libpath from the value encoded in an empty
           # executable.
           _LT_SYS_MODULE_PATH_AIX([$1])
-          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
         else
-          if test "$host_cpu" = ia64; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+          if test ia64 = "$host_cpu"; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
 	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
           else
 	    # Determine the default libpath from the value encoded in an
 	    # empty executable.
 	    _LT_SYS_MODULE_PATH_AIX([$1])
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 	    # Warning - without using the other run time loading flags,
 	    # -berok will link without error, but may produce a broken library.
-	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
+	    _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+	    _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+	    if test yes = "$with_gnu_ld"; then
 	      # We only use this code for GNU lds that support --whole-archive.
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    else
 	      # Exported symbols can be pulled into shared objects from archives
 	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	    fi
 	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	    # -brtl affects multiple linker settings, -berok does not and is overridden later
+	    compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+	    if test svr4 != "$with_aix_soname"; then
+	      # This is similar to how AIX traditionally builds its shared
+	      # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	    fi
+	    if test aix != "$with_aix_soname"; then
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# [...]
+	    else
+	      # used by -dlpreopen to get the symbols
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	    fi
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
           fi
         fi
         ;;
@@ -6117,7 +6614,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	  # support --undefined.  This deserves some investigation.  FIXME
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 	else
 	  _LT_TAGVAR(ld_shlibs, $1)=no
 	fi
@@ -6145,57 +6642,58 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  # Tell ltmain to make .lib files, not .a files.
 	  libext=lib
 	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
+	  shrext_cmds=.dll
 	  # FIXME: Setting linknames here is a bad hack.
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+              cp "$export_symbols" "$output_objdir/$soname.def";
+              echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+            else
+              $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+            fi~
+            $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+            linknames='
 	  # 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
 	  # Don't use ranlib
 	  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
 	  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+            lt_tool_outputfile="@TOOL_OUTPUT@"~
+            case $lt_outputfile in
+              *.exe|*.EXE) ;;
+              *)
+                lt_outputfile=$lt_outputfile.exe
+                lt_tool_outputfile=$lt_tool_outputfile.exe
+                ;;
+            esac~
+            func_to_tool_file "$lt_outputfile"~
+            if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+              $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+              $RM "$lt_outputfile.manifest";
+            fi'
 	  ;;
 	*)
 	  # g++
 	  # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
 	  # as there is no search path for DLLs.
 	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	  _LT_TAGVAR(always_export_symbols, $1)=no
 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
 	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file, use it as
+	    # is; otherwise, prepend EXPORTS...
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+              cp $export_symbols $output_objdir/$soname.def;
+            else
+              echo EXPORTS > $output_objdir/$soname.def;
+              cat $export_symbols >> $output_objdir/$soname.def;
+            fi~
+            $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	  else
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	  fi
@@ -6206,6 +6704,34 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_DARWIN_LINKER_FEATURES($1)
 	;;
 
+      os2*)
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	_LT_TAGVAR(hardcode_minus_L, $1)=yes
+	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	shrext_cmds=.dll
+	_LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  prefix_cmds="$SED"~
+	  if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	    prefix_cmds="$prefix_cmds -e 1d";
+	  fi~
+	  prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	  cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	_LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+	;;
+
       dgux*)
         case $cc_basename in
           ec++*)
@@ -6241,14 +6767,14 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
       haiku*)
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
         ;;
 
       hpux9*)
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
         _LT_TAGVAR(hardcode_direct, $1)=yes
         _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
 				             # but as the default
@@ -6260,7 +6786,7 @@ if test "$_lt_caught_CXX_error" != yes; then
             _LT_TAGVAR(ld_shlibs, $1)=no
             ;;
           aCC*)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             # Commands to make compiler produce verbose output that lists
             # what "hidden" libraries, object files and flags are used when
             # linking a shared library.
@@ -6269,11 +6795,11 @@ if test "$_lt_caught_CXX_error" != yes; then
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
-            if test "$GXX" = yes; then
-              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            if test yes = "$GXX"; then
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             else
               # FIXME: insert proper C++ library support
               _LT_TAGVAR(ld_shlibs, $1)=no
@@ -6283,15 +6809,15 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
       hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        if test no = "$with_gnu_ld"; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
           case $host_cpu in
             hppa*64*|ia64*)
               ;;
             *)
-	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
               ;;
           esac
         fi
@@ -6317,13 +6843,13 @@ if test "$_lt_caught_CXX_error" != yes; then
           aCC*)
 	    case $host_cpu in
 	      hppa*64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      ia64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      *)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	    esac
 	    # Commands to make compiler produce verbose output that lists
@@ -6334,20 +6860,20 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
 	        case $host_cpu in
 	          hppa*64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          ia64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          *)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	        esac
 	      fi
@@ -6362,22 +6888,22 @@ if test "$_lt_caught_CXX_error" != yes; then
       interix[[3-9]]*)
 	_LT_TAGVAR(hardcode_direct, $1)=no
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
 	# Instead, shared libraries are loaded at an image base (0x10000000 by
 	# default) and relocated if they conflict, which is a slow very memory
 	# consuming and fragmenting process.  To avoid this, we pick a random,
 	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
 	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 	;;
       irix5* | irix6*)
         case $cc_basename in
           CC*)
 	    # SGI C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -6386,17 +6912,17 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	      else
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
 	      fi
 	    fi
 	    _LT_TAGVAR(link_all_deplibs, $1)=yes
 	    ;;
         esac
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         _LT_TAGVAR(inherit_rpath, $1)=yes
         ;;
@@ -6409,8 +6935,8 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
 	    # Commands to make compiler produce verbose output that lists
 	    # what "hidden" libraries, object files and flags are used when
 	    # linking a shared library.
@@ -6419,10 +6945,10 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -6436,59 +6962,59 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # earlier do not add the objects themselves.
 	    case `$CC -V 2>&1` in
 	      *"Version 7."*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	      *)  # Version 8.0 or newer
 	        tmp_idyn=
 	        case $host_cpu in
 		  ia64*) tmp_idyn=' -i_dynamic';;
 		esac
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	    esac
 	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    ;;
           pgCC* | pgcpp*)
             # Portland Group C++ compiler
 	    case `$CC -V` in
 	    *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
 	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
 	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+                $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+                $RANLIB $oldlib'
 	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
 	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    *) # Version 6 and above use weak symbols
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    esac
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
             ;;
 	  cxx*)
 	    # Compaq C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname  -o $lib $wl-retain-symbols-file $wl$export_symbols'
 
 	    runpath_var=LD_RUN_PATH
 	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -6502,18 +7028,18 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
 	    ;;
 	  xl* | mpixl* | bgxl*)
 	    # IBM XL 8.0 on PPC, with GNU ld
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    if test yes = "$supports_anon_versioning"; then
 	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+                cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+                echo "local: *; };" >> $output_objdir/$libname.ver~
+                $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
 	    fi
 	    ;;
 	  *)
@@ -6521,10 +7047,10 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    *Sun\ C*)
 	      # Sun C++ 5.9
 	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
 	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	      _LT_TAGVAR(compiler_needs_object, $1)=yes
 
 	      # Not sure whether something based on
@@ -6582,22 +7108,17 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=yes
 	;;
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	;;
-
-      openbsd*)
+      openbsd* | bitrig*)
 	if test -f /usr/libexec/ld.so; then
 	  _LT_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
 	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
 	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
 	  fi
 	  output_verbose_link_cmd=func_echo_all
 	else
@@ -6613,9 +7134,9 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
 	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	    # Archives containing C++ object files must be created using
@@ -6633,17 +7154,17 @@ if test "$_lt_caught_CXX_error" != yes; then
           cxx*)
 	    case $host in
 	      osf3*)
-	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 		;;
 	      *)
 	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
+                  echo "-hidden">> $lib.exp~
+                  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+                  $RM $lib.exp'
 	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
 		;;
 	    esac
@@ -6658,21 +7179,21 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
 	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
 	      case $host in
 	        osf3*)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	        *)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	      esac
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	      # Commands to make compiler produce verbose output that lists
@@ -6718,9 +7239,9 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # Sun C++ 4.2, 5.x and Centerline C++
             _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
 	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+              $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -6728,7 +7249,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 	      *)
 		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
+		# but understands '-z linker_flag'.
 	        # Supported since Solaris 2.6 (maybe 2.5.1?)
 		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	        ;;
@@ -6745,30 +7266,30 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    ;;
           gcx*)
 	    # Green Hills C++ Compiler
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 
 	    # The C++ compiler must be used to create the archive.
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
 	    ;;
           *)
 	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs'
 	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
 	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # g++ 2.7 appears to require '-G' NOT '-shared' on this
 	        # platform.
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
@@ -6776,11 +7297,11 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      fi
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir'
 	      case $host_os in
 		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 		*)
-		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 		  ;;
 	      esac
 	    fi
@@ -6789,52 +7310,52 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       runpath_var='LD_RUN_PATH'
 
       case $cc_basename in
         CC*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
       esac
       ;;
 
       sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
+	# Note: We CANNOT use -z defs as we might desire, because we do not
 	# link with -lc, and that would cause any symbols used from libc to
 	# always be unresolved, which means just about no library would
 	# ever link correctly.  If we're not using GNU ld we use -z text
 	# though, which does catch some bad symbols but isn't as heavy-handed
 	# as -z defs.
-	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+	_LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+	_LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
 	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
 	_LT_TAGVAR(link_all_deplibs, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
 	runpath_var='LD_RUN_PATH'
 
 	case $cc_basename in
           CC*)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
-	      '"$_LT_TAGVAR(old_archive_cmds, $1)"
+              '"$_LT_TAGVAR(old_archive_cmds, $1)"
 	    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
-	      '"$_LT_TAGVAR(reload_cmds, $1)"
+              '"$_LT_TAGVAR(reload_cmds, $1)"
 	    ;;
 	  *)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    ;;
 	esac
       ;;
@@ -6865,10 +7386,10 @@ if test "$_lt_caught_CXX_error" != yes; then
     esac
 
     AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+    test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
 
-    _LT_TAGVAR(GCC, $1)="$GXX"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$GXX
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -6895,7 +7416,7 @@ if test "$_lt_caught_CXX_error" != yes; then
   lt_cv_path_LD=$lt_save_path_LD
   lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
   lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
 
 AC_LANG_POP
 ])# _LT_LANG_CXX_CONFIG
@@ -6917,13 +7438,14 @@ AC_REQUIRE([_LT_DECL_SED])
 AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
 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}\$%%"`;;
+  case @S|@2 in
+  .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;;
+  *)  func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;;
   esac
 } # func_stripname_cnf
 ])# _LT_FUNC_STRIPNAME_CNF
 
+
 # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
 # ---------------------------------
 # Figure out "hidden" library dependencies from verbose
@@ -7007,13 +7529,13 @@ if AC_TRY_EVAL(ac_compile); then
   pre_test_object_deps_done=no
 
   for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+    case $prev$p in
 
     -L* | -R* | -l*)
        # Some compilers place space between "-{L,R}" and the path.
        # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
+       if test x-L = "$p" ||
+          test x-R = "$p"; then
 	 prev=$p
 	 continue
        fi
@@ -7029,16 +7551,16 @@ if AC_TRY_EVAL(ac_compile); then
        case $p in
        =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
        esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
+       if test no = "$pre_test_object_deps_done"; then
+	 case $prev in
 	 -L | -R)
 	   # Internal compiler library paths should come after those
 	   # provided the user.  The postdeps already come after the
 	   # user supplied libs so there is no need to process them.
 	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+	     _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p
 	   else
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p"
 	   fi
 	   ;;
 	 # The "-l" case would never come before the object being
@@ -7046,9 +7568,9 @@ if AC_TRY_EVAL(ac_compile); then
 	 esac
        else
 	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
-	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+	   _LT_TAGVAR(postdeps, $1)=$prev$p
 	 else
-	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p"
 	 fi
        fi
        prev=
@@ -7063,15 +7585,15 @@ if AC_TRY_EVAL(ac_compile); then
 	 continue
        fi
 
-       if test "$pre_test_object_deps_done" = no; then
+       if test no = "$pre_test_object_deps_done"; then
 	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
-	   _LT_TAGVAR(predep_objects, $1)="$p"
+	   _LT_TAGVAR(predep_objects, $1)=$p
 	 else
 	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
 	 fi
        else
 	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
-	   _LT_TAGVAR(postdep_objects, $1)="$p"
+	   _LT_TAGVAR(postdep_objects, $1)=$p
 	 else
 	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
 	 fi
@@ -7102,51 +7624,6 @@ interix[[3-9]]*)
   _LT_TAGVAR(postdep_objects,$1)=
   _LT_TAGVAR(postdeps,$1)=
   ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
-
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
 esac
 ])
 
@@ -7155,7 +7632,7 @@ case " $_LT_TAGVAR(postdeps, $1) " in
 esac
  _LT_TAGVAR(compiler_lib_search_dirs, $1)=
 if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'`
 fi
 _LT_TAGDECL([], [compiler_lib_search_dirs], [1],
     [The directories searched by this compiler when creating a shared library])
@@ -7175,10 +7652,10 @@ _LT_TAGDECL([], [compiler_lib_search_path], [1],
 # --------------------------
 # Ensure that the configuration variables for a Fortran 77 compiler are
 # suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_F77_CONFIG],
 [AC_LANG_PUSH(Fortran 77)
-if test -z "$F77" || test "X$F77" = "Xno"; then
+if test -z "$F77" || test no = "$F77"; then
   _lt_disable_F77=yes
 fi
 
@@ -7215,7 +7692,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the F77 compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_F77" != yes; then
+if test yes != "$_lt_disable_F77"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="\
       subroutine t
@@ -7237,7 +7714,7 @@ if test "$_lt_disable_F77" != yes; then
   _LT_LINKER_BOILERPLATE
 
   # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
+  lt_save_CC=$CC
   lt_save_GCC=$GCC
   lt_save_CFLAGS=$CFLAGS
   CC=${F77-"f77"}
@@ -7251,21 +7728,25 @@ if test "$_lt_disable_F77" != yes; then
     AC_MSG_RESULT([$can_build_shared])
 
     AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+    test no = "$can_build_shared" && 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
+        test yes = "$enable_shared" && 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
+	if test ia64 != "$host_cpu"; then
+	  case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+	  yes,aix,yes) ;;		# shared object as lib.so file only
+	  yes,svr4,*) ;;		# shared object as lib.so archive member only
+	  yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+	  esac
 	fi
         ;;
     esac
@@ -7273,11 +7754,11 @@ if test "$_lt_disable_F77" != yes; then
 
     AC_MSG_CHECKING([whether to build static libraries])
     # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
+    test yes = "$enable_shared" || enable_static=yes
     AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$G77"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$G77
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -7294,9 +7775,9 @@ if test "$_lt_disable_F77" != yes; then
   fi # test -n "$compiler"
 
   GCC=$lt_save_GCC
-  CC="$lt_save_CC"
-  CFLAGS="$lt_save_CFLAGS"
-fi # test "$_lt_disable_F77" != yes
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+fi # test yes != "$_lt_disable_F77"
 
 AC_LANG_POP
 ])# _LT_LANG_F77_CONFIG
@@ -7306,11 +7787,11 @@ AC_LANG_POP
 # -------------------------
 # Ensure that the configuration variables for a Fortran compiler are
 # suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_FC_CONFIG],
 [AC_LANG_PUSH(Fortran)
 
-if test -z "$FC" || test "X$FC" = "Xno"; then
+if test -z "$FC" || test no = "$FC"; then
   _lt_disable_FC=yes
 fi
 
@@ -7347,7 +7828,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the FC compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
+if test yes != "$_lt_disable_FC"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="\
       subroutine t
@@ -7369,7 +7850,7 @@ if test "$_lt_disable_FC" != yes; then
   _LT_LINKER_BOILERPLATE
 
   # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
+  lt_save_CC=$CC
   lt_save_GCC=$GCC
   lt_save_CFLAGS=$CFLAGS
   CC=${FC-"f95"}
@@ -7385,21 +7866,25 @@ if test "$_lt_disable_FC" != yes; then
     AC_MSG_RESULT([$can_build_shared])
 
     AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+    test no = "$can_build_shared" && 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
+        test yes = "$enable_shared" && 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
+	if test ia64 != "$host_cpu"; then
+	  case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+	  yes,aix,yes) ;;		# shared object as lib.so file only
+	  yes,svr4,*) ;;		# shared object as lib.so archive member only
+	  yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+	  esac
 	fi
         ;;
     esac
@@ -7407,11 +7892,11 @@ if test "$_lt_disable_FC" != yes; then
 
     AC_MSG_CHECKING([whether to build static libraries])
     # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
+    test yes = "$enable_shared" || enable_static=yes
     AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -7431,7 +7916,7 @@ if test "$_lt_disable_FC" != yes; then
   GCC=$lt_save_GCC
   CC=$lt_save_CC
   CFLAGS=$lt_save_CFLAGS
-fi # test "$_lt_disable_FC" != yes
+fi # test yes != "$_lt_disable_FC"
 
 AC_LANG_POP
 ])# _LT_LANG_FC_CONFIG
@@ -7441,7 +7926,7 @@ AC_LANG_POP
 # --------------------------
 # Ensure that the configuration variables for the GNU Java Compiler compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_GCJ_CONFIG],
 [AC_REQUIRE([LT_PROG_GCJ])dnl
 AC_LANG_SAVE
@@ -7475,7 +7960,7 @@ CC=${GCJ-"gcj"}
 CFLAGS=$GCJFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
 _LT_CC_BASENAME([$compiler])
 
 # GCJ did not exist at the time GCC didn't implicitly link libc in.
@@ -7512,7 +7997,7 @@ CFLAGS=$lt_save_CFLAGS
 # --------------------------
 # 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'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_GO_CONFIG],
 [AC_REQUIRE([LT_PROG_GO])dnl
 AC_LANG_SAVE
@@ -7546,7 +8031,7 @@ CC=${GOC-"gccgo"}
 CFLAGS=$GOFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
 _LT_CC_BASENAME([$compiler])
 
 # Go did not exist at the time GCC didn't implicitly link libc in.
@@ -7583,7 +8068,7 @@ CFLAGS=$lt_save_CFLAGS
 # -------------------------
 # Ensure that the configuration variables for the Windows resource compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_RC_CONFIG],
 [AC_REQUIRE([LT_PROG_RC])dnl
 AC_LANG_SAVE
@@ -7599,7 +8084,7 @@ _LT_TAGVAR(objext, $1)=$objext
 lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
 
 # Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
+lt_simple_link_test_code=$lt_simple_compile_test_code
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_TAG_COMPILER
@@ -7609,7 +8094,7 @@ _LT_COMPILER_BOILERPLATE
 _LT_LINKER_BOILERPLATE
 
 # Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
+lt_save_CC=$CC
 lt_save_CFLAGS=$CFLAGS
 lt_save_GCC=$GCC
 GCC=
@@ -7638,7 +8123,7 @@ AC_DEFUN([LT_PROG_GCJ],
 [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
   [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
     [AC_CHECK_TOOL(GCJ, gcj,)
-      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+      test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2"
       AC_SUBST(GCJFLAGS)])])[]dnl
 ])
 
@@ -7749,7 +8234,7 @@ lt_ac_count=0
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f "$lt_ac_sed" && continue
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -7766,9 +8251,9 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
     $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
     cmp -s conftest.out conftest.nl || break
     # 10000 chars as input seems more than enough
-    test $lt_ac_count -gt 10 && break
+    test 10 -lt "$lt_ac_count" && break
     lt_ac_count=`expr $lt_ac_count + 1`
-    if test $lt_ac_count -gt $lt_ac_max; then
+    if test "$lt_ac_count" -gt "$lt_ac_max"; then
       lt_ac_max=$lt_ac_count
       lt_cv_path_SED=$lt_ac_sed
     fi
@@ -7792,27 +8277,7 @@ dnl AC_DEFUN([LT_AC_PROG_SED], [])
 # Find out whether the shell is Bourne or XSI compatible,
 # or has some other useful features.
 m4_defun([_LT_CHECK_SHELL_FEATURES],
-[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-AC_MSG_RESULT([$xsi_shell])
-_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
-
-AC_MSG_CHECKING([whether the shell understands "+="])
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-AC_MSG_RESULT([$lt_shell_append])
-_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
-
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   lt_unset=unset
 else
   lt_unset=false
@@ -7836,102 +8301,9 @@ _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
 ])# _LT_CHECK_SHELL_FEATURES
 
 
-# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
-# ------------------------------------------------------
-# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
-# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
-m4_defun([_LT_PROG_FUNCTION_REPLACE],
-[dnl {
-sed -e '/^$1 ()$/,/^} # $1 /c\
-$1 ()\
-{\
-m4_bpatsubsts([$2], [$], [\\], [^\([	 ]\)], [\\\1])
-} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-])
-
-
-# _LT_PROG_REPLACE_SHELLFNS
-# -------------------------
-# Replace existing portable implementations of several shell functions with
-# equivalent extended shell implementations where those features are available..
-m4_defun([_LT_PROG_REPLACE_SHELLFNS],
-[if test x"$xsi_shell" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
-    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
-    # positional parameters, so assign one to ordinary parameter first.
-    func_stripname_result=${3}
-    func_stripname_result=${func_stripname_result#"${1}"}
-    func_stripname_result=${func_stripname_result%"${2}"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
-    func_split_long_opt_name=${1%%=*}
-    func_split_long_opt_arg=${1#*=}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
-    func_split_short_opt_arg=${1#??}
-    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
-    case ${1} in
-      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
-      *)    func_lo2o_result=${1} ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])
-
-  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])
-
-  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval "${1}+=\\${2}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
-    func_quote_for_eval "${2}"
-dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
-    eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
-fi
-])
-
 # _LT_PATH_CONVERSION_FUNCTIONS
 # -----------------------------
-# Determine which file name conversion functions should be used by
+# Determine what file name conversion functions should be used by
 # func_to_host_file (and, implicitly, by func_to_host_path).  These are needed
 # for certain cross-compile configurations and native mingw.
 m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4
index 5d9acd8..94b0829 100644
--- a/m4/ltoptions.m4
+++ b/m4/ltoptions.m4
@@ -1,14 +1,14 @@
 # Helper functions for option handling.                    -*- Autoconf -*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
-#   Inc.
+#   Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Gary V. Vaughan, 2004
 #
 # 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 7 ltoptions.m4
+# serial 8 ltoptions.m4
 
 # This is to help aclocal find these macros, as it can't see m4_define.
 AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION],
 [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
 m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
         _LT_MANGLE_DEFUN([$1], [$2]),
-    [m4_warning([Unknown $1 option `$2'])])[]dnl
+    [m4_warning([Unknown $1 option '$2'])])[]dnl
 ])
 
 
@@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[
   dnl
   dnl If no reference was made to various pairs of opposing options, then
   dnl we run the default mode handler for the pair.  For example, if neither
-  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
   dnl archives by default:
   _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
   _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
-  		   [_LT_ENABLE_FAST_INSTALL])
+		   [_LT_ENABLE_FAST_INSTALL])
+  _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
+		   [_LT_WITH_AIX_SONAME([aix])])
   ])
 ])# _LT_SET_OPTIONS
 
@@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN],
 [_LT_SET_OPTION([LT_INIT], [dlopen])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `dlopen' option into LT_INIT's first parameter.])
+put the 'dlopen' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
 _LT_SET_OPTION([LT_INIT], [win32-dll])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `win32-dll' option into LT_INIT's first parameter.])
+put the 'win32-dll' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
 
 # _LT_ENABLE_SHARED([DEFAULT])
 # ----------------------------
-# implement the --enable-shared flag, and supports the `shared' and
-# `disable-shared' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-shared flag, and supports the 'shared' and
+# 'disable-shared' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_SHARED],
 [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([shared],
@@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared],
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
@@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], [])
 
 # _LT_ENABLE_STATIC([DEFAULT])
 # ----------------------------
-# implement the --enable-static flag, and support the `static' and
-# `disable-static' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-static flag, and support the 'static' and
+# 'disable-static' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_STATIC],
 [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([static],
@@ -226,14 +228,14 @@ AC_ARG_ENABLE([static],
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
@@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], [])
 
 # _LT_ENABLE_FAST_INSTALL([DEFAULT])
 # ----------------------------------
-# implement the --enable-fast-install flag, and support the `fast-install'
-# and `disable-fast-install' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-fast-install flag, and support the 'fast-install'
+# and 'disable-fast-install' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_FAST_INSTALL],
 [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([fast-install],
@@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install],
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
@@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `fast-install' option into LT_INIT's first parameter.])
+the 'fast-install' option into LT_INIT's first parameter.])
 ])
 
 AU_DEFUN([AC_DISABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], [disable-fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `disable-fast-install' option into LT_INIT's first parameter.])
+the 'disable-fast-install' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
 dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
 
 
+# _LT_WITH_AIX_SONAME([DEFAULT])
+# ----------------------------------
+# implement the --with-aix-soname flag, and support the `aix-soname=aix'
+# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
+# is either `aix', `both' or `svr4'.  If omitted, it defaults to `aix'.
+m4_define([_LT_WITH_AIX_SONAME],
+[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
+shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[[5-9]]*,yes)
+  AC_MSG_CHECKING([which variant of shared library versioning to provide])
+  AC_ARG_WITH([aix-soname],
+    [AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
+      [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
+    [case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      AC_MSG_ERROR([Unknown argument to --with-aix-soname])
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname],
+    [AC_CACHE_VAL([lt_cv_with_aix_soname],
+      [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
+    with_aix_soname=$lt_cv_with_aix_soname])
+  AC_MSG_RESULT([$with_aix_soname])
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+_LT_DECL([], [shared_archive_member_spec], [0],
+    [Shared archive member basename, for filename based shared library versioning on AIX])dnl
+])# _LT_WITH_AIX_SONAME
+
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
+
+
 # _LT_WITH_PIC([MODE])
 # --------------------
-# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
 # LT_INIT options.
-# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+# 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@<:@=PKGS@:>@],
@@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC],
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
-    [pic_mode=default])
-
-test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+    [pic_mode=m4_default([$1], [default])])
 
 _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
 ])# _LT_WITH_PIC
@@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE],
 [_LT_SET_OPTION([LT_INIT], [pic-only])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `pic-only' option into LT_INIT's first parameter.])
+put the 'pic-only' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4
index 9000a05..48bc934 100644
--- a/m4/ltsugar.m4
+++ b/m4/ltsugar.m4
@@ -1,6 +1,7 @@
 # ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
 #
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
+# Foundation, Inc.
 # Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -33,7 +34,7 @@ m4_define([_lt_join],
 # ------------
 # Manipulate m4 lists.
 # These macros are necessary as long as will still need to support
-# Autoconf-2.59 which quotes differently.
+# Autoconf-2.59, which quotes differently.
 m4_define([lt_car], [[$1]])
 m4_define([lt_cdr],
 [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
@@ -44,7 +45,7 @@ m4_define([lt_unquote], $1)
 
 # lt_append(MACRO-NAME, STRING, [SEPARATOR])
 # ------------------------------------------
-# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
 # Note that neither SEPARATOR nor STRING are expanded; they are appended
 # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
 # No SEPARATOR is output if MACRO-NAME was previously undefined (different
diff --git a/m4/ltversion.m4 b/m4/ltversion.m4
index 07a8602..fa04b52 100644
--- a/m4/ltversion.m4
+++ b/m4/ltversion.m4
@@ -1,6 +1,6 @@
 # ltversion.m4 -- version numbers			-*- Autoconf -*-
 #
-#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
 #   Written by Scott James Remnant, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -9,15 +9,15 @@
 
 # @configure_input@
 
-# serial 3337 ltversion.m4
+# serial 4179 ltversion.m4
 # This file is part of GNU Libtool
 
-m4_define([LT_PACKAGE_VERSION], [2.4.2])
-m4_define([LT_PACKAGE_REVISION], [1.3337])
+m4_define([LT_PACKAGE_VERSION], [2.4.6])
+m4_define([LT_PACKAGE_REVISION], [2.4.6])
 
 AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.4.2'
-macro_revision='1.3337'
+[macro_version='2.4.6'
+macro_revision='2.4.6'
 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
 _LT_DECL(, macro_revision, 0)
 ])
diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4
index c573da9..c6b26f8 100644
--- a/m4/lt~obsolete.m4
+++ b/m4/lt~obsolete.m4
@@ -1,6 +1,7 @@
 # lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+#   Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Scott James Remnant, 2004.
 #
 # This file is free software; the Free Software Foundation gives
@@ -11,7 +12,7 @@
 
 # These exist entirely to fool aclocal when bootstrapping libtool.
 #
-# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
 # which have later been changed to m4_define as they aren't part of the
 # exported API, or moved to Autoconf or Automake where they belong.
 #
@@ -25,7 +26,7 @@
 # included after everything else.  This provides aclocal with the
 # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
 # because those macros already exist, or will be overwritten later.
-# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
 #
 # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
 # Yes, that means every name once taken will need to remain here until
diff --git a/man/Makefile.in b/man/Makefile.in
index 178eeb4..171fe00 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -78,16 +88,15 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = man
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/mkinstalldirs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/proj_config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
@@ -146,6 +155,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -213,7 +223,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -296,7 +306,7 @@ EXTRA_DIST = CMakeLists.txt
 all: all-recursive
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -308,7 +318,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu man/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -321,9 +330,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
@@ -603,6 +612,8 @@ uninstall-am:
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
 	ps ps-am tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/man/man1/Makefile.in b/man/man1/Makefile.in
index aff916d..aa52d9d 100644
--- a/man/man1/Makefile.in
+++ b/man/man1/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -78,16 +88,15 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = man/man1
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/mkinstalldirs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/proj_config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
@@ -142,6 +151,7 @@ am__installdirs = "$(DESTDIR)$(man1dir)"
 NROFF = nroff
 MANS = $(man_MANS)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -184,7 +194,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -267,7 +277,7 @@ EXTRA_DIST = $(man_MANS)
 all: all-am
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -279,7 +289,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/man1/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu man/man1/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -292,9 +301,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
@@ -503,6 +512,8 @@ uninstall-man: uninstall-man1
 	ps ps-am tags-am uninstall uninstall-am uninstall-man \
 	uninstall-man1
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/man/man1/cs2cs.1 b/man/man1/cs2cs.1
index 4968bb9..6122138 100644
--- a/man/man1/cs2cs.1
+++ b/man/man1/cs2cs.1
@@ -2,7 +2,7 @@
 .nr LL 5.5i
 .ad b
 .hy 1
-.TH PROJ 1 "2000/03/21 Rel. 4.4" 
+.TH CS2CS 1 "2000/03/21 Rel. 4.4" 
 .SH NAME
 cs2cs \- cartographic coordinate system filter
 .SH SYNOPSIS
@@ -116,7 +116,7 @@ The
 .B +args
 run-line arguments are associated with cartographic parameters
 and usage varies with projection and for a complete description see
-.I "Cartographic Projection Procedures for the UNIX Environment\(emA User's Manual" )
+.I "Cartographic Projection Procedures for the UNIX Environment\(emA User's Manual"
 and supplementary documentation for Release 4.
 .PP
 The \fIcs2cs\fR program requires two coordinate system definitions.  The
@@ -198,5 +198,8 @@ USGS Bulletin 1532).
 .br
 .I "An Album of Map Projections"
 (Snyder & Voxland, 1989, USGS Prof. Paper 1453).
+.SH BUGS
+A list of known bugs can found at https://github.com/OSGeo/proj.4/issues
+where new bug reports can be submitted too.
 .SH HOME PAGE
-http://www.remotesensing.org/proj
+http://proj4.org/
diff --git a/man/man1/geod.1 b/man/man1/geod.1
index 157996e..0a847f8 100644
--- a/man/man1/geod.1
+++ b/man/man1/geod.1
@@ -2,7 +2,7 @@
 .nr LL 7.0i
 .ad b
 .hy 1
-.TH GEOD 1 "2013/07/11 Rel. 4.9.0"
+.TH GEOD 1 "2016/02/16 Rel. 4.9.3"
 .SH NAME
 geod \- direct geodesic computations
 .br
@@ -224,5 +224,8 @@ http://geographiclib.sf.net/geod-addenda.html
 The \fIonline geodesic bibliography\fR,
 .br
 http://geographiclib.sf.net/geodesic-papers/biblio.html
+.SH BUGS
+A list of known bugs can found at https://github.com/OSGeo/proj.4/issues
+where new bug reports can be submitted too.
 .SH HOME PAGE
-https://github.com/OSGeo/proj.4/wiki
+http://proj4.org/
diff --git a/man/man1/proj.1 b/man/man1/proj.1
index 4b77286..6cb8ad4 100644
--- a/man/man1/proj.1
+++ b/man/man1/proj.1
@@ -2,7 +2,7 @@
 .nr LL 5.5i
 .ad b
 .hy 1
-.TH PROJ 1 "2000/03/21 Rel. 4.4" 
+.TH PROJ 1 "2000/03/21 Rel. 4.4"
 .SH NAME
 proj \- forward cartographic projection filter
 .br
@@ -10,7 +10,7 @@ invproj \- inverse cartographic projection filter
 .SH SYNOPSIS
 .B proj
 [
-.B \-bceEfiIlmorsStTvVwW
+.B \-bcCeEfiIlmorsStTvVwW
 [
 .I args
 ] ] [
@@ -20,7 +20,7 @@ file[s]
 .br
 .B invproj
 [
-.B \-bceEfiIlmorsStTwW
+.B \-bcCeEfiIlmorsStTwW
 [
 .I args
 ] ] [
@@ -52,6 +52,11 @@ process and allows bypassing formatting operations.
 Selects binary input only (see
 .B \-b option).
 .TP
+.BI \-C
+Check. Invoke all built in self tests and report.
+Get more verbose report by preceding with the
+.B \-V option).
+.TP
 .BI \-I
 alternate method to specify inverse projection.
 Redundant when used with
@@ -106,7 +111,7 @@ that can be selected with
 .B +units
 or
 .B \-ld
-list of datums that can be selected with 
+list of datums that can be selected with
 .B +datum.
 .TP
 .BI \-r
@@ -214,7 +219,7 @@ The
 .B +args
 run-line arguments are associated with cartographic parameters
 and usage varies with projection and for a complete description see
-.I "Cartographic Projection Procedures for the UNIX Environment\(emA User's Manual" )
+.I "Cartographic Projection Procedures for the UNIX Environment\(emA User's Manual"
 and supplementary documentation for Release 4.
 .PP
 Additional projection control parameters may be contained in two
@@ -278,7 +283,7 @@ projection coordinates within one datum.
 The \fIcs2cs\fR program operates
 similarly, but allows translation between any pair of definable coordinate
 systems, including support for datum translation.
-.PP 
+.PP
 The \fIgeod\fR program provides the ability to compute geodesic (Great
 Circle) computations.
 .SH SEE ALSO
@@ -296,5 +301,8 @@ USGS Bulletin 1532).
 .br
 .I "An Album of Map Projections"
 (Snyder & Voxland, 1989, USGS Prof. Paper 1453).
+.SH BUGS
+A list of known bugs can found at https://github.com/OSGeo/proj.4/issues
+where new bug reports can be submitted too.
 .SH HOME PAGE
-http://www.remotesensing.org/proj
+http://proj4.org/
diff --git a/man/man3/Makefile.in b/man/man3/Makefile.in
index 24007b0..b784aa3 100644
--- a/man/man3/Makefile.in
+++ b/man/man3/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -78,16 +88,15 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = man/man3
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/mkinstalldirs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/proj_config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
@@ -142,6 +151,7 @@ am__installdirs = "$(DESTDIR)$(man3dir)"
 NROFF = nroff
 MANS = $(man_MANS)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -184,7 +194,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -267,7 +277,7 @@ EXTRA_DIST = $(man_MANS)
 all: all-am
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -279,7 +289,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/man3/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu man/man3/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -292,9 +301,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
@@ -503,6 +512,8 @@ uninstall-man: uninstall-man3
 	ps ps-am tags-am uninstall uninstall-am uninstall-man \
 	uninstall-man3
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/man/man3/geodesic.3 b/man/man3/geodesic.3
index bf0d764..085df83 100644
--- a/man/man3/geodesic.3
+++ b/man/man3/geodesic.3
@@ -1,23 +1,38 @@
 .\" @(#)geodesic.3
 .nr LL 7.0i
-.TH GEODESIC 3 "2014/12/17 Rel. 4.9.0" 
+.TH GEODESIC 3 "2016/02/16 Rel. 4.9.3"
 .ad b
 .hy 1
 .SH NAME
 .B geod_init
 \- initialize an ellipsoid
 .br
-.B geod_lineinit
+.B geod_direct geod_gendirect
+\- the direct geodesic problem
+.br
+.B geod_inverse geod_geninverse
+\- the inverse geodesic problem
+.br
+.B geod_lineinit geod_directline geod_gendirectline geod_inverseline
 \- initialize a geodesic line
 .br
-.B geod_position
+.B geod_setdistance geod_gensetdistance
+\- set distance to reference point
+.br
+.B geod_position geod_genposition
 \- a position on a geodesic line
 .br
-.B geod_direct
-\- the direct geodesic problem
+.B geod_polygon_init
+\- initialize a polygon
 .br
-.B geod_inverse
-\- the inverse geodesic problem
+.B geod_addpoint geod_addedge
+\- add to a polygon
+.br
+.B geod_polygon_compute geod_polygon_testpoint geod_polygon_testedge
+\- compute properties of polygon
+.br
+.B geod_polygon_clear
+\- clear polygon
 .br
 .B geod_polygonarea
 \- the area of a polygon
@@ -38,7 +53,7 @@ measure angles (latitudes, longitudes, and azimuths) in degrees, unlike
 the rest of the \fBproj\fR library, which uses radians.  The
 documentation for this library is included in geodesic.h.  A formatted
 version of the documentation is available at
-http://geographiclib.sf.net/1.44/C
+http://geographiclib.sf.net/1.46/C
 .SH EXAMPLE
 The following program reads in lines with the coordinates for two points
 in decimal degrees (\fIlat1\fR, \fIlon1\fR, \fIlat2\fR, \fIlon2\fR) and
@@ -57,7 +72,7 @@ int main() {
   struct geod_geodesic g;
 
   geod_init(&g, a, f);
-  while (scanf("%lf %lf %lf %lf\en",
+  while (scanf("%lf %lf %lf %lf",
                &lat1, &lon1, &lat2, &lon2) == 4) {
     geod_inverse(&g, lat1, lon1, lat2, lon2,
                  &s12, &azi1, &azi2);
@@ -72,7 +87,7 @@ libproj.a \- library of projections and support procedures
 .SH SEE ALSO
 Full online documentation for \fBgeodesic(3)\fR,
 .br
-http://geographiclib.sf.net/1.44/C
+http://geographiclib.sf.net/1.46/C
 .PP
 .B geod(1)
 .PP
@@ -90,8 +105,15 @@ DOI: http://dx.doi.org/10.1007/s00190-012-0578-z
 .br
 http://geographiclib.sf.net/geod-addenda.html
 .PP
-The \fIonline geodesic bibliography\fR,
+\fIA geodesic bibliography\fR,
 .br
 http://geographiclib.sf.net/geodesic-papers/biblio.html
+.PP
+The Wikipedia page, \fIGeodesics on an ellipsoid\fR,
+.br
+https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid
+.SH BUGS
+A list of known bugs can found at https://github.com/OSGeo/proj.4/issues
+where new bug reports can be submitted too.
 .SH HOME PAGE
-https://github.com/OSGeo/proj.4/wiki
+http://proj4.org/
diff --git a/man/man3/pj_init.3 b/man/man3/pj_init.3
index 3c2951d..4c989ce 100644
--- a/man/man3/pj_init.3
+++ b/man/man3/pj_init.3
@@ -103,10 +103,12 @@ main(int argc, char **argv) {
 .SH LIBRARY
 libproj.a \- library of projections and support procedures
 .SH SEE ALSO
-.B http://proj.osgeo.org/ProjAPI, proj(1),
+.B https://github.com/OSGeo/proj.4/wiki/ProjAPI, proj(1),
 .br
 .I "Cartographic Projection Procedures for the UNIX Environment\(emA User's Manual,"
 (Evenden, 1990, Open-file report 90\-284).
+.SH BUGS
+A list of known bugs can found at https://github.com/OSGeo/proj.4/issues
+where new bug reports can be submitted too.
 .SH HOME PAGE
-http://proj.osgeo.org
-
+http://proj4.org/
diff --git a/missing b/missing
index 6a37006..f62bbae 100755
--- a/missing
+++ b/missing
@@ -1,7 +1,10 @@
 #! /bin/sh
-# Common stub for a few missing GNU programs while installing.
-# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
+# Common wrapper for a few potentially missing GNU programs.
+
+scriptversion=2013-10-28.13; # UTC
+
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Originally written by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
 
 # 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
@@ -14,9 +17,7 @@
 # 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., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, 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
@@ -24,313 +25,191 @@
 # 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
 
-run=:
-
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
-  configure_ac=configure.ac
-else
-  configure_ac=configure.in
-fi
+case $1 in
 
-case "$1" in
---run)
-  # Try to run requested program, and just exit if it succeeds.
-  run=
-  shift
-  "$@" && exit 0
-  ;;
-esac
+  --is-lightweight)
+    # Used by our autoconf macros to check whether the available missing
+    # script is modern enough.
+    exit 0
+    ;;
 
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case "$1" in
+  --run)
+    # Back-compat with the calling convention used by older automake.
+    shift
+    ;;
 
   -h|--h|--he|--hel|--help)
     echo "\
 $0 [OPTION]... PROGRAM [ARGUMENT]...
 
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
+Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
+to PROGRAM being missing or too old.
 
 Options:
   -h, --help      display this help and exit
   -v, --version   output version information and exit
-  --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'
-  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
-  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]"
+  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
+  bison     yacc      flex         lex       help2man
+
+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 $?
     ;;
 
   -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
-    echo "missing 0.4 - GNU automake"
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
     ;;
 
   -*)
-    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
     ;;
 
-  aclocal*)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  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)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  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)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  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"
-    touch_files=
-    for f in $files; do
-      case "$f" in
-      *:*) touch_files="$touch_files "`echo "$f" |
-				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
-      *) touch_files="$touch_files $f.in";;
-      esac
-    done
-    touch $touch_files
-    ;;
-
-  automake*)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  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/' |
-	   while read f; do touch "$f"; done
-    ;;
-
-  autom4te)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is needed, and you do not seem to have it handy on your
-         system.  You might have modified some files without having the
-         proper tools for further handling them.
-         You can get \`$1Help2man' as part of \`Autoconf' from any GNU
-         archive site."
-
-    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
-    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
-    if test -f "$file"; then
-	touch $file
-    else
-	test -z "$file" || exec >$file
-	echo "#! /bin/sh"
-	echo "# Created by GNU Automake missing as a replacement of"
-	echo "#  $ $@"
-	echo "exit 0"
-	chmod +x $file
-	exit 1
-    fi
-    ;;
-
-  bison|yacc)
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  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."
-    rm -f y.tab.c y.tab.h
-    if [ $# -ne 1 ]; then
-        eval LASTARG="\${$#}"
-	case "$LASTARG" in
-	*.y)
-	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
-	    if [ -f "$SRCFILE" ]; then
-	         cp "$SRCFILE" y.tab.c
-	    fi
-	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
-	    if [ -f "$SRCFILE" ]; then
-	         cp "$SRCFILE" y.tab.h
-	    fi
-	  ;;
-	esac
-    fi
-    if [ ! -f y.tab.h ]; then
-	echo >y.tab.h
-    fi
-    if [ ! -f y.tab.c ]; then
-	echo 'main() { return 0; }' >y.tab.c
-    fi
-    ;;
-
-  lex|flex)
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  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."
-    rm -f lex.yy.c
-    if [ $# -ne 1 ]; then
-        eval LASTARG="\${$#}"
-	case "$LASTARG" in
-	*.l)
-	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
-	    if [ -f "$SRCFILE" ]; then
-	         cp "$SRCFILE" lex.yy.c
-	    fi
-	  ;;
-	esac
-    fi
-    if [ ! -f lex.yy.c ]; then
-	echo 'main() { return 0; }' >lex.yy.c
-    fi
-    ;;
-
-  help2man)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  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."
-
-    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
-    if test -z "$file"; then
-	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
-    fi
-    if [ -f "$file" ]; then
-	touch $file
-    else
-	test -z "$file" || exec >$file
-	echo ".ab help2man is required to generate this page"
-	exit 1
-    fi
-    ;;
-
-  makeinfo)
-    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
-       # We have makeinfo, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  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."
-    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
-    if test -z "$file"; then
-      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
-      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
-    fi
-    touch $file
-    ;;
-
-  tar)
-    shift
-    if test -n "$run"; then
-      echo 1>&2 "ERROR: \`tar' requires --run"
-      exit 1
-    fi
-
-    # 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
+esac
 
-    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
-    ;;
+# Run the given program, remember its exit status.
+"$@"; st=$?
+
+# If it succeeded, we are done.
+test $st -eq 0 && exit 0
+
+# Also exit now if we it failed (or wasn't found), and '--version' was
+# passed; such an option is passed most likely to detect whether the
+# program is present and works.
+case $2 in --version|--help) exit $st;; esac
+
+# Exit code 63 means version mismatch.  This often happens when the user
+# tries to use an ancient version of a tool on a file that requires a
+# minimum version.
+if test $st -eq 63; then
+  msg="probably too old"
+elif test $st -eq 127; then
+  # Program was missing.
+  msg="missing on your system"
+else
+  # Program was found and executed, but failed.  Give up.
+  exit $st
+fi
 
-  *)
-    echo 1>&2 "\
-WARNING: \`$1' is needed, and you do not seem to have it handy on your
-         system.  You might have modified some files without having the
-         proper tools for further handling them.  Check the \`README' file,
-         it often tells you about the needed prerequirements for installing
-         this package.  You may also peek at any GNU archive site, in case
-         some other package would contain this missing \`$1' program."
-    exit 1
+perl_URL=http://www.perl.org/
+flex_URL=http://flex.sourceforge.net/
+gnu_software_URL=http://www.gnu.org/software
+
+program_details ()
+{
+  case $1 in
+    aclocal|automake)
+      echo "The '$1' program is part of the GNU Automake package:"
+      echo "<$gnu_software_URL/automake>"
+      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
+      echo "<$gnu_software_URL/autoconf>"
+      echo "<$gnu_software_URL/m4/>"
+      echo "<$perl_URL>"
+      ;;
+    autoconf|autom4te|autoheader)
+      echo "The '$1' program is part of the GNU Autoconf package:"
+      echo "<$gnu_software_URL/autoconf/>"
+      echo "It also requires GNU m4 and Perl in order to run:"
+      echo "<$gnu_software_URL/m4/>"
+      echo "<$perl_URL>"
+      ;;
+  esac
+}
+
+give_advice ()
+{
+  # Normalize program name to check for.
+  normalized_program=`echo "$1" | sed '
+    s/^gnu-//; t
+    s/^gnu//; t
+    s/^g//; t'`
+
+  printf '%s\n' "'$1' is $msg."
+
+  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
+  case $normalized_program in
+    autoconf*)
+      echo "You should only need it if you modified 'configure.ac',"
+      echo "or m4 files included by it."
+      program_details 'autoconf'
+      ;;
+    autoheader*)
+      echo "You should only need it if you modified 'acconfig.h' or"
+      echo "$configure_deps."
+      program_details 'autoheader'
+      ;;
+    automake*)
+      echo "You should only need it if you modified 'Makefile.am' or"
+      echo "$configure_deps."
+      program_details 'automake'
+      ;;
+    aclocal*)
+      echo "You should only need it if you modified 'acinclude.m4' or"
+      echo "$configure_deps."
+      program_details 'aclocal'
+      ;;
+   autom4te*)
+      echo "You might have modified some maintainer files that require"
+      echo "the 'autom4te' program to be rebuilt."
+      program_details 'autom4te'
+      ;;
+    bison*|yacc*)
+      echo "You should only need it if you modified a '.y' file."
+      echo "You may want to install the GNU Bison package:"
+      echo "<$gnu_software_URL/bison/>"
+      ;;
+    lex*|flex*)
+      echo "You should only need it if you modified a '.l' file."
+      echo "You may want to install the Fast Lexical Analyzer package:"
+      echo "<$flex_URL>"
+      ;;
+    help2man*)
+      echo "You should only need it if you modified a dependency" \
+           "of a man page."
+      echo "You may want to install the GNU Help2man package:"
+      echo "<$gnu_software_URL/help2man/>"
     ;;
-esac
-
-exit 0
+    makeinfo*)
+      echo "You should only need it if you modified a '.texi' file, or"
+      echo "any other file indirectly affecting the aspect of the manual."
+      echo "You might want to install the Texinfo package:"
+      echo "<$gnu_software_URL/texinfo/>"
+      echo "The spurious makeinfo call might also be the consequence of"
+      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
+      echo "want to install GNU make:"
+      echo "<$gnu_software_URL/make/>"
+      ;;
+    *)
+      echo "You might have modified some files without having the proper"
+      echo "tools for further handling them.  Check the 'README' file, it"
+      echo "often tells you about the needed prerequisites for installing"
+      echo "this package.  You may also peek at any GNU archive site, in"
+      echo "case some other package contains this missing '$1' program."
+      ;;
+  esac
+}
+
+give_advice "$1" | sed -e '1s/^/WARNING: /' \
+                       -e '2,$s/^/         /' >&2
+
+# Propagate the correct exit status (expected to be 127 for a program
+# not found, 63 for a program that failed due to version mismatch).
+exit $st
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/mkinstalldirs b/mkinstalldirs
deleted file mode 100755
index 5e17cd3..0000000
--- a/mkinstalldirs
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /bin/sh
-# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman at prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain
-
-errstatus=0
-
-for file
-do
-   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
-   shift
-
-   pathcomp=
-   for d
-   do
-     pathcomp="$pathcomp$d"
-     case "$pathcomp" in
-       -* ) pathcomp=./$pathcomp ;;
-     esac
-
-     if test ! -d "$pathcomp"; then
-        echo "mkdir $pathcomp"
-
-        mkdir "$pathcomp" || lasterr=$?
-
-        if test ! -d "$pathcomp"; then
-  	  errstatus=$lasterr
-        fi
-     fi
-
-     pathcomp="$pathcomp/"
-   done
-done
-
-exit $errstatus
-
-# mkinstalldirs ends here
diff --git a/nad/Makefile.in b/nad/Makefile.in
index 6a412df..6c27a83 100644
--- a/nad/Makefile.in
+++ b/nad/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,17 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -79,18 +89,17 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = nad
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/mkinstalldirs README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/proj_config.h
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = install
 CONFIG_CLEAN_VPATH_FILES =
 AM_V_P = $(am__v_P_ at AM_V@)
 am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
@@ -141,6 +150,7 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(pkgdatadir)"
 DATA = $(pkgdata_DATA)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/install.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -183,7 +193,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -290,7 +300,7 @@ EXTRA_DIST = GL27 nad.lst proj_def.dat nad27 nad83 pj_out27.dist pj_out83.dist t
 all: all-am
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -302,7 +312,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu nad/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu nad/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -315,11 +324,13 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+install: $(top_builddir)/config.status $(srcdir)/install.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -503,6 +514,8 @@ uninstall-am: uninstall-pkgdataDATA
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am uninstall-pkgdataDATA
 
+.PRECIOUS: Makefile
+
 
 process-nad2bin:
 	@if [ -f $(NADPATH)/null.lla -a ! -f null ] || [ -f $(NADPATH)/conus.lla -a ! -f conus ] ; then \
diff --git a/nad/epsg b/nad/epsg
index 9202499..3d8ee13 100644
--- a/nad/epsg
+++ b/nad/epsg
@@ -117,11 +117,11 @@
 # LKS94 (ETRS89)
 <4126> +proj=longlat +ellps=GRS80 +no_defs  <>
 # Tete
-<4127> +proj=longlat +ellps=clrk66 +towgs84=-73.472,-51.66,-112.482,0.953,4.6,-2.368,0.586 +no_defs  <>
+<4127> +proj=longlat +ellps=clrk66 +towgs84=-80,-100,-228,0,0,0,0 +no_defs  <>
 # Madzansua
 <4128> +proj=longlat +ellps=clrk66 +no_defs  <>
 # Observatario
-<4129> +proj=longlat +ellps=clrk66 +no_defs  <>
+<4129> +proj=longlat +ellps=clrk66 +towgs84=-132,-110,-335,0,0,0,0 +no_defs  <>
 # Moznet
 <4130> +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
 # Indian 1960
@@ -144,7 +144,7 @@
 <4139> +proj=longlat +ellps=clrk66 +towgs84=11,72,-101,0,0,0,0 +no_defs  <>
 # NAD83(CSRS98)
 <4140> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
-# Israel
+# Israel 1993
 <4141> +proj=longlat +ellps=GRS80 +towgs84=-48,55,52,0,0,0,0 +no_defs  <>
 # Locodjo 1965
 <4142> +proj=longlat +ellps=clrk80 +towgs84=-125,53,467,0,0,0,0 +no_defs  <>
@@ -239,7 +239,7 @@
 # POSGAR 98
 <4190> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
 # Albanian 1987
-<4191> +proj=longlat +ellps=krass +no_defs  <>
+<4191> +proj=longlat +ellps=krass +towgs84=-44.183,-0.58,-38.489,-2.3867,-2.7072,3.5196,-8.2703 +no_defs  <>
 # Douala 1948
 <4192> +proj=longlat +ellps=intl +towgs84=-206.1,-174.7,-87.7,0,0,0,0 +no_defs  <>
 # Manoca 1962
@@ -317,9 +317,9 @@
 # ED50
 <4230> +proj=longlat +ellps=intl +towgs84=-87,-98,-121,0,0,0,0 +no_defs  <>
 # ED87
-<4231> +proj=longlat +ellps=intl +towgs84=-83.11,-97.38,-117.22,0.00569290865241986,-0.0446975835137458,0.0442850539012516,0.1218 +no_defs  <>
+<4231> +proj=longlat +ellps=intl +towgs84=-83.11,-97.38,-117.22,0.005693,-0.044698,0.044285,0.1218 +no_defs  <>
 # Fahud
-<4232> +proj=longlat +ellps=clrk80 +towgs84=-346,-1,224,0,0,0,0 +no_defs  <>
+<4232> +proj=longlat +ellps=clrk80 +towgs84=-333.102,-11.02,230.69,0,0,0.554,0.219 +no_defs  <>
 # Gandajika 1970
 <4233> +proj=longlat +ellps=intl +towgs84=-133,-321,50,0,0,0,0 +no_defs  <>
 # Garoua
@@ -395,7 +395,7 @@
 # NAD83
 <4269> +proj=longlat +datum=NAD83 +no_defs  <>
 # Nahrwan 1967
-<4270> +proj=longlat +ellps=clrk80 +towgs84=-242.2,-144.9,370.3,0,0,0,0 +no_defs  <>
+<4270> +proj=longlat +ellps=clrk80 +towgs84=-249,-156,381,0,0,0,0 +no_defs  <>
 # Naparima 1972
 <4271> +proj=longlat +ellps=intl +towgs84=-10,375,165,0,0,0,0 +no_defs  <>
 # NZGD49
@@ -433,7 +433,7 @@
 # Loma Quintana
 <4288> +proj=longlat +ellps=intl +no_defs  <>
 # Amersfoort
-<4289> +proj=longlat +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957388243134,0.343987817378283,-1.87740163998045,4.0725 +no_defs  <>
+<4289> +proj=longlat +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957,0.343988,-1.87740,4.0725 +no_defs  <>
 # SAD69
 <4291> +proj=longlat +ellps=GRS67 +towgs84=-57,1,-41,0,0,0,0 +no_defs  <>
 # Sapper Hill 1943
@@ -471,7 +471,7 @@
 # Yacare
 <4309> +proj=longlat +ellps=intl +towgs84=-155,171,37,0,0,0,0 +no_defs  <>
 # Yoff
-<4310> +proj=longlat +a=6378249.2 +b=6356515 +no_defs  <>
+<4310> +proj=longlat +a=6378249.2 +b=6356515 +towgs84=-30,190,89,0,0,0,0 +no_defs  <>
 # Zanderij
 <4311> +proj=longlat +ellps=intl +towgs84=-265,120,-358,0,0,0,0 +no_defs  <>
 # MGI
@@ -607,11 +607,11 @@
 # Reykjavik 1900
 <4657> +proj=longlat +a=6377019.27 +b=6355762.5391 +towgs84=-28,199,5,0,0,0,0 +no_defs  <>
 # Hjorsey 1955
-<4658> +proj=longlat +ellps=intl +towgs84=-73,46,-86,0,0,0,0 +no_defs  <>
+<4658> +proj=longlat +ellps=intl +towgs84=-73,47,-83,0,0,0,0 +no_defs  <>
 # ISN93
 <4659> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
 # Helle 1954
-<4660> +proj=longlat +ellps=intl +towgs84=982.6087,552.753,-540.873,6.68162662527694,-31.6114924086422,-19.8481610048168,16.805 +no_defs  <>
+<4660> +proj=longlat +ellps=intl +towgs84=982.6087,552.753,-540.873,6.6816266,-31.6114924,-19.84816,16.805 +no_defs  <>
 # LKS92
 <4661> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
 # IGN72 Grande Terre
@@ -717,7 +717,7 @@
 # Ascension Island 1958
 <4712> +proj=longlat +ellps=intl +towgs84=-205,107,53,0,0,0,0 +no_defs  <>
 # Ayabelle Lighthouse
-<4713> +proj=longlat +ellps=clrk80 +towgs84=-79,-129,145,0,0,0,0 +no_defs  <>
+<4713> +proj=longlat +ellps=clrk80 +towgs84=-77,-128,142,0,0,0,0 +no_defs  <>
 # Bellevue
 <4714> +proj=longlat +ellps=intl +towgs84=-127,-769,472,0,0,0,0 +no_defs  <>
 # Camp Area Astro
@@ -779,7 +779,7 @@
 # Karbala 1979
 <4743> +proj=longlat +ellps=clrk80 +towgs84=70.995,-335.916,262.898,0,0,0,0 +no_defs  <>
 # Nahrwan 1934
-<4744> +proj=longlat +ellps=clrk80 +no_defs  <>
+<4744> +proj=longlat +ellps=clrk80 +towgs84=-242.2,-144.9,370.3,0,0,0,0 +no_defs  <>
 # RD/83
 <4745> +proj=longlat +ellps=bessel +no_defs  <>
 # PD/83
@@ -795,7 +795,7 @@
 # Kertau (RSO)
 <4751> +proj=longlat +a=6377295.664 +b=6356094.667915204 +no_defs  <>
 # Viti Levu 1912
-<4752> +proj=longlat +a=6378306.3696 +b=6356571.996 +towgs84=51,391,-36,0,0,0,0 +no_defs  <>
+<4752> +proj=longlat +a=6378306.3696 +b=6356571.996 +towgs84=98,390,-22,0,0,0,0 +no_defs  <>
 # fk89
 <4753> +proj=longlat +ellps=intl +no_defs  <>
 # LGD2006
@@ -803,7 +803,7 @@
 # DGN95
 <4755> +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
 # VN-2000
-<4756> +proj=longlat +ellps=WGS84 +towgs84=-192.873,-39.382,-111.202,-0.00205,-0.0005,0.00335,0.0188 +no_defs  <>
+<4756> +proj=longlat +ellps=WGS84 +towgs84=-191.90441429,-39.30318279,-111.45032835,0.00928836,-0.01975479,0.00427372,0.252906278 +no_defs  <>
 # SVY21
 <4757> +proj=longlat +ellps=WGS84 +no_defs  <>
 # JAD2001
@@ -934,6 +934,8 @@
 <6135> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
 # Nepal 1981
 <6207> +proj=longlat +a=6377276.345 +b=6356075.41314024 +towgs84=293.17,726.18,245.36,0,0,0,0 +no_defs  <>
+# CGRS93
+<6311> +proj=longlat +ellps=WGS84 +towgs84=8.846,-4.394,-1.122,0.00237,0.146528,-0.130428,0.783926 +no_defs  <>
 # NAD83(2011)
 <6318> +proj=longlat +ellps=GRS80 +no_defs  <>
 # NAD83(PA11)
@@ -948,6 +950,48 @@
 <6706> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
 # NAD83(CORS96)
 <6783> +proj=longlat +ellps=GRS80 +no_defs  <>
+# Aden 1925
+<6881> +proj=longlat +ellps=clrk80 +towgs84=-24,-203,268,0,0,0,0 +no_defs  <>
+# Bekaa Valley 1920
+<6882> +proj=longlat +ellps=clrk80 +towgs84=-183,-15,273,0,0,0,0 +no_defs  <>
+# Bioko
+<6883> +proj=longlat +ellps=intl +towgs84=-235,-110,393,0,0,0,0 +no_defs  <>
+# South East Island 1943
+<6892> +proj=longlat +ellps=clrk80 +towgs84=-43.685,-179.785,-267.721,0,0,0,0 +no_defs  <>
+# Gambia
+<6894> +proj=longlat +ellps=clrk80 +towgs84=-63,176,185,0,0,0,0 +no_defs  <>
+# IGD05
+<6980> +proj=longlat +ellps=GRS80 +no_defs  <>
+# IG05 Intermediate CRS
+<6983> +proj=longlat +ellps=GRS80 +no_defs  <>
+# IGD05/12
+<6987> +proj=longlat +ellps=GRS80 +no_defs  <>
+# IG05/12 Intermediate CRS
+<6990> +proj=longlat +ellps=GRS80 +no_defs  <>
+# RGSPM06 (lon-lat)
+<7035> +proj=longlat +ellps=GRS80 +no_defs  <>
+# RGR92 (lon-lat)
+<7037> +proj=longlat +ellps=GRS80 +no_defs  <>
+# RGM04 (lon-lat)
+<7039> +proj=longlat +ellps=GRS80 +no_defs  <>
+# RGFG95 (lon-lat)
+<7041> +proj=longlat +ellps=GRS80 +no_defs  <>
+# RGTAAF07
+<7073> +proj=longlat +ellps=GRS80 +no_defs  <>
+# RGF93 (lon-lat)
+<7084> +proj=longlat +ellps=GRS80 +no_defs  <>
+# RGAF09 (lon-lat)
+<7086> +proj=longlat +ellps=GRS80 +no_defs  <>
+# RGTAAF07 (lon-lat)
+<7088> +proj=longlat +ellps=GRS80 +no_defs  <>
+# RGTAAF07 (lon-lat)
+<7133> +proj=longlat +ellps=GRS80 +no_defs  <>
+# IGD05
+<7136> +proj=longlat +ellps=WGS84 +no_defs  <>
+# IGD05/12
+<7139> +proj=longlat +ellps=WGS84 +no_defs  <>
+# ONGD14
+<7373> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
 # Anguilla 1957 / British West Indies Grid
 <2000> +proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +units=m +no_defs  <>
 # Antigua 1943 / British West Indies Grid
@@ -1026,7 +1070,7 @@
 <2037> +proj=utm +zone=19 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
 # NAD83(CSRS98) / UTM zone 20N (deprecated)
 <2038> +proj=utm +zone=20 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
-# Israel / Israeli TM Grid
+# Israel 1993 / Israeli TM Grid
 <2039> +proj=tmerc +lat_0=31.73439361111111 +lon_0=35.20451694444445 +k=1.0000067 +x_0=219529.584 +y_0=626907.39 +ellps=GRS80 +towgs84=-48,55,52,0,0,0,0 +units=m +no_defs  <>
 # Locodjo 1965 / UTM zone 30N
 <2040> +proj=utm +zone=30 +ellps=clrk80 +towgs84=-125,53,467,0,0,0,0 +units=m +no_defs  <>
@@ -1333,7 +1377,7 @@
 # ETRS89 / Kp2000 Bornholm
 <2198> +proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=900000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
 # Albanian 1987 / Gauss Kruger zone 4 (deprecated)
-<2199> +proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +units=m +no_defs  <>
+<2199> +proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +towgs84=-44.183,-0.58,-38.489,-2.3867,-2.7072,3.5196,-8.2703 +units=m +no_defs  <>
 # ATS77 / New Brunswick Stereographic (ATS77)
 <2200> +proj=sterea +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +x_0=300000 +y_0=800000 +a=6378135 +b=6356750.304921594 +units=m +no_defs  <>
 # REGVEN / UTM zone 18N
@@ -1871,7 +1915,7 @@
 # JGD2000 / Japan Plane Rectangular CS XIX
 <2461> +proj=tmerc +lat_0=26 +lon_0=154 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
 # Albanian 1987 / Gauss-Kruger zone 4
-<2462> +proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +units=m +no_defs  <>
+<2462> +proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +towgs84=-44.183,-0.58,-38.489,-2.3867,-2.7072,3.5196,-8.2703 +units=m +no_defs  <>
 # Pulkovo 1995 / Gauss-Kruger CM 21E
 <2463> +proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=500000 +y_0=0 +ellps=krass +towgs84=24.47,-130.89,-81.56,0,0,0.13,-0.22 +units=m +no_defs  <>
 # Pulkovo 1995 / Gauss-Kruger CM 27E
@@ -2419,9 +2463,9 @@
 # Pulkovo 1995 / 3-degree Gauss-Kruger CM 129E
 <2735> +proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=krass +towgs84=24.47,-130.89,-81.56,0,0,0.13,-0.22 +units=m +no_defs  <>
 # Tete / UTM zone 36S
-<2736> +proj=utm +zone=36 +south +ellps=clrk66 +towgs84=-73.472,-51.66,-112.482,0.953,4.6,-2.368,0.586 +units=m +no_defs  <>
+<2736> +proj=utm +zone=36 +south +ellps=clrk66 +towgs84=-80,-100,-228,0,0,0,0 +units=m +no_defs  <>
 # Tete / UTM zone 37S
-<2737> +proj=utm +zone=37 +south +ellps=clrk66 +towgs84=-73.472,-51.66,-112.482,0.953,4.6,-2.368,0.586 +units=m +no_defs  <>
+<2737> +proj=utm +zone=37 +south +ellps=clrk66 +towgs84=-80,-100,-228,0,0,0,0 +units=m +no_defs  <>
 # Pulkovo 1995 / 3-degree Gauss-Kruger CM 132E
 <2738> +proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=500000 +y_0=0 +ellps=krass +towgs84=24.47,-130.89,-81.56,0,0,0.13,-0.22 +units=m +no_defs  <>
 # Pulkovo 1995 / 3-degree Gauss-Kruger CM 135E
@@ -3058,15 +3102,15 @@
 # Unable to translate coordinate system EPSG:3053 into PROJ.4 format.
 #
 # Hjorsey 1955 / UTM zone 26N
-<3054> +proj=utm +zone=26 +ellps=intl +towgs84=-73,46,-86,0,0,0,0 +units=m +no_defs  <>
+<3054> +proj=utm +zone=26 +ellps=intl +towgs84=-73,47,-83,0,0,0,0 +units=m +no_defs  <>
 # Hjorsey 1955 / UTM zone 27N
-<3055> +proj=utm +zone=27 +ellps=intl +towgs84=-73,46,-86,0,0,0,0 +units=m +no_defs  <>
+<3055> +proj=utm +zone=27 +ellps=intl +towgs84=-73,47,-83,0,0,0,0 +units=m +no_defs  <>
 # Hjorsey 1955 / UTM zone 28N
-<3056> +proj=utm +zone=28 +ellps=intl +towgs84=-73,46,-86,0,0,0,0 +units=m +no_defs  <>
+<3056> +proj=utm +zone=28 +ellps=intl +towgs84=-73,47,-83,0,0,0,0 +units=m +no_defs  <>
 # ISN93 / Lambert 1993
 <3057> +proj=lcc +lat_1=64.25 +lat_2=65.75 +lat_0=65 +lon_0=-19 +x_0=500000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
 # Helle 1954 / Jan Mayen Grid
-<3058> +proj=tmerc +lat_0=0 +lon_0=-8.5 +k=1 +x_0=50000 +y_0=-7800000 +ellps=intl +towgs84=982.6087,552.753,-540.873,6.68162662527694,-31.6114924086422,-19.8481610048168,16.805 +units=m +no_defs  <>
+<3058> +proj=tmerc +lat_0=0 +lon_0=-8.5 +k=1 +x_0=50000 +y_0=-7800000 +ellps=intl +towgs84=982.6087,552.753,-540.873,6.6816266,-31.6114924,-19.84816,16.805 +units=m +no_defs  <>
 # LKS92 / Latvia TM
 <3059> +proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996 +x_0=500000 +y_0=-6000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
 # IGN72 Grande Terre / UTM zone 58S
@@ -3231,7 +3275,7 @@
 # Unable to translate coordinate system EPSG:3139 into PROJ.4 format.
 #
 # Viti Levu 1912 / Viti Levu Grid
-<3140> +proj=cass +lat_0=-18 +lon_0=178 +x_0=109435.392 +y_0=141622.272 +a=6378306.3696 +b=6356571.996 +towgs84=51,391,-36,0,0,0,0 +to_meter=0.201168 +no_defs  <>
+<3140> +proj=cass +lat_0=-18 +lon_0=178 +x_0=109435.392 +y_0=141622.272 +a=6378306.3696 +b=6356571.996 +towgs84=98,390,-22,0,0,0,0 +to_meter=0.201168 +no_defs  <>
 # Fiji 1956 / UTM zone 60S
 <3141> +proj=utm +zone=60 +south +ellps=intl +towgs84=265.025,384.929,-194.046,0,0,0,0 +units=m +no_defs  <>
 # Fiji 1956 / UTM zone 1S
@@ -3712,7 +3756,7 @@
 <3377> +proj=cass +lat_0=2.121679744444445 +lon_0=103.4279362361111 +x_0=-14810.562 +y_0=8758.32 +ellps=GRS80 +units=m +no_defs  <>
 # GDM2000 / Sembilan and Melaka Grid
 <3378> +proj=cass +lat_0=2.682347636111111 +lon_0=101.9749050416667 +x_0=3673.785 +y_0=-4240.573 +ellps=GRS80 +units=m +no_defs  <>
-# GDM2000 / PahangGrid
+# GDM2000 / Pahang Grid
 <3379> +proj=cass +lat_0=3.769388088888889 +lon_0=102.3682989833333 +x_0=-7368.228 +y_0=6485.858 +ellps=GRS80 +units=m +no_defs  <>
 # GDM2000 / Selangor Grid
 <3380> +proj=cass +lat_0=3.68464905 +lon_0=101.3891079138889 +x_0=-34836.161 +y_0=56464.049 +ellps=GRS80 +units=m +no_defs  <>
@@ -3743,7 +3787,7 @@
 # Karbala 1979 / UTM zone 39N
 <3393> +proj=utm +zone=39 +ellps=clrk80 +towgs84=70.995,-335.916,262.898,0,0,0,0 +units=m +no_defs  <>
 # Nahrwan 1934 / Iraq zone
-<3394> +proj=lcc +lat_1=32.5 +lat_0=32.5 +lon_0=45 +k_0=0.9987864078000001 +x_0=1500000 +y_0=1166200 +ellps=clrk80 +units=m +no_defs  <>
+<3394> +proj=lcc +lat_1=32.5 +lat_0=32.5 +lon_0=45 +k_0=0.9987864078000001 +x_0=1500000 +y_0=1166200 +ellps=clrk80 +towgs84=-242.2,-144.9,370.3,0,0,0,0 +units=m +no_defs  <>
 # WGS 84 / World Mercator
 <3395> +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs  <>
 # PD/83 / 3-degree Gauss-Kruger zone 3
@@ -3765,9 +3809,9 @@
 # NAD83(HARN) / North Carolina (ftUS)
 <3404> +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.2192024384 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs  <>
 # VN-2000 / UTM zone 48N
-<3405> +proj=utm +zone=48 +ellps=WGS84 +towgs84=-192.873,-39.382,-111.202,-0.00205,-0.0005,0.00335,0.0188 +units=m +no_defs  <>
+<3405> +proj=utm +zone=48 +ellps=WGS84 +towgs84=-191.90441429,-39.30318279,-111.45032835,0.00928836,-0.01975479,0.00427372,0.252906278 +units=m +no_defs  <>
 # VN-2000 / UTM zone 49N
-<3406> +proj=utm +zone=49 +ellps=WGS84 +towgs84=-192.873,-39.382,-111.202,-0.00205,-0.0005,0.00335,0.0188 +units=m +no_defs  <>
+<3406> +proj=utm +zone=49 +ellps=WGS84 +towgs84=-191.90441429,-39.30318279,-111.45032835,0.00928836,-0.01975479,0.00427372,0.252906278 +units=m +no_defs  <>
 # Hong Kong 1963 Grid System
 <3407> +proj=cass +lat_0=22.31213333333334 +lon_0=114.1785555555556 +x_0=40243.57775604237 +y_0=19069.93351512578 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.3047972654 +no_defs  <>
 # NSIDC EASE-Grid North
@@ -4694,11 +4738,11 @@
 <3969> +proj=lcc +lat_1=37 +lat_2=39.5 +lat_0=36 +lon_0=-79.5 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
 # NAD83(NSRS2007) / Virginia Lambert
 <3970> +proj=lcc +lat_1=37 +lat_2=39.5 +lat_0=36 +lon_0=-79.5 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
-# WGS 84 / NSIDC EASE-Grid North
+# WGS 84 / NSIDC EASE-Grid North (deprecated)
 <3973> +proj=laea +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs  <>
-# WGS 84 / NSIDC EASE-Grid South
+# WGS 84 / NSIDC EASE-Grid South (deprecated)
 <3974> +proj=laea +lat_0=-90 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs  <>
-# WGS 84 / NSIDC EASE-Grid Global
+# WGS 84 / NSIDC EASE-Grid Global (deprecated)
 <3975> +proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs  <>
 # WGS 84 / NSIDC Sea Ice Polar Stereographic South
 <3976> +proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs  <>
@@ -4781,6 +4825,24 @@
 <4096> +proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=800000 +y_0=-5000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
 # NAD83 / BLM 59N (ftUS)
 <4217> +proj=tmerc +lat_0=0 +lon_0=171 +k=0.9996 +x_0=500000.001016002 +y_0=0 +datum=NAD83 +units=us-ft +no_defs  <>
+# Kertau 1968 / Johor Grid
+<4390> +proj=cass +lat_0=2.042583333333333 +lon_0=103.5627583333333 +x_0=0 +y_0=0 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m +no_defs  <>
+# Kertau 1968 / Sembilan and Melaka Grid
+<4391> +proj=cass +lat_0=2.712283333333334 +lon_0=101.9411666666667 +x_0=-242.005 +y_0=-948.547 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m +no_defs  <>
+# Kertau 1968 / Pahang Grid
+<4392> +proj=cass +lat_0=3.710972222222222 +lon_0=102.4361777777778 +x_0=0 +y_0=0 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m +no_defs  <>
+# Kertau 1968 / Selangor Grid
+<4393> +proj=cass +lat_0=3.680344444444444 +lon_0=101.5082444444444 +x_0=-21759.438 +y_0=55960.906 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m +no_defs  <>
+# Kertau 1968 / Terengganu Grid
+<4394> +proj=cass +lat_0=4.946141666666667 +lon_0=102.8952083333333 +x_0=0 +y_0=0 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m +no_defs  <>
+# Kertau 1968 / Pinang Grid
+<4395> +proj=cass +lat_0=5.421325 +lon_0=100.3458694444444 +x_0=0 +y_0=0 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m +no_defs  <>
+# Kertau 1968 / Kedah and Perlis Grid
+<4396> +proj=cass +lat_0=5.965147222222223 +lon_0=100.6375944444444 +x_0=0 +y_0=0 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m +no_defs  <>
+# Kertau 1968 / Perak Revised Grid
+<4397> +proj=cass +lat_0=4.859380555555555 +lon_0=100.8167666666667 +x_0=0 +y_0=133453.669 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m +no_defs  <>
+# Kertau 1968 / Kelantan Grid
+<4398> +proj=cass +lat_0=5.893922222222222 +lon_0=102.1772916666667 +x_0=0 +y_0=0 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m +no_defs  <>
 # NAD27 / BLM 59N (ftUS)
 <4399> +proj=tmerc +lat_0=0 +lon_0=171 +k=0.9996 +x_0=500000.001016002 +y_0=0 +datum=NAD27 +units=us-ft +no_defs  <>
 # NAD27 / BLM 60N (ftUS)
@@ -5923,7 +5985,7 @@
 <6129> +proj=utm +zone=17 +ellps=clrk66 +towgs84=8.853,-52.644,180.304,-0.393,-2.323,2.96,-24.081 +units=ft +no_defs  <>
 # Cayman Islands National Grid 2011 (deprecated)
 <6141> +proj=lcc +lat_1=19.33333333333333 +lat_2=19.7 +lat_0=19.33333333333333 +lon_0=80.56666666666666 +x_0=899160 +y_0=579120 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=ft +no_defs  <>
-# NAD27 / Michigan North
+# NAD27 / Michigan North (deprecated)
 # Unable to translate coordinate system EPSG:6200 into PROJ.4 format.
 #
 # NAD27 / Michigan Central
@@ -5932,7 +5994,7 @@
 # NAD27 / Michigan South
 # Unable to translate coordinate system EPSG:6202 into PROJ.4 format.
 #
-# Macedonian State Coordinate System
+# Macedonia State Coordinate System
 <6204> +proj=tmerc +lat_0=0 +lon_0=21 +k=0.9999 +x_0=500000 +y_0=0 +ellps=bessel +towgs84=682,-203,480,0,0,0,0 +units=m +no_defs  <>
 # SIRGAS 2000 / UTM zone 23N
 <6210> +proj=utm +zone=23 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
@@ -6034,6 +6096,10 @@
 # MAGNA-SIRGAS / Yopal urban grid
 # Unable to translate coordinate system EPSG:6275 into PROJ.4 format.
 #
+# NAD83(CORS96) / Puerto Rico and Virgin Is.
+<6307> +proj=lcc +lat_1=18.43333333333333 +lat_2=18.03333333333333 +lat_0=17.83333333333333 +lon_0=-66.43333333333334 +x_0=200000 +y_0=200000 +ellps=GRS80 +units=m +no_defs  <>
+# CGRS93 / Cyprus Local Transverse Mercator
+<6312> +proj=tmerc +lat_0=0 +lon_0=33 +k=0.99995 +x_0=200000 +y_0=-3500000 +ellps=WGS84 +towgs84=8.846,-4.394,-1.122,0.00237,0.146528,-0.130428,0.783926 +units=m +no_defs  <>
 # Macedonia State Coordinate System zone 7
 <6316> +proj=tmerc +lat_0=0 +lon_0=21 +k=0.9999 +x_0=7500000 +y_0=0 +ellps=bessel +towgs84=682,-203,480,0,0,0,0 +units=m +no_defs  <>
 # NAD83(2011) / UTM zone 59N
@@ -6680,13 +6746,13 @@
 <6722> +proj=tmerc +lat_0=0 +lon_0=96.875 +k=1 +x_0=50000 +y_0=1400000 +datum=WGS84 +units=m +no_defs  <>
 # GDA94 / CKIG94
 <6723> +proj=tmerc +lat_0=0 +lon_0=96.875 +k=0.99999387 +x_0=50000 +y_0=1500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
-# GDA94 / MGA zone 41
+# GDA94 / MGA zone 41 (deprecated)
 <6732> +proj=utm +zone=41 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
-# GDA94 / MGA zone 42
+# GDA94 / MGA zone 42 (deprecated)
 <6733> +proj=utm +zone=42 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
-# GDA94 / MGA zone 43
+# GDA94 / MGA zone 43 (deprecated)
 <6734> +proj=utm +zone=43 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
-# GDA94 / MGA zone 44
+# GDA94 / MGA zone 44 (deprecated)
 <6735> +proj=utm +zone=44 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
 # GDA94 / MGA zone 46
 <6736> +proj=utm +zone=46 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
@@ -6694,11 +6760,171 @@
 <6737> +proj=utm +zone=47 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
 # GDA94 / MGA zone 59
 <6738> +proj=utm +zone=59 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Baker zone (m)
+<6784> +proj=tmerc +lat_0=44.5 +lon_0=-117.8333333333333 +k=1.00016 +x_0=40000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Baker zone (ft)
+<6785> +proj=tmerc +lat_0=44.5 +lon_0=-117.8333333333333 +k=1.00016 +x_0=39999.99999984 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Baker zone (m)
+<6786> +proj=tmerc +lat_0=44.5 +lon_0=-117.8333333333333 +k=1.00016 +x_0=40000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Baker zone (ft)
+<6787> +proj=tmerc +lat_0=44.5 +lon_0=-117.8333333333333 +k=1.00016 +x_0=39999.99999984 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Bend-Klamath Falls zone (m)
+<6788> +proj=tmerc +lat_0=41.75 +lon_0=-121.75 +k=1.0002 +x_0=80000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Bend-Klamath Falls zone (ft)
+<6789> +proj=tmerc +lat_0=41.75 +lon_0=-121.75 +k=1.0002 +x_0=79999.99999968 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Bend-Klamath Falls zone (m)
+<6790> +proj=tmerc +lat_0=41.75 +lon_0=-121.75 +k=1.0002 +x_0=80000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Bend-Klamath Falls zone (ft)
+<6791> +proj=tmerc +lat_0=41.75 +lon_0=-121.75 +k=1.0002 +x_0=79999.99999968 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Bend-Redmond-Prineville zone (m)
+<6792> +proj=lcc +lat_1=44.66666666666666 +lat_0=44.66666666666666 +lon_0=-121.25 +k_0=1.00012 +x_0=80000 +y_0=130000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Bend-Redmond-Prineville zone (ft)
+<6793> +proj=lcc +lat_1=44.66666666666666 +lat_0=44.66666666666666 +lon_0=-121.25 +k_0=1.00012 +x_0=79999.99999968 +y_0=130000.00001472 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Bend-Redmond-Prineville zone (m)
+<6794> +proj=lcc +lat_1=44.66666666666666 +lat_0=44.66666666666666 +lon_0=-121.25 +k_0=1.00012 +x_0=80000 +y_0=130000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Bend-Redmond-Prineville zone (ft)
+<6795> +proj=lcc +lat_1=44.66666666666666 +lat_0=44.66666666666666 +lon_0=-121.25 +k_0=1.00012 +x_0=79999.99999968 +y_0=130000.00001472 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Bend-Burns zone (m)
+<6796> +proj=lcc +lat_1=43.66666666666666 +lat_0=43.66666666666666 +lon_0=-119.75 +k_0=1.0002 +x_0=120000 +y_0=60000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Bend-Burns zone (ft)
+<6797> +proj=lcc +lat_1=43.66666666666666 +lat_0=43.66666666666666 +lon_0=-119.75 +k_0=1.0002 +x_0=119999.99999952 +y_0=59999.99999976 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Bend-Burns zone (m)
+<6798> +proj=lcc +lat_1=43.66666666666666 +lat_0=43.66666666666666 +lon_0=-119.75 +k_0=1.0002 +x_0=120000 +y_0=60000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Bend-Burns zone (ft)
+<6799> +proj=lcc +lat_1=43.66666666666666 +lat_0=43.66666666666666 +lon_0=-119.75 +k_0=1.0002 +x_0=119999.99999952 +y_0=59999.99999976 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Canyonville-Grants Pass zone (m)
+<6800> +proj=tmerc +lat_0=42.5 +lon_0=-123.3333333333333 +k=1.00007 +x_0=40000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Canyonville-Grants Pass zone (ft)
+<6801> +proj=tmerc +lat_0=42.5 +lon_0=-123.3333333333333 +k=1.00007 +x_0=39999.99999984 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Canyonville-Grants Pass zone (m)
+<6802> +proj=tmerc +lat_0=42.5 +lon_0=-123.3333333333333 +k=1.00007 +x_0=40000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Canyonville-Grants Pass zone (ft)
+<6803> +proj=tmerc +lat_0=42.5 +lon_0=-123.3333333333333 +k=1.00007 +x_0=39999.99999984 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Columbia River East zone (m)
+<6804> +proj=lcc +lat_1=45.66666666666666 +lat_0=45.66666666666666 +lon_0=-120.5 +k_0=1.000008 +x_0=150000 +y_0=30000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Columbia River East zone (ft)
+<6805> +proj=lcc +lat_1=45.66666666666666 +lat_0=45.66666666666666 +lon_0=-120.5 +k_0=1.000008 +x_0=150000.00001464 +y_0=30000.00001512 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Columbia River East zone (m)
+<6806> +proj=lcc +lat_1=45.66666666666666 +lat_0=45.66666666666666 +lon_0=-120.5 +k_0=1.000008 +x_0=150000 +y_0=30000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Columbia River East zone (ft)
+<6807> +proj=lcc +lat_1=45.66666666666666 +lat_0=45.66666666666666 +lon_0=-120.5 +k_0=1.000008 +x_0=150000.00001464 +y_0=30000.00001512 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Columbia River West zone (m)
+<6808> +proj=omerc +lat_0=45.91666666666666 +lonc=-123 +alpha=295 +k=1 +x_0=7000000 +y_0=-3000000 +no_uoff +gamma=295 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Columbia River West zone (ft)
+<6809> +proj=omerc +lat_0=45.91666666666666 +lonc=-123 +alpha=295 +k=1 +x_0=7000000.00000248 +y_0=-2999999.999988 +no_uoff +gamma=295 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Columbia River West zone (m)
+<6810> +proj=omerc +lat_0=45.91666666666666 +lonc=-123 +alpha=295 +k=1 +x_0=7000000 +y_0=-3000000 +no_uoff +gamma=295 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Columbia River West zone (ft)
+<6811> +proj=omerc +lat_0=45.91666666666666 +lonc=-123 +alpha=295 +k=1 +x_0=7000000.00000248 +y_0=-2999999.999988 +no_uoff +gamma=295 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Cottage Grove-Canyonville zone (m)
+<6812> +proj=tmerc +lat_0=42.83333333333334 +lon_0=-123.3333333333333 +k=1.000023 +x_0=50000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Cottage Grove-Canyonville zone (ft)
+<6813> +proj=tmerc +lat_0=42.83333333333334 +lon_0=-123.3333333333333 +k=1.000023 +x_0=50000.00001504 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Cottage Grove-Canyonville zone (m)
+<6814> +proj=tmerc +lat_0=42.83333333333334 +lon_0=-123.3333333333333 +k=1.000023 +x_0=50000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Cottage Grove-Canyonville zone (ft)
+<6815> +proj=tmerc +lat_0=42.83333333333334 +lon_0=-123.3333333333333 +k=1.000023 +x_0=50000.00001504 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Dufur-Madras zone (m)
+<6816> +proj=tmerc +lat_0=44.5 +lon_0=-121 +k=1.00011 +x_0=80000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Dufur-Madras zone (ft)
+<6817> +proj=tmerc +lat_0=44.5 +lon_0=-121 +k=1.00011 +x_0=79999.99999968 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Dufur-Madras zone (m)
+<6818> +proj=tmerc +lat_0=44.5 +lon_0=-121 +k=1.00011 +x_0=80000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Dufur-Madras zone (ft)
+<6819> +proj=tmerc +lat_0=44.5 +lon_0=-121 +k=1.00011 +x_0=79999.99999968 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Eugene zone (m)
+<6820> +proj=tmerc +lat_0=43.75 +lon_0=-123.1666666666667 +k=1.000015 +x_0=50000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Eugene zone (ft)
+<6821> +proj=tmerc +lat_0=43.75 +lon_0=-123.1666666666667 +k=1.000015 +x_0=50000.00001504 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Eugene zone (m)
+<6822> +proj=tmerc +lat_0=43.75 +lon_0=-123.1666666666667 +k=1.000015 +x_0=50000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Eugene zone (ft)
+<6823> +proj=tmerc +lat_0=43.75 +lon_0=-123.1666666666667 +k=1.000015 +x_0=50000.00001504 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Grants Pass-Ashland zone (m)
+<6824> +proj=tmerc +lat_0=41.75 +lon_0=-123.3333333333333 +k=1.000043 +x_0=50000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Grants Pass-Ashland zone (ft)
+<6825> +proj=tmerc +lat_0=41.75 +lon_0=-123.3333333333333 +k=1.000043 +x_0=50000.00001504 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Grants Pass-Ashland zone (m)
+<6826> +proj=tmerc +lat_0=41.75 +lon_0=-123.3333333333333 +k=1.000043 +x_0=50000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Grants Pass-Ashland zone (ft)
+<6827> +proj=tmerc +lat_0=41.75 +lon_0=-123.3333333333333 +k=1.000043 +x_0=50000.00001504 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Gresham-Warm Springs zone (m)
+<6828> +proj=tmerc +lat_0=45 +lon_0=-122.3333333333333 +k=1.00005 +x_0=10000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Gresham-Warm Springs zone (ft)
+<6829> +proj=tmerc +lat_0=45 +lon_0=-122.3333333333333 +k=1.00005 +x_0=10000.0000152 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Gresham-Warm Springs zone (m)
+<6830> +proj=tmerc +lat_0=45 +lon_0=-122.3333333333333 +k=1.00005 +x_0=10000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Gresham-Warm Springs zone (ft)
+<6831> +proj=tmerc +lat_0=45 +lon_0=-122.3333333333333 +k=1.00005 +x_0=10000.0000152 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon La Grande zone (m)
+<6832> +proj=tmerc +lat_0=45 +lon_0=-118 +k=1.00013 +x_0=40000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon La Grande zone (ft)
+<6833> +proj=tmerc +lat_0=45 +lon_0=-118 +k=1.00013 +x_0=39999.99999984 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon La Grande zone (m)
+<6834> +proj=tmerc +lat_0=45 +lon_0=-118 +k=1.00013 +x_0=40000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon La Grande zone (ft)
+<6835> +proj=tmerc +lat_0=45 +lon_0=-118 +k=1.00013 +x_0=39999.99999984 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Ontario zone (m)
+<6836> +proj=tmerc +lat_0=43.25 +lon_0=-117 +k=1.0001 +x_0=80000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Ontario zone (ft)
+<6837> +proj=tmerc +lat_0=43.25 +lon_0=-117 +k=1.0001 +x_0=79999.99999968 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Ontario zone (m)
+<6838> +proj=tmerc +lat_0=43.25 +lon_0=-117 +k=1.0001 +x_0=80000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Ontario zone (ft)
+<6839> +proj=tmerc +lat_0=43.25 +lon_0=-117 +k=1.0001 +x_0=79999.99999968 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Coast zone (m)
+<6840> +proj=omerc +lat_0=44.75 +lonc=-124.05 +alpha=5 +k=1 +x_0=-300000 +y_0=-4600000 +no_uoff +gamma=5 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Coast zone (ft)
+<6841> +proj=omerc +lat_0=44.75 +lonc=-124.05 +alpha=5 +k=1 +x_0=-299999.9999988 +y_0=-4600000.00001208 +no_uoff +gamma=5 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Coast zone (m)
+<6842> +proj=omerc +lat_0=44.75 +lonc=-124.05 +alpha=5 +k=1 +x_0=-300000 +y_0=-4600000 +no_uoff +gamma=5 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Coast zone (ft)
+<6843> +proj=omerc +lat_0=44.75 +lonc=-124.05 +alpha=5 +k=1 +x_0=-299999.9999988 +y_0=-4600000.00001208 +no_uoff +gamma=5 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Pendleton zone (m)
+<6844> +proj=tmerc +lat_0=45.25 +lon_0=-119.1666666666667 +k=1.000045 +x_0=60000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Pendleton zone (ft)
+<6845> +proj=tmerc +lat_0=45.25 +lon_0=-119.1666666666667 +k=1.000045 +x_0=59999.99999976 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Pendleton zone (m)
+<6846> +proj=tmerc +lat_0=45.25 +lon_0=-119.1666666666667 +k=1.000045 +x_0=60000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Pendleton zone (ft)
+<6847> +proj=tmerc +lat_0=45.25 +lon_0=-119.1666666666667 +k=1.000045 +x_0=59999.99999976 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Pendleton-La Grande zone (m)
+<6848> +proj=tmerc +lat_0=45.08333333333334 +lon_0=-118.3333333333333 +k=1.000175 +x_0=30000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Pendleton-La Grande zone (ft)
+<6849> +proj=tmerc +lat_0=45.08333333333334 +lon_0=-118.3333333333333 +k=1.000175 +x_0=30000.00001512 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Pendleton-La Grande zone (m)
+<6850> +proj=tmerc +lat_0=45.08333333333334 +lon_0=-118.3333333333333 +k=1.000175 +x_0=30000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Pendleton-La Grande zone (ft)
+<6851> +proj=tmerc +lat_0=45.08333333333334 +lon_0=-118.3333333333333 +k=1.000175 +x_0=30000.00001512 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Portland zone (m)
+<6852> +proj=lcc +lat_1=45.5 +lat_0=45.5 +lon_0=-122.75 +k_0=1.000002 +x_0=100000 +y_0=50000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Portland zone (ft)
+<6853> +proj=lcc +lat_1=45.5 +lat_0=45.5 +lon_0=-122.75 +k_0=1.000002 +x_0=99999.99999960001 +y_0=50000.00001504 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Portland zone (m)
+<6854> +proj=lcc +lat_1=45.5 +lat_0=45.5 +lon_0=-122.75 +k_0=1.000002 +x_0=100000 +y_0=50000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Portland zone (ft)
+<6855> +proj=lcc +lat_1=45.5 +lat_0=45.5 +lon_0=-122.75 +k_0=1.000002 +x_0=99999.99999960001 +y_0=50000.00001504 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Salem zone (m)
+<6856> +proj=tmerc +lat_0=44.33333333333334 +lon_0=-123.0833333333333 +k=1.00001 +x_0=50000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Salem zone (ft)
+<6857> +proj=tmerc +lat_0=44.33333333333334 +lon_0=-123.0833333333333 +k=1.00001 +x_0=50000.00001504 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Salem zone (m)
+<6858> +proj=tmerc +lat_0=44.33333333333334 +lon_0=-123.0833333333333 +k=1.00001 +x_0=50000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Salem zone (ft)
+<6859> +proj=tmerc +lat_0=44.33333333333334 +lon_0=-123.0833333333333 +k=1.00001 +x_0=50000.00001504 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(CORS96) / Oregon Santiam Pass zone (m)
+<6860> +proj=tmerc +lat_0=44.08333333333334 +lon_0=-122.5 +k=1.000155 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(CORS96) / Oregon Santiam Pass zone (ft)
+<6861> +proj=tmerc +lat_0=44.08333333333334 +lon_0=-122.5 +k=1.000155 +x_0=0 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / Oregon Santiam Pass zone (m)
+<6862> +proj=tmerc +lat_0=44.08333333333334 +lon_0=-122.5 +k=1.000155 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Oregon Santiam Pass (ft)
+<6863> +proj=tmerc +lat_0=44.08333333333334 +lon_0=-122.5 +k=1.000155 +x_0=0 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
 # NAD83(CORS96) / Oregon LCC (m)
 <6867> +proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
 # NAD83(CORS96) / Oregon GIC Lambert (ft)
 <6868> +proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=399999.9999984 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
-# ETRS89 / Albania 2010
+# ETRS89 / Albania TM 2010
 <6870> +proj=tmerc +lat_0=0 +lon_0=20 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
 # RDN2008 / Italy zone
 <6875> +proj=tmerc +lat_0=0 +lon_0=12 +k=0.9985000000000001 +x_0=7000000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
@@ -6716,6 +6942,612 @@
 <6886> +proj=lcc +lat_1=44 +lat_2=42.33333333333334 +lat_0=41.66666666666666 +lon_0=-120.5 +x_0=1500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
 # NAD83(CORS96) / Oregon South (ft)
 <6887> +proj=lcc +lat_1=44 +lat_2=42.33333333333334 +lat_0=41.66666666666666 +lon_0=-120.5 +x_0=1500000.0001464 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# South East Island 1943 / UTM zone 40N
+<6915> +proj=utm +zone=40 +ellps=clrk80 +towgs84=-43.685,-179.785,-267.721,0,0,0,0 +units=m +no_defs  <>
+# NAD83 / Kansas LCC
+<6922> +proj=lcc +lat_1=39.5 +lat_2=37.5 +lat_0=36 +lon_0=-98.25 +x_0=400000 +y_0=0 +datum=NAD83 +units=m +no_defs  <>
+# NAD83 / Kansas LCC (ftUS)
+<6923> +proj=lcc +lat_1=39.5 +lat_2=37.5 +lat_0=36 +lon_0=-98.25 +x_0=399999.99998984 +y_0=0 +datum=NAD83 +units=us-ft +no_defs  <>
+# NAD83(2011) / Kansas LCC
+<6924> +proj=lcc +lat_1=39.5 +lat_2=37.5 +lat_0=36 +lon_0=-98.25 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / Kansas LCC (ftUS)
+<6925> +proj=lcc +lat_1=39.5 +lat_2=37.5 +lat_0=36 +lon_0=-98.25 +x_0=399999.99998984 +y_0=0 +ellps=GRS80 +units=us-ft +no_defs  <>
+# WGS 84 / NSIDC EASE-Grid 2.0 North
+<6931> +proj=laea +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs  <>
+# WGS 84 / NSIDC EASE-Grid 2.0 South
+<6932> +proj=laea +lat_0=-90 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs  <>
+# WGS 84 / NSIDC EASE-Grid 2.0 Global
+<6933> +proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs  <>
+# VN-2000 / TM-3 zone 481
+<6956> +proj=tmerc +lat_0=0 +lon_0=102 +k=0.9999 +x_0=0 +y_0=500000 +ellps=WGS84 +towgs84=-191.90441429,-39.30318279,-111.45032835,0.00928836,-0.01975479,0.00427372,0.252906278 +units=m +no_defs  <>
+# VN-2000 / TM-3 zone 482
+<6957> +proj=tmerc +lat_0=0 +lon_0=105 +k=0.9999 +x_0=0 +y_0=500000 +ellps=WGS84 +towgs84=-191.90441429,-39.30318279,-111.45032835,0.00928836,-0.01975479,0.00427372,0.252906278 +units=m +no_defs  <>
+# VN-2000 / TM-3 zone 491
+<6958> +proj=tmerc +lat_0=0 +lon_0=108 +k=0.9999 +x_0=0 +y_0=500000 +ellps=WGS84 +towgs84=-191.90441429,-39.30318279,-111.45032835,0.00928836,-0.01975479,0.00427372,0.252906278 +units=m +no_defs  <>
+# VN-2000 / TM-3 Da Nang zone
+<6959> +proj=tmerc +lat_0=0 +lon_0=107.75 +k=0.9999 +x_0=0 +y_0=500000 +ellps=WGS84 +towgs84=-191.90441429,-39.30318279,-111.45032835,0.00928836,-0.01975479,0.00427372,0.252906278 +units=m +no_defs  <>
+# ETRS89 / Albania LCC 2010
+<6962> +proj=lcc +lat_1=39 +lat_2=43 +lat_0=41 +lon_0=20 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
+# NAD27 / Michigan North
+# Unable to translate coordinate system EPSG:6966 into PROJ.4 format.
+#
+# Israeli Grid 05
+<6984> +proj=tmerc +lat_0=31.73439361111111 +lon_0=35.20451694444445 +k=1.0000067 +x_0=219529.584 +y_0=626907.39 +ellps=GRS80 +units=m +no_defs  <>
+# Israeli Grid 05/12
+<6991> +proj=tmerc +lat_0=31.73439361111111 +lon_0=35.20451694444445 +k=1.0000067 +x_0=219529.584 +y_0=626907.39 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / San Francisco CS13 (deprecated)
+<6996> +proj=tmerc +lat_0=37.75 +lon_0=-122.45 +k=1.000007 +x_0=48000 +y_0=24000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / San Francisco CS13 (ftUS) (deprecated)
+<6997> +proj=tmerc +lat_0=37.75 +lon_0=-122.45 +k=1.000007 +x_0=48000 +y_0=24000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# Nahrwan 1934 / UTM zone 37N
+<7005> +proj=utm +zone=37 +ellps=clrk80 +towgs84=-242.2,-144.9,370.3,0,0,0,0 +units=m +no_defs  <>
+# Nahrwan 1934 / UTM zone 38N
+<7006> +proj=utm +zone=38 +ellps=clrk80 +towgs84=-242.2,-144.9,370.3,0,0,0,0 +units=m +no_defs  <>
+# Nahrwan 1934 / UTM zone 39N
+<7007> +proj=utm +zone=39 +ellps=clrk80 +towgs84=-242.2,-144.9,370.3,0,0,0,0 +units=m +no_defs  <>
+# NAD83(2011) / IaRCS zone 1
+<7057> +proj=lcc +lat_1=43.2 +lat_0=43.2 +lon_0=-95.25 +k_0=1.000052 +x_0=3505207.010414021 +y_0=2926085.852171705 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 2
+<7058> +proj=lcc +lat_1=43.16666666666666 +lat_0=43.16666666666666 +lon_0=-92.75 +k_0=1.000043 +x_0=3810007.62001524 +y_0=2987045.974091948 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 3
+<7059> +proj=tmerc +lat_0=40.25 +lon_0=-91.2 +k=1.000035 +x_0=4114808.229616459 +y_0=2529845.05969012 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 4
+<7060> +proj=lcc +lat_1=42.53333333333333 +lat_0=42.53333333333333 +lon_0=-94.83333333333333 +k_0=1.000045 +x_0=4419608.839217679 +y_0=2621285.242570485 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 5
+<7061> +proj=lcc +lat_1=42.65 +lat_0=42.65 +lon_0=-92.25 +k_0=1.000032 +x_0=4724409.448818898 +y_0=2712725.425450851 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 6
+<7062> +proj=tmerc +lat_0=40.25 +lon_0=-95.73333333333333 +k=1.000039 +x_0=5029210.058420117 +y_0=2011684.023368047 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 7
+<7063> +proj=tmerc +lat_0=40.25 +lon_0=-94.63333333333334 +k=1.000045 +x_0=5334010.668021336 +y_0=2072644.145288291 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 8
+<7064> +proj=tmerc +lat_0=40.25 +lon_0=-93.71666666666667 +k=1.000033 +x_0=5638811.277622555 +y_0=2133604.267208535 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 9
+<7065> +proj=tmerc +lat_0=40.25 +lon_0=-92.81666666666666 +k=1.000027 +x_0=5943611.887223775 +y_0=2194564.389128779 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 10
+<7066> +proj=lcc +lat_1=41.83333333333334 +lat_0=41.83333333333334 +lon_0=-91.66666666666667 +k_0=1.00002 +x_0=6248412.496824994 +y_0=2438404.876809754 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 11
+<7067> +proj=tmerc +lat_0=40.25 +lon_0=-90.53333333333333 +k=1.000027 +x_0=6553213.106426213 +y_0=2316484.632969266 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 12
+<7068> +proj=lcc +lat_1=40.91666666666666 +lat_0=40.91666666666666 +lon_0=-93.75 +k_0=1.000037 +x_0=6858013.716027432 +y_0=1889763.779527559 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 13
+<7069> +proj=tmerc +lat_0=40.25 +lon_0=-91.91666666666667 +k=1.00002 +x_0=7162814.325628651 +y_0=1950723.901447803 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / IaRCS zone 14
+<7070> +proj=tmerc +lat_0=40.25 +lon_0=-91.25 +k=1.000018 +x_0=7467614.93522987 +y_0=1889763.779527559 +ellps=GRS80 +units=us-ft +no_defs  <>
+# RGTAAF07 / UTM zone 37S
+<7074> +proj=utm +zone=37 +south +ellps=GRS80 +units=m +no_defs  <>
+# RGTAAF07 / UTM zone 38S
+<7075> +proj=utm +zone=38 +south +ellps=GRS80 +units=m +no_defs  <>
+# RGTAAF07 / UTM zone 39S
+<7076> +proj=utm +zone=39 +south +ellps=GRS80 +units=m +no_defs  <>
+# RGTAAF07 / UTM zone 40S
+<7077> +proj=utm +zone=40 +south +ellps=GRS80 +units=m +no_defs  <>
+# RGTAAF07 / UTM zone 41S
+<7078> +proj=utm +zone=41 +south +ellps=GRS80 +units=m +no_defs  <>
+# RGTAAF07 / UTM zone 42S
+<7079> +proj=utm +zone=42 +south +ellps=GRS80 +units=m +no_defs  <>
+# RGTAAF07 / UTM zone 43S
+<7080> +proj=utm +zone=43 +south +ellps=GRS80 +units=m +no_defs  <>
+# RGTAAF07 / UTM zone 44S
+<7081> +proj=utm +zone=44 +south +ellps=GRS80 +units=m +no_defs  <>
+# RGTAAF07 / Terre Adelie Polar Stereographic
+# Unable to translate coordinate system EPSG:7082 into PROJ.4 format.
+#
+# NAD83(2011) / RMTCRS St Mary (m)
+<7109> +proj=tmerc +lat_0=48.5 +lon_0=-112.5 +k=1.00016 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / RMTCRS Blackfeet (m)
+<7110> +proj=tmerc +lat_0=48 +lon_0=-112.5 +k=1.00019 +x_0=100000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / RMTCRS Milk River (m)
+<7111> +proj=lcc +lat_1=48.5 +lat_0=48.5 +lon_0=-111 +k_0=1.000145 +x_0=150000 +y_0=200000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / RMTCRS Fort Belknap (m)
+<7112> +proj=lcc +lat_1=48.5 +lat_0=48.5 +lon_0=-108.5 +k_0=1.00012 +x_0=200000 +y_0=150000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / RMTCRS Fort Peck Assiniboine (m)
+<7113> +proj=lcc +lat_1=48.33333333333334 +lat_0=48.33333333333334 +lon_0=-105.5 +k_0=1.00012 +x_0=200000 +y_0=100000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / RMTCRS Fort Peck Sioux (m)
+<7114> +proj=lcc +lat_1=48.33333333333334 +lat_0=48.33333333333334 +lon_0=-105.5 +k_0=1.00009 +x_0=100000 +y_0=50000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / RMTCRS Crow (m)
+<7115> +proj=tmerc +lat_0=44.75 +lon_0=-107.75 +k=1.000148 +x_0=200000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / RMTCRS Bobcat (m)
+<7116> +proj=lcc +lat_1=46.25 +lat_0=46.25 +lon_0=-111.25 +k_0=1.000185 +x_0=100000 +y_0=100000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / RMTCRS Billings (m)
+<7117> +proj=lcc +lat_1=45.78333333333333 +lat_0=45.78333333333333 +lon_0=-108.4166666666667 +k_0=1.0001515 +x_0=200000 +y_0=50000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / RMTCRS Wind River (m)
+<7118> +proj=tmerc +lat_0=42.66666666666666 +lon_0=-108.3333333333333 +k=1.00024 +x_0=100000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / RMTCRS St Mary (ft)
+<7119> +proj=tmerc +lat_0=48.5 +lon_0=-112.5 +k=1.00016 +x_0=150000.00001464 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / RMTCRS Blackfeet (ft)
+<7120> +proj=tmerc +lat_0=48 +lon_0=-112.5 +k=1.00019 +x_0=99999.99999960001 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / RMTCRS Milk River (ft)
+<7121> +proj=lcc +lat_1=48.5 +lat_0=48.5 +lon_0=-111 +k_0=1.000145 +x_0=150000.00001464 +y_0=199999.9999992 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / RMTCRS Fort Belknap (ft)
+<7122> +proj=lcc +lat_1=48.5 +lat_0=48.5 +lon_0=-108.5 +k_0=1.00012 +x_0=199999.9999992 +y_0=150000.00001464 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / RMTCRS Fort Peck Assiniboine (ft)
+<7123> +proj=lcc +lat_1=48.33333333333334 +lat_0=48.33333333333334 +lon_0=-105.5 +k_0=1.00012 +x_0=199999.9999992 +y_0=99999.99999960001 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / RMTCRS Fort Peck Sioux (ft)
+<7124> +proj=lcc +lat_1=48.33333333333334 +lat_0=48.33333333333334 +lon_0=-105.5 +k_0=1.00009 +x_0=99999.99999960001 +y_0=49999.99971024 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / RMTCRS Crow (ft)
+<7125> +proj=tmerc +lat_0=44.75 +lon_0=-107.75 +k=1.000148 +x_0=199999.9999992 +y_0=0 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / RMTCRS Bobcat (ft)
+<7126> +proj=lcc +lat_1=46.25 +lat_0=46.25 +lon_0=-111.25 +k_0=1.000185 +x_0=99999.99999960001 +y_0=99999.99999960001 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / RMTCRS Billings (ft)
+<7127> +proj=lcc +lat_1=45.78333333333333 +lat_0=45.78333333333333 +lon_0=-108.4166666666667 +k_0=1.0001515 +x_0=199999.9999992 +y_0=50000.00001504 +ellps=GRS80 +units=ft +no_defs  <>
+# NAD83(2011) / RMTCRS Wind River (ftUS)
+<7128> +proj=tmerc +lat_0=42.66666666666666 +lon_0=-108.3333333333333 +k=1.00024 +x_0=99999.99998983997 +y_0=0 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / San Francisco CS13
+<7131> +proj=tmerc +lat_0=37.75 +lon_0=-122.45 +k=1.000007 +x_0=48000 +y_0=24000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / San Francisco CS13 (ftUS)
+<7132> +proj=tmerc +lat_0=37.75 +lon_0=-122.45 +k=1.000007 +x_0=48000 +y_0=24000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# Palestine 1923 / Palestine Grid modified
+<7142> +proj=tmerc +lat_0=31.73409694444445 +lon_0=35.21208055555556 +k=1 +x_0=170251.555 +y_0=126867.909 +a=6378300.789 +b=6356566.435 +towgs84=-275.7224,94.7824,340.8944,-8.001,-4.42,-11.821,1 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Adams (m)
+<7257> +proj=tmerc +lat_0=40.55 +lon_0=-84.95 +k=1.000034 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Adams (ftUS)
+<7258> +proj=tmerc +lat_0=40.55 +lon_0=-84.95 +k=1.000034 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Allen (m)
+<7259> +proj=tmerc +lat_0=40.9 +lon_0=-85.05 +k=1.000031 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Allen (ftUS)
+<7260> +proj=tmerc +lat_0=40.9 +lon_0=-85.05 +k=1.000031 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Bartholomew (m)
+<7261> +proj=tmerc +lat_0=39 +lon_0=-85.84999999999999 +k=1.000026 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Bartholomew (ftUS)
+<7262> +proj=tmerc +lat_0=39 +lon_0=-85.84999999999999 +k=1.000026 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Benton (m)
+<7263> +proj=tmerc +lat_0=40.45 +lon_0=-87.3 +k=1.000029 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Benton (ftUS)
+<7264> +proj=tmerc +lat_0=40.45 +lon_0=-87.3 +k=1.000029 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Blackford-Delaware (m)
+<7265> +proj=tmerc +lat_0=40.05 +lon_0=-85.40000000000001 +k=1.000038 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Blackford-Delaware (ftUS)
+<7266> +proj=tmerc +lat_0=40.05 +lon_0=-85.40000000000001 +k=1.000038 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Boone-Hendricks (m)
+<7267> +proj=tmerc +lat_0=39.6 +lon_0=-86.5 +k=1.000036 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Boone-Hendricks (ftUS)
+<7268> +proj=tmerc +lat_0=39.6 +lon_0=-86.5 +k=1.000036 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Brown (m)
+<7269> +proj=tmerc +lat_0=39 +lon_0=-86.3 +k=1.00003 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Brown (ftUS)
+<7270> +proj=tmerc +lat_0=39 +lon_0=-86.3 +k=1.00003 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Carroll (m)
+<7271> +proj=tmerc +lat_0=40.4 +lon_0=-86.65000000000001 +k=1.000026 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Carroll (ftUS)
+<7272> +proj=tmerc +lat_0=40.4 +lon_0=-86.65000000000001 +k=1.000026 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Cass (m)
+<7273> +proj=tmerc +lat_0=40.55 +lon_0=-86.40000000000001 +k=1.000028 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Cass (ftUS)
+<7274> +proj=tmerc +lat_0=40.55 +lon_0=-86.40000000000001 +k=1.000028 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Clark-Floyd-Scott (m)
+<7275> +proj=tmerc +lat_0=38.15 +lon_0=-85.59999999999999 +k=1.000021 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Clark-Floyd-Scott (ftUS)
+<7276> +proj=tmerc +lat_0=38.15 +lon_0=-85.59999999999999 +k=1.000021 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Clay (m)
+<7277> +proj=tmerc +lat_0=39.15 +lon_0=-87.15000000000001 +k=1.000024 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Clay (ftUS)
+<7278> +proj=tmerc +lat_0=39.15 +lon_0=-87.15000000000001 +k=1.000024 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Clinton (m)
+<7279> +proj=tmerc +lat_0=40.15 +lon_0=-86.59999999999999 +k=1.000032 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Clinton (ftUS)
+<7280> +proj=tmerc +lat_0=40.15 +lon_0=-86.59999999999999 +k=1.000032 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Crawford-Lawrence-Orange (m)
+<7281> +proj=tmerc +lat_0=38.1 +lon_0=-86.5 +k=1.000025 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Crawford-Lawrence-Orange (ftUS)
+<7282> +proj=tmerc +lat_0=38.1 +lon_0=-86.5 +k=1.000025 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Daviess-Greene (m)
+<7283> +proj=tmerc +lat_0=38.45 +lon_0=-87.09999999999999 +k=1.000018 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Daviess-Greene (ftUS)
+<7284> +proj=tmerc +lat_0=38.45 +lon_0=-87.09999999999999 +k=1.000018 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Dearborn-Ohio-Switzerland (m)
+<7285> +proj=tmerc +lat_0=38.65 +lon_0=-84.90000000000001 +k=1.000029 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Dearborn-Ohio-Switzerland (ftUS)
+<7286> +proj=tmerc +lat_0=38.65 +lon_0=-84.90000000000001 +k=1.000029 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Decatur-Rush (m)
+<7287> +proj=tmerc +lat_0=39.1 +lon_0=-85.65000000000001 +k=1.000036 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Decatur-Rush (ftUS)
+<7288> +proj=tmerc +lat_0=39.1 +lon_0=-85.65000000000001 +k=1.000036 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS DeKalb (m)
+<7289> +proj=tmerc +lat_0=41.25 +lon_0=-84.95 +k=1.000036 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS DeKalb (ftUS)
+<7290> +proj=tmerc +lat_0=41.25 +lon_0=-84.95 +k=1.000036 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Dubois-Martin (m)
+<7291> +proj=tmerc +lat_0=38.2 +lon_0=-86.95 +k=1.00002 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Dubois-Martin (ftUS)
+<7292> +proj=tmerc +lat_0=38.2 +lon_0=-86.95 +k=1.00002 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Elkhart-Kosciusko-Wabash (m)
+<7293> +proj=tmerc +lat_0=40.65 +lon_0=-85.84999999999999 +k=1.000033 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Elkhart-Kosciusko-Wabash (ftUS)
+<7294> +proj=tmerc +lat_0=40.65 +lon_0=-85.84999999999999 +k=1.000033 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Fayette-Franklin-Union (m)
+<7295> +proj=tmerc +lat_0=39.25 +lon_0=-85.05 +k=1.000038 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Fayette-Franklin-Union (ftUS)
+<7296> +proj=tmerc +lat_0=39.25 +lon_0=-85.05 +k=1.000038 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Fountain-Warren (m)
+<7297> +proj=tmerc +lat_0=39.95 +lon_0=-87.3 +k=1.000025 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Fountain-Warren (ftUS)
+<7298> +proj=tmerc +lat_0=39.95 +lon_0=-87.3 +k=1.000025 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Fulton-Marshall-St. Joseph (m)
+<7299> +proj=tmerc +lat_0=40.9 +lon_0=-86.3 +k=1.000031 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Fulton-Marshall-St. Joseph (ftUS)
+<7300> +proj=tmerc +lat_0=40.9 +lon_0=-86.3 +k=1.000031 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Gibson (m)
+<7301> +proj=tmerc +lat_0=38.15 +lon_0=-87.65000000000001 +k=1.000013 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Gibson (ftUS)
+<7302> +proj=tmerc +lat_0=38.15 +lon_0=-87.65000000000001 +k=1.000013 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Grant (m)
+<7303> +proj=tmerc +lat_0=40.35 +lon_0=-85.7 +k=1.000034 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Grant (ftUS)
+<7304> +proj=tmerc +lat_0=40.35 +lon_0=-85.7 +k=1.000034 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Hamilton-Tipton (m)
+<7305> +proj=tmerc +lat_0=39.9 +lon_0=-86 +k=1.000034 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Hamilton-Tipton (ftUS)
+<7306> +proj=tmerc +lat_0=39.9 +lon_0=-86 +k=1.000034 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Hancock-Madison (m)
+<7307> +proj=tmerc +lat_0=39.65 +lon_0=-85.8 +k=1.000036 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Hancock-Madison (ftUS)
+<7308> +proj=tmerc +lat_0=39.65 +lon_0=-85.8 +k=1.000036 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Harrison-Washington (m)
+<7309> +proj=tmerc +lat_0=37.95 +lon_0=-86.15000000000001 +k=1.000027 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Harrison-Washington (ftUS)
+<7310> +proj=tmerc +lat_0=37.95 +lon_0=-86.15000000000001 +k=1.000027 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Henry (m)
+<7311> +proj=tmerc +lat_0=39.75 +lon_0=-85.45 +k=1.000043 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Henry (ftUS)
+<7312> +proj=tmerc +lat_0=39.75 +lon_0=-85.45 +k=1.000043 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Howard-Miami (m)
+<7313> +proj=tmerc +lat_0=40.35 +lon_0=-86.15000000000001 +k=1.000031 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Howard-Miami (ftUS)
+<7314> +proj=tmerc +lat_0=40.35 +lon_0=-86.15000000000001 +k=1.000031 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Huntington-Whitley (m)
+<7315> +proj=tmerc +lat_0=40.65 +lon_0=-85.5 +k=1.000034 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Huntington-Whitley (ftUS)
+<7316> +proj=tmerc +lat_0=40.65 +lon_0=-85.5 +k=1.000034 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Jackson (m)
+<7317> +proj=tmerc +lat_0=38.7 +lon_0=-85.95 +k=1.000022 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Jackson (ftUS)
+<7318> +proj=tmerc +lat_0=38.7 +lon_0=-85.95 +k=1.000022 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Jasper-Porter (m)
+<7319> +proj=tmerc +lat_0=40.7 +lon_0=-87.09999999999999 +k=1.000027 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Jasper-Porter (ftUS)
+<7320> +proj=tmerc +lat_0=40.7 +lon_0=-87.09999999999999 +k=1.000027 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Jay (m)
+<7321> +proj=tmerc +lat_0=40.3 +lon_0=-85 +k=1.000038 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Jay (ftUS)
+<7322> +proj=tmerc +lat_0=40.3 +lon_0=-85 +k=1.000038 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Jefferson (m)
+<7323> +proj=tmerc +lat_0=38.55 +lon_0=-85.34999999999999 +k=1.000028 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Jefferson (ftUS)
+<7324> +proj=tmerc +lat_0=38.55 +lon_0=-85.34999999999999 +k=1.000028 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Jennings (m)
+<7325> +proj=tmerc +lat_0=38.8 +lon_0=-85.8 +k=1.000025 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Jennings (ftUS)
+<7326> +proj=tmerc +lat_0=38.8 +lon_0=-85.8 +k=1.000025 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Johnson-Marion (m)
+<7327> +proj=tmerc +lat_0=39.3 +lon_0=-86.15000000000001 +k=1.000031 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Johnson-Marion (ftUS)
+<7328> +proj=tmerc +lat_0=39.3 +lon_0=-86.15000000000001 +k=1.000031 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Knox (m)
+<7329> +proj=tmerc +lat_0=38.4 +lon_0=-87.45 +k=1.000015 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Knox (ftUS)
+<7330> +proj=tmerc +lat_0=38.4 +lon_0=-87.45 +k=1.000015 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS LaGrange-Noble (m)
+<7331> +proj=tmerc +lat_0=41.25 +lon_0=-85.45 +k=1.000037 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS LaGrange-Noble (ftUS)
+<7332> +proj=tmerc +lat_0=41.25 +lon_0=-85.45 +k=1.000037 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Lake-Newton (m)
+<7333> +proj=tmerc +lat_0=40.7 +lon_0=-87.40000000000001 +k=1.000026 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Lake-Newton (ftUS)
+<7334> +proj=tmerc +lat_0=40.7 +lon_0=-87.40000000000001 +k=1.000026 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS LaPorte-Pulaski-Starke (m)
+<7335> +proj=tmerc +lat_0=40.9 +lon_0=-86.75 +k=1.000027 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS LaPorte-Pulaski-Starke (ftUS)
+<7336> +proj=tmerc +lat_0=40.9 +lon_0=-86.75 +k=1.000027 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Monroe-Morgan (m)
+<7337> +proj=tmerc +lat_0=38.95 +lon_0=-86.5 +k=1.000028 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Monroe-Morgan (ftUS)
+<7338> +proj=tmerc +lat_0=38.95 +lon_0=-86.5 +k=1.000028 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Montgomery-Putnam (m)
+<7339> +proj=tmerc +lat_0=39.45 +lon_0=-86.95 +k=1.000031 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Montgomery-Putnam (ftUS)
+<7340> +proj=tmerc +lat_0=39.45 +lon_0=-86.95 +k=1.000031 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Owen (m)
+<7341> +proj=tmerc +lat_0=39.15 +lon_0=-86.90000000000001 +k=1.000026 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Owen (ftUS)
+<7342> +proj=tmerc +lat_0=39.15 +lon_0=-86.90000000000001 +k=1.000026 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Parke-Vermillion (m)
+<7343> +proj=tmerc +lat_0=39.6 +lon_0=-87.34999999999999 +k=1.000022 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Parke-Vermillion (ftUS)
+<7344> +proj=tmerc +lat_0=39.6 +lon_0=-87.34999999999999 +k=1.000022 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Perry (m)
+<7345> +proj=tmerc +lat_0=37.8 +lon_0=-86.7 +k=1.00002 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Perry (ftUS)
+<7346> +proj=tmerc +lat_0=37.8 +lon_0=-86.7 +k=1.00002 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Pike-Warrick (m)
+<7347> +proj=tmerc +lat_0=37.85 +lon_0=-87.3 +k=1.000015 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Pike-Warrick (ftUS)
+<7348> +proj=tmerc +lat_0=37.85 +lon_0=-87.3 +k=1.000015 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Posey (m)
+<7349> +proj=tmerc +lat_0=37.75 +lon_0=-87.95 +k=1.000013 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Posey (ftUS)
+<7350> +proj=tmerc +lat_0=37.75 +lon_0=-87.95 +k=1.000013 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Randolph-Wayne (m)
+<7351> +proj=tmerc +lat_0=39.7 +lon_0=-85.05 +k=1.000044 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Randolph-Wayne (ftUS)
+<7352> +proj=tmerc +lat_0=39.7 +lon_0=-85.05 +k=1.000044 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Ripley (m)
+<7353> +proj=tmerc +lat_0=38.9 +lon_0=-85.3 +k=1.000038 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Ripley (ftUS)
+<7354> +proj=tmerc +lat_0=38.9 +lon_0=-85.3 +k=1.000038 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Shelby (m)
+<7355> +proj=tmerc +lat_0=39.3 +lon_0=-85.90000000000001 +k=1.00003 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Shelby (ftUS)
+<7356> +proj=tmerc +lat_0=39.3 +lon_0=-85.90000000000001 +k=1.00003 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Spencer (m)
+<7357> +proj=tmerc +lat_0=37.75 +lon_0=-87.05 +k=1.000014 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Spencer (ftUS)
+<7358> +proj=tmerc +lat_0=37.75 +lon_0=-87.05 +k=1.000014 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Steuben (m)
+<7359> +proj=tmerc +lat_0=41.5 +lon_0=-85 +k=1.000041 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Steuben (ftUS)
+<7360> +proj=tmerc +lat_0=41.5 +lon_0=-85 +k=1.000041 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Sullivan (m)
+<7361> +proj=tmerc +lat_0=38.9 +lon_0=-87.5 +k=1.000017 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Sullivan (ftUS)
+<7362> +proj=tmerc +lat_0=38.9 +lon_0=-87.5 +k=1.000017 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Tippecanoe-White (m)
+<7363> +proj=tmerc +lat_0=40.2 +lon_0=-86.90000000000001 +k=1.000026 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Tippecanoe-White (ftUS)
+<7364> +proj=tmerc +lat_0=40.2 +lon_0=-86.90000000000001 +k=1.000026 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Vanderburgh (m)
+<7365> +proj=tmerc +lat_0=37.8 +lon_0=-87.55 +k=1.000015 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Vanderburgh (ftUS)
+<7366> +proj=tmerc +lat_0=37.8 +lon_0=-87.55 +k=1.000015 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Vigo (m)
+<7367> +proj=tmerc +lat_0=39.25 +lon_0=-87.45 +k=1.00002 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Vigo (ftUS)
+<7368> +proj=tmerc +lat_0=39.25 +lon_0=-87.45 +k=1.00002 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / InGCS Wells (m)
+<7369> +proj=tmerc +lat_0=40.55 +lon_0=-85.25 +k=1.000034 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / InGCS Wells (ftUS)
+<7370> +proj=tmerc +lat_0=40.55 +lon_0=-85.25 +k=1.000034 +x_0=240000 +y_0=36000 +ellps=GRS80 +units=us-ft +no_defs  <>
+# ONGD14 / UTM zone 39N
+<7374> +proj=utm +zone=39 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
+# ONGD14 / UTM zone 40N
+<7375> +proj=utm +zone=40 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
+# ONGD14 / UTM zone 41N
+<7376> +proj=utm +zone=41 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Adams and Juneau (m)
+<7528> +proj=tmerc +lat_0=43.36666666666667 +lon_0=-90 +k=1.0000365285 +x_0=147218.6942 +y_0=0.0037 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Ashland (m)
+<7529> +proj=tmerc +lat_0=45.70611111111111 +lon_0=-90.62222222222222 +k=1.0000495683 +x_0=172821.9461 +y_0=0.0017 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Barron (m)
+<7530> +proj=tmerc +lat_0=45.13333333333333 +lon_0=-91.84999999999999 +k=1.0000486665 +x_0=93150 +y_0=0.0029 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Bayfield (m)
+<7531> +proj=lcc +lat_1=46.66964837722222 +lat_0=46.66964837722222 +lon_0=-91.15277777777779 +k_0=1.0000331195 +x_0=228600.4575 +y_0=148551.4837 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Brown (m)
+<7532> +proj=tmerc +lat_0=43 +lon_0=-88 +k=1.00002 +x_0=31600 +y_0=4600 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Buffalo (m)
+<7533> +proj=tmerc +lat_0=43.48138888888889 +lon_0=-91.79722222222222 +k=1.0000382778 +x_0=175260.3502 +y_0=0.0048 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Burnett (m)
+<7534> +proj=lcc +lat_1=45.89871486583333 +lat_0=45.89871486583333 +lon_0=-92.45777777777778 +k_0=1.0000383841 +x_0=64008.1276 +y_0=59445.9043 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Calumet, Fond du Lac, Outagamie and Winnebago (m)
+<7535> +proj=tmerc +lat_0=42.71944444444445 +lon_0=-88.5 +k=1.0000286569 +x_0=244754.8893 +y_0=0.0049 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Chippewa (m)
+<7536> +proj=lcc +lat_1=44.97785689861112 +lat_0=44.97785689861112 +lon_0=-91.29444444444444 +k_0=1.0000391127 +x_0=60045.72 +y_0=44091.4346 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Clark (m)
+<7537> +proj=tmerc +lat_0=43.6 +lon_0=-90.70833333333334 +k=1.0000463003 +x_0=199949.1989 +y_0=0.0086 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Columbia (m)
+<7538> +proj=lcc +lat_1=43.46254664583333 +lat_0=43.46254664583333 +lon_0=-89.39444444444445 +k_0=1.00003498 +x_0=169164.3381 +y_0=111569.6134 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Crawford (m)
+<7539> +proj=lcc +lat_1=43.200055605 +lat_0=43.200055605 +lon_0=-90.9388888888889 +k_0=1.0000349151 +x_0=113690.6274 +y_0=53703.1201 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Dane (m)
+<7540> +proj=lcc +lat_1=43.0695160375 +lat_0=43.0695160375 +lon_0=-89.42222222222223 +k_0=1.0000384786 +x_0=247193.2944 +y_0=146591.9896 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Dodge and Jefferson (m)
+<7541> +proj=tmerc +lat_0=41.47222222222222 +lon_0=-88.77500000000001 +k=1.0000346418 +x_0=263347.7263 +y_0=0.0076 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Door (m)
+<7542> +proj=tmerc +lat_0=44.4 +lon_0=-87.27222222222223 +k=1.0000187521 +x_0=158801.1176 +y_0=0.0023 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Douglas (m)
+<7543> +proj=tmerc +lat_0=45.88333333333333 +lon_0=-91.91666666666667 +k=1.0000385418 +x_0=59131.3183 +y_0=0.0041 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Dunn (m)
+<7544> +proj=tmerc +lat_0=44.40833333333333 +lon_0=-91.89444444444445 +k=1.0000410324 +x_0=51816.104 +y_0=0.003 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Eau Claire (m)
+<7545> +proj=lcc +lat_1=44.87228112638889 +lat_0=44.87228112638889 +lon_0=-91.28888888888889 +k_0=1.000035079 +x_0=120091.4402 +y_0=91687.92389999999 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Florence (m)
+<7546> +proj=tmerc +lat_0=45.43888888888888 +lon_0=-88.14166666666668 +k=1.0000552095 +x_0=133502.6683 +y_0=0.0063 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Forest (m)
+<7547> +proj=tmerc +lat_0=44.00555555555555 +lon_0=-88.63333333333334 +k=1.0000673004 +x_0=275844.5533 +y_0=0.0157 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Grant (m)
+<7548> +proj=tmerc +lat_0=41.41111111111111 +lon_0=-90.8 +k=1.0000349452 +x_0=242316.4841 +y_0=0.01 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Green and Lafayette (m)
+<7549> +proj=lcc +lat_1=42.63756227694444 +lat_0=42.63756227694444 +lon_0=-89.83888888888889 +k_0=1.0000390487 +x_0=170078.7403 +y_0=45830.2947 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Green Lake and Marquette (m)
+<7550> +proj=lcc +lat_1=43.80700011777778 +lat_0=43.80700011777778 +lon_0=-89.24166666666667 +k_0=1.0000344057 +x_0=150876.3018 +y_0=79170.7795 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Iowa (m)
+<7551> +proj=tmerc +lat_0=42.53888888888888 +lon_0=-90.16111111111111 +k=1.0000394961 +x_0=113081.0261 +y_0=0.0045 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Iron (m)
+<7552> +proj=tmerc +lat_0=45.43333333333333 +lon_0=-90.25555555555556 +k=1.0000677153 +x_0=220980.4419 +y_0=0.008500000000000001 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Jackson (m)
+<7553> +proj=tmerc +lat_0=44.25333512777778 +lon_0=-90.84429651944444 +k=1.0000353 +x_0=27000 +y_0=25000 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Kenosha, Milwaukee, Ozaukee and Racine (m)
+<7554> +proj=tmerc +lat_0=42.21666666666667 +lon_0=-87.89444444444445 +k=1.0000260649 +x_0=185928.3728 +y_0=0.0009 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Kewaunee, Manitowoc and Sheboygan (m)
+<7555> +proj=tmerc +lat_0=43.26666666666667 +lon_0=-87.55 +k=1.0000233704 +x_0=79857.7614 +y_0=0.0012 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS La Crosse (m)
+<7556> +proj=tmerc +lat_0=43.45111111111111 +lon_0=-91.31666666666666 +k=1.0000319985 +x_0=130454.6598 +y_0=0.0033 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Langlade (m)
+<7557> +proj=lcc +lat_1=45.15423710527778 +lat_0=45.15423710527778 +lon_0=-89.03333333333333 +k_0=1.0000627024 +x_0=198425.197 +y_0=105279.7829 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Lincoln (m)
+<7558> +proj=tmerc +lat_0=44.84444444444445 +lon_0=-89.73333333333333 +k=1.0000599003 +x_0=116129.0323 +y_0=0.0058 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Marathon (m)
+<7559> +proj=lcc +lat_1=44.90090442361111 +lat_0=44.90090442361111 +lon_0=-89.77 +k_0=1.000053289 +x_0=74676.1493 +y_0=55049.2669 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Marinette (m)
+<7560> +proj=tmerc +lat_0=44.69166666666666 +lon_0=-87.71111111111111 +k=1.0000234982 +x_0=238658.8794 +y_0=0.0032 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Menominee (m)
+<7561> +proj=tmerc +lat_0=44.71666666666667 +lon_0=-88.41666666666667 +k=1.0000362499 +x_0=105461.0121 +y_0=0.0029 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Monroe (m)
+<7562> +proj=lcc +lat_1=44.00007392861111 +lat_0=44.00007392861111 +lon_0=-90.64166666666668 +k_0=1.0000434122 +x_0=204521.209 +y_0=121923.9861 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Oconto (m)
+<7563> +proj=tmerc +lat_0=44.39722222222222 +lon_0=-87.90833333333335 +k=1.0000236869 +x_0=182880.3676 +y_0=0.0033 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Oneida (m)
+<7564> +proj=lcc +lat_1=45.70422377027778 +lat_0=45.70422377027778 +lon_0=-89.54444444444444 +k_0=1.0000686968 +x_0=70104.1401 +y_0=57588.0346 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Pepin and Pierce (m)
+<7565> +proj=lcc +lat_1=44.63614887194444 +lat_0=44.63614887194444 +lon_0=-92.22777777777777 +k_0=1.0000362977 +x_0=167640.3354 +y_0=86033.0876 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Polk (m)
+<7566> +proj=tmerc +lat_0=44.66111111111111 +lon_0=-92.63333333333334 +k=1.0000433849 +x_0=141732.2823 +y_0=0.0059 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Portage (m)
+<7567> +proj=lcc +lat_1=44.41682397527777 +lat_0=44.41682397527777 +lon_0=-89.5 +k_0=1.000039936 +x_0=56388.1128 +y_0=50022.1874 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Price (m)
+<7568> +proj=tmerc +lat_0=44.55555555555555 +lon_0=-90.48888888888889 +k=1.0000649554 +x_0=227990.8546 +y_0=0.0109 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Richland (m)
+<7569> +proj=lcc +lat_1=43.3223129275 +lat_0=43.3223129275 +lon_0=-90.43055555555556 +k_0=1.0000375653 +x_0=202387.6048 +y_0=134255.4253 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Rock (m)
+<7570> +proj=tmerc +lat_0=41.94444444444444 +lon_0=-89.07222222222222 +k=1.0000337311 +x_0=146304.2926 +y_0=0.0068 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Rusk (m)
+<7571> +proj=tmerc +lat_0=43.91944444444444 +lon_0=-91.06666666666666 +k=1.0000495976 +x_0=250546.1013 +y_0=0.0234 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Sauk (m)
+<7572> +proj=tmerc +lat_0=42.81944444444445 +lon_0=-89.90000000000001 +k=1.0000373868 +x_0=185623.5716 +y_0=0.0051 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Sawyer (m)
+<7573> +proj=lcc +lat_1=45.90009913138888 +lat_0=45.90009913138888 +lon_0=-91.11666666666666 +k_0=1.0000573461 +x_0=216713.2336 +y_0=120734.1631 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Shawano (m)
+<7574> +proj=tmerc +lat_0=44.03611111111111 +lon_0=-88.60555555555555 +k=1.000032144 +x_0=262433.3253 +y_0=0.009599999999999999 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS St. Croix (m)
+<7575> +proj=tmerc +lat_0=44.03611111111111 +lon_0=-92.63333333333334 +k=1.0000381803 +x_0=165506.7302 +y_0=0.0103 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Taylor (m)
+<7576> +proj=lcc +lat_1=45.17782208583333 +lat_0=45.17782208583333 +lon_0=-90.48333333333333 +k_0=1.0000597566 +x_0=187147.5744 +y_0=107746.7522 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Trempealeau (m)
+<7577> +proj=tmerc +lat_0=43.16111111111111 +lon_0=-91.36666666666666 +k=1.0000361538 +x_0=256946.9138 +y_0=0.0041 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Vernon (m)
+<7578> +proj=lcc +lat_1=43.57503293972223 +lat_0=43.57503293972223 +lon_0=-90.78333333333333 +k_0=1.0000408158 +x_0=222504.4451 +y_0=47532.0602 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Vilas (m)
+<7579> +proj=lcc +lat_1=46.07784409055556 +lat_0=46.07784409055556 +lon_0=-89.48888888888889 +k_0=1.0000730142 +x_0=134417.0689 +y_0=50337.1092 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Walworth (m)
+<7580> +proj=lcc +lat_1=42.66946209694444 +lat_0=42.66946209694444 +lon_0=-88.54166666666667 +k_0=1.0000367192 +x_0=232562.8651 +y_0=111088.2224 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Washburn (m)
+<7581> +proj=lcc +lat_1=45.96121983333334 +lat_0=45.96121983333334 +lon_0=-91.78333333333333 +k_0=1.0000475376 +x_0=234086.8682 +y_0=188358.6058 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Washington (m)
+<7582> +proj=tmerc +lat_0=42.91805555555555 +lon_0=-88.06388888888888 +k=1.00003738 +x_0=120091.4415 +y_0=0.003 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Waukesha (m)
+<7583> +proj=tmerc +lat_0=42.56944444444445 +lon_0=-88.22499999999999 +k=1.0000346179 +x_0=208788.418 +y_0=0.0034 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Waupaca (m)
+<7584> +proj=tmerc +lat_0=43.42027777777778 +lon_0=-88.81666666666666 +k=1.0000333645 +x_0=185013.9709 +y_0=0.007 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Waushara (m)
+<7585> +proj=lcc +lat_1=44.11394404583334 +lat_0=44.11394404583334 +lon_0=-89.24166666666667 +k_0=1.0000392096 +x_0=120091.4402 +y_0=45069.7587 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Wood (m)
+<7586> +proj=lcc +lat_1=44.36259546944444 +lat_0=44.36259546944444 +lon_0=-90 +k_0=1.0000421209 +x_0=208483.6173 +y_0=134589.754 +ellps=GRS80 +units=m +no_defs  <>
+# NAD83(2011) / WISCRS Adams and Juneau (ftUS)
+<7587> +proj=tmerc +lat_0=43.36666666666667 +lon_0=-90 +k=1.0000365285 +x_0=147218.6941325883 +y_0=0.00365760731521463 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Ashland (ftUS)
+<7588> +proj=tmerc +lat_0=45.70611111111111 +lon_0=-90.62222222222222 +k=1.0000495683 +x_0=172821.945948692 +y_0=0.001828803657607315 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Barron (ftUS)
+<7589> +proj=tmerc +lat_0=45.13333333333333 +lon_0=-91.84999999999999 +k=1.0000486665 +x_0=93150 +y_0=0.003048006096012192 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Bayfield (ftUS)
+<7590> +proj=lcc +lat_1=46.66964837722222 +lat_0=46.66964837722222 +lon_0=-91.15277777777779 +k_0=1.0000331195 +x_0=228600.4575057151 +y_0=148551.4835661671 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Brown (ftUS)
+<7591> +proj=tmerc +lat_0=43 +lon_0=-88 +k=1.00002 +x_0=31599.99989839979 +y_0=4599.999898399797 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Buffalo (ftUS)
+<7592> +proj=tmerc +lat_0=43.48138888888889 +lon_0=-91.79722222222222 +k=1.0000382778 +x_0=175260.3502159004 +y_0=0.004876809753619507 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Burnett (ftUS)
+<7593> +proj=lcc +lat_1=45.89871486583333 +lat_0=45.89871486583333 +lon_0=-92.45777777777778 +k_0=1.0000383841 +x_0=64008.12771145543 +y_0=59445.90419100838 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Calumet, Fond du Lac, Outagamie and Winnebago (ftUS)
+<7594> +proj=tmerc +lat_0=42.71944444444445 +lon_0=-88.5 +k=1.0000286569 +x_0=244754.8892049784 +y_0=0.004876809753619507 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Chippewa (ftUS)
+<7595> +proj=lcc +lat_1=44.97785689861112 +lat_0=44.97785689861112 +lon_0=-91.29444444444444 +k_0=1.0000391127 +x_0=60045.72009144018 +y_0=44091.43449326898 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Clark (ftUS)
+<7596> +proj=tmerc +lat_0=43.6 +lon_0=-90.70833333333334 +k=1.0000463003 +x_0=199949.198983998 +y_0=0.008534417068834137 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Columbia (ftUS)
+<7597> +proj=lcc +lat_1=43.46254664583333 +lat_0=43.46254664583333 +lon_0=-89.39444444444445 +k_0=1.00003498 +x_0=169164.338023876 +y_0=111569.613512827 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Crawford (ftUS)
+<7598> +proj=lcc +lat_1=43.200055605 +lat_0=43.200055605 +lon_0=-90.9388888888889 +k_0=1.0000349151 +x_0=113690.6273812548 +y_0=53703.12024384048 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Dane (ftUS)
+<7599> +proj=lcc +lat_1=43.0695160375 +lat_0=43.0695160375 +lon_0=-89.42222222222223 +k_0=1.0000384786 +x_0=247193.2943865888 +y_0=146591.9896367793 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Dodge and Jefferson (ftUS)
+<7600> +proj=tmerc +lat_0=41.47222222222222 +lon_0=-88.77500000000001 +k=1.0000346418 +x_0=263347.7263906528 +y_0=0.00762001524003048 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Door (ftUS)
+<7601> +proj=tmerc +lat_0=44.4 +lon_0=-87.27222222222223 +k=1.0000187521 +x_0=158801.1176022352 +y_0=0.002438404876809754 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Douglas (ftUS)
+<7602> +proj=tmerc +lat_0=45.88333333333333 +lon_0=-91.91666666666667 +k=1.0000385418 +x_0=59131.31826263652 +y_0=0.003962407924815849 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Dunn (ftUS)
+<7603> +proj=tmerc +lat_0=44.40833333333333 +lon_0=-91.89444444444445 +k=1.0000410324 +x_0=51816.10393700787 +y_0=0.003048006096012192 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Eau Claire (ftUS)
+<7604> +proj=lcc +lat_1=44.87228112638889 +lat_0=44.87228112638889 +lon_0=-91.28888888888889 +k_0=1.000035079 +x_0=120091.4401828804 +y_0=91687.92390144781 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Florence (ftUS)
+<7605> +proj=tmerc +lat_0=45.43888888888888 +lon_0=-88.14166666666668 +k=1.0000552095 +x_0=133502.6682245364 +y_0=0.006400812801625603 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Forest (ftUS)
+<7606> +proj=tmerc +lat_0=44.00555555555555 +lon_0=-88.63333333333334 +k=1.0000673004 +x_0=275844.5532131065 +y_0=0.0158496316992634 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Grant (ftUS)
+<7607> +proj=tmerc +lat_0=41.41111111111111 +lon_0=-90.8 +k=1.0000349452 +x_0=242316.484023368 +y_0=0.01005842011684023 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Green and Lafayette (ftUS)
+<7608> +proj=lcc +lat_1=42.63756227694444 +lat_0=42.63756227694444 +lon_0=-89.83888888888889 +k_0=1.0000390487 +x_0=170078.7401574803 +y_0=45830.29484378968 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Green Lake and Marquette (ftUS)
+<7609> +proj=lcc +lat_1=43.80700011777778 +lat_0=43.80700011777778 +lon_0=-89.24166666666667 +k_0=1.0000344057 +x_0=150876.3017526035 +y_0=79170.77937515875 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Iowa (ftUS)
+<7610> +proj=tmerc +lat_0=42.53888888888888 +lon_0=-90.16111111111111 +k=1.0000394961 +x_0=113081.0261620523 +y_0=0.004572009144018288 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Iron (ftUS)
+<7611> +proj=tmerc +lat_0=45.43333333333333 +lon_0=-90.25555555555556 +k=1.0000677153 +x_0=220980.4419608839 +y_0=0.008534417068834137 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Jackson (ftUS)
+<7612> +proj=tmerc +lat_0=44.25333512777778 +lon_0=-90.84429651944444 +k=1.0000353 +x_0=27000 +y_0=24999.99989839979 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Kenosha, Milwaukee, Ozaukee and Racine (ftUS)
+<7613> +proj=tmerc +lat_0=42.21666666666667 +lon_0=-87.89444444444445 +k=1.0000260649 +x_0=185928.3727711455 +y_0=0.0009144018288036576 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Kewaunee, Manitowoc and Sheboygan (ftUS)
+<7614> +proj=tmerc +lat_0=43.26666666666667 +lon_0=-87.55 +k=1.0000233704 +x_0=79857.76154432308 +y_0=0.001219202438404877 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS La Crosse (ftUS)
+<7615> +proj=tmerc +lat_0=43.45111111111111 +lon_0=-91.31666666666666 +k=1.0000319985 +x_0=130454.6596901194 +y_0=0.003352806705613411 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Langlade (ftUS)
+<7616> +proj=lcc +lat_1=45.15423710527778 +lat_0=45.15423710527778 +lon_0=-89.03333333333333 +k_0=1.0000627024 +x_0=198425.1968503937 +y_0=105279.7828803657 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Lincoln (ftUS)
+<7617> +proj=tmerc +lat_0=44.84444444444445 +lon_0=-89.73333333333333 +k=1.0000599003 +x_0=116129.0322580645 +y_0=0.005791211582423164 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Marathon (ftUS)
+<7618> +proj=lcc +lat_1=44.90090442361111 +lat_0=44.90090442361111 +lon_0=-89.77 +k_0=1.000053289 +x_0=74676.1493522987 +y_0=55049.26695453391 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Marinette (ftUS)
+<7619> +proj=tmerc +lat_0=44.69166666666666 +lon_0=-87.71111111111111 +k=1.0000234982 +x_0=238658.8794513589 +y_0=0.003048006096012192 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Menominee (ftUS)
+<7620> +proj=tmerc +lat_0=44.71666666666667 +lon_0=-88.41666666666667 +k=1.0000362499 +x_0=105461.0121412243 +y_0=0.003048006096012192 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Monroe (ftUS)
+<7621> +proj=lcc +lat_1=44.00007392861111 +lat_0=44.00007392861111 +lon_0=-90.64166666666668 +k_0=1.0000434122 +x_0=204521.2090424181 +y_0=121923.9861823724 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Oconto (ftUS)
+<7622> +proj=tmerc +lat_0=44.39722222222222 +lon_0=-87.90833333333335 +k=1.0000236869 +x_0=182880.3675895352 +y_0=0.003352806705613411 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Oneida (ftUS)
+<7623> +proj=lcc +lat_1=45.70422377027778 +lat_0=45.70422377027778 +lon_0=-89.54444444444444 +k_0=1.0000686968 +x_0=70104.14020828041 +y_0=57588.03474726949 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Pepin and Pierce (ftUS)
+<7624> +proj=lcc +lat_1=44.63614887194444 +lat_0=44.63614887194444 +lon_0=-92.22777777777777 +k_0=1.0000362977 +x_0=167640.3352806706 +y_0=86033.08773177546 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Polk (ftUS)
+<7625> +proj=tmerc +lat_0=44.66111111111111 +lon_0=-92.63333333333334 +k=1.0000433849 +x_0=141732.2822453645 +y_0=0.005791211582423164 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Portage (ftUS)
+<7626> +proj=lcc +lat_1=44.41682397527777 +lat_0=44.41682397527777 +lon_0=-89.5 +k_0=1.000039936 +x_0=56388.11277622555 +y_0=50022.1874523749 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Price (ftUS)
+<7627> +proj=tmerc +lat_0=44.55555555555555 +lon_0=-90.48888888888889 +k=1.0000649554 +x_0=227990.8544577089 +y_0=0.01097282194564389 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Richland (ftUS)
+<7628> +proj=lcc +lat_1=43.3223129275 +lat_0=43.3223129275 +lon_0=-90.43055555555556 +k_0=1.0000375653 +x_0=202387.6047752095 +y_0=134255.4254508509 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Rock (ftUS)
+<7629> +proj=tmerc +lat_0=41.94444444444444 +lon_0=-89.07222222222222 +k=1.0000337311 +x_0=146304.2926085852 +y_0=0.006705613411226822 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Rusk (ftUS)
+<7630> +proj=tmerc +lat_0=43.91944444444444 +lon_0=-91.06666666666666 +k=1.0000495976 +x_0=250546.1013970028 +y_0=0.02346964693929388 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Sauk (ftUS)
+<7631> +proj=tmerc +lat_0=42.81944444444445 +lon_0=-89.90000000000001 +k=1.0000373868 +x_0=185623.5715519431 +y_0=0.005181610363220727 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Sawyer (ftUS)
+<7632> +proj=lcc +lat_1=45.90009913138888 +lat_0=45.90009913138888 +lon_0=-91.11666666666666 +k_0=1.0000573461 +x_0=216713.2337312675 +y_0=120734.1631699263 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Shawano (ftUS)
+<7633> +proj=tmerc +lat_0=44.03611111111111 +lon_0=-88.60555555555555 +k=1.000032144 +x_0=262433.3251714504 +y_0=0.009448818897637795 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS St. Croix (ftUS)
+<7634> +proj=tmerc +lat_0=44.03611111111111 +lon_0=-92.63333333333334 +k=1.0000381803 +x_0=165506.7300990602 +y_0=0.01036322072644145 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Taylor (ftUS)
+<7635> +proj=lcc +lat_1=45.17782208583333 +lat_0=45.17782208583333 +lon_0=-90.48333333333333 +k_0=1.0000597566 +x_0=187147.5742951486 +y_0=107746.7521463043 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Trempealeau (ftUS)
+<7636> +proj=tmerc +lat_0=43.16111111111111 +lon_0=-91.36666666666666 +k=1.0000361538 +x_0=256946.9138938278 +y_0=0.003962407924815849 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Vernon (ftUS)
+<7637> +proj=lcc +lat_1=43.57503293972223 +lat_0=43.57503293972223 +lon_0=-90.78333333333333 +k_0=1.0000408158 +x_0=222504.44500889 +y_0=47532.0603505207 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Vilas (ftUS)
+<7638> +proj=lcc +lat_1=46.07784409055556 +lat_0=46.07784409055556 +lon_0=-89.48888888888889 +k_0=1.0000730142 +x_0=134417.0688341377 +y_0=50337.10927101854 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Walworth (ftUS)
+<7639> +proj=lcc +lat_1=42.66946209694444 +lat_0=42.66946209694444 +lon_0=-88.54166666666667 +k_0=1.0000367192 +x_0=232562.8651257302 +y_0=111088.2224028448 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Washburn (ftUS)
+<7640> +proj=lcc +lat_1=45.96121983333334 +lat_0=45.96121983333334 +lon_0=-91.78333333333333 +k_0=1.0000475376 +x_0=234086.8681737363 +y_0=188358.6059436119 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Washington (ftUS)
+<7641> +proj=tmerc +lat_0=42.91805555555555 +lon_0=-88.06388888888888 +k=1.00003738 +x_0=120091.4414020828 +y_0=0.003048006096012192 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Waukesha (ftUS)
+<7642> +proj=tmerc +lat_0=42.56944444444445 +lon_0=-88.22499999999999 +k=1.0000346179 +x_0=208788.4178816358 +y_0=0.003352806705613411 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Waupaca (ftUS)
+<7643> +proj=tmerc +lat_0=43.42027777777778 +lon_0=-88.81666666666666 +k=1.0000333645 +x_0=185013.9709423419 +y_0=0.007010414020828041 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Waushara (ftUS)
+<7644> +proj=lcc +lat_1=44.11394404583334 +lat_0=44.11394404583334 +lon_0=-89.24166666666667 +k_0=1.0000392096 +x_0=120091.4401828804 +y_0=45069.7588011176 +ellps=GRS80 +units=us-ft +no_defs  <>
+# NAD83(2011) / WISCRS Wood (ftUS)
+<7645> +proj=lcc +lat_1=44.36259546944444 +lat_0=44.36259546944444 +lon_0=-90 +k_0=1.0000421209 +x_0=208483.6172720346 +y_0=134589.7539243078 +ellps=GRS80 +units=us-ft +no_defs  <>
 # Pulkovo 1995 / Gauss-Kruger zone 4
 <20004> +proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +towgs84=24.47,-130.89,-81.56,0,0,0.13,-0.22 +units=m +no_defs  <>
 # Pulkovo 1995 / Gauss-Kruger zone 5
@@ -7172,9 +8004,9 @@
 # ED50 / TM 5 NE
 <23095> +proj=tmerc +lat_0=0 +lon_0=5 +k=0.9996 +x_0=500000 +y_0=0 +ellps=intl +towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs  <>
 # Fahud / UTM zone 39N
-<23239> +proj=utm +zone=39 +ellps=clrk80 +towgs84=-346,-1,224,0,0,0,0 +units=m +no_defs  <>
+<23239> +proj=utm +zone=39 +ellps=clrk80 +towgs84=-333.102,-11.02,230.69,0,0,0.554,0.219 +units=m +no_defs  <>
 # Fahud / UTM zone 40N
-<23240> +proj=utm +zone=40 +ellps=clrk80 +towgs84=-346,-1,224,0,0,0,0 +units=m +no_defs  <>
+<23240> +proj=utm +zone=40 +ellps=clrk80 +towgs84=-333.102,-11.02,230.69,0,0,0.554,0.219 +units=m +no_defs  <>
 # Garoua / UTM zone 33N (deprecated)
 <23433> +proj=utm +zone=33 +a=6378249.2 +b=6356515 +units=m +no_defs  <>
 # HD72 / EOV
@@ -7937,14 +8769,14 @@
 <26997> +proj=tmerc +lat_0=35.83333333333334 +lon_0=-92.5 +k=0.999933333 +x_0=500000 +y_0=0 +datum=NAD83 +units=m +no_defs  <>
 # NAD83 / Missouri West
 <26998> +proj=tmerc +lat_0=36.16666666666666 +lon_0=-94.5 +k=0.999941177 +x_0=850000 +y_0=0 +datum=NAD83 +units=m +no_defs  <>
-# Nahrwan 1967 / UTM zone 37N
-<27037> +proj=utm +zone=37 +ellps=clrk80 +towgs84=-242.2,-144.9,370.3,0,0,0,0 +units=m +no_defs  <>
-# Nahrwan 1967 / UTM zone 38N
-<27038> +proj=utm +zone=38 +ellps=clrk80 +towgs84=-242.2,-144.9,370.3,0,0,0,0 +units=m +no_defs  <>
+# Nahrwan 1967 / UTM zone 37N (deprecated)
+<27037> +proj=utm +zone=37 +ellps=clrk80 +towgs84=-249,-156,381,0,0,0,0 +units=m +no_defs  <>
+# Nahrwan 1967 / UTM zone 38N (deprecated)
+<27038> +proj=utm +zone=38 +ellps=clrk80 +towgs84=-249,-156,381,0,0,0,0 +units=m +no_defs  <>
 # Nahrwan 1967 / UTM zone 39N
-<27039> +proj=utm +zone=39 +ellps=clrk80 +towgs84=-242.2,-144.9,370.3,0,0,0,0 +units=m +no_defs  <>
+<27039> +proj=utm +zone=39 +ellps=clrk80 +towgs84=-249,-156,381,0,0,0,0 +units=m +no_defs  <>
 # Nahrwan 1967 / UTM zone 40N
-<27040> +proj=utm +zone=40 +ellps=clrk80 +towgs84=-242.2,-144.9,370.3,0,0,0,0 +units=m +no_defs  <>
+<27040> +proj=utm +zone=40 +ellps=clrk80 +towgs84=-249,-156,381,0,0,0,0 +units=m +no_defs  <>
 # Naparima 1972 / UTM zone 20N
 <27120> +proj=utm +zone=20 +ellps=intl +towgs84=-10,375,165,0,0,0,0 +units=m +no_defs  <>
 # NZGD49 / New Zealand Map Grid
@@ -8230,9 +9062,9 @@
 # Qatar 1974 / Qatar National Grid
 <28600> +proj=tmerc +lat_0=24.45 +lon_0=51.21666666666667 +k=0.99999 +x_0=200000 +y_0=300000 +ellps=intl +towgs84=-128.16,-282.42,21.93,0,0,0,0 +units=m +no_defs  <>
 # Amersfoort / RD Old
-<28991> +proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=0 +y_0=0 +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957388243134,0.343987817378283,-1.87740163998045,4.0725 +units=m +no_defs  <>
+<28991> +proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=0 +y_0=0 +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957,0.343988,-1.87740,4.0725 +units=m +no_defs  <>
 # Amersfoort / RD New
-<28992> +proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957388243134,0.343987817378283,-1.87740163998045,4.0725 +units=m +no_defs  <>
+<28992> +proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957,0.343988,-1.87740,4.0725 +units=m +no_defs  <>
 # SAD69 / Brazil Polyconic (deprecated)
 <29100> +proj=poly +lat_0=0 +lon_0=-54 +x_0=5000000 +y_0=10000000 +ellps=GRS67 +towgs84=-57,1,-41,0,0,0,0 +units=m +no_defs  <>
 # SAD69 / Brazil Polyconic
@@ -8415,7 +9247,7 @@
 # RT38 2.5 gon W (deprecated)
 <30800> +proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs  <>
 # Yoff / UTM zone 28N
-<31028> +proj=utm +zone=28 +a=6378249.2 +b=6356515 +units=m +no_defs  <>
+<31028> +proj=utm +zone=28 +a=6378249.2 +b=6356515 +towgs84=-30,190,89,0,0,0,0 +units=m +no_defs  <>
 # Zanderij / UTM zone 21N
 <31121> +proj=utm +zone=21 +ellps=intl +towgs84=-265,120,-358,0,0,0,0 +units=m +no_defs  <>
 # Zanderij / TM 54 NW
@@ -9912,6 +10744,8 @@
 <5884> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
 # CIGD11
 <6133> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
+# CGRS93
+<6309> +proj=geocent +ellps=WGS84 +units=m +no_defs  <>
 # NAD83(2011)
 <6317> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
 # NAD83(PA11)
@@ -9926,6 +10760,24 @@
 <6704> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
 # NAD83(CORS96)
 <6781> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
+# IGS08
+<6934> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
+# IGD05
+<6978> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
+# IG05 Intermediate CRS
+<6981> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
+# IGD05/12
+<6985> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
+# IG05/12 Intermediate CRS
+<6988> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
+# RGTAAF07
+<7071> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
+# IGD05
+<7134> +proj=geocent +ellps=WGS84 +units=m +no_defs  <>
+# IGD05/12
+<7137> +proj=geocent +ellps=WGS84 +units=m +no_defs  <>
+# ONGD14
+<7371> +proj=geocent +ellps=GRS80 +units=m +no_defs  <>
 # KKJ / Finland Uniform Coordinate System + N60 height
 <3901> +proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=3500000 +y_0=0 +ellps=intl +towgs84=-96.062,-82.428,-121.753,4.801,0.345,-1.376,1.496 +units=m +vunits=m +no_defs  <>
 # ETRS89 / TM35FIN(N,E) + N60 height
@@ -10178,6 +11030,12 @@
 <6700> +proj=longlat +ellps=bessel +towgs84=-146.414,507.337,680.507,0,0,0,0 +vunits=m +no_defs  <>
 # WGS 84 / Pseudo-Mercator +  EGM2008 geoid height
 <6871> +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +geoidgrids=egm08_25.gtx +vunits=m +no_defs  <>
+# WGS 84 / World Mercator +  EGM2008 height
+<6893> +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +geoidgrids=egm08_25.gtx +vunits=m +no_defs  <>
+# SVY21 + SHD height
+<6917> +proj=longlat +ellps=WGS84 +vunits=m +no_defs  <>
+# SVY21 / Singapore TM + SHD height
+<6927> +proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +units=m +vunits=m +no_defs  <>
 # NTF (Paris) + NGF IGN69 height
 <7400> +proj=longlat +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +vunits=m +no_defs  <>
 # NTF (Paris) / France II + NGF Lallemand
@@ -10195,7 +11053,7 @@
 # NAD27 / Texas North + NGVD29 height
 <7407> +proj=lcc +lat_1=34.65 +lat_2=36.18333333333333 +lat_0=34 +lon_0=-101.5 +x_0=609601.2192024384 +y_0=0 +datum=NAD27 +units=us-ft +vunits=us-ft +no_defs  <>
 # RD/NAP
-<7408> +proj=longlat +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957388243134,0.343987817378283,-1.87740163998045,4.0725 +vunits=m +no_defs  <>
+<7408> +proj=longlat +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957,0.343988,-1.87740,4.0725 +vunits=m +no_defs  <>
 # ETRS89 + EVRF2000 height
 <7409> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +vunits=m +no_defs  <>
 # PSHD93
@@ -10209,7 +11067,7 @@
 # Tokyo + JSLD69 height
 <7414> +proj=longlat +ellps=bessel +towgs84=-146.414,507.337,680.507,0,0,0,0 +vunits=m +no_defs  <>
 # Amersfoort / RD New + NAP height
-<7415> +proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957388243134,0.343987817378283,-1.87740163998045,4.0725 +units=m +vunits=m +no_defs  <>
+<7415> +proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957,0.343988,-1.87740,4.0725 +units=m +vunits=m +no_defs  <>
 # ETRS89 / UTM zone 32N + DVR90 height
 <7416> +proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +vunits=m +no_defs  <>
 # ETRS89 / UTM zone 33N + DVR90 height
diff --git a/nad/install.in b/nad/install.in
new file mode 100755
index 0000000..d60dc72
--- /dev/null
+++ b/nad/install.in
@@ -0,0 +1,53 @@
+:
+# SCCSID @(#)install.in	4.8 95/09/24 GIE REL
+#
+# Installation script all PROJ.4 system reference files.
+#
+# This script must be executed after compilation of proj library.
+#
+# Execute as:
+#
+#	install
+#
+# ------------------------------------------------------------
+prefix=/usr/local
+#
+lib=${prefix}/lib/proj.4
+# Copy in "init" files
+for x in proj_def.dat nad27 nad83 world GL27
+do
+	cp $x ${lib}/$x
+	if [ $? -ne 0 ] ; then
+		echo "init copying failed for file $x"
+	else
+		echo "file $x installed"
+	fi
+done
+# just test for conus and assume others are there
+if [ -f conus.lla ] ; then
+# install nad2nad NADCON files
+	echo "installing ${lib}/nad2783"
+	lib=${lib}/nad2783
+	if [ ! -d $lib ] ; then
+		mkdir $lib
+		if [ $? -ne 0 ] ; then
+			echo "failed to make dir $lib"
+			echo "nad2nad lib install stopped"
+			exit 1
+		fi
+	fi
+# Process ascii grid into nad2nad compatible files.
+	for x in *.lla ; do
+		dest=`expr $x : '\(.*\)\.lla'`
+		cat < $x | ../src/nad2bin ${lib}/${dest}
+		if [ $? -ne 0 ] ; then
+			echo "nad2nad file install failed on file ${lib}/${dest}"
+			exit 1
+		fi
+		echo "${lib}/${dest} installed"
+	done
+else
+	echo "nad2nad NADCON files not present"
+fi
+echo "normal completion"
+exit 0
diff --git a/nad/makefile.vc b/nad/makefile.vc
index d2bba08..287ff2c 100644
--- a/nad/makefile.vc
+++ b/nad/makefile.vc
@@ -6,7 +6,7 @@
 
 OLD_GRIDS = conus MD TN WI WO alaska hawaii prvi stgeorge stlrnc stpaul null
 
-OTHER_FILES =  GL27 nad.lst nad27 nad83 proj_def.dat world epsg esri \
+OTHER_FILES = FL GL27 nad.lst nad27 nad83 proj_def.dat world epsg esri \
 	esri.extra other.extra IGNF
 
 
diff --git a/nad/testvarious b/nad/testvarious
index 694d0d1..ef1bfbe 100755
--- a/nad/testvarious
+++ b/nad/testvarious
@@ -266,6 +266,22 @@ $EXE +proj=robin +datum=WGS84 \
 1741397.30      4276351.58 0.00
 EOF
 echo "##############################################################" >> ${OUT}
+echo "Test hammer projection (pull request #329)" >> ${OUT}
+$EXE +proj=latlong +datum=WGS84 \
+ +to +proj=hammer  +datum=WGS84 \
+ -E >>${OUT} <<EOF
+-30 40
+-35 45
+20 40
+EOF
+$EXE +proj=hammer  +datum=WGS84 \
+ +to +proj=latlong +datum=WGS84 \
+ -E >>${OUT} <<EOF
+-2711575.08	4395506.62 0.00
+-2964412.70	4929091.33 0.00
+1811748.54	4377349.50 0.00
+EOF
+echo "##############################################################" >> ${OUT}
 echo "Test healpix forward projection on sphere" >> ${OUT}
 $EXE +proj=latlong +a=1 +lon_0=0 \
  +to +proj=healpix +a=1 +lon_0=0  -f '%.'5'f' \
@@ -492,7 +508,7 @@ $EXE +proj=latlong +ellps=sphere \
 EOF
 #
 echo "##############################################################" >> ${OUT}
-echo "Test the natural earth projection" >> ${OUT}
+echo "Test the Natural Earth Projection" >> ${OUT}
 $EXE +proj=latlong +a=1 +lon_0=0 \
  +to +proj=natearth +a=6371008.7714 +b=6371008.7714 -f '%.'7'f' \
  -E >>${OUT} <<EOF
@@ -523,6 +539,68 @@ $EXE +proj=latlong +a=1 +lon_0=0 \
 180.0 90.0 0 9591912.979377454 9062062.394736718
 EOF
 echo "##############################################################" >> ${OUT}
+echo "Test the Natural Earth II Projection" >> ${OUT}
+$EXE +proj=latlong +a=1 +lon_0=0 \
+ +to +proj=natearth2 +a=6371008.7714 +b=6371008.7714 -f '%.'7'f' \
+ -E >>${OUT} <<EOF
+0.0 0.0 0 0.00000000 0.00000000
+0.0 22.5 0 0.00000000 2531453.57080958
+0.0 45.0 0 0.00000000 5051471.50086845
+0.0 67.5 0 0.00000000 7395411.22478983
+0.0 90.0 0 0.00000000 9073776.52662810
+45.0 0.0 0 4239151.18200719 0.00000000
+45.0 22.5 0 4138348.61904244 2531453.57080958
+45.0 45.0 0 3830621.33880773 5051471.50086845
+45.0 67.5 0 3158326.32836996 7395411.22478983
+45.0 90.0 0 957973.37034235 9073776.52662810
+90.0 0.0 0 8478302.36401439 0.00000000
+90.0 22.5 0 8276697.23808488 2531453.57080958
+90.0 45.0 0 7661242.67761547 5051471.50086845
+90.0 67.5 0 6316652.65673992 7395411.22478983
+90.0 90.0 0 1915946.74068470 9073776.52662810
+135.0 0.0 0 12717453.54602160 0.00000000
+135.0 22.5 0 12415045.85712730 2531453.57080958
+135.0 45.0 0 11491864.01642320 5051471.50086845
+135.0 67.5 0 9474978.98510988 7395411.22478983
+135.0 90.0 0 2873920.11102705 9073776.52662810
+180.0 0.0 0 16956604.72802880 0.00000000
+180.0 22.5 0 16553394.47616980 2531453.57080958
+180.0 45.0 0 15322485.35523090 5051471.50086845
+180.0 67.5 0 12633305.31347990 7395411.22478983
+180.0 90.0 0 3831893.48136940 9073776.52662810
+EOF
+echo "##############################################################" >> ${OUT}
+echo "Test the Compact Miller projection" >> ${OUT}
+$EXE +proj=latlong +a=1 +lon_0=0 \
+ +to +proj=comill +a=6371008.7714 +b=6371008.7714 -f '%.'7'f' \
+ -E >>${OUT} <<EOF
+0.0 0.0 0 0.0 0.0
+0.0 22.5 0 0.0 2537439.6610749415
+0.0 45.0 0 0.0 5391682.432264133
+0.0 67.5 0 0.0 8661480.510260897
+0.0 90.0 0 0.0 12009484.264916677
+45.0 0.0 0 5003778.588046594 0.0
+45.0 22.5 0 5003778.588046594 2537439.6610749415
+45.0 45.0 0 5003778.588046594 5391682.432264133
+45.0 67.5 0 5003778.588046594 8661480.510260897
+45.0 90.0 0 5003778.588046594 12009484.264916677
+90.0 0.0 0 10007557.176093187 0.0
+90.0 22.5 0 10007557.176093187 2537439.6610749415
+90.0 45.0 0 10007557.176093187 5391682.432264133
+90.0 67.5 0 10007557.176093187 8661480.510260897
+90.0 90.0 0 10007557.176093187 12009484.264916677
+135.0 0.0 0 15011335.76413978 0.0
+135.0 22.5 0 15011335.76413978 2537439.6610749415
+135.0 45.0 0 15011335.76413978 5391682.432264133
+135.0 67.5 0 15011335.76413978 8661480.510260897
+135.0 90.0 0 15011335.76413978 12009484.264916677
+180.0 0.0 0 20015114.352186374 0.0
+180.0 22.5 0 20015114.352186374 2537439.6610749415
+180.0 45.0 0 20015114.352186374 5391682.432264133
+180.0 67.5 0 20015114.352186374 8661480.510260897
+180.0 90.0 0 20015114.352186374 12009484.264916677
+EOF
+echo "##############################################################" >> ${OUT}
 echo "Test pconic (#148)" >> ${OUT}
 #
 $EXE +proj=latlong +datum=WGS84 \
@@ -656,7 +734,7 @@ EOF
 echo "##############################################################" >> ${OUT}
 echo "Test bug 244 " >> ${OUT}
 #
-$EXE -f '%.12f' \
+$EXE -f '%.8f' \
      +init=epsg:4326 \
      +to +proj=aeqd +lon_0=130.0 +lat_0=40.0 +a=6378137 +b=6378137 +units=m +no_defs \
  -E >>${OUT} <<EOF
@@ -665,29 +743,148 @@ EOF
 echo "##############################################################" >> ${OUT}
 echo "Test bug 244 (2)" >> ${OUT}
 #
-$EXE -f '%.12f' \
+$EXE -f '%.11f' \
      +proj=aeqd +lon_0=130.0 +lat_0=40.0 +a=6378137 +b=6378137 +units=m +no_defs \
      +to +init=epsg:4326 \
  -E >>${OUT} <<EOF
-987122.4183302754536 -14429896.5395309105515
+987122.418330284 -14429896.539530909
 EOF
 echo "##############################################################" >> ${OUT}
 echo "Test bug 245 (use +datum=carthage)" >> ${OUT}
 #
 $EXE -f '%.7f' \
-     +proj=longlat +datum=WGS84 +nodefs +to +proj=utm +zone=32 +datum=carthage +nodefs \
+     +proj=longlat +datum=WGS84 +no_defs +to +proj=utm +zone=32 +datum=carthage +no_defs \
  -E >>${OUT} <<EOF
 10 34
 EOF
 echo "##############################################################" >> ${OUT}
-echo "Test bug 245 (use expension of +datum=carthage)" >> ${OUT}
+echo "Test bug 245 (use expansion of +datum=carthage)" >> ${OUT}
 #
 $EXE -f '%.7f' \
-     +proj=longlat +datum=WGS84 +nodefs +to +proj=utm +zone=32 +a=6378249.2 +b=6356515 +towgs84=-263.0,6.0,431.0 +nodefs \
+     +proj=longlat +datum=WGS84 +no_defs +to +proj=utm +zone=32 +a=6378249.2 +b=6356515 +towgs84=-263.0,6.0,431.0 +no_defs \
  -E >>${OUT} <<EOF
 10 34
 EOF
+echo  "##############################################################" >> ${OUT}
+echo  "Test SCH forward projection" >> ${OUT}
+#
+$EXE -f '%.7f' \
+    +proj=latlong +datum=WGS84 +to +proj=sch +datum=WGS84 +plat_0=30.0 +plon_0=45.0 \
+    +phdg_0=-12.0 +nodefs \
+ -E >> ${OUT} <<EOF
+0.0 0.0
+0.0 90.0
+45.0 45.0
+45.1 44.9
+44.9 45.1
+30.0 45.0
+EOF
+echo  "##############################################################" >> ${OUT}
+echo  "Test SCH inverse projection" >> ${OUT}
+#
+$EXE -f '%.7f' \
+    +proj=sch +datum=WGS84 +plat_0=30.0 +plon_0=45.0 +phdg_0=-12.0 +nodefs +to \
+    +proj=latlong +datum=WGS84 \
+ -E >> ${OUT} <<EOF
+0. 0.
+0. 1000.
+1000. 0.
+1000. 1000.
+EOF
 ##############################################################################
+echo "##############################################################" >> ${OUT}
+echo "Test issue #316 (switch utm to use etmerc)" >> ${OUT}
+#
+$EXE -f '%.6f' \
+     +proj=latlong +datum=WGS84 +no_defs +to +proj=utm +zone=35 +datum=WGS84 +no_defs \
+ -E >>${OUT} <<EOF
+0 83
+EOF
+##############################################################################
+echo "##############################################################" >> ${OUT}
+echo "Test issue #316 (switch utm to use etmerc)" >> ${OUT}
+#
+$EXE -f '%.6f' \
+     +proj=latlong +datum=WGS84 +no_defs +to +proj=etmerc +datum=WGS84 +no_defs +k=0.9996 +lon_0=27 +x_0=500000 -f %.6f \
+ -E >>${OUT} <<EOF
+0 83
+EOF
+##############################################################################
+echo  "##############################################################" >> ${OUT}
+echo  "Test nzmg forward projection" >> ${OUT}
+#
+$EXE -f '%.7f' \
+    +proj=latlong +datum=WGS84 +to \
+    +proj=nzmg +lat_0=-41 +lon_0=173 +x_0=2510000 +y_0=6023150 +ellps=WGS84 +units=m +no_defs \
+ -E >> ${OUT} <<EOF
+175. -40. 0.
+EOF
+##############################################################################
+echo  "##############################################################" >> ${OUT}
+echo  "Test nzmg inverse projection" >> ${OUT}
+#
+$EXE -f '%.7f' \
+    +proj=nzmg +lat_0=-41 +lon_0=173 +x_0=2510000 +y_0=6023150 +ellps=WGS84 +units=m +no_defs +to \
+    +proj=latlong +datum=WGS84 \
+ -E >> ${OUT} <<EOF
+2680778.57267967 6132228.07645127 0.
+EOF
+##############################################################################
+echo  "##############################################################" >> ${OUT}
+echo  "Test misrsom forward projection" >> ${OUT}
+#
+$EXE -f '%.7f' \
+    +proj=latlong +datum=WGS84 +no_defs +to \
+    +proj=misrsom +path=41 +ellps=WGS84 +units=m \
+ -E >> ${OUT} <<EOF
+48.64966165540372 66.2263195368941 0.
+EOF
+##############################################################################
+echo  "##############################################################" >> ${OUT}
+echo  "Test misrsom inverse projection" >> ${OUT}
+#
+$EXE -f '%.7f' \
+    +proj=misrsom +path=41 +ellps=WGS84 +units=m +no_defs +to \
+    +proj=latlong +datum=WGS84 -f '%0.7f' \
+ -E >> ${OUT} <<EOF
+7461300.0 528000.0 0.0
+EOF
+echo  "##############################################################" >> ${OUT}
+echo  "Test patterson forward projection" >> ${OUT}
+#
+$EXE -f '%0.8f' \
+    +proj=latlong +datum=WGS84 \
+    +to +proj=patterson +a=6371008.7714 +b=6371008.7714 +units=m \
+ -E >> ${OUT} <<EOF
+-180 90
+-135 67.5
+-90 45
+-45 22.5
+0 0
+45 -22.5
+90 -45
+135 -67.5
+180 -90
+EOF
+echo  "##############################################################" >> ${OUT}
+echo  "Test patterson inverse projection" >> ${OUT}
+#
+$EXE -f '%0.3f' \
+    +proj=patterson +a=6371008.7714 +b=6371008.7714 +units=m \
+    +to +proj=latlong +datum=WGS84 \
+ -E >> ${OUT} <<EOF
+-20015114.352186374 11409566.822831295
+-15011335.76413978 8729502.054111844
+-10007557.176093187 5366413.421153781
+-5003778.588046594 2551415.729669344
+0.0 0.0
+5003778.588046594 -2551415.729669344
+10007557.176093187 -5366413.421153781
+15011335.76413978 -8729502.054111844
+20015114.352186374 -11409566.822831295
+EOF
+
+
 # Done!
 # do 'diff' with distribution results
 echo "diff ${OUT} with ${OUT}.dist"
diff --git a/nad/tv_out.dist b/nad/tv_out.dist
index d36ab5b..28b1562 100644
--- a/nad/tv_out.dist
+++ b/nad/tv_out.dist
@@ -20,8 +20,8 @@ Test simple prime meridian handling.
 ##############################################################
 Test support for the lon_wrap switch.
 1d00'00.000"W 10d00'00.000"N 0.0	359dE	10dN 0.000
-0d00'00.000"W 10d00'00.000"N 0.0	360dE	10dN 0.000
-0d00'00.000"E 10d00'00.000"N 0.0	360dE	10dN 0.000
+0d00'00.000"W 10d00'00.000"N 0.0	0dE	10dN 0.000
+0d00'00.000"E 10d00'00.000"N 0.0	0dE	10dN 0.000
 1d00'00.000"E 45d00'00.000"N 0.0	1dE	45dN 0.000
 179d00'00.000"E 45d00'00.000"N 0.0	179dE	45dN 0.000
 181d00'00.000"E 45d00'00.000"N 0.0	181dE	45dN 0.000
@@ -92,6 +92,14 @@ Test robinson projection (#113)
 -2963455.42     4805073.65 0.00	35dW	45dN 0.000
 1741397.30      4276351.58 0.00	20d0'0.002"E	40d0'0.066"N 0.000
 ##############################################################
+Test hammer projection (pull request #329)
+-30 40	-2711575.08	4395506.62 0.00
+-35 45	-2964412.70	4929091.33 0.00
+20 40	1811748.54	4377349.50 0.00
+-2711575.08	4395506.62 0.00	30dW	40dN 0.000
+-2964412.70	4929091.33 0.00	35dW	45dN 0.000
+1811748.54	4377349.50 0.00	20dE	40dN 0.000
+##############################################################
 Test healpix forward projection on sphere
 0 41.81031	0.00000	0.78540 0.00000
 -90 0	-1.57080	0.00000 0.00000
@@ -101,8 +109,8 @@ Test healpix forward projection on sphere
 90.0 0	7.85398	0.00000 0.00000
 -90.0 0	-7.85398	0.00000 0.00000
 -180 0	-15.70796	0.00000 0.00000
--180 90.0	-19.63495	7.85398 0.00000
--180 -90.0	-19.63495	-7.85398 0.00000
+-180 90.0	-11.78097	7.85398 0.00000
+-180 -90.0	-11.78097	-7.85398 0.00000
 0 60.0	1.43738	5.36437 0.00000
 0 -60.0	1.43738	-5.36437 0.00000
 Test healpix forward projection on ellipsoid
@@ -114,8 +122,8 @@ Test healpix forward projection on ellipsoid
 90.0 0	6.78898	0.00000 0.00000
 -90.0 0	-6.78898	0.00000 0.00000
 -180 0	-13.57797	0.00000 0.00000
--180 90.0	-16.97246	6.78898 0.00000
--180 -90.0	-16.97246	-6.78898 0.00000
+-180 90.0	-10.18348	6.78898 0.00000
+-180 -90.0	-10.18348	-6.78898 0.00000
 0 60.0	0.00000	3.35128 0.00000
 0 -60.0	0.00000	-3.35128 0.00000
 Test healpix inverse projection on ellipsoid
@@ -228,7 +236,7 @@ Test inv geos on a ellipsoid with alternate sweep
 1605067.15 -3400461.47	18d25'26"E	33d55'31"S 0.000
 3820138.08 2888664.15	47d58'42"E	29d22'11"N 0.000
 ##############################################################
-Test the natural earth projection
+Test the Natural Earth Projection
 0.0 0.0 0	0.0000000	0.0000000 0.0000000 0.0 0.0
 0.0 22.5 0	0.0000000	2525419.5693838 0.0000000 0.0 2525419.569383768
 0.0 45.0 0	0.0000000	5052537.3899732 0.0000000 0.0 5052537.389973222
@@ -255,6 +263,60 @@ Test the natural earth projection
 180.0 67.5 0	13419749.8846233	7400065.6562574 0.0000000 1.341974988462332E7 7400065.6562573705
 180.0 90.0 0	9591912.9793775	9062062.3947367 0.0000000 9591912.979377454 9062062.394736718
 ##############################################################
+Test the Natural Earth II Projection
+0.0 0.0 0	0.0000000	0.0000000 0.0000000 0.00000000 0.00000000
+0.0 22.5 0	0.0000000	2531453.5708096 0.0000000 0.00000000 2531453.57080958
+0.0 45.0 0	0.0000000	5051471.5008684 0.0000000 0.00000000 5051471.50086845
+0.0 67.5 0	0.0000000	7395411.2247898 0.0000000 0.00000000 7395411.22478983
+0.0 90.0 0	0.0000000	9073776.5266281 0.0000000 0.00000000 9073776.52662810
+45.0 0.0 0	4239151.1820072	0.0000000 0.0000000 4239151.18200719 0.00000000
+45.0 22.5 0	4138348.6190424	2531453.5708096 0.0000000 4138348.61904244 2531453.57080958
+45.0 45.0 0	3830621.3388077	5051471.5008684 0.0000000 3830621.33880773 5051471.50086845
+45.0 67.5 0	3158326.3283700	7395411.2247898 0.0000000 3158326.32836996 7395411.22478983
+45.0 90.0 0	957973.3703423	9073776.5266281 0.0000000 957973.37034235 9073776.52662810
+90.0 0.0 0	8478302.3640144	0.0000000 0.0000000 8478302.36401439 0.00000000
+90.0 22.5 0	8276697.2380849	2531453.5708096 0.0000000 8276697.23808488 2531453.57080958
+90.0 45.0 0	7661242.6776155	5051471.5008684 0.0000000 7661242.67761547 5051471.50086845
+90.0 67.5 0	6316652.6567399	7395411.2247898 0.0000000 6316652.65673992 7395411.22478983
+90.0 90.0 0	1915946.7406847	9073776.5266281 0.0000000 1915946.74068470 9073776.52662810
+135.0 0.0 0	12717453.5460216	0.0000000 0.0000000 12717453.54602160 0.00000000
+135.0 22.5 0	12415045.8571273	2531453.5708096 0.0000000 12415045.85712730 2531453.57080958
+135.0 45.0 0	11491864.0164232	5051471.5008684 0.0000000 11491864.01642320 5051471.50086845
+135.0 67.5 0	9474978.9851099	7395411.2247898 0.0000000 9474978.98510988 7395411.22478983
+135.0 90.0 0	2873920.1110270	9073776.5266281 0.0000000 2873920.11102705 9073776.52662810
+180.0 0.0 0	16956604.7280288	0.0000000 0.0000000 16956604.72802880 0.00000000
+180.0 22.5 0	16553394.4761698	2531453.5708096 0.0000000 16553394.47616980 2531453.57080958
+180.0 45.0 0	15322485.3552309	5051471.5008684 0.0000000 15322485.35523090 5051471.50086845
+180.0 67.5 0	12633305.3134798	7395411.2247898 0.0000000 12633305.31347990 7395411.22478983
+180.0 90.0 0	3831893.4813694	9073776.5266281 0.0000000 3831893.48136940 9073776.52662810
+##############################################################
+Test the Compact Miller projection
+0.0 0.0 0	0.0000000	0.0000000 0.0000000 0.0 0.0
+0.0 22.5 0	0.0000000	2537439.6610749 0.0000000 0.0 2537439.6610749415
+0.0 45.0 0	0.0000000	5391682.4322641 0.0000000 0.0 5391682.432264133
+0.0 67.5 0	0.0000000	8661480.5102609 0.0000000 0.0 8661480.510260897
+0.0 90.0 0	0.0000000	12009484.2649167 0.0000000 0.0 12009484.264916677
+45.0 0.0 0	5003778.5880466	0.0000000 0.0000000 5003778.588046594 0.0
+45.0 22.5 0	5003778.5880466	2537439.6610749 0.0000000 5003778.588046594 2537439.6610749415
+45.0 45.0 0	5003778.5880466	5391682.4322641 0.0000000 5003778.588046594 5391682.432264133
+45.0 67.5 0	5003778.5880466	8661480.5102609 0.0000000 5003778.588046594 8661480.510260897
+45.0 90.0 0	5003778.5880466	12009484.2649167 0.0000000 5003778.588046594 12009484.264916677
+90.0 0.0 0	10007557.1760932	0.0000000 0.0000000 10007557.176093187 0.0
+90.0 22.5 0	10007557.1760932	2537439.6610749 0.0000000 10007557.176093187 2537439.6610749415
+90.0 45.0 0	10007557.1760932	5391682.4322641 0.0000000 10007557.176093187 5391682.432264133
+90.0 67.5 0	10007557.1760932	8661480.5102609 0.0000000 10007557.176093187 8661480.510260897
+90.0 90.0 0	10007557.1760932	12009484.2649167 0.0000000 10007557.176093187 12009484.264916677
+135.0 0.0 0	15011335.7641398	0.0000000 0.0000000 15011335.76413978 0.0
+135.0 22.5 0	15011335.7641398	2537439.6610749 0.0000000 15011335.76413978 2537439.6610749415
+135.0 45.0 0	15011335.7641398	5391682.4322641 0.0000000 15011335.76413978 5391682.432264133
+135.0 67.5 0	15011335.7641398	8661480.5102609 0.0000000 15011335.76413978 8661480.510260897
+135.0 90.0 0	15011335.7641398	12009484.2649167 0.0000000 15011335.76413978 12009484.264916677
+180.0 0.0 0	20015114.3521864	0.0000000 0.0000000 20015114.352186374 0.0
+180.0 22.5 0	20015114.3521864	2537439.6610749 0.0000000 20015114.352186374 2537439.6610749415
+180.0 45.0 0	20015114.3521864	5391682.4322641 0.0000000 20015114.352186374 5391682.432264133
+180.0 67.5 0	20015114.3521864	8661480.5102609 0.0000000 20015114.352186374 8661480.510260897
+180.0 90.0 0	20015114.3521864	12009484.2649167 0.0000000 20015114.352186374 12009484.264916677
+##############################################################
 Test pconic (#148)
 -70.4 -23.65	-2240096.40	-6940342.15 0.00
 -2240096.40 -6940342.15	70d24'W	23d39'S 0.000
@@ -307,13 +369,67 @@ Test bug 229 (2)
 13 -10	13.0000000000000	-10.0000000000000 0.0000000000000
 ##############################################################
 Test bug 244 
--140.100000 -87.000000	987122.418330275454	-14429896.539530910552 0.000000000000
+-140.100000 -87.000000	987122.41833028	-14429896.53953091 0.00000000
 ##############################################################
 Test bug 244 (2)
-987122.4183302754536 -14429896.5395309105515	-140.100000000000	-87.000000000000 0.000000000000
+987122.418330284 -14429896.539530909	-140.10000000000	-87.00000000000 0.00000000000
 ##############################################################
 Test bug 245 (use +datum=carthage)
-10 34	592302.9819462	3762148.7340610 -30.3110170
-##############################################################
-Test bug 245 (use expension of +datum=carthage)
-10 34	592302.9819462	3762148.7340610 -30.3110170
+10 34	592302.9819461	3762148.7340609 -30.3110170
+##############################################################
+Test bug 245 (use expansion of +datum=carthage)
+10 34	592302.9819461	3762148.7340609 -30.3110170
+##############################################################
+Test SCH forward projection
+0.0 0.0	-1977112.0305592	5551475.1418378 6595.7256583
+0.0 90.0	6618337.9734775	-1152927.4060894 10055.1157181
+45.0 45.0	1630035.5650122	-342353.6396475 128.3445654
+45.1 44.9	1617547.4295637	-347855.9734973 125.4645102
+44.9 45.1	1642526.7453121	-336878.8571851 131.3265616
+30.0 45.0	1974596.2356203	787409.8217445 773.0028577
+##############################################################
+Test SCH inverse projection
+0. 0.	45.0000000	30.0000000 0.0000000
+0. 1000.	44.9898625	29.9981240 -0.0003617
+1000. 0.	44.9978450	30.0088238 -0.0000000
+1000. 1000.	44.9877066	30.0069477 -0.0005228
+##############################################################
+Test issue #316 (switch utm to use etmerc)
+0 83	145723.870553	9300924.845226 0.000000
+##############################################################
+Test issue #316 (switch utm to use etmerc)
+0 83	145723.870553	9300924.845226 0.000000
+##############################################################
+Test nzmg forward projection
+175. -40. 0.	2680778.5726797	6132228.0764513 0.0000000
+##############################################################
+Test nzmg inverse projection
+2680778.57267967 6132228.07645127 0.	175.0000000	-40.0000000 0.0000000
+##############################################################
+Test misrsom forward projection
+48.64966165540372 66.2263195368941 0.	7461299.8819401	528000.0550107 0.0000000
+##############################################################
+Test misrsom inverse projection
+7461300.0 528000.0 0.0	48.6496622	66.2263207 0.0000000
+##############################################################
+Test patterson forward projection
+-180 90	-20015114.35218637	11409566.82283130 0.00000000
+-135 67.5	-15011335.76413978	8729502.05411184 0.00000000
+-90 45	-10007557.17609319	5366413.42115378 0.00000000
+-45 22.5	-5003778.58804659	2551415.72966934 0.00000000
+0 0	0.00000000	0.00000000 0.00000000
+45 -22.5	5003778.58804659	-2551415.72966934 0.00000000
+90 -45	10007557.17609319	-5366413.42115378 0.00000000
+135 -67.5	15011335.76413978	-8729502.05411184 0.00000000
+180 -90	20015114.35218637	-11409566.82283130 0.00000000
+##############################################################
+Test patterson inverse projection
+-20015114.352186374 11409566.822831295	-180.000	90.000 0.000
+-15011335.76413978 8729502.054111844	-135.000	67.500 0.000
+-10007557.176093187 5366413.421153781	-90.000	45.000 0.000
+-5003778.588046594 2551415.729669344	-45.000	22.500 0.000
+0.0 0.0	0.000	0.000 0.000
+5003778.588046594 -2551415.729669344	45.000	-22.500 0.000
+10007557.176093187 -5366413.421153781	90.000	-45.000 0.000
+15011335.76413978 -8729502.054111844	135.000	-67.500 0.000
+20015114.352186374 -11409566.822831295	180.000	-90.000 0.000
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index aba5b4c..8d7e7d1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -32,6 +32,7 @@ endif(BUILD_PROJ)
 
 if(BUILD_GEOD)
   include(bin_geod.cmake)
+  include(bin_geodtest.cmake)
 endif(BUILD_GEOD)
 
 if(BUILD_NAD2BIN)
diff --git a/src/Makefile.am b/src/Makefile.am
index 3344a7e..c048ad7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,7 +3,7 @@ AM_CFLAGS = @C_WFLAGS@
 bin_PROGRAMS =	proj nad2bin geod cs2cs
 EXTRA_PROGRAMS = multistresstest test228
 
-INCLUDES =	-DPROJ_LIB=\"$(pkgdatadir)\" \
+AM_CPPFLAGS =	-DPROJ_LIB=\"$(pkgdatadir)\" \
 		-DMUTEX_ at MUTEX_SETTING@ @JNI_INCLUDE@
 
 include_HEADERS = proj_api.h projects.h geodesic.h \
@@ -29,7 +29,7 @@ test228_LDADD = libproj.la @THREAD_LIB@
 
 lib_LTLIBRARIES = libproj.la
 
-libproj_la_LDFLAGS = -no-undefined -version-info 10:0:1
+libproj_la_LDFLAGS = -no-undefined -version-info 12:0:0
 
 libproj_la_SOURCES = \
 	pj_list.h \
@@ -39,7 +39,7 @@ libproj_la_SOURCES = \
 	PJ_imw_p.c PJ_krovak.c PJ_lcc.c PJ_poly.c \
 	PJ_rpoly.c PJ_sconics.c proj_rouss.c \
 	PJ_cass.c PJ_cc.c PJ_cea.c PJ_eqc.c \
-	PJ_gall.c PJ_labrd.c PJ_lsat.c PJ_merc.c \
+	PJ_gall.c PJ_labrd.c PJ_lsat.c PJ_misrsom.c PJ_merc.c \
 	PJ_mill.c PJ_ocea.c PJ_omerc.c PJ_somerc.c \
 	PJ_tcc.c PJ_tcea.c PJ_tmerc.c \
 	PJ_airy.c PJ_aitoff.c PJ_august.c PJ_bacon.c \
@@ -47,24 +47,25 @@ libproj_la_SOURCES = \
 	PJ_lask.c PJ_nocol.c PJ_ob_tran.c PJ_oea.c \
 	PJ_tpeqd.c PJ_vandg.c PJ_vandg2.c PJ_vandg4.c \
 	PJ_wag7.c PJ_lcca.c PJ_geos.c proj_etmerc.c \
-	PJ_boggs.c PJ_collg.c PJ_crast.c PJ_denoy.c \
+	PJ_boggs.c PJ_collg.c PJ_comill.c PJ_crast.c PJ_denoy.c \
 	PJ_eck1.c PJ_eck2.c PJ_eck3.c PJ_eck4.c \
 	PJ_eck5.c PJ_fahey.c PJ_fouc_s.c PJ_gins8.c PJ_gstmerc.c \
 	PJ_gn_sinu.c PJ_goode.c PJ_igh.c PJ_hatano.c PJ_loxim.c \
 	PJ_mbt_fps.c PJ_mbtfpp.c PJ_mbtfpq.c PJ_moll.c \
-	PJ_nell.c PJ_nell_h.c PJ_putp2.c PJ_putp3.c \
+	PJ_nell.c PJ_nell_h.c PJ_patterson.c PJ_putp2.c PJ_putp3.c \
 	PJ_putp4p.c PJ_putp5.c PJ_putp6.c PJ_qsc.c PJ_robin.c \
-	PJ_sts.c PJ_urm5.c PJ_urmfps.c PJ_wag2.c \
+	PJ_sch.c PJ_sts.c PJ_urm5.c PJ_urmfps.c PJ_wag2.c \
 	PJ_wag3.c PJ_wink1.c PJ_wink2.c pj_latlong.c pj_geocent.c \
 	aasincos.c adjlon.c bch2bps.c bchgen.c \
 	biveval.c dmstor.c mk_cheby.c pj_auth.c \
 	pj_deriv.c pj_ell_set.c pj_ellps.c pj_errno.c \
-	pj_factors.c pj_fwd.c pj_init.c pj_inv.c \
+	pj_factors.c pj_fwd.c pj_init.c pj_inv.c pj_fwd3d.c pj_inv3d.c\
 	pj_list.c pj_malloc.c pj_mlfn.c pj_msfn.c proj_mdist.c \
 	pj_open_lib.c pj_param.c pj_phi2.c pj_pr_list.c \
-	pj_qsfn.c pj_strerrno.c pj_tsfn.c pj_units.c pj_ctx.c pj_log.c \
-	pj_zpoly1.c rtodms.c vector1.c pj_release.c pj_gauss.c \
-	PJ_healpix.c PJ_natearth.c PJ_calcofi.c pj_fileapi.c \
+	pj_qsfn.c pj_generic_selftest.c pj_run_selftests.c pj_strerrno.c \
+	pj_tsfn.c pj_units.c pj_ctx.c pj_log.c pj_zpoly1.c rtodms.c \
+	vector1.c pj_release.c pj_gauss.c \
+	PJ_healpix.c PJ_natearth.c PJ_natearth2.c PJ_calcofi.c pj_fileapi.c \
 	\
 	pj_gc_reader.c pj_gridcatalog.c \
 	nad_cvt.c nad_init.c nad_intr.c emess.c emess.h \
diff --git a/src/Makefile.in b/src/Makefile.in
index fbc3b76..3b1ee65 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,17 @@
 
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -84,17 +94,16 @@ bin_PROGRAMS = proj$(EXEEXT) nad2bin$(EXEEXT) geod$(EXEEXT) \
 	cs2cs$(EXEEXT)
 EXTRA_PROGRAMS = multistresstest$(EXEEXT) test228$(EXEEXT)
 subdir = src
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(srcdir)/proj_config.h.in $(top_srcdir)/mkinstalldirs \
-	$(top_srcdir)/depcomp $(include_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
 	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+DIST_COMMON = $(srcdir)/Makefile.am $(include_HEADERS) \
+	$(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = proj_config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
@@ -135,34 +144,36 @@ am_libproj_la_OBJECTS = PJ_aeqd.lo PJ_gnom.lo PJ_laea.lo \
 	PJ_isea.lo PJ_imw_p.lo PJ_krovak.lo PJ_lcc.lo PJ_poly.lo \
 	PJ_rpoly.lo PJ_sconics.lo proj_rouss.lo PJ_cass.lo PJ_cc.lo \
 	PJ_cea.lo PJ_eqc.lo PJ_gall.lo PJ_labrd.lo PJ_lsat.lo \
-	PJ_merc.lo PJ_mill.lo PJ_ocea.lo PJ_omerc.lo PJ_somerc.lo \
-	PJ_tcc.lo PJ_tcea.lo PJ_tmerc.lo PJ_airy.lo PJ_aitoff.lo \
-	PJ_august.lo PJ_bacon.lo PJ_chamb.lo PJ_hammer.lo PJ_lagrng.lo \
-	PJ_larr.lo PJ_lask.lo PJ_nocol.lo PJ_ob_tran.lo PJ_oea.lo \
-	PJ_tpeqd.lo PJ_vandg.lo PJ_vandg2.lo PJ_vandg4.lo PJ_wag7.lo \
-	PJ_lcca.lo PJ_geos.lo proj_etmerc.lo PJ_boggs.lo PJ_collg.lo \
-	PJ_crast.lo PJ_denoy.lo PJ_eck1.lo PJ_eck2.lo PJ_eck3.lo \
-	PJ_eck4.lo PJ_eck5.lo PJ_fahey.lo PJ_fouc_s.lo PJ_gins8.lo \
-	PJ_gstmerc.lo PJ_gn_sinu.lo PJ_goode.lo PJ_igh.lo PJ_hatano.lo \
-	PJ_loxim.lo PJ_mbt_fps.lo PJ_mbtfpp.lo PJ_mbtfpq.lo PJ_moll.lo \
-	PJ_nell.lo PJ_nell_h.lo PJ_putp2.lo PJ_putp3.lo PJ_putp4p.lo \
-	PJ_putp5.lo PJ_putp6.lo PJ_qsc.lo PJ_robin.lo PJ_sts.lo \
-	PJ_urm5.lo PJ_urmfps.lo PJ_wag2.lo PJ_wag3.lo PJ_wink1.lo \
-	PJ_wink2.lo pj_latlong.lo pj_geocent.lo aasincos.lo adjlon.lo \
-	bch2bps.lo bchgen.lo biveval.lo dmstor.lo mk_cheby.lo \
-	pj_auth.lo pj_deriv.lo pj_ell_set.lo pj_ellps.lo pj_errno.lo \
-	pj_factors.lo pj_fwd.lo pj_init.lo pj_inv.lo pj_list.lo \
-	pj_malloc.lo pj_mlfn.lo pj_msfn.lo proj_mdist.lo \
-	pj_open_lib.lo pj_param.lo pj_phi2.lo pj_pr_list.lo pj_qsfn.lo \
-	pj_strerrno.lo pj_tsfn.lo pj_units.lo pj_ctx.lo pj_log.lo \
-	pj_zpoly1.lo rtodms.lo vector1.lo pj_release.lo pj_gauss.lo \
-	PJ_healpix.lo PJ_natearth.lo PJ_calcofi.lo pj_fileapi.lo \
-	pj_gc_reader.lo pj_gridcatalog.lo nad_cvt.lo nad_init.lo \
-	nad_intr.lo emess.lo pj_apply_gridshift.lo pj_datums.lo \
-	pj_datum_set.lo pj_transform.lo geocent.lo pj_utils.lo \
-	pj_gridinfo.lo pj_gridlist.lo jniproj.lo pj_mutex.lo \
-	pj_initcache.lo pj_apply_vgridshift.lo geodesic.lo \
-	pj_strtod.lo
+	PJ_misrsom.lo PJ_merc.lo PJ_mill.lo PJ_ocea.lo PJ_omerc.lo \
+	PJ_somerc.lo PJ_tcc.lo PJ_tcea.lo PJ_tmerc.lo PJ_airy.lo \
+	PJ_aitoff.lo PJ_august.lo PJ_bacon.lo PJ_chamb.lo PJ_hammer.lo \
+	PJ_lagrng.lo PJ_larr.lo PJ_lask.lo PJ_nocol.lo PJ_ob_tran.lo \
+	PJ_oea.lo PJ_tpeqd.lo PJ_vandg.lo PJ_vandg2.lo PJ_vandg4.lo \
+	PJ_wag7.lo PJ_lcca.lo PJ_geos.lo proj_etmerc.lo PJ_boggs.lo \
+	PJ_collg.lo PJ_comill.lo PJ_crast.lo PJ_denoy.lo PJ_eck1.lo \
+	PJ_eck2.lo PJ_eck3.lo PJ_eck4.lo PJ_eck5.lo PJ_fahey.lo \
+	PJ_fouc_s.lo PJ_gins8.lo PJ_gstmerc.lo PJ_gn_sinu.lo \
+	PJ_goode.lo PJ_igh.lo PJ_hatano.lo PJ_loxim.lo PJ_mbt_fps.lo \
+	PJ_mbtfpp.lo PJ_mbtfpq.lo PJ_moll.lo PJ_nell.lo PJ_nell_h.lo \
+	PJ_patterson.lo PJ_putp2.lo PJ_putp3.lo PJ_putp4p.lo \
+	PJ_putp5.lo PJ_putp6.lo PJ_qsc.lo PJ_robin.lo PJ_sch.lo \
+	PJ_sts.lo PJ_urm5.lo PJ_urmfps.lo PJ_wag2.lo PJ_wag3.lo \
+	PJ_wink1.lo PJ_wink2.lo pj_latlong.lo pj_geocent.lo \
+	aasincos.lo adjlon.lo bch2bps.lo bchgen.lo biveval.lo \
+	dmstor.lo mk_cheby.lo pj_auth.lo pj_deriv.lo pj_ell_set.lo \
+	pj_ellps.lo pj_errno.lo pj_factors.lo pj_fwd.lo pj_init.lo \
+	pj_inv.lo pj_fwd3d.lo pj_inv3d.lo pj_list.lo pj_malloc.lo \
+	pj_mlfn.lo pj_msfn.lo proj_mdist.lo pj_open_lib.lo pj_param.lo \
+	pj_phi2.lo pj_pr_list.lo pj_qsfn.lo pj_generic_selftest.lo \
+	pj_run_selftests.lo pj_strerrno.lo pj_tsfn.lo pj_units.lo \
+	pj_ctx.lo pj_log.lo pj_zpoly1.lo rtodms.lo vector1.lo \
+	pj_release.lo pj_gauss.lo PJ_healpix.lo PJ_natearth.lo \
+	PJ_natearth2.lo PJ_calcofi.lo pj_fileapi.lo pj_gc_reader.lo \
+	pj_gridcatalog.lo nad_cvt.lo nad_init.lo nad_intr.lo emess.lo \
+	pj_apply_gridshift.lo pj_datums.lo pj_datum_set.lo \
+	pj_transform.lo geocent.lo pj_utils.lo pj_gridinfo.lo \
+	pj_gridlist.lo jniproj.lo pj_mutex.lo pj_initcache.lo \
+	pj_apply_vgridshift.lo geodesic.lo pj_strtod.lo
 libproj_la_OBJECTS = $(am_libproj_la_OBJECTS)
 AM_V_lt = $(am__v_lt_ at AM_V@)
 am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
@@ -258,6 +269,8 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/proj_config.h.in \
+	$(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -300,7 +313,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -379,7 +392,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AM_CFLAGS = @C_WFLAGS@
-INCLUDES = -DPROJ_LIB=\"$(pkgdatadir)\" \
+AM_CPPFLAGS = -DPROJ_LIB=\"$(pkgdatadir)\" \
 		-DMUTEX_ at MUTEX_SETTING@ @JNI_INCLUDE@
 
 include_HEADERS = proj_api.h projects.h geodesic.h \
@@ -402,7 +415,7 @@ geod_LDADD = libproj.la
 multistresstest_LDADD = libproj.la @THREAD_LIB@
 test228_LDADD = libproj.la @THREAD_LIB@
 lib_LTLIBRARIES = libproj.la
-libproj_la_LDFLAGS = -no-undefined -version-info 10:0:1
+libproj_la_LDFLAGS = -no-undefined -version-info 12:0:0
 libproj_la_SOURCES = \
 	pj_list.h \
 	PJ_aeqd.c PJ_gnom.c PJ_laea.c PJ_mod_ster.c \
@@ -411,7 +424,7 @@ libproj_la_SOURCES = \
 	PJ_imw_p.c PJ_krovak.c PJ_lcc.c PJ_poly.c \
 	PJ_rpoly.c PJ_sconics.c proj_rouss.c \
 	PJ_cass.c PJ_cc.c PJ_cea.c PJ_eqc.c \
-	PJ_gall.c PJ_labrd.c PJ_lsat.c PJ_merc.c \
+	PJ_gall.c PJ_labrd.c PJ_lsat.c PJ_misrsom.c PJ_merc.c \
 	PJ_mill.c PJ_ocea.c PJ_omerc.c PJ_somerc.c \
 	PJ_tcc.c PJ_tcea.c PJ_tmerc.c \
 	PJ_airy.c PJ_aitoff.c PJ_august.c PJ_bacon.c \
@@ -419,24 +432,25 @@ libproj_la_SOURCES = \
 	PJ_lask.c PJ_nocol.c PJ_ob_tran.c PJ_oea.c \
 	PJ_tpeqd.c PJ_vandg.c PJ_vandg2.c PJ_vandg4.c \
 	PJ_wag7.c PJ_lcca.c PJ_geos.c proj_etmerc.c \
-	PJ_boggs.c PJ_collg.c PJ_crast.c PJ_denoy.c \
+	PJ_boggs.c PJ_collg.c PJ_comill.c PJ_crast.c PJ_denoy.c \
 	PJ_eck1.c PJ_eck2.c PJ_eck3.c PJ_eck4.c \
 	PJ_eck5.c PJ_fahey.c PJ_fouc_s.c PJ_gins8.c PJ_gstmerc.c \
 	PJ_gn_sinu.c PJ_goode.c PJ_igh.c PJ_hatano.c PJ_loxim.c \
 	PJ_mbt_fps.c PJ_mbtfpp.c PJ_mbtfpq.c PJ_moll.c \
-	PJ_nell.c PJ_nell_h.c PJ_putp2.c PJ_putp3.c \
+	PJ_nell.c PJ_nell_h.c PJ_patterson.c PJ_putp2.c PJ_putp3.c \
 	PJ_putp4p.c PJ_putp5.c PJ_putp6.c PJ_qsc.c PJ_robin.c \
-	PJ_sts.c PJ_urm5.c PJ_urmfps.c PJ_wag2.c \
+	PJ_sch.c PJ_sts.c PJ_urm5.c PJ_urmfps.c PJ_wag2.c \
 	PJ_wag3.c PJ_wink1.c PJ_wink2.c pj_latlong.c pj_geocent.c \
 	aasincos.c adjlon.c bch2bps.c bchgen.c \
 	biveval.c dmstor.c mk_cheby.c pj_auth.c \
 	pj_deriv.c pj_ell_set.c pj_ellps.c pj_errno.c \
-	pj_factors.c pj_fwd.c pj_init.c pj_inv.c \
+	pj_factors.c pj_fwd.c pj_init.c pj_inv.c pj_fwd3d.c pj_inv3d.c\
 	pj_list.c pj_malloc.c pj_mlfn.c pj_msfn.c proj_mdist.c \
 	pj_open_lib.c pj_param.c pj_phi2.c pj_pr_list.c \
-	pj_qsfn.c pj_strerrno.c pj_tsfn.c pj_units.c pj_ctx.c pj_log.c \
-	pj_zpoly1.c rtodms.c vector1.c pj_release.c pj_gauss.c \
-	PJ_healpix.c PJ_natearth.c PJ_calcofi.c pj_fileapi.c \
+	pj_qsfn.c pj_generic_selftest.c pj_run_selftests.c pj_strerrno.c \
+	pj_tsfn.c pj_units.c pj_ctx.c pj_log.c pj_zpoly1.c rtodms.c \
+	vector1.c pj_release.c pj_gauss.c \
+	PJ_healpix.c PJ_natearth.c PJ_natearth2.c PJ_calcofi.c pj_fileapi.c \
 	\
 	pj_gc_reader.c pj_gridcatalog.c \
 	nad_cvt.c nad_init.c nad_intr.c emess.c emess.h \
@@ -450,7 +464,7 @@ all: proj_config.h
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -462,7 +476,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu src/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -475,9 +488,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
@@ -488,7 +501,7 @@ proj_config.h: stamp-h1
 stamp-h1: $(srcdir)/proj_config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
 	cd $(top_builddir) && $(SHELL) ./config.status src/proj_config.h
-$(srcdir)/proj_config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
+$(srcdir)/proj_config.h.in:  $(am__configure_deps) 
 	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
 	rm -f stamp-h1
 	touch $@
@@ -628,6 +641,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_cea.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_chamb.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_collg.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_comill.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_crast.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_denoy.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_eck1.Plo at am__quote@
@@ -667,9 +681,11 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_mbtfpq.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_merc.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_mill.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_misrsom.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_mod_ster.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_moll.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_natearth.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_natearth2.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_nell.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_nell_h.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_nocol.Plo at am__quote@
@@ -680,6 +696,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_oea.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_omerc.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_ortho.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_patterson.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_poly.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_putp2.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_putp3.Plo at am__quote@
@@ -689,6 +706,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_qsc.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_robin.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_rpoly.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_sch.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_sconics.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_somerc.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PJ_stere.Plo at am__quote@
@@ -743,8 +761,10 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_factors.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_fileapi.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_fwd.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_fwd3d.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_gauss.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_gc_reader.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_generic_selftest.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_geocent.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_gridcatalog.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_gridinfo.Plo at am__quote@
@@ -752,6 +772,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_init.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_initcache.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_inv.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_inv3d.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_latlong.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_list.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_log.Plo at am__quote@
@@ -765,6 +786,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_pr_list.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_qsfn.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_release.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_run_selftests.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_strerrno.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_strtod.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pj_transform.Plo at am__quote@
@@ -1041,6 +1063,8 @@ uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \
 	tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \
 	uninstall-includeHEADERS uninstall-libLTLIBRARIES
 
+.PRECIOUS: Makefile
+
 
 install-exec-local:
 	rm -f $(DESTDIR)$(bindir)/invproj$(EXEEXT)
diff --git a/src/PJ_aea.c b/src/PJ_aea.c
index 0881ba7..b8267e0 100644
--- a/src/PJ_aea.c
+++ b/src/PJ_aea.c
@@ -1,7 +1,9 @@
 /******************************************************************************
  * Project:  PROJ.4
  * Purpose:  Implementation of the aea (Albers Equal Area) projection.
- * Author:   Gerald Evenden
+ *           and the leac (Lambert Equal Area Conic) projection
+ * Author:   Gerald Evenden (1995)
+ *           Thomas Knudsen (2016) - revise/add regression tests
  *
  ******************************************************************************
  * Copyright (c) 1995, Gerald Evenden
@@ -25,35 +27,21 @@
  * DEALINGS IN THE SOFTWARE.
  *****************************************************************************/
 
-#define PROJ_PARMS__ \
-	double	ec; \
-	double	n; \
-	double	c; \
-	double	dd; \
-	double	n2; \
-	double	rho0; \
-	double	rho; \
-	double	phi1; \
-	double	phi2; \
-	double	*en; \
-	int		ellips;
-
 #define PJ_LIB__
 #include <projects.h>
 
 # define EPS10	1.e-10
 # define TOL7	1.e-7
 
-PROJ_HEAD(aea, "Albers Equal Area")
-	"\n\tConic Sph&Ell\n\tlat_1= lat_2=";
-PROJ_HEAD(leac, "Lambert Equal Area Conic")
-	"\n\tConic, Sph&Ell\n\tlat_1= south";
+PROJ_HEAD(aea, "Albers Equal Area") "\n\tConic Sph&Ell\n\tlat_1= lat_2=";
+PROJ_HEAD(leac, "Lambert Equal Area Conic") "\n\tConic, Sph&Ell\n\tlat_1= south";
+
+
 /* determine latitude angle phi-1 */
 # define N_ITER 15
 # define EPSILON 1.0e-7
 # define TOL 1.0e-10
-	static double
-phi1_(double qs, double Te, double Tone_es) {
+static double phi1_(double qs, double Te, double Tone_es) {
 	int i;
 	double Phi, sinpi, cospi, con, com, dphi;
 
@@ -73,86 +61,269 @@ phi1_(double qs, double Te, double Tone_es) {
 	} while (fabs(dphi) > TOL && --i);
 	return( i ? Phi : HUGE_VAL );
 }
-FORWARD(e_forward); /* ellipsoid & spheroid */
-	if ((P->rho = P->c - (P->ellips ? P->n * pj_qsfn(sin(lp.phi),
-		P->e, P->one_es) : P->n2 * sin(lp.phi))) < 0.) F_ERROR
-	P->rho = P->dd * sqrt(P->rho);
-	xy.x = P->rho * sin( lp.lam *= P->n );
-	xy.y = P->rho0 - P->rho * cos(lp.lam);
-	return (xy);
+
+
+struct pj_opaque {
+	double	ec;
+	double	n;
+	double	c;
+	double	dd;
+	double	n2;
+	double	rho0;
+	double	rho;
+	double	phi1;
+	double	phi2;
+	double	*en;
+	int		ellips;
+};
+
+
+
+static XY e_forward (LP lp, PJ *P) {   /* Ellipsoid/spheroid, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+	if ((Q->rho = Q->c - (Q->ellips ? Q->n * pj_qsfn(sin(lp.phi),
+		P->e, P->one_es) : Q->n2 * sin(lp.phi))) < 0.) F_ERROR
+	Q->rho = Q->dd * sqrt(Q->rho);
+	xy.x = Q->rho * sin( lp.lam *= Q->n );
+	xy.y = Q->rho0 - Q->rho * cos(lp.lam);
+	return xy;
 }
-INVERSE(e_inverse) /* ellipsoid & spheroid */;
-	if( (P->rho = hypot(xy.x, xy.y = P->rho0 - xy.y)) != 0.0 ) {
-		if (P->n < 0.) {
-			P->rho = -P->rho;
+
+
+static LP e_inverse (XY xy, PJ *P) {   /* Ellipsoid/spheroid, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+	if( (Q->rho = hypot(xy.x, xy.y = Q->rho0 - xy.y)) != 0.0 ) {
+		if (Q->n < 0.) {
+			Q->rho = -Q->rho;
 			xy.x = -xy.x;
 			xy.y = -xy.y;
 		}
-		lp.phi =  P->rho / P->dd;
-		if (P->ellips) {
-			lp.phi = (P->c - lp.phi * lp.phi) / P->n;
-			if (fabs(P->ec - fabs(lp.phi)) > TOL7) {
+		lp.phi =  Q->rho / Q->dd;
+		if (Q->ellips) {
+			lp.phi = (Q->c - lp.phi * lp.phi) / Q->n;
+			if (fabs(Q->ec - fabs(lp.phi)) > TOL7) {
 				if ((lp.phi = phi1_(lp.phi, P->e, P->one_es)) == HUGE_VAL)
 					I_ERROR
 			} else
-				lp.phi = lp.phi < 0. ? -HALFPI : HALFPI;
-		} else if (fabs(lp.phi = (P->c - lp.phi * lp.phi) / P->n2) <= 1.)
+				lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
+		} else if (fabs(lp.phi = (Q->c - lp.phi * lp.phi) / Q->n2) <= 1.)
 			lp.phi = asin(lp.phi);
 		else
-			lp.phi = lp.phi < 0. ? -HALFPI : HALFPI;
-		lp.lam = atan2(xy.x, xy.y) / P->n;
+			lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
+		lp.lam = atan2(xy.x, xy.y) / Q->n;
 	} else {
 		lp.lam = 0.;
-		lp.phi = P->n > 0. ? HALFPI : - HALFPI;
+		lp.phi = Q->n > 0. ? M_HALFPI : - M_HALFPI;
 	}
-	return (lp);
+	return lp;
 }
-FREEUP; if (P) { if (P->en) pj_dalloc(P->en); pj_dalloc(P); } }
-	static PJ *
-setup(PJ *P) {
+
+
+static void *freeup_new (PJ *P) {                        /* Destructor */
+    if (0==P)
+        return 0;
+
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque->en);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+static PJ *setup(PJ *P) {
 	double cosphi, sinphi;
 	int secant;
+    struct pj_opaque *Q = P->opaque;
 
-	if (fabs(P->phi1 + P->phi2) < EPS10) E_ERROR(-21);
-	P->n = sinphi = sin(P->phi1);
-	cosphi = cos(P->phi1);
-	secant = fabs(P->phi1 - P->phi2) >= EPS10;
-	if( (P->ellips = (P->es > 0.))) {
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+
+	if (fabs(Q->phi1 + Q->phi2) < EPS10) E_ERROR(-21);
+	Q->n = sinphi = sin(Q->phi1);
+	cosphi = cos(Q->phi1);
+	secant = fabs(Q->phi1 - Q->phi2) >= EPS10;
+	if( (Q->ellips = (P->es > 0.))) {
 		double ml1, m1;
 
-		if (!(P->en = pj_enfn(P->es))) E_ERROR_0;
+		if (!(Q->en = pj_enfn(P->es))) E_ERROR_0;
 		m1 = pj_msfn(sinphi, cosphi, P->es);
 		ml1 = pj_qsfn(sinphi, P->e, P->one_es);
 		if (secant) { /* secant cone */
 			double ml2, m2;
 
-			sinphi = sin(P->phi2);
-			cosphi = cos(P->phi2);
+			sinphi = sin(Q->phi2);
+			cosphi = cos(Q->phi2);
 			m2 = pj_msfn(sinphi, cosphi, P->es);
 			ml2 = pj_qsfn(sinphi, P->e, P->one_es);
-			P->n = (m1 * m1 - m2 * m2) / (ml2 - ml1);
+			Q->n = (m1 * m1 - m2 * m2) / (ml2 - ml1);
 		}
-		P->ec = 1. - .5 * P->one_es * log((1. - P->e) /
+		Q->ec = 1. - .5 * P->one_es * log((1. - P->e) /
 			(1. + P->e)) / P->e;
-		P->c = m1 * m1 + P->n * ml1;
-		P->dd = 1. / P->n;
-		P->rho0 = P->dd * sqrt(P->c - P->n * pj_qsfn(sin(P->phi0),
+		Q->c = m1 * m1 + Q->n * ml1;
+		Q->dd = 1. / Q->n;
+		Q->rho0 = Q->dd * sqrt(Q->c - Q->n * pj_qsfn(sin(P->phi0),
 			P->e, P->one_es));
 	} else {
-		if (secant) P->n = .5 * (P->n + sin(P->phi2));
-		P->n2 = P->n + P->n;
-		P->c = cosphi * cosphi + P->n2 * sinphi;
-		P->dd = 1. / P->n;
-		P->rho0 = P->dd * sqrt(P->c - P->n2 * sin(P->phi0));
+		if (secant) Q->n = .5 * (Q->n + sin(Q->phi2));
+		Q->n2 = Q->n + Q->n;
+		Q->c = cosphi * cosphi + Q->n2 * sinphi;
+		Q->dd = 1. / Q->n;
+		Q->rho0 = Q->dd * sqrt(Q->c - Q->n2 * sin(P->phi0));
 	}
-	P->inv = e_inverse; P->fwd = e_forward;
+
 	return P;
 }
-ENTRY1(aea,en)
-	P->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
-	P->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
-ENDENTRY(setup(P))
-ENTRY1(leac,en)
-	P->phi2 = pj_param(P->ctx, P->params, "rlat_1").f;
-	P->phi1 = pj_param(P->ctx, P->params, "bsouth").i ? - HALFPI: HALFPI;
-ENDENTRY(setup(P))
+
+
+PJ *PROJECTION(aea) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
+	Q->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
+    setup(P);
+    return P;
+}
+
+
+PJ *PROJECTION(leac) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	Q->phi2 = pj_param(P->ctx, P->params, "rlat_1").f;
+	Q->phi1 = pj_param(P->ctx, P->params, "bsouth").i ? - M_HALFPI: M_HALFPI;
+    setup (P);
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_aea_selftest (void) {return 10000;}
+#else
+
+int pj_aea_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=aea   +ellps=GRS80  +lat_1=0 +lat_2=2"};
+    char s_args[] = {"+proj=aea   +a=6400000    +lat_1=0 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222571.60875710563,  110653.32674302977},
+        {222706.30650839131,  -110484.26714439997},
+        {-222571.60875710563,  110653.32674302977},
+        {-222706.30650839131,  -110484.26714439997},
+    };
+
+    XY s_fwd_expect[] = {
+        {223334.08517088494,  111780.43188447191},
+        {223470.15499168713,  -111610.33943099028},
+        {-223334.08517088494,  111780.43188447191},
+        {-223470.15499168713,  -111610.33943099028},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017966310597749514,  0.00090436885862202158},
+        {0.0017966300767030448,  -0.00090437009538581453},
+        {-0.0017966310597749514,  0.00090436885862202158},
+        {-0.0017966300767030448,  -0.00090437009538581453},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017904935979658752,  0.00089524594491375306},
+        {0.0017904926216016812,  -0.00089524716502493225},
+        {-0.0017904935979658752,  0.00089524594491375306},
+        {-0.0017904926216016812,  -0.00089524716502493225},
+    };
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_leac_selftest (void) {return 10000;}
+#else
+
+int pj_leac_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=leac   +ellps=GRS80  +lat_1=0 +lat_2=2"};
+    char s_args[] = {"+proj=leac   +a=6400000    +lat_1=0 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {220685.14054297868,  112983.50088939646},
+        {224553.31227982609,  -108128.63674487274},
+        {-220685.14054297868,  112983.50088939646},
+        {-224553.31227982609,  -108128.63674487274},
+    };
+
+    XY s_fwd_expect[] = {
+        {221432.86859285168,  114119.45452653214},
+        {225331.72412711097,  -109245.82943505641},
+        {-221432.86859285168,  114119.45452653214},
+        {-225331.72412711097,  -109245.82943505641},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017966446840328458,  0.00090435171340223211},
+        {0.0017966164523713021,  -0.00090438724081843625},
+        {-0.0017966446840328458,  0.00090435171340223211},
+        {-0.0017966164523713021,  -0.00090438724081843625},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017905070979748127,  0.00089522906964877795},
+        {0.001790479121519977,  -0.00089526404022281043},
+        {-0.0017905070979748127,  0.00089522906964877795},
+        {-0.001790479121519977,  -0.00089526404022281043},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+#endif
diff --git a/src/PJ_aeqd.c b/src/PJ_aeqd.c
index 739dfdd..2b832ed 100644
--- a/src/PJ_aeqd.c
+++ b/src/PJ_aeqd.c
@@ -25,237 +25,346 @@
  * DEALINGS IN THE SOFTWARE.
  *****************************************************************************/
 
-#define PROJ_PARMS__ \
-	double	sinph0; \
-	double	cosph0; \
-	double	*en; \
-	double	M1; \
-	double	N1; \
-	double	Mp; \
-	double	He; \
-	double	G; \
-	int		mode; \
-	struct geod_geodesic g;
 #define PJ_LIB__
-#include	"geodesic.h"
-#include	<projects.h>
+#include "geodesic.h"
+#include <projects.h>
+
+struct pj_opaque {
+    double  sinph0;
+    double  cosph0;
+    double  *en;
+    double  M1;
+    double  N1;
+    double  Mp;
+    double  He;
+    double  G;
+    int     mode;
+    struct geod_geodesic g;
+};
 
 PROJ_HEAD(aeqd, "Azimuthal Equidistant") "\n\tAzi, Sph&Ell\n\tlat_0 guam";
 
 #define EPS10 1.e-10
 #define TOL 1.e-14
-#define RHO 57.295779513082320876798154814105
-
-#define N_POLE	0
-#define S_POLE	1
-#define EQUIT	2
-#define OBLIQ	3
-
-FORWARD(e_guam_fwd); /* Guam elliptical */
-	double  cosphi, sinphi, t;
-
-	cosphi = cos(lp.phi);
-	sinphi = sin(lp.phi);
-	t = 1. / sqrt(1. - P->es * sinphi * sinphi);
-	xy.x = lp.lam * cosphi * t;
-	xy.y = pj_mlfn(lp.phi, sinphi, cosphi, P->en) - P->M1 +
-		.5 * lp.lam * lp.lam * cosphi * sinphi * t;
-	return (xy);
+
+#define N_POLE  0
+#define S_POLE  1
+#define EQUIT   2
+#define OBLIQ   3
+
+
+static XY e_guam_fwd(LP lp, PJ *P) {        /* Guam elliptical */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  cosphi, sinphi, t;
+
+    cosphi = cos(lp.phi);
+    sinphi = sin(lp.phi);
+    t = 1. / sqrt(1. - P->es * sinphi * sinphi);
+    xy.x = lp.lam * cosphi * t;
+    xy.y = pj_mlfn(lp.phi, sinphi, cosphi, Q->en) - Q->M1 +
+        .5 * lp.lam * lp.lam * cosphi * sinphi * t;
+
+    return xy;
 }
-FORWARD(e_forward); /* elliptical */
-	double  coslam, cosphi, sinphi, rho;
-	double azi1, azi2, s12;
-	double lam1, phi1, lam2, phi2;
-
-	coslam = cos(lp.lam);
-	cosphi = cos(lp.phi);
-	sinphi = sin(lp.phi);
-	switch (P->mode) {
-	case N_POLE:
-		coslam = - coslam;
-	case S_POLE:
-		xy.x = (rho = fabs(P->Mp - pj_mlfn(lp.phi, sinphi, cosphi, P->en))) *
-			sin(lp.lam);
-		xy.y = rho * coslam;
-		break;
-	case EQUIT:
-	case OBLIQ:
-		if (fabs(lp.lam) < EPS10 && fabs(lp.phi - P->phi0) < EPS10) {
-			xy.x = xy.y = 0.;
-			break;
-		}
-
-		phi1 = P->phi0*RHO; lam1 = P->lam0*RHO;
-		phi2 = lp.phi*RHO;  lam2 = (lp.lam+P->lam0)*RHO;
-
-		geod_inverse(&P->g, phi1, lam1, phi2, lam2, &s12, &azi1, &azi2);
-		azi1 /= RHO;
-		xy.x = s12 * sin(azi1) / P->a;
-		xy.y = s12 * cos(azi1) / P->a;
-		break;
-	}
-	return (xy);
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  coslam, cosphi, sinphi, rho;
+    double azi1, azi2, s12;
+    double lam1, phi1, lam2, phi2;
+
+    coslam = cos(lp.lam);
+    cosphi = cos(lp.phi);
+    sinphi = sin(lp.phi);
+    switch (Q->mode) {
+    case N_POLE:
+        coslam = - coslam;
+    case S_POLE:
+        xy.x = (rho = fabs(Q->Mp - pj_mlfn(lp.phi, sinphi, cosphi, Q->en))) *
+            sin(lp.lam);
+        xy.y = rho * coslam;
+        break;
+    case EQUIT:
+    case OBLIQ:
+        if (fabs(lp.lam) < EPS10 && fabs(lp.phi - P->phi0) < EPS10) {
+            xy.x = xy.y = 0.;
+            break;
+        }
+
+        phi1 = P->phi0 / DEG_TO_RAD; lam1 = P->lam0 / DEG_TO_RAD;
+        phi2 = lp.phi / DEG_TO_RAD;  lam2 = (lp.lam+P->lam0) / DEG_TO_RAD;
+
+        geod_inverse(&Q->g, phi1, lam1, phi2, lam2, &s12, &azi1, &azi2);
+        azi1 *= DEG_TO_RAD;
+        xy.x = s12 * sin(azi1) / P->a;
+        xy.y = s12 * cos(azi1) / P->a;
+        break;
+    }
+    return xy;
 }
-FORWARD(s_forward); /* spherical */
-	double  coslam, cosphi, sinphi;
-
-	sinphi = sin(lp.phi);
-	cosphi = cos(lp.phi);
-	coslam = cos(lp.lam);
-	switch (P->mode) {
-	case EQUIT:
-		xy.y = cosphi * coslam;
-		goto oblcon;
-	case OBLIQ:
-		xy.y = P->sinph0 * sinphi + P->cosph0 * cosphi * coslam;
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  coslam, cosphi, sinphi;
+
+    sinphi = sin(lp.phi);
+    cosphi = cos(lp.phi);
+    coslam = cos(lp.lam);
+    switch (Q->mode) {
+    case EQUIT:
+        xy.y = cosphi * coslam;
+        goto oblcon;
+    case OBLIQ:
+        xy.y = Q->sinph0 * sinphi + Q->cosph0 * cosphi * coslam;
 oblcon:
-		if (fabs(fabs(xy.y) - 1.) < TOL)
-			if (xy.y < 0.)
-				F_ERROR
-			else
-				xy.x = xy.y = 0.;
-		else {
-			xy.y = acos(xy.y);
-			xy.y /= sin(xy.y);
-			xy.x = xy.y * cosphi * sin(lp.lam);
-			xy.y *= (P->mode == EQUIT) ? sinphi :
-		   		P->cosph0 * sinphi - P->sinph0 * cosphi * coslam;
-		}
-		break;
-	case N_POLE:
-		lp.phi = -lp.phi;
-		coslam = -coslam;
-	case S_POLE:
-		if (fabs(lp.phi - HALFPI) < EPS10) F_ERROR;
-		xy.x = (xy.y = (HALFPI + lp.phi)) * sin(lp.lam);
-		xy.y *= coslam;
-		break;
-	}
-	return (xy);
+        if (fabs(fabs(xy.y) - 1.) < TOL)
+            if (xy.y < 0.)
+                F_ERROR
+            else
+                xy.x = xy.y = 0.;
+        else {
+            xy.y = acos(xy.y);
+            xy.y /= sin(xy.y);
+            xy.x = xy.y * cosphi * sin(lp.lam);
+            xy.y *= (Q->mode == EQUIT) ? sinphi :
+                Q->cosph0 * sinphi - Q->sinph0 * cosphi * coslam;
+        }
+        break;
+    case N_POLE:
+        lp.phi = -lp.phi;
+        coslam = -coslam;
+    case S_POLE:
+        if (fabs(lp.phi - M_HALFPI) < EPS10) F_ERROR;
+        xy.x = (xy.y = (M_HALFPI + lp.phi)) * sin(lp.lam);
+        xy.y *= coslam;
+        break;
+    }
+    return xy;
 }
-INVERSE(e_guam_inv); /* Guam elliptical */
-	double x2, t;
-	int i;
-
-	x2 = 0.5 * xy.x * xy.x;
-	lp.phi = P->phi0;
-	for (i = 0; i < 3; ++i) {
-		t = P->e * sin(lp.phi);
-		lp.phi = pj_inv_mlfn(P->ctx, P->M1 + xy.y -
-			x2 * tan(lp.phi) * (t = sqrt(1. - t * t)), P->es, P->en);
-	}
-	lp.lam = xy.x * t / cos(lp.phi);
-	return (lp);
+
+
+static LP e_guam_inv(XY xy, PJ *P) { /* Guam elliptical */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double x2, t;
+    int i;
+
+    x2 = 0.5 * xy.x * xy.x;
+    lp.phi = P->phi0;
+    for (i = 0; i < 3; ++i) {
+        t = P->e * sin(lp.phi);
+        lp.phi = pj_inv_mlfn(P->ctx, Q->M1 + xy.y -
+            x2 * tan(lp.phi) * (t = sqrt(1. - t * t)), P->es, Q->en);
+    }
+    lp.lam = xy.x * t / cos(lp.phi);
+    return lp;
 }
-INVERSE(e_inverse); /* elliptical */
-	double c;
-	double azi1, azi2, s12, x2, y2, lat1, lon1, lat2, lon2;
-
-	if ((c = hypot(xy.x, xy.y)) < EPS10) {
-		lp.phi = P->phi0;
-		lp.lam = 0.;
-		return (lp);
-	}
-	if (P->mode == OBLIQ || P->mode == EQUIT) {
-
-		x2 = xy.x * P->a;
-		y2 = xy.y * P->a;
-		lat1 = P->phi0 * RHO;
-		lon1 = P->lam0 * RHO;
-		azi1 = atan2(x2, y2) * RHO;
-		s12 = sqrt(x2 * x2 + y2 * y2);
-		geod_direct(&P->g, lat1, lon1, azi1, s12, &lat2, &lon2, &azi2);
-		lp.phi = lat2 / RHO;
-		lp.lam = lon2 / RHO;
-		lp.lam -= P->lam0;
-	} else { /* Polar */
-		lp.phi = pj_inv_mlfn(P->ctx, P->mode == N_POLE ? P->Mp - c : P->Mp + c,
-			P->es, P->en);
-		lp.lam = atan2(xy.x, P->mode == N_POLE ? -xy.y : xy.y);
-	}
-	return (lp);
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double c;
+    double azi1, azi2, s12, x2, y2, lat1, lon1, lat2, lon2;
+
+    if ((c = hypot(xy.x, xy.y)) < EPS10) {
+        lp.phi = P->phi0;
+        lp.lam = 0.;
+        return (lp);
+    }
+    if (Q->mode == OBLIQ || Q->mode == EQUIT) {
+
+        x2 = xy.x * P->a;
+        y2 = xy.y * P->a;
+        lat1 = P->phi0 / DEG_TO_RAD;
+        lon1 = P->lam0 / DEG_TO_RAD;
+        azi1 = atan2(x2, y2) / DEG_TO_RAD;
+        s12 = sqrt(x2 * x2 + y2 * y2);
+        geod_direct(&Q->g, lat1, lon1, azi1, s12, &lat2, &lon2, &azi2);
+        lp.phi = lat2 * DEG_TO_RAD;
+        lp.lam = lon2 * DEG_TO_RAD;
+        lp.lam -= P->lam0;
+    } else { /* Polar */
+        lp.phi = pj_inv_mlfn(P->ctx, Q->mode == N_POLE ? Q->Mp - c : Q->Mp + c,
+            P->es, Q->en);
+        lp.lam = atan2(xy.x, Q->mode == N_POLE ? -xy.y : xy.y);
+    }
+    return lp;
 }
-INVERSE(s_inverse); /* spherical */
-	double cosc, c_rh, sinc;
-
-	if ((c_rh = hypot(xy.x, xy.y)) > PI) {
-		if (c_rh - EPS10 > PI) I_ERROR;
-		c_rh = PI;
-	} else if (c_rh < EPS10) {
-		lp.phi = P->phi0;
-		lp.lam = 0.;
-		return (lp);
-	}
-	if (P->mode == OBLIQ || P->mode == EQUIT) {
-		sinc = sin(c_rh);
-		cosc = cos(c_rh);
-		if (P->mode == EQUIT) {
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double cosc, c_rh, sinc;
+
+    if ((c_rh = hypot(xy.x, xy.y)) > M_PI) {
+        if (c_rh - EPS10 > M_PI) I_ERROR;
+        c_rh = M_PI;
+    } else if (c_rh < EPS10) {
+        lp.phi = P->phi0;
+        lp.lam = 0.;
+        return (lp);
+    }
+    if (Q->mode == OBLIQ || Q->mode == EQUIT) {
+        sinc = sin(c_rh);
+        cosc = cos(c_rh);
+        if (Q->mode == EQUIT) {
                         lp.phi = aasin(P->ctx, xy.y * sinc / c_rh);
-			xy.x *= sinc;
-			xy.y = cosc * c_rh;
-		} else {
-			lp.phi = aasin(P->ctx,cosc * P->sinph0 + xy.y * sinc * P->cosph0 /
-				c_rh);
-			xy.y = (cosc - P->sinph0 * sin(lp.phi)) * c_rh;
-			xy.x *= sinc * P->cosph0;
-		}
-		lp.lam = xy.y == 0. ? 0. : atan2(xy.x, xy.y);
-	} else if (P->mode == N_POLE) {
-		lp.phi = HALFPI - c_rh;
-		lp.lam = atan2(xy.x, -xy.y);
-	} else {
-		lp.phi = c_rh - HALFPI;
-		lp.lam = atan2(xy.x, xy.y);
-	}
-	return (lp);
+            xy.x *= sinc;
+            xy.y = cosc * c_rh;
+        } else {
+            lp.phi = aasin(P->ctx,cosc * Q->sinph0 + xy.y * sinc * Q->cosph0 /
+                c_rh);
+            xy.y = (cosc - Q->sinph0 * sin(lp.phi)) * c_rh;
+            xy.x *= sinc * Q->cosph0;
+        }
+        lp.lam = xy.y == 0. ? 0. : atan2(xy.x, xy.y);
+    } else if (Q->mode == N_POLE) {
+        lp.phi = M_HALFPI - c_rh;
+        lp.lam = atan2(xy.x, -xy.y);
+    } else {
+        lp.phi = c_rh - M_HALFPI;
+        lp.lam = atan2(xy.x, xy.y);
+    }
+    return lp;
 }
-FREEUP;
-    if (P) {
-		if (P->en)
-			pj_dalloc(P->en);
-		pj_dalloc(P);
-	}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    if (P->opaque->en)
+        pj_dealloc(P->opaque->en);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(aeqd) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    geod_init(&Q->g, P->a, P->es / (1 + sqrt(P->one_es)));
+    P->phi0 = pj_param(P->ctx, P->params, "rlat_0").f;
+    if (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) {
+        Q->mode = P->phi0 < 0. ? S_POLE : N_POLE;
+        Q->sinph0 = P->phi0 < 0. ? -1. : 1.;
+        Q->cosph0 = 0.;
+    } else if (fabs(P->phi0) < EPS10) {
+        Q->mode = EQUIT;
+        Q->sinph0 = 0.;
+        Q->cosph0 = 1.;
+    } else {
+        Q->mode = OBLIQ;
+        Q->sinph0 = sin(P->phi0);
+        Q->cosph0 = cos(P->phi0);
+    }
+    if (! P->es) {
+        P->inv = s_inverse;
+        P->fwd = s_forward;
+    } else {
+        if (!(Q->en = pj_enfn(P->es))) E_ERROR_0;
+        if (pj_param(P->ctx, P->params, "bguam").i) {
+            Q->M1 = pj_mlfn(P->phi0, Q->sinph0, Q->cosph0, Q->en);
+            P->inv = e_guam_inv;
+            P->fwd = e_guam_fwd;
+        } else {
+            switch (Q->mode) {
+            case N_POLE:
+                Q->Mp = pj_mlfn(M_HALFPI, 1., 0., Q->en);
+                break;
+            case S_POLE:
+                Q->Mp = pj_mlfn(-M_HALFPI, -1., 0., Q->en);
+                break;
+            case EQUIT:
+            case OBLIQ:
+                P->inv = e_inverse; P->fwd = e_forward;
+                Q->N1 = 1. / sqrt(1. - P->es * Q->sinph0 * Q->sinph0);
+                Q->G = Q->sinph0 * (Q->He = P->e / sqrt(P->one_es));
+                Q->He *= Q->cosph0;
+                break;
+            }
+            P->inv = e_inverse;
+            P->fwd = e_forward;
+        }
+    }
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_aeqd_selftest (void) {return 0;}
+#else
+
+int pj_aeqd_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=aeqd   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=aeqd   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222616.522190051648,  110596.996549550197},
+        { 222616.522190051648, -110596.996549550211},
+        {-222616.522190051648,  110596.996549550197},
+        {-222616.522190051648, -110596.996549550211},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223379.456047271,  111723.757570854126},
+        { 223379.456047271, -111723.757570854126},
+        {-223379.456047271,  111723.757570854126},
+        {-223379.456047271, -111723.757570854126},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.00179663056838724787,  0.000904369476930248902},
+        { 0.00179663056838724787, -0.000904369476930248469},
+        {-0.00179663056838724787,  0.000904369476930248902},
+        {-0.00179663056838724787, -0.000904369476930248469},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179049310992953335,  0.000895246554746200623},
+        { 0.00179049310992953335, -0.000895246554746200623},
+        {-0.00179049310992953335,  0.000895246554746200623},
+        {-0.00179049310992953335, -0.000895246554746200623},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
 }
-ENTRY1(aeqd, en)
-	geod_init(&P->g, P->a, P->es / (1 + sqrt(P->one_es)));
-	P->phi0 = pj_param(P->ctx, P->params, "rlat_0").f;
-	if (fabs(fabs(P->phi0) - HALFPI) < EPS10) {
-		P->mode = P->phi0 < 0. ? S_POLE : N_POLE;
-		P->sinph0 = P->phi0 < 0. ? -1. : 1.;
-		P->cosph0 = 0.;
-	} else if (fabs(P->phi0) < EPS10) {
-		P->mode = EQUIT;
-		P->sinph0 = 0.;
-		P->cosph0 = 1.;
-	} else {
-		P->mode = OBLIQ;
-		P->sinph0 = sin(P->phi0);
-		P->cosph0 = cos(P->phi0);
-	}
-	if (! P->es) {
-		P->inv = s_inverse; P->fwd = s_forward;
-	} else {
-		if (!(P->en = pj_enfn(P->es))) E_ERROR_0;
-		if (pj_param(P->ctx, P->params, "bguam").i) {
-			P->M1 = pj_mlfn(P->phi0, P->sinph0, P->cosph0, P->en);
-			P->inv = e_guam_inv; P->fwd = e_guam_fwd;
-		} else {
-			switch (P->mode) {
-			case N_POLE:
-				P->Mp = pj_mlfn(HALFPI, 1., 0., P->en);
-				break;
-			case S_POLE:
-				P->Mp = pj_mlfn(-HALFPI, -1., 0., P->en);
-				break;
-			case EQUIT:
-			case OBLIQ:
-				P->inv = e_inverse; P->fwd = e_forward;
-				P->N1 = 1. / sqrt(1. - P->es * P->sinph0 * P->sinph0);
-				P->G = P->sinph0 * (P->He = P->e / sqrt(P->one_es));
-				P->He *= P->cosph0;
-				break;
-			}
-			P->inv = e_inverse; P->fwd = e_forward;
-		}
-	}
-ENDENTRY(P)
+
+
+#endif
diff --git a/src/PJ_airy.c b/src/PJ_airy.c
index 73a51e5..8b61901 100644
--- a/src/PJ_airy.c
+++ b/src/PJ_airy.c
@@ -1,7 +1,8 @@
 /******************************************************************************
  * Project:  PROJ.4
  * Purpose:  Implementation of the airy (Airy) projection.
- * Author:   Gerald Evenden
+ * Author:   Gerald Evenden (1995)
+ *           Thomas Knudsen (2016) - revise/add regression tests
  *
  ******************************************************************************
  * Copyright (c) 1995, Gerald Evenden
@@ -25,96 +26,161 @@
  * DEALINGS IN THE SOFTWARE.
  *****************************************************************************/
 
-#define PROJ_PARMS__ \
-	double	p_halfpi; \
-	double	sinph0; \
-	double	cosph0; \
-	double	Cb; \
-	int		mode; \
-	int		no_cut;	/* do not cut at hemisphere limit */
 #define PJ_LIB__
 #include <projects.h>
 
 PROJ_HEAD(airy, "Airy") "\n\tMisc Sph, no inv.\n\tno_cut lat_b=";
 
+
+struct pj_opaque {
+	double	p_halfpi;
+	double	sinph0;
+	double	cosph0;
+	double	Cb;
+	int		mode;
+	int		no_cut;	/* do not cut at hemisphere limit */
+};
+
+
 # define EPS 1.e-10
 # define N_POLE	0
 # define S_POLE 1
 # define EQUIT	2
 # define OBLIQ	3
-FORWARD(s_forward); /* spheroid */
+
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double  sinlam, coslam, cosphi, sinphi, t, s, Krho, cosz;
 
 	sinlam = sin(lp.lam);
 	coslam = cos(lp.lam);
-	switch (P->mode) {
+	switch (Q->mode) {
 	case EQUIT:
 	case OBLIQ:
 		sinphi = sin(lp.phi);
 		cosphi = cos(lp.phi);
 		cosz = cosphi * coslam;
-		if (P->mode == OBLIQ)
-			cosz = P->sinph0 * sinphi + P->cosph0 * cosz;
-		if (!P->no_cut && cosz < -EPS)
+		if (Q->mode == OBLIQ)
+			cosz = Q->sinph0 * sinphi + Q->cosph0 * cosz;
+		if (!Q->no_cut && cosz < -EPS)
 			F_ERROR;
 		if (fabs(s = 1. - cosz) > EPS) {
 			t = 0.5 * (1. + cosz);
-			Krho = -log(t)/s - P->Cb / t;
+			Krho = -log(t)/s - Q->Cb / t;
 		} else
-			Krho = 0.5 - P->Cb;
+			Krho = 0.5 - Q->Cb;
 		xy.x = Krho * cosphi * sinlam;
-		if (P->mode == OBLIQ)
-			xy.y = Krho * (P->cosph0 * sinphi -
-				P->sinph0 * cosphi * coslam);
+		if (Q->mode == OBLIQ)
+			xy.y = Krho * (Q->cosph0 * sinphi -
+				Q->sinph0 * cosphi * coslam);
 		else
 			xy.y = Krho * sinphi;
 		break;
 	case S_POLE:
 	case N_POLE:
-		lp.phi = fabs(P->p_halfpi - lp.phi);
-		if (!P->no_cut && (lp.phi - EPS) > HALFPI)
+		lp.phi = fabs(Q->p_halfpi - lp.phi);
+		if (!Q->no_cut && (lp.phi - EPS) > M_HALFPI)
 			F_ERROR;
 		if ((lp.phi *= 0.5) > EPS) {
 			t = tan(lp.phi);
-			Krho = -2.*(log(cos(lp.phi)) / t + t * P->Cb);
+			Krho = -2.*(log(cos(lp.phi)) / t + t * Q->Cb);
 			xy.x = Krho * sinlam;
 			xy.y = Krho * coslam;
-			if (P->mode == N_POLE)
+			if (Q->mode == N_POLE)
 				xy.y = -xy.y;
 		} else
 			xy.x = xy.y = 0.;
 	}
-	return (xy);
+	return xy;
+}
+
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(airy)
+
+
+PJ *PROJECTION(airy) {
 	double beta;
 
-	P->no_cut = pj_param(P->ctx, P->params, "bno_cut").i;
-	beta = 0.5 * (HALFPI - pj_param(P->ctx, P->params, "rlat_b").f);
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+
+    P->opaque = Q;
+
+	Q->no_cut = pj_param(P->ctx, P->params, "bno_cut").i;
+	beta = 0.5 * (M_HALFPI - pj_param(P->ctx, P->params, "rlat_b").f);
 	if (fabs(beta) < EPS)
-		P->Cb = -0.5;
+		Q->Cb = -0.5;
 	else {
-		P->Cb = 1./tan(beta);
-		P->Cb *= P->Cb * log(cos(beta));
+		Q->Cb = 1./tan(beta);
+		Q->Cb *= Q->Cb * log(cos(beta));
 	}
-	if (fabs(fabs(P->phi0) - HALFPI) < EPS)
+
+	if (fabs(fabs(P->phi0) - M_HALFPI) < EPS)
 		if (P->phi0 < 0.) {
-			P->p_halfpi = -HALFPI;
-			P->mode = S_POLE;
+			Q->p_halfpi = -M_HALFPI;
+			Q->mode = S_POLE;
 		} else {
-			P->p_halfpi =  HALFPI;
-			P->mode = N_POLE;
+			Q->p_halfpi =  M_HALFPI;
+			Q->mode = N_POLE;
 		}
 	else {
 		if (fabs(P->phi0) < EPS)
-			P->mode = EQUIT;
+			Q->mode = EQUIT;
 		else {
-			P->mode = OBLIQ;
-			P->sinph0 = sin(P->phi0);
-			P->cosph0 = cos(P->phi0);
+			Q->mode = OBLIQ;
+			Q->sinph0 = sin(P->phi0);
+			Q->cosph0 = cos(P->phi0);
 		}
 	}
 	P->fwd = s_forward;
 	P->es = 0.;
-ENDENTRY(P)
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_airy_selftest (void) {return 0;}
+#else
+
+int pj_airy_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=airy   +a=6400000    +lat_1=0 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 189109.88690862127,   94583.752387504152},
+        { 189109.88690862127,  -94583.752387504152},
+        {-189109.88690862127,   94583.752387504152},
+        {-189109.88690862127,  -94583.752387504152},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 0, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+#endif
diff --git a/src/PJ_aitoff.c b/src/PJ_aitoff.c
index d5350f2..b7f33d2 100644
--- a/src/PJ_aitoff.c
+++ b/src/PJ_aitoff.c
@@ -2,7 +2,9 @@
  * Project:  PROJ.4
  * Purpose:  Implementation of the aitoff (Aitoff) and wintri (Winkel Tripel)
  *           projections.
- * Author:   Gerald Evenden
+ * Author:   Gerald Evenden (1995)
+ *           Drazen Tutic, Lovro Gradiser (2015) - add inverse
+ *           Thomas Knudsen (2016) - revise/add regression tests
  *
  ******************************************************************************
  * Copyright (c) 1995, Gerald Evenden
@@ -26,23 +28,29 @@
  * DEALINGS IN THE SOFTWARE.
  *****************************************************************************/
 
-#define PROJ_PARMS__ \
-	double	cosphi1; \
-	int		mode;
 #define PJ_LIB__
 #include <projects.h>
 
-#ifndef M_PI
-#  define M_PI 3.14159265358979323846
-#endif
-#ifndef M_PI_2
-#  define M_PI_2 1.57079632679489661923
-#endif
+
+struct pj_opaque {
+	double	cosphi1;
+	int		mode;
+};
+
 
 PROJ_HEAD(aitoff, "Aitoff") "\n\tMisc Sph";
 PROJ_HEAD(wintri, "Winkel Tripel") "\n\tMisc Sph\n\tlat_1";
 
+
+
+#if 0
 FORWARD(s_forward); /* spheroid */
+#endif
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double c, d;
 
 	if((d = acos(cos(lp.phi) * cos(c = 0.5 * lp.lam)))) {/* basic Aitoff */
@@ -50,8 +58,8 @@ FORWARD(s_forward); /* spheroid */
 		xy.y *= d * sin(lp.phi);
 	} else
 		xy.x = xy.y = 0.;
-	if (P->mode) { /* Winkel Tripel */
-		xy.x = (xy.x + lp.lam * P->cosphi1) * 0.5;
+	if (Q->mode) { /* Winkel Tripel */
+		xy.x = (xy.x + lp.lam * Q->cosphi1) * 0.5;
 		xy.y = (xy.y + lp.phi) * 0.5;
 	}
 	return (xy);
@@ -60,13 +68,13 @@ FORWARD(s_forward); /* spheroid */
 /***********************************************************************************
 *
 * Inverse functions added by Drazen Tutic and Lovro Gradiser based on paper:
-*           
-* I.Özbug Biklirici and Cengizhan Ipbüker. A General Algorithm for the Inverse 
+*
+* I.Özbug Biklirici and Cengizhan Ipbüker. A General Algorithm for the Inverse
 * Transformation of Map Projections Using Jacobian Matrices. In Proceedings of the
 * Third International Symposium Mathematical & Computational Applications,
 * pages 175{182, Turkey, September 2002.
 *
-* Expected accuracy is defined by EPSILON = 1e-12. Should be appropriate for 
+* Expected accuracy is defined by EPSILON = 1e-12. Should be appropriate for
 * most applications of Aitoff and Winkel Tripel projections.
 *
 * Longitudes of 180W and 180E can be mixed in solution obtained.
@@ -78,19 +86,21 @@ FORWARD(s_forward); /* spheroid */
 *
 ************************************************************************************/
 
-INVERSE(s_inverse); /* sphere */  
-        int iter, MAXITER = 10, round = 0, MAXROUND = 20;
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    int iter, MAXITER = 10, round = 0, MAXROUND = 20;
 	double EPSILON = 1e-12, D, C, f1, f2, f1p, f1l, f2p, f2l, dp, dl, sl, sp, cp, cl, x, y;
 
-	if ((fabs(xy.x) < EPSILON) && (fabs(xy.y) < EPSILON )) { lp.phi = 0.; lp.lam = 0.; return (lp); }
+	if ((fabs(xy.x) < EPSILON) && (fabs(xy.y) < EPSILON )) { lp.phi = 0.; lp.lam = 0.; return lp; }
 
 	/* intial values for Newton-Raphson method */
-	lp.phi = xy.y; lp.lam = xy.x; 
+	lp.phi = xy.y; lp.lam = xy.x;
 	do {
-		iter = 0; 
-		do { 
-			sl = sin(lp.lam * 0.5); cl = cos(lp.lam * 0.5); 
-			sp = sin(lp.phi); cp = cos(lp.phi); 
+		iter = 0;
+		do {
+			sl = sin(lp.lam * 0.5); cl = cos(lp.lam * 0.5);
+			sp = sin(lp.phi); cp = cos(lp.phi);
 			D = cp * cl;
  		      	C = 1. - D * D;
 			D = acos(D) / pow(C, 1.5);
@@ -100,11 +110,11 @@ INVERSE(s_inverse); /* sphere */
 		       	f1l = cp * cp * sl * sl / C + D * cp * cl * sp * sp;
 		    	f2p = sp * sp * cl / C + D * sl * sl * cp;
 		      	f2l = 0.5 * (sp * cp * sl / C - D * sp * cp * cp * sl * cl);
-		      	if (P->mode) { /* Winkel Tripel */
-				f1 = 0.5 * (f1 + lp.lam * P->cosphi1);
+		      	if (Q->mode) { /* Winkel Tripel */
+				f1 = 0.5 * (f1 + lp.lam * Q->cosphi1);
 				f2 = 0.5 * (f2 + lp.phi);
 				f1p *= 0.5;
-				f1l = 0.5 * (f1l + P->cosphi1);
+				f1l = 0.5 * (f1l + Q->cosphi1);
 				f2p = 0.5 * (f2p + 1.);
 				f2l *= 0.5;
 			}
@@ -115,9 +125,9 @@ INVERSE(s_inverse); /* sphere */
 			while (dl < -M_PI) dl += M_PI; /* set to interval [-M_PI, M_PI]  */
 			lp.phi -= dp;	lp.lam -= dl;
 		} while ((fabs(dp) > EPSILON || fabs(dl) > EPSILON) && (iter++ < MAXITER));
-		if (lp.phi > M_PI_2) lp.phi -= 2.*(lp.phi-M_PI_2); /* correct if symmetrical solution for Aitoff */ 
-		if (lp.phi < -M_PI_2) lp.phi -= 2.*(lp.phi+M_PI_2); /* correct if symmetrical solution for Aitoff */ 
-		if ((fabs(fabs(lp.phi) - M_PI_2) < EPSILON) && (!P->mode)) lp.lam = 0.; /* if pole in Aitoff, return longitude of 0 */ 
+		if (lp.phi > M_PI_2) lp.phi -= 2.*(lp.phi-M_PI_2); /* correct if symmetrical solution for Aitoff */
+		if (lp.phi < -M_PI_2) lp.phi -= 2.*(lp.phi+M_PI_2); /* correct if symmetrical solution for Aitoff */
+		if ((fabs(fabs(lp.phi) - M_PI_2) < EPSILON) && (!Q->mode)) lp.lam = 0.; /* if pole in Aitoff, return longitude of 0 */
 
 		/* calculate x,y coordinates with solution obtained */
 		if((D = acos(cos(lp.phi) * cos(C = 0.5 * lp.lam)))) {/* Aitoff */
@@ -125,8 +135,8 @@ INVERSE(s_inverse); /* sphere */
 			y *= D * sin(lp.phi);
 		} else
 			x = y = 0.;
-		if (P->mode) { /* Winkel Tripel */
-			x = (x + lp.lam * P->cosphi1) * 0.5;
+		if (Q->mode) { /* Winkel Tripel */
+			x = (x + lp.lam * Q->cosphi1) * 0.5;
 			y = (y + lp.phi) * 0.5;
 		}
 	/* if too far from given values of x,y, repeat with better approximation of phi,lam */
@@ -134,27 +144,150 @@ INVERSE(s_inverse); /* sphere */
 
 	if (iter == MAXITER && round == MAXROUND) fprintf(stderr, "Warning: Accuracy of 1e-12 not reached. Last increments: dlat=%e and dlon=%e\n", dp, dl);
 
-	return (lp);
+	return lp;
+}
+
+
+
+static void *freeup_new (PJ *P) {                        /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
 
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) {
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+static PJ *setup(PJ *P) {
 	P->inv = s_inverse;
 	P->fwd = s_forward;
 	P->es = 0.;
 	return P;
 }
-ENTRY0(aitoff)
-	P->mode = 0;
-ENDENTRY(setup(P))
-ENTRY0(wintri)
-	P->mode = 1;
-	if (pj_param(P->ctx, P->params, "tlat_1").i)
-        {
-		if ((P->cosphi1 = cos(pj_param(P->ctx, P->params, "rlat_1").f)) == 0.)
+
+
+PJ *PROJECTION(aitoff) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	Q->mode = 0;
+    return setup(P);
+}
+
+
+PJ *PROJECTION(wintri) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	Q->mode = 1;
+	if (pj_param(P->ctx, P->params, "tlat_1").i) {
+		if ((Q->cosphi1 = cos(pj_param(P->ctx, P->params, "rlat_1").f)) == 0.)
 			E_ERROR(-22)
-        }
+    }
 	else /* 50d28' or acos(2/pi) */
-		P->cosphi1 = 0.636619772367581343;
-ENDENTRY(setup(P))
+		Q->cosphi1 = 0.636619772367581343;
+    return setup(P);
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_aitoff_selftest (void) {return 0;}
+#else
+
+int pj_aitoff_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=aitoff   +a=6400000    +lat_1=0 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+
+    XY s_fwd_expect[] = {
+        {223379.45881169615,  111706.74288385305},
+        {223379.45881169615,  -111706.74288385305},
+        {-223379.45881169615,  111706.74288385305},
+        {-223379.45881169615,  -111706.74288385305},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+
+    LP s_inv_expect[] = {
+        {0.0017904931100388164,  0.00089524655491012516},
+        {0.0017904931100388164,  -0.00089524655491012516},
+        {-0.0017904931100388164,  0.00089524655491012516},
+        {-0.0017904931100388164,  -0.00089524655491012516},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_wintri_selftest (void) {return 0;}
+#else
+
+int pj_wintri_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=wintri   +a=6400000    +lat_1=0 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {223390.80153348515,  111703.90750574505},
+        {223390.80153348515,  -111703.90750574505},
+        {-223390.80153348515,  111703.90750574505},
+        {-223390.80153348515,  -111703.90750574505},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017904931099113196,  0.00089524655490101819},
+        {0.0017904931099113196,  -0.00089524655490101819},
+        {-0.0017904931099113196,  0.00089524655490101819},
+        {-0.0017904931099113196,  -0.00089524655490101819},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_august.c b/src/PJ_august.c
index 496fc3c..83463e9 100644
--- a/src/PJ_august.c
+++ b/src/PJ_august.c
@@ -1,8 +1,13 @@
 #define PJ_LIB__
 #include	<projects.h>
+
+
 PROJ_HEAD(august, "August Epicycloidal") "\n\tMisc Sph, no inv.";
 #define M 1.333333333333333
-FORWARD(s_forward); /* spheroid */
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
 	double t, c1, c, x1, x12, y1, y12;
 	(void) P;
 
@@ -15,5 +20,52 @@ FORWARD(s_forward); /* spheroid */
 	xy.y = M * y1 * (3. + 3. * x12 - y12);
 	return (xy);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(august) P->inv = 0; P->fwd = s_forward; P->es = 0.; ENDENTRY(P)
+
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(august) {
+    P->inv = 0;
+    P->fwd = s_forward;
+    P->es = 0.;
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_august_selftest (void) {return 0;}
+#else
+
+int pj_august_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=august   +a=6400000    +lat_1=0 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {223404.97818097242,  111722.34028976287},
+        {223404.97818097242,  -111722.34028976287},
+        {-223404.97818097242,  111722.34028976287},
+        {-223404.97818097242,  -111722.34028976287},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_bacon.c b/src/PJ_bacon.c
index dfc559b..ce6725c 100644
--- a/src/PJ_bacon.c
+++ b/src/PJ_bacon.c
@@ -1,20 +1,28 @@
-# define HLFPI2	2.46740110027233965467
+# define HLFPI2	2.46740110027233965467      /* (pi/2)^2 */
 # define EPS	1e-10
-#define PROJ_PARMS__ \
-	int bacn; \
-	int ortl;
 #define PJ_LIB__
 #include	<projects.h>
+
+
+struct pj_opaque {
+	int bacn;
+	int ortl;
+};
+
 PROJ_HEAD(apian, "Apian Globular I") "\n\tMisc Sph, no inv.";
 PROJ_HEAD(ortel, "Ortelius Oval") "\n\tMisc Sph, no inv.";
 PROJ_HEAD(bacon, "Bacon Globular") "\n\tMisc Sph, no inv.";
-FORWARD(s_forward); /* spheroid */
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double ax, f;
 
-	xy.y = P->bacn ? HALFPI * sin(lp.phi) : lp.phi;
+	xy.y = Q->bacn ? M_HALFPI * sin(lp.phi) : lp.phi;
 	if ((ax = fabs(lp.lam)) >= EPS) {
-		if (P->ortl && ax >= HALFPI)
-			xy.x = sqrt(HLFPI2 - lp.phi * lp.phi + EPS) + ax - HALFPI;
+		if (Q->ortl && ax >= M_HALFPI)
+			xy.x = sqrt(HLFPI2 - lp.phi * lp.phi + EPS) + ax - M_HALFPI;
 		else {
 			f = 0.5 * (HLFPI2 / ax + ax);
 			xy.x = ax - f + sqrt(f * f - xy.y * xy.y);
@@ -24,18 +32,148 @@ FORWARD(s_forward); /* spheroid */
 		xy.x = 0.;
 	return (xy);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(bacon)
-	P->bacn = 1;
-	P->ortl = 0;
-	P->es = 0.; P->fwd = s_forward;
-ENDENTRY(P)
-ENTRY0(apian)
-	P->bacn = P->ortl = 0;
-	P->es = 0.; P->fwd = s_forward;
-ENDENTRY(P)
-ENTRY0(ortel)
-	P->bacn = 0;
-	P->ortl = 1;
-	P->es = 0.; P->fwd = s_forward;
-ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(bacon) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	Q->bacn = 1;
+	Q->ortl = 0;
+	P->es = 0.;
+    P->fwd = s_forward;
+    return P;
+}
+
+
+PJ *PROJECTION(apian) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	Q->bacn = Q->ortl = 0;
+	P->es = 0.;
+    P->fwd = s_forward;
+    return P;
+}
+
+
+PJ *PROJECTION(ortel) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	Q->bacn = 0;
+	Q->ortl = 1;
+	P->es = 0.;
+    P->fwd = s_forward;
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_bacon_selftest (void) {return 0;}
+#else
+int pj_bacon_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=bacon   +a=6400000    +lat_1=0 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {223334.13255596498,  175450.72592266591},
+        {223334.13255596498,  -175450.72592266591},
+        {-223334.13255596498,  175450.72592266591},
+        {-223334.13255596498,  -175450.72592266591},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 0, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+#endif
+
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_apian_selftest (void) {return 0;}
+#else
+int pj_apian_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=apian   +a=6400000    +lat_1=0 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223374.57735525275,   111701.07212763709},
+        { 223374.57735525275,  -111701.07212763709},
+        {-223374.57735525275,   111701.07212763709},
+        {-223374.57735525275,  -111701.07212763709},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 0, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+#endif
+
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_ortel_selftest (void) {return 0;}
+#else
+int pj_ortel_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=ortel   +a=6400000    +lat_1=0 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223374.57735525275,   111701.07212763709},
+        { 223374.57735525275,  -111701.07212763709},
+        {-223374.57735525275,   111701.07212763709},
+        {-223374.57735525275,  -111701.07212763709},
+    };
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 0, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+#endif
+
diff --git a/src/PJ_bipc.c b/src/PJ_bipc.c
index 471e726..2a5b310 100644
--- a/src/PJ_bipc.c
+++ b/src/PJ_bipc.c
@@ -1,132 +1,224 @@
-#define PROJ_PARMS__ \
-	int	noskew;
 #define PJ_LIB__
-# include	<projects.h>
-PROJ_HEAD(bipc, "Bipolar conic of western hemisphere")
-	"\n\tConic Sph.";
-# define EPS	1e-10
-# define EPS10	1e-10
+#include <projects.h>
+
+PROJ_HEAD(bipc, "Bipolar conic of western hemisphere") "\n\tConic Sph.";
+
+# define EPS    1e-10
+# define EPS10  1e-10
 # define ONEEPS 1.000000001
-# define NITER	10
-# define lamB	-.34894976726250681539
-# define n	.63055844881274687180
-# define F	1.89724742567461030582
-# define Azab	.81650043674686363166
-# define Azba	1.82261843856185925133
-# define T	1.27246578267089012270
-# define rhoc	1.20709121521568721927
-# define cAzc	.69691523038678375519
-# define sAzc	.71715351331143607555
-# define C45	.70710678118654752469
-# define S45	.70710678118654752410
-# define C20	.93969262078590838411
-# define S20	-.34202014332566873287
-# define R110	1.91986217719376253360
-# define R104	1.81514242207410275904
-FORWARD(s_forward); /* spheroid */
-	double cphi, sphi, tphi, t, al, Az, z, Av, cdlam, sdlam, r;
-	int tag;
-
-	cphi = cos(lp.phi);
-	sphi = sin(lp.phi);
-	cdlam = cos(sdlam = lamB - lp.lam);
-	sdlam = sin(sdlam);
-	if (fabs(fabs(lp.phi) - HALFPI) < EPS10) {
-		Az = lp.phi < 0. ? PI : 0.;
-		tphi = HUGE_VAL;
-	} else {
-		tphi = sphi / cphi;
-		Az = atan2(sdlam , C45 * (tphi - cdlam));
-	}
-	if( (tag = (Az > Azba)) ) {
-		cdlam = cos(sdlam = lp.lam + R110);
-		sdlam = sin(sdlam);
-		z = S20 * sphi + C20 * cphi * cdlam;
-		if (fabs(z) > 1.) {
-			if (fabs(z) > ONEEPS) F_ERROR
-			else z = z < 0. ? -1. : 1.;
-		} else
-			z = acos(z);
-		if (tphi != HUGE_VAL)
-			Az = atan2(sdlam, (C20 * tphi - S20 * cdlam));
-		Av = Azab;
-		xy.y = rhoc;
-	} else {
-		z = S45 * (sphi + cphi * cdlam);
-		if (fabs(z) > 1.) {
-			if (fabs(z) > ONEEPS) F_ERROR
-			else z = z < 0. ? -1. : 1.;
-		} else
-			z = acos(z);
-		Av = Azba;
-		xy.y = -rhoc;
-	}
-	if (z < 0.) F_ERROR;
-	r = F * (t = pow(tan(.5 * z), n));
-	if ((al = .5 * (R104 - z)) < 0.) F_ERROR;
-	al = (t + pow(al, n)) / T;
-	if (fabs(al) > 1.) {
-		if (fabs(al) > ONEEPS) F_ERROR
-		else al = al < 0. ? -1. : 1.;
-	} else
-		al = acos(al);
-	if (fabs(t = n * (Av - Az)) < al)
-		r /= cos(al + (tag ? t : -t));
-	xy.x = r * sin(t);
-	xy.y += (tag ? -r : r) * cos(t);
-	if (P->noskew) {
-		t = xy.x;
-		xy.x = -xy.x * cAzc - xy.y * sAzc; 
-		xy.y = -xy.y * cAzc + t * sAzc; 
-	}
-	return (xy);
+# define NITER  10
+# define lamB   -.34894976726250681539
+# define n  .63055844881274687180
+# define F  1.89724742567461030582
+# define Azab   .81650043674686363166
+# define Azba   1.82261843856185925133
+# define T  1.27246578267089012270
+# define rhoc   1.20709121521568721927
+# define cAzc   .69691523038678375519
+# define sAzc   .71715351331143607555
+# define C45    .70710678118654752469
+# define S45    .70710678118654752410
+# define C20    .93969262078590838411
+# define S20    -.34202014332566873287
+# define R110   1.91986217719376253360
+# define R104   1.81514242207410275904
+
+
+struct pj_opaque {
+    int noskew;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double cphi, sphi, tphi, t, al, Az, z, Av, cdlam, sdlam, r;
+    int tag;
+
+    cphi = cos(lp.phi);
+    sphi = sin(lp.phi);
+    cdlam = cos(sdlam = lamB - lp.lam);
+    sdlam = sin(sdlam);
+    if (fabs(fabs(lp.phi) - M_HALFPI) < EPS10) {
+        Az = lp.phi < 0. ? M_PI : 0.;
+        tphi = HUGE_VAL;
+    } else {
+        tphi = sphi / cphi;
+        Az = atan2(sdlam , C45 * (tphi - cdlam));
+    }
+    if( (tag = (Az > Azba)) ) {
+        cdlam = cos(sdlam = lp.lam + R110);
+        sdlam = sin(sdlam);
+        z = S20 * sphi + C20 * cphi * cdlam;
+        if (fabs(z) > 1.) {
+            if (fabs(z) > ONEEPS) F_ERROR
+            else z = z < 0. ? -1. : 1.;
+        } else
+            z = acos(z);
+        if (tphi != HUGE_VAL)
+            Az = atan2(sdlam, (C20 * tphi - S20 * cdlam));
+        Av = Azab;
+        xy.y = rhoc;
+    } else {
+        z = S45 * (sphi + cphi * cdlam);
+        if (fabs(z) > 1.) {
+            if (fabs(z) > ONEEPS) F_ERROR
+            else z = z < 0. ? -1. : 1.;
+        } else
+            z = acos(z);
+        Av = Azba;
+        xy.y = -rhoc;
+    }
+    if (z < 0.) F_ERROR;
+    r = F * (t = pow(tan(.5 * z), n));
+    if ((al = .5 * (R104 - z)) < 0.) F_ERROR;
+    al = (t + pow(al, n)) / T;
+    if (fabs(al) > 1.) {
+        if (fabs(al) > ONEEPS) F_ERROR
+        else al = al < 0. ? -1. : 1.;
+    } else
+        al = acos(al);
+    if (fabs(t = n * (Av - Az)) < al)
+        r /= cos(al + (tag ? t : -t));
+    xy.x = r * sin(t);
+    xy.y += (tag ? -r : r) * cos(t);
+    if (Q->noskew) {
+        t = xy.x;
+        xy.x = -xy.x * cAzc - xy.y * sAzc;
+        xy.y = -xy.y * cAzc + t * sAzc;
+    }
+    return (xy);
 }
-INVERSE(s_inverse); /* spheroid */
-	double t, r, rp, rl, al, z, fAz, Az, s, c, Av;
-	int neg, i;
-
-	if (P->noskew) {
-		t = xy.x;
-		xy.x = -xy.x * cAzc + xy.y * sAzc; 
-		xy.y = -xy.y * cAzc - t * sAzc; 
-	}
-	if( (neg = (xy.x < 0.)) ) {
-		xy.y = rhoc - xy.y;
-		s = S20;
-		c = C20;
-		Av = Azab;
-	} else {
-		xy.y += rhoc;
-		s = S45;
-		c = C45;
-		Av = Azba;
-	}
-	rl = rp = r = hypot(xy.x, xy.y);
-	fAz = fabs(Az = atan2(xy.x, xy.y));
-	for (i = NITER; i ; --i) {
-		z = 2. * atan(pow(r / F,1 / n));
-		al = acos((pow(tan(.5 * z), n) +
-		   pow(tan(.5 * (R104 - z)), n)) / T);
-		if (fAz < al)
-			r = rp * cos(al + (neg ? Az : -Az));
-		if (fabs(rl - r) < EPS)
-			break;
-		rl = r;
-	}
-	if (! i) I_ERROR;
-	Az = Av - Az / n;
-	lp.phi = asin(s * cos(z) + c * sin(z) * cos(Az));
-	lp.lam = atan2(sin(Az), c / tan(z) - s * cos(Az));
-	if (neg)
-		lp.lam -= R110;
-	else
-		lp.lam = lamB - lp.lam;
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double t, r, rp, rl, al, z, fAz, Az, s, c, Av;
+    int neg, i;
+
+    if (Q->noskew) {
+        t = xy.x;
+        xy.x = -xy.x * cAzc + xy.y * sAzc;
+        xy.y = -xy.y * cAzc - t * sAzc;
+    }
+    if( (neg = (xy.x < 0.)) ) {
+        xy.y = rhoc - xy.y;
+        s = S20;
+        c = C20;
+        Av = Azab;
+    } else {
+        xy.y += rhoc;
+        s = S45;
+        c = C45;
+        Av = Azba;
+    }
+    rl = rp = r = hypot(xy.x, xy.y);
+    fAz = fabs(Az = atan2(xy.x, xy.y));
+    for (i = NITER; i ; --i) {
+        z = 2. * atan(pow(r / F,1 / n));
+        al = acos((pow(tan(.5 * z), n) +
+           pow(tan(.5 * (R104 - z)), n)) / T);
+        if (fAz < al)
+            r = rp * cos(al + (neg ? Az : -Az));
+        if (fabs(rl - r) < EPS)
+            break;
+        rl = r;
+    }
+    if (! i) I_ERROR;
+    Az = Av - Az / n;
+    lp.phi = asin(s * cos(z) + c * sin(z) * cos(Az));
+    lp.lam = atan2(sin(Az), c / tan(z) - s * cos(Az));
+    if (neg)
+        lp.lam -= R110;
+    else
+        lp.lam = lamB - lp.lam;
+    return (lp);
+}
+
+
+static void *freeup_new (PJ *P) {                        /* Destructor */
+    if (0==P)
+        return 0;
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(bipc)
-	P->noskew = pj_param(P->ctx, P->params, "bns").i;
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-	P->es = 0.;
-ENDENTRY(P)
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(bipc) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->noskew = pj_param(P->ctx, P->params, "bns").i;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    P->es = 0.;
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_bipc_selftest (void) {return 0;}
+#else
+
+int pj_bipc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=bipc   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=bipc   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {2452160.2177257561,  -14548450.759654747},
+        {2447915.213725341,  -14763427.21279873},
+        {2021695.5229349085,  -14540413.695283702},
+        {2018090.5030046992,  -14755620.651414108},
+    };
+
+    XY s_fwd_expect[] = {
+        {2460565.7409749646,  -14598319.9893308},
+        {2456306.1859352002,  -14814033.339502094},
+        {2028625.4978190989,  -14590255.375482792},
+        {2025008.1205891429,  -14806200.018759441},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {-73.038700284978702,  17.248118466239116},
+        {-73.03730373933017,  17.249414978178777},
+        {-73.03589317304332,  17.245536403008771},
+        {-73.034496627213585,  17.246832895573739},
+    };
+
+    LP s_inv_expect[] = {
+        {-73.038693104942126,  17.248116270440242},
+        {-73.037301330021322,  17.24940835333777},
+        {-73.035895582251086,  17.245543027866539},
+        {-73.034503807150301,  17.246835091521532},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_boggs.c b/src/PJ_boggs.c
index b22a25f..1bc7de1 100644
--- a/src/PJ_boggs.c
+++ b/src/PJ_boggs.c
@@ -7,17 +7,19 @@ PROJ_HEAD(boggs, "Boggs Eumorphic") "\n\tPCyl., no inv., Sph.";
 # define FXC	2.00276
 # define FXC2	1.11072
 # define FYC	0.49931
-# define FYC2	1.41421356237309504880
-FORWARD(s_forward); /* spheroid */
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
 	double theta, th1, c;
 	int i;
 	(void) P;
 
 	theta = lp.phi;
-	if (fabs(fabs(lp.phi) - HALFPI) < EPS)
+	if (fabs(fabs(lp.phi) - M_HALFPI) < EPS)
 		xy.x = 0.;
 	else {
-		c = sin(theta) * PI;
+		c = sin(theta) * M_PI;
 		for (i = NITER; i; --i) {
 			theta -= th1 = (theta + sin(theta) - c) /
 				(1. + cos(theta));
@@ -26,8 +28,50 @@ FORWARD(s_forward); /* spheroid */
 		theta *= 0.5;
 		xy.x = FXC * lp.lam / (1. / cos(lp.phi) + FXC2 / cos(theta));
 	}
-	xy.y = FYC * (lp.phi + FYC2 * sin(theta));
+	xy.y = FYC * (lp.phi + M_SQRT2 * sin(theta));
 	return (xy);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(boggs) P->es = 0.; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                        /* Destructor */
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(boggs) {
+    P->es = 0.;
+    P->fwd = s_forward;
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_boggs_selftest (void) {return 0;}
+#else
+int pj_boggs_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=boggs   +a=6400000    +lat_1=0 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 211949.70080818201,   117720.99830541089},
+        { 211949.70080818201,  -117720.99830541089},
+        {-211949.70080818201,   117720.99830541089},
+        {-211949.70080818201,  -117720.99830541089},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 0, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+#endif
diff --git a/src/PJ_bonne.c b/src/PJ_bonne.c
index 4b1e786..56656f1 100644
--- a/src/PJ_bonne.c
+++ b/src/PJ_bonne.c
@@ -1,85 +1,180 @@
-#define PROJ_PARMS__ \
-	double phi1; \
-	double cphi1; \
-	double am1; \
-	double m1; \
-	double *en;
 #define PJ_LIB__
 #include	<projects.h>
+
 PROJ_HEAD(bonne, "Bonne (Werner lat_1=90)")
 	"\n\tConic Sph&Ell\n\tlat_1=";
 #define EPS10	1e-10
-FORWARD(e_forward); /* ellipsoid */
+
+struct pj_opaque {
+	double phi1;
+	double cphi1;
+	double am1;
+	double m1;
+	double *en;
+};
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double rh, E, c;
 
-	rh = P->am1 + P->m1 - pj_mlfn(lp.phi, E = sin(lp.phi), c = cos(lp.phi), P->en);
+	rh = Q->am1 + Q->m1 - pj_mlfn(lp.phi, E = sin(lp.phi), c = cos(lp.phi), Q->en);
 	E = c * lp.lam / (rh * sqrt(1. - P->es * E * E));
 	xy.x = rh * sin(E);
-	xy.y = P->am1 - rh * cos(E);
-	return (xy);
+	xy.y = Q->am1 - rh * cos(E);
+	return xy;
 }
-FORWARD(s_forward); /* spheroid */
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double E, rh;
 
-	rh = P->cphi1 + P->phi1 - lp.phi;
+	rh = Q->cphi1 + Q->phi1 - lp.phi;
 	if (fabs(rh) > EPS10) {
 		xy.x = rh * sin(E = lp.lam * cos(lp.phi) / rh);
-		xy.y = P->cphi1 - rh * cos(E);
+		xy.y = Q->cphi1 - rh * cos(E);
 	} else
 		xy.x = xy.y = 0.;
-	return (xy);
+	return xy;
 }
-INVERSE(s_inverse); /* spheroid */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double rh;
 
-	rh = hypot(xy.x, xy.y = P->cphi1 - xy.y);
-	lp.phi = P->cphi1 + P->phi1 - rh;
-	if (fabs(lp.phi) > HALFPI) I_ERROR;
-	if (fabs(fabs(lp.phi) - HALFPI) <= EPS10)
+	rh = hypot(xy.x, xy.y = Q->cphi1 - xy.y);
+	lp.phi = Q->cphi1 + Q->phi1 - rh;
+	if (fabs(lp.phi) > M_HALFPI) I_ERROR;
+	if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10)
 		lp.lam = 0.;
 	else
 		lp.lam = rh * atan2(xy.x, xy.y) / cos(lp.phi);
-	return (lp);
+	return lp;
 }
-INVERSE(e_inverse); /* ellipsoid */
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double s, rh;
 
-	rh = hypot(xy.x, xy.y = P->am1 - xy.y);
-	lp.phi = pj_inv_mlfn(P->ctx, P->am1 + P->m1 - rh, P->es, P->en);
-	if ((s = fabs(lp.phi)) < HALFPI) {
+	rh = hypot(xy.x, xy.y = Q->am1 - xy.y);
+	lp.phi = pj_inv_mlfn(P->ctx, Q->am1 + Q->m1 - rh, P->es, Q->en);
+	if ((s = fabs(lp.phi)) < M_HALFPI) {
 		s = sin(lp.phi);
 		lp.lam = rh * atan2(xy.x, xy.y) *
 		   sqrt(1. - P->es * s * s) / cos(lp.phi);
-	} else if (fabs(s - HALFPI) <= EPS10)
+	} else if (fabs(s - M_HALFPI) <= EPS10)
 		lp.lam = 0.;
 	else I_ERROR;
-	return (lp);
+	return lp;
 }
-FREEUP;
-	if (P) {
-		if (P->en)
-			pj_dalloc(P->en);
-		pj_dalloc(P);
-	}
+
+
+static void *freeup_new (PJ *P) {                        /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque->en);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-ENTRY1(bonne, en)
+
+
+PJ *PROJECTION(bonne) {
 	double c;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
 
-	P->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
-	if (fabs(P->phi1) < EPS10) E_ERROR(-23);
+	Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
+	if (fabs(Q->phi1) < EPS10) E_ERROR(-23);
 	if (P->es) {
-		P->en = pj_enfn(P->es);
-		P->m1 = pj_mlfn(P->phi1, P->am1 = sin(P->phi1),
-			c = cos(P->phi1), P->en);
-		P->am1 = c / (sqrt(1. - P->es * P->am1 * P->am1) * P->am1);
+		Q->en = pj_enfn(P->es);
+		Q->m1 = pj_mlfn(Q->phi1, Q->am1 = sin(Q->phi1),
+			c = cos(Q->phi1), Q->en);
+		Q->am1 = c / (sqrt(1. - P->es * Q->am1 * Q->am1) * Q->am1);
 		P->inv = e_inverse;
 		P->fwd = e_forward;
 	} else {
-		if (fabs(P->phi1) + EPS10 >= HALFPI)
-			P->cphi1 = 0.;
+		if (fabs(Q->phi1) + EPS10 >= M_HALFPI)
+			Q->cphi1 = 0.;
 		else
-			P->cphi1 = 1. / tan(P->phi1);
+			Q->cphi1 = 1. / tan(Q->phi1);
 		P->inv = s_inverse;
 		P->fwd = s_forward;
 	}
-ENDENTRY(P)
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_bonne_selftest (void) {return 0;}
+#else
+int pj_bonne_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=bonne   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=bonne   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222605.29609715697,   55321.139565494814},
+        { 222605.29609923941,  -165827.64779905154},
+        {-222605.29609715697,   55321.139565494814},
+        {-222605.29609923941,  -165827.64779905154},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223368.11557252839,   55884.555246393575},
+        { 223368.11557463196,  -167517.59936969393},
+        {-223368.11557252839,   55884.555246393575},
+        {-223368.11557463196,  -167517.59936969393},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017966987691132891,  0.50090436853737497},
+        { 0.0017966982774478867,  0.4990956309655612},
+        {-0.0017966987691132891,  0.50090436853737497},
+        {-0.0017966982774478867,  0.4990956309655612},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017905615332457991,  0.50089524631087834},
+        { 0.0017905610449335603,  0.49910475320072978},
+        {-0.0017905615332457991,  0.50089524631087834},
+        {-0.0017905610449335603,  0.49910475320072978},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_calcofi.c b/src/PJ_calcofi.c
index 2d14293..23c42c4 100644
--- a/src/PJ_calcofi.c
+++ b/src/PJ_calcofi.c
@@ -1,25 +1,27 @@
 #define PJ_LIB__
 #include <projects.h>
+
+PROJ_HEAD(calcofi,
+    "Cal Coop Ocean Fish Invest Lines/Stations") "\n\tCyl, Sph&Ell";
+
 #include <string.h>
 #include <stdio.h>
 #include <math.h>
 #include <proj_api.h>
 #include <errno.h>
 
-/* Conversions for the California Cooperative Oceanic Fisheries Investigations 
+/* Conversions for the California Cooperative Oceanic Fisheries Investigations
 Line/Station coordinate system following the algorithm of:
-Eber, L.E., and  R.P. Hewitt. 1979. Conversion algorithms for the CALCOFI 
-station grid. California Cooperative Oceanic Fisheries Investigations Reports 
-20:135-137. (corrected for typographical errors). 
+Eber, L.E., and  R.P. Hewitt. 1979. Conversion algorithms for the CALCOFI
+station grid. California Cooperative Oceanic Fisheries Investigations Reports
+20:135-137. (corrected for typographical errors).
 http://www.calcofi.org/publications/calcofireports/v20/Vol_20_Eber___Hewitt.pdf
-They assume 1 unit of CalCOFI Line == 1/5 degree in longitude or 
-meridional units at reference point O, and similarly 1 unit of CalCOFI 
-Station == 1/15 of a degree at O. 
-By convention, CalCOFI Line/Station conversions use Clarke 1866 but we use 
+They assume 1 unit of CalCOFI Line == 1/5 degree in longitude or
+meridional units at reference point O, and similarly 1 unit of CalCOFI
+Station == 1/15 of a degree at O.
+By convention, CalCOFI Line/Station conversions use Clarke 1866 but we use
 whatever ellipsoid is provided. */
 
-PROJ_HEAD(calcofi, 
-    "Cal Coop Ocean Fish Invest Lines/Stations") "\n\tCyl, Sph&Ell";
 
 #define EPS10 1.e-10
 #define DEG_TO_LINE 5
@@ -31,17 +33,20 @@ PROJ_HEAD(calcofi,
 #define PT_O_LAMBDA -2.1144663887911301 /* lon -121.15 and */
 #define PT_O_PHI 0.59602993955606354 /* lat 34.15 */
 #define ROTATION_ANGLE 0.52359877559829882 /*CalCOFI angle of 30 deg in rad */
-FORWARD(e_forward); /* ellipsoid */
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
     double oy; /* pt O y value in Mercator */
     double l1; /* l1 and l2 are distances calculated using trig that sum
                to the east/west distance between point O and point xy */
     double l2;
-    double ry; /* r is the point on the same station as o (60) and the same 
+    double ry; /* r is the point on the same station as o (60) and the same
                line as xy xy, r, o form a right triangle */
-    /* if the user has specified +lon_0 or +k0 for some reason, 
+    /* if the user has specified +lon_0 or +k0 for some reason,
     we're going to ignore it so that xy is consistent with point O */
     lp.lam = lp.lam + P->lam0;
-    if (fabs(fabs(lp.phi) - HALFPI) <= EPS10) F_ERROR;
+    if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10) F_ERROR;
     xy.x = lp.lam;
     xy.y = -log(pj_tsfn(lp.phi, sin(lp.phi), P->e)); /* Mercator transform xy*/
     oy = -log(pj_tsfn(PT_O_PHI, sin(PT_O_PHI), P->e));
@@ -49,41 +54,47 @@ FORWARD(e_forward); /* ellipsoid */
     l2 = -xy.x - l1 + PT_O_LAMBDA;
     ry = l2 * cos(ROTATION_ANGLE) * sin(ROTATION_ANGLE) + xy.y;
     ry = pj_phi2(P->ctx, exp(-ry), P->e); /*inverse Mercator*/
-    xy.x = PT_O_LINE - RAD_TO_DEG * 
-        (ry - PT_O_PHI) * DEG_TO_LINE / cos(ROTATION_ANGLE); 
-    xy.y = PT_O_STATION + RAD_TO_DEG * 
+    xy.x = PT_O_LINE - RAD_TO_DEG *
+        (ry - PT_O_PHI) * DEG_TO_LINE / cos(ROTATION_ANGLE);
+    xy.y = PT_O_STATION + RAD_TO_DEG *
         (ry - lp.phi) * DEG_TO_STATION / sin(ROTATION_ANGLE);
     /* set a = 1, x0 = 0, and y0 = 0 so that no further unit adjustments
     are done */
     P->a = 1;
     P->x0 = 0;
     P->y0 = 0;
-    return (xy);
+    return xy;
 }
-FORWARD(s_forward); /* spheroid */
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
     double oy;
     double l1;
     double l2;
     double ry;
     lp.lam = lp.lam + P->lam0;
-    if (fabs(fabs(lp.phi) - HALFPI) <= EPS10) F_ERROR;
+    if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10) F_ERROR;
     xy.x = lp.lam;
-    xy.y = log(tan(FORTPI + .5 * lp.phi));
-    oy = log(tan(FORTPI + .5 * PT_O_PHI));
+    xy.y = log(tan(M_FORTPI + .5 * lp.phi));
+    oy = log(tan(M_FORTPI + .5 * PT_O_PHI));
     l1 = (xy.y - oy) * tan(ROTATION_ANGLE);
     l2 = -xy.x - l1 + PT_O_LAMBDA;
     ry = l2 * cos(ROTATION_ANGLE) * sin(ROTATION_ANGLE) + xy.y;
-    ry = HALFPI - 2. * atan(exp(-ry)); 
-    xy.x = PT_O_LINE - RAD_TO_DEG * 
-        (ry - PT_O_PHI) * DEG_TO_LINE / cos(ROTATION_ANGLE); 
-    xy.y = PT_O_STATION + RAD_TO_DEG * 
+    ry = M_HALFPI - 2. * atan(exp(-ry));
+    xy.x = PT_O_LINE - RAD_TO_DEG *
+        (ry - PT_O_PHI) * DEG_TO_LINE / cos(ROTATION_ANGLE);
+    xy.y = PT_O_STATION + RAD_TO_DEG *
         (ry - lp.phi) * DEG_TO_STATION / sin(ROTATION_ANGLE);
     P->a = 1;
     P->x0 = 0;
     P->y0 = 0;
-    return (xy);
+    return xy;
 }
-INVERSE(e_inverse); /* ellipsoid */
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
     double ry; /* y value of point r */
     double oymctr; /* Mercator-transformed y value of point O */
     double rymctr; /* Mercator-transformed ry */
@@ -93,7 +104,7 @@ INVERSE(e_inverse); /* ellipsoid */
     /* turn x and y back into Line/Station */
     xy.x /= P->ra;
     xy.y /= P->ra;
-    ry = PT_O_PHI - LINE_TO_RAD * (xy.x - PT_O_LINE) * 
+    ry = PT_O_PHI - LINE_TO_RAD * (xy.x - PT_O_LINE) *
         cos(ROTATION_ANGLE);
     lp.phi = ry - STATION_TO_RAD * (xy.y - PT_O_STATION) * sin(ROTATION_ANGLE);
     oymctr = -log(pj_tsfn(PT_O_PHI, sin(PT_O_PHI), P->e));
@@ -103,9 +114,12 @@ INVERSE(e_inverse); /* ellipsoid */
     l2 = (rymctr - xymctr) / (cos(ROTATION_ANGLE) * sin(ROTATION_ANGLE));
     lp.lam = PT_O_LAMBDA - (l1 + l2);
     P->over = 1;
-    return (lp);
+    return lp;
 }
-INVERSE(s_inverse); /* spheroid */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
     double ry;
     double oymctr;
     double rymctr;
@@ -114,20 +128,33 @@ INVERSE(s_inverse); /* spheroid */
     double l2;
     xy.x /= P->ra;
     xy.y /= P->ra;
-    ry = PT_O_PHI - LINE_TO_RAD * (xy.x - PT_O_LINE) * 
+    ry = PT_O_PHI - LINE_TO_RAD * (xy.x - PT_O_LINE) *
         cos(ROTATION_ANGLE);
     lp.phi = ry - STATION_TO_RAD * (xy.y - PT_O_STATION) * sin(ROTATION_ANGLE);
-    oymctr = log(tan(FORTPI + .5 * PT_O_PHI));
-    rymctr = log(tan(FORTPI + .5 * ry));
-    xymctr = log(tan(FORTPI + .5 * lp.phi));
+    oymctr = log(tan(M_FORTPI + .5 * PT_O_PHI));
+    rymctr = log(tan(M_FORTPI + .5 * ry));
+    xymctr = log(tan(M_FORTPI + .5 * lp.phi));
     l1 = (xymctr - oymctr) * tan(ROTATION_ANGLE);
     l2 = (rymctr - xymctr) / (cos(ROTATION_ANGLE) * sin(ROTATION_ANGLE));
     lp.lam = PT_O_LAMBDA - (l1 + l2);
     P->over = 1;
-    return (lp);
+    return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(calcofi)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc (P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(calcofi) {
+    P->opaque = 0;
+
     if (P->es) { /* ellipsoid */
         P->inv = e_inverse;
         P->fwd = e_forward;
@@ -135,4 +162,65 @@ ENTRY0(calcofi)
         P->inv = s_inverse;
         P->fwd = s_forward;
     }
-ENDENTRY(P)
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_calcofi_selftest (void) {return 0;}
+#else
+
+int pj_calcofi_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=calcofi   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=calcofi   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {508.44487214981905,  -1171.7648604175156},
+        {514.99916815188112,  -1145.8219814677668},
+        {500.68538412539851,  -1131.4453779204598},
+        {507.36971913666355,  -1106.1782014834275},
+    };
+
+    XY s_fwd_expect[] = {
+        {507.09050748781806,  -1164.7273751978314},
+        {513.68613637462886,  -1138.9992682173072},
+        {499.33626147591531,  -1124.4351309968195},
+        {506.0605703929898,  -1099.3756650673038},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {-110.36330792469906,  12.032056975840137},
+        {-98.455008863288782,  18.698723642506803},
+        {-207.4470245036909,  81.314089278595247},
+        {-62.486322854481287,  87.980755945261919},
+    };
+
+    LP s_inv_expect[] = {
+        {-110.30519040955151,  12.032056975840137},
+        {-98.322360950234085,  18.698723642506803},
+        {-207.54490681381429,  81.314089278595247},
+        {-62.576950371885275,  87.980755945261919},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_cass.c b/src/PJ_cass.c
index 38fa9db..28d35b9 100644
--- a/src/PJ_cass.c
+++ b/src/PJ_cass.c
@@ -1,79 +1,178 @@
-#define PROJ_PARMS__ \
-	double m0; \
-	double n; \
-	double t; \
-	double a1; \
-	double c; \
-	double r; \
-	double dd; \
-	double d2; \
-	double a2; \
-	double tn; \
-	double *en;
 #define PJ_LIB__
-# include	<projects.h>
+# include   <projects.h>
 PROJ_HEAD(cass, "Cassini") "\n\tCyl, Sph&Ell";
-# define EPS10	1e-10
-# define C1	.16666666666666666666
-# define C2	.00833333333333333333
-# define C3	.04166666666666666666
-# define C4	.33333333333333333333
-# define C5	.06666666666666666666
-FORWARD(e_forward); /* ellipsoid */
-	xy.y = pj_mlfn(lp.phi, P->n = sin(lp.phi), P->c = cos(lp.phi), P->en);
-	P->n = 1./sqrt(1. - P->es * P->n * P->n);
-	P->tn = tan(lp.phi); P->t = P->tn * P->tn;
-	P->a1 = lp.lam * P->c;
-	P->c *= P->es * P->c / (1 - P->es);
-	P->a2 = P->a1 * P->a1;
-	xy.x = P->n * P->a1 * (1. - P->a2 * P->t *
-		(C1 - (8. - P->t + 8. * P->c) * P->a2 * C2));
-	xy.y -= P->m0 - P->n * P->tn * P->a2 *
-		(.5 + (5. - P->t + 6. * P->c) * P->a2 * C3);
-	return (xy);
+
+
+# define EPS10  1e-10
+# define C1 .16666666666666666666
+# define C2 .00833333333333333333
+# define C3 .04166666666666666666
+# define C4 .33333333333333333333
+# define C5 .06666666666666666666
+
+
+struct pj_opaque {
+    double *en;
+    double m0;
+};
+
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    double n, t, a1, c, a2, tn;
+    XY xy = {0.0, 0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    xy.y = pj_mlfn (lp.phi, n = sin (lp.phi), c = cos (lp.phi), Q->en);
+
+    n  = 1./sqrt(1. - P->es * n*n);
+    tn = tan(lp.phi); t = tn * tn;
+    a1 = lp.lam * c;
+    c *= P->es * c / (1 - P->es);
+    a2 = a1 * a1;
+
+    xy.x = n * a1 * (1. - a2 * t *
+        (C1 - (8. - t + 8. * c) * a2 * C2));
+    xy.y -= Q->m0 - n * tn * a2 *
+        (.5 + (5. - t + 6. * c) * a2 * C3);
+
+    return xy;
+}
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0, 0.0};
+    xy.x  =  asin (cos (lp.phi) * sin (lp.lam));
+    xy.y  =  atan2 (tan (lp.phi), cos (lp.lam)) - P->phi0;
+    return xy;
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    double n, t, r, dd, d2, tn, ph1;
+    LP lp = {0.0, 0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    ph1 = pj_inv_mlfn (P->ctx, Q->m0 + xy.y, P->es, Q->en);
+    tn  = tan (ph1); t = tn*tn;
+    n   = sin (ph1);
+    r   = 1. / (1. - P->es * n * n);
+    n   = sqrt (r);
+    r  *= (1. - P->es) * n;
+    dd  = xy.x / n;
+    d2  = dd * dd;
+    lp.phi = ph1 - (n * tn / r) * d2 *
+        (.5 - (1. + 3. * t) * d2 * C3);
+    lp.lam = dd * (1. + t * d2 *
+        (-C4 + (1. + 3. * t) * d2 * C5)) / cos (ph1);
+    return lp;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double dd;
+    lp.phi = asin(sin(dd = xy.y + P->phi0) * cos(xy.x));
+    lp.lam = atan2(tan(xy.x), cos(dd));
+    return lp;
 }
-FORWARD(s_forward); /* spheroid */
-	xy.x = asin(cos(lp.phi) * sin(lp.lam));
-	xy.y = atan2(tan(lp.phi) , cos(lp.lam)) - P->phi0;
-	return (xy);
+
+
+static void *freeup_new(PJ *P) {                        /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc(P->opaque->en);
+    pj_dealloc(P->opaque);
+    return pj_dealloc(P);
 }
-INVERSE(e_inverse); /* ellipsoid */
-	double ph1;
-
-	ph1 = pj_inv_mlfn(P->ctx, P->m0 + xy.y, P->es, P->en);
-	P->tn = tan(ph1); P->t = P->tn * P->tn;
-	P->n = sin(ph1);
-	P->r = 1. / (1. - P->es * P->n * P->n);
-	P->n = sqrt(P->r);
-	P->r *= (1. - P->es) * P->n;
-	P->dd = xy.x / P->n;
-	P->d2 = P->dd * P->dd;
-	lp.phi = ph1 - (P->n * P->tn / P->r) * P->d2 *
-		(.5 - (1. + 3. * P->t) * P->d2 * C3);
-	lp.lam = P->dd * (1. + P->t * P->d2 *
-		(-C4 + (1. + 3. * P->t) * P->d2 * C5)) / cos(ph1);
-	return (lp);
+
+static void freeup(PJ *P) {                             /* Destructor */
+    freeup_new (P);
+    return;
 }
-INVERSE(s_inverse); /* spheroid */
-	lp.phi = asin(sin(P->dd = xy.y + P->phi0) * cos(xy.x));
-	lp.lam = atan2(tan(xy.x), cos(P->dd));
-	return (lp);
+
+PJ *PROJECTION(cass) {
+
+    /* Spheroidal? */
+    if (0==P->es) {
+        P->inv = s_inverse;
+        P->fwd = s_forward;
+        return P;
+    }
+
+    /* otherwise it's ellipsoidal */
+    P->opaque = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==P->opaque)
+        return freeup_new (P);
+
+    P->opaque->en = pj_enfn (P->es);
+    if (0==P->opaque->en)
+        return freeup_new (P);
+
+    P->opaque->m0 = pj_mlfn (P->phi0,  sin (P->phi0),  cos (P->phi0),  P->opaque->en);
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+
+    return P;
 }
-FREEUP;
-	if (P) {
-		if (P->en)
-			pj_dalloc(P->en);
-		pj_dalloc(P);
-	}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_cass_selftest (void) {return 0;}
+#else
+
+int pj_cass_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=cass   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=cass   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222605.28577699114,   110642.22925399939},
+        { 222605.28577699114,  -110642.22925399939},
+        {-222605.28577699114,   110642.22925399939},
+        {-222605.28577699114,  -110642.22925399939},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223368.10520348375,  111769.14504058579},
+        { 223368.10520348375, -111769.14504058579},
+        {-223368.10520348375,  111769.14504058579},
+        {-223368.10520348375, -111769.14504058579},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017966305684613522,   0.00090436947663183841},
+        { 0.0017966305684613522,  -0.00090436947663183841},
+        {-0.0017966305684613522,   0.00090436947663183841},
+        {-0.0017966305684613522,  -0.00090436947663183841},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931100023887,   0.00089524655445477922},
+        { 0.0017904931100023887,  -0.00089524655445477922},
+        {-0.0017904931100023887,   0.00089524655445477922},
+        {-0.0017904931100023887,  -0.00089524655445477922},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
 }
-ENTRY1(cass, en)
-	if (P->es) {
-		if (!(P->en = pj_enfn(P->es))) E_ERROR_0;
-		P->m0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), P->en);
-		P->inv = e_inverse;
-		P->fwd = e_forward;
-	} else {
-		P->inv = s_inverse;
-		P->fwd = s_forward;
-	}
-ENDENTRY(P)
+#endif
diff --git a/src/PJ_cc.c b/src/PJ_cc.c
index 0f57392..3419441 100644
--- a/src/PJ_cc.c
+++ b/src/PJ_cc.c
@@ -1,20 +1,89 @@
-#define PROJ_PARMS__ \
-	double ap;
 #define PJ_LIB__
 #include	<projects.h>
+
 PROJ_HEAD(cc, "Central Cylindrical") "\n\tCyl, Sph";
 #define EPS10 1.e-10
-FORWARD(s_forward); /* spheroid */
-	if (fabs(fabs(lp.phi) - HALFPI) <= EPS10) F_ERROR;
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+	if (fabs (fabs(lp.phi) - M_HALFPI) <= EPS10) F_ERROR;
 	xy.x = lp.lam;
 	xy.y = tan(lp.phi);
-	return (xy);
+	return xy;
 }
-INVERSE(s_inverse); /* spheroid */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
 	(void) P;
 	lp.phi = atan(xy.y);
 	lp.lam = xy.x;
-	return (lp);
+	return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(cc) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(cc) {
+    P->es = 0.;
+
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_cc_selftest (void) {return 0;}
+#else
+
+int pj_cc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=cc   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {223402.14425527418,  111712.41554059254},
+        {223402.14425527418,  -111712.41554059254},
+        {-223402.14425527418,  111712.41554059254},
+        {-223402.14425527418,  -111712.41554059254},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017904931097838226,  0.00089524655481905597},
+        {0.0017904931097838226,  -0.00089524655481905597},
+        {-0.0017904931097838226,  0.00089524655481905597},
+        {-0.0017904931097838226,  -0.00089524655481905597},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_cea.c b/src/PJ_cea.c
index 44c0a88..9042543 100644
--- a/src/PJ_cea.c
+++ b/src/PJ_cea.c
@@ -1,63 +1,155 @@
-#define PROJ_PARMS__ \
-	double qp; \
-	double *apa;
 #define PJ_LIB__
-# include	<projects.h>
+#include   <projects.h>
+
+struct pj_opaque {
+    double qp;
+    double *apa;
+};
+
 PROJ_HEAD(cea, "Equal Area Cylindrical") "\n\tCyl, Sph&Ell\n\tlat_ts=";
-# define EPS	1e-10
-FORWARD(e_forward); /* spheroid */
-	xy.x = P->k0 * lp.lam;
-	xy.y = .5 * pj_qsfn(sin(lp.phi), P->e, P->one_es) / P->k0;
-	return (xy);
-}
-FORWARD(s_forward); /* spheroid */
-	xy.x = P->k0 * lp.lam;
-	xy.y = sin(lp.phi) / P->k0;
-	return (xy);
-}
-INVERSE(e_inverse); /* spheroid */
-	lp.phi = pj_authlat(asin( 2. * xy.y * P->k0 / P->qp), P->apa);
-	lp.lam = xy.x / P->k0;
-	return (lp);
-}
-INVERSE(s_inverse); /* spheroid */
-	double t;
-
-	if ((t = fabs(xy.y *= P->k0)) - EPS <= 1.) {
-		if (t >= 1.)
-			lp.phi = xy.y < 0. ? -HALFPI : HALFPI;
-		else
-			lp.phi = asin(xy.y);
-		lp.lam = xy.x / P->k0;
-	} else I_ERROR;
-	return (lp);
-}
-FREEUP;
-	if (P) {
-		if (P->apa)
-			pj_dalloc(P->apa);
-		pj_dalloc(P);
-	}
-}
-ENTRY1(cea, apa)
-	double t = 0.0;
-
-	if (pj_param(P->ctx, P->params, "tlat_ts").i) {
-		P->k0 = cos(t = pj_param(P->ctx, P->params, "rlat_ts").f);
-		if (P->k0 < 0.) {
-			E_ERROR(-24);
-		}
-	}
-	if (P->es) {
-		t = sin(t);
-		P->k0 /= sqrt(1. - P->es * t * t);
-		P->e = sqrt(P->es);
-		if (!(P->apa = pj_authset(P->es))) E_ERROR_0;
-		P->qp = pj_qsfn(1., P->e, P->one_es);
-		P->inv = e_inverse;
-		P->fwd = e_forward;
-	} else {
-		P->inv = s_inverse;
-		P->fwd = s_forward;
-	}
-ENDENTRY(P)
+# define EPS    1e-10
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    xy.x = P->k0 * lp.lam;
+    xy.y = 0.5 * pj_qsfn (sin (lp.phi), P->e, P->one_es) / P->k0;
+    return xy;
+}
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    xy.x = P->k0 * lp.lam;
+    xy.y = sin(lp.phi) / P->k0;
+    return xy;
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    lp.phi = pj_authlat(asin( 2. * xy.y * P->k0 / P->opaque->qp), P->opaque->apa);
+    lp.lam = xy.x / P->k0;
+    return lp;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double t;
+
+    if ((t = fabs(xy.y *= P->k0)) - EPS <= 1.) {
+        if (t >= 1.)
+            lp.phi = xy.y < 0. ? -M_HALFPI : M_HALFPI;
+        else
+            lp.phi = asin(xy.y);
+        lp.lam = xy.x / P->k0;
+    } else I_ERROR;
+    return (lp);
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque->apa);
+    pj_dealloc (P->opaque);
+    return pj_dealloc (P);
+}
+
+static void freeup (PJ *P) {
+   freeup_new (P);
+    return;
+}
+
+PJ *PROJECTION(cea) {
+    double t = 0.0;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+
+    if (pj_param(P->ctx, P->params, "tlat_ts").i) {
+        P->k0 = cos(t = pj_param(P->ctx, P->params, "rlat_ts").f);
+        if (P->k0 < 0.) {
+            E_ERROR(-24);
+        }
+    }
+    if (P->es) {
+        t = sin(t);
+        P->k0 /= sqrt(1. - P->es * t * t);
+        P->e = sqrt(P->es);
+        if (!(Q->apa = pj_authset(P->es))) E_ERROR_0;
+        Q->qp = pj_qsfn(1., P->e, P->one_es);
+        P->inv = e_inverse;
+        P->fwd = e_forward;
+    } else {
+        P->inv = s_inverse;
+        P->fwd = s_forward;
+    }
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_cea_selftest (void) {return 0;}
+#else
+
+int pj_cea_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=cea   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=cea   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222638.981586547132,  110568.812396267356},
+        { 222638.981586547132, -110568.812396265886},
+        {-222638.981586547132,  110568.812396267356},
+        {-222638.981586547132, -110568.812396265886},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223402.144255274179,  111695.401198614476},
+        { 223402.144255274179, -111695.401198614476},
+        {-223402.144255274179,  111695.401198614476},
+        {-223402.144255274179, -111695.401198614476},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.00179663056823904264,  0.000904369476105564289},
+        { 0.00179663056823904264, -0.000904369476105564289},
+        {-0.00179663056823904264,  0.000904369476105564289},
+        {-0.00179663056823904264, -0.000904369476105564289},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179049310978382265,  0.000895246554928338998},
+        { 0.00179049310978382265, -0.000895246554928338998},
+        {-0.00179049310978382265,  0.000895246554928338998},
+        {-0.00179049310978382265, -0.000895246554928338998},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+#endif
diff --git a/src/PJ_chamb.c b/src/PJ_chamb.c
index 65f2112..f38dc6b 100644
--- a/src/PJ_chamb.c
+++ b/src/PJ_chamb.c
@@ -1,112 +1,179 @@
-typedef struct { double r, Az; } VECT;
-#define PROJ_PARMS__ \
-	struct { /* control point data */ \
-		double phi, lam; \
-		double cosphi, sinphi; \
-		VECT v; \
-		XY	p; \
-		double Az; \
-	} c[3]; \
-	XY p; \
-	double beta_0, beta_1, beta_2;
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
+typedef struct { double r, Az; } VECT;
+struct pj_opaque {
+    struct { /* control point data */
+        double phi, lam;
+        double cosphi, sinphi;
+        VECT v;
+        XY  p;
+        double Az;
+    } c[3];
+    XY p;
+    double beta_0, beta_1, beta_2;
+};
+
 PROJ_HEAD(chamb, "Chamberlin Trimetric") "\n\tMisc Sph, no inv."
 "\n\tlat_1= lon_1= lat_2= lon_2= lat_3= lon_3=";
-#include	<stdio.h>
+
+#include <stdio.h>
 #define THIRD 0.333333333333333333
 #define TOL 1e-9
-	static VECT /* distance and azimuth from point 1 to point 2 */
-vect(projCtx ctx, double dphi, double c1, double s1, double c2, double s2, double dlam) {
-	VECT v;
-	double cdl, dp, dl;
-
-	cdl = cos(dlam);
-	if (fabs(dphi) > 1. || fabs(dlam) > 1.)
-		v.r = aacos(ctx, s1 * s2 + c1 * c2 * cdl);
-	else { /* more accurate for smaller distances */
-		dp = sin(.5 * dphi);
-		dl = sin(.5 * dlam);
-		v.r = 2. * aasin(ctx,sqrt(dp * dp + c1 * c2 * dl * dl));
-	}
-	if (fabs(v.r) > TOL)
-		v.Az = atan2(c2 * sin(dlam), c1 * s2 - s1 * c2 * cdl);
-	else
-		v.r = v.Az = 0.;
-	return v;
+
+/* distance and azimuth from point 1 to point 2 */
+static VECT vect(projCtx ctx, double dphi, double c1, double s1, double c2, double s2, double dlam) {
+    VECT v;
+    double cdl, dp, dl;
+
+    cdl = cos(dlam);
+    if (fabs(dphi) > 1. || fabs(dlam) > 1.)
+        v.r = aacos(ctx, s1 * s2 + c1 * c2 * cdl);
+    else { /* more accurate for smaller distances */
+        dp = sin(.5 * dphi);
+        dl = sin(.5 * dlam);
+        v.r = 2. * aasin(ctx,sqrt(dp * dp + c1 * c2 * dl * dl));
+    }
+    if (fabs(v.r) > TOL)
+        v.Az = atan2(c2 * sin(dlam), c1 * s2 - s1 * c2 * cdl);
+    else
+        v.r = v.Az = 0.;
+    return v;
+}
+
+/* law of cosines */
+static double lc(projCtx ctx, double b,double c,double a) {
+    return aacos(ctx, .5 * (b * b + c * c - a * a) / (b * c));
+}
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double sinphi, cosphi, a;
+    VECT v[3];
+    int i, j;
+
+    sinphi = sin(lp.phi);
+    cosphi = cos(lp.phi);
+    for (i = 0; i < 3; ++i) { /* dist/azimiths from control */
+        v[i] = vect(P->ctx, lp.phi - Q->c[i].phi, Q->c[i].cosphi, Q->c[i].sinphi,
+            cosphi, sinphi, lp.lam - Q->c[i].lam);
+        if ( ! v[i].r)
+            break;
+        v[i].Az = adjlon(v[i].Az - Q->c[i].v.Az);
+    }
+    if (i < 3) /* current point at control point */
+        xy = Q->c[i].p;
+    else { /* point mean of intersepts */
+        xy = Q->p;
+        for (i = 0; i < 3; ++i) {
+            j = i == 2 ? 0 : i + 1;
+            a = lc(P->ctx,Q->c[i].v.r, v[i].r, v[j].r);
+            if (v[i].Az < 0.)
+                a = -a;
+            if (! i) { /* coord comp unique to each arc */
+                xy.x += v[i].r * cos(a);
+                xy.y -= v[i].r * sin(a);
+            } else if (i == 1) {
+                a = Q->beta_1 - a;
+                xy.x -= v[i].r * cos(a);
+                xy.y -= v[i].r * sin(a);
+            } else {
+                a = Q->beta_2 - a;
+                xy.x += v[i].r * cos(a);
+                xy.y += v[i].r * sin(a);
+            }
+        }
+        xy.x *= THIRD; /* mean of arc intercepts */
+        xy.y *= THIRD;
+    }
+    return xy;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-	static double /* law of cosines */
-lc(projCtx ctx, double b,double c,double a) {
-	return aacos(ctx, .5 * (b * b + c * c - a * a) / (b * c));
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FORWARD(s_forward); /* spheroid */
-	double sinphi, cosphi, a;
-	VECT v[3];
-	int i, j;
-
-	sinphi = sin(lp.phi);
-	cosphi = cos(lp.phi);
-	for (i = 0; i < 3; ++i) { /* dist/azimiths from control */
-		v[i] = vect(P->ctx, lp.phi - P->c[i].phi, P->c[i].cosphi, P->c[i].sinphi,
-			cosphi, sinphi, lp.lam - P->c[i].lam);
-		if ( ! v[i].r)
-			break;
-		v[i].Az = adjlon(v[i].Az - P->c[i].v.Az);
-	}
-	if (i < 3) /* current point at control point */
-		xy = P->c[i].p;
-	else { /* point mean of intersepts */
-		xy = P->p;
-		for (i = 0; i < 3; ++i) {
-			j = i == 2 ? 0 : i + 1;
-			a = lc(P->ctx,P->c[i].v.r, v[i].r, v[j].r);
-			if (v[i].Az < 0.)
-				a = -a;
-			if (! i) { /* coord comp unique to each arc */
-				xy.x += v[i].r * cos(a);
-				xy.y -= v[i].r * sin(a);
-			} else if (i == 1) {
-				a = P->beta_1 - a;
-				xy.x -= v[i].r * cos(a);
-				xy.y -= v[i].r * sin(a);
-			} else {
-				a = P->beta_2 - a;
-				xy.x += v[i].r * cos(a);
-				xy.y += v[i].r * sin(a);
-			}
-		}
-		xy.x *= THIRD; /* mean of arc intercepts */
-		xy.y *= THIRD;
-	}
-	return xy;
+
+
+PJ *PROJECTION(chamb) {
+    int i, j;
+    char line[10];
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+
+    for (i = 0; i < 3; ++i) { /* get control point locations */
+        (void)sprintf(line, "rlat_%d", i+1);
+        Q->c[i].phi = pj_param(P->ctx, P->params, line).f;
+        (void)sprintf(line, "rlon_%d", i+1);
+        Q->c[i].lam = pj_param(P->ctx, P->params, line).f;
+        Q->c[i].lam = adjlon(Q->c[i].lam - P->lam0);
+        Q->c[i].cosphi = cos(Q->c[i].phi);
+        Q->c[i].sinphi = sin(Q->c[i].phi);
+    }
+    for (i = 0; i < 3; ++i) { /* inter ctl pt. distances and azimuths */
+        j = i == 2 ? 0 : i + 1;
+        Q->c[i].v = vect(P->ctx,Q->c[j].phi - Q->c[i].phi, Q->c[i].cosphi, Q->c[i].sinphi,
+            Q->c[j].cosphi, Q->c[j].sinphi, Q->c[j].lam - Q->c[i].lam);
+        if (! Q->c[i].v.r) E_ERROR(-25);
+        /* co-linearity problem ignored for now */
+    }
+    Q->beta_0 = lc(P->ctx,Q->c[0].v.r, Q->c[2].v.r, Q->c[1].v.r);
+    Q->beta_1 = lc(P->ctx,Q->c[0].v.r, Q->c[1].v.r, Q->c[2].v.r);
+    Q->beta_2 = M_PI - Q->beta_0;
+    Q->p.y = 2. * (Q->c[0].p.y = Q->c[1].p.y = Q->c[2].v.r * sin(Q->beta_0));
+    Q->c[2].p.y = 0.;
+    Q->c[0].p.x = - (Q->c[1].p.x = 0.5 * Q->c[0].v.r);
+    Q->p.x = Q->c[2].p.x = Q->c[0].p.x + Q->c[2].v.r * cos(Q->beta_0);
+
+    P->es = 0.;
+    P->fwd = s_forward;
+
+    return P;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(chamb)
-	int i, j;
-	char line[10];
-
-	for (i = 0; i < 3; ++i) { /* get control point locations */
-		(void)sprintf(line, "rlat_%d", i+1);
-		P->c[i].phi = pj_param(P->ctx, P->params, line).f;
-		(void)sprintf(line, "rlon_%d", i+1);
-		P->c[i].lam = pj_param(P->ctx, P->params, line).f;
-		P->c[i].lam = adjlon(P->c[i].lam - P->lam0);
-		P->c[i].cosphi = cos(P->c[i].phi);
-		P->c[i].sinphi = sin(P->c[i].phi);
-	}
-	for (i = 0; i < 3; ++i) { /* inter ctl pt. distances and azimuths */
-		j = i == 2 ? 0 : i + 1;
-		P->c[i].v = vect(P->ctx,P->c[j].phi - P->c[i].phi, P->c[i].cosphi, P->c[i].sinphi,
-			P->c[j].cosphi, P->c[j].sinphi, P->c[j].lam - P->c[i].lam);
-		if (! P->c[i].v.r) E_ERROR(-25);
-		/* co-linearity problem ignored for now */
-	}
-	P->beta_0 = lc(P->ctx,P->c[0].v.r, P->c[2].v.r, P->c[1].v.r);
-	P->beta_1 = lc(P->ctx,P->c[0].v.r, P->c[1].v.r, P->c[2].v.r);
-	P->beta_2 = PI - P->beta_0;
-	P->p.y = 2. * (P->c[0].p.y = P->c[1].p.y = P->c[2].v.r * sin(P->beta_0));
-	P->c[2].p.y = 0.;
-	P->c[0].p.x = - (P->c[1].p.x = 0.5 * P->c[0].v.r);
-	P->p.x = P->c[2].p.x = P->c[0].p.x + P->c[2].v.r * cos(P->beta_0);
-	P->es = 0.; P->fwd = s_forward;
-ENDENTRY(P)
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_chamb_selftest (void) {return 0;}
+#else
+
+int pj_chamb_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=chamb   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {-27864.7795868005815,  -223364.324593274243},
+        {-251312.283053493476,  -223402.145526208304},
+        {-27864.7856491046077,  223364.327328827145},
+        {-251312.289116443484,  223402.142197287147},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_collg.c b/src/PJ_collg.c
index 871dfc9..939eb2d 100644
--- a/src/PJ_collg.c
+++ b/src/PJ_collg.c
@@ -1,10 +1,14 @@
 #define PJ_LIB__
 # include	<projects.h>
+
 PROJ_HEAD(collg, "Collignon") "\n\tPCyl, Sph.";
 #define FXC	1.12837916709551257390
 #define FYC	1.77245385090551602729
 #define ONEEPS	1.0000001
-FORWARD(s_forward); /* spheroid */
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
 	(void) P;
 	if ((xy.y = 1. - sin(lp.phi)) <= 0.)
 		xy.y = 0.;
@@ -14,17 +18,81 @@ FORWARD(s_forward); /* spheroid */
 	xy.y = FYC * (1. - xy.y);
 	return (xy);
 }
-INVERSE(s_inverse); /* spheroid */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
 	lp.phi = xy.y / FYC - 1.;
 	if (fabs(lp.phi = 1. - lp.phi * lp.phi) < 1.)
 		lp.phi = asin(lp.phi);
 	else if (fabs(lp.phi) > ONEEPS) I_ERROR
-	else	lp.phi = lp.phi < 0. ? -HALFPI : HALFPI;
+	else	lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
 	if ((lp.lam = 1. - sin(lp.phi)) <= 0.)
 		lp.lam = 0.;
 	else
 		lp.lam = xy.x / (FXC * sqrt(lp.lam));
 	return (lp);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(collg) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(collg) {
+    P->es = 0.0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_collg_selftest (void) {return 0;}
+#else
+
+int pj_collg_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=collg   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {249872.921577929839,  99423.1747884602082},
+        {254272.532301245432,  -98559.3077607425657},
+        {-249872.921577929839,  99423.1747884602082},
+        {-254272.532301245432,  -98559.3077607425657},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.00158679719207879865,  0.00101017310941749921},
+        {0.001586769215623956,  -0.00101018201458258111},
+        {-0.00158679719207879865,  0.00101017310941749921},
+        {-0.001586769215623956,  -0.00101018201458258111},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_comill.c b/src/PJ_comill.c
new file mode 100644
index 0000000..97b659d
--- /dev/null
+++ b/src/PJ_comill.c
@@ -0,0 +1,131 @@
+/*
+The Compact Miller projection was designed by Tom Patterson, US National
+Park Service, in 2014. The polynomial equation was developed by Bojan
+Savric and Bernhard Jenny, College of Earth, Ocean, and Atmospheric
+Sciences, Oregon State University.
+Port to PROJ.4 by Bojan Savric, 4 April 2016
+*/
+
+#define PJ_LIB__
+#include    <projects.h>
+
+PROJ_HEAD(comill, "Compact Miller") "\n\tCyl., Sph.";
+
+#define K1 0.9902
+#define K2 0.1604
+#define K3 -0.03054
+#define C1 K1
+#define C2 (3 * K2)
+#define C3 (5 * K3)
+#define EPS 1e-11
+#define MAX_Y (0.6000207669862655 * M_PI)
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double lat_sq;
+
+    (void) P;   /* silence unused parameter warnings */
+
+    lat_sq = lp.phi * lp.phi;
+    xy.x = lp.lam;
+    xy.y = lp.phi * (K1 + lat_sq * (K2 + K3 * lat_sq));
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double yc, tol, y2, f, fder;
+
+    (void) P;   /* silence unused parameter warnings */
+
+    /* make sure y is inside valid range */
+    if (xy.y > MAX_Y) {
+        xy.y = MAX_Y;
+    } else if (xy.y < -MAX_Y) {
+        xy.y = -MAX_Y;
+    }
+
+    /* latitude */
+    yc = xy.y;
+    for (;;) { /* Newton-Raphson */
+        y2 = yc * yc;
+        f = (yc * (K1 + y2 * (K2 + K3 * y2))) - xy.y;
+        fder = C1 + y2 * (C2 + C3 * y2);
+        yc -= tol = f / fder;
+        if (fabs(tol) < EPS) {
+            break;
+        }
+    }
+    lp.phi = yc;
+
+    /* longitude */
+    lp.lam = xy.x;
+
+    return lp;
+}
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(comill) {
+    P->es = 0;
+
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_comill_selftest (void) {return 0;}
+#else
+
+int pj_comill_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=comill   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {223402.144255274179,  110611.859089458536},
+        {223402.144255274179,  -110611.859089458536},
+        {-223402.144255274179,  110611.859089458536},
+        {-223402.144255274179,  -110611.859089458536},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.00179049310978382265,  0.000904106801510605831},
+        {0.00179049310978382265,  -0.000904106801510605831},
+        {-0.00179049310978382265,  0.000904106801510605831},
+        {-0.00179049310978382265,  -0.000904106801510605831},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_crast.c b/src/PJ_crast.c
index 3f251ac..4773ee7 100644
--- a/src/PJ_crast.c
+++ b/src/PJ_crast.c
@@ -1,24 +1,94 @@
 #define PJ_LIB__
-# include	<projects.h>
-PROJ_HEAD(crast, "Craster Parabolic (Putnins P4)")
-"\n\tPCyl., Sph.";
-#define XM	0.97720502380583984317
-#define RXM	1.02332670794648848847
-#define YM	3.06998012383946546542
-#define RYM	0.32573500793527994772
-#define THIRD	0.333333333333333333
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-	lp.phi *= THIRD;
-	xy.x = XM * lp.lam * (2. * cos(lp.phi + lp.phi) - 1.);
-	xy.y = YM * sin(lp.phi);
-	return (xy);
+# include   <projects.h>
+
+PROJ_HEAD(crast, "Craster Parabolic (Putnins P4)") "\n\tPCyl., Sph.";
+
+#define XM  0.97720502380583984317
+#define RXM 1.02332670794648848847
+#define YM  3.06998012383946546542
+#define RYM 0.32573500793527994772
+#define THIRD   0.333333333333333333
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+    lp.phi *= THIRD;
+    xy.x = XM * lp.lam * (2. * cos(lp.phi + lp.phi) - 1.);
+    xy.y = YM * sin(lp.phi);
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	(void) P;
-	lp.phi = 3. * asin(xy.y * RYM);
-	lp.lam = xy.x * RXM / (2. * cos((lp.phi + lp.phi) * THIRD) - 1);
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    (void) P;
+    lp.phi = 3. * asin(xy.y * RYM);
+    lp.lam = xy.x * RXM / (2. * cos((lp.phi + lp.phi) * THIRD) - 1);
+    return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(crast) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+   return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(crast) {
+    P->es = 0.0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_crast_selftest (void) {return 0;}
+#else
+
+int pj_crast_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=crast   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+
+    XY s_fwd_expect[] = {
+        {218280.142056780722,  114306.045604279774},
+        {218280.142056780722,  -114306.045604279774},
+        {-218280.142056780722,  114306.045604279774},
+        {-218280.142056780722,  -114306.045604279774},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.00183225941982580187,  0.00087483943098902331},
+        {0.00183225941982580187,  -0.00087483943098902331},
+        {-0.00183225941982580187,  0.00087483943098902331},
+        {-0.00183225941982580187,  -0.00087483943098902331},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_denoy.c b/src/PJ_denoy.c
index b1a6fe8..10005a3 100644
--- a/src/PJ_denoy.c
+++ b/src/PJ_denoy.c
@@ -1,19 +1,69 @@
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
 PROJ_HEAD(denoy, "Denoyer Semi-Elliptical") "\n\tPCyl., no inv., Sph.";
-#define C0	0.95
-#define C1	-.08333333333333333333
-#define C3	.00166666666666666666
-#define D1	0.9
-#define D5	0.03
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-	xy.y = lp.phi;
-	xy.x = lp.lam;
-	lp.lam = fabs(lp.lam);
-	xy.x *= cos((C0 + lp.lam * (C1 + lp.lam * lp.lam * C3)) *
-		(lp.phi * (D1 + D5 * lp.phi * lp.phi * lp.phi * lp.phi)));
-	return (xy);
+
+#define C0  0.95
+#define C1 -0.08333333333333333333
+#define C3  0.00166666666666666666
+#define D1  0.9
+#define D5  0.03
+
+
+static XY s_forward (LP lp, PJ *P) {            /* Spheroidal, forward */
+    XY xy = {0.0, 0.0};
+    (void) P;
+    xy.y = lp.phi;
+    xy.x = lp.lam;
+    lp.lam = fabs(lp.lam);
+    xy.x *= cos((C0 + lp.lam * (C1 + lp.lam * lp.lam * C3)) *
+            (lp.phi * (D1 + D5 * lp.phi * lp.phi * lp.phi * lp.phi)));
+    return xy;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(denoy) P->es = 0.; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {               /* Destructor */
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(denoy) {
+    P->es = 0.0;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_denoy_selftest (void) {return 0;}
+#else
+
+int pj_denoy_selftest (void) {
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=denoy   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223377.422876954137,  111701.07212763709},
+        { 223377.422876954137, -111701.07212763709},
+        {-223377.422876954137,  111701.07212763709},
+        {-223377.422876954137, -111701.07212763709},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, 0, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_eck1.c b/src/PJ_eck1.c
index b0b43da..da2c868 100644
--- a/src/PJ_eck1.c
+++ b/src/PJ_eck1.c
@@ -1,21 +1,92 @@
-#define PJ_LIB__
-#include	<projects.h>
-PROJ_HEAD(eck1, "Eckert I") "\n\tPCyl., Sph.";
-#define FC	.92131773192356127802
-#define RP	.31830988618379067154
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-	xy.x = FC * lp.lam * (1. - RP * fabs(lp.phi));
-	xy.y = FC * lp.phi;
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	(void) P;
-	lp.phi = xy.y / FC;
-	lp.lam = xy.x / (FC * (1. - RP * fabs(lp.phi)));
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(eck1)
-	P->es = 0.; P->inv = s_inverse; P->fwd = s_forward;
-ENDENTRY(P)
+#define PJ_LIB__
+#include <projects.h>
+
+PROJ_HEAD(eck1, "Eckert I") "\n\tPCyl., Sph.";
+#define FC  0.92131773192356127802
+#define RP  0.31830988618379067154
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+
+    xy.x = FC * lp.lam * (1. - RP * fabs(lp.phi));
+    xy.y = FC * lp.phi;
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    (void) P;
+
+    lp.phi = xy.y / FC;
+    lp.lam = xy.x / (FC * (1. - RP * fabs(lp.phi)));
+
+    return (lp);
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(eck1) {
+    P->es = 0.0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P
;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_eck1_selftest (void) {return 0;}
+#else
+
+int pj_eck1_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=eck1   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+    XY s_fwd_expect[] = {
+        { 204680.88820295094,  102912.17842606473},
+        { 204680.88820295094, -102912.17842606473},
+        {-204680.88820295094,  102912.17842606473},
+        {-204680.88820295094, -102912.17842606473},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0019434150820034624,  0.00097170229538813102},
+        { 0.0019434150820034624, -0.00097170229538813102},
+        {-0.0019434150820034624,  0.00097170229538813102},
+        {-0.0019434150820034624, -0.00097170229538813102},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_eck2.c b/src/PJ_eck2.c
index 08b6559..c6eac8b 100644
--- a/src/PJ_eck2.c
+++ b/src/PJ_eck2.c
@@ -1,29 +1,104 @@
 #define PJ_LIB__
-# include	<projects.h>
+# include   <projects.h>
+
 PROJ_HEAD(eck2, "Eckert II") "\n\tPCyl. Sph.";
-#define FXC	0.46065886596178063902
-#define FYC	1.44720250911653531871
-#define C13	0.33333333333333333333
-#define ONEEPS	1.0000001
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-	xy.x = FXC * lp.lam * (xy.y = sqrt(4. - 3. * sin(fabs(lp.phi))));
-	xy.y = FYC * (2. - xy.y);
-	if ( lp.phi < 0.) xy.y = -xy.y;
-	return (xy);
+
+#define FXC     0.46065886596178063902
+#define FYC     1.44720250911653531871
+#define C13     0.33333333333333333333
+#define ONEEPS  1.0000001
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+
+    xy.x = FXC * lp.lam * (xy.y = sqrt(4. - 3. * sin(fabs(lp.phi))));
+    xy.y = FYC * (2. - xy.y);
+    if ( lp.phi < 0.) xy.y = -xy.y;
+
+    return (xy);
 }
-INVERSE(s_inverse); /* spheroid */
-	lp.lam = xy.x / (FXC * ( lp.phi = 2. - fabs(xy.y) / FYC) );
-	lp.phi = (4. - lp.phi * lp.phi) * C13;
-	if (fabs(lp.phi) >= 1.) {
-		if (fabs(lp.phi) > ONEEPS)	I_ERROR
-		else
-			lp.phi = lp.phi < 0. ? -HALFPI : HALFPI;
-	} else
-		lp.phi = asin(lp.phi);
-	if (xy.y < 0)
-		lp.phi = -lp.phi;
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    (void) P;
+
+    lp.lam = xy.x / (FXC * ( lp.phi = 2. - fabs(xy.y) / FYC) );
+    lp.phi = (4. - lp.phi * lp.phi) * C13;
+    if (fabs(lp.phi) >= 1.) {
+        if (fabs(lp.phi) > ONEEPS)  I_ERROR
+        else
+            lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
+    } else
+        lp.phi = asin(lp.phi);
+    if (xy.y < 0)
+        lp.phi = -lp.phi;
+    return (lp);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(eck2); P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc (P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(eck2) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_eck2_selftest (void) {return 0;}
+#else
+
+int pj_eck2_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=eck2   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 204472.87090796008,  121633.73497524235},
+        { 204472.87090796008, -121633.73497524235},
+        {-204472.87090796008,  121633.73497524235},
+        {-204472.87090796008, -121633.73497524235},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0019434150820034624,  0.00082480429919795412},
+        { 0.0019434150820034624, -0.00082480429919795412},
+        {-0.0019434150820034624,  0.00082480429919795412},
+        {-0.0019434150820034624, -0.00082480429919795412},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_eck3.c b/src/PJ_eck3.c
index d7755f0..3eb7f8f 100644
--- a/src/PJ_eck3.c
+++ b/src/PJ_eck3.c
@@ -1,50 +1,295 @@
-#define PROJ_PARMS__ \
-	double C_x, C_y, A, B;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(eck3, "Eckert III") "\n\tPCyl, Sph.";
 PROJ_HEAD(putp1, "Putnins P1") "\n\tPCyl, Sph.";
 PROJ_HEAD(wag6, "Wagner VI") "\n\tPCyl, Sph.";
 PROJ_HEAD(kav7, "Kavraisky VII") "\n\tPCyl, Sph.";
-FORWARD(s_forward); /* spheroid */
-	xy.y = P->C_y * lp.phi;
-	xy.x = P->C_x * lp.lam * (P->A + asqrt(1. - P->B * lp.phi * lp.phi));
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	lp.phi = xy.y / P->C_y;
-	lp.lam = xy.x / (P->C_x * (P->A + asqrt(1. - P->B * lp.phi * lp.phi)));
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) {
-	P->es = 0.;
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-	return P;
-}
-ENTRY0(eck3)
-	P->C_x = .42223820031577120149;
-	P->C_y = .84447640063154240298;
-	P->A = 1.;
-	P->B = 0.4052847345693510857755;
-ENDENTRY(setup(P))
-ENTRY0(kav7)
-	P->C_x = 0.2632401569273184856851;
-	P->C_x = 0.8660254037844;
-	P->C_y = 1.;
-	P->A = 0.;
-	P->B = 0.30396355092701331433;
-ENDENTRY(setup(P))
-ENTRY0(wag6);
-	P->C_x = P->C_y = 0.94745;
-	P->A = 0.;
-	P->B = 0.30396355092701331433;
-ENDENTRY(setup(P))
-ENTRY0(putp1);
-	P->C_x = 1.89490;
-	P->C_y = 0.94745;
-	P->A = -0.5;
-	P->B = 0.30396355092701331433;
-ENDENTRY(setup(P))
+
+struct pj_opaque {
+    double C_x, C_y, A, B;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    xy.y = Q->C_y * lp.phi;
+    xy.x = Q->C_x * lp.lam * (Q->A + asqrt(1. - Q->B * lp.phi * lp.phi));
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    lp.phi = xy.y / Q->C_y;
+    lp.lam = xy.x / (Q->C_x * (Q->A + asqrt(1. - Q->B * lp.phi * lp.phi)));
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {               /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+static PJ *setup(PJ *P) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    return P;
+}
+
+
+PJ *PROJECTION(eck3) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->C_x = 0.42223820031577120149;
+    Q->C_y = 0.84447640063154240298;
+    Q->A = 1.0;
+    Q->B = 0.4052847345693510857755;
+
+    return setup(P);
+}
+
+
+PJ *PROJECTION(kav7) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    /* Defined twice in original code - Using 0.866...,
+     * but leaving the other one here as a safety measure.
+     * Q->C_x = 0.2632401569273184856851; */
+    Q->C_x = 0.8660254037844;
+    Q->C_y = 1.;
+    Q->A = 0.;
+    Q->B = 0.30396355092701331433;
+
+    return setup(P);
+}
+
+
+PJ *PROJECTION(wag6) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->C_x = Q->C_y = 0.94745;
+    Q->A = 0.0;
+    Q->B = 0.30396355092701331433;
+
+    return setup(P);
+}
+
+
+PJ *PROJECTION(putp1) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->C_x = 1.89490;
+    Q->C_y = 0.94745;
+    Q->A = -0.5;
+    Q->B = 0.30396355092701331433;
+
+    return setup(P);
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_eck3_selftest (void) {return 0;}
+#else
+
+int pj_eck3_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=eck3   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 188652.01572153764,  94328.919337031271},
+        { 188652.01572153764, -94328.919337031271},
+        {-188652.01572153764,  94328.919337031271},
+        {-188652.01572153764, -94328.919337031271},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0021202405520236059,  0.0010601202759750307},
+        { 0.0021202405520236059, -0.0010601202759750307},
+        {-0.0021202405520236059,  0.0010601202759750307},
+        {-0.0021202405520236059, -0.0010601202759750307},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_kav7_selftest (void) {return 0;}
+#else
+
+int pj_kav7_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=kav7   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 193462.9749437288,  111701.07212763709},
+        { 193462.9749437288, -111701.07212763709},
+        {-193462.9749437288,  111701.07212763709},
+        {-193462.9749437288, -111701.07212763709}
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0020674833579085268,  0.00089524655489191132},
+        { 0.0020674833579085268, -0.00089524655489191132},
+        {-0.0020674833579085268,  0.00089524655489191132},
+        {-0.0020674833579085268, -0.00089524655489191132}
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_wag6_selftest (void) {return 0;}
+#else
+
+int pj_wag6_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=wag6   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 211652.56216440981,  105831.18078732977},
+        { 211652.56216440981, -105831.18078732977},
+        {-211652.56216440981,  105831.18078732977},
+        {-211652.56216440981, -105831.18078732977}
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0018898022163257513,  0.000944901108123818},
+        { 0.0018898022163257513, -0.000944901108123818},
+        {-0.0018898022163257513,  0.000944901108123818},
+        {-0.0018898022163257513, -0.000944901108123818}
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_putp1_selftest (void) {return 0;}
+#else
+
+int pj_putp1_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=putp1   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 211642.76275416015,  105831.18078732977},
+        { 211642.76275416015, -105831.18078732977},
+        {-211642.76275416015,  105831.18078732977},
+        {-211642.76275416015, -105831.18078732977}
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0018898022164038663,  0.000944901108123818},
+        { 0.0018898022164038663, -0.000944901108123818},
+        {-0.0018898022164038663,  0.000944901108123818},
+        {-0.0018898022164038663, -0.000944901108123818}
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_eck4.c b/src/PJ_eck4.c
index 0bedbbc..8a56f01 100644
--- a/src/PJ_eck4.c
+++ b/src/PJ_eck4.c
@@ -1,45 +1,117 @@
-#define PJ_LIB__
-#include	<projects.h>
-PROJ_HEAD(eck4, "Eckert IV") "\n\tPCyl, Sph.";
-#define C_x	.42223820031577120149
-#define C_y	1.32650042817700232218
-#define RC_y	.75386330736002178205
-#define C_p	3.57079632679489661922
-#define RC_p	.28004957675577868795
-#define EPS	1e-7
-#define NITER	6
-FORWARD(s_forward); /* spheroid */
-	double p, V, s, c;
-	int i;
-	(void) P;
-
-	p = C_p * sin(lp.phi);
-	V = lp.phi * lp.phi;
-	lp.phi *= 0.895168 + V * ( 0.0218849 + V * 0.00826809 );
-	for (i = NITER; i ; --i) {
-		c = cos(lp.phi);
-		s = sin(lp.phi);
-		lp.phi -= V = (lp.phi + s * (c + 2.) - p) /
-			(1. + c * (c + 2.) - s * s);
-		if (fabs(V) < EPS)
-			break;
-	}
-	if (!i) {
-		xy.x = C_x * lp.lam;
-		xy.y = lp.phi < 0. ? -C_y : C_y;
-	} else {
-		xy.x = C_x * lp.lam * (1. + cos(lp.phi));
-		xy.y = C_y * sin(lp.phi);
-	}
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	double c;
-
-	lp.phi = aasin(P->ctx,xy.y / C_y);
-	lp.lam = xy.x / (C_x * (1. + (c = cos(lp.phi))));
-	lp.phi = aasin(P->ctx,(lp.phi + sin(lp.phi) * (c + 2.)) / C_p);
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(eck4); P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+#define PJ_LIB__
+#include    <projects.h>
+
+PROJ_HEAD(eck4, "Eckert IV") "\n\tPCyl, Sph.";
+
+#define C_x .42223820031577120149
+#define C_y 1.32650042817700232218
+#define RC_y    .75386330736002178205
+#define C_p 3.57079632679489661922
+#define RC_p    .28004957675577868795
+#define EPS 1e-7
+#define NITER   6
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double p, V, s, c;
+    int i;
+    (void) P;
+
+    p = C_p * sin(lp.phi);
+    V = lp.phi * lp.phi;
+    lp.phi *= 0.895168 + V * ( 0.0218849 + V * 0.00826809 );
+    for (i = NITER; i ; --i) {
+        c = cos(lp.phi);
+        s = sin(lp.phi);
+        lp.phi -= V = (lp.phi + s * (c + 2.) - p) /
+            (1. + c * (c + 2.) - s * s);
+        if (fabs(V) < EPS)
+            break;
+    }
+    if (!i) {
+        xy.x = C_x * lp.lam;
+        xy.y = lp.phi < 0. ? -C_y : C_y;
+    } else {
+        xy.x = C_x * lp.lam * (1. + cos(lp.phi));
+        xy.y = C_y * sin(lp.phi);
+    }
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double c;
+
+    lp.phi = aasin(P->ctx,xy.y / C_y);
+    lp.lam = xy.x / (C_x * (1. + (c = cos(lp.phi))));
+    lp.phi = aasin(P->ctx,(lp.phi + sin(lp.phi) * (c + 2.)) / C_p);
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(eck4) {
+    P->es = 0.0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_eck4_selftest (void) {return 0;}
+#else
+
+int pj_eck4_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=eck4   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 188646.38935641639,  132268.54017406539},
+        { 188646.38935641639, -132268.54017406539},
+        {-188646.38935641639,  132268.54017406539},
+        {-188646.38935641639, -132268.54017406539},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0021202405520236059, 0.00075601458836610643},
+        { 0.0021202405520236059, -0.00075601458836610643},
+        {-0.0021202405520236059, 0.00075601458836610643},
+        {-0.0021202405520236059, -0.00075601458836610643},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_eck5.c b/src/PJ_eck5.c
index 029c18e..d762693 100644
--- a/src/PJ_eck5.c
+++ b/src/PJ_eck5.c
@@ -1,20 +1,93 @@
-#define PJ_LIB__
-# include	<projects.h>
-PROJ_HEAD(eck5, "Eckert V") "\n\tPCyl, Sph.";
-#define XF	0.44101277172455148219
-#define RXF	2.26750802723822639137
-#define YF	0.88202554344910296438
-#define RYF	1.13375401361911319568
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-	xy.x = XF * (1. + cos(lp.phi)) * lp.lam;
-	xy.y = YF * lp.phi;
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	(void) P;
-	lp.lam = RXF * xy.x / (1. + cos( lp.phi = RYF * xy.y));
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(eck5); P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+#define PJ_LIB__
+#include <projects.h>
+
+PROJ_HEAD(eck5, "Eckert V") "\n\tPCyl, Sph.";
+
+#define XF  0.44101277172455148219
+#define RXF 2.26750802723822639137
+#define YF  0.88202554344910296438
+#define RYF 1.13375401361911319568
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+    xy.x = XF * (1. + cos(lp.phi)) * lp.lam;
+    xy.y = YF * lp.phi;
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    (void) P;
+    lp.lam = RXF * xy.x / (1. + cos( lp.phi = RYF * xy.y));
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {              /* Destructor */
+    if (0==P)
+        return 0;
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(eck5) {
+    P->es = 0.0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_eck5_selftest (void) {return 0;}
+#else
+
+int pj_eck5_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=eck5   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 197031.39213406085,  98523.198847226551},
+        { 197031.39213406085, -98523.198847226551},
+        {-197031.39213406085,  98523.198847226551},
+        {-197031.39213406085, -98523.198847226551},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.002029978749734037,  0.001014989374787388},
+        {0.002029978749734037,  -0.001014989374787388},
+        {-0.002029978749734037,  0.001014989374787388},
+        {-0.002029978749734037,  -0.001014989374787388},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_eqc.c b/src/PJ_eqc.c
index c69a6ba..3fcb100 100644
--- a/src/PJ_eqc.c
+++ b/src/PJ_eqc.c
@@ -1,23 +1,108 @@
-#define PROJ_PARMS__ \
-	double rc;
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    double rc;
+};
+
 PROJ_HEAD(eqc, "Equidistant Cylindrical (Plate Caree)")
-	"\n\tCyl, Sph\n\tlat_ts=[, lat_0=0]";
-FORWARD(s_forward); /* spheroid */
-	xy.x = P->rc * lp.lam;
-	xy.y = lp.phi - P->phi0;
-	return (xy);
+    "\n\tCyl, Sph\n\tlat_ts=[, lat_0=0]";
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    xy.x = Q->rc * lp.lam;
+    xy.y = lp.phi - P->phi0;
+
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	lp.lam = xy.x / P->rc;
-	lp.phi = xy.y + P->phi0;
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    lp.lam = xy.x / Q->rc;
+    lp.phi = xy.y + P->phi0;
+
+    return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(eqc)
-	if ((P->rc = cos(pj_param(P->ctx, P->params, "rlat_ts").f)) <= 0.) E_ERROR(-24);
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-	P->es = 0.;
-ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(eqc) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    if ((Q->rc = cos(pj_param(P->ctx, P->params, "rlat_ts").f)) <= 0.) E_ERROR(-24);
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    P->es = 0.;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_eqc_selftest (void) {return 0;}
+#else
+
+int pj_eqc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=eqc   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223402.144255274179,  111701.07212763709},
+        { 223402.144255274179, -111701.07212763709},
+        {-223402.144255274179,  111701.07212763709},
+        {-223402.144255274179, -111701.07212763709},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179049310978382265,  0.000895246554891911323},
+        { 0.00179049310978382265, -0.000895246554891911323},
+        {-0.00179049310978382265,  0.000895246554891911323},
+        {-0.00179049310978382265, -0.000895246554891911323},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_eqdc.c b/src/PJ_eqdc.c
index 01a0f03..ce1a8bd 100644
--- a/src/PJ_eqdc.c
+++ b/src/PJ_eqdc.c
@@ -1,85 +1,190 @@
-#define PROJ_PARMS__ \
-	double phi1; \
-	double phi2; \
-	double n; \
-	double rho; \
-	double rho0; \
-	double c; \
-	double *en; \
-	int		ellips;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    double phi1;
+    double phi2;
+    double n;
+    double rho;
+    double rho0;
+    double c;
+    double *en;
+    int     ellips;
+};
+
 PROJ_HEAD(eqdc, "Equidistant Conic")
-	"\n\tConic, Sph&Ell\n\tlat_1= lat_2=";
-# define EPS10	1.e-10
-FORWARD(e_forward); /* sphere & ellipsoid */
-	P->rho = P->c - (P->ellips ? pj_mlfn(lp.phi, sin(lp.phi),
-		cos(lp.phi), P->en) : lp.phi);
-	xy.x = P->rho * sin( lp.lam *= P->n );
-	xy.y = P->rho0 - P->rho * cos(lp.lam);
-	return (xy);
+    "\n\tConic, Sph&Ell\n\tlat_1= lat_2=";
+# define EPS10  1.e-10
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    Q->rho = Q->c - (Q->ellips ? pj_mlfn(lp.phi, sin(lp.phi),
+        cos(lp.phi), Q->en) : lp.phi);
+    xy.x = Q->rho * sin( lp.lam *= Q->n );
+    xy.y = Q->rho0 - Q->rho * cos(lp.lam);
+
+    return xy;
 }
-INVERSE(e_inverse); /* sphere & ellipsoid */
-	if ((P->rho = hypot(xy.x, xy.y = P->rho0 - xy.y)) != 0.0 ) {
-		if (P->n < 0.) {
-			P->rho = -P->rho;
-			xy.x = -xy.x;
-			xy.y = -xy.y;
-		}
-		lp.phi = P->c - P->rho;
-		if (P->ellips)
-			lp.phi = pj_inv_mlfn(P->ctx, lp.phi, P->es, P->en);
-		lp.lam = atan2(xy.x, xy.y) / P->n;
-	} else {
-		lp.lam = 0.;
-		lp.phi = P->n > 0. ? HALFPI : - HALFPI;
-	}
-	return (lp);
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    if ((Q->rho = hypot(xy.x, xy.y = Q->rho0 - xy.y)) != 0.0 ) {
+        if (Q->n < 0.) {
+            Q->rho = -Q->rho;
+            xy.x = -xy.x;
+            xy.y = -xy.y;
+        }
+        lp.phi = Q->c - Q->rho;
+        if (Q->ellips)
+            lp.phi = pj_inv_mlfn(P->ctx, lp.phi, P->es, Q->en);
+        lp.lam = atan2(xy.x, xy.y) / Q->n;
+    } else {
+        lp.lam = 0.;
+        lp.phi = Q->n > 0. ? M_HALFPI : -M_HALFPI;
+    }
+    return lp;
 }
-SPECIAL(fac) {
-	double sinphi, cosphi;
-
-	sinphi = sin(lp.phi);
-	cosphi = cos(lp.phi);
-	fac->code |= IS_ANAL_HK;
-	fac->h = 1.;
-	fac->k = P->n * (P->c - (P->ellips ? pj_mlfn(lp.phi, sinphi,
-		cosphi, P->en) : lp.phi)) / pj_msfn(sinphi, cosphi, P->es);
+
+
+static void special(LP lp, PJ *P, struct FACTORS *fac) {
+    struct pj_opaque *Q = P->opaque;
+    double sinphi, cosphi;
+
+    sinphi = sin(lp.phi);
+    cosphi = cos(lp.phi);
+    fac->code |= IS_ANAL_HK;
+    fac->h = 1.;
+    fac->k = Q->n * (Q->c - (Q->ellips ? pj_mlfn(lp.phi, sinphi,
+        cosphi, Q->en) : lp.phi)) / pj_msfn(sinphi, cosphi, P->es);
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    if (P->opaque->en)
+        pj_dealloc (P->opaque->en);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-FREEUP; if (P) { if (P->en) pj_dalloc(P->en); pj_dalloc(P); } }
-ENTRY1(eqdc, en)
-	double cosphi, sinphi;
-	int secant;
-
-	P->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
-	P->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
-	if (fabs(P->phi1 + P->phi2) < EPS10) E_ERROR(-21);
-	if (!(P->en = pj_enfn(P->es)))
-		E_ERROR_0;
-	P->n = sinphi = sin(P->phi1);
-	cosphi = cos(P->phi1);
-	secant = fabs(P->phi1 - P->phi2) >= EPS10;
-	if( (P->ellips = (P->es > 0.)) ) {
-		double ml1, m1;
-
-		m1 = pj_msfn(sinphi, cosphi, P->es);
-		ml1 = pj_mlfn(P->phi1, sinphi, cosphi, P->en);
-		if (secant) { /* secant cone */
-			sinphi = sin(P->phi2);
-			cosphi = cos(P->phi2);
-			P->n = (m1 - pj_msfn(sinphi, cosphi, P->es)) /
-				(pj_mlfn(P->phi2, sinphi, cosphi, P->en) - ml1);
-		}
-		P->c = ml1 + m1 / P->n;
-		P->rho0 = P->c - pj_mlfn(P->phi0, sin(P->phi0),
-			cos(P->phi0), P->en);
-	} else {
-		if (secant)
-			P->n = (cosphi - cos(P->phi2)) / (P->phi2 - P->phi1);
-		P->c = P->phi1 + cos(P->phi1) / P->n;
-		P->rho0 = P->c - P->phi0;
-	}
-	P->inv = e_inverse;
-	P->fwd = e_forward;
-	P->spc = fac;
-ENDENTRY(P)
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(eqdc) {
+    double cosphi, sinphi;
+    int secant;
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
+    Q->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
+    if (fabs(Q->phi1 + Q->phi2) < EPS10) E_ERROR(-21);
+    if (!(Q->en = pj_enfn(P->es)))
+        E_ERROR_0;
+    Q->n = sinphi = sin(Q->phi1);
+    cosphi = cos(Q->phi1);
+    secant = fabs(Q->phi1 - Q->phi2) >= EPS10;
+    if( (Q->ellips = (P->es > 0.)) ) {
+        double ml1, m1;
+
+        m1 = pj_msfn(sinphi, cosphi, P->es);
+        ml1 = pj_mlfn(Q->phi1, sinphi, cosphi, Q->en);
+        if (secant) { /* secant cone */
+            sinphi = sin(Q->phi2);
+            cosphi = cos(Q->phi2);
+            Q->n = (m1 - pj_msfn(sinphi, cosphi, P->es)) /
+                (pj_mlfn(Q->phi2, sinphi, cosphi, Q->en) - ml1);
+        }
+        Q->c = ml1 + m1 / Q->n;
+        Q->rho0 = Q->c - pj_mlfn(P->phi0, sin(P->phi0),
+            cos(P->phi0), Q->en);
+    } else {
+        if (secant)
+            Q->n = (cosphi - cos(Q->phi2)) / (Q->phi2 - Q->phi1);
+        Q->c = Q->phi1 + cos(Q->phi1) / Q->n;
+        Q->rho0 = Q->c - P->phi0;
+    }
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+    P->spc = special;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_eqdc_selftest (void) {return 0;}
+#else
+
+int pj_eqdc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=eqdc   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=eqdc   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222588.440269285755,  110659.134907347048},
+        { 222756.836702042434, -110489.578087220681},
+        {-222588.440269285755,  110659.134907347048},
+        {-222756.836702042434, -110489.578087220681},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223351.088175113517,  111786.108747173785},
+        { 223521.200266735133, -111615.970741240744},
+        {-223351.088175113517,  111786.108747173785},
+        {-223521.200266735133, -111615.970741240744},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.00179635944879094839,  0.000904368858588402644},
+        { 0.00179635822020772734, -0.000904370095529954975},
+        {-0.00179635944879094839,  0.000904368858588402644},
+        {-0.00179635822020772734, -0.000904370095529954975},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017902210900486641,   0.000895245944814909169},
+        { 0.00179021986984890255, -0.000895247165333684842},
+        {-0.0017902210900486641,   0.000895245944814909169},
+        {-0.00179021986984890255, -0.000895247165333684842},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_fahey.c b/src/PJ_fahey.c
index 007fc90..b8841c9 100644
--- a/src/PJ_fahey.c
+++ b/src/PJ_fahey.c
@@ -1,19 +1,95 @@
-#define PJ_LIB__
-# include	<projects.h>
-PROJ_HEAD(fahey, "Fahey") "\n\tPcyl, Sph.";
-#define TOL 1e-6
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-	xy.y = 1.819152 * ( xy.x = tan(0.5 * lp.phi) );
-	xy.x = 0.819152 * lp.lam * asqrt(1 - xy.x * xy.x);
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	(void) P;
-	lp.phi = 2. * atan(xy.y /= 1.819152);
-	lp.lam = fabs(xy.y = 1. - xy.y * xy.y) < TOL ? 0. :
-		xy.x / (0.819152 * sqrt(xy.y));
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(fahey) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+#define PJ_LIB__
+#include <projects.h>
+
+PROJ_HEAD(fahey, "Fahey") "\n\tPcyl, Sph.";
+
+#define TOL 1e-6
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+
+    xy.x = tan(0.5 * lp.phi);
+    xy.y = 1.819152 * xy.x;
+    xy.x = 0.819152 * lp.lam * asqrt(1 - xy.x * xy.x);
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    (void) P;
+
+    xy.y /= 1.819152;
+    lp.phi = 2. * atan(xy.y);
+    xy.y = 1. - xy.y * xy.y;
+    lp.lam = fabs(xy.y) < TOL ? 0. : xy.x / (0.819152 * sqrt(xy.y));
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(fahey) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_fahey_selftest (void) {return 0;}
+#else
+
+int pj_fahey_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=fahey   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 182993.34464912376,  101603.19356988439},
+        { 182993.34464912376, -101603.19356988439},
+        {-182993.34464912376,  101603.19356988439},
+        {-182993.34464912376, -101603.19356988439},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.0021857886080359551,  0.00098424601668238403},
+        {0.0021857886080359551,  -0.00098424601668238403},
+        {-0.0021857886080359551,  0.00098424601668238403},
+        {-0.0021857886080359551,  -0.00098424601668238403},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_fouc_s.c b/src/PJ_fouc_s.c
index b84b3f8..ae176d7 100644
--- a/src/PJ_fouc_s.c
+++ b/src/PJ_fouc_s.c
@@ -1,45 +1,126 @@
-#define PROJ_PARMS__ \
-	double n, n1;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(fouc_s, "Foucaut Sinusoidal") "\n\tPCyl., Sph.";
+
 #define MAX_ITER    10
 #define LOOP_TOL    1e-7
-FORWARD(s_forward); /* spheroid */
-	double t;
 
-	t = cos(lp.phi);
-	xy.x = lp.lam * t / (P->n + P->n1 * t);
-	xy.y = P->n * lp.phi + P->n1 * sin(lp.phi);
-	return (xy);
+struct pj_opaque {
+    double n, n1;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double t;
+
+    t = cos(lp.phi);
+    xy.x = lp.lam * t / (Q->n + Q->n1 * t);
+    xy.y = Q->n * lp.phi + Q->n1 * sin(lp.phi);
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double V;
+    int i;
+
+    if (Q->n) {
+        lp.phi = xy.y;
+        for (i = MAX_ITER; i ; --i) {
+            lp.phi -= V = (Q->n * lp.phi + Q->n1 * sin(lp.phi) - xy.y ) /
+                (Q->n + Q->n1 * cos(lp.phi));
+            if (fabs(V) < LOOP_TOL)
+                break;
+        }
+        if (!i)
+            lp.phi = xy.y < 0. ? -M_HALFPI : M_HALFPI;
+    } else
+        lp.phi = aasin(P->ctx,xy.y);
+    V = cos(lp.phi);
+    lp.lam = xy.x * (Q->n + Q->n1 * V) / V;
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-INVERSE(s_inverse); /* spheroid */
-	double V;
-	int i;
-
-	if (P->n) {
-		lp.phi = xy.y;
-		for (i = MAX_ITER; i ; --i) {
-			lp.phi -= V = (P->n * lp.phi + P->n1 * sin(lp.phi) - xy.y ) /
-				(P->n + P->n1 * cos(lp.phi));
-			if (fabs(V) < LOOP_TOL)
-				break;
-		}
-		if (!i)
-			lp.phi = xy.y < 0. ? -HALFPI : HALFPI;
-	} else
-		lp.phi = aasin(P->ctx,xy.y);
-	V = cos(lp.phi);
-	lp.lam = xy.x * (P->n + P->n1 * V) / V;
-	return (lp);
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(fouc_s)
-	P->n = pj_param(P->ctx, P->params, "dn").f;
-	if (P->n < 0. || P->n > 1.)
-		E_ERROR(-99)
-	P->n1 = 1. - P->n;
-	P->es = 0;
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-ENDENTRY(P)
+
+
+PJ *PROJECTION(fouc_s) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->n = pj_param(P->ctx, P->params, "dn").f;
+    if (Q->n < 0. || Q->n > 1.)
+        E_ERROR(-99)
+    Q->n1 = 1. - Q->n;
+    P->es = 0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_fouc_s_selftest (void) {return 0;}
+#else
+
+int pj_fouc_s_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=fouc_s   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223402.14425527424,  111695.40119861449},
+        { 223402.14425527424, -111695.40119861449},
+        {-223402.14425527424,  111695.40119861449},
+        {-223402.14425527424, -111695.40119861449},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931097838226,  0.000895246554928339},
+        { 0.0017904931097838226, -0.000895246554928339},
+        {-0.0017904931097838226,  0.000895246554928339},
+        {-0.0017904931097838226, -0.000895246554928339},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_gall.c b/src/PJ_gall.c
index 1acd7d0..b3d7cc6 100644
--- a/src/PJ_gall.c
+++ b/src/PJ_gall.c
@@ -1,21 +1,100 @@
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(gall, "Gall (Gall Stereographic)") "\n\tCyl, Sph";
-#define YF	1.70710678118654752440
-#define XF	0.70710678118654752440
-#define RYF	0.58578643762690495119
-#define RXF	1.41421356237309504880
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-	xy.x = XF * lp.lam;
-	xy.y = YF * tan(.5 * lp.phi);
-	return (xy);
+
+#define YF  1.70710678118654752440
+#define XF  0.70710678118654752440
+#define RYF 0.58578643762690495119
+#define RXF 1.41421356237309504880
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+
+    xy.x = XF * lp.lam;
+    xy.y = YF * tan(.5 * lp.phi);
+
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	(void) P;
-	lp.lam = RXF * xy.x;
-	lp.phi = 2. * atan(xy.y * RYF);
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    (void) P;
+
+    lp.lam = RXF * xy.x;
+    lp.phi = 2. * atan(xy.y * RYF);
+
+    return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(gall) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {              /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(gall) {
+    P->es = 0.0;
+
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_gall_selftest (void) {return 0;}
+#else
+
+int pj_gall_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=gall   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 157969.17113451968,  95345.249178385886},
+        { 157969.17113451968, -95345.249178385886},
+        {-157969.17113451968,  95345.249178385886},
+        {-157969.17113451968, -95345.249178385886},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0025321396391918614,  0.001048846580346495},
+        { 0.0025321396391918614, -0.001048846580346495},
+        {-0.0025321396391918614,  0.001048846580346495},
+        {-0.0025321396391918614, -0.001048846580346495},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_geos.c b/src/PJ_geos.c
index 09393ad..578608c 100644
--- a/src/PJ_geos.c
+++ b/src/PJ_geos.c
@@ -3,8 +3,7 @@
 **
 ** Copyright (c) 2004   Gerald I. Evenden
 ** Copyright (c) 2012   Martin Raspaud
-*/
-/*
+**
 ** See also (section 4.4.3.2):
 **   http://www.eumetsat.int/en/area4/msg/news/us_doc/cgms_03_26.pdf
 **
@@ -27,164 +26,274 @@
 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
-#define PROJ_PARMS__ \
-	double	h; \
-	double  radius_p; \
-	double  radius_p2; \
-	double  radius_p_inv2; \
-	double  radius_g; \
-	double  radius_g_1; \
-	double  C; \
-        char *  sweep_axis; \
-        int     flip_axis;
+
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    double h;
+    double radius_p;
+    double radius_p2;
+    double radius_p_inv2;
+    double radius_g;
+    double radius_g_1;
+    double C;
+    char *sweep_axis;
+    int flip_axis;
+};
 
 PROJ_HEAD(geos, "Geostationary Satellite View") "\n\tAzi, Sph&Ell\n\th=";
 
-FORWARD(s_forward); /* spheroid */
-	double Vx, Vy, Vz, tmp;
-
-/* Calculation of the three components of the vector from satellite to
-** position on earth surface (lon,lat).*/
-	tmp = cos(lp.phi);
-	Vx = cos (lp.lam) * tmp;
-	Vy = sin (lp.lam) * tmp;
-	Vz = sin (lp.phi);
-/* Check visibility.*/
-	if (((P->radius_g - Vx) * Vx - Vy * Vy - Vz * Vz) < 0.) F_ERROR;
-/* Calculation based on view angles from satellite.*/
-	tmp = P->radius_g - Vx;
-        if(P->flip_axis)
-          {
-            xy.x = P->radius_g_1 * atan(Vy / hypot(Vz, tmp));
-            xy.y = P->radius_g_1 * atan(Vz / tmp);
-          }
-        else
-          {
-            xy.x = P->radius_g_1 * atan(Vy / tmp);
-            xy.y = P->radius_g_1 * atan(Vz / hypot(Vy, tmp));
-          }
-	return (xy);
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double Vx, Vy, Vz, tmp;
+
+    /* Calculation of the three components of the vector from satellite to
+    ** position on earth surface (lon,lat).*/
+    tmp = cos(lp.phi);
+    Vx = cos (lp.lam) * tmp;
+    Vy = sin (lp.lam) * tmp;
+    Vz = sin (lp.phi);
+
+    /* Check visibility*/
+
+
+    /* Calculation based on view angles from satellite.*/
+    tmp = Q->radius_g - Vx;
+
+    if(Q->flip_axis) {
+        xy.x = Q->radius_g_1 * atan(Vy / hypot(Vz, tmp));
+        xy.y = Q->radius_g_1 * atan(Vz / tmp);
+    } else {
+        xy.x = Q->radius_g_1 * atan(Vy / tmp);
+        xy.y = Q->radius_g_1 * atan(Vz / hypot(Vy, tmp));
+    }
+
+    return xy;
 }
-FORWARD(e_forward); /* ellipsoid */
-	double r, Vx, Vy, Vz, tmp;
-
-/* Calculation of geocentric latitude. */
-	lp.phi = atan (P->radius_p2 * tan (lp.phi));
-/* Calculation of the three components of the vector from satellite to
-** position on earth surface (lon,lat).*/
-	r = (P->radius_p) / hypot(P->radius_p * cos (lp.phi), sin (lp.phi));
-	Vx = r * cos (lp.lam) * cos (lp.phi);
-	Vy = r * sin (lp.lam) * cos (lp.phi);
-	Vz = r * sin (lp.phi);
-/* Check visibility. */
-	if (((P->radius_g - Vx) * Vx - Vy * Vy - Vz * Vz * P->radius_p_inv2) < 0.)
-		F_ERROR;
-/* Calculation based on view angles from satellite. */
-	tmp = P->radius_g - Vx;
-        if(P->flip_axis)
-          {
-            xy.x = P->radius_g_1 * atan (Vy / hypot (Vz, tmp));
-            xy.y = P->radius_g_1 * atan (Vz / tmp);
-          }
-        else
-          {
-            xy.x = P->radius_g_1 * atan (Vy / tmp);
-            xy.y = P->radius_g_1 * atan (Vz / hypot (Vy, tmp));
-          }
-	return (xy);
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double r, Vx, Vy, Vz, tmp;
+
+    /* Calculation of geocentric latitude. */
+    lp.phi = atan (Q->radius_p2 * tan (lp.phi));
+
+    /* Calculation of the three components of the vector from satellite to
+    ** position on earth surface (lon,lat).*/
+    r = (Q->radius_p) / hypot(Q->radius_p * cos (lp.phi), sin (lp.phi));
+    Vx = r * cos (lp.lam) * cos (lp.phi);
+    Vy = r * sin (lp.lam) * cos (lp.phi);
+    Vz = r * sin (lp.phi);
+
+    /* Check visibility. */
+    if (((Q->radius_g - Vx) * Vx - Vy * Vy - Vz * Vz * Q->radius_p_inv2) < 0.)
+        F_ERROR;
+
+    /* Calculation based on view angles from satellite. */
+    tmp = Q->radius_g - Vx;
+
+    if(Q->flip_axis) {
+        xy.x = Q->radius_g_1 * atan (Vy / hypot (Vz, tmp));
+        xy.y = Q->radius_g_1 * atan (Vz / tmp);
+    } else {
+        xy.x = Q->radius_g_1 * atan (Vy / tmp);
+        xy.y = Q->radius_g_1 * atan (Vz / hypot (Vy, tmp));
+    }
+
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	double Vx, Vy, Vz, a, b, det, k;
-
-/* Setting three components of vector from satellite to position.*/
-	Vx = -1.0;
-	if(P->flip_axis)
-          {
-            Vz = tan (xy.y / (P->radius_g - 1.0));
-            Vy = tan (xy.x / (P->radius_g - 1.0)) * sqrt (1.0 + Vz * Vz);
-          }
-        else
-          {
-            Vy = tan (xy.x / (P->radius_g - 1.0));
-            Vz = tan (xy.y / (P->radius_g - 1.0)) * sqrt (1.0 + Vy * Vy);
-          }
-/* Calculation of terms in cubic equation and determinant.*/
-	a   = Vy * Vy + Vz * Vz + Vx * Vx;
-	b   = 2 * P->radius_g * Vx;
-	if ((det = (b * b) - 4 * a * P->C) < 0.) I_ERROR;
-/* Calculation of three components of vector from satellite to position.*/
-	k  = (-b - sqrt(det)) / (2 * a);
-	Vx = P->radius_g + k * Vx;
-	Vy *= k;
-	Vz *= k;
-/* Calculation of longitude and latitude.*/
-	lp.lam = atan2 (Vy, Vx);
-	lp.phi = atan (Vz * cos (lp.lam) / Vx);
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double Vx, Vy, Vz, a, b, det, k;
+
+    /* Setting three components of vector from satellite to position.*/
+    Vx = -1.0;
+    if(Q->flip_axis) {
+        Vz = tan (xy.y / (Q->radius_g - 1.0));
+        Vy = tan (xy.x / (Q->radius_g - 1.0)) * sqrt (1.0 + Vz * Vz);
+    } else {
+        Vy = tan (xy.x / (Q->radius_g - 1.0));
+        Vz = tan (xy.y / (Q->radius_g - 1.0)) * sqrt (1.0 + Vy * Vy);
+    }
+
+    /* Calculation of terms in cubic equation and determinant.*/
+    a = Vy * Vy + Vz * Vz + Vx * Vx;
+    b = 2 * Q->radius_g * Vx;
+    if ((det = (b * b) - 4 * a * Q->C) < 0.) I_ERROR;
+
+    /* Calculation of three components of vector from satellite to position.*/
+    k  = (-b - sqrt(det)) / (2 * a);
+    Vx = Q->radius_g + k * Vx;
+    Vy *= k;
+    Vz *= k;
+
+    /* Calculation of longitude and latitude.*/
+    lp.lam = atan2 (Vy, Vx);
+    lp.phi = atan (Vz * cos (lp.lam) / Vx);
+
+    return lp;
 }
-INVERSE(e_inverse); /* ellipsoid */
-	double Vx, Vy, Vz, a, b, det, k;
-
-/* Setting three components of vector from satellite to position.*/
-	Vx = -1.0;
-        if(P->flip_axis)
-          {
-            Vz = tan (xy.y / P->radius_g_1);
-            Vy = tan (xy.x / P->radius_g_1) * hypot(1.0, Vz);
-          }
-        else
-          {
-            Vy = tan (xy.x / P->radius_g_1);
-            Vz = tan (xy.y / P->radius_g_1) * hypot(1.0, Vy);
-          }
-/* Calculation of terms in cubic equation and determinant.*/
-	a = Vz / P->radius_p;
-	a   = Vy * Vy + a * a + Vx * Vx;
-	b   = 2 * P->radius_g * Vx;
-	if ((det = (b * b) - 4 * a * P->C) < 0.) I_ERROR;
-/* Calculation of three components of vector from satellite to position.*/
-	k  = (-b - sqrt(det)) / (2. * a);
-	Vx = P->radius_g + k * Vx;
-	Vy *= k;
-	Vz *= k;
-/* Calculation of longitude and latitude.*/
-	lp.lam  = atan2 (Vy, Vx);
-	lp.phi = atan (Vz * cos (lp.lam) / Vx);
-	lp.phi = atan (P->radius_p_inv2 * tan (lp.phi));
-	return (lp);
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double Vx, Vy, Vz, a, b, det, k;
+
+    /* Setting three components of vector from satellite to position.*/
+    Vx = -1.0;
+
+    if(Q->flip_axis) {
+        Vz = tan (xy.y / Q->radius_g_1);
+        Vy = tan (xy.x / Q->radius_g_1) * hypot(1.0, Vz);
+    } else {
+        Vy = tan (xy.x / Q->radius_g_1);
+        Vz = tan (xy.y / Q->radius_g_1) * hypot(1.0, Vy);
+    }
+
+    /* Calculation of terms in cubic equation and determinant.*/
+    a = Vz / Q->radius_p;
+    a   = Vy * Vy + a * a + Vx * Vx;
+    b   = 2 * Q->radius_g * Vx;
+    if ((det = (b * b) - 4 * a * Q->C) < 0.) I_ERROR;
+
+    /* Calculation of three components of vector from satellite to position.*/
+    k  = (-b - sqrt(det)) / (2. * a);
+    Vx = Q->radius_g + k * Vx;
+    Vy *= k;
+    Vz *= k;
+
+    /* Calculation of longitude and latitude.*/
+    lp.lam = atan2 (Vy, Vx);
+    lp.phi = atan (Vz * cos (lp.lam) / Vx);
+    lp.phi = atan (Q->radius_p_inv2 * tan (lp.phi));
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-FREEUP; if (P) free(P); }
-ENTRY0(geos)
-	if ((P->h = pj_param(P->ctx, P->params, "dh").f) <= 0.) E_ERROR(-30);
-	if (P->phi0) E_ERROR(-46);
-        P->sweep_axis = pj_param(P->ctx, P->params, "ssweep").s;
-        if (P->sweep_axis == NULL)
-          P->flip_axis = 0;
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(geos) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    if ((Q->h = pj_param(P->ctx, P->params, "dh").f) <= 0.) E_ERROR(-30);
+
+    if (P->phi0) E_ERROR(-46);
+
+    Q->sweep_axis = pj_param(P->ctx, P->params, "ssweep").s;
+    if (Q->sweep_axis == NULL)
+      Q->flip_axis = 0;
+    else {
+        if (Q->sweep_axis[1] != '\0' ||
+            (Q->sweep_axis[0] != 'x' &&
+             Q->sweep_axis[0] != 'y'))
+          E_ERROR(-49);
+        if (Q->sweep_axis[0] == 'x')
+          Q->flip_axis = 1;
         else
-          {
-            if (P->sweep_axis[1] != '\0' ||
-                (P->sweep_axis[0] != 'x' &&
-                 P->sweep_axis[0] != 'y'))
-              E_ERROR(-49);
-            if (P->sweep_axis[0] == 'x')
-              P->flip_axis = 1;
-            else
-              P->flip_axis = 0;
-          }
-        P->radius_g_1 = P->h / P->a;
-	P->radius_g = 1. + P->radius_g_1;
-	P->C  = P->radius_g * P->radius_g - 1.0;
-	if (P->es) {
-		P->radius_p      = sqrt (P->one_es);
-		P->radius_p2     = P->one_es;
-		P->radius_p_inv2 = P->rone_es;
-		P->inv = e_inverse;
-		P->fwd = e_forward;
-	} else {
-		P->radius_p = P->radius_p2 = P->radius_p_inv2 = 1.0;
-		P->inv = s_inverse;
-		P->fwd = s_forward;
-	}
-ENDENTRY(P)
+          Q->flip_axis = 0;
+    }
+
+    Q->radius_g_1 = Q->h / P->a;
+    Q->radius_g = 1. + Q->radius_g_1;
+    Q->C  = Q->radius_g * Q->radius_g - 1.0;
+    if (P->es) {
+        Q->radius_p      = sqrt (P->one_es);
+        Q->radius_p2     = P->one_es;
+        Q->radius_p_inv2 = P->rone_es;
+        P->inv = e_inverse;
+        P->fwd = e_forward;
+    } else {
+        Q->radius_p = Q->radius_p2 = Q->radius_p_inv2 = 1.0;
+        P->inv = s_inverse;
+        P->fwd = s_forward;
+    }
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_geos_selftest (void) {return 0;}
+#else
+
+int pj_geos_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=geos   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +h=35785831"};
+    char s_args[] = {"+proj=geos   +a=6400000    +lat_1=0.5 +lat_2=2 +h=35785831"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222527.07036580026,  110551.30341332949},
+        { 222527.07036580026, -110551.30341332949},
+        {-222527.07036580026,  110551.30341332949},
+        {-222527.07036580026, -110551.30341332949},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223289.45763579503,  111677.65745653701},
+        { 223289.45763579503,  -111677.65745653701},
+        {-223289.45763579503,  111677.65745653701},
+        {-223289.45763579503,  -111677.65745653701},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017966305689715385,  0.00090436947723267452},
+        { 0.0017966305689715385, -0.00090436947723267452},
+        {-0.0017966305689715385,  0.00090436947723267452},
+        {-0.0017966305689715385, -0.00090436947723267452},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931105078943,  0.00089524655504237148},
+        { 0.0017904931105078943, -0.00089524655504237148},
+        {-0.0017904931105078943,  0.00089524655504237148},
+        {-0.0017904931105078943, -0.00089524655504237148},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_gins8.c b/src/PJ_gins8.c
index b7f38ad..3eae7ef 100644
--- a/src/PJ_gins8.c
+++ b/src/PJ_gins8.c
@@ -1,18 +1,75 @@
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(gins8, "Ginsburg VIII (TsNIIGAiK)") "\n\tPCyl, Sph., no inv.";
-#define	Cl 0.000952426
-#define	Cp 0.162388
-#define	C12 0.08333333333333333
-FORWARD(s_forward); /* spheroid */
-	double t = lp.phi * lp.phi;
-	(void) P;
-
-	xy.y = lp.phi * (1. + t * C12);
-	xy.x = lp.lam * (1. - Cp * t);
-	t = lp.lam * lp.lam;
-	xy.x *= (0.87 - Cl * t * t);
-	return (xy);
+
+#define Cl 0.000952426
+#define Cp 0.162388
+#define C12 0.08333333333333333
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double t = lp.phi * lp.phi;
+    (void) P;
+
+    xy.y = lp.phi * (1. + t * C12);
+    xy.x = lp.lam * (1. - Cp * t);
+    t = lp.lam * lp.lam;
+    xy.x *= (0.87 - Cl * t * t);
+
+    return xy;
+}
+
+
+static void *freeup_new (PJ *P) {              /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(gins8) {
+    P->es = 0.0;
+    P->inv = 0;
+    P->fwd = s_forward;
+
+    return P;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(gins8) P->es = 0.; P->inv = 0; P->fwd = s_forward; ENDENTRY(P)
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_gins8_selftest (void) {return 0;}
+#else
+
+int pj_gins8_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=gins8   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 194350.25093959007,  111703.90763533533},
+        { 194350.25093959007, -111703.90763533533},
+        {-194350.25093959007,  111703.90763533533},
+        {-194350.25093959007, -111703.90763533533},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_gn_sinu.c b/src/PJ_gn_sinu.c
index bfd8bc2..dffc9d4 100644
--- a/src/PJ_gn_sinu.c
+++ b/src/PJ_gn_sinu.c
@@ -1,98 +1,373 @@
-#define PROJ_PARMS__ \
-	double	*en; \
-	double	m, n, C_x, C_y;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(gn_sinu, "General Sinusoidal Series") "\n\tPCyl, Sph.\n\tm= n=";
 PROJ_HEAD(sinu, "Sinusoidal (Sanson-Flamsteed)") "\n\tPCyl, Sph&Ell";
 PROJ_HEAD(eck6, "Eckert VI") "\n\tPCyl, Sph.";
 PROJ_HEAD(mbtfps, "McBryde-Thomas Flat-Polar Sinusoidal") "\n\tPCyl, Sph.";
-#define EPS10	1e-10
+
+#define EPS10    1e-10
 #define MAX_ITER 8
 #define LOOP_TOL 1e-7
-/* Ellipsoidal Sinusoidal only */
-FORWARD(e_forward); /* ellipsoid */
-	double s, c;
 
-	xy.y = pj_mlfn(lp.phi, s = sin(lp.phi), c = cos(lp.phi), P->en);
-	xy.x = lp.lam * c / sqrt(1. - P->es * s * s);
-	return (xy);
+struct pj_opaque {
+    double *en;
+    double m, n, C_x, C_y;
+};
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    double s, c;
+
+    xy.y = pj_mlfn(lp.phi, s = sin(lp.phi), c = cos(lp.phi), P->opaque->en);
+    xy.x = lp.lam * c / sqrt(1. - P->es * s * s);
+    return xy;
 }
-INVERSE(e_inverse); /* ellipsoid */
-	double s;
-
-	if ((s = fabs(lp.phi = pj_inv_mlfn(P->ctx, xy.y, P->es, P->en))) < HALFPI) {
-		s = sin(lp.phi);
-		lp.lam = xy.x * sqrt(1. - P->es * s * s) / cos(lp.phi);
-	} else if ((s - EPS10) < HALFPI)
-		lp.lam = 0.;
-	else I_ERROR;
-	return (lp);
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    double s;
+
+    if ((s = fabs(lp.phi = pj_inv_mlfn(P->ctx, xy.y, P->es, P->opaque->en))) < M_HALFPI) {
+        s = sin(lp.phi);
+        lp.lam = xy.x * sqrt(1. - P->es * s * s) / cos(lp.phi);
+    } else if ((s - EPS10) < M_HALFPI) {
+        lp.lam = 0.;
+    } else {
+        I_ERROR;
+    }
+
+    return lp;
 }
-/* General spherical sinusoidals */
-FORWARD(s_forward); /* sphere */
-	if (!P->m)
-		lp.phi = P->n != 1. ? aasin(P->ctx,P->n * sin(lp.phi)): lp.phi;
-	else {
-		double k, V;
-		int i;
-
-		k = P->n * sin(lp.phi);
-		for (i = MAX_ITER; i ; --i) {
-			lp.phi -= V = (P->m * lp.phi + sin(lp.phi) - k) /
-				(P->m + cos(lp.phi));
-			if (fabs(V) < LOOP_TOL)
-				break;
-		}
-		if (!i)
-			F_ERROR
-	}
-	xy.x = P->C_x * lp.lam * (P->m + cos(lp.phi));
-	xy.y = P->C_y * lp.phi;
-	return (xy);
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    if (!Q->m)
+        lp.phi = Q->n != 1. ? aasin(P->ctx,Q->n * sin(lp.phi)): lp.phi;
+    else {
+        double k, V;
+        int i;
+
+        k = Q->n * sin(lp.phi);
+        for (i = MAX_ITER; i ; --i) {
+            lp.phi -= V = (Q->m * lp.phi + sin(lp.phi) - k) /
+                (Q->m + cos(lp.phi));
+            if (fabs(V) < LOOP_TOL)
+                break;
+        }
+        if (!i)
+            F_ERROR
+    }
+    xy.x = Q->C_x * lp.lam * (Q->m + cos(lp.phi));
+    xy.y = Q->C_y * lp.phi;
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    xy.y /= Q->C_y;
+    lp.phi = Q->m ? aasin(P->ctx,(Q->m * xy.y + sin(xy.y)) / Q->n) :
+        ( Q->n != 1. ? aasin(P->ctx,sin(xy.y) / Q->n) : xy.y );
+    lp.lam = xy.x / (Q->C_x * (Q->m + cos(xy.y)));
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {              /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    if (P->opaque->en)
+        pj_dalloc(P->opaque->en);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-INVERSE(s_inverse); /* sphere */
-	xy.y /= P->C_y;
-	lp.phi = P->m ? aasin(P->ctx,(P->m * xy.y + sin(xy.y)) / P->n) :
-		( P->n != 1. ? aasin(P->ctx,sin(xy.y) / P->n) : xy.y );
-	lp.lam = xy.x / (P->C_x * (P->m + cos(xy.y)));
-	return (lp);
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) { if (P->en) pj_dalloc(P->en); pj_dalloc(P); } }
-	static void /* for spheres, only */
-setup(PJ *P) {
-	P->es = 0;
-	P->C_x = (P->C_y = sqrt((P->m + 1.) / P->n))/(P->m + 1.);
-	P->inv = s_inverse;
-	P->fwd = s_forward;
+
+
+/* for spheres, only */
+static void setup(PJ *P) {
+    struct pj_opaque *Q = P->opaque;
+    P->es = 0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    Q->C_x = (Q->C_y = sqrt((Q->m + 1.) / Q->n))/(Q->m + 1.);
+}
+
+
+PJ *PROJECTION(sinu) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    if (!(Q->en = pj_enfn(P->es)))
+        E_ERROR_0;
+
+    if (P->es) {
+        P->inv = e_inverse;
+        P->fwd = e_forward;
+    } else {
+        Q->n = 1.;
+        Q->m = 0.;
+        setup(P);
+    }
+    return P;
+}
+
+
+PJ *PROJECTION(eck6) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->m = 1.;
+    Q->n = 2.570796326794896619231321691;
+    setup(P);
+
+    return P;
+}
+
+
+PJ *PROJECTION(mbtfps) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->m = 0.5;
+    Q->n = 1.785398163397448309615660845;
+    setup(P);
+
+    return P;
+}
+
+
+PJ *PROJECTION(gn_sinu) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    if (pj_param(P->ctx, P->params, "tn").i && pj_param(P->ctx, P->params, "tm").i) {
+        Q->n = pj_param(P->ctx, P->params, "dn").f;
+        Q->m = pj_param(P->ctx, P->params, "dm").f;
+    } else
+        E_ERROR(-99)
+
+    setup(P);
+
+    return P;
 }
-ENTRY1(sinu, en)
-	if (!(P->en = pj_enfn(P->es)))
-		E_ERROR_0;
-	if (P->es) {
-		P->inv = e_inverse;
-		P->fwd = e_forward;
-	} else {
-		P->n = 1.;
-		P->m = 0.;
-		setup(P);
-	}
-ENDENTRY(P)
-ENTRY1(eck6, en)
-	P->m = 1.;
-	P->n = 2.570796326794896619231321691;
-	setup(P);
-ENDENTRY(P)
-ENTRY1(mbtfps, en)
-	P->m = 0.5;
-	P->n = 1.785398163397448309615660845;
-	setup(P);
-ENDENTRY(P)
-ENTRY1(gn_sinu, en)
-	if (pj_param(P->ctx, P->params, "tn").i && pj_param(P->ctx, P->params, "tm").i) {
-		P->n = pj_param(P->ctx, P->params, "dn").f;
-		P->m = pj_param(P->ctx, P->params, "dm").f;
-	} else
-		E_ERROR(-99)
-	setup(P);
-ENDENTRY(P)
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_sinu_selftest (void) {return 0;}
+#else
+
+int pj_sinu_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=sinu   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=sinu   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222605.29953946592,  110574.38855415257},
+        { 222605.29953946592, -110574.38855415257},
+        {-222605.29953946592,  110574.38855415257},
+        {-222605.29953946592, -110574.38855415257},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223368.11902663155,  111701.07212763709},
+        { 223368.11902663155, -111701.07212763709},
+        {-223368.11902663155,  111701.07212763709},
+        {-223368.11902663155, -111701.07212763709},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017966305684613522,  0.00090436947707945409},
+        { 0.0017966305684613522, -0.00090436947707945409},
+        {-0.0017966305684613522,  0.00090436947707945409},
+        {-0.0017966305684613522, -0.00090436947707945409},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931100023887,  0.00089524655489191132},
+        { 0.0017904931100023887, -0.00089524655489191132},
+        {-0.0017904931100023887,  0.00089524655489191132},
+        {-0.0017904931100023887, -0.00089524655489191132},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_eck6_selftest (void) {return 0;}
+#else
+
+int pj_eck6_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=eck6   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 197021.60562899226,  126640.42073317352},
+        { 197021.60562899226, -126640.42073317352},
+        {-197021.60562899226,  126640.42073317352},
+        {-197021.60562899226, -126640.42073317352},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.002029978749734037,  0.00078963032910382171},
+        { 0.002029978749734037, -0.00078963032910382171},
+        {-0.002029978749734037,  0.00078963032910382171},
+        {-0.002029978749734037, -0.00078963032910382171},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_mbtfps_selftest (void) {return 0;}
+#else
+
+int pj_mbtfps_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=mbtfps   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 204740.11747857218,  121864.72971934026},
+        { 204740.11747857218, -121864.72971934026},
+        {-204740.11747857218,  121864.72971934026},
+        {-204740.11747857218, -121864.72971934026},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0019534152166442065,  0.00082057965689633387},
+        { 0.0019534152166442065, -0.00082057965689633387},
+        {-0.0019534152166442065,  0.00082057965689633387},
+        {-0.0019534152166442065, -0.00082057965689633387},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_gn_sinu_selftest (void) {return 0;}
+#else
+
+int pj_gn_sinu_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=gn_sinu   +a=6400000    +lat_1=0.5 +lat_2=2 +m=1 +n=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223385.13250469571,  111698.23644718733},
+        { 223385.13250469571, -111698.23644718733},
+        {-223385.13250469571,  111698.23644718733},
+        {-223385.13250469571, -111698.23644718733},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931098931057,  0.00089524655491012516},
+        { 0.0017904931098931057, -0.00089524655491012516},
+        {-0.0017904931098931057,  0.00089524655491012516},
+        {-0.0017904931098931057, -0.00089524655491012516},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_gnom.c b/src/PJ_gnom.c
index 11deb86..1571e6e 100644
--- a/src/PJ_gnom.c
+++ b/src/PJ_gnom.c
@@ -1,105 +1,192 @@
-#define PROJ_PARMS__ \
-	double	sinph0; \
-	double	cosph0; \
-	int		mode;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(gnom, "Gnomonic") "\n\tAzi, Sph.";
-#define EPS10 1.e-10
-#define N_POLE	0
+
+#define EPS10  1.e-10
+#define N_POLE 0
 #define S_POLE 1
-#define EQUIT	2
-#define OBLIQ	3
-FORWARD(s_forward); /* spheroid */
-	double  coslam, cosphi, sinphi;
-
-	sinphi = sin(lp.phi);
-	cosphi = cos(lp.phi);
-	coslam = cos(lp.lam);
-	switch (P->mode) {
-	case EQUIT:
-		xy.y = cosphi * coslam;
-		break;
-	case OBLIQ:
-		xy.y = P->sinph0 * sinphi + P->cosph0 * cosphi * coslam;
-		break;
-	case S_POLE:
-		xy.y = - sinphi;
-		break;
-	case N_POLE:
-		xy.y = sinphi;
-		break;
-	}
-	if (xy.y <= EPS10) F_ERROR;
-	xy.x = (xy.y = 1. / xy.y) * cosphi * sin(lp.lam);
-	switch (P->mode) {
-	case EQUIT:
-		xy.y *= sinphi;
-		break;
-	case OBLIQ:
-		xy.y *= P->cosph0 * sinphi - P->sinph0 * cosphi * coslam;
-		break;
-	case N_POLE:
-		coslam = - coslam;
-	case S_POLE:
-		xy.y *= cosphi * coslam;
-		break;
-	}
-	return (xy);
+#define EQUIT  2
+#define OBLIQ  3
+
+struct pj_opaque {
+    double  sinph0;
+    double  cosph0;
+    int     mode;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  coslam, cosphi, sinphi;
+
+    sinphi = sin(lp.phi);
+    cosphi = cos(lp.phi);
+    coslam = cos(lp.lam);
+
+    switch (Q->mode) {
+        case EQUIT:
+            xy.y = cosphi * coslam;
+            break;
+        case OBLIQ:
+            xy.y = Q->sinph0 * sinphi + Q->cosph0 * cosphi * coslam;
+            break;
+        case S_POLE:
+            xy.y = - sinphi;
+            break;
+        case N_POLE:
+            xy.y = sinphi;
+            break;
+    }
+
+    if (xy.y <= EPS10) F_ERROR;
+
+    xy.x = (xy.y = 1. / xy.y) * cosphi * sin(lp.lam);
+    switch (Q->mode) {
+        case EQUIT:
+            xy.y *= sinphi;
+            break;
+        case OBLIQ:
+            xy.y *= Q->cosph0 * sinphi - Q->sinph0 * cosphi * coslam;
+            break;
+        case N_POLE:
+            coslam = - coslam;
+        case S_POLE:
+            xy.y *= cosphi * coslam;
+            break;
+    }
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  rh, cosz, sinz;
+
+    rh = hypot(xy.x, xy.y);
+    sinz = sin(lp.phi = atan(rh));
+    cosz = sqrt(1. - sinz * sinz);
+
+    if (fabs(rh) <= EPS10) {
+        lp.phi = P->phi0;
+        lp.lam = 0.;
+    } else {
+        switch (Q->mode) {
+            case OBLIQ:
+                lp.phi = cosz * Q->sinph0 + xy.y * sinz * Q->cosph0 / rh;
+                if (fabs(lp.phi) >= 1.)
+                    lp.phi = lp.phi > 0. ? M_HALFPI : - M_HALFPI;
+                else
+                    lp.phi = asin(lp.phi);
+                xy.y = (cosz - Q->sinph0 * sin(lp.phi)) * rh;
+                xy.x *= sinz * Q->cosph0;
+                break;
+            case EQUIT:
+                lp.phi = xy.y * sinz / rh;
+                if (fabs(lp.phi) >= 1.)
+                    lp.phi = lp.phi > 0. ? M_HALFPI : - M_HALFPI;
+                else
+                    lp.phi = asin(lp.phi);
+                xy.y = cosz * rh;
+                xy.x *= sinz;
+                break;
+            case S_POLE:
+                lp.phi -= M_HALFPI;
+                break;
+            case N_POLE:
+                lp.phi = M_HALFPI - lp.phi;
+                xy.y = -xy.y;
+                break;
+        }
+        lp.lam = atan2(xy.x, xy.y);
+    }
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {              /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(s_inverse); /* spheroid */
-	double  rh, cosz, sinz;
-
-	rh = hypot(xy.x, xy.y);
-	sinz = sin(lp.phi = atan(rh));
-	cosz = sqrt(1. - sinz * sinz);
-	if (fabs(rh) <= EPS10) {
-		lp.phi = P->phi0;
-		lp.lam = 0.;
-	} else {
-		switch (P->mode) {
-		case OBLIQ:
-			lp.phi = cosz * P->sinph0 + xy.y * sinz * P->cosph0 / rh;
-			if (fabs(lp.phi) >= 1.)
-				lp.phi = lp.phi > 0. ? HALFPI : - HALFPI;
-			else
-				lp.phi = asin(lp.phi);
-			xy.y = (cosz - P->sinph0 * sin(lp.phi)) * rh;
-			xy.x *= sinz * P->cosph0;
-			break;
-		case EQUIT:
-			lp.phi = xy.y * sinz / rh;
-			if (fabs(lp.phi) >= 1.)
-				lp.phi = lp.phi > 0. ? HALFPI : - HALFPI;
-			else
-				lp.phi = asin(lp.phi);
-			xy.y = cosz * rh;
-			xy.x *= sinz;
-			break;
-		case S_POLE:
-			lp.phi -= HALFPI;
-			break;
-		case N_POLE:
-			lp.phi = HALFPI - lp.phi;
-			xy.y = -xy.y;
-			break;
-		}
-		lp.lam = atan2(xy.x, xy.y);
-	}
-	return (lp);
+
+
+PJ *PROJECTION(gnom) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    if (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) {
+        Q->mode = P->phi0 < 0. ? S_POLE : N_POLE;
+    } else if (fabs(P->phi0) < EPS10) {
+        Q->mode = EQUIT;
+    } else {
+        Q->mode = OBLIQ;
+        Q->sinph0 = sin(P->phi0);
+        Q->cosph0 = cos(P->phi0);
+    }
+
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    P->es = 0.;
+
+    return P;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(gnom)
-	if (fabs(fabs(P->phi0) - HALFPI) < EPS10)
-		P->mode = P->phi0 < 0. ? S_POLE : N_POLE;
-	else if (fabs(P->phi0) < EPS10)
-		P->mode = EQUIT;
-	else {
-		P->mode = OBLIQ;
-		P->sinph0 = sin(P->phi0);
-		P->cosph0 = cos(P->phi0);
-	}
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-	P->es = 0.;
-ENDENTRY(P)
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_gnom_selftest (void) {return 0;}
+#else
+
+int pj_gnom_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=gnom   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223492.92474718543,  111780.50920659291},
+        { 223492.92474718543, -111780.50920659291},
+        {-223492.92474718543,  111780.50920659291},
+        {-223492.92474718543, -111780.50920659291},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931092009798,  0.00089524655438192376},
+        { 0.0017904931092009798, -0.00089524655438192376},
+        {-0.0017904931092009798,  0.00089524655438192376},
+        {-0.0017904931092009798, -0.00089524655438192376},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_goode.c b/src/PJ_goode.c
index 387557e..48fc9ad 100644
--- a/src/PJ_goode.c
+++ b/src/PJ_goode.c
@@ -1,49 +1,122 @@
-#define PROJ_PARMS__ \
-	struct PJconsts	*sinu; \
-	struct PJconsts	*moll;
-#define PJ_LIB__
-#include	<projects.h>
-PROJ_HEAD(goode, "Goode Homolosine") "\n\tPCyl, Sph.";
-	C_NAMESPACE PJ
-*pj_sinu(PJ *), *pj_moll(PJ *);
-#define Y_COR		0.05280
-#define PHI_LIM	.71093078197902358062
-FORWARD(s_forward); /* spheroid */
-	if (fabs(lp.phi) <= PHI_LIM)
-		xy = P->sinu->fwd(lp, P->sinu);
-	else {
-		xy = P->moll->fwd(lp, P->moll);
-		xy.y -= lp.phi >= 0.0 ? Y_COR : -Y_COR;
-	}
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	if (fabs(xy.y) <= PHI_LIM)
-		lp = P->sinu->inv(xy, P->sinu);
-	else {
-		xy.y += xy.y >= 0.0 ? Y_COR : -Y_COR;
-		lp = P->moll->inv(xy, P->moll);
-	}
-	return (lp);
-}
-FREEUP;
-	if (P) {
-		if (P->sinu)
-			(*(P->sinu->pfree))(P->sinu);
-		if (P->moll)
-			(*(P->moll->pfree))(P->moll);
-		pj_dalloc(P);
-	}
-}
-ENTRY2(goode, sinu, moll)
-	P->es = 0.;
-	if (!(P->sinu = pj_sinu(0)) || !(P->moll = pj_moll(0)))
-		E_ERROR_0;
-	P->sinu->es = 0.;
-        P->sinu->ctx = P->ctx;
-        P->moll->ctx = P->ctx;
-	if (!(P->sinu = pj_sinu(P->sinu)) || !(P->moll = pj_moll(P->moll)))
-		E_ERROR_0;
-	P->fwd = s_forward;
-	P->inv = s_inverse;
-ENDENTRY(P)
+#define PJ_LIB__
+#include <projects.h>
+
+PROJ_HEAD(goode, "Goode Homolosine") "\n\tPCyl, Sph.";
+
+#define Y_COR   0.05280
+#define PHI_LIM 0.71093078197902358062
+
+C_NAMESPACE PJ *pj_sinu(PJ *), *pj_moll(PJ *);
+
+struct pj_opaque {
+    PJ *sinu;
+    PJ *moll;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    if (fabs(lp.phi) <= PHI_LIM)
+        xy = Q->sinu->fwd(lp, Q->sinu);
+    else {
+        xy = Q->moll->fwd(lp, Q->moll);
+        xy.y -= lp.phi >= 0.0 ? Y_COR : -Y_COR;
+    }
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    if (fabs(xy.y) <= PHI_LIM)
+        lp = Q->sinu->inv(xy, Q->sinu);
+    else {
+        xy.y += xy.y >= 0.0 ? Y_COR : -Y_COR;
+        lp = Q->moll->inv(xy, Q->moll);
+    }
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {              /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc(P);
+    if (P->opaque->sinu)
+        pj_dealloc(P->opaque->sinu);
+    if (P->opaque->moll)
+        pj_dealloc(P->opaque->moll);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(goode) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    P->es = 0.;
+    if (!(Q->sinu = pj_sinu(0)) || !(Q->moll = pj_moll(0)))
+        E_ERROR_0;
+    Q->sinu->es = 0.;
+        Q->sinu->ctx = P->ctx;
+        Q->moll->ctx = P->ctx;
+    if (!(Q->sinu = pj_sinu(Q->sinu)) || !(Q->moll = pj_moll(Q->moll)))
+        E_ERROR_0;
+
+    P->fwd = s_forward;
+    P->inv = s_inverse;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_goode_selftest (void) {return 0;}
+#else
+
+int pj_goode_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=goode   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223368.11902663155,  111701.07212763709},
        { 223368.11902663155, -111701.07212763709},
        {-223368.11902663155,  111701.07212763709},
        {-223368.11902663155, -111701.07212763709},
    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931100023887,  0.00089524655489191132},
        { 0.0017904931100023887, -0.00089524655489191132},
        {-0.0017904931100023887,  0.00089524655489191132},
        {-0.0017904931100023887, -0.00089524655489191132},
    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_gstmerc.c b/src/PJ_gstmerc.c
index bffe0b2..2720c94 100644
--- a/src/PJ_gstmerc.c
+++ b/src/PJ_gstmerc.c
@@ -1,48 +1,131 @@
-#define PROJ_PARMS__ \
-	double lamc;\
-	double phic;\
-	double c;\
-	double n1;\
-	double n2;\
-    double XS;\
-    double YS;
-
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(gstmerc, "Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion)")
-	"\n\tCyl, Sph&Ell\n\tlat_0= lon_0= k_0=";
-FORWARD(s_forward); /* spheroid */
-	double L, Ls, sinLs1, Ls1;
-	L= P->n1*lp.lam;
-    Ls= P->c+P->n1*log(pj_tsfn(-1.0*lp.phi,-1.0*sin(lp.phi),P->e));
-    sinLs1= sin(L)/cosh(Ls);
-    Ls1= log(pj_tsfn(-1.0*asin(sinLs1),0.0,0.0));
-    xy.x= (P->XS + P->n2*Ls1)*P->ra;
-    xy.y= (P->YS + P->n2*atan(sinh(Ls)/cos(L)))*P->ra;
-    /*fprintf(stderr,"fwd:\nL      =%16.13f\nLs     =%16.13f\nLs1    =%16.13f\nLP(%16.13f,%16.13f)=XY(%16.4f,%16.4f)\n",L,Ls,Ls1,lp.lam+P->lam0,lp.phi,(xy.x*P->a + P->x0)*P->to_meter,(xy.y*P->a + P->y0)*P->to_meter);*/
-	return (xy);
+    "\n\tCyl, Sph&Ell\n\tlat_0= lon_0= k_0=";
+
+struct pj_opaque {
+    double lamc;
+    double phic;
+    double c;
+    double n1;
+    double n2;
+    double XS;
+    double YS;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double L, Ls, sinLs1, Ls1;
+
+    L = Q->n1*lp.lam;
+    Ls = Q->c + Q->n1 * log(pj_tsfn(-1.0 * lp.phi, -1.0 * sin(lp.phi), P->e));
+    sinLs1 = sin(L) / cosh(Ls);
+    Ls1 = log(pj_tsfn(-1.0 * asin(sinLs1), 0.0, 0.0));
+    xy.x = (Q->XS + Q->n2*Ls1) * P->ra;
+    xy.y = (Q->YS + Q->n2*atan(sinh(Ls) / cos(L))) * P->ra;
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double L, LC, sinC;
+
+    L = atan(sinh((xy.x * P->a - Q->XS) / Q->n2) / cos((xy.y * P->a - Q->YS) / Q->n2));
+    sinC = sin((xy.y * P->a - Q->YS) / Q->n2) / cosh((xy.x * P->a - Q->XS) / Q->n2);
+    LC = log(pj_tsfn(-1.0 * asin(sinC), 0.0, 0.0));
+    lp.lam = L / Q->n1;
+    lp.phi = -1.0 * pj_phi2(P->ctx, exp((LC - Q->c) / Q->n1), P->e);
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {              /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-INVERSE(s_inverse); /* spheroid */
-	double L, LC, sinC;
-	L= atan(sinh((xy.x*P->a - P->XS)/P->n2)/cos((xy.y*P->a - P->YS)/P->n2));
-    sinC= sin((xy.y*P->a - P->YS)/P->n2)/cosh((xy.x*P->a - P->XS)/P->n2);
-    LC= log(pj_tsfn(-1.0*asin(sinC),0.0,0.0));
-    lp.lam= L/P->n1;
-    lp.phi= -1.0*pj_phi2(P->ctx, exp((LC-P->c)/P->n1),P->e);
-    /*fprintf(stderr,"inv:\nL      =%16.13f\nsinC   =%16.13f\nLC     =%16.13f\nXY(%16.4f,%16.4f)=LP(%16.13f,%16.13f)\n",L,sinC,LC,((xy.x/P->ra)+P->x0)/P->to_meter,((xy.y/P->ra)+P->y0)/P->to_meter,lp.lam+P->lam0,lp.phi);*/
-	return (lp);
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(gstmerc)
-    P->lamc= P->lam0;
-    P->n1= sqrt(1.0+P->es*pow(cos(P->phi0),4.0)/(1.0-P->es));
-    P->phic= asin(sin(P->phi0)/P->n1);
-    P->c=       log(pj_tsfn(-1.0*P->phic,0.0,0.0))
-         -P->n1*log(pj_tsfn(-1.0*P->phi0,-1.0*sin(P->phi0),P->e));
-    P->n2= P->k0*P->a*sqrt(1.0-P->es)/(1.0-P->es*sin(P->phi0)*sin(P->phi0));
-    P->XS= 0;/* -P->x0 */
-    P->YS= -1.0*P->n2*P->phic;/* -P->y0 */
-	P->inv= s_inverse;
-	P->fwd= s_forward;
-    /*fprintf(stderr,"a  (m) =%16.4f\ne      =%16.13f\nl0(rad)=%16.13f\np0(rad)=%16.13f\nk0     =%16.4f\nX0  (m)=%16.4f\nY0  (m)=%16.4f\n\nlC(rad)=%16.13f\npC(rad)=%16.13f\nc      =%16.13f\nn1     =%16.13f\nn2 (m) =%16.4f\nXS (m) =%16.4f\nYS (m) =%16.4f\n", P->a, P->e, P->lam0, P->phi0, P->k0, P->x0, P->y0, P->lamc, P->phic, P->c, P->n1, P->n2, P->XS +P->x0, P->YS + P->y0);*/
-ENDENTRY(P)
+
+
+PJ *PROJECTION(gstmerc) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->lamc = P->lam0;
+    Q->n1 = sqrt(1.0 + P->es * pow(cos(P->phi0), 4.0) / (1.0 - P->es));
+    Q->phic = asin(sin(P->phi0) / Q->n1);
+    Q->c = log(pj_tsfn(-1.0 * Q->phic, 0.0, 0.0))
+         - Q->n1 * log(pj_tsfn(-1.0 * P->phi0, -1.0 * sin(P->phi0), P->e));
+    Q->n2 = P->k0 * P->a * sqrt(1.0 - P->es) / (1.0 - P->es * sin(P->phi0) * sin(P->phi0));
+    Q->XS = 0;
+    Q->YS = -1.0 * Q->n2 * Q->phic;
+
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_gstmerc_selftest (void) {return 0;}
+#else
+
+int pj_gstmerc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=gstmerc   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+
+    XY s_fwd_expect[] = {
+        { 223413.46640632182,  111769.14504058557},
+        { 223413.46640632182, -111769.14504058668},
+        {-223413.46640632302,  111769.14504058557},
+        {-223413.46640632302, -111769.14504058668},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931097109673,  0.0008952465544509083},
+        { 0.0017904931097109673, -0.0008952465544509083},
+        {-0.0017904931097109673,  0.0008952465544509083},
+        {-0.0017904931097109673, -0.0008952465544509083},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_hammer.c b/src/PJ_hammer.c
index 719a2ce..3118640 100644
--- a/src/PJ_hammer.c
+++ b/src/PJ_hammer.c
@@ -1,29 +1,129 @@
-#define PROJ_PARMS__ \
-	double w; \
-	double m, rm;
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(hammer, "Hammer & Eckert-Greifendorff")
-	"\n\tMisc Sph, no inv.\n\tW= M=";
-FORWARD(s_forward); /* spheroid */
-	double cosphi, d;
-
-	d = sqrt(2./(1. + (cosphi = cos(lp.phi)) * cos(lp.lam *= P->w)));
-	xy.x = P->m * d * cosphi * sin(lp.lam);
-	xy.y = P->rm * d * sin(lp.phi);
-	return (xy);
+    "\n\tMisc Sph, \n\tW= M=";
+
+#define EPS 1.0e-10
+
+struct pj_opaque {
+    double w; \
+    double m, rm;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double cosphi, d;
+
+    d = sqrt(2./(1. + (cosphi = cos(lp.phi)) * cos(lp.lam *= Q->w)));
+    xy.x = Q->m * d * cosphi * sin(lp.lam);
+    xy.y = Q->rm * d * sin(lp.phi);
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double z;
+
+    z = sqrt(1. - 0.25*Q->w*Q->w*xy.x*xy.x - 0.25*xy.y*xy.y);
+    if (fabs(2.*z*z-1.) < EPS) {
+        lp.lam = HUGE_VAL;
+        lp.phi = HUGE_VAL;
+        pj_errno = -14;
+    } else {
+        lp.lam = aatan2(Q->w * xy.x * z,2. * z * z - 1)/Q->w;
+        lp.phi = aasin(P->ctx,z * xy.y);
+    }
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {              /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(hammer)
-	if (pj_param(P->ctx, P->params, "tW").i) {
-		if ((P->w = fabs(pj_param(P->ctx, P->params, "dW").f)) <= 0.) E_ERROR(-27);
-	} else
-		P->w = .5;
-	if (pj_param(P->ctx, P->params, "tM").i) {
-		if ((P->m = fabs(pj_param(P->ctx, P->params, "dM").f)) <= 0.) E_ERROR(-27);
-	} else
-		P->m = 1.;
-	P->rm = 1. / P->m;
-	P->m /= P->w;
-	P->es = 0.; P->fwd = s_forward;
-ENDENTRY(P)
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(hammer) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    if (pj_param(P->ctx, P->params, "tW").i) {
+        if ((Q->w = fabs(pj_param(P->ctx, P->params, "dW").f)) <= 0.) E_ERROR(-27);
+    } else
+        Q->w = .5;
+    if (pj_param(P->ctx, P->params, "tM").i) {
+        if ((Q->m = fabs(pj_param(P->ctx, P->params, "dM").f)) <= 0.) E_ERROR(-27);
+    } else
+        Q->m = 1.;
+
+    Q->rm = 1. / Q->m;
+    Q->m /= Q->w;
+
+    P->es = 0.;
+    P->fwd = s_forward;
+    P->inv = s_inverse;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_hammer_selftest (void) {return 0;}
+#else
+
+int pj_hammer_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=hammer   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223373.78870324057,  111703.90739776699},
+        { 223373.78870324057, -111703.90739776699},
+        {-223373.78870324057,  111703.90739776699},
+        {-223373.78870324057, -111703.90739776699},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.001790493109965961,  0.00089524655487369749},
+        { 0.001790493109965961, -0.00089524655487369749},
+        {-0.001790493109965961,  0.00089524655487369749},
+        {-0.001790493109965961, -0.00089524655487369749},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_hatano.c b/src/PJ_hatano.c
index 7516ba6..34c70c0 100644
--- a/src/PJ_hatano.c
+++ b/src/PJ_hatano.c
@@ -1,51 +1,134 @@
-#define PJ_LIB__
-#include	<projects.h>
-PROJ_HEAD(hatano, "Hatano Asymmetrical Equal Area") "\n\tPCyl, Sph.";
-#define NITER	20
-#define EPS	1e-7
-#define ONETOL 1.000001
-#define CN	2.67595
-#define CS	2.43763
-#define RCN	0.37369906014686373063
-#define RCS	0.41023453108141924738
-#define FYCN	1.75859
-#define FYCS	1.93052
-#define RYCN	0.56863737426006061674
-#define RYCS	0.51799515156538134803
-#define FXC	0.85
-#define RXC	1.17647058823529411764
-FORWARD(s_forward); /* spheroid */
-	double th1, c;
-	int i;
-	(void) P;
-
-	c = sin(lp.phi) * (lp.phi < 0. ? CS : CN);
-	for (i = NITER; i; --i) {
-		lp.phi -= th1 = (lp.phi + sin(lp.phi) - c) / (1. + cos(lp.phi));
-		if (fabs(th1) < EPS) break;
-	}
-	xy.x = FXC * lp.lam * cos(lp.phi *= .5);
-	xy.y = sin(lp.phi) * (lp.phi < 0. ? FYCS : FYCN);
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	double th;
-
-	th = xy.y * ( xy.y < 0. ? RYCS : RYCN);
-	if (fabs(th) > 1.)
-		if (fabs(th) > ONETOL)	I_ERROR
-		else			th = th > 0. ? HALFPI : - HALFPI;
-	else
-		th = asin(th);
-	lp.lam = RXC * xy.x / cos(th);
-	th += th;
-	lp.phi = (th + sin(th)) * (xy.y < 0. ? RCS : RCN);
-	if (fabs(lp.phi) > 1.)
-		if (fabs(lp.phi) > ONETOL)	I_ERROR
-		else			lp.phi = lp.phi > 0. ? HALFPI : - HALFPI;
-	else
-		lp.phi = asin(lp.phi);
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(hatano) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+#define PJ_LIB__
+#include <projects.h>
+
+PROJ_HEAD(hatano, "Hatano Asymmetrical Equal Area") "\n\tPCyl, Sph.";
+
+#define NITER   20
+#define EPS 1e-7
+#define ONETOL 1.000001
+#define CN  2.67595
+#define CS  2.43763
+#define RCN 0.37369906014686373063
+#define RCS 0.41023453108141924738
+#define FYCN    1.75859
+#define FYCS    1.93052
+#define RYCN    0.56863737426006061674
+#define RYCS    0.51799515156538134803
+#define FXC 0.85
+#define RXC 1.17647058823529411764
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double th1, c;
+    int i;
+    (void) P;
+
+    c = sin(lp.phi) * (lp.phi < 0. ? CS : CN);
+    for (i = NITER; i; --i) {
+        lp.phi -= th1 = (lp.phi + sin(lp.phi) - c) / (1. + cos(lp.phi));
+        if (fabs(th1) < EPS) break;
+    }
+    xy.x = FXC * lp.lam * cos(lp.phi *= .5);
+    xy.y = sin(lp.phi) * (lp.phi < 0. ? FYCS : FYCN);
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double th;
+
+    th = xy.y * ( xy.y < 0. ? RYCS : RYCN);
+    if (fabs(th) > 1.) {
+        if (fabs(th) > ONETOL) {
+            I_ERROR;
+        } else {
+            th = th > 0. ? M_HALFPI : - M_HALFPI;
+        }
+    } else {
+        th = asin(th);
+    }
+
+    lp.lam = RXC * xy.x / cos(th);
+    th += th;
+    lp.phi = (th + sin(th)) * (xy.y < 0. ? RCS : RCN);
+    if (fabs(lp.phi) > 1.) {
+        if (fabs(lp.phi) > ONETOL) {
+           I_ERROR;
+        } else {
+            lp.phi = lp.phi > 0. ? M_HALFPI : - M_HALFPI;
+        }
+    } else {
+        lp.phi = asin(lp.phi);
+    }
+
+    return (lp);
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(hatano) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_hatano_selftest (void) {return 0;}
+#else
+
+int pj_hatano_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=hatano   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 189878.87894652804,  131409.8024406255
},
+        { 189881.08195244463, -131409.14227607418
},
+        {-189878.87894652804,  131409.8024406255
},
+        {-189881.08195244463, -131409.14227607418
},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0021064624821817597,  0.00076095689425791926
},
+        { 0.0021064624821676096, -0.00076095777439265377
},
+        {-0.0021064624821817597,  0.00076095689425791926
},
+        {-0.0021064624821676096, -0.00076095777439265377
},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_healpix.c b/src/PJ_healpix.c
index 12d57ff..e8d3f38 100644
--- a/src/PJ_healpix.c
+++ b/src/PJ_healpix.c
@@ -2,10 +2,10 @@
  * Project: PROJ.4
  * Purpose: Implementation of the HEALPix and rHEALPix projections.
  *          For background see <http://code.scenzgrid.org/index.php/p/scenzgrid-py/source/tree/master/docs/rhealpix_dggs.pdf>.
- * Authors: Alex Raichev (raichev at cs.auckland.ac.nz) 
+ * Authors: Alex Raichev (raichev at cs.auckland.ac.nz)
  *          Michael Speth (spethm at landcareresearch.co.nz)
- * Notes:   Raichev implemented these projections in Python and 
- *          Speth translated them into C here.   
+ * Notes:   Raichev implemented these projections in Python and
+ *          Speth translated them into C here.
  ******************************************************************************
  * Copyright (c) 2001, Thomas Flemming, tf at ttqv.com
  *
@@ -28,38 +28,46 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  *****************************************************************************/
-# define PROJ_PARMS__ \
-    int north_square; \
-    int south_square; \
-    double qp; \
-    double *apa;
-# define PJ_LIB__    
-# include	<projects.h>
+# define PJ_LIB__
+# include <projects.h>
+
 PROJ_HEAD(healpix, "HEALPix") "\n\tSph., Ellps.";
 PROJ_HEAD(rhealpix, "rHEALPix") "\n\tSph., Ellps.\n\tnorth_square= south_square=";
-# include	<stdio.h>
+
+# include <stdio.h>
 /* Matrix for counterclockwise rotation by pi/2: */
-# define R1 {{ 0,-1},{ 1, 0}}	
+# define R1 {{ 0,-1},{ 1, 0}}
 /* Matrix for counterclockwise rotation by pi: */
-# define R2 {{-1, 0},{ 0,-1}}	
+# define R2 {{-1, 0},{ 0,-1}}
 /* Matrix for counterclockwise rotation by 3*pi/2:  */
-# define R3 {{ 0, 1},{-1, 0}}	
+# define R3 {{ 0, 1},{-1, 0}}
 /* Identity matrix */
 # define IDENT {{1, 0},{0, 1}}
 /* IDENT, R1, R2, R3, R1 inverse, R2 inverse, R3 inverse:*/
 # define ROT {IDENT, R1, R2, R3, R3, R2, R1}
 /* Fuzz to handle rounding errors: */
 # define EPS 1e-15
+
+struct pj_opaque {
+    int north_square; \
+    int south_square; \
+    double qp; \
+    double *apa;
+};
+
 typedef struct {
     int cn; /* An integer 0--3 indicating the position of the polar cap. */
     double x, y;  /* Coordinates of the pole point (point of most extreme latitude on the polar caps). */
     enum Region {north, south, equatorial} region;
 } CapMap;
+
 typedef struct {
     double x, y;
 } Point;
+
 double rot[7][2][2] = ROT;
 
+
 /**
  * Returns the sign of the double.
  * @param v the parameter whose sign is returned.
@@ -68,31 +76,35 @@ double rot[7][2][2] = ROT;
 double pj_sign (double v) {
     return v > 0 ? 1 : (v < 0 ? -1 : 0);
 }
+
+
 /**
  * Return the index of the matrix in ROT.
  * @param index ranges from -3 to 3.
  */
 static int get_rotate_index(int index) {
     switch(index) {
-	case 0:
-	    return 0;
-	case 1:
-	    return 1;
-	case 2: 
-	    return 2;
-	case 3: 
-	    return 3;
-	case -1:
-	    return 4;
-	case -2:
-	    return 5;
-	case -3:
-	    return 6;
+    case 0:
+        return 0;
+    case 1:
+        return 1;
+    case 2:
+        return 2;
+    case 3:
+        return 3;
+    case -1:
+        return 4;
+    case -2:
+        return 5;
+    case -3:
+        return 6;
     }
     return 0;
 }
+
+
 /**
- * Return 1 if point (testx, testy) lies in the interior of the polygon 
+ * Return 1 if point (testx, testy) lies in the interior of the polygon
  * determined by the vertices in vert, and return 0 otherwise.
  * See http://paulbourke.net/geometry/polygonmesh/ for more details.
  * @param nvert the number of vertices in the polygon.
@@ -103,6 +115,7 @@ static int pnpoly(int nvert, double vert[][2], double testx, double testy) {
     int counter = 0;
     double xinters;
     Point p1, p2;
+
     /* Check for boundrary cases */
     for (i = 0; i < nvert; i++) {
         if (testx == vert[i][0] && testy == vert[i][1]) {
@@ -135,76 +148,84 @@ static int pnpoly(int nvert, double vert[][2], double testx, double testy) {
     }
     return c;
 }
+
+
 /**
  * Return 1 if (x, y) lies in (the interior or boundary of) the image of the
- * HEALPix projection (in case proj=0) or in the image the rHEALPix projection 
+ * HEALPix projection (in case proj=0) or in the image the rHEALPix projection
  * (in case proj=1), and return 0 otherwise.
- * @param north_square the position of the north polar square (rHEALPix only)       
- * @param south_square the position of the south polar square (rHEALPix only)  
+ * @param north_square the position of the north polar square (rHEALPix only)
+ * @param south_square the position of the south polar square (rHEALPix only)
  **/
 int in_image(double x, double y, int proj, int north_square, int south_square) {
     if (proj == 0) {
-    	double healpixVertsJit[][2] = {
-    	    {-1.0*PI- EPS, PI/4.0},
-    	    {-3.0*PI/4.0, PI/2.0 + EPS},
-    	    {-1.0*PI/2.0, PI/4.0 + EPS},
-    	    {-1.0*PI/4.0, PI/2.0 + EPS},
-    	    {0.0, PI/4.0 + EPS},
-    	    {PI/4.0, PI/2.0 + EPS},
-    	    {PI/2.0, PI/4.0 + EPS},
-    	    {3.0*PI/4.0, PI/2.0 + EPS},
-    	    {PI+ EPS, PI/4.0},
-    	    {PI+ EPS, -1.0*PI/4.0},
-    	    {3.0*PI/4.0, -1.0*PI/2.0 - EPS},
-    	    {PI/2.0, -1.0*PI/4.0 - EPS},
-    	    {PI/4.0, -1.0*PI/2.0 - EPS},
-    	    {0.0, -1.0*PI/4.0 - EPS},
-    	    {-1.0*PI/4.0, -1.0*PI/2.0 - EPS},
-    	    {-1.0*PI/2.0, -1.0*PI/4.0 - EPS},
-    	    {-3.0*PI/4.0, -1.0*PI/2.0 - EPS},
-    	    {-1.0*PI - EPS, -1.0*PI/4.0}
-    	};
-    	return pnpoly((int)sizeof(healpixVertsJit)/
-    	              sizeof(healpixVertsJit[0]), healpixVertsJit, x, y);
+        double healpixVertsJit[][2] = {
+            {-1.0*M_PI- EPS, M_PI/4.0},
+            {-3.0*M_PI/4.0, M_PI/2.0 + EPS},
+            {-1.0*M_PI/2.0, M_PI/4.0 + EPS},
+            {-1.0*M_PI/4.0, M_PI/2.0 + EPS},
+            {0.0, M_PI/4.0 + EPS},
+            {M_PI/4.0, M_PI/2.0 + EPS},
+            {M_PI/2.0, M_PI/4.0 + EPS},
+            {3.0*M_PI/4.0, M_PI/2.0 + EPS},
+            {M_PI+ EPS, M_PI/4.0},
+            {M_PI+ EPS, -1.0*M_PI/4.0},
+            {3.0*M_PI/4.0, -1.0*M_PI/2.0 - EPS},
+            {M_PI/2.0, -1.0*M_PI/4.0 - EPS},
+            {M_PI/4.0, -1.0*M_PI/2.0 - EPS},
+            {0.0, -1.0*M_PI/4.0 - EPS},
+            {-1.0*M_PI/4.0, -1.0*M_PI/2.0 - EPS},
+            {-1.0*M_PI/2.0, -1.0*M_PI/4.0 - EPS},
+            {-3.0*M_PI/4.0, -1.0*M_PI/2.0 - EPS},
+            {-1.0*M_PI - EPS, -1.0*M_PI/4.0}
+        };
+        return pnpoly((int)sizeof(healpixVertsJit)/
+                      sizeof(healpixVertsJit[0]), healpixVertsJit, x, y);
     } else {
-    	double rhealpixVertsJit[][2] = {
-    	    {-1.0*PI - EPS, PI/4.0 + EPS},
-    	    {-1.0*PI + north_square*PI/2.0- EPS, PI/4.0 + EPS},
-    	    {-1.0*PI + north_square*PI/2.0- EPS, 3*PI/4.0 + EPS},
-    	    {-1.0*PI + (north_square + 1.0)*PI/2.0 + EPS, 3*PI/4.0 + EPS},
-    	    {-1.0*PI + (north_square + 1.0)*PI/2.0 + EPS, PI/4.0 + EPS},
-    	    {PI + EPS, PI/4.0 + EPS},
-    	    {PI + EPS, -1.0*PI/4.0 - EPS},
-    	    {-1.0*PI + (south_square + 1.0)*PI/2.0 + EPS, -1.0*PI/4.0 - EPS},
-    	    {-1.0*PI + (south_square + 1.0)*PI/2.0 + EPS, -3.0*PI/4.0 - EPS},
-    	    {-1.0*PI + south_square*PI/2.0 - EPS, -3.0*PI/4.0 - EPS},
-    	    {-1.0*PI + south_square*PI/2.0 - EPS, -1.0*PI/4.0 - EPS},
-    	    {-1.0*PI - EPS, -1.0*PI/4.0 - EPS}};
-    	return pnpoly((int)sizeof(rhealpixVertsJit)/
-    	              sizeof(rhealpixVertsJit[0]), rhealpixVertsJit, x, y);
+        double rhealpixVertsJit[][2] = {
+            {-1.0*M_PI - EPS, M_PI/4.0 + EPS},
+            {-1.0*M_PI + north_square*M_PI/2.0- EPS, M_PI/4.0 + EPS},
+            {-1.0*M_PI + north_square*M_PI/2.0- EPS, 3*M_PI/4.0 + EPS},
+            {-1.0*M_PI + (north_square + 1.0)*M_PI/2.0 + EPS, 3*M_PI/4.0 + EPS},
+            {-1.0*M_PI + (north_square + 1.0)*M_PI/2.0 + EPS, M_PI/4.0 + EPS},
+            {M_PI + EPS, M_PI/4.0 + EPS},
+            {M_PI + EPS, -1.0*M_PI/4.0 - EPS},
+            {-1.0*M_PI + (south_square + 1.0)*M_PI/2.0 + EPS, -1.0*M_PI/4.0 - EPS},
+            {-1.0*M_PI + (south_square + 1.0)*M_PI/2.0 + EPS, -3.0*M_PI/4.0 - EPS},
+            {-1.0*M_PI + south_square*M_PI/2.0 - EPS, -3.0*M_PI/4.0 - EPS},
+            {-1.0*M_PI + south_square*M_PI/2.0 - EPS, -1.0*M_PI/4.0 - EPS},
+            {-1.0*M_PI - EPS, -1.0*M_PI/4.0 - EPS}};
+        return pnpoly((int)sizeof(rhealpixVertsJit)/
+                      sizeof(rhealpixVertsJit[0]), rhealpixVertsJit, x, y);
     }
 }
+
+
 /**
  * Return the authalic latitude of latitude alpha (if inverse=0) or
- * return the approximate latitude of authalic latitude alpha (if inverse=1).    
- * P contains the relavent ellipsoid parameters. 
+ * return the approximate latitude of authalic latitude alpha (if inverse=1).
+ * P contains the relavent ellipsoid parameters.
  **/
 double auth_lat(PJ *P, double alpha, int inverse) {
+    struct pj_opaque *Q = P->opaque;
     if (inverse == 0) {
         /* Authalic latitude. */
         double q = pj_qsfn(sin(alpha), P->e, 1.0 - P->es);
-        double qp = P->qp; 
-	    double ratio = q/qp;
-	    if (fabsl(ratio) > 1) {
-	        /* Rounding error. */
-	        ratio = pj_sign(ratio);
-	    }
-	    return asin(ratio);
+        double qp = Q->qp;
+        double ratio = q/qp;
+
+        if (fabsl(ratio) > 1) {
+            /* Rounding error. */
+            ratio = pj_sign(ratio);
+        }
+        return asin(ratio);
     } else {
         /* Approximation to inverse authalic latitude. */
-        return pj_authlat(alpha, P->apa);
+        return pj_authlat(alpha, Q->apa);
     }
 }
+
+
 /**
  * Return the HEALPix projection of the longitude-latitude point lp on
  * the unit sphere.
@@ -214,51 +235,57 @@ XY healpix_sphere(LP lp) {
     double phi = lp.phi;
     double phi0 = asin(2.0/3.0);
     XY xy;
+
     /* equatorial region */
     if ( fabsl(phi) <= phi0) {
-	    xy.x = lam;
-	    xy.y = 3.0*PI/8.0*sin(phi);
+        xy.x = lam;
+        xy.y = 3.0*M_PI/8.0*sin(phi);
     } else {
-	    double lamc;
-	    double sigma = sqrt(3.0*(1 - fabsl(sin(phi))));
-	    double cn = floor(2*lam / PI + 2);
-	    if (cn >= 4) {
-	        cn = 3;
-	    }
-	    lamc = -3*PI/4 + (PI/2)*cn;
-	    xy.x = lamc + (lam - lamc)*sigma;
-	    xy.y = pj_sign(phi)*PI/4*(2 - sigma);
+        double lamc;
+        double sigma = sqrt(3.0*(1 - fabsl(sin(phi))));
+        double cn = floor(2*lam / M_PI + 2);
+        if (cn >= 4) {
+            cn = 3;
+        }
+        lamc = -3*M_PI/4 + (M_PI/2)*cn;
+        xy.x = lamc + (lam - lamc)*sigma;
+        xy.y = pj_sign(phi)*M_PI/4*(2 - sigma);
     }
     return xy;
 }
+
+
 /**
- * Return the inverse of healpix_sphere(). 
+ * Return the inverse of healpix_sphere().
 **/
 LP healpix_sphere_inverse(XY xy) {
-    LP lp; 
+    LP lp;
     double x = xy.x;
     double y = xy.y;
-    double y0 = PI/4.0;
+    double y0 = M_PI/4.0;
+
     /* Equatorial region. */
     if (fabsl(y) <= y0) {
-	    lp.lam = x;
-	    lp.phi = asin(8.0*y/(3.0*PI));	
-    } else if (fabsl(y) < PI/2.0) {
-	    double cn = floor(2.0*x/PI + 2.0);
+        lp.lam = x;
+        lp.phi = asin(8.0*y/(3.0*M_PI));
+    } else if (fabsl(y) < M_PI/2.0) {
+        double cn = floor(2.0*x/M_PI + 2.0);
         double xc, tau;
-	    if (cn >= 4) {
-	        cn = 3;
-	    }
-	    xc = -3.0*PI/4.0 + (PI/2.0)*cn;
-	    tau = 2.0 - 4.0*fabsl(y)/PI;
-	    lp.lam = xc + (x - xc)/tau;	
-	    lp.phi = pj_sign(y)*asin(1.0 - pow(tau , 2.0)/3.0);
+        if (cn >= 4) {
+            cn = 3;
+        }
+        xc = -3.0*M_PI/4.0 + (M_PI/2.0)*cn;
+        tau = 2.0 - 4.0*fabsl(y)/M_PI;
+        lp.lam = xc + (x - xc)/tau;
+        lp.phi = pj_sign(y)*asin(1.0 - pow(tau , 2.0)/3.0);
     } else {
-	    lp.lam = -1.0*PI;
-	    lp.phi = pj_sign(y)*PI/2.0;
+        lp.lam = -1.0*M_PI;
+        lp.phi = pj_sign(y)*M_PI/2.0;
     }
     return (lp);
 }
+
+
 /**
  * Return the vector sum a + b, where a and b are 2-dimensional vectors.
  * @param ret holds a + b.
@@ -266,21 +293,25 @@ LP healpix_sphere_inverse(XY xy) {
 static void vector_add(double a[2], double b[2], double *ret) {
     int i;
     for(i = 0; i < 2; i++) {
-	    ret[i] = a[i] + b[i];
+        ret[i] = a[i] + b[i];
     }
 }
+
+
 /**
  * Return the vector difference a - b, where a and b are 2-dimensional vectors.
  * @param ret holds a - b.
  **/
 static void vector_sub(double a[2], double b[2], double*ret) {
     int i;
-    for(i = 0; i < 2; i++) { 
-	    ret[i] = a[i] - b[i];
+    for(i = 0; i < 2; i++) {
+        ret[i] = a[i] - b[i];
     }
 }
+
+
 /**
- * Return the 2 x 1 matrix product a*b, where a is a 2 x 2 matrix and 
+ * Return the 2 x 1 matrix product a*b, where a is a 2 x 2 matrix and
  * b is a 2 x 1 matrix.
  * @param ret holds a*b.
  **/
@@ -288,105 +319,110 @@ static void dot_product(double a[2][2], double b[2], double *ret) {
     int i, j;
     int length = 2;
     for(i = 0; i < length; i++) {
-	    ret[i] = 0;
-	    for(j = 0; j < length; j++) {
-	        ret[i] += a[i][j]*b[j];
-	    }
+        ret[i] = 0;
+        for(j = 0; j < length; j++) {
+            ret[i] += a[i][j]*b[j];
+        }
     }
 }
+
+
 /**
- * Return the number of the polar cap, the pole point coordinates, and 
+ * Return the number of the polar cap, the pole point coordinates, and
  * the region that (x, y) lies in.
- * If inverse=0, then assume (x,y) lies in the image of the HEALPix 
+ * If inverse=0, then assume (x,y) lies in the image of the HEALPix
  * projection of the unit sphere.
- * If inverse=1, then assume (x,y) lies in the image of the 
+ * If inverse=1, then assume (x,y) lies in the image of the
  * (north_square, south_square)-rHEALPix projection of the unit sphere.
  **/
 static CapMap get_cap(double x, double y, int north_square, int south_square,
                       int inverse) {
     CapMap capmap;
     double c;
+
     capmap.x = x;
     capmap.y = y;
     if (inverse == 0) {
-    	if (y > PI/4.0) {
-    	    capmap.region = north;
-    	    c = PI/2.0; 
-    	} else if (y < -1*PI/4.0) {
-    	    capmap.region = south;
-    	    c = -1*PI/2.0;
-    	} else {
-    	    capmap.region = equatorial;
-    	    capmap.cn = 0;
-    	    return capmap;
-    	}
-    	/* polar region */
-    	if (x < -1*PI/2.0) {
-    	    capmap.cn = 0;
-    	    capmap.x = (-1*3.0*PI/4.0);
-    	    capmap.y = c;
-    	} else if (x >= -1*PI/2.0 && x < 0) {
-    	    capmap.cn = 1;
-    	    capmap.x = -1*PI/4.0;
-    	    capmap.y = c;
-    	} else if (x >= 0 && x < PI/2.0) {
-    	    capmap.cn = 2;
-    	    capmap.x = PI/4.0;
-    	    capmap.y = c;
-    	} else {
-    	    capmap.cn = 3;
-    	    capmap.x = 3.0*PI/4.0;
-    	    capmap.y = c;
-    	}
-    	return capmap;
+        if (y > M_PI/4.0) {
+            capmap.region = north;
+            c = M_PI/2.0;
+        } else if (y < -1*M_PI/4.0) {
+            capmap.region = south;
+            c = -1*M_PI/2.0;
+        } else {
+            capmap.region = equatorial;
+            capmap.cn = 0;
+            return capmap;
+        }
+        /* polar region */
+        if (x < -1*M_PI/2.0) {
+            capmap.cn = 0;
+            capmap.x = (-1*3.0*M_PI/4.0);
+            capmap.y = c;
+        } else if (x >= -1*M_PI/2.0 && x < 0) {
+            capmap.cn = 1;
+            capmap.x = -1*M_PI/4.0;
+            capmap.y = c;
+        } else if (x >= 0 && x < M_PI/2.0) {
+            capmap.cn = 2;
+            capmap.x = M_PI/4.0;
+            capmap.y = c;
+        } else {
+            capmap.cn = 3;
+            capmap.x = 3.0*M_PI/4.0;
+            capmap.y = c;
+        }
+        return capmap;
     } else {
-    	double eps;
-    	if (y > PI/4.0) {
-    	    capmap.region = north;
-    	    capmap.x = (-3.0*PI/4.0 + north_square*PI/2.0); 
-    	    capmap.y = PI/2.0;
-    	    x = x - north_square*PI/2.0;
-    	} else if (y < -1*PI/4.0) {
-    	    capmap.region = south;
-    	    capmap.x = (-3.0*PI/4.0 + south_square*PI/2); 
-    	    capmap.y = -1*PI/2.0;
-    	    x = x - south_square*PI/2.0;
-    	} else {
-    	    capmap.region = equatorial;
-    	    capmap.cn = 0;
-    	    return capmap;
-    	}
-    	/* Polar Region, find the HEALPix polar cap number that 
-    	   x, y moves to when rHEALPix polar square is disassembled. */
-    	eps = 1e-15; /* Kludge.  Fuzz to avoid some rounding errors. */
-    	if (capmap.region == north) {
-    	    if (y >= -1*x - PI/4.0 - eps && y < x + 5.0*PI/4.0 - eps) {
-    		    capmap.cn = (north_square + 1) % 4;
-    	    } else if (y > -1*x -1*PI/4.0 + eps && y >= x + 5.0*PI/4.0 - eps) {
-    		    capmap.cn = (north_square + 2) % 4;
-    	    } else if (y <= -1*x -1*PI/4.0 + eps && y > x + 5.0*PI/4.0 + eps) {
-    		    capmap.cn = (north_square + 3) % 4;
-    	    } else {
-    		    capmap.cn = north_square;
-    	    }
-    	} else if (capmap.region == south) {
-    	    if (y <= x + PI/4.0 + eps && y > -1*x - 5.0*PI/4 + eps) {
-    		    capmap.cn = (south_square + 1) % 4;
-    	    } else if (y < x + PI/4.0 - eps && y <= -1*x - 5.0*PI/4.0 + eps) {
-    		    capmap.cn = (south_square + 2) % 4;
-    	    } else if (y >= x + PI/4.0 - eps && y < -1*x - 5.0*PI/4.0 - eps) {
-    		    capmap.cn = (south_square + 3) % 4;
-    	    } else {
-    		    capmap.cn = south_square;
-    	    }
-    	}
-    	return capmap;
+        double eps;
+        if (y > M_PI/4.0) {
+            capmap.region = north;
+            capmap.x = (-3.0*M_PI/4.0 + north_square*M_PI/2.0);
+            capmap.y = M_PI/2.0;
+            x = x - north_square*M_PI/2.0;
+        } else if (y < -1*M_PI/4.0) {
+            capmap.region = south;
+            capmap.x = (-3.0*M_PI/4.0 + south_square*M_PI/2);
+            capmap.y = -1*M_PI/2.0;
+            x = x - south_square*M_PI/2.0;
+        } else {
+            capmap.region = equatorial;
+            capmap.cn = 0;
+            return capmap;
+        }
+        /* Polar Region, find the HEALPix polar cap number that
+           x, y moves to when rHEALPix polar square is disassembled. */
+        eps = 1e-15; /* Kludge.  Fuzz to avoid some rounding errors. */
+        if (capmap.region == north) {
+            if (y >= -1*x - M_PI/4.0 - eps && y < x + 5.0*M_PI/4.0 - eps) {
+                capmap.cn = (north_square + 1) % 4;
+            } else if (y > -1*x -1*M_PI/4.0 + eps && y >= x + 5.0*M_PI/4.0 - eps) {
+                capmap.cn = (north_square + 2) % 4;
+            } else if (y <= -1*x -1*M_PI/4.0 + eps && y > x + 5.0*M_PI/4.0 + eps) {
+                capmap.cn = (north_square + 3) % 4;
+            } else {
+                capmap.cn = north_square;
+            }
+        } else if (capmap.region == south) {
+            if (y <= x + M_PI/4.0 + eps && y > -1*x - 5.0*M_PI/4 + eps) {
+                capmap.cn = (south_square + 1) % 4;
+            } else if (y < x + M_PI/4.0 - eps && y <= -1*x - 5.0*M_PI/4.0 + eps) {
+                capmap.cn = (south_square + 2) % 4;
+            } else if (y >= x + M_PI/4.0 - eps && y < -1*x - 5.0*M_PI/4.0 - eps) {
+                capmap.cn = (south_square + 3) % 4;
+            } else {
+                capmap.cn = south_square;
+            }
+        }
+        return capmap;
     }
 }
+
+
 /**
- * Rearrange point (x, y) in the HEALPix projection by 
+ * Rearrange point (x, y) in the HEALPix projection by
  * combining the polar caps into two polar squares.
- * Put the north polar square in position north_square and 
+ * Put the north polar square in position north_square and
  * the south polar square in position south_square.
  * If inverse=1, then uncombine the polar caps.
  * @param north_square integer between 0 and 3.
@@ -400,173 +436,352 @@ static XY combine_caps(double x, double y, int north_square, int south_square,
     double vector[2];
     double v_min_c[2];
     double ret_dot[2];
+
     CapMap capmap = get_cap(x, y, north_square, south_square, inverse);
     if (capmap.region == equatorial) {
-	    xy.x = capmap.x;
-	    xy.y = capmap.y;
-	    return xy;
+        xy.x = capmap.x;
+        xy.y = capmap.y;
+        return xy;
     }
     v[0] = x;
     v[1] = y;
     if (inverse == 0) {
-        /* Rotate (x, y) about its polar cap tip and then translate it to  
+        /* Rotate (x, y) about its polar cap tip and then translate it to
            north_square or south_square. */
-    	int pole = 0;
-    	double (*tmpRot)[2];
-    	double c[2] = {capmap.x, capmap.y};
-    	if (capmap.region == north) {
-    	    pole = north_square;
-    	    a[0] =  (-3.0*PI/4.0 + pole*PI/2);
-    	    a[1] =  (PI/2.0 + pole*0);
-    	    tmpRot = rot[get_rotate_index(capmap.cn - pole)];
-    	    vector_sub(v, c, v_min_c);	
-    	    dot_product(tmpRot, v_min_c, ret_dot);
-    	    vector_add(ret_dot, a, vector);
-    	} else {
-    	    pole = south_square;
-    	    a[0] =  (-3.0*PI/4.0 + pole*PI/2);
-    	    a[1] =  (PI/-2.0 + pole*0);
-    	    tmpRot = rot[get_rotate_index(-1*(capmap.cn - pole))];
-    	    vector_sub(v, c, v_min_c);	
-    	    dot_product(tmpRot, v_min_c, ret_dot);
-    	    vector_add(ret_dot, a, vector);
-    	}
-    	xy.x = vector[0];
-    	xy.y = vector[1];
-    	return xy;
+        int pole = 0;
+        double (*tmpRot)[2];
+        double c[2] = {capmap.x, capmap.y};
+        if (capmap.region == north) {
+            pole = north_square;
+            a[0] =  (-3.0*M_PI/4.0 + pole*M_PI/2);
+            a[1] =  (M_PI/2.0 + pole*0);
+            tmpRot = rot[get_rotate_index(capmap.cn - pole)];
+            vector_sub(v, c, v_min_c);
+            dot_product(tmpRot, v_min_c, ret_dot);
+            vector_add(ret_dot, a, vector);
+        } else {
+            pole = south_square;
+            a[0] =  (-3.0*M_PI/4.0 + pole*M_PI/2);
+            a[1] =  (M_PI/-2.0 + pole*0);
+            tmpRot = rot[get_rotate_index(-1*(capmap.cn - pole))];
+            vector_sub(v, c, v_min_c);
+            dot_product(tmpRot, v_min_c, ret_dot);
+            vector_add(ret_dot, a, vector);
+        }
+        xy.x = vector[0];
+        xy.y = vector[1];
+        return xy;
     } else {
         /* Inverse function.
          Unrotate (x, y) and then translate it back. */
-    	int pole = 0;
-    	double (*tmpRot)[2];
-    	double c[2] = {capmap.x, capmap.y};
-    	/* disassemble */
-    	if (capmap.region == north) {
-    	    pole = north_square;
-    	    a[0] =  (-3.0*PI/4.0 + capmap.cn*PI/2);
-    	    a[1] =  (PI/2.0 + capmap.cn*0);
-    	    tmpRot = rot[get_rotate_index(-1*(capmap.cn - pole))];
-    	    vector_sub(v, c, v_min_c);	
-    	    dot_product(tmpRot, v_min_c, ret_dot);
-    	    vector_add(ret_dot, a, vector);
-    	} else {
-    	    pole = south_square;
-    	    a[0] =  (-3.0*PI/4.0 + capmap.cn*PI/2);
-    	    a[1] =  (PI/-2.0 + capmap.cn*0);
-    	    tmpRot = rot[get_rotate_index(capmap.cn - pole)];
-    	    vector_sub(v, c, v_min_c);	
-    	    dot_product(tmpRot, v_min_c, ret_dot);
-    	    vector_add(ret_dot, a, vector);
-    	}
-    	xy.x = vector[0];
-    	xy.y = vector[1];
-    	return xy;
+        int pole = 0;
+        double (*tmpRot)[2];
+        double c[2] = {capmap.x, capmap.y};
+        /* disassemble */
+        if (capmap.region == north) {
+            pole = north_square;
+            a[0] =  (-3.0*M_PI/4.0 + capmap.cn*M_PI/2);
+            a[1] =  (M_PI/2.0 + capmap.cn*0);
+            tmpRot = rot[get_rotate_index(-1*(capmap.cn - pole))];
+            vector_sub(v, c, v_min_c);
+            dot_product(tmpRot, v_min_c, ret_dot);
+            vector_add(ret_dot, a, vector);
+        } else {
+            pole = south_square;
+            a[0] =  (-3.0*M_PI/4.0 + capmap.cn*M_PI/2);
+            a[1] =  (M_PI/-2.0 + capmap.cn*0);
+            tmpRot = rot[get_rotate_index(capmap.cn - pole)];
+            vector_sub(v, c, v_min_c);
+            dot_product(tmpRot, v_min_c, ret_dot);
+            vector_add(ret_dot, a, vector);
+        }
+        xy.x = vector[0];
+        xy.y = vector[1];
+        return xy;
     }
 }
-FORWARD(s_healpix_forward); /* sphere  */
+
+
+static XY s_healpix_forward(LP lp, PJ *P) { /* sphere  */
     (void) P;
-    (void) xy;
     return healpix_sphere(lp);
 }
-FORWARD(e_healpix_forward); /* ellipsoid  */
-    (void) xy;
+
+
+static XY e_healpix_forward(LP lp, PJ *P) { /* ellipsoid  */
     lp.phi = auth_lat(P, lp.phi, 0);
     return healpix_sphere(lp);
 }
-INVERSE(s_healpix_inverse); /* sphere */
+
+
+static LP s_healpix_inverse(XY xy, PJ *P) { /* sphere */
+    LP lp = {0.0,0.0};
+
     /* Check whether (x, y) lies in the HEALPix image */
     if (in_image(xy.x, xy.y, 0, 0, 0) == 0) {
-	    lp.lam = HUGE_VAL;
-	    lp.phi = HUGE_VAL;
-	    pj_ctx_set_errno(P->ctx, -15);
-	    return lp;
+        lp.lam = HUGE_VAL;
+        lp.phi = HUGE_VAL;
+        pj_ctx_set_errno(P->ctx, -15);
+        return lp;
     }
     return healpix_sphere_inverse(xy);
 }
-INVERSE(e_healpix_inverse); /* ellipsoid */
+
+
+static LP e_healpix_inverse(XY xy, PJ *P) { /* ellipsoid */
+    LP lp = {0.0,0.0};
+
     /* Check whether (x, y) lies in the HEALPix image. */
     if (in_image(xy.x, xy.y, 0, 0, 0) == 0) {
-	    lp.lam = HUGE_VAL;
-	    lp.phi = HUGE_VAL;
-	    pj_ctx_set_errno(P->ctx, -15);
-	    return lp;
+        lp.lam = HUGE_VAL;
+        lp.phi = HUGE_VAL;
+        pj_ctx_set_errno(P->ctx, -15);
+        return lp;
     }
     lp = healpix_sphere_inverse(xy);
     lp.phi = auth_lat(P, lp.phi, 1);
-    return (lp);
+    return lp;
 }
-FORWARD(s_rhealpix_forward); /* sphere */
-    xy = healpix_sphere(lp);
-    return combine_caps(xy.x, xy.y, P->north_square, P->south_square, 0);
+
+
+static XY s_rhealpix_forward(LP lp, PJ *P) { /* sphere */
+    struct pj_opaque *Q = P->opaque;
+
+    XY xy = healpix_sphere(lp);
+    return combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 0);
 }
-FORWARD(e_rhealpix_forward); /* ellipsoid */
+
+
+static XY e_rhealpix_forward(LP lp, PJ *P) { /* ellipsoid */
+    struct pj_opaque *Q = P->opaque;
+    XY xy;
     lp.phi = auth_lat(P, lp.phi, 0);
     xy = healpix_sphere(lp);
-    return combine_caps(xy.x, xy.y, P->north_square, P->south_square, 0);
+    return combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 0);
 }
-INVERSE(s_rhealpix_inverse); /* sphere */
+
+
+static LP s_rhealpix_inverse(XY xy, PJ *P) { /* sphere */
+    struct pj_opaque *Q = P->opaque;
+    LP lp = {0.0,0.0};
+
     /* Check whether (x, y) lies in the rHEALPix image. */
-    if (in_image(xy.x, xy.y, 1, P->north_square, P->south_square) == 0) {
-	    lp.lam = HUGE_VAL;
-	    lp.phi = HUGE_VAL;
-	    pj_ctx_set_errno(P->ctx, -15);
-	    return lp;
+    if (in_image(xy.x, xy.y, 1, Q->north_square, Q->south_square) == 0) {
+        lp.lam = HUGE_VAL;
+        lp.phi = HUGE_VAL;
+        pj_ctx_set_errno(P->ctx, -15);
+        return lp;
     }
-    xy = combine_caps(xy.x, xy.y, P->north_square, P->south_square, 1);
+    xy = combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 1);
     return healpix_sphere_inverse(xy);
 }
-INVERSE(e_rhealpix_inverse); /* ellipsoid */
+
+
+static LP e_rhealpix_inverse(XY xy, PJ *P) { /* ellipsoid */
+    struct pj_opaque *Q = P->opaque;
+    LP lp = {0.0,0.0};
+
     /* Check whether (x, y) lies in the rHEALPix image. */
-    if (in_image(xy.x, xy.y, 1, P->north_square, P->south_square) == 0) {
-	    lp.lam = HUGE_VAL;
-	    lp.phi = HUGE_VAL;
-	    pj_ctx_set_errno(P->ctx, -15);
-	    return lp;
+    if (in_image(xy.x, xy.y, 1, Q->north_square, Q->south_square) == 0) {
+        lp.lam = HUGE_VAL;
+        lp.phi = HUGE_VAL;
+        pj_ctx_set_errno(P->ctx, -15);
+        return lp;
     }
-    xy = combine_caps(xy.x, xy.y, P->north_square, P->south_square, 1);
+    xy = combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 1);
     lp = healpix_sphere_inverse(xy);
     lp.phi = auth_lat(P, lp.phi, 1);
     return lp;
 }
-FREEUP;
-	if (P) {
-		if (P->apa)
-			pj_dalloc(P->apa);
-		pj_dalloc(P);
-	}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    if (P->opaque->apa)
+        pj_dealloc(P->opaque->apa);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-ENTRY1(healpix, apa)
+
+
+PJ *PROJECTION(healpix) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
     if (P->es) {
-        P->apa = pj_authset(P->es); /* For auth_lat(). */
-        P->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */
-    	P->a = P->a*sqrt(0.5*P->qp); /* Set P->a to authalic radius. */
+        Q->apa = pj_authset(P->es); /* For auth_lat(). */
+        Q->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */
+        P->a = P->a*sqrt(0.5*Q->qp); /* Set P->a to authalic radius. */
         P->ra = 1.0/P->a;
-    	P->fwd = e_healpix_forward;
-    	P->inv = e_healpix_inverse; 
+        P->fwd = e_healpix_forward;
+        P->inv = e_healpix_inverse;
     } else {
-    	P->fwd = s_healpix_forward;
-    	P->inv = s_healpix_inverse; 
+        P->fwd = s_healpix_forward;
+        P->inv = s_healpix_inverse;
     }
-ENDENTRY(P)
-ENTRY1(rhealpix, apa)
-    P->north_square = pj_param(P->ctx, P->params,"inorth_square").i;
-    P->south_square = pj_param(P->ctx, P->params,"isouth_square").i;
+
+    return P;
+}
+
+
+PJ *PROJECTION(rhealpix) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->north_square = pj_param(P->ctx, P->params,"inorth_square").i;
+    Q->south_square = pj_param(P->ctx, P->params,"isouth_square").i;
+
     /* Check for valid north_square and south_square inputs. */
-    if (P->north_square < 0 || P->north_square > 3) {
-	    E_ERROR(-47);
+    if (Q->north_square < 0 || Q->north_square > 3) {
+        E_ERROR(-47);
     }
-    if (P->south_square < 0 || P->south_square > 3) {
-	    E_ERROR(-47);
+    if (Q->south_square < 0 || Q->south_square > 3) {
+        E_ERROR(-47);
     }
     if (P->es) {
-        P->apa = pj_authset(P->es); /* For auth_lat(). */
-        P->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */
-	    P->a = P->a*sqrt(0.5*P->qp); /* Set P->a to authalic radius. */
+        Q->apa = pj_authset(P->es); /* For auth_lat(). */
+        Q->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */
+        P->a = P->a*sqrt(0.5*Q->qp); /* Set P->a to authalic radius. */
         P->ra = 1.0/P->a;
-	    P->fwd = e_rhealpix_forward;
-	    P->inv = e_rhealpix_inverse; 
+        P->fwd = e_rhealpix_forward;
+        P->inv = e_rhealpix_inverse;
     } else {
-	    P->fwd = s_rhealpix_forward;
-	    P->inv = s_rhealpix_inverse; 
+        P->fwd = s_rhealpix_forward;
+        P->inv = s_rhealpix_inverse;
     }
-ENDENTRY(P)
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_healpix_selftest (void) {return 0;}
+#else
+
+int pj_healpix_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=healpix   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=healpix   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222390.10394923863,  130406.58866448226},
+        { 222390.10394923863, -130406.58866448054},
+        {-222390.10394923863,  130406.58866448226},
+        {-222390.10394923863, -130406.58866448054},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223402.14425527418,  131588.04444199943},
+        { 223402.14425527418, -131588.04444199943},
+        {-223402.14425527418,  131588.04444199943},
+        {-223402.14425527418, -131588.04444199943},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017986411845524453,  0.00076679453057823619},
+        { 0.0017986411845524453, -0.00076679453057823619},
+        {-0.0017986411845524453,  0.00076679453057823619},
+        {-0.0017986411845524453, -0.00076679453057823619},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931097838226,  0.00075990887733981202},
+        { 0.0017904931097838226, -0.00075990887733981202},
+        {-0.0017904931097838226,  0.00075990887733981202},
+        {-0.0017904931097838226, -0.00075990887733981202},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_rhealpix_selftest (void) {return 0;}
+#else
+
+int pj_rhealpix_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=rhealpix   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=rhealpix   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222390.10394923863,  130406.58866448226},
+        { 222390.10394923863, -130406.58866448054},
+        {-222390.10394923863,  130406.58866448226},
+        {-222390.10394923863, -130406.58866448054},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223402.14425527418,  131588.04444199943},
+        { 223402.14425527418, -131588.04444199943},
+        {-223402.14425527418,  131588.04444199943},
+        {-223402.14425527418, -131588.04444199943},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017986411845524453,  0.00076679453057823619},
+        { 0.0017986411845524453, -0.00076679453057823619},
+        {-0.0017986411845524453,  0.00076679453057823619},
+        {-0.0017986411845524453, -0.00076679453057823619},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931097838226,  0.00075990887733981202},
+        { 0.0017904931097838226, -0.00075990887733981202},
+        {-0.0017904931097838226,  0.00075990887733981202},
+        {-0.0017904931097838226, -0.00075990887733981202},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_igh.c b/src/PJ_igh.c
index 4155c85..533c3aa 100644
--- a/src/PJ_igh.c
+++ b/src/PJ_igh.c
@@ -1,13 +1,17 @@
-#define PROJ_PARMS__ \
-        struct PJconsts* pj[12]; \
-        double dy0;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(igh, "Interrupted Goode Homolosine") "\n\tPCyl, Sph.";
-	C_NAMESPACE PJ
-*pj_sinu(PJ *), *pj_moll(PJ *);
 
-static const double d4044118 = (40 + 44/60. + 11.8/3600.) * DEG_TO_RAD; // 40d 44' 11.8" [degrees]
+C_NAMESPACE PJ *pj_sinu(PJ *), *pj_moll(PJ *);
+
+/* 40d 44' 11.8" [degrees] */
+/*
+static const double d4044118 = (40 + 44/60. + 11.8/3600.) * DEG_TO_RAD;
+has been replaced by this define, to eliminate portability issue:
+Initializer element not computable at load time
+*/
+#define d4044118 ((40 + 44/60. + 11.8/3600.) * DEG_TO_RAD)
 
 static const double d10  =  10 * DEG_TO_RAD;
 static const double d20  =  20 * DEG_TO_RAD;
@@ -22,108 +26,134 @@ static const double d140 = 140 * DEG_TO_RAD;
 static const double d160 = 160 * DEG_TO_RAD;
 static const double d180 = 180 * DEG_TO_RAD;
 
-static const double EPSLN = 1.e-10; // allow a little 'slack' on zone edge positions
+static const double EPSLN = 1.e-10; /* allow a little 'slack' on zone edge positions */
 
-FORWARD(s_forward); /* spheroid */
-        int z;
-        if (lp.phi >=  d4044118) {          // 1|2
-          z = (lp.lam <= -d40 ? 1: 2);
-        }
-        else if (lp.phi >=  0) {            // 3|4
-          z = (lp.lam <= -d40 ? 3: 4);
-        }
-        else if (lp.phi >= -d4044118) {     // 5|6|7|8
-               if (lp.lam <= -d100) z =  5; // 5
-          else if (lp.lam <=  -d20) z =  6; // 6
-          else if (lp.lam <=   d80) z =  7; // 7
-          else z = 8;                       // 8
-        }
-        else {                              // 9|10|11|12
-               if (lp.lam <= -d100) z =  9; // 9
-          else if (lp.lam <=  -d20) z = 10; // 10
-          else if (lp.lam <=   d80) z = 11; // 11
-          else z = 12;                      // 12
-        }
+struct pj_opaque {
+    struct PJconsts* pj[12]; \
+    double dy0;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    int z;
+
+    if (lp.phi >=  d4044118) {          /* 1|2 */
+      z = (lp.lam <= -d40 ? 1: 2);
+    }
+    else if (lp.phi >=  0) {            /* 3|4 */
+      z = (lp.lam <= -d40 ? 3: 4);
+    }
+    else if (lp.phi >= -d4044118) {     /* 5|6|7|8 */
+           if (lp.lam <= -d100) z =  5; /* 5 */
+      else if (lp.lam <=  -d20) z =  6; /* 6 */
+      else if (lp.lam <=   d80) z =  7; /* 7 */
+      else z = 8;                       /* 8 */
+    }
+    else {                              /* 9|10|11|12 */
+           if (lp.lam <= -d100) z =  9; /* 9 */
+      else if (lp.lam <=  -d20) z = 10; /* 10 */
+      else if (lp.lam <=   d80) z = 11; /* 11 */
+      else z = 12;                      /* 12 */
+    }
 
-        lp.lam -= P->pj[z-1]->lam0;
-        xy = P->pj[z-1]->fwd(lp, P->pj[z-1]);
-        xy.x += P->pj[z-1]->x0;
-        xy.y += P->pj[z-1]->y0;
+    lp.lam -= Q->pj[z-1]->lam0;
+    xy = Q->pj[z-1]->fwd(lp, Q->pj[z-1]);
+    xy.x += Q->pj[z-1]->x0;
+    xy.y += Q->pj[z-1]->y0;
 
-        return (xy);
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-        const double y90 = P->dy0 + sqrt(2); // lt=90 corresponds to y=y0+sqrt(2)
-
-        int z = 0;
-        if (xy.y > y90+EPSLN || xy.y < -y90+EPSLN) // 0
-          z = 0;
-        else if (xy.y >=  d4044118)       // 1|2
-          z = (xy.x <= -d40? 1: 2);
-        else if (xy.y >=  0)              // 3|4
-          z = (xy.x <= -d40? 3: 4);
-        else if (xy.y >= -d4044118) {     // 5|6|7|8
-               if (xy.x <= -d100) z =  5; // 5
-          else if (xy.x <=  -d20) z =  6; // 6
-          else if (xy.x <=   d80) z =  7; // 7
-          else z = 8;                     // 8
-        }
-        else {                            // 9|10|11|12
-               if (xy.x <= -d100) z =  9; // 9
-          else if (xy.x <=  -d20) z = 10; // 10
-          else if (xy.x <=   d80) z = 11; // 11
-          else z = 12;                    // 12
-        }
 
-        if (z)
-        {
-          int ok = 0;
-
-          xy.x -= P->pj[z-1]->x0;
-          xy.y -= P->pj[z-1]->y0;
-          lp = P->pj[z-1]->inv(xy, P->pj[z-1]);
-          lp.lam += P->pj[z-1]->lam0;
-
-          switch (z) {
-            case  1: ok = (lp.lam >= -d180-EPSLN && lp.lam <=  -d40+EPSLN) ||
-                         ((lp.lam >=  -d40-EPSLN && lp.lam <=  -d10+EPSLN) &&
-                          (lp.phi >=   d60-EPSLN && lp.phi <=   d90+EPSLN)); break;
-            case  2: ok = (lp.lam >=  -d40-EPSLN && lp.lam <=  d180+EPSLN) ||
-                         ((lp.lam >= -d180-EPSLN && lp.lam <= -d160+EPSLN) &&
-                          (lp.phi >=   d50-EPSLN && lp.phi <=   d90+EPSLN)) ||
-                         ((lp.lam >=  -d50-EPSLN && lp.lam <=  -d40+EPSLN) &&
-                          (lp.phi >=   d60-EPSLN && lp.phi <=   d90+EPSLN)); break;
-            case  3: ok = (lp.lam >= -d180-EPSLN && lp.lam <=  -d40+EPSLN); break;
-            case  4: ok = (lp.lam >=  -d40-EPSLN && lp.lam <=  d180+EPSLN); break;
-            case  5: ok = (lp.lam >= -d180-EPSLN && lp.lam <= -d100+EPSLN); break;
-            case  6: ok = (lp.lam >= -d100-EPSLN && lp.lam <=  -d20+EPSLN); break;
-            case  7: ok = (lp.lam >=  -d20-EPSLN && lp.lam <=   d80+EPSLN); break;
-            case  8: ok = (lp.lam >=   d80-EPSLN && lp.lam <=  d180+EPSLN); break;
-            case  9: ok = (lp.lam >= -d180-EPSLN && lp.lam <= -d100+EPSLN); break;
-            case 10: ok = (lp.lam >= -d100-EPSLN && lp.lam <=  -d20+EPSLN); break;
-            case 11: ok = (lp.lam >=  -d20-EPSLN && lp.lam <=   d80+EPSLN); break;
-            case 12: ok = (lp.lam >=   d80-EPSLN && lp.lam <=  d180+EPSLN); break;
-          }
-
-          z = (!ok? 0: z); // projectable?
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    const double y90 = Q->dy0 + sqrt(2); /* lt=90 corresponds to y=y0+sqrt(2) */
+
+    int z = 0;
+    if (xy.y > y90+EPSLN || xy.y < -y90+EPSLN) /* 0 */
+      z = 0;
+    else if (xy.y >=  d4044118)       /* 1|2 */
+      z = (xy.x <= -d40? 1: 2);
+    else if (xy.y >=  0)              /* 3|4 */
+      z = (xy.x <= -d40? 3: 4);
+    else if (xy.y >= -d4044118) {     /* 5|6|7|8 */
+           if (xy.x <= -d100) z =  5; /* 5 */
+      else if (xy.x <=  -d20) z =  6; /* 6 */
+      else if (xy.x <=   d80) z =  7; /* 7 */
+      else z = 8;                     /* 8 */
+    }
+    else {                            /* 9|10|11|12 */
+           if (xy.x <= -d100) z =  9; /* 9 */
+      else if (xy.x <=  -d20) z = 10; /* 10 */
+      else if (xy.x <=   d80) z = 11; /* 11 */
+      else z = 12;                    /* 12 */
+    }
+
+    if (z) {
+        int ok = 0;
+
+        xy.x -= Q->pj[z-1]->x0;
+        xy.y -= Q->pj[z-1]->y0;
+        lp = Q->pj[z-1]->inv(xy, Q->pj[z-1]);
+        lp.lam += Q->pj[z-1]->lam0;
+
+        switch (z) {
+        case  1: ok = (lp.lam >= -d180-EPSLN && lp.lam <=  -d40+EPSLN) ||
+                     ((lp.lam >=  -d40-EPSLN && lp.lam <=  -d10+EPSLN) &&
+                      (lp.phi >=   d60-EPSLN && lp.phi <=   d90+EPSLN)); break;
+        case  2: ok = (lp.lam >=  -d40-EPSLN && lp.lam <=  d180+EPSLN) ||
+                     ((lp.lam >= -d180-EPSLN && lp.lam <= -d160+EPSLN) &&
+                      (lp.phi >=   d50-EPSLN && lp.phi <=   d90+EPSLN)) ||
+                     ((lp.lam >=  -d50-EPSLN && lp.lam <=  -d40+EPSLN) &&
+                      (lp.phi >=   d60-EPSLN && lp.phi <=   d90+EPSLN)); break;
+        case  3: ok = (lp.lam >= -d180-EPSLN && lp.lam <=  -d40+EPSLN); break;
+        case  4: ok = (lp.lam >=  -d40-EPSLN && lp.lam <=  d180+EPSLN); break;
+        case  5: ok = (lp.lam >= -d180-EPSLN && lp.lam <= -d100+EPSLN); break;
+        case  6: ok = (lp.lam >= -d100-EPSLN && lp.lam <=  -d20+EPSLN); break;
+        case  7: ok = (lp.lam >=  -d20-EPSLN && lp.lam <=   d80+EPSLN); break;
+        case  8: ok = (lp.lam >=   d80-EPSLN && lp.lam <=  d180+EPSLN); break;
+        case  9: ok = (lp.lam >= -d180-EPSLN && lp.lam <= -d100+EPSLN); break;
+        case 10: ok = (lp.lam >= -d100-EPSLN && lp.lam <=  -d20+EPSLN); break;
+        case 11: ok = (lp.lam >=  -d20-EPSLN && lp.lam <=   d80+EPSLN); break;
+        case 12: ok = (lp.lam >=   d80-EPSLN && lp.lam <=  d180+EPSLN); break;
         }
-     // if (!z) pj_errno = -15; // invalid x or y
-        if (!z) lp.lam = HUGE_VAL;
-        if (!z) lp.phi = HUGE_VAL;
-        return (lp);
+      z = (!ok? 0: z); /* projectable? */
+    }
+
+    if (!z) lp.lam = HUGE_VAL;
+    if (!z) lp.phi = HUGE_VAL;
+
+    return lp;
 }
-FREEUP;
-        if (P) {
-                int i;
-                for (i = 0; i < 12; ++i)
-		{
-			if (P->pj[i]) 
-				(*(P->pj[i]->pfree))(P->pj[i]); 
-                }
-                pj_dalloc(P);
-        }
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    int i;
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    for (i = 0; i < 12; ++i) {
+        if (P->opaque->pj[i])
+            pj_dealloc(P->opaque->pj[i]);
+    }
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-ENTRY0(igh)
+
+
+
 /*
   Zones:
 
@@ -145,46 +175,96 @@ ENTRY0(igh)
 */
 
 #define SETUP(n, proj, x_0, y_0, lon_0) \
-    if (!(P->pj[n-1] = pj_##proj(0))) E_ERROR_0; \
-    if (!(P->pj[n-1] = pj_##proj(P->pj[n-1]))) E_ERROR_0; \
-    P->pj[n-1]->x0 = x_0; \
-    P->pj[n-1]->y0 = y_0; \
-    P->pj[n-1]->lam0 = lon_0; 
+    if (!(Q->pj[n-1] = pj_##proj(0))) E_ERROR_0; \
+    if (!(Q->pj[n-1] = pj_##proj(Q->pj[n-1]))) E_ERROR_0; \
+    Q->pj[n-1]->x0 = x_0; \
+    Q->pj[n-1]->y0 = y_0; \
+    Q->pj[n-1]->lam0 = lon_0;
+
+
+PJ *PROJECTION(igh) {
+    XY xy1, xy3;
+    LP lp = { 0, d4044118 };
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
 
-        LP lp = { 0, d4044118 };
-        XY xy1;
-        XY xy3;
 
-        // sinusoidal zones
-        SETUP(3, sinu, -d100, 0, -d100);
-        SETUP(4, sinu,   d30, 0,   d30);
-        SETUP(5, sinu, -d160, 0, -d160);
-        SETUP(6, sinu,  -d60, 0,  -d60);
-        SETUP(7, sinu,   d20, 0,   d20);
-        SETUP(8, sinu,  d140, 0,  d140);
+    /* sinusoidal zones */
+    SETUP(3, sinu, -d100, 0, -d100);
+    SETUP(4, sinu,   d30, 0,   d30);
+    SETUP(5, sinu, -d160, 0, -d160);
+    SETUP(6, sinu,  -d60, 0,  -d60);
+    SETUP(7, sinu,   d20, 0,   d20);
+    SETUP(8, sinu,  d140, 0,  d140);
 
-        // mollweide zones
-        SETUP(1, moll, -d100, 0, -d100);
+    /* mollweide zones */
+    SETUP(1, moll, -d100, 0, -d100);
 
-        // y0 ?
-        xy1 = P->pj[0]->fwd(lp, P->pj[0]); // zone 1
-        xy3 = P->pj[2]->fwd(lp, P->pj[2]); // zone 3
-        // y0 + xy1.y = xy3.y for lt = 40d44'11.8"
-        P->dy0 = xy3.y - xy1.y;
+    /* y0 ? */
+    xy1 = Q->pj[0]->fwd(lp, Q->pj[0]); /* zone 1 */
+    xy3 = Q->pj[2]->fwd(lp, Q->pj[2]); /* zone 3 */
+    /* y0 + xy1.y = xy3.y for lt = 40d44'11.8" */
+    Q->dy0 = xy3.y - xy1.y;
 
-        P->pj[0]->y0 = P->dy0;
+    Q->pj[0]->y0 = Q->dy0;
 
-        // mollweide zones (cont'd)
-        SETUP( 2, moll,   d30,  P->dy0,   d30);
-        SETUP( 9, moll, -d160, -P->dy0, -d160);
-        SETUP(10, moll,  -d60, -P->dy0,  -d60);
-        SETUP(11, moll,   d20, -P->dy0,   d20);
-        SETUP(12, moll,  d140, -P->dy0,  d140);
+    /* mollweide zones (cont'd) */
+    SETUP( 2, moll,   d30,  Q->dy0,   d30);
+    SETUP( 9, moll, -d160, -Q->dy0, -d160);
+    SETUP(10, moll,  -d60, -Q->dy0,  -d60);
+    SETUP(11, moll,   d20, -Q->dy0,   d20);
+    SETUP(12, moll,  d140, -Q->dy0,  d140);
 
-        P->inv = s_inverse;
-        P->fwd = s_forward;
-        P->es = 0.;
-ENDENTRY(P)
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    P->es = 0.;
 
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_igh_selftest (void) {return 0;}
+#else
+
+int pj_igh_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=igh   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223878.49745627123,  111701.07212763709},
+        { 223708.37131305804, -111701.07212763709},
+        {-222857.74059699223,  111701.07212763709},
+        {-223027.86674020503, -111701.07212763709},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.001790489447892545,   0.00089524655489191132},
+        { 0.0017904906685957927, -0.00089524655489191132},
+        {-0.001790496772112032,   0.00089524655489191132},
+        {-0.0017904955514087843, -0.00089524655489191132},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
 
 
+#endif
diff --git a/src/PJ_imw_p.c b/src/PJ_imw_p.c
index ae41111..a1675a9 100644
--- a/src/PJ_imw_p.c
+++ b/src/PJ_imw_p.c
@@ -1,151 +1,238 @@
-#define PROJ_PARMS__ \
-	double	P, Pp, Q, Qp, R_1, R_2, sphi_1, sphi_2, C2; \
-	double	phi_1, phi_2, lam_1; \
-	double	*en; \
-	int	mode; /* = 0, phi_1 and phi_2 != 0, = 1, phi_1 = 0, = -1 phi_2 = 0 */
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(imw_p, "International Map of the World Polyconic")
-	"\n\tMod. Polyconic, Ell\n\tlat_1= and lat_2= [lon_1=]";
+    "\n\tMod. Polyconic, Ell\n\tlat_1= and lat_2= [lon_1=]";
+
 #define TOL 1e-10
 #define EPS 1e-10
-	static int
-phi12(PJ *P, double *del, double *sig) {
-	int err = 0;
-
-	if (!pj_param(P->ctx, P->params, "tlat_1").i ||
-		!pj_param(P->ctx, P->params, "tlat_2").i) {
-		err = -41;
-	} else {
-		P->phi_1 = pj_param(P->ctx, P->params, "rlat_1").f;
-		P->phi_2 = pj_param(P->ctx, P->params, "rlat_2").f;
-		*del = 0.5 * (P->phi_2 - P->phi_1);
-		*sig = 0.5 * (P->phi_2 + P->phi_1);
-		err = (fabs(*del) < EPS || fabs(*sig) < EPS) ? -42 : 0;
-	}
-	return err;
+
+struct pj_opaque {
+    double  P, Pp, Q, Qp, R_1, R_2, sphi_1, sphi_2, C2; \
+    double  phi_1, phi_2, lam_1; \
+    double  *en; \
+    int mode; /* = 0, phi_1 and phi_2 != 0, = 1, phi_1 = 0, = -1 phi_2 = 0 */
+};
+
+
+static int phi12(PJ *P, double *del, double *sig) {
+    struct pj_opaque *Q = P->opaque;
+    int err = 0;
+
+    if (!pj_param(P->ctx, P->params, "tlat_1").i ||
+        !pj_param(P->ctx, P->params, "tlat_2").i) {
+        err = -41;
+    } else {
+        Q->phi_1 = pj_param(P->ctx, P->params, "rlat_1").f;
+        Q->phi_2 = pj_param(P->ctx, P->params, "rlat_2").f;
+        *del = 0.5 * (Q->phi_2 - Q->phi_1);
+        *sig = 0.5 * (Q->phi_2 + Q->phi_1);
+        err = (fabs(*del) < EPS || fabs(*sig) < EPS) ? -42 : 0;
+    }
+    return err;
+}
+
+
+static XY loc_for(LP lp, PJ *P, double *yc) {
+    struct pj_opaque *Q = P->opaque;
+    XY xy;
+
+    if (! lp.phi) {
+        xy.x = lp.lam;
+        xy.y = 0.;
+    } else {
+        double xa, ya, xb, yb, xc, D, B, m, sp, t, R, C;
+
+        sp = sin(lp.phi);
+        m = pj_mlfn(lp.phi, sp, cos(lp.phi), Q->en);
+        xa = Q->Pp + Q->Qp * m;
+        ya = Q->P + Q->Q * m;
+        R = 1. / (tan(lp.phi) * sqrt(1. - P->es * sp * sp));
+        C = sqrt(R * R - xa * xa);
+        if (lp.phi < 0.) C = - C;
+        C += ya - R;
+        if (Q->mode < 0) {
+            xb = lp.lam;
+            yb = Q->C2;
+        } else {
+            t = lp.lam * Q->sphi_2;
+            xb = Q->R_2 * sin(t);
+            yb = Q->C2 + Q->R_2 * (1. - cos(t));
+        }
+        if (Q->mode > 0) {
+            xc = lp.lam;
+            *yc = 0.;
+        } else {
+            t = lp.lam * Q->sphi_1;
+            xc = Q->R_1 * sin(t);
+            *yc = Q->R_1 * (1. - cos(t));
+        }
+        D = (xb - xc)/(yb - *yc);
+        B = xc + D * (C + R - *yc);
+        xy.x = D * sqrt(R * R * (1 + D * D) - B * B);
+        if (lp.phi > 0)
+            xy.x = - xy.x;
+        xy.x = (B + xy.x) / (1. + D * D);
+        xy.y = sqrt(R * R - xy.x * xy.x);
+        if (lp.phi > 0)
+            xy.y = - xy.y;
+        xy.y += C + R;
+    }
+    return xy;
+}
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    double yc;
+
+    xy = loc_for(lp, P, &yc);
+    return (xy);
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    XY t;
+    double yc;
+
+    lp.phi = Q->phi_2;
+    lp.lam = xy.x / cos(lp.phi);
+    do {
+        t = loc_for(lp, P, &yc);
+        lp.phi = ((lp.phi - Q->phi_1) * (xy.y - yc) / (t.y - yc)) + Q->phi_1;
+        lp.lam = lp.lam * xy.x / t.x;
+    } while (fabs(t.x - xy.x) > TOL || fabs(t.y - xy.y) > TOL);
+
+    return lp;
+}
+
+
+static void xy(PJ *P, double phi, double *x, double *y, double *sp, double *R) {
+    double F;
+
+    *sp = sin(phi);
+    *R = 1./(tan(phi) * sqrt(1. - P->es * *sp * *sp ));
+    F = P->opaque->lam_1 * *sp;
+    *y = *R * (1 - cos(F));
+    *x = *R * sin(F);
 }
-	static XY
-loc_for(LP lp, PJ *P, double *yc) {
-	XY xy;
-
-	if (! lp.phi) {
-		xy.x = lp.lam;
-		xy.y = 0.;
-	} else {
-		double xa, ya, xb, yb, xc, D, B, m, sp, t, R, C;
-
-		sp = sin(lp.phi);
-		m = pj_mlfn(lp.phi, sp, cos(lp.phi), P->en);
-		xa = P->Pp + P->Qp * m;
-		ya = P->P + P->Q * m;
-		R = 1. / (tan(lp.phi) * sqrt(1. - P->es * sp * sp));
-		C = sqrt(R * R - xa * xa);
-		if (lp.phi < 0.) C = - C;
-		C += ya - R;
-		if (P->mode < 0) {
-			xb = lp.lam;
-			yb = P->C2;
-		} else {
-			t = lp.lam * P->sphi_2;
-			xb = P->R_2 * sin(t);
-			yb = P->C2 + P->R_2 * (1. - cos(t));
-		}
-		if (P->mode > 0) {
-			xc = lp.lam;
-			*yc = 0.;
-		} else {
-			t = lp.lam * P->sphi_1;
-			xc = P->R_1 * sin(t);
-			*yc = P->R_1 * (1. - cos(t));
-		}
-		D = (xb - xc)/(yb - *yc);
-		B = xc + D * (C + R - *yc);
-		xy.x = D * sqrt(R * R * (1 + D * D) - B * B);
-		if (lp.phi > 0)
-			xy.x = - xy.x;
-		xy.x = (B + xy.x) / (1. + D * D);
-		xy.y = sqrt(R * R - xy.x * xy.x);
-		if (lp.phi > 0)
-			xy.y = - xy.y;
-		xy.y += C + R;
-	}
-	return (xy);
+
+
+static void *freeup_new (PJ *P) {              /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-FORWARD(e_forward); /* ellipsoid */
-	double yc;
-	xy = loc_for(lp, P, &yc);
-	return (xy);
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(e_inverse); /* ellipsoid */
-	XY t;
-	double yc;
-
-	lp.phi = P->phi_2;
-	lp.lam = xy.x / cos(lp.phi);
-	do {
-		t = loc_for(lp, P, &yc);
-		lp.phi = ((lp.phi - P->phi_1) * (xy.y - yc) / (t.y - yc)) + P->phi_1;
-		lp.lam = lp.lam * xy.x / t.x;
-	} while (fabs(t.x - xy.x) > TOL || fabs(t.y - xy.y) > TOL);
-	return (lp);
+
+
+PJ *PROJECTION(imw_p) {
+    double del, sig, s, t, x1, x2, T2, y1, m1, m2, y2;
+    int i;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    if (!(Q->en = pj_enfn(P->es))) E_ERROR_0;
+    if( (i = phi12(P, &del, &sig)) != 0)
+        E_ERROR(i);
+    if (Q->phi_2 < Q->phi_1) { /* make sure P->phi_1 most southerly */
+        del = Q->phi_1;
+        Q->phi_1 = Q->phi_2;
+        Q->phi_2 = del;
+    }
+    if (pj_param(P->ctx, P->params, "tlon_1").i)
+        Q->lam_1 = pj_param(P->ctx, P->params, "rlon_1").f;
+    else { /* use predefined based upon latitude */
+        sig = fabs(sig * RAD_TO_DEG);
+        if (sig <= 60)      sig = 2.;
+        else if (sig <= 76) sig = 4.;
+        else                sig = 8.;
+        Q->lam_1 = sig * DEG_TO_RAD;
+    }
+    Q->mode = 0;
+    if (Q->phi_1) xy(P, Q->phi_1, &x1, &y1, &Q->sphi_1, &Q->R_1);
+    else {
+        Q->mode = 1;
+        y1 = 0.;
+        x1 = Q->lam_1;
+    }
+    if (Q->phi_2) xy(P, Q->phi_2, &x2, &T2, &Q->sphi_2, &Q->R_2);
+    else {
+        Q->mode = -1;
+        T2 = 0.;
+        x2 = Q->lam_1;
+    }
+    m1 = pj_mlfn(Q->phi_1, Q->sphi_1, cos(Q->phi_1), Q->en);
+    m2 = pj_mlfn(Q->phi_2, Q->sphi_2, cos(Q->phi_2), Q->en);
+    t = m2 - m1;
+    s = x2 - x1;
+    y2 = sqrt(t * t - s * s) + y1;
+    Q->C2 = y2 - T2;
+    t = 1. / t;
+    Q->P = (m2 * y1 - m1 * y2) * t;
+    Q->Q = (y2 - y1) * t;
+    Q->Pp = (m2 * x1 - m1 * x2) * t;
+    Q->Qp = (x2 - x1) * t;
+
+    P->fwd = e_forward;
+    P->inv = e_inverse;
+
+    return P;
 }
-	static void
-xy(PJ *P, double phi, double *x, double *y, double *sp, double *R) {
-	double F;
-
-	*sp = sin(phi);
-	*R = 1./(tan(phi) * sqrt(1. - P->es * *sp * *sp ));
-	F = P->lam_1 * *sp;
-	*y = *R * (1 - cos(F));
-	*x = *R * sin(F);
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_imw_p_selftest (void) {return 0;}
+#else
+
+int pj_imw_p_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=imw_p   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222588.4411393762,   55321.128653809537},
+        { 222756.90637768712, -165827.58428832365},
+        {-222588.4411393762,   55321.128653809537},
+        {-222756.90637768712, -165827.58428832365},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017966991379592214, 0.50090492361427374},
+        { 0.0017966979081574697, 0.49909507588689922},
+        {-0.0017966991379592214, 0.50090492361427374},
+        {-0.0017966979081574697, 0.49909507588689922},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
 }
-FREEUP; if (P) { if (P->en) pj_dalloc(P->en); pj_dalloc(P); } }
-ENTRY1(imw_p, en)
-	double del, sig, s, t, x1, x2, T2, y1, m1, m2, y2;
-	int i;
-
-	if (!(P->en = pj_enfn(P->es))) E_ERROR_0;
-	if( (i = phi12(P, &del, &sig)) != 0)
-		E_ERROR(i);
-	if (P->phi_2 < P->phi_1) { /* make sure P->phi_1 most southerly */
-		del = P->phi_1;
-		P->phi_1 = P->phi_2;
-		P->phi_2 = del;
-	}
-	if (pj_param(P->ctx, P->params, "tlon_1").i)
-		P->lam_1 = pj_param(P->ctx, P->params, "rlon_1").f;
-	else { /* use predefined based upon latitude */
-		sig = fabs(sig * RAD_TO_DEG);
-		if (sig <= 60)		sig = 2.;
-		else if (sig <= 76) sig = 4.;
-		else				sig = 8.;
-		P->lam_1 = sig * DEG_TO_RAD;
-	}
-	P->mode = 0;
-	if (P->phi_1) xy(P, P->phi_1, &x1, &y1, &P->sphi_1, &P->R_1);
-	else {
-		P->mode = 1;
-		y1 = 0.;
-		x1 = P->lam_1;
-	}
-	if (P->phi_2) xy(P, P->phi_2, &x2, &T2, &P->sphi_2, &P->R_2);
-	else {
-		P->mode = -1;
-		T2 = 0.;
-		x2 = P->lam_1;
-	}
-	m1 = pj_mlfn(P->phi_1, P->sphi_1, cos(P->phi_1), P->en);
-	m2 = pj_mlfn(P->phi_2, P->sphi_2, cos(P->phi_2), P->en);
-	t = m2 - m1;
-	s = x2 - x1;
-	y2 = sqrt(t * t - s * s) + y1;
-	P->C2 = y2 - T2;
-	t = 1. / t;
-	P->P = (m2 * y1 - m1 * y2) * t;
-	P->Q = (y2 - y1) * t;
-	P->Pp = (m2 * x1 - m1 * x2) * t;
-	P->Qp = (x2 - x1) * t;
-	P->fwd = e_forward;
-	P->inv = e_inverse;
-ENDENTRY(P)
+
+
+#endif
diff --git a/src/PJ_isea.c b/src/PJ_isea.c
index 7c09189..ba9d3c6 100644
--- a/src/PJ_isea.c
+++ b/src/PJ_isea.c
@@ -1,1119 +1,1176 @@
-/*
- * This code was entirely written by Nathan Wagner
- * and is in the public domain.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <float.h>
-
-#ifndef M_PI
-#  define M_PI 3.14159265358979323846
-#endif
-
-/*
- * Proj 4 provides its own entry points into
- * the code, so none of the library functions
- * need to be global
- */
-#define ISEA_STATIC static
-#ifndef ISEA_STATIC
-#define ISEA_STATIC
-#endif
-
-struct hex {
-        int iso;
-        int x, y, z;
-};
-
-/* y *must* be positive down as the xy /iso conversion assumes this */
-ISEA_STATIC
-int hex_xy(struct hex *h) {
-	if (!h->iso) return 1;
-	if (h->x >= 0) {
-		h->y = -h->y - (h->x+1)/2;
-	} else {
-		/* need to round toward -inf, not toward zero, so x-1 */
-		h->y = -h->y - h->x/2;
-	}
-	h->iso = 0;
-
-	return 1;
-}
-
-ISEA_STATIC
-int hex_iso(struct hex *h) {
-	if (h->iso) return 1;
-
-	if (h->x >= 0) {
-		h->y = (-h->y - (h->x+1)/2);
-	} else {
-		/* need to round toward -inf, not toward zero, so x-1 */
-		h->y = (-h->y - (h->x)/2);
-	}
-
-	h->z = -h->x - h->y;
-	h->iso = 1;
-	return 1;
-}
-
-ISEA_STATIC
-int hexbin2(double width, double x, double y,
-                int *i, int *j) {
-	double z, rx, ry, rz;
-	double abs_dx, abs_dy, abs_dz;
-	int ix, iy, iz, s;
-	struct hex h;
-
-	x = x / cos(30 * M_PI / 180.0); /* rotated X coord */
-	y = y - x / 2.0; /* adjustment for rotated X */
-
-	/* adjust for actual hexwidth */
-	x /= width;
-	y /= width;
-
-	z = -x - y;
-
-	ix = rx = floor(x + 0.5);
-	iy = ry = floor(y + 0.5);
-	iz = rz = floor(z + 0.5);
-
-	s = ix + iy + iz;
-
-	if (s) {
-		abs_dx = fabs(rx - x);
-		abs_dy = fabs(ry - y);
-		abs_dz = fabs(rz - z);
-
-		if (abs_dx >= abs_dy && abs_dx >= abs_dz) {
-			ix -= s;
-		} else if (abs_dy >= abs_dx && abs_dy >= abs_dz) {
-			iy -= s;
-		} else {
-			iz -= s;
-		}
-	}
-	h.x = ix;
-	h.y = iy;
-	h.z = iz;
-	h.iso = 1;
-
-	hex_xy(&h);
-	*i = h.x;
-	*j = h.y;
-        return ix * 100 + iy;
-}
-#ifndef ISEA_STATIC
-#define ISEA_STATIC
-#endif
-
-enum isea_poly { ISEA_NONE, ISEA_ICOSAHEDRON = 20 };
-enum isea_topology { ISEA_HEXAGON=6, ISEA_TRIANGLE=3, ISEA_DIAMOND=4 };
-enum isea_address_form { ISEA_GEO, ISEA_Q2DI, ISEA_SEQNUM, ISEA_INTERLEAVE,
-	ISEA_PLANE, ISEA_Q2DD, ISEA_PROJTRI, ISEA_VERTEX2DD, ISEA_HEX
-};
-
-struct isea_dgg {
-	int	polyhedron; /* ignored, icosahedron */
-	double	o_lat, o_lon, o_az; /* orientation, radians */
-	int	pole; /* true if standard snyder */
-	int	topology; /* ignored, hexagon */
-	int	aperture; /* valid values depend on partitioning method */
-	int	resolution;
-	double	radius; /* radius of the earth in meters, ignored 1.0 */
-	int	output; /* an isea_address_form */
-	int	triangle; /* triangle of last transformed point */
-	int	quad; /* quad of last transformed point */
-	unsigned long serial;
-};
-
-struct isea_pt {
-	double x, y;
-};
-
-struct isea_geo {
-	double lon, lat;
-};
-
-struct isea_address {
-	int	type; /* enum isea_address_form */
-	int	number;
-	double	x,y; /* or i,j or lon,lat depending on type */
-};
-
-/* ENDINC */
-
-enum snyder_polyhedron {
-	SNYDER_POLY_HEXAGON, SNYDER_POLY_PENTAGON,
-	SNYDER_POLY_TETRAHEDRON, SNYDER_POLY_CUBE,
-	SNYDER_POLY_OCTAHEDRON, SNYDER_POLY_DODECAHEDRON,
-	SNYDER_POLY_ICOSAHEDRON
-};
-
-struct snyder_constants {
-	double          g, G, theta, ea_w, ea_a, ea_b, g_w, g_a, g_b;
-};
-
-/* TODO put these in radians to avoid a later conversion */
-ISEA_STATIC
-struct snyder_constants constants[] = {
-	{23.80018260, 62.15458023, 60.0, 3.75, 1.033, 0.968, 5.09, 1.195, 1.0},
-	{20.07675127, 55.69063953, 54.0, 2.65, 1.030, 0.983, 3.59, 1.141, 1.027},
-	{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
-	{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
-	{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
-	{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
-	{37.37736814, 36.0, 30.0, 17.27, 1.163, 0.860, 13.14, 1.584, 1.0},
-};
-
-#define E 52.62263186
-#define F 10.81231696
-
-#define DEG60 1.04719755119659774614
-#define DEG120 2.09439510239319549229
-#define DEG72 1.25663706143591729537
-#define DEG90 1.57079632679489661922
-#define DEG144 2.51327412287183459075
-#define DEG36 0.62831853071795864768
-#define DEG108 1.88495559215387594306
-#define DEG180 M_PI
-/* sqrt(5)/M_PI */
-#define ISEA_SCALE 0.8301572857837594396028083
-
-/* 26.565051177 degrees */
-#define V_LAT 0.46364760899944494524
-
-#define RAD2DEG (180.0/M_PI)
-#define DEG2RAD (M_PI/180.0)
-
-ISEA_STATIC
-struct isea_geo vertex[] = {
-	{0.0, DEG90},
-	{DEG180, V_LAT},
-	{-DEG108, V_LAT},
-	{-DEG36, V_LAT},
-	{DEG36, V_LAT},
-	{DEG108, V_LAT},
-	{-DEG144, -V_LAT},
-	{-DEG72, -V_LAT},
-	{0.0, -V_LAT},
-	{DEG72, -V_LAT},
-	{DEG144, -V_LAT},
-	{0.0, -DEG90}
-};
-
-/* TODO make an isea_pt array of the vertices as well */
-
-static int      tri_v1[] = {0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 2, 3, 4, 5, 1, 11, 11, 11, 11, 11};
-
-/* 52.62263186 */
-#define E_RAD 0.91843818702186776133
-
-/* 10.81231696 */
-#define F_RAD 0.18871053072122403508
-
-/* triangle Centers */
-struct isea_geo icostriangles[] = {
-	{0.0, 0.0},
-	{-DEG144, E_RAD},
-	{-DEG72, E_RAD},
-	{0.0, E_RAD},
-	{DEG72, E_RAD},
-	{DEG144, E_RAD},
-	{-DEG144, F_RAD},
-	{-DEG72, F_RAD},
-	{0.0, F_RAD},
-	{DEG72, F_RAD},
-	{DEG144, F_RAD},
-	{-DEG108, -F_RAD},
-	{-DEG36, -F_RAD},
-	{DEG36, -F_RAD},
-	{DEG108, -F_RAD},
-	{DEG180, -F_RAD},
-	{-DEG108, -E_RAD},
-	{-DEG36, -E_RAD},
-	{DEG36, -E_RAD},
-	{DEG108, -E_RAD},
-	{DEG180, -E_RAD},
-};
-
-static double
-az_adjustment(int triangle)
-{
-	double          adj;
-
-	struct isea_geo v;
-	struct isea_geo c;
-
-	v = vertex[tri_v1[triangle]];
-	c = icostriangles[triangle];
-
-	/* TODO looks like the adjustment is always either 0 or 180 */
-	/* at least if you pick your vertex carefully */
-	adj = atan2(cos(v.lat) * sin(v.lon - c.lon),
-		    cos(c.lat) * sin(v.lat)
-		    - sin(c.lat) * cos(v.lat) * cos(v.lon - c.lon));
-	return adj;
-}
-
-/* R tan(g) sin(60) */
-#define TABLE_G 0.6615845383
-
-/* H = 0.25 R tan g = */
-#define TABLE_H 0.1909830056
-
-#define RPRIME 0.91038328153090290025
-
-ISEA_STATIC
-struct isea_pt
-isea_triangle_xy(int triangle)
-{
-	struct isea_pt  c;
-	double Rprime = 0.91038328153090290025;
-
-	triangle = (triangle - 1) % 20;
-
-	c.x = TABLE_G * ((triangle % 5) - 2) * 2.0;
-	if (triangle > 9) {
-		c.x += TABLE_G;
-	}
-	switch (triangle / 5) {
-	case 0:
-		c.y = 5.0 * TABLE_H;
-		break;
-	case 1:
-		c.y = TABLE_H;
-		break;
-	case 2:
-		c.y = -TABLE_H;
-		break;
-	case 3:
-		c.y = -5.0 * TABLE_H;
-		break;
-	default:
-		/* should be impossible */
-		exit(EXIT_FAILURE);
-	};
-	c.x *= Rprime;
-	c.y *= Rprime;
-
-	return c;
-}
-
-/* snyder eq 14 */
-static double
-sph_azimuth(double f_lon, double f_lat, double t_lon, double t_lat)
-{
-	double          az;
-
-	az = atan2(cos(t_lat) * sin(t_lon - f_lon),
-		   cos(f_lat) * sin(t_lat)
-		   - sin(f_lat) * cos(t_lat) * cos(t_lon - f_lon)
-		);
-	return az;
-}
-
-/* coord needs to be in radians */
-ISEA_STATIC
-int
-isea_snyder_forward(struct isea_geo * ll, struct isea_pt * out)
-{
-	int             i;
-
-	/*
-	 * spherical distance from center of polygon face to any of its
-	 * vertexes on the globe
-	 */
-	double          g;
-
-	/*
-	 * spherical angle between radius vector to center and adjacent edge
-	 * of spherical polygon on the globe
-	 */
-	double          G;
-
-	/*
-	 * plane angle between radius vector to center and adjacent edge of
-	 * plane polygon
-	 */
-	double          theta;
-
-	/* additional variables from snyder */
-	double          q, Rprime, H, Ag, Azprime, Az, dprime, f, rho,
-	                x, y;
-
-	/* variables used to store intermediate results */
-	double          cot_theta, tan_g, az_offset;
-
-	/* how many multiples of 60 degrees we adjust the azimuth */
-	int             Az_adjust_multiples;
-
-	struct snyder_constants c;
-
-	/*
-	 * TODO by locality of reference, start by trying the same triangle
-	 * as last time
-	 */
-
-	/* TODO put these constants in as radians to begin with */
-	c = constants[SNYDER_POLY_ICOSAHEDRON];
-	theta = c.theta * DEG2RAD;
-	g = c.g * DEG2RAD;
-	G = c.G * DEG2RAD;
-
-	for (i = 1; i <= 20; i++) {
-		double          z;
-		struct isea_geo center;
-
-		center = icostriangles[i];
-
-		/* step 1 */
-		z = acos(sin(center.lat) * sin(ll->lat)
-			 + cos(center.lat) * cos(ll->lat) * cos(ll->lon - center.lon));
-		/* not on this triangle */
-		if (z > g + 0.000005) { /* TODO DBL_EPSILON */
-			continue;
-		}
-
-		Az = sph_azimuth(center.lon, center.lat, ll->lon, ll->lat);
-
-		/* step 2 */
-
-		/* This calculates "some" vertex coordinate */
-		az_offset = az_adjustment(i);
-
-		Az -= az_offset;
-
-		/* TODO I don't know why we do this.  It's not in snyder */
-		/* maybe because we should have picked a better vertex */
-		if (Az < 0.0) {
-			Az += 2.0 * M_PI;
-		}
-		/*
-		 * adjust Az for the point to fall within the range of 0 to
-		 * 2(90 - theta) or 60 degrees for the hexagon, by
-		 * and therefore 120 degrees for the triangle
-		 * of the icosahedron
-		 * subtracting or adding multiples of 60 degrees to Az and
-		 * recording the amount of adjustment
-		 */
-
-		Az_adjust_multiples = 0;
-		while (Az < 0.0) {
-			Az += DEG120;
-			Az_adjust_multiples--;
-		}
-		while (Az > DEG120 + DBL_EPSILON) {
-			Az -= DEG120;
-			Az_adjust_multiples++;
-		}
-
-		/* step 3 */
-		cot_theta = 1.0 / tan(theta);
-		tan_g = tan(g);	/* TODO this is a constant */
-
-		/* Calculate q from eq 9. */
-		/* TODO cot_theta is cot(30) */
-		q = atan2(tan_g, cos(Az) + sin(Az) * cot_theta);
-
-		/* not in this triangle */
-		if (z > q + 0.000005) {
-			continue;
-		}
-		/* step 4 */
-
-		/* Apply equations 5-8 and 10-12 in order */
-
-		/* eq 5 */
-		/* Rprime = 0.9449322893 * R; */
-		/* R' in the paper is for the truncated */
-		Rprime = 0.91038328153090290025;
-
-		/* eq 6 */
-		H = acos(sin(Az) * sin(G) * cos(g) - cos(Az) * cos(G));
-
-		/* eq 7 */
-		/* Ag = (Az + G + H - DEG180) * M_PI * R * R / DEG180; */
-		Ag = Az + G + H - DEG180;
-
-		/* eq 8 */
-		Azprime = atan2(2.0 * Ag, Rprime * Rprime * tan_g * tan_g - 2.0 * Ag * cot_theta);
-
-		/* eq 10 */
-		/* cot(theta) = 1.73205080756887729355 */
-		dprime = Rprime * tan_g / (cos(Azprime) + sin(Azprime) * cot_theta);
-
-		/* eq 11 */
-		f = dprime / (2.0 * Rprime * sin(q / 2.0));
-
-		/* eq 12 */
-		rho = 2.0 * Rprime * f * sin(z / 2.0);
-
-		/*
-		 * add back the same 60 degree multiple adjustment from step
-		 * 2 to Azprime
-		 */
-
-		Azprime += DEG120 * Az_adjust_multiples;
-
-		/* calculate rectangular coordinates */
-
-		x = rho * sin(Azprime);
-		y = rho * cos(Azprime);
-
-		/*
-		 * TODO
-		 * translate coordinates to the origin for the particular
-		 * hexagon on the flattened polyhedral map plot
-		 */
-
-		out->x = x;
-		out->y = y;
-
-		return i;
-	}
-
-	/*
-	 * should be impossible, this implies that the coordinate is not on
-	 * any triangle
-	 */
-
-	fprintf(stderr, "impossible transform: %f %f is not on any triangle\n",
-		ll->lon * RAD2DEG, ll->lat * RAD2DEG);
-
-	exit(EXIT_FAILURE);
-
-	/* not reached */
-	return 0;		/* supresses a warning */
-}
-
-/*
- * return the new coordinates of any point in orginal coordinate system.
- * Define a point (newNPold) in orginal coordinate system as the North Pole in
- * new coordinate system, and the great circle connect the original and new
- * North Pole as the lon0 longitude in new coordinate system, given any point
- * in orginal coordinate system, this function return the new coordinates.
- */
-
-#define PRECISION 0.0000000000005
-
-/* formula from Snyder, Map Projections: A working manual, p31 */
-/*
- * old north pole at np in new coordinates
- * could be simplified a bit with fewer intermediates
- *
- * TODO take a result pointer
- */
-ISEA_STATIC
-struct isea_geo
-snyder_ctran(struct isea_geo * np, struct isea_geo * pt)
-{
-	struct isea_geo npt;
-	double          alpha, phi, lambda, lambda0, beta, lambdap, phip;
-	double          sin_phip;
-	double          lp_b;	/* lambda prime minus beta */
-	double          cos_p, sin_a;
-
-	phi = pt->lat;
-	lambda = pt->lon;
-	alpha = np->lat;
-	beta = np->lon;
-	lambda0 = beta;
-
-	cos_p = cos(phi);
-	sin_a = sin(alpha);
-
-	/* mpawm 5-7 */
-	sin_phip = sin_a * sin(phi) - cos(alpha) * cos_p * cos(lambda - lambda0);
-
-	/* mpawm 5-8b */
-
-	/* use the two argument form so we end up in the right quadrant */
-	lp_b = atan2(cos_p * sin(lambda - lambda0),
-	   (sin_a * cos_p * cos(lambda - lambda0) + cos(alpha) * sin(phi)));
-
-	lambdap = lp_b + beta;
-
-	/* normalize longitude */
-	/* TODO can we just do a modulus ? */
-	lambdap = fmod(lambdap, 2 * M_PI);
-	while (lambdap > M_PI)
-		lambdap -= 2 * M_PI;
-	while (lambdap < -M_PI)
-		lambdap += 2 * M_PI;
-
-	phip = asin(sin_phip);
-
-	npt.lat = phip;
-	npt.lon = lambdap;
-
-	return npt;
-}
-
-ISEA_STATIC
-struct isea_geo
-isea_ctran(struct isea_geo * np, struct isea_geo * pt, double lon0)
-{
-	struct isea_geo npt;
-
-	np->lon += M_PI;
-	npt = snyder_ctran(np, pt);
-	np->lon -= M_PI;
-
-	npt.lon -= (M_PI - lon0 + np->lon);
-
-	/*
-	 * snyder is down tri 3, isea is along side of tri1 from vertex 0 to
-	 * vertex 1 these are 180 degrees apart
-	 */
-	npt.lon += M_PI;
-	/* normalize longitude */
-	npt.lon = fmod(npt.lon, 2 * M_PI);
-	while (npt.lon > M_PI)
-		npt.lon -= 2 * M_PI;
-	while (npt.lon < -M_PI)
-		npt.lon += 2 * M_PI;
-
-	return npt;
-}
-
-/* in radians */
-#define ISEA_STD_LAT 1.01722196792335072101
-#define ISEA_STD_LON .19634954084936207740
-
-/* fuller's at 5.2454 west, 2.3009 N, adjacent at 7.46658 deg */
-
-ISEA_STATIC
-int
-isea_grid_init(struct isea_dgg * g)
-{
-	if (!g)
-		return 0;
-
-	g->polyhedron = 20;
-	g->o_lat = ISEA_STD_LAT;
-	g->o_lon = ISEA_STD_LON;
-	g->o_az = 0.0;
-	g->aperture = 4;
-	g->resolution = 6;
-	g->radius = 1.0;
-	g->topology = 6;
-
-	return 1;
-}
-
-ISEA_STATIC
-int
-isea_orient_isea(struct isea_dgg * g)
-{
-	if (!g)
-		return 0;
-	g->o_lat = ISEA_STD_LAT;
-	g->o_lon = ISEA_STD_LON;
-	g->o_az = 0.0;
-	return 1;
-}
-
-ISEA_STATIC
-int
-isea_orient_pole(struct isea_dgg * g)
-{
-	if (!g)
-		return 0;
-	g->o_lat = M_PI / 2.0;
-	g->o_lon = 0.0;
-	g->o_az = 0;
-	return 1;
-}
-
-ISEA_STATIC
-int
-isea_transform(struct isea_dgg * g, struct isea_geo * in,
-	       struct isea_pt * out)
-{
-	struct isea_geo i, pole;
-	int             tri;
-
-	pole.lat = g->o_lat;
-	pole.lon = g->o_lon;
-
-	i = isea_ctran(&pole, in, g->o_az);
-
-	tri = isea_snyder_forward(&i, out);
-	out->x *= g->radius;
-	out->y *= g->radius;
-	g->triangle = tri;
-
-	return tri;
-}
-
-#define DOWNTRI(tri) (((tri - 1) / 5) % 2 == 1)
-
-ISEA_STATIC
-void
-isea_rotate(struct isea_pt * pt, double degrees)
-{
-	double          rad;
-
-	double          x, y;
-
-	rad = -degrees * M_PI / 180.0;
-	while (rad >= 2.0 * M_PI) rad -= 2.0 * M_PI;
-	while (rad <= -2.0 * M_PI) rad += 2.0 * M_PI;
-
-	x = pt->x * cos(rad) + pt->y * sin(rad);
-	y = -pt->x * sin(rad) + pt->y * cos(rad);
-
-	pt->x = x;
-	pt->y = y;
-}
-
-ISEA_STATIC
-int isea_tri_plane(int tri, struct isea_pt *pt, double radius) {
-	struct isea_pt tc; /* center of triangle */
-
-	if (DOWNTRI(tri)) {
-		isea_rotate(pt, 180.0);
-	}
-	tc = isea_triangle_xy(tri);
-	tc.x *= radius;
-	tc.y *= radius;
-	pt->x += tc.x;
-	pt->y += tc.y;
-
-	return tri;
-}
-
-/* convert projected triangle coords to quad xy coords, return quad number */
-ISEA_STATIC
-int
-isea_ptdd(int tri, struct isea_pt *pt) {
-	int             downtri, quad;
-
-	downtri = (((tri - 1) / 5) % 2 == 1);
-	quad = ((tri - 1) % 5) + ((tri - 1) / 10) * 5 + 1;
-
-	isea_rotate(pt, downtri ? 240.0 : 60.0);
-	if (downtri) {
-		pt->x += 0.5;
-		/* pt->y += cos(30.0 * M_PI / 180.0); */
-		pt->y += .86602540378443864672;
-	}
-	return quad;
-}
-
-ISEA_STATIC
-int
-isea_dddi_ap3odd(struct isea_dgg *g, int quad, struct isea_pt *pt, struct isea_pt *di)
-{
-	struct isea_pt  v;
-	double          hexwidth;
-	double          sidelength;	/* in hexes */
-	int             d, i;
-	int             maxcoord;
-	struct hex      h;
-
-	/* This is the number of hexes from apex to base of a triangle */
-	sidelength = (pow(2.0, g->resolution) + 1.0) / 2.0;
-
-	/* apex to base is cos(30deg) */
-	hexwidth = cos(M_PI / 6.0) / sidelength;
-
-	/* TODO I think sidelength is always x.5, so
-	 * (int)sidelength * 2 + 1 might be just as good
-	 */
-	maxcoord = (int) (sidelength * 2.0 + 0.5);
-
-	v = *pt;
-	hexbin2(hexwidth, v.x, v.y, &h.x, &h.y);
-	h.iso = 0;
-	hex_iso(&h);
-
-	d = h.x - h.z;
-	i = h.x + h.y + h.y;
-	
-	/*
-	 * you want to test for max coords for the next quad in the same
-	 * "row" first to get the case where both are max
-	 */
-	if (quad <= 5) {
-		if (d == 0 && i == maxcoord) {
-			/* north pole */
-			quad = 0;
-			d = 0;
-			i = 0;
-		} else if (i == maxcoord) {
-			/* upper right in next quad */
-			quad += 1;
-			if (quad == 6)
-				quad = 1;
-			i = maxcoord - d;
-			d = 0;
-		} else if (d == maxcoord) {
-			/* lower right in quad to lower right */
-			quad += 5;
-			d = 0;
-		}
-	} else if (quad >= 6) {
-		if (i == 0 && d == maxcoord) {
-			/* south pole */
-			quad = 11;
-			d = 0;
-			i = 0;
-		} else if (d == maxcoord) {
-			/* lower right in next quad */
-			quad += 1;
-			if (quad == 11)
-				quad = 6;
-			d = maxcoord - i;
-			i = 0;
-		} else if (i == maxcoord) {
-			/* upper right in quad to upper right */
-			quad = (quad - 4) % 5;
-			i = 0;
-		}
-	}
-
-	di->x = d;
-	di->y = i;
-
-	g->quad = quad;
-	return quad;
-}
-
-ISEA_STATIC
-int
-isea_dddi(struct isea_dgg *g, int quad, struct isea_pt *pt, struct isea_pt *di) {
-	struct isea_pt  v;
-	double          hexwidth;
-	int             sidelength;	/* in hexes */
-	struct hex      h;
-
-	if (g->aperture == 3 && g->resolution % 2 != 0) {
-		return isea_dddi_ap3odd(g, quad, pt, di);
-	}
-	/* todo might want to do this as an iterated loop */
-	if (g->aperture >0) {
-		sidelength = (int) (pow(g->aperture, g->resolution / 2.0) + 0.5);
-	} else {
-		sidelength = g->resolution;
-	}
-
-	hexwidth = 1.0 / sidelength;
-
-	v = *pt;
-	isea_rotate(&v, -30.0);
-	hexbin2(hexwidth, v.x, v.y, &h.x, &h.y);
-	h.iso = 0;
-	hex_iso(&h);
-
-	/* we may actually be on another quad */
-	if (quad <= 5) {
-		if (h.x == 0 && h.z == -sidelength) {
-			/* north pole */
-			quad = 0;
-			h.z = 0;
-			h.y = 0;
-			h.x = 0;
-		} else if (h.z == -sidelength) {
-			quad = quad + 1;
-			if (quad == 6)
-				quad = 1;
-			h.y = sidelength - h.x;
-			h.z = h.x - sidelength;
-			h.x = 0;
-		} else if (h.x == sidelength) {
-			quad += 5;
-			h.y = -h.z;
-			h.x = 0;
-		}
-	} else if (quad >= 6) {
-		if (h.z == 0 && h.x == sidelength) {
-			/* south pole */
-			quad = 11;
-			h.x = 0;
-			h.y = 0;
-			h.z = 0;
-		} else if (h.x == sidelength) {
-			quad = quad + 1;
-			if (quad == 11)
-				quad = 6;
-			h.x = h.y + sidelength;
-			h.y = 0;
-			h.z = -h.x;
-		} else if (h.y == -sidelength) {
-			quad -= 4;
-			h.y = 0;
-			h.z = -h.x;
-		}
-	}
-	di->x = h.x;
-	di->y = -h.z;
-
-	g->quad = quad;
-	return quad;
-}
-
-ISEA_STATIC
-int isea_ptdi(struct isea_dgg *g, int tri, struct isea_pt *pt,
-	       	struct isea_pt *di) {
-	struct isea_pt  v;
-	int             quad;
-
-	v = *pt;
-	quad = isea_ptdd(tri, &v);
-	quad = isea_dddi(g, quad, &v, di);
-	return quad;
-}
-
-/* q2di to seqnum */
-ISEA_STATIC
-int isea_disn(struct isea_dgg *g, int quad, struct isea_pt *di) {
-	int             sidelength;
-	int             sn, height;
-	int             hexes;
-
-	if (quad == 0) {
-		g->serial = 1;
-		return g->serial;
-	}
-	/* hexes in a quad */
-	hexes = (int) (pow(g->aperture, g->resolution) + 0.5);
-	if (quad == 11) {
-		g->serial = 1 + 10 * hexes + 1;
-		return g->serial;
-	}
-	if (g->aperture == 3 && g->resolution % 2 == 1) {
-		height = (int) (pow(g->aperture, (g->resolution - 1) / 2.0));
-		sn = ((int) di->x) * height;
-		sn += ((int) di->y) / height;
-		sn += (quad - 1) * hexes;
-		sn += 2;
-	} else {
-		sidelength = (int) (pow(g->aperture, g->resolution / 2.0) + 0.5);
-		sn = (quad - 1) * hexes + sidelength * di->x + di->y + 2;
-	}
-
-	g->serial = sn;
-	return sn;
-}
-
-/* TODO just encode the quad in the d or i coordinate
- * quad is 0-11, which can be four bits.
- * d' = d << 4 + q, d = d' >> 4, q = d' & 0xf
- */
-/* convert a q2di to global hex coord */
-ISEA_STATIC
-int isea_hex(struct isea_dgg *g, int tri,
-		struct isea_pt *pt, struct isea_pt *hex) {
-	struct isea_pt v;
-	int sidelength;
-	int d, i, x, y, quad;
-
-	quad = isea_ptdi(g, tri, pt, &v);
-
-	hex->x = ((int)v.x << 4) + quad;
-	hex->y = v.y;
-
-	return 1;
-
-	d = v.x;
-	i = v.y;
-
-	/* Aperture 3 odd resolutions */
-	if (g->aperture == 3 && g->resolution % 2 != 0) {
-		int offset = (int)(pow(3.0, g->resolution - 1) + 0.5);
-
-		d += offset * ((g->quad-1) % 5);
-		i += offset * ((g->quad-1) % 5);
-
-		if (quad == 0) {
-			d = 0;
-			i = offset;
-		} else if (quad == 11) {
-			d = 2 * offset;
-			i = 0;
-		} else if (quad > 5) {
-			d += offset;
-		}
-
-		x = (2*d - i) /3;
-		y = (2*i - d) /3;
-
-		hex->x = x + offset / 3;
-		hex->y = y + 2 * offset / 3;
-		return 1;
-	}
-
-	/* aperture 3 even resolutions and aperture 4 */
-	sidelength = (int) (pow(g->aperture, g->resolution / 2.0) + 0.5);
-	if (g->quad == 0) {
-		hex->x = 0;
-		hex->y = sidelength;
-	} else if (g->quad == 11) {
-		hex->x = sidelength * 2;
-		hex->y = 0;
-	} else {
-		hex->x = d + sidelength * ((g->quad-1) % 5);
-		if (g->quad > 5) hex->x += sidelength;
-		hex->y = i + sidelength * ((g->quad-1) % 5);
-	}
-
-	return 1;
-}
-
-ISEA_STATIC
-struct isea_pt
-isea_forward(struct isea_dgg *g, struct isea_geo *in)
-{
-	int             tri;
-	struct isea_pt  out, coord;
-
-	tri = isea_transform(g, in, &out);
-
-	if (g->output == ISEA_PLANE) {
-		isea_tri_plane(tri, &out, g->radius);
-		return out;
-	}
-
-	/* convert to isea standard triangle size */
-	out.x = out.x / g->radius * ISEA_SCALE;
-	out.y = out.y / g->radius * ISEA_SCALE;
-	out.x += 0.5;
-	out.y += 2.0 * .14433756729740644112;
-
-	switch (g->output) {
-	case ISEA_PROJTRI:
-		/* nothing to do, already in projected triangle */
-		break;
-	case ISEA_VERTEX2DD:
-		g->quad = isea_ptdd(tri, &out);
-		break;
-	case ISEA_Q2DD:
-		/* Same as above, we just don't print as much */
-		g->quad = isea_ptdd(tri, &out);
-		break;
-	case ISEA_Q2DI:
-		g->quad = isea_ptdi(g, tri, &out, &coord);
-		return coord;
-		break;
-	case ISEA_SEQNUM:
-		isea_ptdi(g, tri, &out, &coord);
-		/* disn will set g->serial */
-		isea_disn(g, g->quad, &coord);
-		return coord;
-		break;
-	case ISEA_HEX:
-		isea_hex(g, tri, &out, &coord);
-		return coord;
-		break;
-	}
-
-	return out;
-}
-/*
- * Proj 4 integration code follows
- */
-
-#define PROJ_PARMS__ \
-	struct isea_dgg dgg;
-
-#define PJ_LIB__
-#include <projects.h>
-
-PROJ_HEAD(isea, "Icosahedral Snyder Equal Area") "\n\tSph";
-
-FORWARD(s_forward);
-	struct isea_pt out;
-	struct isea_geo in;
-
-	in.lon = lp.lam;
-	in.lat = lp.phi;
-
-	out = isea_forward(&P->dgg, &in);
-	
-	xy.x = out.x;
-	xy.y = out.y;
-
-	return xy;
-}
-FREEUP; if (P) pj_dalloc(P); }
-
-ENTRY0(isea)
-	char *opt;
-
-        P->fwd = s_forward;
-        isea_grid_init(&P->dgg);
-
-        P->dgg.output = ISEA_PLANE;
-/*		P->dgg.radius = P->a; / * otherwise defaults to 1 */
-	/* calling library will scale, I think */
-
-	opt = pj_param(P->ctx,P->params, "sorient").s;
-	if (opt) {
-		if (!strcmp(opt, "isea")) {
-			isea_orient_isea(&P->dgg);
-		} else if (!strcmp(opt, "pole")) {
-			isea_orient_pole(&P->dgg);
-		} else {
-			E_ERROR(-34);
-		}
-	}
-
-	if (pj_param(P->ctx,P->params, "tazi").i) {
-		P->dgg.o_az = pj_param(P->ctx,P->params, "razi").f;
-	}
-
-	if (pj_param(P->ctx,P->params, "tlon_0").i) {
-		P->dgg.o_lon = pj_param(P->ctx,P->params, "rlon_0").f;
-	}
-
-	if (pj_param(P->ctx,P->params, "tlat_0").i) {
-		P->dgg.o_lat = pj_param(P->ctx,P->params, "rlat_0").f;
-	}
-
-	if (pj_param(P->ctx,P->params, "taperture").i) {
-		P->dgg.aperture = pj_param(P->ctx,P->params, "iaperture").i;
-	}
-
-	if (pj_param(P->ctx,P->params, "tresolution").i) {
-		P->dgg.resolution = pj_param(P->ctx,P->params, "iresolution").i;
-	}
-
-	opt = pj_param(P->ctx,P->params, "smode").s;
-	if (opt) {
-		if (!strcmp(opt, "plane")) {
-			P->dgg.output = ISEA_PLANE;
-		} else if (!strcmp(opt, "di")) {
-			P->dgg.output = ISEA_Q2DI;
-		}
-		else if (!strcmp(opt, "dd")) {
-			P->dgg.output = ISEA_Q2DD;
-		}
-		else if (!strcmp(opt, "hex")) {
-			P->dgg.output = ISEA_HEX;
-		}
-		else {
-			/* TODO verify error code.  Possibly eliminate magic */
-			E_ERROR(-34);
-		}
-	}
-
-	if (pj_param(P->ctx,P->params, "trescale").i) {
-		P->dgg.radius = ISEA_SCALE;
-	}
-
-	if (pj_param(P->ctx,P->params, "tresolution").i) {
-		P->dgg.resolution = pj_param(P->ctx,P->params, "iresolution").i;
-	} else {
-		P->dgg.resolution = 4;
-	}
-
-	if (pj_param(P->ctx,P->params, "taperture").i) {
-		P->dgg.aperture = pj_param(P->ctx,P->params, "iaperture").i;
-	} else {
-		P->dgg.aperture = 3;
-	}
-
-ENDENTRY(P)
+/*
+ * This code was entirely written by Nathan Wagner
+ * and is in the public domain.
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <float.h>
+
+#ifndef M_PI
+#  define M_PI 3.14159265358979323846
+#endif
+
+/*
+ * Proj 4 provides its own entry points into
+ * the code, so none of the library functions
+ * need to be global
+ */
+#define ISEA_STATIC static
+#ifndef ISEA_STATIC
+#define ISEA_STATIC
+#endif
+
+struct hex {
+        int iso;
+        int x, y, z;
+};
+
+/* y *must* be positive down as the xy /iso conversion assumes this */
+ISEA_STATIC
+int hex_xy(struct hex *h) {
+    if (!h->iso) return 1;
+    if (h->x >= 0) {
+        h->y = -h->y - (h->x+1)/2;
+    } else {
+        /* need to round toward -inf, not toward zero, so x-1 */
+        h->y = -h->y - h->x/2;
+    }
+    h->iso = 0;
+
+    return 1;
+}
+
+ISEA_STATIC
+int hex_iso(struct hex *h) {
+    if (h->iso) return 1;
+
+    if (h->x >= 0) {
+        h->y = (-h->y - (h->x+1)/2);
+    } else {
+        /* need to round toward -inf, not toward zero, so x-1 */
+        h->y = (-h->y - (h->x)/2);
+    }
+
+    h->z = -h->x - h->y;
+    h->iso = 1;
+    return 1;
+}
+
+ISEA_STATIC
+int hexbin2(double width, double x, double y,
+                int *i, int *j) {
+    double z, rx, ry, rz;
+    double abs_dx, abs_dy, abs_dz;
+    int ix, iy, iz, s;
+    struct hex h;
+
+    x = x / cos(30 * M_PI / 180.0); /* rotated X coord */
+    y = y - x / 2.0; /* adjustment for rotated X */
+
+    /* adjust for actual hexwidth */
+    x /= width;
+    y /= width;
+
+    z = -x - y;
+
+    ix = rx = floor(x + 0.5);
+    iy = ry = floor(y + 0.5);
+    iz = rz = floor(z + 0.5);
+
+    s = ix + iy + iz;
+
+    if (s) {
+        abs_dx = fabs(rx - x);
+        abs_dy = fabs(ry - y);
+        abs_dz = fabs(rz - z);
+
+        if (abs_dx >= abs_dy && abs_dx >= abs_dz) {
+            ix -= s;
+        } else if (abs_dy >= abs_dx && abs_dy >= abs_dz) {
+            iy -= s;
+        } else {
+            iz -= s;
+        }
+    }
+    h.x = ix;
+    h.y = iy;
+    h.z = iz;
+    h.iso = 1;
+
+    hex_xy(&h);
+    *i = h.x;
+    *j = h.y;
+        return ix * 100 + iy;
+}
+#ifndef ISEA_STATIC
+#define ISEA_STATIC
+#endif
+
+enum isea_poly { ISEA_NONE, ISEA_ICOSAHEDRON = 20 };
+enum isea_topology { ISEA_HEXAGON=6, ISEA_TRIANGLE=3, ISEA_DIAMOND=4 };
+enum isea_address_form { ISEA_GEO, ISEA_Q2DI, ISEA_SEQNUM, ISEA_INTERLEAVE,
+    ISEA_PLANE, ISEA_Q2DD, ISEA_PROJTRI, ISEA_VERTEX2DD, ISEA_HEX
+};
+
+struct isea_dgg {
+    int polyhedron; /* ignored, icosahedron */
+    double  o_lat, o_lon, o_az; /* orientation, radians */
+    int pole; /* true if standard snyder */
+    int topology; /* ignored, hexagon */
+    int aperture; /* valid values depend on partitioning method */
+    int resolution;
+    double  radius; /* radius of the earth in meters, ignored 1.0 */
+    int output; /* an isea_address_form */
+    int triangle; /* triangle of last transformed point */
+    int quad; /* quad of last transformed point */
+    unsigned long serial;
+};

+
+struct isea_pt {
+    double x, y;
+};
+
+struct isea_geo {
+    double lon, lat;
+};
+
+struct isea_address {
+    int type; /* enum isea_address_form */
+    int number;
+    double  x,y; /* or i,j or lon,lat depending on type */
+};
+
+/* ENDINC */
+
+enum snyder_polyhedron {
+    SNYDER_POLY_HEXAGON, SNYDER_POLY_PENTAGON,
+    SNYDER_POLY_TETRAHEDRON, SNYDER_POLY_CUBE,
+    SNYDER_POLY_OCTAHEDRON, SNYDER_POLY_DODECAHEDRON,
+    SNYDER_POLY_ICOSAHEDRON
+};
+
+struct snyder_constants {
+    double          g, G, theta, ea_w, ea_a, ea_b, g_w, g_a, g_b;
+};
+
+/* TODO put these in radians to avoid a later conversion */
+ISEA_STATIC
+struct snyder_constants constants[] = {
+    {23.80018260, 62.15458023, 60.0, 3.75, 1.033, 0.968, 5.09, 1.195, 1.0},
+    {20.07675127, 55.69063953, 54.0, 2.65, 1.030, 0.983, 3.59, 1.141, 1.027},
+    {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+    {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+    {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+    {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+    {37.37736814, 36.0, 30.0, 17.27, 1.163, 0.860, 13.14, 1.584, 1.0},
+};
+
+#define E 52.62263186
+#define F 10.81231696
+
+#define DEG60 1.04719755119659774614
+#define DEG120 2.09439510239319549229
+#define DEG72 1.25663706143591729537
+#define DEG90 1.57079632679489661922
+#define DEG144 2.51327412287183459075
+#define DEG36 0.62831853071795864768
+#define DEG108 1.88495559215387594306
+#define DEG180 M_PI
+/* sqrt(5)/M_PI */
+#define ISEA_SCALE 0.8301572857837594396028083
+
+/* 26.565051177 degrees */
+#define V_LAT 0.46364760899944494524
+
+#define RAD2DEG (180.0/M_PI)
+#define DEG2RAD (M_PI/180.0)
+
+ISEA_STATIC
+struct isea_geo vertex[] = {
+    {0.0, DEG90},
+    {DEG180, V_LAT},
+    {-DEG108, V_LAT},
+    {-DEG36, V_LAT},
+    {DEG36, V_LAT},
+    {DEG108, V_LAT},
+    {-DEG144, -V_LAT},
+    {-DEG72, -V_LAT},
+    {0.0, -V_LAT},
+    {DEG72, -V_LAT},
+    {DEG144, -V_LAT},
+    {0.0, -DEG90}
+};
+
+/* TODO make an isea_pt array of the vertices as well */
+
+static int      tri_v1[] = {0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 2, 3, 4, 5, 1, 11, 11, 11, 11, 11};
+
+/* 52.62263186 */
+#define E_RAD 0.91843818702186776133
+
+/* 10.81231696 */
+#define F_RAD 0.18871053072122403508
+
+/* triangle Centers */
+struct isea_geo icostriangles[] = {
+    {0.0, 0.0},
+    {-DEG144, E_RAD},
+    {-DEG72, E_RAD},
+    {0.0, E_RAD},
+    {DEG72, E_RAD},
+    {DEG144, E_RAD},
+    {-DEG144, F_RAD},
+    {-DEG72, F_RAD},
+    {0.0, F_RAD},
+    {DEG72, F_RAD},
+    {DEG144, F_RAD},
+    {-DEG108, -F_RAD},
+    {-DEG36, -F_RAD},
+    {DEG36, -F_RAD},
+    {DEG108, -F_RAD},
+    {DEG180, -F_RAD},
+    {-DEG108, -E_RAD},
+    {-DEG36, -E_RAD},
+    {DEG36, -E_RAD},
+    {DEG108, -E_RAD},
+    {DEG180, -E_RAD},
+};
+
+static double
+az_adjustment(int triangle)
+{
+    double          adj;
+
+    struct isea_geo v;
+    struct isea_geo c;
+
+    v = vertex[tri_v1[triangle]];
+    c = icostriangles[triangle];
+
+    /* TODO looks like the adjustment is always either 0 or 180 */
+    /* at least if you pick your vertex carefully */
+    adj = atan2(cos(v.lat) * sin(v.lon - c.lon),
+            cos(c.lat) * sin(v.lat)
+            - sin(c.lat) * cos(v.lat) * cos(v.lon - c.lon));
+    return adj;
+}
+
+/* R tan(g) sin(60) */
+#define TABLE_G 0.6615845383
+
+/* H = 0.25 R tan g = */
+#define TABLE_H 0.1909830056
+
+#define RPRIME 0.91038328153090290025
+
+ISEA_STATIC
+struct isea_pt
+isea_triangle_xy(int triangle)
+{
+    struct isea_pt  c;
+    double Rprime = 0.91038328153090290025;
+
+    triangle = (triangle - 1) % 20;
+
+    c.x = TABLE_G * ((triangle % 5) - 2) * 2.0;
+    if (triangle > 9) {
+        c.x += TABLE_G;
+    }
+    switch (triangle / 5) {
+    case 0:
+        c.y = 5.0 * TABLE_H;
+        break;
+    case 1:
+        c.y = TABLE_H;
+        break;
+    case 2:
+        c.y = -TABLE_H;
+        break;
+    case 3:
+        c.y = -5.0 * TABLE_H;
+        break;
+    default:
+        /* should be impossible */
+        exit(EXIT_FAILURE);
+    };
+    c.x *= Rprime;
+    c.y *= Rprime;
+
+    return c;
+}
+
+/* snyder eq 14 */
+static double
+sph_azimuth(double f_lon, double f_lat, double t_lon, double t_lat)
+{
+    double          az;
+
+    az = atan2(cos(t_lat) * sin(t_lon - f_lon),
+           cos(f_lat) * sin(t_lat)
+           - sin(f_lat) * cos(t_lat) * cos(t_lon - f_lon)
+        );
+    return az;
+}
+
+/* coord needs to be in radians */
+ISEA_STATIC
+int
+isea_snyder_forward(struct isea_geo * ll, struct isea_pt * out)
+{
+    int             i;
+
+    /*
+     * spherical distance from center of polygon face to any of its
+     * vertexes on the globe
+     */
+    double          g;
+
+    /*
+     * spherical angle between radius vector to center and adjacent edge
+     * of spherical polygon on the globe
+     */
+    double          G;
+
+    /*
+     * plane angle between radius vector to center and adjacent edge of
+     * plane polygon
+     */
+    double          theta;
+
+    /* additional variables from snyder */
+    double          q, Rprime, H, Ag, Azprime, Az, dprime, f, rho,
+                    x, y;
+
+    /* variables used to store intermediate results */
+    double          cot_theta, tan_g, az_offset;
+
+    /* how many multiples of 60 degrees we adjust the azimuth */
+    int             Az_adjust_multiples;
+
+    struct snyder_constants c;
+
+    /*
+     * TODO by locality of reference, start by trying the same triangle
+     * as last time
+     */
+
+    /* TODO put these constants in as radians to begin with */
+    c = constants[SNYDER_POLY_ICOSAHEDRON];
+    theta = c.theta * DEG2RAD;
+    g = c.g * DEG2RAD;
+    G = c.G * DEG2RAD;
+
+    for (i = 1; i <= 20; i++) {
+        double          z;
+        struct isea_geo center;
+
+        center = icostriangles[i];
+
+        /* step 1 */
+        z = acos(sin(center.lat) * sin(ll->lat)
+             + cos(center.lat) * cos(ll->lat) * cos(ll->lon - center.lon));
+        /* not on this triangle */
+        if (z > g + 0.000005) { /* TODO DBL_EPSILON */
+            continue;
+        }
+
+        Az = sph_azimuth(center.lon, center.lat, ll->lon, ll->lat);
+
+        /* step 2 */
+
+        /* This calculates "some" vertex coordinate */
+        az_offset = az_adjustment(i);
+
+        Az -= az_offset;
+
+        /* TODO I don't know why we do this.  It's not in snyder */
+        /* maybe because we should have picked a better vertex */
+        if (Az < 0.0) {
+            Az += 2.0 * M_PI;
+        }
+        /*
+         * adjust Az for the point to fall within the range of 0 to
+         * 2(90 - theta) or 60 degrees for the hexagon, by
+         * and therefore 120 degrees for the triangle
+         * of the icosahedron
+         * subtracting or adding multiples of 60 degrees to Az and
+         * recording the amount of adjustment
+         */
+
+        Az_adjust_multiples = 0;
+        while (Az < 0.0) {
+            Az += DEG120;
+            Az_adjust_multiples--;
+        }
+        while (Az > DEG120 + DBL_EPSILON) {
+            Az -= DEG120;
+            Az_adjust_multiples++;
+        }
+
+        /* step 3 */
+        cot_theta = 1.0 / tan(theta);
+        tan_g = tan(g); /* TODO this is a constant */
+
+        /* Calculate q from eq 9. */
+        /* TODO cot_theta is cot(30) */
+        q = atan2(tan_g, cos(Az) + sin(Az) * cot_theta);
+
+        /* not in this triangle */
+        if (z > q + 0.000005) {
+            continue;
+        }
+        /* step 4 */
+
+        /* Apply equations 5-8 and 10-12 in order */
+
+        /* eq 5 */
+        /* Rprime = 0.9449322893 * R; */
+        /* R' in the paper is for the truncated */
+        Rprime = 0.91038328153090290025;
+
+        /* eq 6 */
+        H = acos(sin(Az) * sin(G) * cos(g) - cos(Az) * cos(G));
+
+        /* eq 7 */
+        /* Ag = (Az + G + H - DEG180) * M_PI * R * R / DEG180; */
+        Ag = Az + G + H - DEG180;
+
+        /* eq 8 */
+        Azprime = atan2(2.0 * Ag, Rprime * Rprime * tan_g * tan_g - 2.0 * Ag * cot_theta);
+
+        /* eq 10 */
+        /* cot(theta) = 1.73205080756887729355 */
+        dprime = Rprime * tan_g / (cos(Azprime) + sin(Azprime) * cot_theta);
+
+        /* eq 11 */
+        f = dprime / (2.0 * Rprime * sin(q / 2.0));
+
+        /* eq 12 */
+        rho = 2.0 * Rprime * f * sin(z / 2.0);
+
+        /*
+         * add back the same 60 degree multiple adjustment from step
+         * 2 to Azprime
+         */
+
+        Azprime += DEG120 * Az_adjust_multiples;
+
+        /* calculate rectangular coordinates */
+
+        x = rho * sin(Azprime);
+        y = rho * cos(Azprime);
+
+        /*
+         * TODO
+         * translate coordinates to the origin for the particular
+         * hexagon on the flattened polyhedral map plot
+         */
+
+        out->x = x;
+        out->y = y;
+
+        return i;
+    }
+
+    /*
+     * should be impossible, this implies that the coordinate is not on
+     * any triangle
+     */
+
+    fprintf(stderr, "impossible transform: %f %f is not on any triangle\n",
+        ll->lon * RAD2DEG, ll->lat * RAD2DEG);
+
+    exit(EXIT_FAILURE);
+
+    /* not reached */
+    return 0;       /* supresses a warning */
+}
+
+/*
+ * return the new coordinates of any point in orginal coordinate system.
+ * Define a point (newNPold) in orginal coordinate system as the North Pole in
+ * new coordinate system, and the great circle connect the original and new
+ * North Pole as the lon0 longitude in new coordinate system, given any point
+ * in orginal coordinate system, this function return the new coordinates.
+ */
+
+#define PRECISION 0.0000000000005
+
+/* formula from Snyder, Map Projections: A working manual, p31 */
+/*
+ * old north pole at np in new coordinates
+ * could be simplified a bit with fewer intermediates
+ *
+ * TODO take a result pointer
+ */
+ISEA_STATIC
+struct isea_geo
+snyder_ctran(struct isea_geo * np, struct isea_geo * pt)
+{
+    struct isea_geo npt;
+    double          alpha, phi, lambda, lambda0, beta, lambdap, phip;
+    double          sin_phip;
+    double          lp_b;   /* lambda prime minus beta */
+    double          cos_p, sin_a;
+
+    phi = pt->lat;
+    lambda = pt->lon;
+    alpha = np->lat;
+    beta = np->lon;
+    lambda0 = beta;
+
+    cos_p = cos(phi);
+    sin_a = sin(alpha);
+
+    /* mpawm 5-7 */
+    sin_phip = sin_a * sin(phi) - cos(alpha) * cos_p * cos(lambda - lambda0);
+
+    /* mpawm 5-8b */
+
+    /* use the two argument form so we end up in the right quadrant */
+    lp_b = atan2(cos_p * sin(lambda - lambda0),
+       (sin_a * cos_p * cos(lambda - lambda0) + cos(alpha) * sin(phi)));
+
+    lambdap = lp_b + beta;
+
+    /* normalize longitude */
+    /* TODO can we just do a modulus ? */
+    lambdap = fmod(lambdap, 2 * M_PI);
+    while (lambdap > M_PI)
+        lambdap -= 2 * M_PI;
+    while (lambdap < -M_PI)
+        lambdap += 2 * M_PI;
+
+    phip = asin(sin_phip);
+
+    npt.lat = phip;
+    npt.lon = lambdap;
+
+    return npt;
+}
+
+ISEA_STATIC
+struct isea_geo
+isea_ctran(struct isea_geo * np, struct isea_geo * pt, double lon0)
+{
+    struct isea_geo npt;
+
+    np->lon += M_PI;
+    npt = snyder_ctran(np, pt);
+    np->lon -= M_PI;
+
+    npt.lon -= (M_PI - lon0 + np->lon);
+
+    /*
+     * snyder is down tri 3, isea is along side of tri1 from vertex 0 to
+     * vertex 1 these are 180 degrees apart
+     */
+    npt.lon += M_PI;
+    /* normalize longitude */
+    npt.lon = fmod(npt.lon, 2 * M_PI);
+    while (npt.lon > M_PI)
+        npt.lon -= 2 * M_PI;
+    while (npt.lon < -M_PI)
+        npt.lon += 2 * M_PI;
+
+    return npt;
+}
+
+/* in radians */
+#define ISEA_STD_LAT 1.01722196792335072101
+#define ISEA_STD_LON .19634954084936207740
+
+/* fuller's at 5.2454 west, 2.3009 N, adjacent at 7.46658 deg */
+
+ISEA_STATIC
+int
+isea_grid_init(struct isea_dgg * g)
+{
+    if (!g)
+        return 0;
+
+    g->polyhedron = 20;
+    g->o_lat = ISEA_STD_LAT;
+    g->o_lon = ISEA_STD_LON;
+    g->o_az = 0.0;
+    g->aperture = 4;
+    g->resolution = 6;
+    g->radius = 1.0;
+    g->topology = 6;
+
+    return 1;
+}
+
+ISEA_STATIC
+int
+isea_orient_isea(struct isea_dgg * g)
+{
+    if (!g)
+        return 0;
+    g->o_lat = ISEA_STD_LAT;
+    g->o_lon = ISEA_STD_LON;
+    g->o_az = 0.0;
+    return 1;
+}
+
+ISEA_STATIC
+int
+isea_orient_pole(struct isea_dgg * g)
+{
+    if (!g)
+        return 0;
+    g->o_lat = M_PI / 2.0;
+    g->o_lon = 0.0;
+    g->o_az = 0;
+    return 1;
+}
+
+ISEA_STATIC
+int
+isea_transform(struct isea_dgg * g, struct isea_geo * in,
+           struct isea_pt * out)
+{
+    struct isea_geo i, pole;
+    int             tri;
+
+    pole.lat = g->o_lat;
+    pole.lon = g->o_lon;
+
+    i = isea_ctran(&pole, in, g->o_az);
+
+    tri = isea_snyder_forward(&i, out);
+    out->x *= g->radius;
+    out->y *= g->radius;
+    g->triangle = tri;
+
+    return tri;
+}
+
+#define DOWNTRI(tri) (((tri - 1) / 5) % 2 == 1)
+
+ISEA_STATIC
+void
+isea_rotate(struct isea_pt * pt, double degrees)
+{
+    double          rad;
+
+    double          x, y;
+
+    rad = -degrees * M_PI / 180.0;
+    while (rad >= 2.0 * M_PI) rad -= 2.0 * M_PI;
+    while (rad <= -2.0 * M_PI) rad += 2.0 * M_PI;
+
+    x = pt->x * cos(rad) + pt->y * sin(rad);
+    y = -pt->x * sin(rad) + pt->y * cos(rad);
+
+    pt->x = x;
+    pt->y = y;
+}
+
+ISEA_STATIC
+int isea_tri_plane(int tri, struct isea_pt *pt, double radius) {
+    struct isea_pt tc; /* center of triangle */
+
+    if (DOWNTRI(tri)) {
+        isea_rotate(pt, 180.0);
+    }
+    tc = isea_triangle_xy(tri);
+    tc.x *= radius;
+    tc.y *= radius;
+    pt->x += tc.x;
+    pt->y += tc.y;
+
+    return tri;
+}
+
+/* convert projected triangle coords to quad xy coords, return quad number */
+ISEA_STATIC
+int
+isea_ptdd(int tri, struct isea_pt *pt) {
+    int             downtri, quad;
+
+    downtri = (((tri - 1) / 5) % 2 == 1);
+    quad = ((tri - 1) % 5) + ((tri - 1) / 10) * 5 + 1;
+
+    isea_rotate(pt, downtri ? 240.0 : 60.0);
+    if (downtri) {
+        pt->x += 0.5;
+        /* pt->y += cos(30.0 * M_PI / 180.0); */
+        pt->y += .86602540378443864672;
+    }
+    return quad;
+}
+
+ISEA_STATIC
+int
+isea_dddi_ap3odd(struct isea_dgg *g, int quad, struct isea_pt *pt, struct isea_pt *di)
+{
+    struct isea_pt  v;
+    double          hexwidth;
+    double          sidelength; /* in hexes */
+    int             d, i;
+    int             maxcoord;
+    struct hex      h;
+
+    /* This is the number of hexes from apex to base of a triangle */
+    sidelength = (pow(2.0, g->resolution) + 1.0) / 2.0;
+
+    /* apex to base is cos(30deg) */
+    hexwidth = cos(M_PI / 6.0) / sidelength;
+
+    /* TODO I think sidelength is always x.5, so
+     * (int)sidelength * 2 + 1 might be just as good
+     */
+    maxcoord = (int) (sidelength * 2.0 + 0.5);
+
+    v = *pt;
+    hexbin2(hexwidth, v.x, v.y, &h.x, &h.y);
+    h.iso = 0;
+    hex_iso(&h);
+
+    d = h.x - h.z;
+    i = h.x + h.y + h.y;
+
+    /*
+     * you want to test for max coords for the next quad in the same
+     * "row" first to get the case where both are max
+     */
+    if (quad <= 5) {
+        if (d == 0 && i == maxcoord) {
+            /* north pole */
+            quad = 0;
+            d = 0;
+            i = 0;
+        } else if (i == maxcoord) {
+            /* upper right in next quad */
+            quad += 1;
+            if (quad == 6)
+                quad = 1;
+            i = maxcoord - d;
+            d = 0;
+        } else if (d == maxcoord) {
+            /* lower right in quad to lower right */
+            quad += 5;
+            d = 0;
+        }
+    } else if (quad >= 6) {
+        if (i == 0 && d == maxcoord) {
+            /* south pole */
+            quad = 11;
+            d = 0;
+            i = 0;
+        } else if (d == maxcoord) {
+            /* lower right in next quad */
+            quad += 1;
+            if (quad == 11)
+                quad = 6;
+            d = maxcoord - i;
+            i = 0;
+        } else if (i == maxcoord) {
+            /* upper right in quad to upper right */
+            quad = (quad - 4) % 5;
+            i = 0;
+        }
+    }
+
+    di->x = d;
+    di->y = i;
+
+    g->quad = quad;
+    return quad;
+}
+
+ISEA_STATIC
+int
+isea_dddi(struct isea_dgg *g, int quad, struct isea_pt *pt, struct isea_pt *di) {
+    struct isea_pt  v;
+    double          hexwidth;
+    int             sidelength; /* in hexes */
+    struct hex      h;
+
+    if (g->aperture == 3 && g->resolution % 2 != 0) {
+        return isea_dddi_ap3odd(g, quad, pt, di);
+    }
+    /* todo might want to do this as an iterated loop */
+    if (g->aperture >0) {
+        sidelength = (int) (pow(g->aperture, g->resolution / 2.0) + 0.5);
+    } else {
+        sidelength = g->resolution;
+    }
+
+    hexwidth = 1.0 / sidelength;
+
+    v = *pt;
+    isea_rotate(&v, -30.0);
+    hexbin2(hexwidth, v.x, v.y, &h.x, &h.y);
+    h.iso = 0;
+    hex_iso(&h);
+
+    /* we may actually be on another quad */
+    if (quad <= 5) {
+        if (h.x == 0 && h.z == -sidelength) {
+            /* north pole */
+            quad = 0;
+            h.z = 0;
+            h.y = 0;
+            h.x = 0;
+        } else if (h.z == -sidelength) {
+            quad = quad + 1;
+            if (quad == 6)
+                quad = 1;
+            h.y = sidelength - h.x;
+            h.z = h.x - sidelength;
+            h.x = 0;
+        } else if (h.x == sidelength) {
+            quad += 5;
+            h.y = -h.z;
+            h.x = 0;
+        }
+    } else if (quad >= 6) {
+        if (h.z == 0 && h.x == sidelength) {
+            /* south pole */
+            quad = 11;
+            h.x = 0;
+            h.y = 0;
+            h.z = 0;
+        } else if (h.x == sidelength) {
+            quad = quad + 1;
+            if (quad == 11)
+                quad = 6;
+            h.x = h.y + sidelength;
+            h.y = 0;
+            h.z = -h.x;
+        } else if (h.y == -sidelength) {
+            quad -= 4;
+            h.y = 0;
+            h.z = -h.x;
+        }
+    }
+    di->x = h.x;
+    di->y = -h.z;
+
+    g->quad = quad;
+    return quad;
+}
+
+ISEA_STATIC
+int isea_ptdi(struct isea_dgg *g, int tri, struct isea_pt *pt,
+            struct isea_pt *di) {
+    struct isea_pt  v;
+    int             quad;
+
+    v = *pt;
+    quad = isea_ptdd(tri, &v);
+    quad = isea_dddi(g, quad, &v, di);
+    return quad;
+}
+
+/* q2di to seqnum */
+ISEA_STATIC
+int isea_disn(struct isea_dgg *g, int quad, struct isea_pt *di) {
+    int             sidelength;
+    int             sn, height;
+    int             hexes;
+
+    if (quad == 0) {
+        g->serial = 1;
+        return g->serial;
+    }
+    /* hexes in a quad */
+    hexes = (int) (pow(g->aperture, g->resolution) + 0.5);
+    if (quad == 11) {
+        g->serial = 1 + 10 * hexes + 1;
+        return g->serial;
+    }
+    if (g->aperture == 3 && g->resolution % 2 == 1) {
+        height = (int) (pow(g->aperture, (g->resolution - 1) / 2.0));
+        sn = ((int) di->x) * height;
+        sn += ((int) di->y) / height;
+        sn += (quad - 1) * hexes;
+        sn += 2;
+    } else {
+        sidelength = (int) (pow(g->aperture, g->resolution / 2.0) + 0.5);
+        sn = (quad - 1) * hexes + sidelength * di->x + di->y + 2;
+    }
+
+    g->serial = sn;
+    return sn;
+}
+
+/* TODO just encode the quad in the d or i coordinate
+ * quad is 0-11, which can be four bits.
+ * d' = d << 4 + q, d = d' >> 4, q = d' & 0xf
+ */
+/* convert a q2di to global hex coord */
+ISEA_STATIC
+int isea_hex(struct isea_dgg *g, int tri,
+        struct isea_pt *pt, struct isea_pt *hex) {
+    struct isea_pt v;
+    int sidelength;
+    int d, i, x, y, quad;
+
+    quad = isea_ptdi(g, tri, pt, &v);
+
+    hex->x = ((int)v.x << 4) + quad;
+    hex->y = v.y;
+
+    return 1;
+
+    d = v.x;
+    i = v.y;
+
+    /* Aperture 3 odd resolutions */
+    if (g->aperture == 3 && g->resolution % 2 != 0) {
+        int offset = (int)(pow(3.0, g->resolution - 1) + 0.5);
+
+        d += offset * ((g->quad-1) % 5);
+        i += offset * ((g->quad-1) % 5);
+
+        if (quad == 0) {
+            d = 0;
+            i = offset;
+        } else if (quad == 11) {
+            d = 2 * offset;
+            i = 0;
+        } else if (quad > 5) {
+            d += offset;
+        }
+
+        x = (2*d - i) /3;
+        y = (2*i - d) /3;
+
+        hex->x = x + offset / 3;
+        hex->y = y + 2 * offset / 3;
+        return 1;
+    }
+
+    /* aperture 3 even resolutions and aperture 4 */
+    sidelength = (int) (pow(g->aperture, g->resolution / 2.0) + 0.5);
+    if (g->quad == 0) {
+        hex->x = 0;
+        hex->y = sidelength;
+    } else if (g->quad == 11) {
+        hex->x = sidelength * 2;
+        hex->y = 0;
+    } else {
+        hex->x = d + sidelength * ((g->quad-1) % 5);
+        if (g->quad > 5) hex->x += sidelength;
+        hex->y = i + sidelength * ((g->quad-1) % 5);
+    }
+
+    return 1;
+}
+
+ISEA_STATIC
+struct isea_pt
+isea_forward(struct isea_dgg *g, struct isea_geo *in)
+{
+    int             tri;
+    struct isea_pt  out, coord;
+
+    tri = isea_transform(g, in, &out);
+
+    if (g->output == ISEA_PLANE) {
+        isea_tri_plane(tri, &out, g->radius);
+        return out;
+    }
+
+    /* convert to isea standard triangle size */
+    out.x = out.x / g->radius * ISEA_SCALE;
+    out.y = out.y / g->radius * ISEA_SCALE;
+    out.x += 0.5;
+    out.y += 2.0 * .14433756729740644112;
+
+    switch (g->output) {
+    case ISEA_PROJTRI:
+        /* nothing to do, already in projected triangle */
+        break;
+    case ISEA_VERTEX2DD:
+        g->quad = isea_ptdd(tri, &out);
+        break;
+    case ISEA_Q2DD:
+        /* Same as above, we just don't print as much */
+        g->quad = isea_ptdd(tri, &out);
+        break;
+    case ISEA_Q2DI:
+        g->quad = isea_ptdi(g, tri, &out, &coord);
+        return coord;
+        break;
+    case ISEA_SEQNUM:
+        isea_ptdi(g, tri, &out, &coord);
+        /* disn will set g->serial */
+        isea_disn(g, g->quad, &coord);
+        return coord;
+        break;
+    case ISEA_HEX:
+        isea_hex(g, tri, &out, &coord);
+        return coord;
+        break;
+    }
+
+    return out;
+}
+/*
+ * Proj 4 integration code follows
+ */
+
+#define PJ_LIB__
+#include <projects.h>
+
+PROJ_HEAD(isea, "Icosahedral Snyder Equal Area") "\n\tSph";
+
+struct pj_opaque {
+    struct isea_dgg dgg;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    struct isea_pt out;
+    struct isea_geo in;
+
+    in.lon = lp.lam;
+    in.lat = lp.phi;
+
+    out = isea_forward(&Q->dgg, &in);
+
+    xy.x = out.x;
+    xy.y = out.y;
+
+    return xy;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(isea) {
+    char *opt;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+
+    P->fwd = s_forward;
+    isea_grid_init(&Q->dgg);
+
+    Q->dgg.output = ISEA_PLANE;
+/*      P->dgg.radius = P->a; / * otherwise defaults to 1 */
+    /* calling library will scale, I think */
+
+    opt = pj_param(P->ctx,P->params, "sorient").s;
+    if (opt) {
+        if (!strcmp(opt, "isea")) {
+            isea_orient_isea(&Q->dgg);
+        } else if (!strcmp(opt, "pole")) {
+            isea_orient_pole(&Q->dgg);
+        } else {
+            E_ERROR(-34);
+        }
+    }
+
+    if (pj_param(P->ctx,P->params, "tazi").i) {
+        Q->dgg.o_az = pj_param(P->ctx,P->params, "razi").f;
+    }
+
+    if (pj_param(P->ctx,P->params, "tlon_0").i) {
+        Q->dgg.o_lon = pj_param(P->ctx,P->params, "rlon_0").f;
+    }
+
+    if (pj_param(P->ctx,P->params, "tlat_0").i) {
+        Q->dgg.o_lat = pj_param(P->ctx,P->params, "rlat_0").f;
+    }
+
+    if (pj_param(P->ctx,P->params, "taperture").i) {
+        Q->dgg.aperture = pj_param(P->ctx,P->params, "iaperture").i;
+    }
+
+    if (pj_param(P->ctx,P->params, "tresolution").i) {
+        Q->dgg.resolution = pj_param(P->ctx,P->params, "iresolution").i;
+    }
+
+    opt = pj_param(P->ctx,P->params, "smode").s;
+    if (opt) {
+        if (!strcmp(opt, "plane")) {
+            Q->dgg.output = ISEA_PLANE;
+        } else if (!strcmp(opt, "di")) {
+            Q->dgg.output = ISEA_Q2DI;
+        }
+        else if (!strcmp(opt, "dd")) {
+            Q->dgg.output = ISEA_Q2DD;
+        }
+        else if (!strcmp(opt, "hex")) {
+            Q->dgg.output = ISEA_HEX;
+        }
+        else {
+            /* TODO verify error code.  Possibly eliminate magic */
+            E_ERROR(-34);
+        }
+    }
+
+    if (pj_param(P->ctx,P->params, "trescale").i) {
+        Q->dgg.radius = ISEA_SCALE;
+    }
+
+    if (pj_param(P->ctx,P->params, "tresolution").i) {
+        Q->dgg.resolution = pj_param(P->ctx,P->params, "iresolution").i;
+    } else {
+        Q->dgg.resolution = 4;
+    }
+
+    if (pj_param(P->ctx,P->params, "taperture").i) {
+        Q->dgg.aperture = pj_param(P->ctx,P->params, "iaperture").i;
+    } else {
+        Q->dgg.aperture = 3;
+    }
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_isea_selftest (void) {return 0;}
+#else
+
+int pj_isea_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=isea   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {-1097074.9480224741, 3442909.3090371834},
+        {-1097074.9482647954, 3233611.7285857084},
+        {-1575486.3536415542, 3442168.3420281881},
+        {-1575486.353880283,  3234352.6955947056},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_krovak.c b/src/PJ_krovak.c
index dd25013..562a37c 100644
--- a/src/PJ_krovak.c
+++ b/src/PJ_krovak.c
@@ -1,6 +1,4 @@
-/******************************************************************************
- * $Id$
- *
+ /*
  * Project:  PROJ.4
  * Purpose:  Implementation of the krovak (Krovak) projection.
  *           Definition: http://www.ihsenergy.com/epsg/guid7.html#1.4.3
@@ -27,222 +25,252 @@
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
+ ******************************************************************************
+ * A description of the (forward) projection is found in:
+ *
+ *      Bohuslav Veverka,
+ *
+ *      KROVAK’S PROJECTION AND ITS USE FOR THE
+ *      CZECH REPUBLIC AND THE SLOVAK REPUBLIC,
+ *
+ *      50 years of the Research Institute of
+ *      and the Slovak Republic Geodesy, Topography and Cartography
+ *
+ * which can be found via the Wayback Machine:
+ *
+ *      https://web.archive.org/web/20150216143806/https://www.vugtk.cz/odis/sborniky/sb2005/Sbornik_50_let_VUGTK/Part_1-Scientific_Contribution/16-Veverka.pdf
+ *
+ * Further info, including the inverse projection, is given by EPSG:
+ *
+ *      Guidance Note 7 part 2
+ *      Coordinate Conversions and Transformations including Formulas
+ *
+ *      http://www.iogp.org/pubs/373-07-2.pdf
+ *
+ * Variable names in this file mostly follows what is used in the
+ * paper by Veverka.
+ *
+ * According to EPSG the full Krovak projection method should have
+ * the following parameters.  Within PROJ.4 the azimuth, and pseudo
+ * standard parallel are hardcoded in the algorithm and can't be
+ * altered from outside. The others all have defaults to match the
+ * common usage with Krovak projection.
+ *
+ *      lat_0 = latitude of centre of the projection
+ *
+ *      lon_0 = longitude of centre of the projection
+ *
+ *      ** = azimuth (true) of the centre line passing through the
+ *           centre of the projection
+ *
+ *      ** = latitude of pseudo standard parallel
+ *
+ *      k  = scale factor on the pseudo standard parallel
+ *
+ *      x_0 = False Easting of the centre of the projection at the
+ *            apex of the cone
+ *
+ *      y_0 = False Northing of the centre of the projection at
+ *            the apex of the cone
+ *
  *****************************************************************************/
 
-#define PROJ_PARMS__ \
-	double	C_x;
-#define PJ_LIB__
 
+#define PJ_LIB__
 #include <projects.h>
-#include <string.h>
-#include <stdio.h>
 
 PROJ_HEAD(krovak, "Krovak") "\n\tPCyl., Ellps.";
 
-/**
-   NOTES: According to EPSG the full Krovak projection method should have
-          the following parameters.  Within PROJ.4 the azimuth, and pseudo
-          standard parallel are hardcoded in the algorithm and can't be 
-          altered from outside.  The others all have defaults to match the
-          common usage with Krovak projection.
+#define EPS 1e-15
+#define S45 0.785398163397448  /* 45 deg */
+#define S90 1.570796326794896  /* 90 deg */
+#define UQ  1.04216856380474   /* DU(2, 59, 42, 42.69689) */
+#define S0  1.37008346281555   /* Latitude of pseudo standard parallel 78deg 30'00" N */
 
-  lat_0 = latitude of centre of the projection
-         
-  lon_0 = longitude of centre of the projection
-  
-  ** = azimuth (true) of the centre line passing through the centre of the projection
+struct pj_opaque {
+    double alpha;
+    double k;
+    double n;
+    double rho0;
+    double ad;
+    int czech;
+};
 
-  ** = latitude of pseudo standard parallel
-   
-  k  = scale factor on the pseudo standard parallel
-  
-  x_0 = False Easting of the centre of the projection at the apex of the cone
-  
-  y_0 = False Northing of the centre of the projection at the apex of the cone
 
- **/
+static XY e_forward (LP lp, PJ *P) {                /* Ellipsoidal, forward */
+    struct pj_opaque *Q = P->opaque;
+    XY xy = {0.0,0.0};
 
+    double gfi, u, deltav, s, d, eps, rho;
 
+    gfi = pow ( (1. + P->e * sin(lp.phi)) / (1. - P->e * sin(lp.phi)), Q->alpha * P->e / 2.);
 
-FORWARD(e_forward); /* ellipsoid */
-/* calculate xy from lat/lon */
+    u = 2. * (atan(Q->k * pow( tan(lp.phi / 2. + S45), Q->alpha) / gfi)-S45);
+    deltav = -lp.lam * Q->alpha;
 
-/* Constants, identical to inverse transform function */
-	double s45, s90, e2, e, alfa, uq, u0, g, k, k1, n0, ro0, ad, a, s0, n;
-	double gfi, u, fi0, deltav, s, d, eps, ro;
+    s = asin(cos(Q->ad) * sin(u) + sin(Q->ad) * cos(u) * cos(deltav));
+    d = asin(cos(u) * sin(deltav) / cos(s));
 
+    eps = Q->n * d;
+    rho = Q->rho0 * pow(tan(S0 / 2. + S45) , Q->n) / pow(tan(s / 2. + S45) , Q->n);
 
-	s45 = 0.785398163397448;    /* 45deg */
-	s90 = 2 * s45;
-	fi0 = P->phi0;    /* Latitude of projection centre 49deg 30' */
+    xy.y = rho * cos(eps);
+    xy.x = rho * sin(eps);
 
-   /* Ellipsoid is used as Parameter in for.c and inv.c, therefore a must 
-      be set to 1 here.
-      Ellipsoid Bessel 1841 a = 6377397.155m 1/f = 299.1528128,
-      e2=0.006674372230614;
-   */
-	a =  1; /* 6377397.155; */
-	/* e2 = P->es;*/       /* 0.006674372230614; */
-	e2 = 0.006674372230614;
-	e = sqrt(e2);
+    xy.y *= Q->czech;
+    xy.x *= Q->czech;
 
-	alfa = sqrt(1. + (e2 * pow(cos(fi0), 4)) / (1. - e2));
-
-	uq = 1.04216856380474;      /* DU(2, 59, 42, 42.69689) */
-	u0 = asin(sin(fi0) / alfa);
-	g = pow(   (1. + e * sin(fi0)) / (1. - e * sin(fi0)) , alfa * e / 2.  );
-
-	k = tan( u0 / 2. + s45) / pow  (tan(fi0 / 2. + s45) , alfa) * g;
-
-	k1 = P->k0;
-	n0 = a * sqrt(1. - e2) / (1. - e2 * pow(sin(fi0), 2));
-	s0 = 1.37008346281555;       /* Latitude of pseudo standard parallel 78deg 30'00" N */
-	n = sin(s0);
-	ro0 = k1 * n0 / tan(s0);
-	ad = s90 - uq;
-
-/* Transformation */
+    return xy;
+}
 
-	gfi =pow ( ((1. + e * sin(lp.phi)) /
-               (1. - e * sin(lp.phi))) , (alfa * e / 2.));
 
-	u= 2. * (atan(k * pow( tan(lp.phi / 2. + s45), alfa) / gfi)-s45);
+static LP e_inverse (XY xy, PJ *P) {                /* Ellipsoidal, inverse */
+    struct pj_opaque *Q = P->opaque;
+    LP lp = {0.0,0.0};
 
-	deltav = - lp.lam * alfa;
+    double u, deltav, s, d, eps, rho, fi1, xy0;
+    int ok;
 
-	s = asin(cos(ad) * sin(u) + sin(ad) * cos(u) * cos(deltav));
-	d = asin(cos(u) * sin(deltav) / cos(s));
-	eps = n * d;
-	ro = ro0 * pow(tan(s0 / 2. + s45) , n) / pow(tan(s / 2. + s45) , n)   ;
+    xy0 = xy.x;
+    xy.x = xy.y;
+    xy.y = xy0;
 
-   /* x and y are reverted! */
-	xy.y = ro * cos(eps) / a;
-	xy.x = ro * sin(eps) / a;
+    xy.x *= Q->czech;
+    xy.y *= Q->czech;
 
-        if( !pj_param(P->ctx, P->params, "tczech").i )
-	  {
-	    xy.y *= -1.0;
-	    xy.x *= -1.0;
-	  }
+    rho = sqrt(xy.x * xy.x + xy.y * xy.y);
+    eps = atan2(xy.y, xy.x);
 
-	return (xy);
-}
+    d = eps / sin(S0);
+    s = 2. * (atan(  pow(Q->rho0 / rho, 1. / Q->n) * tan(S0 / 2. + S45)) - S45);
 
+    u = asin(cos(Q->ad) * sin(s) - sin(Q->ad) * cos(s) * cos(d));
+    deltav = asin(cos(s) * sin(d) / cos(u));
 
+    lp.lam = P->lam0 - deltav / Q->alpha;
 
-INVERSE(e_inverse); /* ellipsoid */
-	/* calculate lat/lon from xy */
+    /* ITERATION FOR lp.phi */
+    fi1 = u;
 
-/* Constants, identisch wie in der Umkehrfunktion */
-	double s45, s90, fi0, e2, e, alfa, uq, u0, g, k, k1, n0, ro0, ad, a, s0, n;
-	double u, deltav, s, d, eps, ro, fi1, xy0;
-	int ok;
+    ok = 0;
+    do {
+        lp.phi = 2. * ( atan( pow( Q->k, -1. / Q->alpha)  *
+                              pow( tan(u / 2. + S45) , 1. / Q->alpha)  *
+                              pow( (1. + P->e * sin(fi1)) / (1. - P->e * sin(fi1)) , P->e / 2.)
+                            )  - S45);
 
-	s45 = 0.785398163397448;    /* 45deg */
-	s90 = 2 * s45;
-	fi0 = P->phi0;    /* Latitude of projection centre 49deg 30' */
+        if (fabs(fi1 - lp.phi) < EPS) ok=1;
+        fi1 = lp.phi;
+   } while (ok==0);
 
+   lp.lam -= P->lam0;
 
-   /* Ellipsoid is used as Parameter in for.c and inv.c, therefore a must 
-      be set to 1 here.
-      Ellipsoid Bessel 1841 a = 6377397.155m 1/f = 299.1528128,
-      e2=0.006674372230614;
-   */
-	a = 1; /* 6377397.155; */
-	/* e2 = P->es; */      /* 0.006674372230614; */
-	e2 = 0.006674372230614;
-	e = sqrt(e2);
-
-	alfa = sqrt(1. + (e2 * pow(cos(fi0), 4)) / (1. - e2));
-	uq = 1.04216856380474;      /* DU(2, 59, 42, 42.69689) */
-	u0 = asin(sin(fi0) / alfa);
-	g = pow(   (1. + e * sin(fi0)) / (1. - e * sin(fi0)) , alfa * e / 2.  );
+   return lp;
+}
 
-	k = tan( u0 / 2. + s45) / pow  (tan(fi0 / 2. + s45) , alfa) * g;
 
-	k1 = P->k0;
-	n0 = a * sqrt(1. - e2) / (1. - e2 * pow(sin(fi0), 2));
-	s0 = 1.37008346281555;       /* Latitude of pseudo standard parallel 78deg 30'00" N */
-	n = sin(s0);
-	ro0 = k1 * n0 / tan(s0);
-	ad = s90 - uq;
+static void *freeup_new (PJ *P) {                   /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc(P);
 
+    pj_dealloc(P->opaque);
+    return pj_dealloc(P);
+}
 
-/* Transformation */
-   /* revert y, x*/
-	xy0=xy.x;
-	xy.x=xy.y;
-	xy.y=xy0;
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
 
-        if( !pj_param(P->ctx, P->params, "tczech").i )
-	  {
-	    xy.x *= -1.0;
-	    xy.y *= -1.0;
-	  }
 
-	ro = sqrt(xy.x * xy.x + xy.y * xy.y);
-	eps = atan2(xy.y, xy.x);
-	d = eps / sin(s0);
-	s = 2. * (atan(  pow(ro0 / ro, 1. / n) * tan(s0 / 2. + s45)) - s45);
+PJ *PROJECTION(krovak) {
+    double u0, n0, g;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
 
-	u = asin(cos(ad) * sin(s) - sin(ad) * cos(s) * cos(d));
-	deltav = asin(cos(s) * sin(d) / cos(u));
+    /* we want Bessel as fixed ellipsoid */
+    P->a = 6377397.155;
+    P->e = sqrt(P->es = 0.006674372230614);
 
-	lp.lam = P->lam0 - deltav / alfa;
+    /* if latitude of projection center is not set, use 49d30'N */
+    if (!pj_param(P->ctx, P->params, "tlat_0").i)
+            P->phi0 = 0.863937979737193;
 
-/* ITERATION FOR lp.phi */
-   fi1 = u;
+    /* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */
+    /* that will correspond to using longitudes relative to greenwich    */
+    /* as input and output, instead of lat/long relative to Ferro */
+    if (!pj_param(P->ctx, P->params, "tlon_0").i)
+            P->lam0 = 0.7417649320975901 - 0.308341501185665;
 
-   ok = 0;
-   do
-   {
-   	lp.phi = 2. * ( atan( pow( k, -1. / alfa)  *
-                            pow( tan(u / 2. + s45) , 1. / alfa)  *
-                            pow( (1. + e * sin(fi1)) / (1. - e * sin(fi1)) , e / 2.)
-                           )  - s45);
+    /* if scale not set default to 0.9999 */
+    if (!pj_param(P->ctx, P->params, "tk").i)
+            P->k0 = 0.9999;
 
-      if (fabs(fi1 - lp.phi) < 0.000000000000001) ok=1;
-      fi1 = lp.phi;
+    Q->czech = 1;
+    if( !pj_param(P->ctx, P->params, "tczech").i )
+        Q->czech = -1;
 
-   }
-   while (ok==0);
+    /* Set up shared parameters between forward and inverse */
+    Q->alpha = sqrt(1. + (P->es * pow(cos(P->phi0), 4)) / (1. - P->es));
+    u0 = asin(sin(P->phi0) / Q->alpha);
+    g = pow( (1. + P->e * sin(P->phi0)) / (1. - P->e * sin(P->phi0)) , Q->alpha * P->e / 2. );
+    Q->k = tan( u0 / 2. + S45) / pow  (tan(P->phi0 / 2. + S45) , Q->alpha) * g;
+    n0 = sqrt(1. - P->es) / (1. - P->es * pow(sin(P->phi0), 2));
+    Q->n = sin(S0);
+    Q->rho0 = P->k0 * n0 / tan(S0);
+    Q->ad = S90 - UQ;
 
-   lp.lam -= P->lam0;
+    P->inv = e_inverse;
+    P->fwd = e_forward;
 
-   return (lp);
+    return P;
 }
 
-FREEUP; if (P) pj_dalloc(P); }
-
-ENTRY0(krovak)
-	double ts;
-	/* read some Parameters,
-	 * here Latitude Truescale */
-
-	ts = pj_param(P->ctx, P->params, "rlat_ts").f;
-	P->C_x = ts;
-	
-	/* we want Bessel as fixed ellipsoid */
-	P->a = 6377397.155;
-	P->e = sqrt(P->es = 0.006674372230614);
-
-        /* if latitude of projection center is not set, use 49d30'N */
-	if (!pj_param(P->ctx, P->params, "tlat_0").i)
-            P->phi0 = 0.863937979737193; 
 
-        /* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */
-        /* that will correspond to using longitudes relative to greenwich    */
-        /* as input and output, instead of lat/long relative to Ferro */
-	if (!pj_param(P->ctx, P->params, "tlon_0").i)
-            P->lam0 = 0.7417649320975901 - 0.308341501185665;
-
-        /* if scale not set default to 0.9999 */
-	if (!pj_param(P->ctx, P->params, "tk").i)
-            P->k0 = 0.9999;
-
-	/* always the same */
-        P->inv = e_inverse; 
-	P->fwd = e_forward;
+#ifdef PJ_OMIT_SELFTEST
+int pj_krovak_selftest (void) {return 0;}
+#else
+
+int pj_krovak_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=krovak +ellps=GRS80"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {-3196535.2325636409,  -6617878.8675514441},
+        {-3260035.4405521089,  -6898873.6148780314},
+        {-3756305.3288691747,  -6478142.5615715114},
+        {-3831703.6585019818,  -6759107.1701553948},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {24.836218918719162,  59.758403933233858},
+        {24.836315484509566,  59.756888425730189},
+        {24.830447747947495,  59.758403933233858},
+        {24.830351182157091,  59.756888425730189},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
 
-ENDENTRY(P)
 
+#endif
diff --git a/src/PJ_labrd.c b/src/PJ_labrd.c
index 4cb39ec..1666a5b 100644
--- a/src/PJ_labrd.c
+++ b/src/PJ_labrd.c
@@ -1,109 +1,186 @@
-#define PROJ_PARMS__ \
-	double	Az, kRg, p0s, A, C, Ca, Cb, Cc, Cd; \
-	int		rot;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(labrd, "Laborde") "\n\tCyl, Sph\n\tSpecial for Madagascar";
-#define EPS	1.e-10
-FORWARD(e_forward);
-	double V1, V2, ps, sinps, cosps, sinps2, cosps2, I1, I2, I3, I4, I5, I6,
-		x2, y2, t;
-
-	V1 = P->A * log( tan(FORTPI + .5 * lp.phi) );
-	t = P->e * sin(lp.phi);
-	V2 = .5 * P->e * P->A * log ((1. + t)/(1. - t));
-	ps = 2. * (atan(exp(V1 - V2 + P->C)) - FORTPI);
-	I1 = ps - P->p0s;
-	cosps = cos(ps);	cosps2 = cosps * cosps;
-	sinps = sin(ps);	sinps2 = sinps * sinps;
-	I4 = P->A * cosps;
-	I2 = .5 * P->A * I4 * sinps;
-	I3 = I2 * P->A * P->A * (5. * cosps2 - sinps2) / 12.;
-	I6 = I4 * P->A * P->A;
-	I5 = I6 * (cosps2 - sinps2) / 6.;
-	I6 *= P->A * P->A *
-		(5. * cosps2 * cosps2 + sinps2 * (sinps2 - 18. * cosps2)) / 120.;
-	t = lp.lam * lp.lam;
-	xy.x = P->kRg * lp.lam * (I4 + t * (I5 + t * I6));
-	xy.y = P->kRg * (I1 + t * (I2 + t * I3));
-	x2 = xy.x * xy.x;
-	y2 = xy.y * xy.y;
-	V1 = 3. * xy.x * y2 - xy.x * x2;
-	V2 = xy.y * y2 - 3. * x2 * xy.y;
-	xy.x += P->Ca * V1 + P->Cb * V2;
-	xy.y += P->Ca * V2 - P->Cb * V1;
-	return (xy);
+#define EPS 1.e-10
+
+struct pj_opaque {
+    double  kRg, p0s, A, C, Ca, Cb, Cc, Cd; \
+    int     rot;
+};
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double V1, V2, ps, sinps, cosps, sinps2, cosps2;
+    double I1, I2, I3, I4, I5, I6, x2, y2, t;
+
+    V1 = Q->A * log( tan(M_FORTPI + .5 * lp.phi) );
+    t = P->e * sin(lp.phi);
+    V2 = .5 * P->e * Q->A * log ((1. + t)/(1. - t));
+    ps = 2. * (atan(exp(V1 - V2 + Q->C)) - M_FORTPI);
+    I1 = ps - Q->p0s;
+    cosps = cos(ps);    cosps2 = cosps * cosps;
+    sinps = sin(ps);    sinps2 = sinps * sinps;
+    I4 = Q->A * cosps;
+    I2 = .5 * Q->A * I4 * sinps;
+    I3 = I2 * Q->A * Q->A * (5. * cosps2 - sinps2) / 12.;
+    I6 = I4 * Q->A * Q->A;
+    I5 = I6 * (cosps2 - sinps2) / 6.;
+    I6 *= Q->A * Q->A *
+        (5. * cosps2 * cosps2 + sinps2 * (sinps2 - 18. * cosps2)) / 120.;
+    t = lp.lam * lp.lam;
+    xy.x = Q->kRg * lp.lam * (I4 + t * (I5 + t * I6));
+    xy.y = Q->kRg * (I1 + t * (I2 + t * I3));
+    x2 = xy.x * xy.x;
+    y2 = xy.y * xy.y;
+    V1 = 3. * xy.x * y2 - xy.x * x2;
+    V2 = xy.y * y2 - 3. * x2 * xy.y;
+    xy.x += Q->Ca * V1 + Q->Cb * V2;
+    xy.y += Q->Ca * V2 - Q->Cb * V1;
+    return xy;
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double x2, y2, V1, V2, V3, V4, t, t2, ps, pe, tpe, s;
+    double I7, I8, I9, I10, I11, d, Re;
+    int i;
+
+    x2 = xy.x * xy.x;
+    y2 = xy.y * xy.y;
+    V1 = 3. * xy.x * y2 - xy.x * x2;
+    V2 = xy.y * y2 - 3. * x2 * xy.y;
+    V3 = xy.x * (5. * y2 * y2 + x2 * (-10. * y2 + x2 ));
+    V4 = xy.y * (5. * x2 * x2 + y2 * (-10. * x2 + y2 ));
+    xy.x += - Q->Ca * V1 - Q->Cb * V2 + Q->Cc * V3 + Q->Cd * V4;
+    xy.y +=   Q->Cb * V1 - Q->Ca * V2 - Q->Cd * V3 + Q->Cc * V4;
+    ps = Q->p0s + xy.y / Q->kRg;
+    pe = ps + P->phi0 - Q->p0s;
+    for ( i = 20; i; --i) {
+        V1 = Q->A * log(tan(M_FORTPI + .5 * pe));
+        tpe = P->e * sin(pe);
+        V2 = .5 * P->e * Q->A * log((1. + tpe)/(1. - tpe));
+        t = ps - 2. * (atan(exp(V1 - V2 + Q->C)) - M_FORTPI);
+        pe += t;
+        if (fabs(t) < EPS)
+            break;
+    }
+
+    t = P->e * sin(pe);
+    t = 1. - t * t;
+    Re = P->one_es / ( t * sqrt(t) );
+    t = tan(ps);
+    t2 = t * t;
+    s = Q->kRg * Q->kRg;
+    d = Re * P->k0 * Q->kRg;
+    I7 = t / (2. * d);
+    I8 = t * (5. + 3. * t2) / (24. * d * s);
+    d = cos(ps) * Q->kRg * Q->A;
+    I9 = 1. / d;
+    d *= s;
+    I10 = (1. + 2. * t2) / (6. * d);
+    I11 = (5. + t2 * (28. + 24. * t2)) / (120. * d * s);
+    x2 = xy.x * xy.x;
+    lp.phi = pe + x2 * (-I7 + I8 * x2);
+    lp.lam = xy.x * (I9 + x2 * (-I10 + x2 * I11));
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(e_inverse); /* ellipsoid & spheroid */
-	double x2, y2, V1, V2, V3, V4, t, t2, ps, pe, tpe, s,
-		I7, I8, I9, I10, I11, d, Re;
-	int i;
-
-	x2 = xy.x * xy.x;
-	y2 = xy.y * xy.y;
-	V1 = 3. * xy.x * y2 - xy.x * x2;
-	V2 = xy.y * y2 - 3. * x2 * xy.y;
-	V3 = xy.x * (5. * y2 * y2 + x2 * (-10. * y2 + x2 ));
-	V4 = xy.y * (5. * x2 * x2 + y2 * (-10. * x2 + y2 ));
-	xy.x += - P->Ca * V1 - P->Cb * V2 + P->Cc * V3 + P->Cd * V4;
-	xy.y +=   P->Cb * V1 - P->Ca * V2 - P->Cd * V3 + P->Cc * V4;
-	ps = P->p0s + xy.y / P->kRg;
-	pe = ps + P->phi0 - P->p0s;
-	for ( i = 20; i; --i) {
-		V1 = P->A * log(tan(FORTPI + .5 * pe));
-		tpe = P->e * sin(pe);
-		V2 = .5 * P->e * P->A * log((1. + tpe)/(1. - tpe));
-		t = ps - 2. * (atan(exp(V1 - V2 + P->C)) - FORTPI);
-		pe += t;
-		if (fabs(t) < EPS)
-			break;
-	}
-/*
-	if (!i) {
-	} else {
-	}
-*/
-	t = P->e * sin(pe);
-	t = 1. - t * t;
-	Re = P->one_es / ( t * sqrt(t) );
-	t = tan(ps);
-	t2 = t * t;
-	s = P->kRg * P->kRg;
-	d = Re * P->k0 * P->kRg;
-	I7 = t / (2. * d);
-	I8 = t * (5. + 3. * t2) / (24. * d * s);
-	d = cos(ps) * P->kRg * P->A;
-	I9 = 1. / d;
-	d *= s;
-	I10 = (1. + 2. * t2) / (6. * d);
-	I11 = (5. + t2 * (28. + 24. * t2)) / (120. * d * s);
-	x2 = xy.x * xy.x;
-	lp.phi = pe + x2 * (-I7 + I8 * x2);
-	lp.lam = xy.x * (I9 + x2 * (-I10 + x2 * I11));
-	return (lp);
+
+
+PJ *PROJECTION(labrd) {
+    double Az, sinp, R, N, t;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->rot  = pj_param(P->ctx, P->params, "bno_rot").i == 0;
+    Az = pj_param(P->ctx, P->params, "razi").f;
+    sinp = sin(P->phi0);
+    t = 1. - P->es * sinp * sinp;
+    N = 1. / sqrt(t);
+    R = P->one_es * N / t;
+    Q->kRg = P->k0 * sqrt( N * R );
+    Q->p0s = atan( sqrt(R / N) * tan(P->phi0) );
+    Q->A = sinp / sin(Q->p0s);
+    t = P->e * sinp;
+    Q->C = .5 * P->e * Q->A * log((1. + t)/(1. - t)) +
+          - Q->A * log( tan(M_FORTPI + .5 * P->phi0))
+          + log( tan(M_FORTPI + .5 * Q->p0s));
+    t = Az + Az;
+    Q->Ca = (1. - cos(t)) * ( Q->Cb = 1. / (12. * Q->kRg * Q->kRg) );
+    Q->Cb *= sin(t);
+    Q->Cc = 3. * (Q->Ca * Q->Ca - Q->Cb * Q->Cb);
+    Q->Cd = 6. * Q->Ca * Q->Cb;
+
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+
+    return P;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(labrd)
-	double Az, sinp, R, N, t;
-
-	P->rot	= pj_param(P->ctx, P->params, "bno_rot").i == 0;
-	Az = pj_param(P->ctx, P->params, "razi").f;
-	sinp = sin(P->phi0);
-	t = 1. - P->es * sinp * sinp;
-	N = 1. / sqrt(t);
-	R = P->one_es * N / t;
-	P->kRg = P->k0 * sqrt( N * R );
-	P->p0s = atan( sqrt(R / N) * tan(P->phi0) );
-	P->A = sinp / sin(P->p0s);
-	t = P->e * sinp;
-	P->C = .5 * P->e * P->A * log((1. + t)/(1. - t)) +
-		- P->A * log( tan(FORTPI + .5 * P->phi0))
-		+ log( tan(FORTPI + .5 * P->p0s));
-	t = Az + Az;
-	P->Ca = (1. - cos(t)) * ( P->Cb = 1. / (12. * P->kRg * P->kRg) );
-	P->Cb *= sin(t);
-	P->Cc = 3. * (P->Ca * P->Ca - P->Cb * P->Cb);
-	P->Cd = 6. * P->Ca * P->Cb;
-	P->inv = e_inverse;
-	P->fwd = e_forward;
-ENDENTRY(P)
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_labrd_selftest (void) {return 0;}
+#else
+
+int pj_labrd_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=labrd   +ellps=GRS80  +lon_0=0.5 +lat_0=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 166973.166090228391, -110536.912730266107},
+        { 166973.168287157256, -331761.993650884193},
+        {-278345.500519976194, -110469.032642031714},
+        {-278345.504185269645, -331829.870790275279},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.501797719349373672, 2.00090435742047923},
+        {0.501797717380853658, 1.99909564058898681},
+        {0.498202280650626328, 2.00090435742047923},
+        {0.498202282619146342, 1.99909564058898681},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
+
+
+#endif
diff --git a/src/PJ_laea.c b/src/PJ_laea.c
index d32bb0b..f1cc9c7 100644
--- a/src/PJ_laea.c
+++ b/src/PJ_laea.c
@@ -1,233 +1,338 @@
-#define PROJ_PARMS__ \
-	double	sinb1; \
-	double	cosb1; \
-	double	xmf; \
-	double	ymf; \
-	double	mmf; \
-	double	qp; \
-	double	dd; \
-	double	rq; \
-	double	*apa; \
-	int		mode;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(laea, "Lambert Azimuthal Equal Area") "\n\tAzi, Sph&Ell";
-#define sinph0	P->sinb1
-#define cosph0	P->cosb1
-#define EPS10	1.e-10
-#define NITER	20
-#define CONV	1.e-10
-#define N_POLE	0
-#define S_POLE	1
-#define EQUIT	2
-#define OBLIQ	3
-FORWARD(e_forward); /* ellipsoid */
-	double coslam, sinlam, sinphi, q, sinb=0.0, cosb=0.0, b=0.0;
-
-	coslam = cos(lp.lam);
-	sinlam = sin(lp.lam);
-	sinphi = sin(lp.phi);
-	q = pj_qsfn(sinphi, P->e, P->one_es);
-	if (P->mode == OBLIQ || P->mode == EQUIT) {
-		sinb = q / P->qp;
-		cosb = sqrt(1. - sinb * sinb);
-	}
-	switch (P->mode) {
-	case OBLIQ:
-		b = 1. + P->sinb1 * sinb + P->cosb1 * cosb * coslam;
-		break;
-	case EQUIT:
-		b = 1. + cosb * coslam;
-		break;
-	case N_POLE:
-		b = HALFPI + lp.phi;
-		q = P->qp - q;
-		break;
-	case S_POLE:
-		b = lp.phi - HALFPI;
-		q = P->qp + q;
-		break;
-	}
-	if (fabs(b) < EPS10) F_ERROR;
-	switch (P->mode) {
-	case OBLIQ:
-		xy.y = P->ymf * ( b = sqrt(2. / b) )
-		   * (P->cosb1 * sinb - P->sinb1 * cosb * coslam);
-		goto eqcon;
-		break;
-	case EQUIT:
-		xy.y = (b = sqrt(2. / (1. + cosb * coslam))) * sinb * P->ymf; 
+
+struct pj_opaque {
+    double sinb1;
+    double cosb1;
+    double xmf;
+    double ymf;
+    double mmf;
+    double qp;
+    double dd;
+    double rq;
+    double *apa;
+    int mode;
+};
+
+#define EPS10   1.e-10
+#define NITER   20
+#define CONV    1.e-10
+#define N_POLE  0
+#define S_POLE  1
+#define EQUIT   2
+#define OBLIQ   3
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double coslam, sinlam, sinphi, q, sinb=0.0, cosb=0.0, b=0.0;
+
+    coslam = cos(lp.lam);
+    sinlam = sin(lp.lam);
+    sinphi = sin(lp.phi);
+    q = pj_qsfn(sinphi, P->e, P->one_es);
+
+    if (Q->mode == OBLIQ || Q->mode == EQUIT) {
+        sinb = q / Q->qp;
+        cosb = sqrt(1. - sinb * sinb);
+    }
+
+    switch (Q->mode) {
+    case OBLIQ:
+        b = 1. + Q->sinb1 * sinb + Q->cosb1 * cosb * coslam;
+        break;
+    case EQUIT:
+        b = 1. + cosb * coslam;
+        break;
+    case N_POLE:
+        b = M_HALFPI + lp.phi;
+        q = Q->qp - q;
+        break;
+    case S_POLE:
+        b = lp.phi - M_HALFPI;
+        q = Q->qp + q;
+        break;
+    }
+    if (fabs(b) < EPS10) F_ERROR;
+
+    switch (Q->mode) {
+    case OBLIQ:
+        b = sqrt(2. / b);
+        xy.y = Q->ymf * b * (Q->cosb1 * sinb - Q->sinb1 * cosb * coslam);
+        goto eqcon;
+        break;
+    case EQUIT:
+        b = sqrt(2. / (1. + cosb * coslam));
+        xy.y = b * sinb * Q->ymf;
 eqcon:
-		xy.x = P->xmf * b * cosb * sinlam;
-		break;
-	case N_POLE:
-	case S_POLE:
-		if (q >= 0.) {
-			xy.x = (b = sqrt(q)) * sinlam;
-			xy.y = coslam * (P->mode == S_POLE ? b : -b);
-		} else
-			xy.x = xy.y = 0.;
-		break;
-	}
-	return (xy);
+        xy.x = Q->xmf * b * cosb * sinlam;
+        break;
+    case N_POLE:
+    case S_POLE:
+        if (q >= 0.) {
+            b = sqrt(q);
+            xy.x = b * sinlam;
+            xy.y = coslam * (Q->mode == S_POLE ? b : -b);
+        } else
+            xy.x = xy.y = 0.;
+        break;
+    }
+    return xy;
 }
-FORWARD(s_forward); /* spheroid */
-	double  coslam, cosphi, sinphi;
-
-	sinphi = sin(lp.phi);
-	cosphi = cos(lp.phi);
-	coslam = cos(lp.lam);
-	switch (P->mode) {
-	case EQUIT:
-		xy.y = 1. + cosphi * coslam;
-		goto oblcon;
-	case OBLIQ:
-		xy.y = 1. + sinph0 * sinphi + cosph0 * cosphi * coslam;
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  coslam, cosphi, sinphi;
+
+    sinphi = sin(lp.phi);
+    cosphi = cos(lp.phi);
+    coslam = cos(lp.lam);
+    switch (Q->mode) {
+    case EQUIT:
+        xy.y = 1. + cosphi * coslam;
+        goto oblcon;
+    case OBLIQ:
+        xy.y = 1. + Q->sinb1 * sinphi + Q->cosb1 * cosphi * coslam;
 oblcon:
-		if (xy.y <= EPS10) F_ERROR;
-		xy.x = (xy.y = sqrt(2. / xy.y)) * cosphi * sin(lp.lam);
-		xy.y *= P->mode == EQUIT ? sinphi :
-		   cosph0 * sinphi - sinph0 * cosphi * coslam;
-		break;
-	case N_POLE:
-		coslam = -coslam;
-	case S_POLE:
-		if (fabs(lp.phi + P->phi0) < EPS10) F_ERROR;
-		xy.y = FORTPI - lp.phi * .5;
-		xy.y = 2. * (P->mode == S_POLE ? cos(xy.y) : sin(xy.y));
-		xy.x = xy.y * sin(lp.lam);
-		xy.y *= coslam;
-		break;
-	}
-	return (xy);
+        if (xy.y <= EPS10) F_ERROR;
+        xy.y = sqrt(2. / xy.y);
+        xy.x = xy.y * cosphi * sin(lp.lam);
+        xy.y *= Q->mode == EQUIT ? sinphi :
+           Q->cosb1 * sinphi - Q->sinb1 * cosphi * coslam;
+        break;
+    case N_POLE:
+        coslam = -coslam;
+    case S_POLE:
+        if (fabs(lp.phi + P->phi0) < EPS10) F_ERROR;
+        xy.y = M_FORTPI - lp.phi * .5;
+        xy.y = 2. * (Q->mode == S_POLE ? cos(xy.y) : sin(xy.y));
+        xy.x = xy.y * sin(lp.lam);
+        xy.y *= coslam;
+        break;
+    }
+    return xy;
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double cCe, sCe, q, rho, ab=0.0;
+
+    switch (Q->mode) {
+    case EQUIT:
+    case OBLIQ:
+        xy.x /= Q->dd;
+        xy.y *=  Q->dd;
+        rho = hypot(xy.x, xy.y);
+        if (rho < EPS10) {
+            lp.lam = 0.;
+            lp.phi = P->phi0;
+            return lp;
+        }
+        sCe = 2. * asin(.5 * rho / Q->rq);
+        cCe = cos(sCe);
+        sCe = sin(sCe);
+        xy.x *= sCe;
+        if (Q->mode == OBLIQ) {
+            ab = cCe * Q->sinb1 + xy.y * sCe * Q->cosb1 / rho;
+            xy.y = rho * Q->cosb1 * cCe - xy.y * Q->sinb1 * sCe;
+        } else {
+            ab = xy.y * sCe / rho;
+            xy.y = rho * cCe;
+        }
+        break;
+    case N_POLE:
+        xy.y = -xy.y;
+    case S_POLE:
+        q = (xy.x * xy.x + xy.y * xy.y);
+        if (!q) {
+            lp.lam = 0.;
+            lp.phi = P->phi0;
+            return (lp);
+        }
+        ab = 1. - q / Q->qp;
+        if (Q->mode == S_POLE)
+            ab = - ab;
+        break;
+    }
+    lp.lam = atan2(xy.x, xy.y);
+    lp.phi = pj_authlat(asin(ab), Q->apa);
+    return lp;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  cosz=0.0, rh, sinz=0.0;
+
+    rh = hypot(xy.x, xy.y);
+    if ((lp.phi = rh * .5 ) > 1.) I_ERROR;
+    lp.phi = 2. * asin(lp.phi);
+    if (Q->mode == OBLIQ || Q->mode == EQUIT) {
+        sinz = sin(lp.phi);
+        cosz = cos(lp.phi);
+    }
+    switch (Q->mode) {
+    case EQUIT:
+        lp.phi = fabs(rh) <= EPS10 ? 0. : asin(xy.y * sinz / rh);
+        xy.x *= sinz;
+        xy.y = cosz * rh;
+        break;
+    case OBLIQ:
+        lp.phi = fabs(rh) <= EPS10 ? P->phi0 :
+           asin(cosz * Q->sinb1 + xy.y * sinz * Q->cosb1 / rh);
+        xy.x *= sinz * Q->cosb1;
+        xy.y = (cosz - sin(lp.phi) * Q->sinb1) * rh;
+        break;
+    case N_POLE:
+        xy.y = -xy.y;
+        lp.phi = M_HALFPI - lp.phi;
+        break;
+    case S_POLE:
+        lp.phi -= M_HALFPI;
+        break;
+    }
+    lp.lam = (xy.y == 0. && (Q->mode == EQUIT || Q->mode == OBLIQ)) ?
+        0. : atan2(xy.x, xy.y);
+    return (lp);
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque->apa);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-INVERSE(e_inverse); /* ellipsoid */
-	double cCe, sCe, q, rho, ab=0.0;
-
-	switch (P->mode) {
-	case EQUIT:
-	case OBLIQ:
-		if ((rho = hypot(xy.x /= P->dd, xy.y *=  P->dd)) < EPS10) {
-			lp.lam = 0.;
-			lp.phi = P->phi0;
-			return (lp);
-		}
-		cCe = cos(sCe = 2. * asin(.5 * rho / P->rq));
-		xy.x *= (sCe = sin(sCe));
-		if (P->mode == OBLIQ) {
-			q = P->qp * (ab = cCe * P->sinb1 + xy.y * sCe * P->cosb1 / rho);
-			xy.y = rho * P->cosb1 * cCe - xy.y * P->sinb1 * sCe;
-		} else {
-			q = P->qp * (ab = xy.y * sCe / rho);
-			xy.y = rho * cCe;
-		}
-		break;
-	case N_POLE:
-		xy.y = -xy.y;
-	case S_POLE:
-		if (!(q = (xy.x * xy.x + xy.y * xy.y)) ) {
-			lp.lam = 0.;
-			lp.phi = P->phi0;
-			return (lp);
-		}
-		/*
-		q = P->qp - q;
-		*/
-		ab = 1. - q / P->qp;
-		if (P->mode == S_POLE)
-			ab = - ab;
-		break;
-	}
-	lp.lam = atan2(xy.x, xy.y);
-	lp.phi = pj_authlat(asin(ab), P->apa);
-	return (lp);
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(s_inverse); /* spheroid */
-	double  cosz=0.0, rh, sinz=0.0;
-
-	rh = hypot(xy.x, xy.y);
-	if ((lp.phi = rh * .5 ) > 1.) I_ERROR;
-	lp.phi = 2. * asin(lp.phi);
-	if (P->mode == OBLIQ || P->mode == EQUIT) {
-		sinz = sin(lp.phi);
-		cosz = cos(lp.phi);
-	}
-	switch (P->mode) {
-	case EQUIT:
-		lp.phi = fabs(rh) <= EPS10 ? 0. : asin(xy.y * sinz / rh);
-		xy.x *= sinz;
-		xy.y = cosz * rh;
-		break;
-	case OBLIQ:
-		lp.phi = fabs(rh) <= EPS10 ? P->phi0 :
-		   asin(cosz * sinph0 + xy.y * sinz * cosph0 / rh);
-		xy.x *= sinz * cosph0;
-		xy.y = (cosz - sin(lp.phi) * sinph0) * rh;
-		break;
-	case N_POLE:
-		xy.y = -xy.y;
-		lp.phi = HALFPI - lp.phi;
-		break;
-	case S_POLE:
-		lp.phi -= HALFPI;
-		break;
-	}
-	lp.lam = (xy.y == 0. && (P->mode == EQUIT || P->mode == OBLIQ)) ?
-		0. : atan2(xy.x, xy.y);
-	return (lp);
+
+
+PJ *PROJECTION(laea) {
+    double t;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    t = fabs(P->phi0);
+    if (fabs(t - M_HALFPI) < EPS10)
+        Q->mode = P->phi0 < 0. ? S_POLE : N_POLE;
+    else if (fabs(t) < EPS10)
+        Q->mode = EQUIT;
+    else
+        Q->mode = OBLIQ;
+    if (P->es) {
+        double sinphi;
+
+        P->e = sqrt(P->es);
+        Q->qp = pj_qsfn(1., P->e, P->one_es);
+        Q->mmf = .5 / (1. - P->es);
+        Q->apa = pj_authset(P->es);
+        switch (Q->mode) {
+        case N_POLE:
+        case S_POLE:
+            Q->dd = 1.;
+            break;
+        case EQUIT:
+            Q->dd = 1. / (Q->rq = sqrt(.5 * Q->qp));
+            Q->xmf = 1.;
+            Q->ymf = .5 * Q->qp;
+            break;
+        case OBLIQ:
+            Q->rq = sqrt(.5 * Q->qp);
+            sinphi = sin(P->phi0);
+            Q->sinb1 = pj_qsfn(sinphi, P->e, P->one_es) / Q->qp;
+            Q->cosb1 = sqrt(1. - Q->sinb1 * Q->sinb1);
+            Q->dd = cos(P->phi0) / (sqrt(1. - P->es * sinphi * sinphi) *
+               Q->rq * Q->cosb1);
+            Q->ymf = (Q->xmf = Q->rq) / Q->dd;
+            Q->xmf *= Q->dd;
+            break;
+        }
+        P->inv = e_inverse;
+        P->fwd = e_forward;
+    } else {
+        if (Q->mode == OBLIQ) {
+            Q->sinb1 = sin(P->phi0);
+            Q->cosb1 = cos(P->phi0);
+        }
+        P->inv = s_inverse;
+        P->fwd = s_forward;
+    }
+
+    return P;
 }
-FREEUP;
-    if (P) {
-		if (P->apa)
-			pj_dalloc(P->apa);
-		pj_dalloc(P);
-	}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_laea_selftest (void) {return 0;}
+#else
+
+int pj_laea_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=laea   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=laea   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222602.471450095181,  110589.82722441027},
+        { 222602.471450095181, -110589.827224408786},
+        {-222602.471450095181,  110589.82722441027},
+        {-222602.471450095181, -110589.827224408786},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223365.281370124663,  111716.668072915665},
+        { 223365.281370124663, -111716.668072915665},
+        {-223365.281370124663,  111716.668072915665},
+        {-223365.281370124663, -111716.668072915665},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.00179663056847900867,  0.000904369475966495845},
+        { 0.00179663056847900867, -0.000904369475966495845},
+        {-0.00179663056847900867,  0.000904369475966495845},
+        {-0.00179663056847900867, -0.000904369475966495845},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179049311002060264,  0.000895246554791735271},
+        { 0.00179049311002060264, -0.000895246554791735271},
+        {-0.00179049311002060264,  0.000895246554791735271},
+        {-0.00179049311002060264, -0.000895246554791735271},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
 }
-ENTRY1(laea,apa)
-	double t;
-
-	if (fabs((t = fabs(P->phi0)) - HALFPI) < EPS10)
-		P->mode = P->phi0 < 0. ? S_POLE : N_POLE;
-	else if (fabs(t) < EPS10)
-		P->mode = EQUIT;
-	else
-		P->mode = OBLIQ;
-	if (P->es) {
-		double sinphi;
-
-		P->e = sqrt(P->es);
-		P->qp = pj_qsfn(1., P->e, P->one_es);
-		P->mmf = .5 / (1. - P->es);
-		P->apa = pj_authset(P->es);
-		switch (P->mode) {
-		case N_POLE:
-		case S_POLE:
-			P->dd = 1.;
-			break;
-		case EQUIT:
-			P->dd = 1. / (P->rq = sqrt(.5 * P->qp));
-			P->xmf = 1.;
-			P->ymf = .5 * P->qp;
-			break;
-		case OBLIQ:
-			P->rq = sqrt(.5 * P->qp);
-			sinphi = sin(P->phi0);
-			P->sinb1 = pj_qsfn(sinphi, P->e, P->one_es) / P->qp;
-			P->cosb1 = sqrt(1. - P->sinb1 * P->sinb1);
-			P->dd = cos(P->phi0) / (sqrt(1. - P->es * sinphi * sinphi) *
-			   P->rq * P->cosb1);
-			P->ymf = (P->xmf = P->rq) / P->dd;
-			P->xmf *= P->dd;
-			break;
-		}
-		P->inv = e_inverse;
-		P->fwd = e_forward;
-	} else {
-		if (P->mode == OBLIQ) {
-			sinph0 = sin(P->phi0);
-			cosph0 = cos(P->phi0);
-		}
-		P->inv = s_inverse;
-		P->fwd = s_forward;
-	}
-ENDENTRY(P)
+
+
+#endif
diff --git a/src/PJ_lagrng.c b/src/PJ_lagrng.c
index 8a13b3d..3c89ebc 100644
--- a/src/PJ_lagrng.c
+++ b/src/PJ_lagrng.c
@@ -1,35 +1,103 @@
-#define PROJ_PARMS__ \
-	double	hrw; \
-	double	rw; \
-	double	a1;
-#define TOL	1e-10
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(lagrng, "Lagrange") "\n\tMisc Sph, no inv.\n\tW=";
-FORWARD(s_forward); /* spheroid */
-	double v, c;
-
-	if (fabs(fabs(lp.phi) - HALFPI) < TOL) {
-		xy.x = 0;
-		xy.y = lp.phi < 0 ? -2. : 2.;
-	} else {
-		lp.phi = sin(lp.phi);
-		v = P->a1 * pow((1. + lp.phi)/(1. - lp.phi), P->hrw);
-		if ((c = 0.5 * (v + 1./v) + cos(lp.lam *= P->rw)) < TOL)
-			F_ERROR;
-		xy.x = 2. * sin(lp.lam) / c;
-		xy.y = (v - 1./v) / c;
-	}
-	return (xy);
+
+#define TOL 1e-10
+
+struct pj_opaque {
+    double  a1;
+    double  hrw;
+    double  rw;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double v, c;
+
+    if (fabs(fabs(lp.phi) - M_HALFPI) < TOL) {
+        xy.x = 0;
+        xy.y = lp.phi < 0 ? -2. : 2.;
+    } else {
+        lp.phi = sin(lp.phi);
+        v = Q->a1 * pow((1. + lp.phi)/(1. - lp.phi), Q->hrw);
+        if ((c = 0.5 * (v + 1./v) + cos(lp.lam *= Q->rw)) < TOL)
+            F_ERROR;
+        xy.x = 2. * sin(lp.lam) / c;
+        xy.y = (v - 1./v) / c;
+    }
+    return xy;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(lagrng) {
+    double phi1;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->rw = pj_param(P->ctx, P->params, "dW").f;
+    if (Q->rw <= 0) E_ERROR(-27);
+
+    Q->rw = 1. / Q->rw;
+    Q->hrw = 0.5 * Q->rw;
+    phi1 = sin(pj_param(P->ctx, P->params, "rlat_1").f);
+    if (fabs(fabs(phi1) - 1.) < TOL) E_ERROR(-22);
+
+    Q->a1 = pow((1. - phi1)/(1. + phi1), Q->hrw);
+
+    P->es = 0.;
+    P->fwd = s_forward;
+
+    return P;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(lagrng)
-	double phi1;
-
-	if ((P->rw = pj_param(P->ctx, P->params, "dW").f) <= 0) E_ERROR(-27);
-	P->hrw = 0.5 * (P->rw = 1. / P->rw);
-	phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
-	if (fabs(fabs(phi1 = sin(phi1)) - 1.) < TOL) E_ERROR(-22);
-	P->a1 = pow((1. - phi1)/(1. + phi1), P->hrw);
-	P->es = 0.; P->fwd = s_forward;
-ENDENTRY(P)
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_lagrng_selftest (void) {return 0;}
+#else
+
+int pj_lagrng_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=lagrng   +a=6400000 +W=2   +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 111703.37591722561,   27929.8319080333386},
+        { 111699.122088816002, -83784.1780133577704},
+        {-111703.37591722561,   27929.8319080333386},
+        {-111699.122088816002, -83784.1780133577704},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_larr.c b/src/PJ_larr.c
index 118bef0..f55289b 100644
--- a/src/PJ_larr.c
+++ b/src/PJ_larr.c
@@ -1,13 +1,70 @@
-#define PROJ_PARMS__
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(larr, "Larrivee") "\n\tMisc Sph, no inv.";
+
 #define SIXTH .16666666666666666
-FORWARD(s_forward); /* sphere */
-	(void) P;
-	xy.x = 0.5 * lp.lam * (1. + sqrt(cos(lp.phi)));
-	xy.y = lp.phi / (cos(0.5 * lp.phi) * cos(SIXTH * lp.lam));
-	return (xy);
-}
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(larr) P->fwd = s_forward; P->inv = 0; P->es = 0.; ENDENTRY(P)
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+
+    xy.x = 0.5 * lp.lam * (1. + sqrt(cos(lp.phi)));
+    xy.y = lp.phi / (cos(0.5 * lp.phi) * cos(SIXTH * lp.lam));
+    return xy;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(larr) {
+
+    P->es = 0;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_larr_selftest (void) {return 0;}
+#else
+
+int pj_larr_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=larr   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {223393.637624200899,  111707.215961255497},
+        {223393.637624200899,  -111707.215961255497},
+        {-223393.637624200899,  111707.215961255497},
+        {-223393.637624200899,  -111707.215961255497},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_lask.c b/src/PJ_lask.c
index 797b580..38e7045 100644
--- a/src/PJ_lask.c
+++ b/src/PJ_lask.c
@@ -1,27 +1,81 @@
-#define PROJ_PARMS__
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
 PROJ_HEAD(lask, "Laskowski") "\n\tMisc Sph, no inv.";
-#define	a10	 0.975534
-#define	a12	-0.119161
-#define	a32	-0.0143059
-#define	a14	-0.0547009
-#define	b01	 1.00384
-#define	b21	 0.0802894
-#define	b03	 0.0998909
-#define	b41	 0.000199025
-#define	b23	-0.0285500
-#define	b05	-0.0491032
-FORWARD(s_forward); /* sphere */
-	double l2, p2;
-	(void) P;
-
-	l2 = lp.lam * lp.lam;
-	p2 = lp.phi * lp.phi;
-	xy.x = lp.lam * (a10 + p2 * (a12 + l2 * a32 + p2 * a14));
-	xy.y = lp.phi * (b01 + l2 * (b21 + p2 * b23 + l2 * b41) +
-		p2 * (b03 + p2 * b05));
-	return (xy);
+
+#define a10  0.975534
+#define a12 -0.119161
+#define a32 -0.0143059
+#define a14 -0.0547009
+#define b01  1.00384
+#define b21  0.0802894
+#define b03  0.0998909
+#define b41  0.000199025
+#define b23 -0.0285500
+#define b05 -0.0491032
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double l2, p2;
+    (void) P;
+
+    l2 = lp.lam * lp.lam;
+    p2 = lp.phi * lp.phi;
+    xy.x = lp.lam * (a10 + p2 * (a12 + l2 * a32 + p2 * a14));
+    xy.y = lp.phi * (b01 + l2 * (b21 + p2 * b23 + l2 * b41) +
+               p2 * (b03 + p2 * b05));
+    return xy;
+}
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(lask) {
+
+    P->fwd = s_forward;
+    P->es = 0.;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_lask_selftest (void) {return 0;}
+#else
+
+int pj_lask_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=lask   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 217928.275907355128,  112144.32922014239},
+        { 217928.275907355128, -112144.32922014239},
+        {-217928.275907355128,  112144.32922014239},
+        {-217928.275907355128, -112144.32922014239},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(lask) P->fwd = s_forward; P->inv = 0; P->es = 0.; ENDENTRY(P)
+
+
+#endif
diff --git a/src/PJ_lcc.c b/src/PJ_lcc.c
index 9d3494b..e53ee9b 100644
--- a/src/PJ_lcc.c
+++ b/src/PJ_lcc.c
@@ -1,105 +1,196 @@
-#define PROJ_PARMS__ \
-	double	phi1; \
-	double	phi2; \
-	double	n; \
-	double	rho0; \
-	double	c; \
-	int		ellips;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(lcc, "Lambert Conformal Conic")
-	"\n\tConic, Sph&Ell\n\tlat_1= and lat_2= or lat_0";
-# define EPS10	1.e-10
-FORWARD(e_forward); /* ellipsoid & spheroid */
-        double rho;
-	if (fabs(fabs(lp.phi) - HALFPI) < EPS10) {
-		if ((lp.phi * P->n) <= 0.) F_ERROR;
-		rho = 0.;
-		}
-	else
-		rho = P->c * (P->ellips ? pow(pj_tsfn(lp.phi, sin(lp.phi),
-			P->e), P->n) : pow(tan(FORTPI + .5 * lp.phi), -P->n));
-	xy.x = P->k0 * (rho * sin( lp.lam *= P->n ) );
-	xy.y = P->k0 * (P->rho0 - rho * cos(lp.lam) );
-	return (xy);
+    "\n\tConic, Sph&Ell\n\tlat_1= and lat_2= or lat_0";
+
+# define EPS10  1.e-10
+
+struct pj_opaque {
+    double phi1;
+    double phi2;
+    double n;
+    double rho0;
+    double c;
+    int    ellips;
+};
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double rho;
+
+    if (fabs(fabs(lp.phi) - M_HALFPI) < EPS10) {
+        if ((lp.phi * Q->n) <= 0.) F_ERROR;
+        rho = 0.;
+    } else {
+        rho = Q->c * (Q->ellips ? pow(pj_tsfn(lp.phi, sin(lp.phi),
+            P->e), Q->n) : pow(tan(M_FORTPI + .5 * lp.phi), -Q->n));
+    }
+    lp.lam *= Q->n;
+    xy.x = P->k0 * (rho * sin( lp.lam) );
+    xy.y = P->k0 * (Q->rho0 - rho * cos(lp.lam) );
+    return xy;
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double rho;
+
+    xy.x /= P->k0;
+    xy.y /= P->k0;
+
+    xy.y = Q->rho0 - xy.y;
+    rho = hypot(xy.x, xy.y);
+    if (rho != 0.0) {
+        if (Q->n < 0.) {
+            rho = -rho;
+            xy.x = -xy.x;
+            xy.y = -xy.y;
+        }
+        if (Q->ellips) {
+            lp.phi = pj_phi2(P->ctx, pow(rho / Q->c, 1./Q->n), P->e);
+            if (lp.phi == HUGE_VAL)
+                I_ERROR;
+        } else
+            lp.phi = 2. * atan(pow(Q->c / rho, 1./Q->n)) - M_HALFPI;
+        lp.lam = atan2(xy.x, xy.y) / Q->n;
+    } else {
+        lp.lam = 0.;
+        lp.phi = Q->n > 0. ? M_HALFPI : -M_HALFPI;
+    }
+    return lp;
+}
+
+static void special(LP lp, PJ *P, struct FACTORS *fac) {
+    struct pj_opaque *Q = P->opaque;
+    double rho;
+    if (fabs(fabs(lp.phi) - M_HALFPI) < EPS10) {
+        if ((lp.phi * Q->n) <= 0.) return;
+        rho = 0.;
+    } else
+        rho = Q->c * (Q->ellips ? pow(pj_tsfn(lp.phi, sin(lp.phi),
+            P->e), Q->n) : pow(tan(M_FORTPI + .5 * lp.phi), -Q->n));
+    fac->code |= IS_ANAL_HK + IS_ANAL_CONV;
+    fac->k = fac->h = P->k0 * Q->n * rho /
+        pj_msfn(sin(lp.phi), cos(lp.phi), P->es);
+    fac->conv = - Q->n * lp.lam;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(e_inverse); /* ellipsoid & spheroid */
-        double rho;
-	xy.x /= P->k0;
-	xy.y /= P->k0;
-	if( (rho = hypot(xy.x, xy.y = P->rho0 - xy.y)) != 0.0) {
-		if (P->n < 0.) {
-			rho = -rho;
-			xy.x = -xy.x;
-			xy.y = -xy.y;
-		}
-		if (P->ellips) {
-			if ((lp.phi = pj_phi2(P->ctx, pow(rho / P->c, 1./P->n), P->e))
-				== HUGE_VAL)
-				I_ERROR;
-		} else
-			lp.phi = 2. * atan(pow(P->c / rho, 1./P->n)) - HALFPI;
-		lp.lam = atan2(xy.x, xy.y) / P->n;
-	} else {
-		lp.lam = 0.;
-		lp.phi = P->n > 0. ? HALFPI : - HALFPI;
-	}
-	return (lp);
+
+
+PJ *PROJECTION(lcc) {
+    double cosphi, sinphi;
+    int secant;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+
+    Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
+    if (pj_param(P->ctx, P->params, "tlat_2").i)
+        Q->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
+    else {
+        Q->phi2 = Q->phi1;
+        if (!pj_param(P->ctx, P->params, "tlat_0").i)
+            P->phi0 = Q->phi1;
+    }
+    if (fabs(Q->phi1 + Q->phi2) < EPS10) E_ERROR(-21);
+    Q->n = sinphi = sin(Q->phi1);
+    cosphi = cos(Q->phi1);
+    secant = fabs(Q->phi1 - Q->phi2) >= EPS10;
+    if( (Q->ellips = (P->es != 0.)) ) {
+        double ml1, m1;
+
+        P->e = sqrt(P->es);
+        m1 = pj_msfn(sinphi, cosphi, P->es);
+        ml1 = pj_tsfn(Q->phi1, sinphi, P->e);
+        if (secant) { /* secant cone */
+            sinphi = sin(Q->phi2);
+            Q->n = log(m1 / pj_msfn(sinphi, cos(Q->phi2), P->es));
+            Q->n /= log(ml1 / pj_tsfn(Q->phi2, sinphi, P->e));
+        }
+        Q->c = (Q->rho0 = m1 * pow(ml1, -Q->n) / Q->n);
+        Q->rho0 *= (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) ? 0. :
+            pow(pj_tsfn(P->phi0, sin(P->phi0), P->e), Q->n);
+    } else {
+        if (secant)
+            Q->n = log(cosphi / cos(Q->phi2)) /
+               log(tan(M_FORTPI + .5 * Q->phi2) /
+               tan(M_FORTPI + .5 * Q->phi1));
+        Q->c = cosphi * pow(tan(M_FORTPI + .5 * Q->phi1), Q->n) / Q->n;
+        Q->rho0 = (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) ? 0. :
+            Q->c * pow(tan(M_FORTPI + .5 * P->phi0), -Q->n);
+    }
+
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+    P->spc = special;
+
+    return P;
 }
-SPECIAL(fac) {
-        double rho;
-	if (fabs(fabs(lp.phi) - HALFPI) < EPS10) {
-		if ((lp.phi * P->n) <= 0.) return;
-		rho = 0.;
-	} else
-		rho = P->c * (P->ellips ? pow(pj_tsfn(lp.phi, sin(lp.phi),
-			P->e), P->n) : pow(tan(FORTPI + .5 * lp.phi), -P->n));
-	fac->code |= IS_ANAL_HK + IS_ANAL_CONV;
-	fac->k = fac->h = P->k0 * P->n * rho /
-		pj_msfn(sin(lp.phi), cos(lp.phi), P->es);
-	fac->conv = - P->n * lp.lam;
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_lcc_selftest (void) {return 0;}
+#else
+
+int pj_lcc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=lcc   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222588.439735968423,  110660.533870799671},
+        { 222756.879700278747, -110532.797660827026},
+        {-222588.439735968423,  110660.533870799671},
+        {-222756.879700278747, -110532.797660827026},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.00179635940600536667,  0.000904232207322381741},
+        { 0.00179635817735249777, -0.000904233135128348995},
+        {-0.00179635940600536667,  0.000904232207322381741},
+        {-0.00179635817735249777, -0.000904233135128348995},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(lcc)
-	double cosphi, sinphi;
-	int secant;
-
-	P->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
-	if (pj_param(P->ctx, P->params, "tlat_2").i)
-		P->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
-	else {
-		P->phi2 = P->phi1;
-		if (!pj_param(P->ctx, P->params, "tlat_0").i)
-			P->phi0 = P->phi1;
-	}
-	if (fabs(P->phi1 + P->phi2) < EPS10) E_ERROR(-21);
-	P->n = sinphi = sin(P->phi1);
-	cosphi = cos(P->phi1);
-	secant = fabs(P->phi1 - P->phi2) >= EPS10;
-	if( (P->ellips = (P->es != 0.)) ) {
-		double ml1, m1;
-
-		P->e = sqrt(P->es);
-		m1 = pj_msfn(sinphi, cosphi, P->es);
-		ml1 = pj_tsfn(P->phi1, sinphi, P->e);
-		if (secant) { /* secant cone */
-			P->n = log(m1 /
-			   pj_msfn(sinphi = sin(P->phi2), cos(P->phi2), P->es));
-			P->n /= log(ml1 / pj_tsfn(P->phi2, sinphi, P->e));
-		}
-		P->c = (P->rho0 = m1 * pow(ml1, -P->n) / P->n);
-		P->rho0 *= (fabs(fabs(P->phi0) - HALFPI) < EPS10) ? 0. :
-			pow(pj_tsfn(P->phi0, sin(P->phi0), P->e), P->n);
-	} else {
-		if (secant)
-			P->n = log(cosphi / cos(P->phi2)) /
-			   log(tan(FORTPI + .5 * P->phi2) /
-			   tan(FORTPI + .5 * P->phi1));
-		P->c = cosphi * pow(tan(FORTPI + .5 * P->phi1), P->n) / P->n;
-		P->rho0 = (fabs(fabs(P->phi0) - HALFPI) < EPS10) ? 0. :
-			P->c * pow(tan(FORTPI + .5 * P->phi0), -P->n);
-	}
-	P->inv = e_inverse;
-	P->fwd = e_forward;
-	P->spc = fac;
-ENDENTRY(P)
+
+
+#endif
diff --git a/src/PJ_lcca.c b/src/PJ_lcca.c
index 320d52d..50c8997 100644
--- a/src/PJ_lcca.c
+++ b/src/PJ_lcca.c
@@ -1,70 +1,156 @@
-/* PROJ.4 Cartographic Projection System 
+/* PROJ.4 Cartographic Projection System
 */
-#define MAX_ITER 10
-#define DEL_TOL 1e-12
-#define PROJ_PARMS__ \
-	double	*en; \
-	double	r0, l, M0; \
-	double	C;
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
 
 PROJ_HEAD(lcca, "Lambert Conformal Conic Alternative")
-	"\n\tConic, Sph&Ell\n\tlat_0=";
+    "\n\tConic, Sph&Ell\n\tlat_0=";
+
+#define MAX_ITER 10
+#define DEL_TOL 1e-12
+
+struct pj_opaque {
+    double *en;
+    double r0, l, M0;
+    double C;
+};
+
+
+static double fS(double S, double C) {        /* func to compute dr */
+
+    return S * ( 1. + S * S * C);
+}
+
+
+static double fSp(double S, double C) {       /* deriv of fs */
+
+    return 1. + 3.* S * S * C;
+}
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double S, r, dr;
+
+    S = pj_mlfn(lp.phi, sin(lp.phi), cos(lp.phi), Q->en) - Q->M0;
+    dr = fS(S, Q->C);
+    r = Q->r0 - dr;
+    xy.x = P->k0 * (r * sin( lp.lam *= Q->l ) );
+    xy.y = P->k0 * (Q->r0 - r * cos(lp.lam) );
+    return xy;
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double theta, dr, S, dif;
+    int i;
+
+    xy.x /= P->k0;
+    xy.y /= P->k0;
+    theta = atan2(xy.x , Q->r0 - xy.y);
+    dr = xy.y - xy.x * tan(0.5 * theta);
+    lp.lam = theta / Q->l;
+    S = dr;
+    for (i = MAX_ITER; i ; --i) {
+        S -= (dif = (fS(S, Q->C) - dr) / fSp(S, Q->C));
+        if (fabs(dif) < DEL_TOL) break;
+    }
+    if (!i) I_ERROR
+    lp.phi = pj_inv_mlfn(P->ctx, S + Q->M0, P->es, Q->en);
 
-	static double /* func to compute dr */
-fS(double S, double C) {
-		return(S * ( 1. + S * S * C));
+    return lp;
 }
-	static double /* deriv of fs */
-fSp(double S, double C) {
-	return(1. + 3.* S * S * C);
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque->en);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-FORWARD(e_forward); /* ellipsoid */
-	double S, r, dr;
-	
-	S = pj_mlfn(lp.phi, sin(lp.phi), cos(lp.phi), P->en) - P->M0;
-	dr = fS(S, P->C);
-	r = P->r0 - dr;
-	xy.x = P->k0 * (r * sin( lp.lam *= P->l ) );
-	xy.y = P->k0 * (P->r0 - r * cos(lp.lam) );
-	return (xy);
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(e_inverse); /* ellipsoid & spheroid */
-	double theta, dr, S, dif;
-	int i;
-
-	xy.x /= P->k0;
-	xy.y /= P->k0;
-	theta = atan2(xy.x , P->r0 - xy.y);
-	dr = xy.y - xy.x * tan(0.5 * theta);
-	lp.lam = theta / P->l;
-	S = dr;
-	for (i = MAX_ITER; i ; --i) {
-		S -= (dif = (fS(S, P->C) - dr) / fSp(S, P->C));
-		if (fabs(dif) < DEL_TOL) break;
-	}
-	if (!i) I_ERROR
-	lp.phi = pj_inv_mlfn(P->ctx, S + P->M0, P->es, P->en);
-	return (lp);
+
+
+PJ *PROJECTION(lcca) {
+    double s2p0, N0, R0, tan0;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    (Q->en = pj_enfn(P->es));
+    if (!Q->en) E_ERROR_0;
+    if (!pj_param(P->ctx, P->params, "tlat_0").i) E_ERROR(50);
+    if (P->phi0 == 0.) E_ERROR(51);
+    Q->l = sin(P->phi0);
+    Q->M0 = pj_mlfn(P->phi0, Q->l, cos(P->phi0), Q->en);
+    s2p0 = Q->l * Q->l;
+    R0 = 1. / (1. - P->es * s2p0);
+    N0 = sqrt(R0);
+    R0 *= P->one_es * N0;
+    tan0 = tan(P->phi0);
+    Q->r0 = N0 / tan0;
+    Q->C = 1. / (6. * R0 * N0);
+
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+
+    return P;
 }
-FREEUP; if (P) { if (P->en) pj_dalloc(P->en); pj_dalloc(P); } }
-ENTRY0(lcca)
-	double s2p0, N0, R0, tan0;
-
-	if (!(P->en = pj_enfn(P->es))) E_ERROR_0;
-	if (!pj_param(P->ctx, P->params, "tlat_0").i) E_ERROR(50);
-	if (P->phi0 == 0.) E_ERROR(51);
-	P->l = sin(P->phi0);
-	P->M0 = pj_mlfn(P->phi0, P->l, cos(P->phi0), P->en);
-	s2p0 = P->l * P->l;
-	R0 = 1. / (1. - P->es * s2p0);
-	N0 = sqrt(R0);
-	R0 *= P->one_es * N0;
-	tan0 = tan(P->phi0);
-	P->r0 = N0 / tan0;
-	P->C = 1. / (6. * R0 * N0);
-	P->inv = e_inverse;
-	P->fwd = e_forward;
-ENDENTRY(P)
 
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_lcca_selftest (void) {return 0;}
+#else
+
+int pj_lcca_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=lcca   +ellps=GRS80  +lat_0=1 +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222605.285770237417,  67.8060072715846616},
+        { 222740.037637936533, -221125.539829601563},
+        {-222605.285770237417,  67.8060072715846616},
+        {-222740.037637936533, -221125.539829601563},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.00179690290525662526, 1.00090436621350798},
+        { 0.00179690192174008037, 0.999095632791497268},
+        {-0.00179690290525662526, 1.00090436621350798},
+        {-0.00179690192174008037, 0.999095632791497268},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
+
+
+#endif
diff --git a/src/PJ_loxim.c b/src/PJ_loxim.c
index 595423f..0ce81c2 100644
--- a/src/PJ_loxim.c
+++ b/src/PJ_loxim.c
@@ -1,41 +1,130 @@
-#define PROJ_PARMS__ \
-	double phi1; \
-	double cosphi1; \
-	double tanphi1;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(loxim, "Loximuthal") "\n\tPCyl Sph";
-#define EPS	1e-8
-FORWARD(s_forward); /* spheroid */
-	xy.y = lp.phi - P->phi1;
-	if (fabs(xy.y) < EPS)
-		xy.x = lp.lam * P->cosphi1;
-	else {
-		xy.x = FORTPI + 0.5 * lp.phi;
-		if (fabs(xy.x) < EPS || fabs(fabs(xy.x) - HALFPI) < EPS)
-			xy.x = 0.;
-		else
-			xy.x = lp.lam * xy.y / log( tan(xy.x) / P->tanphi1 );
-	}
-	return (xy);
+
+#define EPS 1e-8
+
+struct pj_opaque {
+    double phi1;
+    double cosphi1;
+    double tanphi1;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    xy.y = lp.phi - Q->phi1;
+    if (fabs(xy.y) < EPS)
+        xy.x = lp.lam * Q->cosphi1;
+    else {
+        xy.x = M_FORTPI + 0.5 * lp.phi;
+        if (fabs(xy.x) < EPS || fabs(fabs(xy.x) - M_HALFPI) < EPS)
+            xy.x = 0.;
+        else
+            xy.x = lp.lam * xy.y / log( tan(xy.x) / Q->tanphi1 );
+    }
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	lp.phi = xy.y + P->phi1;
-	if (fabs(xy.y) < EPS)
-		lp.lam = xy.x / P->cosphi1;
-	else
-		if (fabs( lp.lam = FORTPI + 0.5 * lp.phi ) < EPS ||
-			fabs(fabs(lp.lam) - HALFPI) < EPS)
-			lp.lam = 0.;
-		else
-			lp.lam = xy.x * log( tan(lp.lam) / P->tanphi1 ) / xy.y ;
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    lp.phi = xy.y + Q->phi1;
+    if (fabs(xy.y) < EPS) {
+        lp.lam = xy.x / Q->cosphi1;
+    } else {
+        lp.lam = M_FORTPI + 0.5 * lp.phi;
+        if (fabs(lp.lam) < EPS || fabs(fabs(lp.lam) - M_HALFPI) < EPS)
+            lp.lam = 0.;
+        else
+            lp.lam = xy.x * log( tan(lp.lam) / Q->tanphi1 ) / xy.y ;
+    }
+    return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(loxim);
-	P->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
-	if ((P->cosphi1 = cos(P->phi1)) < EPS) E_ERROR(-22);
-	P->tanphi1 = tan(FORTPI + 0.5 * P->phi1);
-	P->inv = s_inverse; P->fwd = s_forward;
-	P->es = 0.;
-ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(loxim) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
+    Q->cosphi1 = cos(Q->phi1);
+    if (Q->cosphi1 < EPS)
+        E_ERROR(-22);
+
+    Q->tanphi1 = tan(M_FORTPI + 0.5 * Q->phi1);
+
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    P->es = 0.;
+
+   return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_loxim_selftest (void) {return 0;}
+#else
+
+int pj_loxim_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=loxim   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223382.295791338867,  55850.5360638185448},
+        { 223393.637462243292, -167551.608191455656},
+        {-223382.295791338867,  55850.5360638185448},
+        {-223393.637462243292, -167551.608191455656},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179056141104335601, 0.500895246554891926},
+        { 0.00179056116683692576, 0.499104753445108074},
+        {-0.00179056141104335601, 0.500895246554891926},
+        {-0.00179056116683692576, 0.499104753445108074},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_lsat.c b/src/PJ_lsat.c
index d11a5c1..dcbed48 100644
--- a/src/PJ_lsat.c
+++ b/src/PJ_lsat.c
@@ -1,171 +1,256 @@
 /* based upon Snyder and Linck, USGS-NMD */
-#define PROJ_PARMS__ \
-    double a2, a4, b, c1, c3; \
-    double q, t, u, w, p22, sa, ca, xj, rlm, rlm2;
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
 PROJ_HEAD(lsat, "Space oblique for LANDSAT")
-	"\n\tCyl, Sph&Ell\n\tlsat= path=";
+    "\n\tCyl, Sph&Ell\n\tlsat= path=";
+
 #define TOL 1e-7
-#define PI_HALFPI 4.71238898038468985766
-#define TWOPI_HALFPI 7.85398163397448309610
-	static void
-seraz0(double lam, double mult, PJ *P) {
-    double sdsq, h, s, fc, sd, sq, d__1;
+
+struct pj_opaque {
+    double a2, a4, b, c1, c3;
+    double q, t, u, w, p22, sa, ca, xj, rlm, rlm2;
+};
+
+static void seraz0(double lam, double mult, PJ *P) {
+    struct pj_opaque *Q = P->opaque;
+    double sdsq, h, s, fc, sd, sq, d__1 = 0;
 
     lam *= DEG_TO_RAD;
     sd = sin(lam);
     sdsq = sd * sd;
-    s = P->p22 * P->sa * cos(lam) * sqrt((1. + P->t * sdsq) / ((
-	    1. + P->w * sdsq) * (1. + P->q * sdsq)));
-    d__1 = 1. + P->q * sdsq;
-    h = sqrt((1. + P->q * sdsq) / (1. + P->w * sdsq)) * ((1. + 
-	    P->w * sdsq) / (d__1 * d__1) - P->p22 * P->ca);
-    sq = sqrt(P->xj * P->xj + s * s);
-    P->b += fc = mult * (h * P->xj - s * s) / sq;
-    P->a2 += fc * cos(lam + lam);
-    P->a4 += fc * cos(lam * 4.);
-    fc = mult * s * (h + P->xj) / sq;
-    P->c1 += fc * cos(lam);
-    P->c3 += fc * cos(lam * 3.);
+    s = Q->p22 * Q->sa * cos(lam) * sqrt((1. + Q->t * sdsq)
+        / ((1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
+
+    h = sqrt((1. + Q->q * sdsq) / (1. + Q->w * sdsq)) * ((1. + Q->w * sdsq)
+        / (d__1 * d__1) - Q->p22 * Q->ca);
+
+    sq = sqrt(Q->xj * Q->xj + s * s);
+    fc = mult * (h * Q->xj - s * s) / sq;
+    Q->b += fc;
+    Q->a2 += fc * cos(lam + lam);
+    Q->a4 += fc * cos(lam * 4.);
+    fc = mult * s * (h + Q->xj) / sq;
+    Q->c1 += fc * cos(lam);
+    Q->c3 += fc * cos(lam * 3.);
 }
-FORWARD(e_forward); /* ellipsoid */
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
     int l, nn;
-    double lamt, xlam, sdsq, c, d, s, lamdp, phidp, lampp, tanph,
-		lamtp, cl, sd, sp, fac, sav, tanphi;
-
-	if (lp.phi > HALFPI)
-	    lp.phi = HALFPI;
-	else if (lp.phi < -HALFPI)
-	    lp.phi = -HALFPI;
-	lampp = lp.phi >= 0. ? HALFPI : PI_HALFPI;
-	tanphi = tan(lp.phi);
-	for (nn = 0;;) {
-		sav = lampp;
-		lamtp = lp.lam + P->p22 * lampp;
-		cl = cos(lamtp);
-		if (fabs(cl) < TOL)
-		    lamtp -= TOL;
-		fac = lampp - sin(lampp) * (cl < 0. ? -HALFPI : HALFPI);
-		for (l = 50; l; --l) {
-			lamt = lp.lam + P->p22 * sav;
-			if (fabs(c = cos(lamt)) < TOL)
-			    lamt -= TOL;
-			xlam = (P->one_es * tanphi * P->sa + sin(lamt) * P->ca) / c;
-			lamdp = atan(xlam) + fac;
-			if (fabs(fabs(sav) - fabs(lamdp)) < TOL)
-			    break;
-			sav = lamdp;
-		}
-		if (!l || ++nn >= 3 || (lamdp > P->rlm && lamdp < P->rlm2))
-			break;
-		if (lamdp <= P->rlm)
-		    lampp = TWOPI_HALFPI;
-		else if (lamdp >= P->rlm2)
-		    lampp = HALFPI;
-	}
-	if (l) {
-		sp = sin(lp.phi);
-		phidp = aasin(P->ctx,(P->one_es * P->ca * sp - P->sa * cos(lp.phi) * 
-			sin(lamt)) / sqrt(1. - P->es * sp * sp));
-		tanph = log(tan(FORTPI + .5 * phidp));
-		sd = sin(lamdp);
-		sdsq = sd * sd;
-		s = P->p22 * P->sa * cos(lamdp) * sqrt((1. + P->t * sdsq)
-			 / ((1. + P->w * sdsq) * (1. + P->q * sdsq)));
-		d = sqrt(P->xj * P->xj + s * s);
-		xy.x = P->b * lamdp + P->a2 * sin(2. * lamdp) + P->a4 *
-			sin(lamdp * 4.) - tanph * s / d;
-		xy.y = P->c1 * sd + P->c3 * sin(lamdp * 3.) + tanph * P->xj / d;
-	} else
-		xy.x = xy.y = HUGE_VAL;
-	return xy;
+    double lamt, xlam, sdsq, c, d, s, lamdp, phidp, lampp, tanph;
+    double lamtp, cl, sd, sp, fac, sav, tanphi;
+
+    if (lp.phi > M_HALFPI)
+        lp.phi = M_HALFPI;
+    else if (lp.phi < -M_HALFPI)
+        lp.phi = -M_HALFPI;
+
+    lampp = lp.phi >= 0. ? M_HALFPI : M_PI_HALFPI;
+    tanphi = tan(lp.phi);
+    for (nn = 0;;) {
+        sav = lampp;
+        lamtp = lp.lam + Q->p22 * lampp;
+        cl = cos(lamtp);
+        if (fabs(cl) < TOL)
+            lamtp -= TOL;
+        fac = lampp - sin(lampp) * (cl < 0. ? -M_HALFPI : M_HALFPI);
+        for (l = 50; l; --l) {
+            lamt = lp.lam + Q->p22 * sav;
+            c = cos(lamt);
+            if (fabs(c) < TOL)
+                lamt -= TOL;
+            xlam = (P->one_es * tanphi * Q->sa + sin(lamt) * Q->ca) / c;
+            lamdp = atan(xlam) + fac;
+            if (fabs(fabs(sav) - fabs(lamdp)) < TOL)
+                break;
+            sav = lamdp;
+        }
+        if (!l || ++nn >= 3 || (lamdp > Q->rlm && lamdp < Q->rlm2))
+            break;
+        if (lamdp <= Q->rlm)
+            lampp = M_TWOPI_HALFPI;
+        else if (lamdp >= Q->rlm2)
+            lampp = M_HALFPI;
+    }
+    if (l) {
+        sp = sin(lp.phi);
+        phidp = aasin(P->ctx,(P->one_es * Q->ca * sp - Q->sa * cos(lp.phi) *
+            sin(lamt)) / sqrt(1. - P->es * sp * sp));
+        tanph = log(tan(M_FORTPI + .5 * phidp));
+        sd = sin(lamdp);
+        sdsq = sd * sd;
+        s = Q->p22 * Q->sa * cos(lamdp) * sqrt((1. + Q->t * sdsq)
+             / ((1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
+        d = sqrt(Q->xj * Q->xj + s * s);
+        xy.x = Q->b * lamdp + Q->a2 * sin(2. * lamdp) + Q->a4 *
+            sin(lamdp * 4.) - tanph * s / d;
+        xy.y = Q->c1 * sd + Q->c3 * sin(lamdp * 3.) + tanph * Q->xj / d;
+    } else
+        xy.x = xy.y = HUGE_VAL;
+    return xy;
 }
-INVERSE(e_inverse); /* ellipsoid */
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
     int nn;
     double lamt, sdsq, s, lamdp, phidp, sppsq, dd, sd, sl, fac, scl, sav, spp;
 
-	lamdp = xy.x / P->b;
-	nn = 50;
-	do {
-		sav = lamdp;
-		sd = sin(lamdp);
-		sdsq = sd * sd;
-		s = P->p22 * P->sa * cos(lamdp) * sqrt((1. + P->t * sdsq)
-			 / ((1. + P->w * sdsq) * (1. + P->q * sdsq)));
-		lamdp = xy.x + xy.y * s / P->xj - P->a2 * sin(
-			2. * lamdp) - P->a4 * sin(lamdp * 4.) - s / P->xj * (
-			P->c1 * sin(lamdp) + P->c3 * sin(lamdp * 3.));
-		lamdp /= P->b;
-	} while (fabs(lamdp - sav) >= TOL && --nn);
-	sl = sin(lamdp);
-	fac = exp(sqrt(1. + s * s / P->xj / P->xj) * (xy.y - 
-		P->c1 * sl - P->c3 * sin(lamdp * 3.)));
-	phidp = 2. * (atan(fac) - FORTPI);
-	dd = sl * sl;
-	if (fabs(cos(lamdp)) < TOL)
-	    lamdp -= TOL;
-	spp = sin(phidp);
-	sppsq = spp * spp;
-	lamt = atan(((1. - sppsq * P->rone_es) * tan(lamdp) * 
-		P->ca - spp * P->sa * sqrt((1. + P->q * dd) * (
-		1. - sppsq) - sppsq * P->u) / cos(lamdp)) / (1. - sppsq 
-		* (1. + P->u)));
-	sl = lamt >= 0. ? 1. : -1.;
-	scl = cos(lamdp) >= 0. ? 1. : -1;
-	lamt -= HALFPI * (1. - scl) * sl;
-	lp.lam = lamt - P->p22 * lamdp;
-	if (fabs(P->sa) < TOL)
-	    lp.phi = aasin(P->ctx,spp / sqrt(P->one_es * P->one_es + P->es * sppsq));
-	else
-		lp.phi = atan((tan(lamdp) * cos(lamt) - P->ca * sin(lamt)) /
-			(P->one_es * P->sa));
-	return lp;
+    lamdp = xy.x / Q->b;
+    nn = 50;
+    do {
+        sav = lamdp;
+        sd = sin(lamdp);
+        sdsq = sd * sd;
+        s = Q->p22 * Q->sa * cos(lamdp) * sqrt((1. + Q->t * sdsq)
+             / ((1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
+        lamdp = xy.x + xy.y * s / Q->xj - Q->a2 * sin(
+            2. * lamdp) - Q->a4 * sin(lamdp * 4.) - s / Q->xj * (
+            Q->c1 * sin(lamdp) + Q->c3 * sin(lamdp * 3.));
+        lamdp /= Q->b;
+    } while (fabs(lamdp - sav) >= TOL && --nn);
+    sl = sin(lamdp);
+    fac = exp(sqrt(1. + s * s / Q->xj / Q->xj) * (xy.y -
+        Q->c1 * sl - Q->c3 * sin(lamdp * 3.)));
+    phidp = 2. * (atan(fac) - M_FORTPI);
+    dd = sl * sl;
+    if (fabs(cos(lamdp)) < TOL)
+        lamdp -= TOL;
+    spp = sin(phidp);
+    sppsq = spp * spp;
+    lamt = atan(((1. - sppsq * P->rone_es) * tan(lamdp) *
+        Q->ca - spp * Q->sa * sqrt((1. + Q->q * dd) * (
+        1. - sppsq) - sppsq * Q->u) / cos(lamdp)) / (1. - sppsq
+        * (1. + Q->u)));
+    sl = lamt >= 0. ? 1. : -1.;
+    scl = cos(lamdp) >= 0. ? 1. : -1;
+    lamt -= M_HALFPI * (1. - scl) * sl;
+    lp.lam = lamt - Q->p22 * lamdp;
+    if (fabs(Q->sa) < TOL)
+        lp.phi = aasin(P->ctx,spp / sqrt(P->one_es * P->one_es + P->es * sppsq));
+    else
+        lp.phi = atan((tan(lamdp) * cos(lamt) - Q->ca * sin(lamt)) /
+            (P->one_es * Q->sa));
+    return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(lsat)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(lsat) {
     int land, path;
     double lam, alf, esc, ess;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    land = pj_param(P->ctx, P->params, "ilsat").i;
+    if (land <= 0 || land > 5) E_ERROR(-28);
+    path = pj_param(P->ctx, P->params, "ipath").i;
+    if (path <= 0 || path > (land <= 3 ? 251 : 233)) E_ERROR(-29);
+    if (land <= 3) {
+        P->lam0 = DEG_TO_RAD * 128.87 - M_TWOPI / 251. * path;
+        Q->p22 = 103.2669323;
+        alf = DEG_TO_RAD * 99.092;
+    } else {
+        P->lam0 = DEG_TO_RAD * 129.3 - M_TWOPI / 233. * path;
+        Q->p22 = 98.8841202;
+        alf = DEG_TO_RAD * 98.2;
+    }
+    Q->p22 /= 1440.;
+    Q->sa = sin(alf);
+    Q->ca = cos(alf);
+    if (fabs(Q->ca) < 1e-9)
+        Q->ca = 1e-9;
+    esc = P->es * Q->ca * Q->ca;
+    ess = P->es * Q->sa * Q->sa;
+    Q->w = (1. - esc) * P->rone_es;
+    Q->w = Q->w * Q->w - 1.;
+    Q->q = ess * P->rone_es;
+    Q->t = ess * (2. - P->es) * P->rone_es * P->rone_es;
+    Q->u = esc * P->rone_es;
+    Q->xj = P->one_es * P->one_es * P->one_es;
+    Q->rlm = M_PI * (1. / 248. + .5161290322580645);
+    Q->rlm2 = Q->rlm + M_TWOPI;
+    Q->a2 = Q->a4 = Q->b = Q->c1 = Q->c3 = 0.;
+    seraz0(0., 1., P);
+    for (lam = 9.; lam <= 81.0001; lam += 18.)
+        seraz0(lam, 4., P);
+    for (lam = 18; lam <= 72.0001; lam += 18.)
+        seraz0(lam, 2., P);
+    seraz0(90., 1., P);
+    Q->a2 /= 30.;
+    Q->a4 /= 60.;
+    Q->b /= 30.;
+    Q->c1 /= 15.;
+    Q->c3 /= 45.;
+
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_lsat_selftest (void) {return 0;}
+#else
+
+int pj_lsat_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=lsat +ellps=GRS80 +lat_1=0.5 +lat_2=2 +lsat=1 +path=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {18241950.01455855,    9998256.83982293494},
+        {18746856.2533194572, 10215761.669925211},
+        {18565503.6836331636,  9085039.14672705345},
+        {19019696.9020289108,  9247763.0394328218},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {126.000423834530011,  0.00172378224025701425},
+        {126.002213738256714,  0.00188015467480917966},
+        {126.000734468914601, -0.00188015467480917966},
+        {126.002524372641304, -0.00172378224025701425},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
+
 
-	land = pj_param(P->ctx, P->params, "ilsat").i;
-	if (land <= 0 || land > 5) E_ERROR(-28);
-	path = pj_param(P->ctx, P->params, "ipath").i;
-	if (path <= 0 || path > (land <= 3 ? 251 : 233)) E_ERROR(-29);
-	if (land <= 3) {
-		P->lam0 = DEG_TO_RAD * 128.87 - TWOPI / 251. * path;
-	    P->p22 = 103.2669323;
-	    alf = DEG_TO_RAD * 99.092;
-	} else {
-		P->lam0 = DEG_TO_RAD * 129.3 - TWOPI / 233. * path;
-	    P->p22 = 98.8841202;
-	    alf = DEG_TO_RAD * 98.2;
-	}
-	P->p22 /= 1440.;
-	P->sa = sin(alf);
-	P->ca = cos(alf);
-	if (fabs(P->ca) < 1e-9)
-	    P->ca = 1e-9;
-	esc = P->es * P->ca * P->ca;
-	ess = P->es * P->sa * P->sa;
-	P->w = (1. - esc) * P->rone_es;
-	P->w = P->w * P->w - 1.;
-	P->q = ess * P->rone_es;
-	P->t = ess * (2. - P->es) * P->rone_es * P->rone_es;
-	P->u = esc * P->rone_es;
-	P->xj = P->one_es * P->one_es * P->one_es;
-	P->rlm = PI * (1. / 248. + .5161290322580645);
-	P->rlm2 = P->rlm + TWOPI;
-    P->a2 = P->a4 = P->b = P->c1 = P->c3 = 0.;
-	seraz0(0., 1., P);
-	for (lam = 9.; lam <= 81.0001; lam += 18.)
-	    seraz0(lam, 4., P);
-	for (lam = 18; lam <= 72.0001; lam += 18.)
-	    seraz0(lam, 2., P);
-	seraz0(90., 1., P);
-	P->a2 /= 30.;
-	P->a4 /= 60.;
-	P->b /= 30.;
-	P->c1 /= 15.;
-	P->c3 /= 45.;
-	P->inv = e_inverse; P->fwd = e_forward;
-ENDENTRY(P)
+#endif
diff --git a/src/PJ_mbt_fps.c b/src/PJ_mbt_fps.c
index 3cd5e67..daa1555 100644
--- a/src/PJ_mbt_fps.c
+++ b/src/PJ_mbt_fps.c
@@ -1,39 +1,112 @@
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(mbt_fps, "McBryde-Thomas Flat-Pole Sine (No. 2)") "\n\tCyl., Sph.";
-#define MAX_ITER	10
-#define LOOP_TOL	1e-7
+
+#define MAX_ITER    10
+#define LOOP_TOL    1e-7
 #define C1 0.45503
 #define C2 1.36509
 #define C3 1.41546
 #define C_x 0.22248
 #define C_y 1.44492
 #define C1_2 0.33333333333333333333333333
-FORWARD(s_forward); /* spheroid */
-	double k, V, t;
-	int i;
-	(void) P;
-
-	k = C3 * sin(lp.phi);
-	for (i = MAX_ITER; i ; --i) {
-		t = lp.phi / C2;
-		lp.phi -= V = (C1 * sin(t) + sin(lp.phi) - k) /
-			(C1_2 * cos(t) + cos(lp.phi));
-		if (fabs(V) < LOOP_TOL)
-			break;
-	}
-	t = lp.phi / C2;
-	xy.x = C_x * lp.lam * (1. + 3. * cos(lp.phi)/cos(t) );
-	xy.y = C_y * sin(t);
-	return (xy);
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double k, V, t;
+    int i;
+    (void) P;
+
+    k = C3 * sin(lp.phi);
+    for (i = MAX_ITER; i ; --i) {
+        t = lp.phi / C2;
+        lp.phi -= V = (C1 * sin(t) + sin(lp.phi) - k) /
+            (C1_2 * cos(t) + cos(lp.phi));
+        if (fabs(V) < LOOP_TOL)
+            break;
+    }
+    t = lp.phi / C2;
+    xy.x = C_x * lp.lam * (1. + 3. * cos(lp.phi)/cos(t) );
+    xy.y = C_y * sin(t);
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	double t;
 
-	lp.phi = C2 * (t = aasin(P->ctx,xy.y / C_y));
-	lp.lam = xy.x / (C_x * (1. + 3. * cos(lp.phi)/cos(t)));
-	lp.phi = aasin(P->ctx,(C1 * sin(t) + sin(lp.phi)) / C3);
-	return (lp);
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double t;
+
+    lp.phi = C2 * (t = aasin(P->ctx,xy.y / C_y));
+    lp.lam = xy.x / (C_x * (1. + 3. * cos(lp.phi)/cos(t)));
+    lp.phi = aasin(P->ctx,(C1 * sin(t) + sin(lp.phi)) / C3);
+    return (lp);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(mbt_fps) P->es = 0; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(mbt_fps) {
+
+    P->es = 0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_mbt_fps_selftest (void) {return 0;}
+#else
+
+int pj_mbt_fps_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=mbt_fps   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 198798.176129849948,  125512.017254530627},
+        { 198798.176129849948, -125512.017254530627},
+        {-198798.176129849948,  125512.017254530627},
+        {-198798.176129849948, -125512.017254530627},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00201197086238270742,  0.000796711850174446003},
+        { 0.00201197086238270742, -0.000796711850174446003},
+        {-0.00201197086238270742,  0.000796711850174446003},
+        {-0.00201197086238270742, -0.000796711850174446003},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_mbtfpp.c b/src/PJ_mbtfpp.c
index 433d3c8..729c707 100644
--- a/src/PJ_mbtfpp.c
+++ b/src/PJ_mbtfpp.c
@@ -1,33 +1,114 @@
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
 PROJ_HEAD(mbtfpp, "McBride-Thomas Flat-Polar Parabolic") "\n\tCyl., Sph.";
-#define CS	.95257934441568037152
-#define FXC	.92582009977255146156
-#define FYC	3.40168025708304504493
-#define C23	.66666666666666666666
-#define C13	.33333333333333333333
-#define ONEEPS	1.0000001
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-	lp.phi = asin(CS * sin(lp.phi));
-	xy.x = FXC * lp.lam * (2. * cos(C23 * lp.phi) - 1.);
-	xy.y = FYC * sin(C13 * lp.phi);
-	return (xy);
+
+#define CS  .95257934441568037152
+#define FXC .92582009977255146156
+#define FYC 3.40168025708304504493
+#define C23 .66666666666666666666
+#define C13 .33333333333333333333
+#define ONEEPS  1.0000001
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+
+    lp.phi = asin(CS * sin(lp.phi));
+    xy.x = FXC * lp.lam * (2. * cos(C23 * lp.phi) - 1.);
+    xy.y = FYC * sin(C13 * lp.phi);
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	lp.phi = xy.y / FYC;
-	if (fabs(lp.phi) >= 1.) {
-		if (fabs(lp.phi) > ONEEPS)	I_ERROR
-		else	lp.phi = (lp.phi < 0.) ? -HALFPI : HALFPI;
-	} else
-		lp.phi = asin(lp.phi);
-	lp.lam = xy.x / ( FXC * (2. * cos(C23 * (lp.phi *= 3.)) - 1.) );
-	if (fabs(lp.phi = sin(lp.phi) / CS) >= 1.) {
-		if (fabs(lp.phi) > ONEEPS)	I_ERROR
-		else	lp.phi = (lp.phi < 0.) ? -HALFPI : HALFPI;
-	} else
-		lp.phi = asin(lp.phi);
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+
+    lp.phi = xy.y / FYC;
+    if (fabs(lp.phi) >= 1.) {
+        if (fabs(lp.phi) > ONEEPS)
+            I_ERROR
+        else
+            lp.phi = (lp.phi < 0.) ? -M_HALFPI : M_HALFPI;
+    } else
+        lp.phi = asin(lp.phi);
+
+    lp.lam = xy.x / ( FXC * (2. * cos(C23 * (lp.phi *= 3.)) - 1.) );
+    if (fabs(lp.phi = sin(lp.phi) / CS) >= 1.) {
+        if (fabs(lp.phi) > ONEEPS)
+            I_ERROR
+        else
+            lp.phi = (lp.phi < 0.) ? -M_HALFPI : M_HALFPI;
+    } else
+        lp.phi = asin(lp.phi);
+
+    return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(mbtfpp) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(mbtfpp) {
+
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_mbtfpp_selftest (void) {return 0;}
+#else
+
+int pj_mbtfpp_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=mbtfpp   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {206804.786929820373,  120649.762565792524},
+        {206804.786929820373,  -120649.762565792524},
+        {-206804.786929820373,  120649.762565792524},
+        {-206804.786929820373,  -120649.762565792524},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.00193395359462902698,  0.00082883725477665357},
+        {0.00193395359462902698,  -0.00082883725477665357},
+        {-0.00193395359462902698,  0.00082883725477665357},
+        {-0.00193395359462902698,  -0.00082883725477665357},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_mbtfpq.c b/src/PJ_mbtfpq.c
index 0d343fa..a1cc33c 100644
--- a/src/PJ_mbtfpq.c
+++ b/src/PJ_mbtfpq.c
@@ -1,48 +1,121 @@
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(mbtfpq, "McBryde-Thomas Flat-Polar Quartic") "\n\tCyl., Sph.";
-#define NITER	20
-#define EPS	1e-7
+
+#define NITER   20
+#define EPS 1e-7
 #define ONETOL 1.000001
-#define C	1.70710678118654752440
-#define RC	0.58578643762690495119
-#define FYC	1.87475828462269495505
-#define RYC	0.53340209679417701685
-#define FXC	0.31245971410378249250
-#define RXC	3.20041258076506210122
-FORWARD(s_forward); /* spheroid */
-	double th1, c;
-	int i;
-	(void) P;
-
-	c = C * sin(lp.phi);
-	for (i = NITER; i; --i) {
-		lp.phi -= th1 = (sin(.5*lp.phi) + sin(lp.phi) - c) /
-			(.5*cos(.5*lp.phi)  + cos(lp.phi));
-		if (fabs(th1) < EPS) break;
-	}
-	xy.x = FXC * lp.lam * (1.0 + 2. * cos(lp.phi)/cos(0.5 * lp.phi));
-	xy.y = FYC * sin(0.5 * lp.phi);
-	return (xy);
+#define C   1.70710678118654752440
+#define RC  0.58578643762690495119
+#define FYC 1.87475828462269495505
+#define RYC 0.53340209679417701685
+#define FXC 0.31245971410378249250
+#define RXC 3.20041258076506210122
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double th1, c;
+    int i;
+    (void) P;
+
+    c = C * sin(lp.phi);
+    for (i = NITER; i; --i) {
+        lp.phi -= th1 = (sin(.5*lp.phi) + sin(lp.phi) - c) /
+            (.5*cos(.5*lp.phi)  + cos(lp.phi));
+        if (fabs(th1) < EPS) break;
+    }
+    xy.x = FXC * lp.lam * (1.0 + 2. * cos(lp.phi)/cos(0.5 * lp.phi));
+    xy.y = FYC * sin(0.5 * lp.phi);
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double t;
+
+    lp.phi = RYC * xy.y;
+    if (fabs(lp.phi) > 1.) {
+        if (fabs(lp.phi) > ONETOL)  I_ERROR
+        else if (lp.phi < 0.) { t = -1.; lp.phi = -M_PI; }
+        else { t = 1.; lp.phi = M_PI; }
+    } else
+        lp.phi = 2. * asin(t = lp.phi);
+    lp.lam = RXC * xy.x / (1. + 2. * cos(lp.phi)/cos(0.5 * lp.phi));
+    lp.phi = RC * (t + sin(lp.phi));
+    if (fabs(lp.phi) > 1.)
+        if (fabs(lp.phi) > ONETOL)  I_ERROR
+        else            lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
+    else
+        lp.phi = asin(lp.phi);
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(s_inverse); /* spheroid */
-	double t;
-
-	lp.phi = RYC * xy.y;
-	if (fabs(lp.phi) > 1.) {
-		if (fabs(lp.phi) > ONETOL)	I_ERROR
-		else if (lp.phi < 0.) { t = -1.; lp.phi = -PI; }
-		else { t = 1.; lp.phi = PI; }
-	} else
-		lp.phi = 2. * asin(t = lp.phi);
-	lp.lam = RXC * xy.x / (1. + 2. * cos(lp.phi)/cos(0.5 * lp.phi));
-	lp.phi = RC * (t + sin(lp.phi));
-	if (fabs(lp.phi) > 1.)
-		if (fabs(lp.phi) > ONETOL)	I_ERROR
-		else			lp.phi = lp.phi < 0. ? -HALFPI : HALFPI;
-	else
-		lp.phi = asin(lp.phi);
-	return (lp);
+
+
+PJ *PROJECTION(mbtfpq) {
+
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(mbtfpq) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_mbtfpq_selftest (void) {return 0;}
+#else
+
+int pj_mbtfpq_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=mbtfpq   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 209391.854738393013,  119161.040199054827},
+        { 209391.854738393013, -119161.040199054827},
+        {-209391.854738393013,  119161.040199054827},
+        {-209391.854738393013, -119161.040199054827},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00191010555824111571,  0.000839185447792341723},
+        { 0.00191010555824111571, -0.000839185447792341723},
+        {-0.00191010555824111571,  0.000839185447792341723},
+        {-0.00191010555824111571, -0.000839185447792341723},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_merc.c b/src/PJ_merc.c
index 4b991c1..8318aa1 100644
--- a/src/PJ_merc.c
+++ b/src/PJ_merc.c
@@ -1,47 +1,134 @@
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(merc, "Mercator") "\n\tCyl, Sph&Ell\n\tlat_ts=";
+
 #define EPS10 1.e-10
-FORWARD(e_forward); /* ellipsoid */
-	if (fabs(fabs(lp.phi) - HALFPI) <= EPS10) F_ERROR;
-	xy.x = P->k0 * lp.lam;
-	xy.y = - P->k0 * log(pj_tsfn(lp.phi, sin(lp.phi), P->e));
-	return (xy);
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10)
+        F_ERROR;
+    xy.x = P->k0 * lp.lam;
+    xy.y = - P->k0 * log(pj_tsfn(lp.phi, sin(lp.phi), P->e));
+    return xy;
 }
-FORWARD(s_forward); /* spheroid */
-	if (fabs(fabs(lp.phi) - HALFPI) <= EPS10) F_ERROR;
-	xy.x = P->k0 * lp.lam;
-	xy.y = P->k0 * log(tan(FORTPI + .5 * lp.phi));
-	return (xy);
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10)
+        F_ERROR;
+    xy.x = P->k0 * lp.lam;
+    xy.y = P->k0 * log(tan(M_FORTPI + .5 * lp.phi));
+    return xy;
 }
-INVERSE(e_inverse); /* ellipsoid */
-	if ((lp.phi = pj_phi2(P->ctx, exp(- xy.y / P->k0), P->e)) == HUGE_VAL) I_ERROR;
-	lp.lam = xy.x / P->k0;
-	return (lp);
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    if ((lp.phi = pj_phi2(P->ctx, exp(- xy.y / P->k0), P->e)) == HUGE_VAL)
+        I_ERROR;
+    lp.lam = xy.x / P->k0;
+    return lp;
 }
-INVERSE(s_inverse); /* spheroid */
-	lp.phi = HALFPI - 2. * atan(exp(-xy.y / P->k0));
-	lp.lam = xy.x / P->k0;
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    lp.phi = M_HALFPI - 2. * atan(exp(-xy.y / P->k0));
+    lp.lam = xy.x / P->k0;
+    return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(merc)
-	double phits=0.0;
-	int is_phits;
-
-	if( (is_phits = pj_param(P->ctx, P->params, "tlat_ts").i) ) {
-		phits = fabs(pj_param(P->ctx, P->params, "rlat_ts").f);
-		if (phits >= HALFPI) E_ERROR(-24);
-	}
-	if (P->es) { /* ellipsoid */
-		if (is_phits)
-			P->k0 = pj_msfn(sin(phits), cos(phits), P->es);
-		P->inv = e_inverse;
-		P->fwd = e_forward;
-	} else { /* sphere */
-		if (is_phits)
-			P->k0 = cos(phits);
-		P->inv = s_inverse;
-		P->fwd = s_forward;
-	}
-ENDENTRY(P)
+
+
+static void freeup(PJ *P) {                             /* Destructor */
+    pj_dealloc(P);
+}
+
+
+PJ *PROJECTION(merc) {
+    double phits=0.0;
+    int is_phits;
+
+    if( (is_phits = pj_param(P->ctx, P->params, "tlat_ts").i) ) {
+        phits = fabs(pj_param(P->ctx, P->params, "rlat_ts").f);
+        if (phits >= M_HALFPI) E_ERROR(-24);
+    }
+
+    if (P->es) { /* ellipsoid */
+        if (is_phits)
+            P->k0 = pj_msfn(sin(phits), cos(phits), P->es);
+        P->inv = e_inverse;
+        P->fwd = e_forward;
+    }
+
+    else { /* sphere */
+        if (is_phits)
+            P->k0 = cos(phits);
+        P->inv = s_inverse;
+        P->fwd = s_forward;
+    }
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_merc_selftest (void) {return 0;}
+#else
+
+int pj_merc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=merc   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=merc   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222638.981586547132,  110579.965218249708},
+        { 222638.981586547132, -110579.965218249112},
+        {-222638.981586547132,  110579.965218249708},
+        {-222638.981586547132, -110579.965218249112},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223402.144255274179,  111706.743574944077},
+        { 223402.144255274179, -111706.743574944485},
+        {-223402.144255274179,  111706.743574944077},
+        {-223402.144255274179, -111706.743574944485},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.00179663056823904264,  0.00090436947522799056},
+        { 0.00179663056823904264, -0.00090436947522799056},
+        {-0.00179663056823904264,  0.00090436947522799056},
+        {-0.00179663056823904264,  -0.00090436947522799056},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179049310978382265,  0.000895246554845297135},
+        { 0.00179049310978382265, -0.000895246554858019272},
+        {-0.00179049310978382265,  0.000895246554845297135},
+        {-0.00179049310978382265, -0.000895246554858019272},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_mill.c b/src/PJ_mill.c
index c4cee7f..c4af4c5 100644
--- a/src/PJ_mill.c
+++ b/src/PJ_mill.c
@@ -1,17 +1,92 @@
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(mill, "Miller Cylindrical") "\n\tCyl, Sph";
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-	xy.x = lp.lam;
-	xy.y = log(tan(FORTPI + lp.phi * .4)) * 1.25;
-	return (xy);
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+
+    xy.x = lp.lam;
+    xy.y = log(tan(M_FORTPI + lp.phi * .4)) * 1.25;
+
+    return (xy);
 }
-INVERSE(s_inverse); /* spheroid */
-	(void) P;
-	lp.lam = xy.x;
-	lp.phi = 2.5 * (atan(exp(.8 * xy.y)) - FORTPI);
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    (void) P;
+
+    lp.lam = xy.x;
+    lp.phi = 2.5 * (atan(exp(.8 * xy.y)) - M_FORTPI);
+
+    return (lp);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(mill) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+   return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(mill) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_mill_selftest (void) {return 0;}
+#else
+
+int pj_mill_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=mill   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223402.144255274179,  111704.701754393827},
+        { 223402.144255274179, -111704.701754396243},
+        {-223402.144255274179,  111704.701754393827},
+        {-223402.144255274179, -111704.701754396243},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179049310978382265,  0.000895246554873922024},
+        { 0.00179049310978382265, -0.000895246554873922024},
+        {-0.00179049310978382265,  0.000895246554873922024},
+        {-0.00179049310978382265, -0.000895246554873922024},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_misrsom.c b/src/PJ_misrsom.c
new file mode 100644
index 0000000..412aa81
--- /dev/null
+++ b/src/PJ_misrsom.c
@@ -0,0 +1,281 @@
+/******************************************************************************
+ * This implements Space Oblique Mercator (SOM) projection, used by the
+ * Multi-angle Imaging SpectroRadiometer (MISR) products, from the NASA EOS Terra
+ * platform.
+ *
+ * The code is identical to that of Landsat SOM (PJ_lsat.c) with the following
+ * parameter changes:
+ *
+ *   inclination angle = 98.30382 degrees
+ *   period of revolution = 98.88 minutes
+ *   ascending longitude = 129.3056 degrees - (360 / 233) * path_number
+ *
+ * and the following code change:
+ *
+ *   Q->rlm = PI * (1. / 248. + .5161290322580645);
+ *
+ * changed to:
+ *
+ *   Q->rlm = 0
+ *
+ *****************************************************************************/
+/* based upon Snyder and Linck, USGS-NMD */
+#define PJ_LIB__
+#include <projects.h>
+
+PROJ_HEAD(misrsom, "Space oblique for MISR")
+        "\n\tCyl, Sph&Ell\n\tpath=";
+
+#define TOL 1e-7
+
+struct pj_opaque {
+    double a2, a4, b, c1, c3;
+    double q, t, u, w, p22, sa, ca, xj, rlm, rlm2;
+};
+
+static void seraz0(double lam, double mult, PJ *P) {
+    struct pj_opaque *Q = P->opaque;
+    double sdsq, h, s, fc, sd, sq, d__1;
+
+    lam *= DEG_TO_RAD;
+    sd = sin(lam);
+    sdsq = sd * sd;
+    s = Q->p22 * Q->sa * cos(lam) * sqrt((1. + Q->t * sdsq) / ((
+        1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
+    d__1 = 1. + Q->q * sdsq;
+    h = sqrt((1. + Q->q * sdsq) / (1. + Q->w * sdsq)) * ((1. +
+        Q->w * sdsq) / (d__1 * d__1) - Q->p22 * Q->ca);
+    sq = sqrt(Q->xj * Q->xj + s * s);
+    Q->b += fc = mult * (h * Q->xj - s * s) / sq;
+    Q->a2 += fc * cos(lam + lam);
+    Q->a4 += fc * cos(lam * 4.);
+    fc = mult * s * (h + Q->xj) / sq;
+    Q->c1 += fc * cos(lam);
+    Q->c3 += fc * cos(lam * 3.);
+}
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    int l, nn;
+    double lamt, xlam, sdsq, c, d, s, lamdp, phidp, lampp, tanph;
+    double lamtp, cl, sd, sp, fac, sav, tanphi;
+
+    if (lp.phi > M_HALFPI)
+        lp.phi = M_HALFPI;
+    else if (lp.phi < -M_HALFPI)
+        lp.phi = -M_HALFPI;
+    lampp = lp.phi >= 0. ? M_HALFPI : M_PI_HALFPI;
+    tanphi = tan(lp.phi);
+    for (nn = 0;;) {
+            sav = lampp;
+            lamtp = lp.lam + Q->p22 * lampp;
+            cl = cos(lamtp);
+            if (fabs(cl) < TOL)
+                lamtp -= TOL;
+            fac = lampp - sin(lampp) * (cl < 0. ? -M_HALFPI : M_HALFPI);
+            for (l = 50; l; --l) {
+                    lamt = lp.lam + Q->p22 * sav;
+                    if (fabs(c = cos(lamt)) < TOL)
+                        lamt -= TOL;
+                    xlam = (P->one_es * tanphi * Q->sa + sin(lamt) * Q->ca) / c;
+                    lamdp = atan(xlam) + fac;
+                    if (fabs(fabs(sav) - fabs(lamdp)) < TOL)
+                        break;
+                    sav = lamdp;
+            }
+            if (!l || ++nn >= 3 || (lamdp > Q->rlm && lamdp < Q->rlm2))
+                    break;
+            if (lamdp <= Q->rlm)
+                lampp = M_TWOPI_HALFPI;
+            else if (lamdp >= Q->rlm2)
+                lampp = M_HALFPI;
+    }
+    if (l) {
+            sp = sin(lp.phi);
+            phidp = aasin(P->ctx,(P->one_es * Q->ca * sp - Q->sa * cos(lp.phi) *
+                    sin(lamt)) / sqrt(1. - P->es * sp * sp));
+            tanph = log(tan(M_FORTPI + .5 * phidp));
+            sd = sin(lamdp);
+            sdsq = sd * sd;
+            s = Q->p22 * Q->sa * cos(lamdp) * sqrt((1. + Q->t * sdsq)
+                     / ((1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
+            d = sqrt(Q->xj * Q->xj + s * s);
+            xy.x = Q->b * lamdp + Q->a2 * sin(2. * lamdp) + Q->a4 *
+                    sin(lamdp * 4.) - tanph * s / d;
+            xy.y = Q->c1 * sd + Q->c3 * sin(lamdp * 3.) + tanph * Q->xj / d;
+    } else
+            xy.x = xy.y = HUGE_VAL;
+    return xy;
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    int nn;
+    double lamt, sdsq, s, lamdp, phidp, sppsq, dd, sd, sl, fac, scl, sav, spp;
+
+    lamdp = xy.x / Q->b;
+    nn = 50;
+    do {
+        sav = lamdp;
+        sd = sin(lamdp);
+        sdsq = sd * sd;
+        s = Q->p22 * Q->sa * cos(lamdp) * sqrt((1. + Q->t * sdsq)
+                 / ((1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
+        lamdp = xy.x + xy.y * s / Q->xj - Q->a2 * sin(
+                2. * lamdp) - Q->a4 * sin(lamdp * 4.) - s / Q->xj * (
+                Q->c1 * sin(lamdp) + Q->c3 * sin(lamdp * 3.));
+        lamdp /= Q->b;
+    } while (fabs(lamdp - sav) >= TOL && --nn);
+    sl = sin(lamdp);
+    fac = exp(sqrt(1. + s * s / Q->xj / Q->xj) * (xy.y -
+            Q->c1 * sl - Q->c3 * sin(lamdp * 3.)));
+    phidp = 2. * (atan(fac) - M_FORTPI);
+    dd = sl * sl;
+    if (fabs(cos(lamdp)) < TOL)
+        lamdp -= TOL;
+    spp = sin(phidp);
+    sppsq = spp * spp;
+    lamt = atan(((1. - sppsq * P->rone_es) * tan(lamdp) *
+            Q->ca - spp * Q->sa * sqrt((1. + Q->q * dd) * (
+            1. - sppsq) - sppsq * Q->u) / cos(lamdp)) / (1. - sppsq
+            * (1. + Q->u)));
+    sl = lamt >= 0. ? 1. : -1.;
+    scl = cos(lamdp) >= 0. ? 1. : -1;
+    lamt -= M_HALFPI * (1. - scl) * sl;
+    lp.lam = lamt - Q->p22 * lamdp;
+    if (fabs(Q->sa) < TOL)
+        lp.phi = aasin(P->ctx,spp / sqrt(P->one_es * P->one_es + P->es * sppsq));
+    else
+        lp.phi = atan((tan(lamdp) * cos(lamt) - Q->ca * sin(lamt)) /
+                (P->one_es * Q->sa));
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(misrsom) {
+    int path;
+    double lam, alf, esc, ess;
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    path = pj_param(P->ctx, P->params, "ipath").i;
+    if (path <= 0 || path > 233) E_ERROR(-29);
+    P->lam0 = DEG_TO_RAD * 129.3056 - M_TWOPI / 233. * path;
+    alf = 98.30382 * DEG_TO_RAD;
+    Q->p22 = 98.88 / 1440.0;
+
+    Q->sa = sin(alf);
+    Q->ca = cos(alf);
+    if (fabs(Q->ca) < 1e-9)
+        Q->ca = 1e-9;
+    esc = P->es * Q->ca * Q->ca;
+    ess = P->es * Q->sa * Q->sa;
+    Q->w = (1. - esc) * P->rone_es;
+    Q->w = Q->w * Q->w - 1.;
+    Q->q = ess * P->rone_es;
+    Q->t = ess * (2. - P->es) * P->rone_es * P->rone_es;
+    Q->u = esc * P->rone_es;
+    Q->xj = P->one_es * P->one_es * P->one_es;
+    Q->rlm = 0;
+    Q->rlm2 = Q->rlm + M_TWOPI;
+    Q->a2 = Q->a4 = Q->b = Q->c1 = Q->c3 = 0.;
+    seraz0(0., 1., P);
+    for (lam = 9.; lam <= 81.0001; lam += 18.)
+        seraz0(lam, 4., P);
+    for (lam = 18; lam <= 72.0001; lam += 18.)
+        seraz0(lam, 2., P);
+    seraz0(90., 1., P);
+    Q->a2 /= 30.;
+    Q->a4 /= 60.;
+    Q->b /= 30.;
+    Q->c1 /= 15.;
+    Q->c3 /= 45.;
+
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+
+   return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_misrsom_selftest (void) {return 0;}
+#else
+
+int pj_misrsom_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=misrsom   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +path=1"};
+    char s_args[] = {"+proj=misrsom   +a=6400000    +lat_1=0.5 +lat_2=2 +path=1"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {18556630.3683698252, 9533394.6753112711},
+        {19041866.0067297369, 9707182.17532352544},
+        {18816810.1301847994, 8647669.64980295487},
+        {19252610.7845367305, 8778164.08580140397},
+    };
+
+    XY s_fwd_expect[] = {
+        {18641249.2791703865, 9563342.53233416565},
+        {19130982.4615812786, 9739539.59350463562},
+        {18903483.5150115378, 8675064.50061797537},
+        {19343388.3998006098, 8807471.90406848863},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {127.759503987730625,  0.00173515039622462014},
+        {127.761295471077958,  0.00187196632421706517},
+        {127.759775773557251, -0.00187196632421891525},
+        {127.76156725690457,  -0.00173515039622462014},
+    };
+
+    LP s_inv_expect[] = {
+        {127.75950514818588,   0.00171623111593511971},
+        {127.761290323778738,  0.00185412132880796244},
+        {127.759780920856471, -0.00185412132880796244},
+        {127.761566096449329, -0.00171623111593511971},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_mod_ster.c b/src/PJ_mod_ster.c
index 185e95e..f4f3d9d 100644
--- a/src/PJ_mod_ster.c
+++ b/src/PJ_mod_ster.c
@@ -1,211 +1,541 @@
 /* based upon Snyder and Linck, USGS-NMD */
-#define PROJ_PARMS__ \
-    COMPLEX	*zcoeff; \
-	double	cchio, schio; \
-	int		n;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(mil_os, "Miller Oblated Stereographic") "\n\tAzi(mod)";
 PROJ_HEAD(lee_os, "Lee Oblated Stereographic") "\n\tAzi(mod)";
-PROJ_HEAD(gs48, "Mod. Stererographics of 48 U.S.") "\n\tAzi(mod)";
-PROJ_HEAD(alsk, "Mod. Stererographics of Alaska") "\n\tAzi(mod)";
-PROJ_HEAD(gs50, "Mod. Stererographics of 50 U.S.") "\n\tAzi(mod)";
-#define EPSLN 1e-10
-
-FORWARD(e_forward); /* ellipsoid */
-	double sinlon, coslon, esphi, chi, schi, cchi, s;
-	COMPLEX p;
-
-	sinlon = sin(lp.lam);
-	coslon = cos(lp.lam);
-	esphi = P->e * sin(lp.phi);
-	chi = 2. * atan(tan((HALFPI + lp.phi) * .5) *
-		pow((1. - esphi) / (1. + esphi), P->e * .5)) - HALFPI;
-	schi = sin(chi);
-	cchi = cos(chi);
-	s = 2. / (1. + P->schio * schi + P->cchio * cchi * coslon);
-	p.r = s * cchi * sinlon;
-	p.i = s * (P->cchio * schi - P->schio * cchi * coslon);
-	p = pj_zpoly1(p, P->zcoeff, P->n);
-	xy.x = p.r;
-	xy.y = p.i;
-	return xy;
+PROJ_HEAD(gs48, "Mod. Stereographic of 48 U.S.") "\n\tAzi(mod)";
+PROJ_HEAD(alsk, "Mod. Stereographic of Alaska") "\n\tAzi(mod)";
+PROJ_HEAD(gs50, "Mod. Stereographic of 50 U.S.") "\n\tAzi(mod)";
+
+#define EPSLN 1e-12
+
+struct pj_opaque {
+    COMPLEX *zcoeff; \
+    double  cchio, schio; \
+    int     n;
+};
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double sinlon, coslon, esphi, chi, schi, cchi, s;
+    COMPLEX p;
+
+    sinlon = sin(lp.lam);
+    coslon = cos(lp.lam);
+    esphi = P->e * sin(lp.phi);
+    chi = 2. * atan(tan((M_HALFPI + lp.phi) * .5) *
+        pow((1. - esphi) / (1. + esphi), P->e * .5)) - M_HALFPI;
+    schi = sin(chi);
+    cchi = cos(chi);
+    s = 2. / (1. + Q->schio * schi + Q->cchio * cchi * coslon);
+    p.r = s * cchi * sinlon;
+    p.i = s * (Q->cchio * schi - Q->schio * cchi * coslon);
+    p = pj_zpoly1(p, Q->zcoeff, Q->n);
+    xy.x = p.r;
+    xy.y = p.i;
+
+    return xy;
 }
-INVERSE(e_inverse); /* ellipsoid */
-	int nn;
-	COMPLEX p, fxy, fpxy, dp;
-	double den, rh, z, sinz, cosz, chi, phi, dphi, esphi;
-
-	p.r = xy.x;
-	p.i = xy.y;
-	for (nn = 20; nn ;--nn) {
-		fxy = pj_zpolyd1(p, P->zcoeff, P->n, &fpxy);
-		fxy.r -= xy.x;
-		fxy.i -= xy.y;
-		den = fpxy.r * fpxy.r + fpxy.i * fpxy.i;
-		dp.r = -(fxy.r * fpxy.r + fxy.i * fpxy.i) / den;
-		dp.i = -(fxy.i * fpxy.r - fxy.r * fpxy.i) / den;
-		p.r += dp.r;
-		p.i += dp.i;
-		if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
-			break;
-	}
-	if (nn) {
-		rh = hypot(p.r, p.i);
-		z = 2. * atan(.5 * rh);
-		sinz = sin(z);
-		cosz = cos(z);
-		lp.lam = P->lam0;
-		if (fabs(rh) <= EPSLN) {
-			lp.phi = P->phi0;
-			return lp;
-		}
-		chi = aasin(P->ctx, cosz * P->schio + p.i * sinz * P->cchio / rh);
-		phi = chi;
-		for (nn = 20; nn ;--nn) {
-			esphi = P->e * sin(phi);
-			dphi = 2. * atan(tan((HALFPI + chi) * .5) *
-				pow((1. + esphi) / (1. - esphi), P->e * .5)) - HALFPI - phi;
-			phi += dphi;
-			if (fabs(dphi) <= EPSLN)
-				break;
-		}
-	}
-	if (nn) {
-		lp.phi = phi;
-		lp.lam = atan2(p.r * sinz, rh * P->cchio * cosz - p.i * 
-			P->schio * sinz);
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    int nn;
+    COMPLEX p, fxy, fpxy, dp;
+    double den, rh, z, sinz, cosz, chi, phi, dphi, esphi;
+
+    p.r = xy.x;
+    p.i = xy.y;
+    for (nn = 20; nn ;--nn) {
+        fxy = pj_zpolyd1(p, Q->zcoeff, Q->n, &fpxy);
+        fxy.r -= xy.x;
+        fxy.i -= xy.y;
+        den = fpxy.r * fpxy.r + fpxy.i * fpxy.i;
+        dp.r = -(fxy.r * fpxy.r + fxy.i * fpxy.i) / den;
+        dp.i = -(fxy.i * fpxy.r - fxy.r * fpxy.i) / den;
+        p.r += dp.r;
+        p.i += dp.i;
+        if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
+            break;
+    }
+    if (nn) {
+        rh = hypot(p.r, p.i);
+        z = 2. * atan(.5 * rh);
+        sinz = sin(z);
+        cosz = cos(z);
+        lp.lam = P->lam0;
+        if (fabs(rh) <= EPSLN) {
+            lp.phi = P->phi0;
+            return lp;
+        }
+        chi = aasin(P->ctx, cosz * Q->schio + p.i * sinz * Q->cchio / rh);
+        phi = chi;
+        for (nn = 20; nn ;--nn) {
+            esphi = P->e * sin(phi);
+            dphi = 2. * atan(tan((M_HALFPI + chi) * .5) *
+                pow((1. + esphi) / (1. - esphi), P->e * .5)) - M_HALFPI - phi;
+            phi += dphi;
+            if (fabs(dphi) <= EPSLN)
+                break;
+        }
+    }
+    if (nn) {
+        lp.phi = phi;
+        lp.lam = atan2(p.r * sinz, rh * Q->cchio * cosz - p.i *
+            Q->schio * sinz);
     } else
-		lp.lam = lp.phi = HUGE_VAL;
-	return lp;
+        lp.lam = lp.phi = HUGE_VAL;
+    return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) { /* general initialization */
-	double esphi, chio;
-
-	if (P->es) {
-		esphi = P->e * sin(P->phi0);
-		chio = 2. * atan(tan((HALFPI + P->phi0) * .5) *
-			pow((1. - esphi) / (1. + esphi), P->e * .5)) - HALFPI;
-	} else
-		chio = P->phi0;
-	P->schio = sin(chio);
-	P->cchio = cos(chio);
-	P->inv = e_inverse; P->fwd = e_forward;
-	return P;
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-ENTRY0(mil_os)
-	static COMPLEX /* Miller Oblated Stereographic */
-AB[] = {
-	{0.924500,	0.},
-	{0.,			0.},
-	{0.019430,	0.}
-};
 
-	P->n = 2;
-	P->lam0 = DEG_TO_RAD * 20.;
-	P->phi0 = DEG_TO_RAD * 18.;
-	P->zcoeff = AB;
-	P->es = 0.;
-ENDENTRY(setup(P))
-ENTRY0(lee_os)
-	static COMPLEX /* Lee Oblated Stereographic */
-AB[] = {
-	{0.721316,	0.},
-	{0.,			0.},
-        {-0.0088162,	 -0.00617325}
-};
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
 
-	P->n = 2;
-	P->lam0 = DEG_TO_RAD * -165.;
-	P->phi0 = DEG_TO_RAD * -10.;
-	P->zcoeff = AB;
-	P->es = 0.;
-ENDENTRY(setup(P))
-ENTRY0(gs48)
-	static COMPLEX /* 48 United States */
-AB[] = {
-	{0.98879,	0.},
-	{0.,		0.},
-	{-0.050909,	0.},
-	{0.,		0.},
-        {0.075528,	0.}
-};
+static PJ *setup(PJ *P) { /* general initialization */
+    struct pj_opaque *Q = P->opaque;
+    double esphi, chio;
 
-	P->n = 4;
-	P->lam0 = DEG_TO_RAD * -96.;
-	P->phi0 = DEG_TO_RAD * -39.;
-	P->zcoeff = AB;
-	P->es = 0.;
-	P->a = 6370997.;
-ENDENTRY(setup(P))
-ENTRY0(alsk)
-	static COMPLEX
-ABe[] = { /* Alaska ellipsoid */
-	{.9945303,	0.},
-	{.0052083,	-.0027404},
-	{.0072721,	.0048181},
-	{-.0151089,	-.1932526},
-	{.0642675,	-.1381226},
-	{.3582802,	-.2884586}},
-ABs[] = { /* Alaska sphere */
-	{.9972523,	0.},
-	{.0052513,	-.0041175},
-	{.0074606,	.0048125},
-	{-.0153783,	-.1968253},
-	{.0636871,	-.1408027},
-        {.3660976,	-.2937382}
-};
+    if (P->es) {
+        esphi = P->e * sin(P->phi0);
+        chio = 2. * atan(tan((M_HALFPI + P->phi0) * .5) *
+            pow((1. - esphi) / (1. + esphi), P->e * .5)) - M_HALFPI;
+    } else
+        chio = P->phi0;
+    Q->schio = sin(chio);
+    Q->cchio = cos(chio);
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+
+    return P;
+}
+
+
+/* Miller Oblated Stereographic */
+PJ *PROJECTION(mil_os) {
+    static COMPLEX AB[] = {
+        {0.924500, 0.},
+        {0.,       0.},
+        {0.019430, 0.}
+    };
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->n = 2;
+    P->lam0 = DEG_TO_RAD * 20.;
+    P->phi0 = DEG_TO_RAD * 18.;
+    Q->zcoeff = AB;
+    P->es = 0.;
+
+    return setup(P);
+}
+
+
+/* Lee Oblated Stereographic */
+PJ *PROJECTION(lee_os) {
+    static COMPLEX AB[] = {
+        {0.721316,    0.},
+        {0.,          0.},
+        {-0.0088162, -0.00617325}
+    };
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->n = 2;
+    P->lam0 = DEG_TO_RAD * -165.;
+    P->phi0 = DEG_TO_RAD * -10.;
+    Q->zcoeff = AB;
+    P->es = 0.;
+
+   return setup(P);
+}
+
+
+PJ *PROJECTION(gs48) {
+    static COMPLEX /* 48 United States */
+    AB[] = {
+        {0.98879,   0.},
+        {0.,        0.},
+        {-0.050909, 0.},
+        {0.,        0.},
+        {0.075528,  0.}
+    };
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->n = 4;
+    P->lam0 = DEG_TO_RAD * -96.;
+    P->phi0 = DEG_TO_RAD * -39.;
+    Q->zcoeff = AB;
+    P->es = 0.;
+    P->a = 6370997.;
+
+    return setup(P);
+}
+
+
+PJ *PROJECTION(alsk) {
+    static COMPLEX  ABe[] = { /* Alaska ellipsoid */
+        { .9945303, 0.},
+        { .0052083, -.0027404},
+        { .0072721,  .0048181},
+        {-.0151089, -.1932526},
+        { .0642675, -.1381226},
+        { .3582802, -.2884586},
+    };
+
+    static COMPLEX ABs[] = { /* Alaska sphere */
+        { .9972523, 0.},
+        { .0052513, -.0041175},
+        { .0074606,  .0048125},
+        {-.0153783, -.1968253},
+        { .0636871, -.1408027},
+        { .3660976, -.2937382}
+    };
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->n = 5;
+    P->lam0 = DEG_TO_RAD * -152.;
+    P->phi0 = DEG_TO_RAD * 64.;
+    if (P->es) { /* fixed ellipsoid/sphere */
+        Q->zcoeff = ABe;
+        P->a = 6378206.4;
+        P->e = sqrt(P->es = 0.00676866);
+    } else {
+        Q->zcoeff = ABs;
+        P->a = 6370997.;
+    }
+
+    return setup(P);
+}
+
+
+PJ *PROJECTION(gs50) {
+    static COMPLEX  ABe[] = { /* GS50 ellipsoid */
+        { .9827497, 0.},
+        { .0210669,  .0053804},
+        {-.1031415, -.0571664},
+        {-.0323337, -.0322847},
+        { .0502303,  .1211983},
+        { .0251805,  .0895678},
+        {-.0012315, -.1416121},
+        { .0072202, -.1317091},
+        {-.0194029,  .0759677},
+        {-.0210072,  .0834037}
+    };
+
+    static COMPLEX ABs[] = { /* GS50 sphere */
+        { .9842990, 0.},
+        { .0211642,  .0037608},
+        {-.1036018, -.0575102},
+        {-.0329095, -.0320119},
+        { .0499471,  .1223335},
+        { .0260460,  .0899805},
+        { .0007388, -.1435792},
+        { .0075848, -.1334108},
+        {-.0216473,  .0776645},
+        {-.0225161,  .0853673}
+    };
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->n = 9;
+    P->lam0 = DEG_TO_RAD * -120.;
+    P->phi0 = DEG_TO_RAD * 45.;
+    if (P->es) { /* fixed ellipsoid/sphere */
+        Q->zcoeff = ABe;
+        P->a = 6378206.4;
+        P->e = sqrt(P->es = 0.00676866);
+    } else {
+        Q->zcoeff = ABs;
+        P->a = 6370997.;
+    }
+
+    return setup(P);
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_mil_os_selftest (void) {return 0;}
+#else
+
+int pj_mil_os_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=mil_os   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {-1908527.94959420455, -1726237.4730614475},
+        {-1916673.02291848511, -1943133.88812552323},
+        {-2344429.41208962305, -1706258.05121891224},
+        {-2354637.83553299867, -1926468.60513541684},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {20.0020363939492398, 18.0009683469140498},
+        {20.0020363715837419, 17.999031631815086},
+        {19.9979636060507602, 18.0009683469140498},
+        {19.9979636284162581, 17.999031631815086},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_lee_os_selftest (void) {return 0;}
+#else
+
+int pj_lee_os_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=lee_os   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {-25564478.9526050538, 154490848.8286255},
+        { 30115393.9385746419, 125193997.439701974},
+        {-31039340.5921660066,  57678685.0448915437},
+        {-3088419.93942357088,  58150091.0991110131},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {-164.997479457813824,  -9.99875886103541411},
+        {-164.997479438558884, -10.0012411200022751},
+        {-165.002520542186289,  -9.99875886103545142},
+        {-165.002520561440946, -10.0012411200022999},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_gs48_selftest (void) {return 0;}
+#else
+
+int pj_gs48_selftest (void) {
+    double tolerance_lp = 1e-12;
+    double tolerance_xy = 1e-8;
+
+    char s_args[] = {"+proj=gs48 +a=6370997"};
+
+    /* All latitudes and longitudes within the continental US */
+    LP fwd_in[] = {
+        { -119.0, 40.0},
+        {  -70.0, 64.0},
+        {  -80.0, 25.0},
+        {  -95.0, 35.0}
+    };
+
+    XY s_fwd_expect[] = {
+        {-12110635.970867658000, 11668127.145744404000},
+        { 55440975.381938063000, 52147696.705027729000},
+        {  4451809.270766614000,  8613528.123849634100},
+        {   468857.625827528540, 14336668.749030361000},
+    };
+
+    XY inv_in[] = {
+        {-11980000.0, 11570000.0},
+        {  5500000.0, 52000000.0},
+        {  4400000.0, 8600000.0},
+        {   460000.0, 14000000.0},
+    };
+
+    LP s_inv_expect[] = {
+        {-119.003821215898, 39.801671381755},
+        { -92.805621432558, 59.836947814918},
+        { -80.122548940303, 24.869675983950},
+        { -94.990474496482, 34.401182359832},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_alsk_selftest (void) {return 0;}
+#else
+
+int pj_alsk_selftest (void) {
+
+    /* The standard test points are way outside the definition area bounds, hence we relax tolerances */
+    double tolerance_lp = 1e-12;
+    double tolerance_xy = 1e-8;
+
+    char e_args[] = {"+proj=alsk +ellps=clrk66"};
+    char s_args[] = {"+proj=alsk +a=6370997"};
+
+    LP fwd_in[] = {
+        {-160.0, 55.0},
+        {-160.0, 70.0},
+        {-145.0, 70.0},
+        {-145.0, 60.0}
+    };
+
+    XY e_fwd_expect[] = {
+        {-513253.146950842060, -968928.031867943470},
+        {-305001.133897637190,  687494.464958650530},
+        {266454.305088600490,   683423.477493030950},
+        {389141.322439243960,  -423913.251230396680},
+    };
+
+    XY s_fwd_expect[] = {
+        {-511510.319410844070, -967150.991676078060},
+        {-303744.771290368980,  685439.745941123230},
+        {265354.974019662940,   681386.892874573010},
+        {387711.995394026630,  -422980.685505462640},
+    };
+
+    XY inv_in[] = {
+        {-500000.0, -950000.0},
+        {-305000.0,  700000.0},
+        { 250000.0,  700000.0},
+        { 400000.0, -400000.0}
+    };
+
+    LP e_inv_expect[] = {
+        {-159.830804302926, 55.183195262220},
+        {-160.042203155537, 70.111086864056},
+        {-145.381043551466, 70.163900908411},
+        {-144.758985461448, 60.202929200739},
+    };
+
+    LP s_inv_expect[] = {
+        {-159.854014457557, 55.165653849074},
+        {-160.082332371601, 70.128307617632},
+        {-145.347827407243, 70.181566919011},
+        {-144.734239827146, 60.193564732505},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_gs50_selftest (void) {return 0;}
+#else
+
+int pj_gs50_selftest (void) {
+    double tolerance_lp = 1e-12;
+    double tolerance_xy = 1e-8;
+
+    char e_args[] = {"+proj=gs50 +ellps=clrk66"};
+    char s_args[] = {"+proj=gs50 +a=6370997"};
+
+    LP fwd_in[] = {
+        {-160.0, 65.0},
+        {-130.0, 45.0},
+        { -65.0, 45.0},
+        { -80.0, 36.0},
+    };
+
+    XY e_fwd_expect[] = {
+        {-1874628.5377402329,   2660907.942291015300},
+        { -771831.51885333552,    48465.166491304852},
+        { 4030931.8339815089,   1323687.864777399200},
+        { 3450764.2615361013,   -175619.041820732440},
+    };
+
+    XY s_fwd_expect[] = {
+        {-1867268.2534600089,   2656506.230401823300},
+        { -769572.18967299373,    48324.312440863941},
+        { 4019393.068680791200, 1320191.309350289200},
+        { 3442685.615172345700, -178760.423489428680},
+    };
+
+    XY inv_in[] = {
+        {-1800000.0, 2600000.0},
+        { -800000.0,  500000.0},
+        { 4000000.0, 1300000.0},
+        { 3900000.0, -170000.0},
+    };
+
+    LP e_inv_expect[] = {
+        {-157.989284999679, 64.851559609698},
+        {-131.171390466814, 49.084969745967},
+        { -65.491568685301, 44.992837923774},
+        { -75.550660091101, 34.191114075743},
+    };
+
+    LP s_inv_expect[] = {
+        {-158.163295044933, 64.854288364994},
+        {-131.206816959506, 49.082915350974},
+        { -65.348945220767, 44.957292681774},
+        { -75.446820242089, 34.185406225616},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
 
-	P->n = 5;
-	P->lam0 = DEG_TO_RAD * -152.;
-	P->phi0 = DEG_TO_RAD * 64.;
-	if (P->es) { /* fixed ellipsoid/sphere */
-		P->zcoeff = ABe;
-		P->a = 6378206.4;
-		P->e = sqrt(P->es = 0.00676866);
-	} else {
-		P->zcoeff = ABs;
-		P->a = 6370997.;
-	}
-ENDENTRY(setup(P))
-ENTRY0(gs50)
-	static COMPLEX
-ABe[] = { /* GS50 ellipsoid */
-	{.9827497,	0.},
-	{.0210669,	.0053804},
-	{-.1031415,	-.0571664},
-	{-.0323337,	-.0322847},
-	{.0502303,	.1211983},
-	{.0251805,	.0895678},
-	{-.0012315,	-.1416121},
-	{.0072202,	-.1317091},
-	{-.0194029,	.0759677},
-        {-.0210072,	.0834037}
-},
-ABs[] = { /* GS50 sphere */
-	{.9842990,	0.},
-	{.0211642,	.0037608},
-	{-.1036018,	-.0575102},
-	{-.0329095,	-.0320119},
-	{.0499471,	.1223335},
-	{.0260460,	.0899805},
-	{.0007388,	-.1435792},
-	{.0075848,	-.1334108},
-	{-.0216473,	.0776645},
-        {-.0225161,	.0853673}
-};
 
-	P->n = 9;
-	P->lam0 = DEG_TO_RAD * -120.;
-	P->phi0 = DEG_TO_RAD * 45.;
-	if (P->es) { /* fixed ellipsoid/sphere */
-		P->zcoeff = ABe;
-		P->a = 6378206.4;
-		P->e = sqrt(P->es = 0.00676866);
-	} else {
-		P->zcoeff = ABs;
-		P->a = 6370997.;
-	}
-ENDENTRY(setup(P))
+#endif
diff --git a/src/PJ_moll.c b/src/PJ_moll.c
index cf9369d..2a65108 100644
--- a/src/PJ_moll.c
+++ b/src/PJ_moll.c
@@ -1,64 +1,259 @@
-#define PROJ_PARMS__ \
-	double	C_x, C_y, C_p;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(moll, "Mollweide") "\n\tPCyl., Sph.";
 PROJ_HEAD(wag4, "Wagner IV") "\n\tPCyl., Sph.";
 PROJ_HEAD(wag5, "Wagner V") "\n\tPCyl., Sph.";
-#define MAX_ITER	10
-#define LOOP_TOL	1e-7
-FORWARD(s_forward); /* spheroid */
-	double k, V;
-	int i;
-
-	k = P->C_p * sin(lp.phi);
-	for (i = MAX_ITER; i ; --i) {
-		lp.phi -= V = (lp.phi + sin(lp.phi) - k) /
-			(1. + cos(lp.phi));
-		if (fabs(V) < LOOP_TOL)
-			break;
-	}
-	if (!i)
-		lp.phi = (lp.phi < 0.) ? -HALFPI : HALFPI;
-	else
-		lp.phi *= 0.5;
-	xy.x = P->C_x * lp.lam * cos(lp.phi);
-	xy.y = P->C_y * sin(lp.phi);
-	return (xy);
+
+#define MAX_ITER    10
+#define LOOP_TOL    1e-7
+
+struct pj_opaque {
+    double  C_x, C_y, C_p;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double k, V;
+    int i;
+
+    k = Q->C_p * sin(lp.phi);
+    for (i = MAX_ITER; i ; --i) {
+        lp.phi -= V = (lp.phi + sin(lp.phi) - k) /
+            (1. + cos(lp.phi));
+        if (fabs(V) < LOOP_TOL)
+            break;
+    }
+    if (!i)
+        lp.phi = (lp.phi < 0.) ? -M_HALFPI : M_HALFPI;
+    else
+        lp.phi *= 0.5;
+    xy.x = Q->C_x * lp.lam * cos(lp.phi);
+    xy.y = Q->C_y * sin(lp.phi);
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	lp.phi = aasin(P->ctx, xy.y / P->C_y);
-	lp.lam = xy.x / (P->C_x * cos(lp.phi));
-        if (fabs(lp.lam) < PI) {
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    lp.phi = aasin(P->ctx, xy.y / Q->C_y);
+    lp.lam = xy.x / (Q->C_x * cos(lp.phi));
+        if (fabs(lp.lam) < M_PI) {
             lp.phi += lp.phi;
-            lp.phi = aasin(P->ctx, (lp.phi + sin(lp.phi)) / P->C_p);
+            lp.phi = aasin(P->ctx, (lp.phi + sin(lp.phi)) / Q->C_p);
         } else {
             lp.lam = lp.phi = HUGE_VAL;
         }
-	return (lp);
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+static PJ * setup(PJ *P, double p) {
+    struct pj_opaque *Q = P->opaque;
+    double r, sp, p2 = p + p;
+
+    P->es = 0;
+    sp = sin(p);
+    r = sqrt(M_TWOPI * sp / (p2 + sin(p2)));
+
+    Q->C_x = 2. * r / M_PI;
+    Q->C_y = r / sp;
+    Q->C_p = p2 + sin(p2);
+
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    return P;
+}
+
+
+PJ *PROJECTION(moll) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    return setup(P, M_HALFPI);
+}
+
+
+PJ *PROJECTION(wag4) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    return setup(P, M_PI/3.);
+}
+
+PJ *PROJECTION(wag5) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    P->es = 0;
+    Q->C_x = 0.90977;
+    Q->C_y = 1.65014;
+    Q->C_p = 3.00896;
+
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_moll_selftest (void) {return 0;}
+#else
+
+int pj_moll_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=moll   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {201113.698641813244,  124066.283433859542},
+        {201113.698641813244,  -124066.283433859542},
+        {-201113.698641813244,  124066.283433859542},
+        {-201113.698641813244,  -124066.283433859542},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.00198873782220854774,  0.000806005080362811612},
+        {0.00198873782220854774,  -0.000806005080362811612},
+        {-0.00198873782220854774,  0.000806005080362811612},
+        {-0.00198873782220854774,  -0.000806005080362811612},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
 }
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P, double p) {
-	double r, sp, p2 = p + p;
-
-	P->es = 0;
-	sp = sin(p);
-	r = sqrt(TWOPI * sp / (p2 + sin(p2)));
-	P->C_x = 2. * r / PI;
-	P->C_y = r / sp;
-	P->C_p = p2 + sin(p2);
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-	return P;
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_wag4_selftest (void) {return 0;}
+#else
+
+int pj_wag4_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=wag4   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 192801.218662384286,  129416.216394802992},
+        { 192801.218662384286, -129416.216394802992},
+        {-192801.218662384286,  129416.216394802992},
+        {-192801.218662384286, -129416.216394802992},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00207450259783523421, 0.000772682950537716476},
+        { 0.00207450259783523421, -0.000772682950537716476},
+        {-0.00207450259783523421,  0.000772682950537716476},
+        {-0.00207450259783523421, -0.000772682950537716476},
+   };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
 }
-ENTRY0(moll) ENDENTRY(setup(P, HALFPI))
-ENTRY0(wag4) ENDENTRY(setup(P, PI/3.))
-ENTRY0(wag5)
-	P->es = 0;
-	P->C_x = 0.90977;
-	P->C_y = 1.65014;
-	P->C_p = 3.00896;
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-ENDENTRY(P)
+
+#endif
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_wag5_selftest (void) {return 0;}
+#else
+
+int pj_wag5_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=wag5   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+
+    XY s_fwd_expect[] = {
+        { 203227.05192532466,  138651.631442713202},
+        { 203227.05192532466, -138651.631442713202},
+        {-203227.05192532466,  138651.631442713202},
+        {-203227.05192532466, -138651.631442713202},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+
+
+
+    LP s_inv_expect[] = {
+        { 0.00196807227086416396,  0.00072121615041701424},
+        { 0.00196807227086416396, -0.00072121615041701424},
+        {-0.00196807227086416396,  0.00072121615041701424},
+        {-0.00196807227086416396, -0.00072121615041701424},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_natearth.c b/src/PJ_natearth.c
index 0f28341..65a5662 100644
--- a/src/PJ_natearth.c
+++ b/src/PJ_natearth.c
@@ -12,10 +12,11 @@ where they meet the horizontal pole line. This improvement is by intention
 and designed in collaboration with Tom Patterson.
 Port to PROJ.4 by Bernhard Jenny, 6 June 2011
 */
-
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(natearth, "Natural Earth") "\n\tPCyl., Sph.";
+
 #define A0 0.8707
 #define A1 -0.131979
 #define A2 -0.013791
@@ -32,48 +33,118 @@ PROJ_HEAD(natearth, "Natural Earth") "\n\tPCyl., Sph.";
 #define C3 (9 * B3)
 #define C4 (11 * B4)
 #define EPS 1e-11
-#define MAX_Y (0.8707 * 0.52 * PI)
+#define MAX_Y (0.8707 * 0.52 * M_PI)
+
 
-FORWARD(s_forward); /* spheroid */
-	double phi2, phi4;
-	(void) P;
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double phi2, phi4;
+    (void) P;
 
-	phi2 = lp.phi * lp.phi;
-	phi4 = phi2 * phi2;
-	xy.x = lp.lam * (A0 + phi2 * (A1 + phi2 * (A2 + phi4 * phi2 * (A3 + phi2 * A4))));
-	xy.y = lp.phi * (B0 + phi2 * (B1 + phi4 * (B2 + B3 * phi2 + B4 * phi4)));
-	return (xy);
+    phi2 = lp.phi * lp.phi;
+    phi4 = phi2 * phi2;
+    xy.x = lp.lam * (A0 + phi2 * (A1 + phi2 * (A2 + phi4 * phi2 * (A3 + phi2 * A4))));
+    xy.y = lp.phi * (B0 + phi2 * (B1 + phi4 * (B2 + B3 * phi2 + B4 * phi4)));
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	double yc, tol, y2, y4, f, fder;
-	(void) P;
-
-        /* make sure y is inside valid range */
-	if (xy.y > MAX_Y) {
-		xy.y = MAX_Y;
-	} else if (xy.y < -MAX_Y) {
-		xy.y = -MAX_Y;
-	}
-
-        /* latitude */
-	yc = xy.y;
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double yc, tol, y2, y4, f, fder;
+    (void) P;
+
+    /* make sure y is inside valid range */
+    if (xy.y > MAX_Y) {
+        xy.y = MAX_Y;
+    } else if (xy.y < -MAX_Y) {
+        xy.y = -MAX_Y;
+    }
+
+    /* latitude */
+    yc = xy.y;
         for (;;) { /* Newton-Raphson */
-		y2 = yc * yc;
-		y4 = y2 * y2;
-		f = (yc * (B0 + y2 * (B1 + y4 * (B2 + B3 * y2 + B4 * y4)))) - xy.y;
-		fder = C0 + y2 * (C1 + y4 * (C2 + C3 * y2 + C4 * y4));
-		yc -= tol = f / fder;
-		if (fabs(tol) < EPS) {
-			break;
-		}
-	}
-	lp.phi = yc;
-
-        /* longitude */
-	y2 = yc * yc;
-	lp.lam = xy.x / (A0 + y2 * (A1 + y2 * (A2 + y2 * y2 * y2 * (A3 + y2 * A4))));
-
-	return (lp);
+        y2 = yc * yc;
+        y4 = y2 * y2;
+        f = (yc * (B0 + y2 * (B1 + y4 * (B2 + B3 * y2 + B4 * y4)))) - xy.y;
+        fder = C0 + y2 * (C1 + y4 * (C2 + C3 * y2 + C4 * y4));
+        yc -= tol = f / fder;
+        if (fabs(tol) < EPS) {
+            break;
+        }
+    }
+    lp.phi = yc;
+
+    /* longitude */
+    y2 = yc * yc;
+    lp.lam = xy.x / (A0 + y2 * (A1 + y2 * (A2 + y2 * y2 * y2 * (A3 + y2 * A4))));
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(natearth) {
+    P->es = 0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_natearth_selftest (void) {return 0;}
+#else
+
+int pj_natearth_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=natearth   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 194507.265257889288,  112508.737358294515},
+        { 194507.265257889288, -112508.737358294515},
+        {-194507.265257889288,  112508.737358294515},
+        {-194507.265257889288, -112508.737358294515},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00205638349586440223,  0.000888823913291242177},
+        { 0.00205638349586440223, -0.000888823913291242177},
+        {-0.00205638349586440223,  0.000888823913291242177},
+        {-0.00205638349586440223, -0.000888823913291242177},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(natearth) P->es = 0; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+#endif
diff --git a/src/PJ_natearth2.c b/src/PJ_natearth2.c
new file mode 100644
index 0000000..18b5e29
--- /dev/null
+++ b/src/PJ_natearth2.c
@@ -0,0 +1,147 @@
+/*
+The Natural Earth II projection was designed by Tom Patterson, US National
+Park Service, in 2012, using Flex Projector. The polynomial equation was
+developed by Bojan Savric and Bernhard Jenny, College of Earth, Ocean,
+and Atmospheric Sciences, Oregon State University.
+Port to PROJ.4 by Bojan Savric, 4 April 2016
+*/
+#define PJ_LIB__
+#include <projects.h>
+
+PROJ_HEAD(natearth2, "Natural Earth 2") "\n\tPCyl., Sph.";
+
+#define A0 0.84719
+#define A1 -0.13063
+#define A2 -0.04515
+#define A3 0.05494
+#define A4 -0.02326
+#define A5 0.00331
+#define B0 1.01183
+#define B1 -0.02625
+#define B2 0.01926
+#define B3 -0.00396
+#define C0 B0
+#define C1 (9 * B1)
+#define C2 (11 * B2)
+#define C3 (13 * B3)
+#define EPS 1e-11
+#define MAX_Y (0.84719 * 0.535117535153096 * M_PI)
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double phi2, phi4, phi6;
+    (void) P;
+
+    phi2 = lp.phi * lp.phi;
+    phi4 = phi2 * phi2;
+    phi6 = phi2 * phi4;
+
+    xy.x = lp.lam * (A0 + A1 * phi2 + phi6 * phi6 * (A2 + A3 * phi2 + A4 * phi4 + A5 * phi6));
+    xy.y = lp.phi * (B0 + phi4 * phi4 * (B1 + B2 * phi2 + B3 * phi4));
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double yc, tol, y2, y4, y6, f, fder;
+    (void) P;
+
+    /* make sure y is inside valid range */
+    if (xy.y > MAX_Y) {
+        xy.y = MAX_Y;
+    } else if (xy.y < -MAX_Y) {
+        xy.y = -MAX_Y;
+    }
+
+    /* latitude */
+    yc = xy.y;
+    for (;;) { /* Newton-Raphson */
+        y2 = yc * yc;
+        y4 = y2 * y2;
+        f = (yc * (B0 + y4 * y4 * (B1 + B2 * y2 + B3 * y4))) - xy.y;
+        fder = C0 + y4 * y4 * (C1 + C2 * y2 + C3 * y4);
+        yc -= tol = f / fder;
+        if (fabs(tol) < EPS) {
+            break;
+        }
+    }
+    lp.phi = yc;
+
+    /* longitude */
+    y2 = yc * yc;
+    y4 = y2 * y2;
+    y6 = y2 * y4;
+
+    lp.lam = xy.x / (A0 + A1 * y2 + y6 * y6 * (A2 + A3 * y2 + A4 * y4 + A5 * y6));
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(natearth2) {
+    P->es = 0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_natearth2_selftest (void) {return 0;}
+#else
+
+int pj_natearth2_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=natearth2   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 189255.172934730799,  113022.495810907014},
+        { 189255.172934730799, -113022.495810907014},
+        {-189255.172934730799,  113022.495810907014},
+        {-189255.172934730799, -113022.495810907014},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00211344929691056112,  0.000884779612080993237},
+        { 0.00211344929691056112, -0.000884779612080993237},
+        {-0.00211344929691056112,  0.000884779612080993237},
+        {-0.00211344929691056112, -0.000884779612080993237},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_nell.c b/src/PJ_nell.c
index 77983de..b69b999 100644
--- a/src/PJ_nell.c
+++ b/src/PJ_nell.c
@@ -1,30 +1,106 @@
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(nell, "Nell") "\n\tPCyl., Sph.";
-#define MAX_ITER	10
-#define LOOP_TOL	1e-7
-FORWARD(s_forward); /* spheroid */
-	double k, V;
-	int i;
-	(void) P;
-
-	k = 2. * sin(lp.phi);
-	V = lp.phi * lp.phi;
-	lp.phi *= 1.00371 + V * (-0.0935382 + V * -0.011412);
-	for (i = MAX_ITER; i ; --i) {
-		lp.phi -= V = (lp.phi + sin(lp.phi) - k) /
-			(1. + cos(lp.phi));
-		if (fabs(V) < LOOP_TOL)
-			break;
-	}
-	xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
-	xy.y = lp.phi;
-	return (xy);
+
+#define MAX_ITER 10
+#define LOOP_TOL 1e-7
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double k, V;
+    int i;
+    (void) P;
+
+    k = 2. * sin(lp.phi);
+    V = lp.phi * lp.phi;
+    lp.phi *= 1.00371 + V * (-0.0935382 + V * -0.011412);
+    for (i = MAX_ITER; i ; --i) {
+        lp.phi -= V = (lp.phi + sin(lp.phi) - k) /
+            (1. + cos(lp.phi));
+        if (fabs(V) < LOOP_TOL)
+            break;
+    }
+    xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
+    xy.y = lp.phi;
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    lp.lam = 2. * xy.x / (1. + cos(xy.y));
+    lp.phi = aasin(P->ctx,0.5 * (xy.y + sin(xy.y)));
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(nell) {
+
+    P->es = 0;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
 }
-INVERSE(s_inverse); /* spheroid */
-	lp.lam = 2. * xy.x / (1. + cos(xy.y));
-	lp.phi = aasin(P->ctx,0.5 * (xy.y + sin(xy.y)));
-	return (lp);
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_nell_selftest (void) {return 0;}
+#else
+
+int pj_nell_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=nell   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223385.132504695706,  111698.23644718733},
+        { 223385.132504695706, -111698.23644718733},
+        {-223385.132504695706,  111698.23644718733},
+        {-223385.132504695706, -111698.23644718733},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179049310989310567,  0.000895246554910125161},
+        { 0.00179049310989310567, -0.000895246554910125161},
+        {-0.00179049310989310567,  0.000895246554910125161},
+        {-0.00179049310989310567, -0.000895246554910125161},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(nell) P->es = 0; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+#endif
diff --git a/src/PJ_nell_h.c b/src/PJ_nell_h.c
index 22061ea..3523e53 100644
--- a/src/PJ_nell_h.c
+++ b/src/PJ_nell_h.c
@@ -1,32 +1,109 @@
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(nell_h, "Nell-Hammer") "\n\tPCyl., Sph.";
+
 #define NITER 9
 #define EPS 1e-7
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-	xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
-	xy.y = 2.0 * (lp.phi - tan(0.5 *lp.phi));
-	return (xy);
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+
+    xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
+    xy.y = 2.0 * (lp.phi - tan(0.5 *lp.phi));
+
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	double V, c, p;
-	int i;
-	(void) P;
-
-	p = 0.5 * xy.y;
-	for (i = NITER; i ; --i) {
-		c = cos(0.5 * lp.phi);
-		lp.phi -= V = (lp.phi - tan(lp.phi/2) - p)/(1. - 0.5/(c*c));
-		if (fabs(V) < EPS)
-			break;
-	}
-	if (!i) {
-		lp.phi = p < 0. ? -HALFPI : HALFPI;
-		lp.lam = 2. * xy.x;
-	} else
-		lp.lam = 2. * xy.x / (1. + cos(lp.phi));
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double V, c, p;
+    int i;
+    (void) P;
+
+    p = 0.5 * xy.y;
+    for (i = NITER; i ; --i) {
+        c = cos(0.5 * lp.phi);
+        lp.phi -= V = (lp.phi - tan(lp.phi/2) - p)/(1. - 0.5/(c*c));
+        if (fabs(V) < EPS)
+            break;
+    }
+    if (!i) {
+        lp.phi = p < 0. ? -M_HALFPI : M_HALFPI;
+        lp.lam = 2. * xy.x;
+    } else
+        lp.lam = 2. * xy.x / (1. + cos(lp.phi));
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(nell_h) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+PJ *PROJECTION(nell_h) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_nell_h_selftest (void) {return 0;}
+#else
+
+int pj_nell_h_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=nell_h   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223385.131640952837,  111698.236533561678},
+        { 223385.131640952837, -111698.236533561678},
+        {-223385.131640952837,  111698.236533561678},
+        {-223385.131640952837, -111698.236533561678},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179049310989310567,  0.000895246554910125378},
+        { 0.00179049310989310567, -0.000895246554910125378},
+        {-0.00179049310989310567,  0.000895246554910125378},
+        {-0.00179049310989310567, -0.000895246554910125378},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_nocol.c b/src/PJ_nocol.c
index 2b005e1..029f785 100644
--- a/src/PJ_nocol.c
+++ b/src/PJ_nocol.c
@@ -1,40 +1,96 @@
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(nicol, "Nicolosi Globular") "\n\tMisc Sph, no inv.";
-#define EPS	1e-10
-FORWARD(s_forward); /* spheroid */
-	(void) P;
-
-	if (fabs(lp.lam) < EPS) {
-		xy.x = 0;
-		xy.y = lp.phi;
-	} else if (fabs(lp.phi) < EPS) {
-		xy.x = lp.lam;
-		xy.y = 0.;
-	} else if (fabs(fabs(lp.lam) - HALFPI) < EPS) {
-		xy.x = lp.lam * cos(lp.phi);
-		xy.y = HALFPI * sin(lp.phi);
-	} else if (fabs(fabs(lp.phi) - HALFPI) < EPS) {
-		xy.x = 0;
-		xy.y = lp.phi;
-	} else {
-		double tb, c, d, m, n, r2, sp;
-
-		tb = HALFPI / lp.lam - lp.lam / HALFPI;
-		c = lp.phi / HALFPI;
-		d = (1 - c * c)/((sp = sin(lp.phi)) - c);
-		r2 = tb / d;
-		r2 *= r2;
-		m = (tb * sp / d - 0.5 * tb)/(1. + r2);
-		n = (sp / r2 + 0.5 * d)/(1. + 1./r2);
-		xy.x = cos(lp.phi);
-		xy.x = sqrt(m * m + xy.x * xy.x / (1. + r2));
-		xy.x = HALFPI * ( m + (lp.lam < 0. ? -xy.x : xy.x));
-		xy.y = sqrt(n * n - (sp * sp / r2 + d * sp - 1.) /
-			(1. + 1./r2));
-		xy.y = HALFPI * ( n + (lp.phi < 0. ? xy.y : -xy.y ));
-	}
-	return (xy);
+
+#define EPS 1e-10
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    (void) P;
+
+    if (fabs(lp.lam) < EPS) {
+        xy.x = 0;
+        xy.y = lp.phi;
+    } else if (fabs(lp.phi) < EPS) {
+        xy.x = lp.lam;
+        xy.y = 0.;
+    } else if (fabs(fabs(lp.lam) - M_HALFPI) < EPS) {
+        xy.x = lp.lam * cos(lp.phi);
+        xy.y = M_HALFPI * sin(lp.phi);
+    } else if (fabs(fabs(lp.phi) - M_HALFPI) < EPS) {
+        xy.x = 0;
+        xy.y = lp.phi;
+    } else {
+        double tb, c, d, m, n, r2, sp;
+
+        tb = M_HALFPI / lp.lam - lp.lam / M_HALFPI;
+        c = lp.phi / M_HALFPI;
+        d = (1 - c * c)/((sp = sin(lp.phi)) - c);
+        r2 = tb / d;
+        r2 *= r2;
+        m = (tb * sp / d - 0.5 * tb)/(1. + r2);
+        n = (sp / r2 + 0.5 * d)/(1. + 1./r2);
+        xy.x = cos(lp.phi);
+        xy.x = sqrt(m * m + xy.x * xy.x / (1. + r2));
+        xy.x = M_HALFPI * ( m + (lp.lam < 0. ? -xy.x : xy.x));
+        xy.y = sqrt(n * n - (sp * sp / r2 + d * sp - 1.) /
+            (1. + 1./r2));
+        xy.y = M_HALFPI * ( n + (lp.phi < 0. ? xy.y : -xy.y ));
+    }
+    return (xy);
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(nicol) P->es = 0.; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(nicol) {
+    P->es = 0.;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_nicol_selftest (void) {return 0;}
+#else
+
+int pj_nicol_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=nicol   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223374.561814139714,  111732.553988545071},
+        { 223374.561814139714, -111732.553988545071},
+        {-223374.561814139714,  111732.553988545071},
+        {-223374.561814139714, -111732.553988545071},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_nsper.c b/src/PJ_nsper.c
index 0f355b9..c71f11e 100644
--- a/src/PJ_nsper.c
+++ b/src/PJ_nsper.c
@@ -1,149 +1,287 @@
-#define PROJ_PARMS__ \
-	double	height; \
-	double	sinph0; \
-	double	cosph0; \
-	double	p; \
-	double	rp; \
-	double	pn1; \
-	double	pfact; \
-	double	h; \
-	double	cg; \
-	double	sg; \
-	double	sw; \
-	double	cw; \
-	int		mode; \
-	int		tilt;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    double  height;
+    double  sinph0;
+    double  cosph0;
+    double  p;
+    double  rp;
+    double  pn1;
+    double  pfact;
+    double  h;
+    double  cg;
+    double  sg;
+    double  sw;
+    double  cw;
+    int     mode;
+    int     tilt;
+};
+
 PROJ_HEAD(nsper, "Near-sided perspective") "\n\tAzi, Sph\n\th=";
 PROJ_HEAD(tpers, "Tilted perspective") "\n\tAzi, Sph\n\ttilt= azi= h=";
+
 # define EPS10 1.e-10
-# define N_POLE	0
+# define N_POLE 0
 # define S_POLE 1
-# define EQUIT	2
-# define OBLIQ	3
-FORWARD(s_forward); /* spheroid */
-	double  coslam, cosphi, sinphi;
-
-	sinphi = sin(lp.phi);
-	cosphi = cos(lp.phi);
-	coslam = cos(lp.lam);
-	switch (P->mode) {
-	case OBLIQ:
-		xy.y = P->sinph0 * sinphi + P->cosph0 * cosphi * coslam;
-		break;
-	case EQUIT:
-		xy.y = cosphi * coslam;
-		break;
-	case S_POLE:
-		xy.y = - sinphi;
-		break;
-	case N_POLE:
-		xy.y = sinphi;
-		break;
-	}
-	if (xy.y < P->rp) F_ERROR;
-	xy.y = P->pn1 / (P->p - xy.y);
-	xy.x = xy.y * cosphi * sin(lp.lam);
-	switch (P->mode) {
-	case OBLIQ:
-		xy.y *= (P->cosph0 * sinphi -
-		   P->sinph0 * cosphi * coslam);
-		break;
-	case EQUIT:
-		xy.y *= sinphi;
-		break;
-	case N_POLE:
-		coslam = - coslam;
-	case S_POLE:
-		xy.y *= cosphi * coslam;
-		break;
-	}
-	if (P->tilt) {
-		double yt, ba;
-
-		yt = xy.y * P->cg + xy.x * P->sg;
-		ba = 1. / (yt * P->sw * P->h + P->cw);
-		xy.x = (xy.x * P->cg - xy.y * P->sg) * P->cw * ba;
-		xy.y = yt * ba;
-	}
-	return (xy);
+# define EQUIT  2
+# define OBLIQ  3
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  coslam, cosphi, sinphi;
+
+    sinphi = sin(lp.phi);
+    cosphi = cos(lp.phi);
+    coslam = cos(lp.lam);
+    switch (Q->mode) {
+    case OBLIQ:
+        xy.y = Q->sinph0 * sinphi + Q->cosph0 * cosphi * coslam;
+        break;
+    case EQUIT:
+        xy.y = cosphi * coslam;
+        break;
+    case S_POLE:
+        xy.y = - sinphi;
+        break;
+    case N_POLE:
+        xy.y = sinphi;
+        break;
+    }
+    if (xy.y < Q->rp) F_ERROR;
+    xy.y = Q->pn1 / (Q->p - xy.y);
+    xy.x = xy.y * cosphi * sin(lp.lam);
+    switch (Q->mode) {
+    case OBLIQ:
+        xy.y *= (Q->cosph0 * sinphi -
+           Q->sinph0 * cosphi * coslam);
+        break;
+    case EQUIT:
+        xy.y *= sinphi;
+        break;
+    case N_POLE:
+        coslam = - coslam;
+    case S_POLE:
+        xy.y *= cosphi * coslam;
+        break;
+    }
+    if (Q->tilt) {
+        double yt, ba;
+
+        yt = xy.y * Q->cg + xy.x * Q->sg;
+        ba = 1. / (yt * Q->sw * Q->h + Q->cw);
+        xy.x = (xy.x * Q->cg - xy.y * Q->sg) * Q->cw * ba;
+        xy.y = yt * ba;
+    }
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  rh, cosz, sinz;
+
+    if (Q->tilt) {
+        double bm, bq, yt;
+
+        yt = 1./(Q->pn1 - xy.y * Q->sw);
+        bm = Q->pn1 * xy.x * yt;
+        bq = Q->pn1 * xy.y * Q->cw * yt;
+        xy.x = bm * Q->cg + bq * Q->sg;
+        xy.y = bq * Q->cg - bm * Q->sg;
+    }
+    rh = hypot(xy.x, xy.y);
+    if ((sinz = 1. - rh * rh * Q->pfact) < 0.) I_ERROR;
+    sinz = (Q->p - sqrt(sinz)) / (Q->pn1 / rh + rh / Q->pn1);
+    cosz = sqrt(1. - sinz * sinz);
+    if (fabs(rh) <= EPS10) {
+        lp.lam = 0.;
+        lp.phi = P->phi0;
+    } else {
+        switch (Q->mode) {
+        case OBLIQ:
+            lp.phi = asin(cosz * Q->sinph0 + xy.y * sinz * Q->cosph0 / rh);
+            xy.y = (cosz - Q->sinph0 * sin(lp.phi)) * rh;
+            xy.x *= sinz * Q->cosph0;
+            break;
+        case EQUIT:
+            lp.phi = asin(xy.y * sinz / rh);
+            xy.y = cosz * rh;
+            xy.x *= sinz;
+            break;
+        case N_POLE:
+            lp.phi = asin(cosz);
+            xy.y = -xy.y;
+            break;
+        case S_POLE:
+            lp.phi = - asin(cosz);
+            break;
+        }
+        lp.lam = atan2(xy.x, xy.y);
+    }
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(s_inverse); /* spheroid */
-	double  rh, cosz, sinz;
-
-	if (P->tilt) {
-		double bm, bq, yt;
-
-		yt = 1./(P->pn1 - xy.y * P->sw);
-		bm = P->pn1 * xy.x * yt;
-		bq = P->pn1 * xy.y * P->cw * yt;
-		xy.x = bm * P->cg + bq * P->sg;
-		xy.y = bq * P->cg - bm * P->sg;
-	}
-	rh = hypot(xy.x, xy.y);
-	if ((sinz = 1. - rh * rh * P->pfact) < 0.) I_ERROR;
-	sinz = (P->p - sqrt(sinz)) / (P->pn1 / rh + rh / P->pn1);
-	cosz = sqrt(1. - sinz * sinz);
-	if (fabs(rh) <= EPS10) {
-		lp.lam = 0.;
-		lp.phi = P->phi0;
-	} else {
-		switch (P->mode) {
-		case OBLIQ:
-			lp.phi = asin(cosz * P->sinph0 + xy.y * sinz * P->cosph0 / rh);
-			xy.y = (cosz - P->sinph0 * sin(lp.phi)) * rh;
-			xy.x *= sinz * P->cosph0;
-			break;
-		case EQUIT:
-			lp.phi = asin(xy.y * sinz / rh);
-			xy.y = cosz * rh;
-			xy.x *= sinz;
-			break;
-		case N_POLE:
-			lp.phi = asin(cosz);
-			xy.y = -xy.y;
-			break;
-		case S_POLE:
-			lp.phi = - asin(cosz);
-			break;
-		}
-		lp.lam = atan2(xy.x, xy.y);
-	}
-	return (lp);
+
+
+static PJ *setup(PJ *P) {
+    struct pj_opaque *Q = P->opaque;
+
+    if ((Q->height = pj_param(P->ctx, P->params, "dh").f) <= 0.) E_ERROR(-30);
+    if (fabs(fabs(P->phi0) - M_HALFPI) < EPS10)
+        Q->mode = P->phi0 < 0. ? S_POLE : N_POLE;
+    else if (fabs(P->phi0) < EPS10)
+        Q->mode = EQUIT;
+    else {
+        Q->mode = OBLIQ;
+        Q->sinph0 = sin(P->phi0);
+        Q->cosph0 = cos(P->phi0);
+    }
+    Q->pn1 = Q->height / P->a; /* normalize by radius */
+    Q->p = 1. + Q->pn1;
+    Q->rp = 1. / Q->p;
+    Q->h = 1. / Q->pn1;
+    Q->pfact = (Q->p + 1.) * Q->h;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    P->es = 0.;
+    return P;
 }
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) {
-	if ((P->height = pj_param(P->ctx, P->params, "dh").f) <= 0.) E_ERROR(-30);
-	if (fabs(fabs(P->phi0) - HALFPI) < EPS10)
-		P->mode = P->phi0 < 0. ? S_POLE : N_POLE;
-	else if (fabs(P->phi0) < EPS10)
-		P->mode = EQUIT;
-	else {
-		P->mode = OBLIQ;
-		P->sinph0 = sin(P->phi0);
-		P->cosph0 = cos(P->phi0);
-	}
-	P->pn1 = P->height / P->a; /* normalize by radius */
-	P->p = 1. + P->pn1;
-	P->rp = 1. / P->p;
-	P->h = 1. / P->pn1;
-	P->pfact = (P->p + 1.) * P->h;
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-	P->es = 0.;
-	return P;
+
+
+PJ *PROJECTION(nsper) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->tilt = 0;
+
+   return setup(P);
 }
-ENTRY0(nsper)
-	P->tilt = 0;
-ENDENTRY(setup(P))
-ENTRY0(tpers)
-	double omega, gamma;
-
-	omega = pj_param(P->ctx, P->params, "dtilt").f * DEG_TO_RAD;
-	gamma = pj_param(P->ctx, P->params, "dazi").f * DEG_TO_RAD;
-	P->tilt = 1;
-	P->cg = cos(gamma); P->sg = sin(gamma);
-	P->cw = cos(omega); P->sw = sin(omega);
-ENDENTRY(setup(P))
+
+
+PJ *PROJECTION(tpers) {
+    double omega, gamma;
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    omega = pj_param(P->ctx, P->params, "dtilt").f * DEG_TO_RAD;
+    gamma = pj_param(P->ctx, P->params, "dazi").f * DEG_TO_RAD;
+    Q->tilt = 1;
+    Q->cg = cos(gamma); Q->sg = sin(gamma);
+    Q->cw = cos(omega); Q->sw = sin(omega);
+
+    return setup(P);
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_nsper_selftest (void) {return 0;}
+#else
+
+int pj_nsper_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=nsper   +a=6400000  +h=1000000"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 222239.816114099842,  111153.763991924759},
+        { 222239.816114099842, -111153.763991924759},
+        {-222239.816114099842,  111153.763991924759},
+        {-222239.816114099842, -111153.763991924759},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179049311728792437,  0.000895246558425396135},
+        { 0.00179049311728792437, -0.000895246558425396135},
+        {-0.00179049311728792437,  0.000895246558425396135},
+        {-0.00179049311728792437, -0.000895246558425396135},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_tpers_selftest (void) {return 0;}
+#else
+
+int pj_tpers_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=tpers   +a=6400000  +h=1000000 +azi=20"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 170820.288955531199,  180460.865555804776},
+        { 246853.941538942483, -28439.8780357754222},
+        {-246853.941538942483,  28439.8780357754222},
+        {-170820.288955531199, -180460.865555804776}
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00198870552603137678,  0.000228871872278689991},
+        { 0.00137632081376749859, -0.00145364129728205432},
+        {-0.00137632081376749859,  0.00145364129728205432},
+        {-0.00198870552603137678, -0.000228871872278689991},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_nzmg.c b/src/PJ_nzmg.c
index 60df004..8dcb263 100644
--- a/src/PJ_nzmg.c
+++ b/src/PJ_nzmg.c
@@ -25,79 +25,153 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  *****************************************************************************/
-
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
 
 PROJ_HEAD(nzmg, "New Zealand Map Grid") "\n\tfixed Earth";
 
 #define EPSLN 1e-10
 #define SEC5_TO_RAD 0.4848136811095359935899141023
 #define RAD_TO_SEC5 2.062648062470963551564733573
-	static COMPLEX
-bf[] = {
-	{.7557853228,	0.0},
-	{.249204646,	.003371507},
-	{-.001541739,	.041058560},
-	{-.10162907,	.01727609},
-	{-.26623489,	-.36249218},
-	{-.6870983,	-1.1651967} };
-	static double
-tphi[] = { 1.5627014243, .5185406398, -.03333098, -.1052906, -.0368594,
-	.007317, .01220, .00394, -.0013 },
-tpsi[] = { .6399175073, -.1358797613, .063294409, -.02526853, .0117879,
-	-.0055161, .0026906, -.001333, .00067, -.00034 };
+
+static COMPLEX bf[] = {
+    { .7557853228, 0.0},
+    { .249204646,  0.003371507},
+    {-.001541739,  0.041058560},
+    {-.10162907,   0.01727609},
+    {-.26623489,  -0.36249218},
+    {-.6870983,   -1.1651967} };
+
+static double tphi[] = { 1.5627014243, .5185406398, -.03333098,
+                         -.1052906,   -.0368594,     .007317,
+                          .01220,      .00394,      -.0013 };
+
+static double tpsi[] = { .6399175073, -.1358797613, .063294409, -.02526853, .0117879,
+                        -.0055161,     .0026906,   -.001333,     .00067,   -.00034 };
+
 #define Nbf 5
 #define Ntpsi 9
 #define Ntphi 8
-FORWARD(e_forward); /* ellipsoid */
-	COMPLEX p;
-	double *C;
-	int i;
-
-	lp.phi = (lp.phi - P->phi0) * RAD_TO_SEC5;
-	for (p.r = *(C = tpsi + (i = Ntpsi)); i ; --i)
-		p.r = *--C + lp.phi * p.r;
-	p.r *= lp.phi;
-	p.i = lp.lam;
-	p = pj_zpoly1(p, bf, Nbf);
-	xy.x = p.i;
-	xy.y = p.r;
-	return xy;
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    COMPLEX p;
+    double *C;
+    int i;
+
+    lp.phi = (lp.phi - P->phi0) * RAD_TO_SEC5;
+    for (p.r = *(C = tpsi + (i = Ntpsi)); i ; --i)
+        p.r = *--C + lp.phi * p.r;
+    p.r *= lp.phi;
+    p.i = lp.lam;
+    p = pj_zpoly1(p, bf, Nbf);
+    xy.x = p.i;
+    xy.y = p.r;
+
+    return xy;
 }
-INVERSE(e_inverse); /* ellipsoid */
-	int nn, i;
-	COMPLEX p, f, fp, dp;
-	double den, *C;
-
-	p.r = xy.y;
-	p.i = xy.x;
-	for (nn = 20; nn ;--nn) {
-		f = pj_zpolyd1(p, bf, Nbf, &fp);
-		f.r -= xy.y;
-		f.i -= xy.x;
-		den = fp.r * fp.r + fp.i * fp.i;
-		p.r += dp.r = -(f.r * fp.r + f.i * fp.i) / den;
-		p.i += dp.i = -(f.i * fp.r - f.r * fp.i) / den;
-		if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
-			break;
-	}
-	if (nn) {
-		lp.lam = p.i;
-		for (lp.phi = *(C = tphi + (i = Ntphi)); i ; --i)
-			lp.phi = *--C + p.r * lp.phi;
-		lp.phi = P->phi0 + p.r * lp.phi * SEC5_TO_RAD;
-	} else
-		lp.lam = lp.phi = HUGE_VAL;
-	return lp;
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    int nn, i;
+    COMPLEX p, f, fp, dp;
+    double den, *C;
+
+    p.r = xy.y;
+    p.i = xy.x;
+    for (nn = 20; nn ;--nn) {
+        f = pj_zpolyd1(p, bf, Nbf, &fp);
+        f.r -= xy.y;
+        f.i -= xy.x;
+        den = fp.r * fp.r + fp.i * fp.i;
+        p.r += dp.r = -(f.r * fp.r + f.i * fp.i) / den;
+        p.i += dp.i = -(f.i * fp.r - f.r * fp.i) / den;
+        if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
+            break;
+    }
+    if (nn) {
+        lp.lam = p.i;
+        for (lp.phi = *(C = tphi + (i = Ntphi)); i ; --i)
+            lp.phi = *--C + p.r * lp.phi;
+        lp.phi = P->phi0 + p.r * lp.phi * SEC5_TO_RAD;
+    } else
+        lp.lam = lp.phi = HUGE_VAL;
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(nzmg)
-	/* force to International major axis */
-	P->ra = 1. / (P->a = 6378388.0);
-	P->lam0 = DEG_TO_RAD * 173.;
-	P->phi0 = DEG_TO_RAD * -41.;
-	P->x0 = 2510000.;
-	P->y0 = 6023150.;
-	P->inv = e_inverse; P->fwd = e_forward;
-ENDENTRY(P)
+
+
+PJ *PROJECTION(nzmg) {
+    /* force to International major axis */
+    P->ra = 1. / (P->a = 6378388.0);
+    P->lam0 = DEG_TO_RAD * 173.;
+    P->phi0 = DEG_TO_RAD * -41.;
+    P->x0 = 2510000.;
+    P->y0 = 6023150.;
+
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_nzmg_selftest (void) {return 0;}
+#else
+
+int pj_nzmg_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=nzmg   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {3352675144.74742508,  -7043205391.10024357},
+        {3691989502.77930641,  -6729069415.33210468},
+        {4099000768.45323849,  -7863208779.66724873},
+        {4466166927.36997604,  -7502531736.62860489},
+    };
+
+    XY inv_in[] = {
+        { 200000, 100000},
+        { 200000,-100000},
+        {-200000, 100000},
+        {-200000,-100000}
+    };
+
+    LP e_inv_expect[] = {
+        {175.48208682711271,  -69.4226921826331846},
+        {175.756819472543611, -69.5335710883796168},
+        {134.605119233460016, -61.4599957106629091},
+        {134.333684315954827, -61.6215536756024349},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
+
+
+#endif
diff --git a/src/PJ_ob_tran.c b/src/PJ_ob_tran.c
index 4ddba9a..e135fb9 100644
--- a/src/PJ_ob_tran.c
+++ b/src/PJ_ob_tran.c
@@ -1,145 +1,225 @@
-#define PROJ_PARMS__ \
-	struct PJconsts *link; \
-	double	lamp; \
-	double	cphip, sphip;
 #define PJ_LIB__
 #include <projects.h>
 #include <string.h>
+
+struct pj_opaque {
+    struct PJconsts *link;
+    double  lamp;
+    double  cphip, sphip;
+};
+
 PROJ_HEAD(ob_tran, "General Oblique Transformation") "\n\tMisc Sph"
 "\n\to_proj= plus parameters for projection"
 "\n\to_lat_p= o_lon_p= (new pole) or"
 "\n\to_alpha= o_lon_c= o_lat_c= or"
 "\n\to_lon_1= o_lat_1= o_lon_2= o_lat_2=";
+
 #define TOL 1e-10
-FORWARD(o_forward); /* spheroid */
-	double coslam, sinphi, cosphi;
-
-        (void) xy;
-
-	coslam = cos(lp.lam);
-	sinphi = sin(lp.phi);
-	cosphi = cos(lp.phi);
-	lp.lam = adjlon(aatan2(cosphi * sin(lp.lam), P->sphip * cosphi * coslam +
-		P->cphip * sinphi) + P->lamp);
-	lp.phi = aasin(P->ctx,P->sphip * sinphi - P->cphip * cosphi * coslam);
-	return (P->link->fwd(lp, P->link));
+
+
+static XY o_forward(LP lp, PJ *P) {             /* spheroid */
+    struct pj_opaque *Q = P->opaque;
+    double coslam, sinphi, cosphi;
+
+    coslam = cos(lp.lam);
+    sinphi = sin(lp.phi);
+    cosphi = cos(lp.phi);
+    lp.lam = adjlon(aatan2(cosphi * sin(lp.lam), Q->sphip * cosphi * coslam +
+        Q->cphip * sinphi) + Q->lamp);
+    lp.phi = aasin(P->ctx,Q->sphip * sinphi - Q->cphip * cosphi * coslam);
+
+    return Q->link->fwd(lp, Q->link);
+}
+
+
+static XY t_forward(LP lp, PJ *P) {             /* spheroid */
+    struct pj_opaque *Q = P->opaque;
+    double cosphi, coslam;
+
+    cosphi = cos(lp.phi);
+    coslam = cos(lp.lam);
+    lp.lam = adjlon(aatan2(cosphi * sin(lp.lam), sin(lp.phi)) + Q->lamp);
+    lp.phi = aasin(P->ctx, - cosphi * coslam);
+
+    return Q->link->fwd(lp, Q->link);
 }
-FORWARD(t_forward); /* spheroid */
-	double cosphi, coslam;
 
-        (void) xy;
 
-	cosphi = cos(lp.phi);
-	coslam = cos(lp.lam);
-	lp.lam = adjlon(aatan2(cosphi * sin(lp.lam), sin(lp.phi)) + P->lamp);
-	lp.phi = aasin(P->ctx, - cosphi * coslam);
-	return (P->link->fwd(lp, P->link));
+static LP o_inverse(XY xy, PJ *P) {             /* spheroid */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double coslam, sinphi, cosphi;
+
+    lp = Q->link->inv(xy, Q->link);
+    if (lp.lam != HUGE_VAL) {
+        coslam = cos(lp.lam -= Q->lamp);
+        sinphi = sin(lp.phi);
+        cosphi = cos(lp.phi);
+        lp.phi = aasin(P->ctx,Q->sphip * sinphi + Q->cphip * cosphi * coslam);
+        lp.lam = aatan2(cosphi * sin(lp.lam), Q->sphip * cosphi * coslam -
+            Q->cphip * sinphi);
+    }
+    return lp;
 }
-INVERSE(o_inverse); /* spheroid */
-	double coslam, sinphi, cosphi;
-
-	lp = P->link->inv(xy, P->link);
-	if (lp.lam != HUGE_VAL) {
-		coslam = cos(lp.lam -= P->lamp);
-		sinphi = sin(lp.phi);
-		cosphi = cos(lp.phi);
-		lp.phi = aasin(P->ctx,P->sphip * sinphi + P->cphip * cosphi * coslam);
-		lp.lam = aatan2(cosphi * sin(lp.lam), P->sphip * cosphi * coslam -
-			P->cphip * sinphi);
-	}
-	return (lp);
+
+
+static LP t_inverse(XY xy, PJ *P) {             /* spheroid */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double cosphi, t;
+
+    lp = Q->link->inv(xy, Q->link);
+    if (lp.lam != HUGE_VAL) {
+        cosphi = cos(lp.phi);
+        t = lp.lam - Q->lamp;
+        lp.lam = aatan2(cosphi * sin(t), - sin(lp.phi));
+        lp.phi = aasin(P->ctx,cosphi * cos(t));
+    }
+    return lp;
 }
-INVERSE(t_inverse); /* spheroid */
-	double cosphi, t;
-
-	lp = P->link->inv(xy, P->link);
-	if (lp.lam != HUGE_VAL) {
-		cosphi = cos(lp.phi);
-		t = lp.lam - P->lamp;
-		lp.lam = aatan2(cosphi * sin(t), - sin(lp.phi));
-		lp.phi = aasin(P->ctx,cosphi * cos(t));
-	}
-	return (lp);
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    if (P->opaque->link)
+        return pj_dealloc (P->opaque->link);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-FREEUP;
-	if (P) {
-		if (P->link)
-			(*(P->link->pfree))(P->link);
-		pj_dalloc(P);
-	}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-ENTRY1(ob_tran, link)
-	int i;
-	double phip;
-	char *name, *s;
-
-	/* get name of projection to be translated */
-	if (!(name = pj_param(P->ctx, P->params, "so_proj").s)) E_ERROR(-26);
-	for (i = 0; (s = pj_list[i].id) && strcmp(name, s) ; ++i) ;
-	if (!s || !(P->link = (*pj_list[i].proj)(0))) E_ERROR(-37);
-	/* copy existing header into new */
-	P->es = 0.; /* force to spherical */
-	P->link->params = P->params;
-        P->link->ctx = P->ctx;
-	P->link->over = P->over;
-	P->link->geoc = P->geoc;
-	P->link->a = P->a;
-	P->link->es = P->es;
-	P->link->ra = P->ra;
-	P->link->lam0 = P->lam0;
-	P->link->phi0 = P->phi0;
-	P->link->x0 = P->x0;
-	P->link->y0 = P->y0;
-	P->link->k0 = P->k0;
-	/* force spherical earth */
-	P->link->one_es = P->link->rone_es = 1.;
-	P->link->es = P->link->e = 0.;
-	if (!(P->link = pj_list[i].proj(P->link))) {
-		freeup(P);
-		return 0;
-	}
-	if (pj_param(P->ctx, P->params, "to_alpha").i) {
-		double lamc, phic, alpha;
-
-		lamc	= pj_param(P->ctx, P->params, "ro_lon_c").f;
-		phic	= pj_param(P->ctx, P->params, "ro_lat_c").f;
-		alpha	= pj_param(P->ctx, P->params, "ro_alpha").f;
+
+
+PJ *PROJECTION(ob_tran) {
+    int i;
+    double phip;
+    char *name, *s;
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    /* get name of projection to be translated */
+    if (!(name = pj_param(P->ctx, P->params, "so_proj").s)) E_ERROR(-26);
+    for (i = 0; (s = pj_list[i].id) && strcmp(name, s) ; ++i) ;
+    if (!s || !(Q->link = (*pj_list[i].proj)(0))) E_ERROR(-37);
+    /* copy existing header into new */
+    P->es = 0.; /* force to spherical */
+    Q->link->params = P->params;
+    Q->link->ctx = P->ctx;
+    Q->link->over = P->over;
+    Q->link->geoc = P->geoc;
+    Q->link->a = P->a;
+    Q->link->es = P->es;
+    Q->link->ra = P->ra;
+    Q->link->lam0 = P->lam0;
+    Q->link->phi0 = P->phi0;
+    Q->link->x0 = P->x0;
+    Q->link->y0 = P->y0;
+    Q->link->k0 = P->k0;
+    /* force spherical earth */
+    Q->link->one_es = Q->link->rone_es = 1.;
+    Q->link->es = Q->link->e = 0.;
+    if (!(Q->link = pj_list[i].proj(Q->link))) {
+        return freeup_new(P);
+    }
+    if (pj_param(P->ctx, P->params, "to_alpha").i) {
+        double lamc, phic, alpha;
+
+        lamc    = pj_param(P->ctx, P->params, "ro_lon_c").f;
+        phic    = pj_param(P->ctx, P->params, "ro_lat_c").f;
+        alpha   = pj_param(P->ctx, P->params, "ro_alpha").f;
 /*
-		if (fabs(phic) <= TOL ||
-			fabs(fabs(phic) - HALFPI) <= TOL ||
-			fabs(fabs(alpha) - HALFPI) <= TOL)
+        if (fabs(phic) <= TOL ||
+            fabs(fabs(phic) - HALFPI) <= TOL ||
+            fabs(fabs(alpha) - HALFPI) <= TOL)
 */
-		if (fabs(fabs(phic) - HALFPI) <= TOL)
-			E_ERROR(-32);
-		P->lamp = lamc + aatan2(-cos(alpha), -sin(alpha) * sin(phic));
-		phip = aasin(P->ctx,cos(phic) * sin(alpha));
-	} else if (pj_param(P->ctx, P->params, "to_lat_p").i) { /* specified new pole */
-		P->lamp = pj_param(P->ctx, P->params, "ro_lon_p").f;
-		phip = pj_param(P->ctx, P->params, "ro_lat_p").f;
-	} else { /* specified new "equator" points */
-		double lam1, lam2, phi1, phi2, con;
-
-		lam1 = pj_param(P->ctx, P->params, "ro_lon_1").f;
-		phi1 = pj_param(P->ctx, P->params, "ro_lat_1").f;
-		lam2 = pj_param(P->ctx, P->params, "ro_lon_2").f;
-		phi2 = pj_param(P->ctx, P->params, "ro_lat_2").f;
-		if (fabs(phi1 - phi2) <= TOL ||
-			(con = fabs(phi1)) <= TOL ||
-			fabs(con - HALFPI) <= TOL ||
-			fabs(fabs(phi2) - HALFPI) <= TOL) E_ERROR(-33);
-		P->lamp = atan2(cos(phi1) * sin(phi2) * cos(lam1) -
-			sin(phi1) * cos(phi2) * cos(lam2),
-			sin(phi1) * cos(phi2) * sin(lam2) -
-			cos(phi1) * sin(phi2) * sin(lam1));
-		phip = atan(-cos(P->lamp - lam1) / tan(phi1));
-	}
-	if (fabs(phip) > TOL) { /* oblique */
-		P->cphip = cos(phip);
-		P->sphip = sin(phip);
-		P->fwd = o_forward;
-		P->inv = P->link->inv ? o_inverse : 0;
-	} else { /* transverse */
-		P->fwd = t_forward;
-		P->inv = P->link->inv ? t_inverse : 0;
-	}
-ENDENTRY(P)
+        if (fabs(fabs(phic) - M_HALFPI) <= TOL)
+            E_ERROR(-32);
+        Q->lamp = lamc + aatan2(-cos(alpha), -sin(alpha) * sin(phic));
+        phip = aasin(P->ctx,cos(phic) * sin(alpha));
+    } else if (pj_param(P->ctx, P->params, "to_lat_p").i) { /* specified new pole */
+        Q->lamp = pj_param(P->ctx, P->params, "ro_lon_p").f;
+        phip = pj_param(P->ctx, P->params, "ro_lat_p").f;
+    } else { /* specified new "equator" points */
+        double lam1, lam2, phi1, phi2, con;
+
+        lam1 = pj_param(P->ctx, P->params, "ro_lon_1").f;
+        phi1 = pj_param(P->ctx, P->params, "ro_lat_1").f;
+        lam2 = pj_param(P->ctx, P->params, "ro_lon_2").f;
+        phi2 = pj_param(P->ctx, P->params, "ro_lat_2").f;
+        if (fabs(phi1 - phi2) <= TOL ||
+            (con = fabs(phi1)) <= TOL ||
+            fabs(con - M_HALFPI) <= TOL ||
+            fabs(fabs(phi2) - M_HALFPI) <= TOL) E_ERROR(-33);
+        Q->lamp = atan2(cos(phi1) * sin(phi2) * cos(lam1) -
+            sin(phi1) * cos(phi2) * cos(lam2),
+            sin(phi1) * cos(phi2) * sin(lam2) -
+            cos(phi1) * sin(phi2) * sin(lam1));
+        phip = atan(-cos(Q->lamp - lam1) / tan(phi1));
+    }
+    if (fabs(phip) > TOL) { /* oblique */
+        Q->cphip = cos(phip);
+        Q->sphip = sin(phip);
+        P->fwd = o_forward;
+        P->inv = Q->link->inv ? o_inverse : 0;
+    } else { /* transverse */
+        P->fwd = t_forward;
+        P->inv = Q->link->inv ? t_inverse : 0;
+    }
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_ob_tran_selftest (void) {return 0;}
+#else
+
+int pj_ob_tran_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=ob_tran +a=6400000 +o_proj=latlon +o_lon_p=20 +o_lat_p=20 +lon_0=180"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {-2.6856872138416592, 1.2374302350496296},
+        {-2.6954069748943286, 1.2026833954513816},
+        {-2.8993663925401947, 1.2374302350496296},
+        {-2.8896466314875244, 1.2026833954513816},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 121.5518748407577,  -2.5361001573966084},
+        { 63.261184340201858,  17.585319578673531},
+        {-141.10073322351622,  26.091712304855108},
+        {-65.862385598848391,  51.830295078417215},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+#endif
diff --git a/src/PJ_ocea.c b/src/PJ_ocea.c
index 8c7bd16..2a3235c 100644
--- a/src/PJ_ocea.c
+++ b/src/PJ_ocea.c
@@ -1,68 +1,153 @@
-#define PROJ_PARMS__ \
-	double	rok; \
-	double	rtk; \
-	double	sinphi; \
-	double	cosphi; \
-	double	singam; \
-	double	cosgam;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(ocea, "Oblique Cylindrical Equal Area") "\n\tCyl, Sph"
-	"lonc= alpha= or\n\tlat_1= lat_2= lon_1= lon_2=";
-FORWARD(s_forward); /* spheroid */
-	double t;
-
-	xy.y = sin(lp.lam);
-/*
-	xy.x = atan2((tan(lp.phi) * P->cosphi + P->sinphi * xy.y) , cos(lp.lam));
-*/
-	t = cos(lp.lam);
-	xy.x = atan((tan(lp.phi) * P->cosphi + P->sinphi * xy.y) / t);
-	if (t < 0.)
-		xy.x += PI;
-	xy.x *= P->rtk;
-	xy.y = P->rok * (P->sinphi * sin(lp.phi) - P->cosphi * cos(lp.phi) * xy.y);
-	return (xy);
+    "lonc= alpha= or\n\tlat_1= lat_2= lon_1= lon_2=";
+
+struct pj_opaque {
+    double  rok;
+    double  rtk;
+    double  sinphi;
+    double  cosphi;
+    double  singam;
+    double  cosgam;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double t;
+
+    xy.y = sin(lp.lam);
+    t = cos(lp.lam);
+    xy.x = atan((tan(lp.phi) * Q->cosphi + Q->sinphi * xy.y) / t);
+    if (t < 0.)
+        xy.x += M_PI;
+    xy.x *= Q->rtk;
+    xy.y = Q->rok * (Q->sinphi * sin(lp.phi) - Q->cosphi * cos(lp.phi) * xy.y);
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double t, s;
+
+    xy.y /= Q->rok;
+    xy.x /= Q->rtk;
+    t = sqrt(1. - xy.y * xy.y);
+    lp.phi = asin(xy.y * Q->sinphi + t * Q->cosphi * (s = sin(xy.x)));
+    lp.lam = atan2(t * Q->sinphi * s - xy.y * Q->cosphi,
+        t * cos(xy.x));
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(ocea) {
+    double phi_0=0.0, phi_1, phi_2, lam_1, lam_2, lonz, alpha;
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->rok = P->a / P->k0;
+    Q->rtk = P->a * P->k0;
+    /*If the keyword "alpha" is found in the sentence then use 1point+1azimuth*/
+    if ( pj_param(P->ctx, P->params, "talpha").i) {
+        /*Define Pole of oblique transformation from 1 point & 1 azimuth*/
+        alpha   = pj_param(P->ctx, P->params, "ralpha").f;
+        lonz = pj_param(P->ctx, P->params, "rlonc").f;
+        /*Equation 9-8 page 80 (http://pubs.usgs.gov/pp/1395/report.pdf)*/
+        Q->singam = atan(-cos(alpha)/(-sin(phi_0) * sin(alpha))) + lonz;
+        /*Equation 9-7 page 80 (http://pubs.usgs.gov/pp/1395/report.pdf)*/
+        Q->sinphi = asin(cos(phi_0) * sin(alpha));
+    /*If the keyword "alpha" is NOT found in the sentence then use 2points*/
+    } else {
+        /*Define Pole of oblique transformation from 2 points*/
+        phi_1 = pj_param(P->ctx, P->params, "rlat_1").f;
+        phi_2 = pj_param(P->ctx, P->params, "rlat_2").f;
+        lam_1 = pj_param(P->ctx, P->params, "rlon_1").f;
+        lam_2 = pj_param(P->ctx, P->params, "rlon_2").f;
+        /*Equation 9-1 page 80 (http://pubs.usgs.gov/pp/1395/report.pdf)*/
+        Q->singam = atan2(cos(phi_1) * sin(phi_2) * cos(lam_1) -
+            sin(phi_1) * cos(phi_2) * cos(lam_2),
+            sin(phi_1) * cos(phi_2) * sin(lam_2) -
+            cos(phi_1) * sin(phi_2) * sin(lam_1) );
+        /*Equation 9-2 page 80 (http://pubs.usgs.gov/pp/1395/report.pdf)*/
+        Q->sinphi = atan(-cos(Q->singam - lam_1) / tan(phi_1));
+    }
+    P->lam0 = Q->singam + M_HALFPI;
+    Q->cosphi = cos(Q->sinphi);
+    Q->sinphi = sin(Q->sinphi);
+    Q->cosgam = cos(Q->singam);
+    Q->singam = sin(Q->singam);
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    P->es = 0.;
+
+    return P;
 }
-INVERSE(s_inverse); /* spheroid */
-	double t, s;
-
-	xy.y /= P->rok;
-	xy.x /= P->rtk;
-	t = sqrt(1. - xy.y * xy.y);
-	lp.phi = asin(xy.y * P->sinphi + t * P->cosphi * (s = sin(xy.x)));
-	lp.lam = atan2(t * P->sinphi * s - xy.y * P->cosphi,
-		t * cos(xy.x));
-	return (lp);
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_ocea_selftest (void) {return 0;}
+#else
+
+int pj_ocea_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=ocea   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {127964312562778.156,  1429265667691.05786},
+        {129394957619297.641,  1429265667691.06812},
+        {127964312562778.188, -1429265667691.0498},
+        {129394957619297.688, -1429265667691.03955},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 179.999999999860108,  2.79764548403721305e-10},
+        {-179.999999999860108,  2.7976454840372327e-10},
+        { 179.999999999860108, -2.7976454840372327e-10},
+        {-179.999999999860108, -2.79764548403721305e-10},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(ocea)
-	double phi_0=0.0, phi_1, phi_2, lam_1, lam_2, lonz, alpha;
-
-	P->rok = P->a / P->k0;
-	P->rtk = P->a * P->k0;
-	if ( pj_param(P->ctx, P->params, "talpha").i) {
-		alpha	= pj_param(P->ctx, P->params, "ralpha").f;
-		lonz = pj_param(P->ctx, P->params, "rlonc").f;
-		P->singam = atan(-cos(alpha)/(-sin(phi_0) * sin(alpha))) + lonz;
-		P->sinphi = asin(cos(phi_0) * sin(alpha));
-	} else {
-		phi_1 = pj_param(P->ctx, P->params, "rlat_1").f;
-		phi_2 = pj_param(P->ctx, P->params, "rlat_2").f;
-		lam_1 = pj_param(P->ctx, P->params, "rlon_1").f;
-		lam_2 = pj_param(P->ctx, P->params, "rlon_2").f;
-		P->singam = atan2(cos(phi_1) * sin(phi_2) * cos(lam_1) -
-			sin(phi_1) * cos(phi_2) * cos(lam_2),
-			sin(phi_1) * cos(phi_2) * sin(lam_2) -
-			cos(phi_1) * sin(phi_2) * sin(lam_1) );
-		P->sinphi = atan(-cos(P->singam - lam_1) / tan(phi_1));
-	}
-	P->lam0 = P->singam + HALFPI;
-	P->cosphi = cos(P->sinphi);
-	P->sinphi = sin(P->sinphi);
-	P->cosgam = cos(P->singam);
-	P->singam = sin(P->singam);
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-	P->es = 0.;
-ENDENTRY(P)
+
+
+#endif
diff --git a/src/PJ_oea.c b/src/PJ_oea.c
index b84a7ea..f29dcfd 100644
--- a/src/PJ_oea.c
+++ b/src/PJ_oea.c
@@ -1,58 +1,140 @@
-#define PROJ_PARMS__ \
-	double	theta; \
-	double	m, n; \
-	double	two_r_m, two_r_n, rm, rn, hm, hn; \
-	double	cp0, sp0;
 #define PJ_LIB__
 #include	<projects.h>
+
 PROJ_HEAD(oea, "Oblated Equal Area") "\n\tMisc Sph\n\tn= m= theta=";
-FORWARD(s_forward); /* sphere */
+
+struct pj_opaque {
+	double	theta;
+	double	m, n;
+	double	two_r_m, two_r_n, rm, rn, hm, hn;
+	double	cp0, sp0;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double Az, M, N, cp, sp, cl, shz;
 
 	cp = cos(lp.phi);
 	sp = sin(lp.phi);
 	cl = cos(lp.lam);
-	Az = aatan2(cp * sin(lp.lam), P->cp0 * sp - P->sp0 * cp * cl) + P->theta;
-	shz = sin(0.5 * aacos(P->ctx, P->sp0 * sp + P->cp0 * cp * cl));
+	Az = aatan2(cp * sin(lp.lam), Q->cp0 * sp - Q->sp0 * cp * cl) + Q->theta;
+	shz = sin(0.5 * aacos(P->ctx, Q->sp0 * sp + Q->cp0 * cp * cl));
 	M = aasin(P->ctx, shz * sin(Az));
-	N = aasin(P->ctx, shz * cos(Az) * cos(M) / cos(M * P->two_r_m));
-	xy.y = P->n * sin(N * P->two_r_n);
-	xy.x = P->m * sin(M * P->two_r_m) * cos(N) / cos(N * P->two_r_n);
-	return (xy);
+	N = aasin(P->ctx, shz * cos(Az) * cos(M) / cos(M * Q->two_r_m));
+	xy.y = Q->n * sin(N * Q->two_r_n);
+	xy.x = Q->m * sin(M * Q->two_r_m) * cos(N) / cos(N * Q->two_r_n);
+
+	return xy;
 }
-INVERSE(s_inverse); /* sphere */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double N, M, xp, yp, z, Az, cz, sz, cAz;
 
-	N = P->hn * aasin(P->ctx,xy.y * P->rn);
-	M = P->hm * aasin(P->ctx,xy.x * P->rm * cos(N * P->two_r_n) / cos(N));
+	N = Q->hn * aasin(P->ctx,xy.y * Q->rn);
+	M = Q->hm * aasin(P->ctx,xy.x * Q->rm * cos(N * Q->two_r_n) / cos(N));
 	xp = 2. * sin(M);
-	yp = 2. * sin(N) * cos(M * P->two_r_m) / cos(M);
-	cAz = cos(Az = aatan2(xp, yp) - P->theta);
+	yp = 2. * sin(N) * cos(M * Q->two_r_m) / cos(M);
+	cAz = cos(Az = aatan2(xp, yp) - Q->theta);
 	z = 2. * aasin(P->ctx, 0.5 * hypot(xp, yp));
 	sz = sin(z);
 	cz = cos(z);
-	lp.phi = aasin(P->ctx, P->sp0 * cz + P->cp0 * sz * cAz);
+	lp.phi = aasin(P->ctx, Q->sp0 * cz + Q->cp0 * sz * cAz);
 	lp.lam = aatan2(sz * sin(Az),
-		P->cp0 * cz - P->sp0 * sz * cAz);
-	return (lp);
+		Q->cp0 * cz - Q->sp0 * sz * cAz);
+
+	return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(oea)
-	if (((P->n = pj_param(P->ctx, P->params, "dn").f) <= 0.) ||
-		((P->m = pj_param(P->ctx, P->params, "dm").f) <= 0.))
+
+
+PJ *PROJECTION(oea) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	if (((Q->n = pj_param(P->ctx, P->params, "dn").f) <= 0.) ||
+		((Q->m = pj_param(P->ctx, P->params, "dm").f) <= 0.))
 		E_ERROR(-39)
 	else {
-		P->theta = pj_param(P->ctx, P->params, "rtheta").f;
-		P->sp0 = sin(P->phi0);
-		P->cp0 = cos(P->phi0);
-		P->rn = 1./ P->n;
-		P->rm = 1./ P->m;
-		P->two_r_n = 2. * P->rn;
-		P->two_r_m = 2. * P->rm;
-		P->hm = 0.5 * P->m;
-		P->hn = 0.5 * P->n;
+		Q->theta = pj_param(P->ctx, P->params, "rtheta").f;
+		Q->sp0 = sin(P->phi0);
+		Q->cp0 = cos(P->phi0);
+		Q->rn = 1./ Q->n;
+		Q->rm = 1./ Q->m;
+		Q->two_r_n = 2. * Q->rn;
+		Q->two_r_m = 2. * Q->rm;
+		Q->hm = 0.5 * Q->m;
+		Q->hn = 0.5 * Q->n;
 		P->fwd = s_forward;
 		P->inv = s_inverse;
 		P->es = 0.;
 	}
-ENDENTRY(P)
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_oea_selftest (void) {return 0;}
+#else
+
+int pj_oea_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=oea   +a=6400000    +lat_1=0.5 +lat_2=2 +n=1 +m=2 +theta=3"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 228926.872097864107,  99870.4884300760023},
+        { 217242.584036940476, -123247.885607474513},
+        {-217242.584036940476,  123247.885607474556},
+        {-228926.872097864078, -99870.4884300760168},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017411857167771369,   0.000987726819566195693},
+        { 0.00183489288577854998, -0.000800312481495174641},
+        {-0.00183489288577854954,  0.000800312481495174966},
+        {-0.00174118571677713712, -0.000987726819566195043},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_omerc.c b/src/PJ_omerc.c
index 310d774..5dd9c20 100644
--- a/src/PJ_omerc.c
+++ b/src/PJ_omerc.c
@@ -21,93 +21,125 @@
 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
-#define PROJ_PARMS__ \
-	double	A, B, E, AB, ArB, BrA, rB, singam, cosgam, sinrot, cosrot; \
-	double  v_pole_n, v_pole_s, u_0; \
-	int no_rot;
 #define PJ_LIB__
 #include <projects.h>
 
 PROJ_HEAD(omerc, "Oblique Mercator")
-	"\n\tCyl, Sph&Ell no_rot\n\t"
-"alpha= [gamma=] [no_off] lonc= or\n\t lon_1= lat_1= lon_2= lat_2=";
-#define TOL	1.e-7
-#define EPS	1.e-10
-
-FORWARD(e_forward); /* ellipsoid */
-	double  Q, S, T, U, V, temp, u, v;
-
-	if (fabs(fabs(lp.phi) - HALFPI) > EPS) {
-		Q = P->E / pow(pj_tsfn(lp.phi, sin(lp.phi), P->e), P->B);
-		temp = 1. / Q;
-		S = .5 * (Q - temp);
-		T = .5 * (Q + temp);
-		V = sin(P->B * lp.lam);
-		U = (S * P->singam - V * P->cosgam) / T;
-		if (fabs(fabs(U) - 1.0) < EPS)
-			F_ERROR;
-		v = 0.5 * P->ArB * log((1. - U)/(1. + U));
-		temp = cos(P->B * lp.lam);
+    "\n\tCyl, Sph&Ell no_rot\n\t"
+    "alpha= [gamma=] [no_off] lonc= or\n\t lon_1= lat_1= lon_2= lat_2=";
+
+struct pj_opaque {
+    double  A, B, E, AB, ArB, BrA, rB, singam, cosgam, sinrot, cosrot;
+    double  v_pole_n, v_pole_s, u_0;
+    int no_rot;
+};
+
+#define TOL 1.e-7
+#define EPS 1.e-10
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double S, T, U, V, W, temp, u, v;
+
+    if (fabs(fabs(lp.phi) - M_HALFPI) > EPS) {
+        W = Q->E / pow(pj_tsfn(lp.phi, sin(lp.phi), P->e), Q->B);
+        temp = 1. / W;
+        S = .5 * (W - temp);
+        T = .5 * (W + temp);
+        V = sin(Q->B * lp.lam);
+        U = (S * Q->singam - V * Q->cosgam) / T;
+        if (fabs(fabs(U) - 1.0) < EPS)
+            F_ERROR;
+        v = 0.5 * Q->ArB * log((1. - U)/(1. + U));
+        temp = cos(Q->B * lp.lam);
                 if(fabs(temp) < TOL) {
-                    u = P->A * lp.lam;
+                    u = Q->A * lp.lam;
                 } else {
-                    u = P->ArB * atan2((S * P->cosgam + V * P->singam), temp);
+                    u = Q->ArB * atan2((S * Q->cosgam + V * Q->singam), temp);
                 }
-	} else {
-		v = lp.phi > 0 ? P->v_pole_n : P->v_pole_s;
-		u = P->ArB * lp.phi;
-	}
-	if (P->no_rot) {
-		xy.x = u;
-		xy.y = v;
-	} else {
-		u -= P->u_0;
-		xy.x = v * P->cosrot + u * P->sinrot;
-		xy.y = u * P->cosrot - v * P->sinrot;
-	}
-	return (xy);
+    } else {
+        v = lp.phi > 0 ? Q->v_pole_n : Q->v_pole_s;
+        u = Q->ArB * lp.phi;
+    }
+    if (Q->no_rot) {
+        xy.x = u;
+        xy.y = v;
+    } else {
+        u -= Q->u_0;
+        xy.x = v * Q->cosrot + u * Q->sinrot;
+        xy.y = u * Q->cosrot - v * Q->sinrot;
+    }
+    return xy;
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  u, v, Qp, Sp, Tp, Vp, Up;
+
+    if (Q->no_rot) {
+        v = xy.y;
+        u = xy.x;
+    } else {
+        v = xy.x * Q->cosrot - xy.y * Q->sinrot;
+        u = xy.y * Q->cosrot + xy.x * Q->sinrot + Q->u_0;
+    }
+    Qp = exp(- Q->BrA * v);
+    Sp = .5 * (Qp - 1. / Qp);
+    Tp = .5 * (Qp + 1. / Qp);
+    Vp = sin(Q->BrA * u);
+    Up = (Vp * Q->cosgam + Sp * Q->singam) / Tp;
+    if (fabs(fabs(Up) - 1.) < EPS) {
+        lp.lam = 0.;
+        lp.phi = Up < 0. ? -M_HALFPI : M_HALFPI;
+    } else {
+        lp.phi = Q->E / sqrt((1. + Up) / (1. - Up));
+        if ((lp.phi = pj_phi2(P->ctx, pow(lp.phi, 1. / Q->B), P->e)) == HUGE_VAL)
+            I_ERROR;
+        lp.lam = - Q->rB * atan2((Sp * Q->cosgam -
+            Vp * Q->singam), cos(Q->BrA * u));
+    }
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-INVERSE(e_inverse); /* ellipsoid */
-	double  u, v, Qp, Sp, Tp, Vp, Up;
-
-	if (P->no_rot) {
-		v = xy.y;
-		u = xy.x;
-	} else {
-		v = xy.x * P->cosrot - xy.y * P->sinrot;
-		u = xy.y * P->cosrot + xy.x * P->sinrot + P->u_0;
-	}
-	Qp = exp(- P->BrA * v);
-	Sp = .5 * (Qp - 1. / Qp);
-	Tp = .5 * (Qp + 1. / Qp);
-	Vp = sin(P->BrA * u);
-	Up = (Vp * P->cosgam + Sp * P->singam) / Tp;
-	if (fabs(fabs(Up) - 1.) < EPS) {
-		lp.lam = 0.;
-		lp.phi = Up < 0. ? -HALFPI : HALFPI;
-	} else {
-		lp.phi = P->E / sqrt((1. + Up) / (1. - Up));
-		if ((lp.phi = pj_phi2(P->ctx, pow(lp.phi, 1. / P->B), P->e)) == HUGE_VAL)
-			I_ERROR;
-		lp.lam = - P->rB * atan2((Sp * P->cosgam -
-			Vp * P->singam), cos(P->BrA * u));
-	}
-	return (lp);
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(omerc)
-	double con, com, cosph0, D, F, H, L, sinph0, p, J, gamma=0,
-		gamma0, lamc=0, lam1=0, lam2=0, phi1=0, phi2=0, alpha_c;
-	int alp, gam, no_off = 0;
 
-	P->no_rot = pj_param(P->ctx, P->params, "tno_rot").i;
+
+PJ *PROJECTION(omerc) {
+    double con, com, cosph0, D, F, H, L, sinph0, p, J, gamma=0,
+        gamma0, lamc=0, lam1=0, lam2=0, phi1=0, phi2=0, alpha_c=0;
+    int alp, gam, no_off = 0;
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->no_rot = pj_param(P->ctx, P->params, "tno_rot").i;
         if ((alp = pj_param(P->ctx, P->params, "talpha").i) != 0)
-		alpha_c = pj_param(P->ctx, P->params, "ralpha").f;
+        alpha_c = pj_param(P->ctx, P->params, "ralpha").f;
         if ((gam = pj_param(P->ctx, P->params, "tgamma").i) != 0)
-		gamma = pj_param(P->ctx, P->params, "rgamma").f;
-	if (alp || gam) {
-		lamc	= pj_param(P->ctx, P->params, "rlonc").f;
-		no_off = 
+        gamma = pj_param(P->ctx, P->params, "rgamma").f;
+    if (alp || gam) {
+        lamc    = pj_param(P->ctx, P->params, "rlonc").f;
+        no_off =
                     /* For libproj4 compatability */
                     pj_param(P->ctx, P->params, "tno_off").i
                     /* for backward compatibility */
@@ -118,86 +150,133 @@ ENTRY0(omerc)
             pj_param(P->ctx, P->params, "sno_uoff");
             pj_param(P->ctx, P->params, "sno_off");
         }
-	} else {
-		lam1 = pj_param(P->ctx, P->params, "rlon_1").f;
-		phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
-		lam2 = pj_param(P->ctx, P->params, "rlon_2").f;
-		phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
-		if (fabs(phi1 - phi2) <= TOL ||
-			(con = fabs(phi1)) <= TOL ||
-			fabs(con - HALFPI) <= TOL ||
-			fabs(fabs(P->phi0) - HALFPI) <= TOL ||
-			fabs(fabs(phi2) - HALFPI) <= TOL) E_ERROR(-33);
-	}
-	com = sqrt(P->one_es);
-	if (fabs(P->phi0) > EPS) {
-		sinph0 = sin(P->phi0);
-		cosph0 = cos(P->phi0);
-		con = 1. - P->es * sinph0 * sinph0;
-		P->B = cosph0 * cosph0;
-		P->B = sqrt(1. + P->es * P->B * P->B / P->one_es);
-		P->A = P->B * P->k0 * com / con;
-		D = P->B * com / (cosph0 * sqrt(con));
-		if ((F = D * D - 1.) <= 0.)
-			F = 0.;
-		else {
-			F = sqrt(F);
-			if (P->phi0 < 0.)
-				F = -F;
-		}
-		P->E = F += D;
-		P->E *= pow(pj_tsfn(P->phi0, sinph0, P->e), P->B);
-	} else {
-		P->B = 1. / com;
-		P->A = P->k0;
-		P->E = D = F = 1.;
-	}
-	if (alp || gam) {
-		if (alp) {
-			gamma0 = asin(sin(alpha_c) / D);
-			if (!gam)
-				gamma = alpha_c;
-		} else
-			alpha_c = asin(D*sin(gamma0 = gamma));
-		if ((con = fabs(alpha_c)) <= TOL ||
-			fabs(con - PI) <= TOL ||
-			fabs(fabs(P->phi0) - HALFPI) <= TOL)
-			E_ERROR(-32);
-		P->lam0 = lamc - asin(.5 * (F - 1. / F) *
-		   tan(gamma0)) / P->B;
-	} else {
-		H = pow(pj_tsfn(phi1, sin(phi1), P->e), P->B);
-		L = pow(pj_tsfn(phi2, sin(phi2), P->e), P->B);
-		F = P->E / H;
-		p = (L - H) / (L + H);
-		J = P->E * P->E;
-		J = (J - L * H) / (J + L * H);
-		if ((con = lam1 - lam2) < -PI)
-			lam2 -= TWOPI;
-		else if (con > PI)
-			lam2 += TWOPI;
-		P->lam0 = adjlon(.5 * (lam1 + lam2) - atan(
-		   J * tan(.5 * P->B * (lam1 - lam2)) / p) / P->B);
-		gamma0 = atan(2. * sin(P->B * adjlon(lam1 - P->lam0)) /
-		   (F - 1. / F));
-		gamma = alpha_c = asin(D * sin(gamma0));
-	}
-	P->singam = sin(gamma0);
-	P->cosgam = cos(gamma0);
-	P->sinrot = sin(gamma);
-	P->cosrot = cos(gamma);
-	P->BrA = 1. / (P->ArB = P->A * (P->rB = 1. / P->B));
-	P->AB = P->A * P->B;
-	if (no_off)
-		P->u_0 = 0;
-	else {
-		P->u_0 = fabs(P->ArB * atan2(sqrt(D * D - 1.), cos(alpha_c)));
-		if (P->phi0 < 0.)
-			P->u_0 = - P->u_0;
-	}
-	F = 0.5 * gamma0;
-	P->v_pole_n = P->ArB * log(tan(FORTPI - F));
-	P->v_pole_s = P->ArB * log(tan(FORTPI + F));
-	P->inv = e_inverse;
-	P->fwd = e_forward;
-ENDENTRY(P)
+    } else {
+        lam1 = pj_param(P->ctx, P->params, "rlon_1").f;
+        phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
+        lam2 = pj_param(P->ctx, P->params, "rlon_2").f;
+        phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
+        if (fabs(phi1 - phi2) <= TOL ||
+            (con = fabs(phi1)) <= TOL ||
+            fabs(con - M_HALFPI) <= TOL ||
+            fabs(fabs(P->phi0) - M_HALFPI) <= TOL ||
+            fabs(fabs(phi2) - M_HALFPI) <= TOL) E_ERROR(-33);
+    }
+    com = sqrt(P->one_es);
+    if (fabs(P->phi0) > EPS) {
+        sinph0 = sin(P->phi0);
+        cosph0 = cos(P->phi0);
+        con = 1. - P->es * sinph0 * sinph0;
+        Q->B = cosph0 * cosph0;
+        Q->B = sqrt(1. + P->es * Q->B * Q->B / P->one_es);
+        Q->A = Q->B * P->k0 * com / con;
+        D = Q->B * com / (cosph0 * sqrt(con));
+        if ((F = D * D - 1.) <= 0.)
+            F = 0.;
+        else {
+            F = sqrt(F);
+            if (P->phi0 < 0.)
+                F = -F;
+        }
+        Q->E = F += D;
+        Q->E *= pow(pj_tsfn(P->phi0, sinph0, P->e), Q->B);
+    } else {
+        Q->B = 1. / com;
+        Q->A = P->k0;
+        Q->E = D = F = 1.;
+    }
+    if (alp || gam) {
+        if (alp) {
+            gamma0 = asin(sin(alpha_c) / D);
+            if (!gam)
+                gamma = alpha_c;
+        } else
+            alpha_c = asin(D*sin(gamma0 = gamma));
+        if ((con = fabs(alpha_c)) <= TOL ||
+            fabs(con - M_PI) <= TOL ||
+            fabs(fabs(P->phi0) - M_HALFPI) <= TOL)
+            E_ERROR(-32);
+        P->lam0 = lamc - asin(.5 * (F - 1. / F) *
+           tan(gamma0)) / Q->B;
+    } else {
+        H = pow(pj_tsfn(phi1, sin(phi1), P->e), Q->B);
+        L = pow(pj_tsfn(phi2, sin(phi2), P->e), Q->B);
+        F = Q->E / H;
+        p = (L - H) / (L + H);
+        J = Q->E * Q->E;
+        J = (J - L * H) / (J + L * H);
+        if ((con = lam1 - lam2) < -M_PI)
+            lam2 -= M_TWOPI;
+        else if (con > M_PI)
+            lam2 += M_TWOPI;
+        P->lam0 = adjlon(.5 * (lam1 + lam2) - atan(
+           J * tan(.5 * Q->B * (lam1 - lam2)) / p) / Q->B);
+        gamma0 = atan(2. * sin(Q->B * adjlon(lam1 - P->lam0)) /
+           (F - 1. / F));
+        gamma = alpha_c = asin(D * sin(gamma0));
+    }
+    Q->singam = sin(gamma0);
+    Q->cosgam = cos(gamma0);
+    Q->sinrot = sin(gamma);
+    Q->cosrot = cos(gamma);
+    Q->BrA = 1. / (Q->ArB = Q->A * (Q->rB = 1. / Q->B));
+    Q->AB = Q->A * Q->B;
+    if (no_off)
+        Q->u_0 = 0;
+    else {
+        Q->u_0 = fabs(Q->ArB * atan2(sqrt(D * D - 1.), cos(alpha_c)));
+        if (P->phi0 < 0.)
+            Q->u_0 = - Q->u_0;
+    }
+    F = 0.5 * gamma0;
+    Q->v_pole_n = Q->ArB * log(tan(M_FORTPI - F));
+    Q->v_pole_s = Q->ArB * log(tan(M_FORTPI + F));
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_omerc_selftest (void) {return 0;}
+#else
+
+int pj_omerc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=omerc   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222650.796885261341,  110642.229314983808},
+        { 222650.796885261341, -110642.229314983808},
+        {-222650.796885261545,  110642.229314983808},
+        {-222650.796885261545, -110642.229314983808},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.00179663056816996357,  0.000904369474808157338},
+        { 0.00179663056816996357, -0.000904369474820879583},
+        {-0.0017966305681604536,   0.000904369474808157338},
+        {-0.0017966305681604536,  -0.000904369474820879583},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
+
+
+#endif
diff --git a/src/PJ_ortho.c b/src/PJ_ortho.c
index 202b017..783777c 100644
--- a/src/PJ_ortho.c
+++ b/src/PJ_ortho.c
@@ -1,42 +1,53 @@
-#define PROJ_PARMS__ \
-	double	sinph0; \
-	double	cosph0; \
-	int		mode;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(ortho, "Orthographic") "\n\tAzi, Sph.";
+
+struct pj_opaque {
+	double	sinph0;
+	double	cosph0;
+	int		mode;
+};
+
 #define EPS10 1.e-10
 #define N_POLE	0
 #define S_POLE 1
 #define EQUIT	2
 #define OBLIQ	3
-FORWARD(s_forward); /* spheroid */
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double  coslam, cosphi, sinphi;
 
 	cosphi = cos(lp.phi);
 	coslam = cos(lp.lam);
-	switch (P->mode) {
+	switch (Q->mode) {
 	case EQUIT:
 		if (cosphi * coslam < - EPS10) F_ERROR;
 		xy.y = sin(lp.phi);
 		break;
 	case OBLIQ:
-		if (P->sinph0 * (sinphi = sin(lp.phi)) +
-		   P->cosph0 * cosphi * coslam < - EPS10) F_ERROR;
-		xy.y = P->cosph0 * sinphi - P->sinph0 * cosphi * coslam;
+		if (Q->sinph0 * (sinphi = sin(lp.phi)) +
+		   Q->cosph0 * cosphi * coslam < - EPS10) F_ERROR;
+		xy.y = Q->cosph0 * sinphi - Q->sinph0 * cosphi * coslam;
 		break;
 	case N_POLE:
 		coslam = - coslam;
 	case S_POLE:
-		if (fabs(lp.phi - P->phi0) - EPS10 > HALFPI) F_ERROR;
+		if (fabs(lp.phi - P->phi0) - EPS10 > M_HALFPI) F_ERROR;
 		xy.y = cosphi * coslam;
 		break;
 	}
 	xy.x = cosphi * sin(lp.lam);
-	return (xy);
+	return xy;
 }
 
-INVERSE(s_inverse); /* spheroid */
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
     double  rh, cosc, sinc;
 
     if ((sinc = (rh = hypot(xy.x, xy.y))) > 1.) {
@@ -48,7 +59,7 @@ INVERSE(s_inverse); /* spheroid */
         lp.phi = P->phi0;
         lp.lam = 0.0;
     } else {
-        switch (P->mode) {
+        switch (Q->mode) {
         case N_POLE:
             xy.y = -xy.y;
             lp.phi = acos(sinc);
@@ -62,34 +73,102 @@ INVERSE(s_inverse); /* spheroid */
             xy.y = cosc * rh;
             goto sinchk;
         case OBLIQ:
-            lp.phi = cosc * P->sinph0 + xy.y * sinc * P->cosph0 /rh;
-            xy.y = (cosc - P->sinph0 * lp.phi) * rh;
-            xy.x *= sinc * P->cosph0;
+            lp.phi = cosc * Q->sinph0 + xy.y * sinc * Q->cosph0 /rh;
+            xy.y = (cosc - Q->sinph0 * lp.phi) * rh;
+            xy.x *= sinc * Q->cosph0;
         sinchk:
             if (fabs(lp.phi) >= 1.)
-                lp.phi = lp.phi < 0. ? -HALFPI : HALFPI;
+                lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
             else
                 lp.phi = asin(lp.phi);
             break;
         }
-        lp.lam = (xy.y == 0. && (P->mode == OBLIQ || P->mode == EQUIT))
-             ? (xy.x == 0. ? 0. : xy.x < 0. ? -HALFPI : HALFPI)
+        lp.lam = (xy.y == 0. && (Q->mode == OBLIQ || Q->mode == EQUIT))
+             ? (xy.x == 0. ? 0. : xy.x < 0. ? -M_HALFPI : M_HALFPI)
                            : atan2(xy.x, xy.y);
     }
-    return (lp);
+    return lp;
 }
 
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(ortho)
-	if (fabs(fabs(P->phi0) - HALFPI) <= EPS10)
-		P->mode = P->phi0 < 0. ? S_POLE : N_POLE;
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(ortho) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	if (fabs(fabs(P->phi0) - M_HALFPI) <= EPS10)
+		Q->mode = P->phi0 < 0. ? S_POLE : N_POLE;
 	else if (fabs(P->phi0) > EPS10) {
-		P->mode = OBLIQ;
-		P->sinph0 = sin(P->phi0);
-		P->cosph0 = cos(P->phi0);
+		Q->mode = OBLIQ;
+		Q->sinph0 = sin(P->phi0);
+		Q->cosph0 = cos(P->phi0);
 	} else
-		P->mode = EQUIT;
+		Q->mode = EQUIT;
 	P->inv = s_inverse;
 	P->fwd = s_forward;
 	P->es = 0.;
-ENDENTRY(P)
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_ortho_selftest (void) {return 0;}
+#else
+
+int pj_ortho_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=ortho   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223322.76057672748,  111695.401198614476},
+        { 223322.76057672748, -111695.401198614476},
+        {-223322.76057672748,  111695.401198614476},
+        {-223322.76057672748, -111695.401198614476},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931102938101,  0.000895246554928338998},
+        { 0.0017904931102938101, -0.000895246554928338998},
+        {-0.0017904931102938101,  0.000895246554928338998},
+        {-0.0017904931102938101, -0.000895246554928338998},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_patterson.c b/src/PJ_patterson.c
new file mode 100644
index 0000000..f3a1842
--- /dev/null
+++ b/src/PJ_patterson.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2014 Bojan Savric
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * The Patterson Cylindrical projection was designed by Tom Patterson, US National
+ * Park Service, in 2014, using Flex Projector. The polynomial equations for the
+ * projection were developed by Bojan Savric, Oregon State University, in
+ * collaboration with Tom Patterson and Bernhard Jenny, Oregon State University.
+ *
+ * Java reference algorithm implemented by Bojan Savric in Java Map Projection
+ * Library (a Java port of PROJ.4) in the file PattersonProjection.java.
+ *
+ * References:
+ *    Java Map Projection Library
+ *       https://github.com/OSUCartography/JMapProjLib
+ *
+ *    Patterson Cylindrical Projection
+ *       http://shadedrelief.com/patterson/
+ *
+ *    Patterson, T., Savric, B., and Jenny, B. (2015). Cartographic Perspectives
+ *       (No.78). Describes the projection design and characteristics, and
+ *       developing the equations.    doi:10.14714/CP78.1270
+ *       http://dx.doi.org/10.14714/CP78.1270
+ *
+ * Port to PROJ.4 by Micah Cochran, 26 March 2016
+ */
+
+#define PJ_LIB__
+#include <projects.h>
+
+PROJ_HEAD(patterson, "Patterson Cylindrical") "\n\tCyl.";
+
+#define K1 1.0148
+#define K2 0.23185
+#define K3 -0.14499
+#define K4 0.02406
+#define C1 K1
+#define C2 (5.0 * K2)
+#define C3 (7.0 * K3)
+#define C4 (9.0 * K4)
+#define EPS11 1.0e-11
+#define MAX_Y 1.790857183
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double phi2;
+    (void) P;
+
+    phi2 = lp.phi * lp.phi;
+    xy.x = lp.lam;
+    xy.y = lp.phi * (K1 + phi2 * phi2 * (K2 + phi2 * (K3 + K4 * phi2)));
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double yc, tol, y2, f, fder;
+    (void) P;
+
+    yc = xy.y;
+
+    /* make sure y is inside valid range */
+    if (xy.y > MAX_Y) {
+        xy.y = MAX_Y;
+    } else if (xy.y < -MAX_Y) {
+        xy.y = -MAX_Y;
+    }
+
+    for (;;) { /* Newton-Raphson */
+        y2 = yc * yc;
+        f = (yc * (K1 + y2 * y2 * (K2 + y2 * (K3 + K4 * y2)))) - xy.y;
+        fder = C1 + y2 * y2 * (C2 + y2 * (C3 + C4 * y2));
+        yc -= tol = f / fder;
+        if (fabs(tol) < EPS11) {
+            break;
+        }
+    }
+    lp.phi = yc;
+
+    /* longitude */
+    lp.lam = xy.x;
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(patterson) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_patterson_selftest (void) {return 0;}
+#else
+
+int pj_patterson_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=patterson   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {223402.144255274179,  113354.250397779804},
+        {223402.144255274179,  -113354.250397779804},
+        {-223402.144255274179,  113354.250397779804},
+        {-223402.144255274179,  -113354.250397779804},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.00179049310978382265,  0.000882190140807953657},
+        {0.00179049310978382265,  -0.000882190140807953657},
+        {-0.00179049310978382265,  0.000882190140807953657},
+        {-0.00179049310978382265,  -0.000882190140807953657},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_poly.c b/src/PJ_poly.c
index ef5b890..50c0ee5 100644
--- a/src/PJ_poly.c
+++ b/src/PJ_poly.c
@@ -1,42 +1,67 @@
-#define PROJ_PARMS__ \
-	double ml0; \
-	double *en;
 #define PJ_LIB__
 #include <projects.h>
+
 PROJ_HEAD(poly, "Polyconic (American)")
 	"\n\tConic, Sph&Ell";
+
+struct pj_opaque {
+	double ml0; \
+	double *en;
+};
+
 #define TOL	1e-10
 #define CONV	1e-10
 #define N_ITER	10
 #define I_ITER 20
 #define ITOL 1.e-12
-FORWARD(e_forward); /* ellipsoid */
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double  ms, sp, cp;
 
-	if (fabs(lp.phi) <= TOL) { xy.x = lp.lam; xy.y = -P->ml0; }
-	else {
+	if (fabs(lp.phi) <= TOL) {
+        xy.x = lp.lam;
+        xy.y = -Q->ml0;
+    } else {
 		sp = sin(lp.phi);
 		ms = fabs(cp = cos(lp.phi)) > TOL ? pj_msfn(sp, cp, P->es) / sp : 0.;
 		xy.x = ms * sin(lp.lam *= sp);
-		xy.y = (pj_mlfn(lp.phi, sp, cp, P->en) - P->ml0) + ms * (1. - cos(lp.lam));
+		xy.y = (pj_mlfn(lp.phi, sp, cp, Q->en) - Q->ml0) + ms * (1. - cos(lp.lam));
 	}
-	return (xy);
+
+	return xy;
 }
-FORWARD(s_forward); /* spheroid */
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double  cot, E;
 
-	if (fabs(lp.phi) <= TOL) { xy.x = lp.lam; xy.y = P->ml0; }
-	else {
+	if (fabs(lp.phi) <= TOL) {
+        xy.x = lp.lam;
+        xy.y = Q->ml0;
+    } else {
 		cot = 1. / tan(lp.phi);
 		xy.x = sin(E = lp.lam * sin(lp.phi)) * cot;
 		xy.y = lp.phi - P->phi0 + cot * (1. - cos(E));
 	}
-	return (xy);
+
+	return xy;
 }
-INVERSE(e_inverse); /* ellipsoid */
-	xy.y += P->ml0;
-	if (fabs(xy.y) <= TOL) { lp.lam = xy.x; lp.phi = 0.; }
-	else {
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+	xy.y += Q->ml0;
+	if (fabs(xy.y) <= TOL) {
+        lp.lam = xy.x;
+        lp.phi = 0.;
+    } else {
 		double r, c, sp, cp, s2ph, ml, mlb, mlp, dPhi;
 		int i;
 
@@ -47,7 +72,7 @@ INVERSE(e_inverse); /* ellipsoid */
 			if (fabs(cp) < ITOL)
 				I_ERROR;
 			c = sp * (mlp = sqrt(1. - P->es * sp * sp)) / cp;
-			ml = pj_mlfn(lp.phi, sp, cp, P->en);
+			ml = pj_mlfn(lp.phi, sp, cp, Q->en);
 			mlb = ml * ml + r;
 			mlp = P->one_es / (mlp * mlp * mlp);
 			lp.phi += ( dPhi =
@@ -62,14 +87,20 @@ INVERSE(e_inverse); /* ellipsoid */
 		c = sin(lp.phi);
 		lp.lam = asin(xy.x * tan(lp.phi) * sqrt(1. - P->es * c * c)) / sin(lp.phi);
 	}
-	return (lp);
+
+	return lp;
 }
-INVERSE(s_inverse); /* spheroid */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
 	double B, dphi, tp;
 	int i;
 
-	if (fabs(xy.y = P->phi0 + xy.y) <= TOL) { lp.lam = xy.x; lp.phi = 0.; }
-	else {
+	if (fabs(xy.y = P->phi0 + xy.y) <= TOL) {
+        lp.lam = xy.x;
+        lp.phi = 0.;
+    } else {
 		lp.phi = xy.y;
 		B = xy.x * xy.x + xy.y * xy.y;
 		i = N_ITER;
@@ -82,18 +113,105 @@ INVERSE(s_inverse); /* spheroid */
 		if (! i) I_ERROR;
 		lp.lam = asin(xy.x * tan(lp.phi)) / sin(lp.phi);
 	}
-	return (lp);
+
+	return lp;
 }
-FREEUP; if (P) { if (P->en) pj_dalloc(P->en); pj_dalloc(P); } }
-ENTRY1(poly, en)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+    if (P->opaque->en)
+        pj_dealloc (P->opaque->en);
+    pj_dealloc (P->opaque);
+
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(poly) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
 	if (P->es) {
-		if (!(P->en = pj_enfn(P->es))) E_ERROR_0;
-		P->ml0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), P->en);
+		if (!(Q->en = pj_enfn(P->es))) E_ERROR_0;
+		Q->ml0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), Q->en);
 		P->inv = e_inverse;
 		P->fwd = e_forward;
 	} else {
-		P->ml0 = -P->phi0;
+		Q->ml0 = -P->phi0;
 		P->inv = s_inverse;
 		P->fwd = s_forward;
 	}
-ENDENTRY(P)
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_poly_selftest (void) {return 0;}
+#else
+
+int pj_poly_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=poly   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=poly   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222605.285770237475,  110642.194561440483},
+        { 222605.285770237475, -110642.194561440483},
+        {-222605.285770237475,  110642.194561440483},
+        {-222605.285770237475, -110642.194561440483},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223368.105210218986,  111769.110491224754},
+        { 223368.105210218986, -111769.110491224754},
+        {-223368.105210218986,  111769.110491224754},
+        {-223368.105210218986, -111769.110491224754},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.00179663056846135222,  0.000904369476631838518},
+        { 0.00179663056846135222, -0.000904369476631838518},
+        {-0.00179663056846135222,  0.000904369476631838518},
+        {-0.00179663056846135222, -0.000904369476631838518},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931100023887,  0.000895246554454779222},
+        { 0.0017904931100023887, -0.000895246554454779222},
+        {-0.0017904931100023887,  0.000895246554454779222},
+        {-0.0017904931100023887, -0.000895246554454779222},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_putp2.c b/src/PJ_putp2.c
index d6fcaea..4c5a417 100644
--- a/src/PJ_putp2.c
+++ b/src/PJ_putp2.c
@@ -1,13 +1,18 @@
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(putp2, "Putnins P2") "\n\tPCyl., Sph.";
+
 #define C_x	1.89490
 #define C_y	1.71848
 #define C_p 0.6141848493043784
 #define EPS	1e-10
 #define NITER	10
 #define PI_DIV_3	1.0471975511965977
-FORWARD(s_forward); /* spheroid */
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
 	double p, c, s, V;
 	int i;
 	(void) P;
@@ -27,15 +32,84 @@ FORWARD(s_forward); /* spheroid */
 		lp.phi = lp.phi < 0 ? - PI_DIV_3 : PI_DIV_3;
 	xy.x = C_x * lp.lam * (cos(lp.phi) - 0.5);
 	xy.y = C_y * sin(lp.phi);
-	return (xy);
+
+	return xy;
 }
-INVERSE(s_inverse); /* spheroid */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
 	double c;
 
 	lp.phi = aasin(P->ctx,xy.y / C_y);
 	lp.lam = xy.x / (C_x * ((c = cos(lp.phi)) - 0.5));
 	lp.phi = aasin(P->ctx,(lp.phi + sin(lp.phi) * (c - 1.)) / C_p);
-	return (lp);
+
+	return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(putp2) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(putp2) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_putp2_selftest (void) {return 0;}
+#else
+
+int pj_putp2_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=putp2   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 211638.039634339279,  117895.033043379764},
+        { 211638.039634339279, -117895.033043379764},
+        {-211638.039634339279,  117895.033043379764},
+        {-211638.039634339279, -117895.033043379764},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00188980221640386672,  0.000848201580276863377},
+        { 0.00188980221640386672, -0.000848201580276863377},
+        {-0.00188980221640386672,  0.000848201580276863377},
+        {-0.00188980221640386672, -0.000848201580276863377},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_putp3.c b/src/PJ_putp3.c
index 298ce55..26fc0a9 100644
--- a/src/PJ_putp3.c
+++ b/src/PJ_putp3.c
@@ -1,26 +1,171 @@
-#define PROJ_PARMS__ \
-	double	A;
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    double  A;
+};
+
 PROJ_HEAD(putp3, "Putnins P3") "\n\tPCyl., Sph.";
 PROJ_HEAD(putp3p, "Putnins P3'") "\n\tPCyl., Sph.";
-#define C	0.79788456
-#define RPISQ	0.1013211836
-FORWARD(s_forward); /* spheroid */
-	xy.x = C * lp.lam * (1. - P->A * lp.phi * lp.phi);
-	xy.y = C * lp.phi;
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	lp.phi = xy.y / C;
-	lp.lam = xy.x / (C * (1. - P->A * lp.phi * lp.phi));
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) {
-	P->es = 0.; P->inv = s_inverse; P->fwd = s_forward;
-	return P;
-}
-ENTRY0(putp3)  P->A = 4. * RPISQ; ENDENTRY(setup(P))
-ENTRY0(putp3p) P->A = 2. * RPISQ; ENDENTRY(setup(P))
+
+#define C       0.79788456
+#define RPISQ   0.1013211836
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+
+    xy.x = C * lp.lam * (1. - P->opaque->A * lp.phi * lp.phi);
+    xy.y = C * lp.phi;
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+
+    lp.phi = xy.y / C;
+    lp.lam = xy.x / (C * (1. - P->opaque->A * lp.phi * lp.phi));
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(putp3) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->A = 4. * RPISQ;
+
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+PJ *PROJECTION(putp3p) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->A = 2. * RPISQ;
+
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_putp3_selftest (void) {return 0;}
+#else
+
+int pj_putp3_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=putp3   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 178227.115507793525,  89124.5607860879827},
+        { 178227.115507793525, -89124.5607860879827},
+        {-178227.115507793525,  89124.5607860879827},
+        {-178227.115507793525, -89124.5607860879827},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00224405032986489889,  0.00112202516475805899},
+        { 0.00224405032986489889, -0.00112202516475805899},
+        {-0.00224405032986489889,  0.00112202516475805899},
+        {-0.00224405032986489889, -0.00112202516475805899},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_putp3p_selftest (void) {return 0;}
+#else
+
+int pj_putp3p_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=putp3p   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 178238.118539984745,  89124.5607860879827},
+        { 178238.118539984745, -89124.5607860879827},
+        {-178238.118539984745,  89124.5607860879827},
+        {-178238.118539984745, -89124.5607860879827},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00224405032969050844,  0.00112202516475805899},
+        { 0.00224405032969050844, -0.00112202516475805899},
+        {-0.00224405032969050844,  0.00112202516475805899},
+        {-0.00224405032969050844, -0.00112202516475805899},
+
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_putp4p.c b/src/PJ_putp4p.c
index 32036bb..9264d89 100644
--- a/src/PJ_putp4p.c
+++ b/src/PJ_putp4p.c
@@ -1,29 +1,177 @@
-#define PROJ_PARMS__ \
-	double	C_x, C_y;
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    double C_x, C_y;
+};
+
 PROJ_HEAD(putp4p, "Putnins P4'") "\n\tPCyl., Sph.";
 PROJ_HEAD(weren, "Werenskiold I") "\n\tPCyl., Sph.";
-FORWARD(s_forward); /* spheroid */
-	lp.phi = aasin(P->ctx,0.883883476 * sin(lp.phi));
-	xy.x = P->C_x * lp.lam * cos(lp.phi);
-	xy.x /= cos(lp.phi *= 0.333333333333333);
-	xy.y = P->C_y * sin(lp.phi);
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	lp.phi = aasin(P->ctx,xy.y / P->C_y);
-	lp.lam = xy.x * cos(lp.phi) / P->C_x;
-	lp.phi *= 3.;
-	lp.lam /= cos(lp.phi);
-	lp.phi = aasin(P->ctx,1.13137085 * sin(lp.phi));
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) {
-	P->es = 0.; P->inv = s_inverse; P->fwd = s_forward;
-	return P;
-}
-ENTRY0(putp4p) P->C_x = 0.874038744; P->C_y = 3.883251825; ENDENTRY(setup(P))
-ENTRY0(weren) P->C_x = 1.; P->C_y = 4.442882938; ENDENTRY(setup(P))
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    lp.phi = aasin(P->ctx,0.883883476 * sin(lp.phi));
+    xy.x = Q->C_x * lp.lam * cos(lp.phi);
+    xy.x /= cos(lp.phi *= 0.333333333333333);
+    xy.y = Q->C_y * sin(lp.phi);
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    lp.phi = aasin(P->ctx,xy.y / Q->C_y);
+    lp.lam = xy.x * cos(lp.phi) / Q->C_x;
+    lp.phi *= 3.;
+    lp.lam /= cos(lp.phi);
+    lp.phi = aasin(P->ctx,1.13137085 * sin(lp.phi));
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(putp4p) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->C_x = 0.874038744;
+    Q->C_y = 3.883251825;
+
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+PJ *PROJECTION(weren) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->C_x = 1.;
+    Q->C_y = 4.442882938;
+
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_putp4p_selftest (void) {return 0;}
+#else
+
+int pj_putp4p_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=putp4p   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 195241.47734938623,  127796.782307926231},
+        { 195241.47734938623, -127796.782307926231},
+        {-195241.47734938623,  127796.782307926231},
+        {-195241.47734938623, -127796.782307926231},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00204852830860296001,  0.000782480174932193733},
+        { 0.00204852830860296001, -0.000782480174932193733},
+        {-0.00204852830860296001,  0.000782480174932193733},
+        {-0.00204852830860296001, -0.000782480174932193733},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_weren_selftest (void) {return 0;}
+#else
+
+int pj_weren_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=weren   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223378.515757633519,  146214.093042288267},
+        { 223378.515757633519, -146214.093042288267},
+        {-223378.515757633519,  146214.093042288267},
+        {-223378.515757633519, -146214.093042288267},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00179049310987240413,  0.000683917989676492265},
+        { 0.00179049310987240413, -0.000683917989676492265},
+        {-0.00179049310987240413,  0.000683917989676492265},
+        {-0.00179049310987240413, -0.000683917989676492265},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_putp5.c b/src/PJ_putp5.c
index 8d3c59a..d4e59ee 100644
--- a/src/PJ_putp5.c
+++ b/src/PJ_putp5.c
@@ -1,26 +1,172 @@
-#define PROJ_PARMS__ \
-	double	A, B;
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    double  A, B;
+};
+
 PROJ_HEAD(putp5, "Putnins P5") "\n\tPCyl., Sph.";
 PROJ_HEAD(putp5p, "Putnins P5'") "\n\tPCyl., Sph.";
-#define C	1.01346
-#define D	1.2158542
-FORWARD(s_forward); /* spheroid */
-	xy.x = C * lp.lam * (P->A - P->B * sqrt(1. + D * lp.phi * lp.phi));
-	xy.y = C * lp.phi;
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	lp.phi = xy.y / C;
-	lp.lam = xy.x / (C * (P->A - P->B * sqrt(1. + D * lp.phi * lp.phi)));
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) {
-	P->es = 0.; P->inv = s_inverse; P->fwd = s_forward;
-	return P;
-}
-ENTRY0(putp5) P->A = 2.; P->B = 1.; ENDENTRY(setup(P))
-ENTRY0(putp5p) P->A = 1.5; P->B = 0.5; ENDENTRY(setup(P))
+
+#define C 1.01346
+#define D 1.2158542
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    xy.x = C * lp.lam * (Q->A - Q->B * sqrt(1. + D * lp.phi * lp.phi));
+    xy.y = C * lp.phi;
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+
+    lp.phi = xy.y / C;
+    lp.lam = xy.x / (C * (Q->A - Q->B * sqrt(1. + D * lp.phi * lp.phi)));
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(putp5) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->A = 2.;
+    Q->B = 1.;
+
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+PJ *PROJECTION(putp5p) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->A = 1.5;
+    Q->B = 0.5;
+
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_putp5_selftest (void) {return 0;}
+#else
+
+int pj_putp5_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=putp5   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 226367.21338056153,  113204.56855847509},
+        { 226367.21338056153, -113204.56855847509},
+        {-226367.21338056153,  113204.56855847509},
+        {-226367.21338056153, -113204.56855847509},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00176671315102969553,  0.000883356575387199546},
+        { 0.00176671315102969553, -0.000883356575387199546},
+        {-0.00176671315102969553,  0.000883356575387199546},
+        {-0.00176671315102969553, -0.000883356575387199546},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_putp5p_selftest (void) {return 0;}
+#else
+
+int pj_putp5p_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=putp5p   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 226388.175248755841,  113204.56855847509},
+        { 226388.175248755841, -113204.56855847509},
+        {-226388.175248755841,  113204.56855847509},
+        {-226388.175248755841, -113204.56855847509},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00176671315090204742,  0.000883356575387199546},
+        { 0.00176671315090204742, -0.000883356575387199546},
+        {-0.00176671315090204742,  0.000883356575387199546},
+        {-0.00176671315090204742, -0.000883356575387199546},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+#endif
diff --git a/src/PJ_putp6.c b/src/PJ_putp6.c
index 5909dd4..7c860cd 100644
--- a/src/PJ_putp6.c
+++ b/src/PJ_putp6.c
@@ -1,59 +1,196 @@
-#define PROJ_PARMS__ \
-	double C_x, C_y, A, B, D;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    double C_x, C_y, A, B, D;
+};
+
 PROJ_HEAD(putp6, "Putnins P6") "\n\tPCyl., Sph.";
 PROJ_HEAD(putp6p, "Putnins P6'") "\n\tPCyl., Sph.";
-#define EPS	1e-10
-#define NITER	10
+
+#define EPS      1e-10
+#define NITER    10
 #define CON_POLE 1.732050807568877
-FORWARD(s_forward); /* spheroid */
-	double p, r, V;
-	int i;
-
-	p = P->B * sin(lp.phi);
-	lp.phi *=  1.10265779;
-	for (i = NITER; i ; --i) {
-		r = sqrt(1. + lp.phi * lp.phi);
-		lp.phi -= V = ( (P->A - r) * lp.phi - log(lp.phi + r) - p ) /
-			(P->A - 2. * r);
-		if (fabs(V) < EPS)
-			break;
-	}
-	if (!i)
-		lp.phi = p < 0. ? -CON_POLE : CON_POLE;
-	xy.x = P->C_x * lp.lam * (P->D - sqrt(1. + lp.phi * lp.phi));
-	xy.y = P->C_y * lp.phi;
-	return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
-	double r;
-
-	lp.phi = xy.y / P->C_y;
-	r = sqrt(1. + lp.phi * lp.phi);
-	lp.lam = xy.x / (P->C_x * (P->D - r));
-	lp.phi = aasin( P->ctx, ( (P->A - r) * lp.phi - log(lp.phi + r) ) / P->B);
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) {
-	P->es = 0.;
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-	return P;
-}
-ENTRY0(putp6)
-	P->C_x = 1.01346;
-	P->C_y = 0.91910;
-	P->A   = 4.;
-	P->B   = 2.1471437182129378784;
-	P->D   = 2.;
-ENDENTRY(setup(P))
-ENTRY0(putp6p)
-	P->C_x = 0.44329;
-	P->C_y = 0.80404;
-	P->A   = 6.;
-	P->B   = 5.61125;
-	P->D   = 3.;
-ENDENTRY(setup(P))
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double p, r, V;
+    int i;
+
+    p = Q->B * sin(lp.phi);
+    lp.phi *=  1.10265779;
+    for (i = NITER; i ; --i) {
+        r = sqrt(1. + lp.phi * lp.phi);
+        lp.phi -= V = ( (Q->A - r) * lp.phi - log(lp.phi + r) - p ) /
+            (Q->A - 2. * r);
+        if (fabs(V) < EPS)
+            break;
+    }
+    if (!i)
+        lp.phi = p < 0. ? -CON_POLE : CON_POLE;
+    xy.x = Q->C_x * lp.lam * (Q->D - sqrt(1. + lp.phi * lp.phi));
+    xy.y = Q->C_y * lp.phi;
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double r;
+
+    lp.phi = xy.y / Q->C_y;
+    r = sqrt(1. + lp.phi * lp.phi);
+    lp.lam = xy.x / (Q->C_x * (Q->D - r));
+    lp.phi = aasin( P->ctx, ( (Q->A - r) * lp.phi - log(lp.phi + r) ) / Q->B);
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(putp6) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->C_x = 1.01346;
+    Q->C_y = 0.91910;
+    Q->A   = 4.;
+    Q->B   = 2.1471437182129378784;
+    Q->D   = 2.;
+
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+PJ *PROJECTION(putp6p) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->C_x = 0.44329;
+    Q->C_y = 0.80404;
+    Q->A   = 6.;
+    Q->B   = 5.61125;
+    Q->D   = 3.;
+
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_putp6_selftest (void) {return 0;}
+#else
+
+int pj_putp6_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=putp6   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 226369.395133402577,  110218.523796520662},
+        { 226369.395133402577, -110218.523796520749},
+        {-226369.395133402577,  110218.523796520662},
+        {-226369.395133402577, -110218.523796520749},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00176671315102969921,  0.000907295534210503544},
+        { 0.00176671315102969921, -0.000907295534205924308},
+        {-0.00176671315102969921,  0.000907295534210503544},
+        {-0.00176671315102969921, -0.000907295534205924308},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_putp6p_selftest (void) {return 0;}
+#else
+
+int pj_putp6p_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=putp6p   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 198034.195132195076,  125989.475461323193},
+        { 198034.195132195076, -125989.475461323193},
+        {-198034.195132195076,  125989.475461323193},
+        {-198034.195132195076, -125989.475461323193},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00201955053120177067,  0.000793716441164738612},
+        { 0.00201955053120177067, -0.000793716441164738612},
+        {-0.00201955053120177067,  0.000793716441164738612},
+        {-0.00201955053120177067, -0.000793716441164738612},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+#endif
diff --git a/src/PJ_qsc.c b/src/PJ_qsc.c
index 12cb9d6..e02369a 100644
--- a/src/PJ_qsc.c
+++ b/src/PJ_qsc.c
@@ -28,7 +28,7 @@
  * Other projection centers will not work!
  *
  * In the projection code below, each cube face is handled differently.
- * See the computation of the face parameter in the ENTRY0(qsc) function
+ * See the computation of the face parameter in the PROJECTION(qsc) function
  * and the handling of different face values (FACE_*) in the forward and
  * inverse projections.
  *
@@ -38,15 +38,18 @@
  * three areas of a cube face are handled by rotation of AREA_0.
  */
 
-#define PROJ_PARMS__ \
-        int face; \
-        double a_squared; \
-        double b; \
-        double one_minus_f; \
-        double one_minus_f_squared;
 #define PJ_LIB__
-#include        <projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+        int face;
+        double a_squared;
+        double b;
+        double one_minus_f;
+        double one_minus_f_squared;
+};
 PROJ_HEAD(qsc, "Quadrilateralized Spherical Cube") "\n\tAzi, Sph.";
+
 #define EPS10 1.e-10
 
 /* The six cube faces. */
@@ -66,316 +69,403 @@ PROJ_HEAD(qsc, "Quadrilateralized Spherical Cube") "\n\tAzi, Sph.";
 
 /* Helper function for forward projection: compute the theta angle
  * and determine the area number. */
-static double
-qsc_fwd_equat_face_theta(double phi, double y, double x, int *area) {
-        double theta;
-        if (phi < EPS10) {
+static double qsc_fwd_equat_face_theta(double phi, double y, double x, int *area) {
+    double theta;
+    if (phi < EPS10) {
+        *area = AREA_0;
+        theta = 0.0;
+    } else {
+        theta = atan2(y, x);
+        if (fabs(theta) <= M_FORTPI) {
             *area = AREA_0;
-            theta = 0.0;
+        } else if (theta > M_FORTPI && theta <= M_HALFPI + M_FORTPI) {
+            *area = AREA_1;
+            theta -= M_HALFPI;
+        } else if (theta > M_HALFPI + M_FORTPI || theta <= -(M_HALFPI + M_FORTPI)) {
+            *area = AREA_2;
+            theta = (theta >= 0.0 ? theta - M_PI : theta + M_PI);
         } else {
-            theta = atan2(y, x);
-            if (fabs(theta) <= FORTPI) {
-                *area = AREA_0;
-            } else if (theta > FORTPI && theta <= HALFPI + FORTPI) {
-                *area = AREA_1;
-                theta -= HALFPI;
-            } else if (theta > HALFPI + FORTPI || theta <= -(HALFPI + FORTPI)) {
-                *area = AREA_2;
-                theta = (theta >= 0.0 ? theta - PI : theta + PI);
-            } else {
-                *area = AREA_3;
-                theta += HALFPI;
-            }
+            *area = AREA_3;
+            theta += M_HALFPI;
         }
-        return (theta);
+    }
+    return theta;
 }
 
 /* Helper function: shift the longitude. */
-static double
-qsc_shift_lon_origin(double lon, double offset) {
-        double slon = lon + offset;
-        if (slon < -PI) {
-            slon += TWOPI;
-        } else if (slon > +PI) {
-            slon -= TWOPI;
-        }
-        return slon;
+static double qsc_shift_lon_origin(double lon, double offset) {
+    double slon = lon + offset;
+    if (slon < -M_PI) {
+        slon += M_TWOPI;
+    } else if (slon > +M_PI) {
+        slon -= M_TWOPI;
+    }
+    return slon;
 }
 
-/* Forward projection, ellipsoid */
-FORWARD(e_forward);
-        double lat, lon;
-        double theta, phi;
-        double t, mu; /* nu; */
-        int area;
-
-        /* Convert the geodetic latitude to a geocentric latitude.
-         * This corresponds to the shift from the ellipsoid to the sphere
-         * described in [LK12]. */
-        if (P->es) {
-            lat = atan(P->one_minus_f_squared * tan(lp.phi));
-        } else {
-            lat = lp.phi;
-        }
 
-        /* Convert the input lat, lon into theta, phi as used by QSC.
-         * This depends on the cube face and the area on it.
-         * For the top and bottom face, we can compute theta and phi
-         * directly from phi, lam. For the other faces, we must use
-         * unit sphere cartesian coordinates as an intermediate step. */
-        lon = lp.lam;
-        if (P->face == FACE_TOP) {
-            phi = HALFPI - lat;
-            if (lon >= FORTPI && lon <= HALFPI + FORTPI) {
-                area = AREA_0;
-                theta = lon - HALFPI;
-            } else if (lon > HALFPI + FORTPI || lon <= -(HALFPI + FORTPI)) {
-                area = AREA_1;
-                theta = (lon > 0.0 ? lon - PI : lon + PI);
-            } else if (lon > -(HALFPI + FORTPI) && lon <= -FORTPI) {
-                area = AREA_2;
-                theta = lon + HALFPI;
-            } else {
-                area = AREA_3;
-                theta = lon;
-            }
-        } else if (P->face == FACE_BOTTOM) {
-            phi = HALFPI + lat;
-            if (lon >= FORTPI && lon <= HALFPI + FORTPI) {
-                area = AREA_0;
-                theta = -lon + HALFPI;
-            } else if (lon < FORTPI && lon >= -FORTPI) {
-                area = AREA_1;
-                theta = -lon;
-            } else if (lon < -FORTPI && lon >= -(HALFPI + FORTPI)) {
-                area = AREA_2;
-                theta = -lon - HALFPI;
-            } else {
-                area = AREA_3;
-                theta = (lon > 0.0 ? -lon + PI : -lon - PI);
-            }
-        } else {
-            double q, r, s;
-            double sinlat, coslat;
-            double sinlon, coslon;
-
-            if (P->face == FACE_RIGHT) {
-                lon = qsc_shift_lon_origin(lon, +HALFPI);
-            } else if (P->face == FACE_BACK) {
-                lon = qsc_shift_lon_origin(lon, +PI);
-            } else if (P->face == FACE_LEFT) {
-                lon = qsc_shift_lon_origin(lon, -HALFPI);
-            }
-            sinlat = sin(lat);
-            coslat = cos(lat);
-            sinlon = sin(lon);
-            coslon = cos(lon);
-            q = coslat * coslon;
-            r = coslat * sinlon;
-            s = sinlat;
-
-            if (P->face == FACE_FRONT) {
-                phi = acos(q);
-                theta = qsc_fwd_equat_face_theta(phi, s, r, &area);
-            } else if (P->face == FACE_RIGHT) {
-                phi = acos(r);
-                theta = qsc_fwd_equat_face_theta(phi, s, -q, &area);
-            } else if (P->face == FACE_BACK) {
-                phi = acos(-q);
-                theta = qsc_fwd_equat_face_theta(phi, s, -r, &area);
-            } else if (P->face == FACE_LEFT) {
-                phi = acos(-r);
-                theta = qsc_fwd_equat_face_theta(phi, s, q, &area);
-            } else {
-                /* Impossible */
-                phi = theta = 0.0;
-                area = AREA_0;
-            }
-        }
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double lat, lon;
+    double theta, phi;
+    double t, mu; /* nu; */
+    int area;
 
-        /* Compute mu and nu for the area of definition.
-         * For mu, see Eq. (3-21) in [OL76], but note the typos:
-         * compare with Eq. (3-14). For nu, see Eq. (3-38). */
-        mu = atan((12.0 / PI) * (theta + acos(sin(theta) * cos(FORTPI)) - HALFPI));
-        t = sqrt((1.0 - cos(phi)) / (cos(mu) * cos(mu)) / (1.0 - cos(atan(1.0 / cos(theta)))));
-        /* nu = atan(t);        We don't really need nu, just t, see below. */
+    /* Convert the geodetic latitude to a geocentric latitude.
+     * This corresponds to the shift from the ellipsoid to the sphere
+     * described in [LK12]. */
+    if (P->es) {
+        lat = atan(Q->one_minus_f_squared * tan(lp.phi));
+    } else {
+        lat = lp.phi;
+    }
 
-        /* Apply the result to the real area. */
-        if (area == AREA_1) {
-            mu += HALFPI;
-        } else if (area == AREA_2) {
-            mu += PI;
-        } else if (area == AREA_3) {
-            mu += HALFPI + PI;
+    /* Convert the input lat, lon into theta, phi as used by QSC.
+     * This depends on the cube face and the area on it.
+     * For the top and bottom face, we can compute theta and phi
+     * directly from phi, lam. For the other faces, we must use
+     * unit sphere cartesian coordinates as an intermediate step. */
+    lon = lp.lam;
+    if (Q->face == FACE_TOP) {
+        phi = M_HALFPI - lat;
+        if (lon >= M_FORTPI && lon <= M_HALFPI + M_FORTPI) {
+            area = AREA_0;
+            theta = lon - M_HALFPI;
+        } else if (lon > M_HALFPI + M_FORTPI || lon <= -(M_HALFPI + M_FORTPI)) {
+            area = AREA_1;
+            theta = (lon > 0.0 ? lon - M_PI : lon + M_PI);
+        } else if (lon > -(M_HALFPI + M_FORTPI) && lon <= -M_FORTPI) {
+            area = AREA_2;
+            theta = lon + M_HALFPI;
+        } else {
+            area = AREA_3;
+            theta = lon;
         }
-
-        /* Now compute x, y from mu and nu */
-        /* t = tan(nu); */
-        xy.x = t * cos(mu);
-        xy.y = t * sin(mu);
-        return (xy);
-}
-
-/* Inverse projection, ellipsoid */
-INVERSE(e_inverse);
-        double mu, nu, cosmu, tannu;
-        double tantheta, theta, cosphi, phi;
-        double t;
-        int area;
-
-        /* Convert the input x, y to the mu and nu angles as used by QSC.
-         * This depends on the area of the cube face. */
-        nu = atan(sqrt(xy.x * xy.x + xy.y * xy.y));
-        mu = atan2(xy.y, xy.x);
-        if (xy.x >= 0.0 && xy.x >= fabs(xy.y)) {
+    } else if (Q->face == FACE_BOTTOM) {
+        phi = M_HALFPI + lat;
+        if (lon >= M_FORTPI && lon <= M_HALFPI + M_FORTPI) {
             area = AREA_0;
-        } else if (xy.y >= 0.0 && xy.y >= fabs(xy.x)) {
+            theta = -lon + M_HALFPI;
+        } else if (lon < M_FORTPI && lon >= -M_FORTPI) {
             area = AREA_1;
-            mu -= HALFPI;
-        } else if (xy.x < 0.0 && -xy.x >= fabs(xy.y)) {
+            theta = -lon;
+        } else if (lon < -M_FORTPI && lon >= -(M_HALFPI + M_FORTPI)) {
             area = AREA_2;
-            mu = (mu < 0.0 ? mu + PI : mu - PI);
+            theta = -lon - M_HALFPI;
         } else {
             area = AREA_3;
-            mu += HALFPI;
+            theta = (lon > 0.0 ? -lon + M_PI : -lon - M_PI);
         }
+    } else {
+        double q, r, s;
+        double sinlat, coslat;
+        double sinlon, coslon;
 
-        /* Compute phi and theta for the area of definition.
-         * The inverse projection is not described in the original paper, but some
-         * good hints can be found here (as of 2011-12-14):
-         * http://fits.gsfc.nasa.gov/fitsbits/saf.93/saf.9302
-         * (search for "Message-Id: <9302181759.AA25477 at fits.cv.nrao.edu>") */
-        t = (PI / 12.0) * tan(mu);
-        tantheta = sin(t) / (cos(t) - (1.0 / sqrt(2.0)));
-        theta = atan(tantheta);
-        cosmu = cos(mu);
-        tannu = tan(nu);
-        cosphi = 1.0 - cosmu * cosmu * tannu * tannu * (1.0 - cos(atan(1.0 / cos(theta))));
-        if (cosphi < -1.0) {
-            cosphi = -1.0;
-        } else if (cosphi > +1.0) {
-            cosphi = +1.0;
+        if (Q->face == FACE_RIGHT) {
+            lon = qsc_shift_lon_origin(lon, +M_HALFPI);
+        } else if (Q->face == FACE_BACK) {
+            lon = qsc_shift_lon_origin(lon, +M_PI);
+        } else if (Q->face == FACE_LEFT) {
+            lon = qsc_shift_lon_origin(lon, -M_HALFPI);
         }
+        sinlat = sin(lat);
+        coslat = cos(lat);
+        sinlon = sin(lon);
+        coslon = cos(lon);
+        q = coslat * coslon;
+        r = coslat * sinlon;
+        s = sinlat;
 
-        /* Apply the result to the real area on the cube face.
-         * For the top and bottom face, we can compute phi and lam directly.
-         * For the other faces, we must use unit sphere cartesian coordinates
-         * as an intermediate step. */
-        if (P->face == FACE_TOP) {
-            phi = acos(cosphi);
-            lp.phi = HALFPI - phi;
-            if (area == AREA_0) {
-                lp.lam = theta + HALFPI;
-            } else if (area == AREA_1) {
-                lp.lam = (theta < 0.0 ? theta + PI : theta - PI);
-            } else if (area == AREA_2) {
-                lp.lam = theta - HALFPI;
-            } else /* area == AREA_3 */ {
-                lp.lam = theta;
-            }
-        } else if (P->face == FACE_BOTTOM) {
-            phi = acos(cosphi);
-            lp.phi = phi - HALFPI;
-            if (area == AREA_0) {
-                lp.lam = -theta + HALFPI;
-            } else if (area == AREA_1) {
-                lp.lam = -theta;
-            } else if (area == AREA_2) {
-                lp.lam = -theta - HALFPI;
-            } else /* area == AREA_3 */ {
-                lp.lam = (theta < 0.0 ? -theta - PI : -theta + PI);
-            }
+        if (Q->face == FACE_FRONT) {
+            phi = acos(q);
+            theta = qsc_fwd_equat_face_theta(phi, s, r, &area);
+        } else if (Q->face == FACE_RIGHT) {
+            phi = acos(r);
+            theta = qsc_fwd_equat_face_theta(phi, s, -q, &area);
+        } else if (Q->face == FACE_BACK) {
+            phi = acos(-q);
+            theta = qsc_fwd_equat_face_theta(phi, s, -r, &area);
+        } else if (Q->face == FACE_LEFT) {
+            phi = acos(-r);
+            theta = qsc_fwd_equat_face_theta(phi, s, q, &area);
         } else {
-            /* Compute phi and lam via cartesian unit sphere coordinates. */
-            double q, r, s, t;
-            q = cosphi;
-            t = q * q;
-            if (t >= 1.0) {
-                s = 0.0;
-            } else {
-                s = sqrt(1.0 - t) * sin(theta);
-            }
-            t += s * s;
-            if (t >= 1.0) {
-                r = 0.0;
-            } else {
-                r = sqrt(1.0 - t);
-            }
-            /* Rotate q,r,s into the correct area. */
-            if (area == AREA_1) {
-                t = r;
-                r = -s;
-                s = t;
-            } else if (area == AREA_2) {
-                r = -r;
-                s = -s;
-            } else if (area == AREA_3) {
-                t = r;
-                r = s;
-                s = -t;
-            }
-            /* Rotate q,r,s into the correct cube face. */
-            if (P->face == FACE_RIGHT) {
-                t = q;
-                q = -r;
-                r = t;
-            } else if (P->face == FACE_BACK) {
-                q = -q;
-                r = -r;
-            } else if (P->face == FACE_LEFT) {
-                t = q;
-                q = r;
-                r = -t;
-            }
-            /* Now compute phi and lam from the unit sphere coordinates. */
-            lp.phi = acos(-s) - HALFPI;
-            lp.lam = atan2(r, q);
-            if (P->face == FACE_RIGHT) {
-                lp.lam = qsc_shift_lon_origin(lp.lam, -HALFPI);
-            } else if (P->face == FACE_BACK) {
-                lp.lam = qsc_shift_lon_origin(lp.lam, -PI);
-            } else if (P->face == FACE_LEFT) {
-                lp.lam = qsc_shift_lon_origin(lp.lam, +HALFPI);
-            }
+            /* Impossible */
+            phi = theta = 0.0;
+            area = AREA_0;
         }
+    }
 
-        /* Apply the shift from the sphere to the ellipsoid as described
-         * in [LK12]. */
-        if (P->es) {
-            int invert_sign;
-            double tanphi, xa;
-            invert_sign = (lp.phi < 0.0 ? 1 : 0);
-            tanphi = tan(lp.phi);
-            xa = P->b / sqrt(tanphi * tanphi + P->one_minus_f_squared);
-            lp.phi = atan(sqrt(P->a * P->a - xa * xa) / (P->one_minus_f * xa));
-            if (invert_sign) {
-                lp.phi = -lp.phi;
-            }
-        }
-        return (lp);
+    /* Compute mu and nu for the area of definition.
+     * For mu, see Eq. (3-21) in [OL76], but note the typos:
+     * compare with Eq. (3-14). For nu, see Eq. (3-38). */
+    mu = atan((12.0 / M_PI) * (theta + acos(sin(theta) * cos(M_FORTPI)) - M_HALFPI));
+    t = sqrt((1.0 - cos(phi)) / (cos(mu) * cos(mu)) / (1.0 - cos(atan(1.0 / cos(theta)))));
+    /* nu = atan(t);        We don't really need nu, just t, see below. */
+
+    /* Apply the result to the real area. */
+    if (area == AREA_1) {
+        mu += M_HALFPI;
+    } else if (area == AREA_2) {
+        mu += M_PI;
+    } else if (area == AREA_3) {
+        mu += M_PI_HALFPI;
+    }
+
+    /* Now compute x, y from mu and nu */
+    /* t = tan(nu); */
+    xy.x = t * cos(mu);
+    xy.y = t * sin(mu);
+    return xy;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(qsc)
-        P->inv = e_inverse;
-        P->fwd = e_forward;
-        /* Determine the cube face from the center of projection. */
-        if (P->phi0 >= HALFPI - FORTPI / 2.0) {
-            P->face = FACE_TOP;
-        } else if (P->phi0 <= -(HALFPI - FORTPI / 2.0)) {
-            P->face = FACE_BOTTOM;
-        } else if (fabs(P->lam0) <= FORTPI) {
-            P->face = FACE_FRONT;
-        } else if (fabs(P->lam0) <= HALFPI + FORTPI) {
-            P->face = (P->lam0 > 0.0 ? FACE_RIGHT : FACE_LEFT);
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double mu, nu, cosmu, tannu;
+    double tantheta, theta, cosphi, phi;
+    double t;
+    int area;
+
+    /* Convert the input x, y to the mu and nu angles as used by QSC.
+     * This depends on the area of the cube face. */
+    nu = atan(sqrt(xy.x * xy.x + xy.y * xy.y));
+    mu = atan2(xy.y, xy.x);
+    if (xy.x >= 0.0 && xy.x >= fabs(xy.y)) {
+        area = AREA_0;
+    } else if (xy.y >= 0.0 && xy.y >= fabs(xy.x)) {
+        area = AREA_1;
+        mu -= M_HALFPI;
+    } else if (xy.x < 0.0 && -xy.x >= fabs(xy.y)) {
+        area = AREA_2;
+        mu = (mu < 0.0 ? mu + M_PI : mu - M_PI);
+    } else {
+        area = AREA_3;
+        mu += M_HALFPI;
+    }
+
+    /* Compute phi and theta for the area of definition.
+     * The inverse projection is not described in the original paper, but some
+     * good hints can be found here (as of 2011-12-14):
+     * http://fits.gsfc.nasa.gov/fitsbits/saf.93/saf.9302
+     * (search for "Message-Id: <9302181759.AA25477 at fits.cv.nrao.edu>") */
+    t = (M_PI / 12.0) * tan(mu);
+    tantheta = sin(t) / (cos(t) - (1.0 / sqrt(2.0)));
+    theta = atan(tantheta);
+    cosmu = cos(mu);
+    tannu = tan(nu);
+    cosphi = 1.0 - cosmu * cosmu * tannu * tannu * (1.0 - cos(atan(1.0 / cos(theta))));
+    if (cosphi < -1.0) {
+        cosphi = -1.0;
+    } else if (cosphi > +1.0) {
+        cosphi = +1.0;
+    }
+
+    /* Apply the result to the real area on the cube face.
+     * For the top and bottom face, we can compute phi and lam directly.
+     * For the other faces, we must use unit sphere cartesian coordinates
+     * as an intermediate step. */
+    if (Q->face == FACE_TOP) {
+        phi = acos(cosphi);
+        lp.phi = M_HALFPI - phi;
+        if (area == AREA_0) {
+            lp.lam = theta + M_HALFPI;
+        } else if (area == AREA_1) {
+            lp.lam = (theta < 0.0 ? theta + M_PI : theta - M_PI);
+        } else if (area == AREA_2) {
+            lp.lam = theta - M_HALFPI;
+        } else /* area == AREA_3 */ {
+            lp.lam = theta;
+        }
+    } else if (Q->face == FACE_BOTTOM) {
+        phi = acos(cosphi);
+        lp.phi = phi - M_HALFPI;
+        if (area == AREA_0) {
+            lp.lam = -theta + M_HALFPI;
+        } else if (area == AREA_1) {
+            lp.lam = -theta;
+        } else if (area == AREA_2) {
+            lp.lam = -theta - M_HALFPI;
+        } else /* area == AREA_3 */ {
+            lp.lam = (theta < 0.0 ? -theta - M_PI : -theta + M_PI);
+        }
+    } else {
+        /* Compute phi and lam via cartesian unit sphere coordinates. */
+        double q, r, s, t;
+        q = cosphi;
+        t = q * q;
+        if (t >= 1.0) {
+            s = 0.0;
         } else {
-            P->face = FACE_BACK;
+            s = sqrt(1.0 - t) * sin(theta);
         }
-        /* Fill in useful values for the ellipsoid <-> sphere shift
-         * described in [LK12]. */
-        if (P->es) {
-            P->a_squared = P->a * P->a;
-            P->b = P->a * sqrt(1.0 - P->es);
-            P->one_minus_f = 1.0 - (P->a - P->b) / P->a;
-            P->one_minus_f_squared = P->one_minus_f * P->one_minus_f;
+        t += s * s;
+        if (t >= 1.0) {
+            r = 0.0;
+        } else {
+            r = sqrt(1.0 - t);
         }
-ENDENTRY(P)
+        /* Rotate q,r,s into the correct area. */
+        if (area == AREA_1) {
+            t = r;
+            r = -s;
+            s = t;
+        } else if (area == AREA_2) {
+            r = -r;
+            s = -s;
+        } else if (area == AREA_3) {
+            t = r;
+            r = s;
+            s = -t;
+        }
+        /* Rotate q,r,s into the correct cube face. */
+        if (Q->face == FACE_RIGHT) {
+            t = q;
+            q = -r;
+            r = t;
+        } else if (Q->face == FACE_BACK) {
+            q = -q;
+            r = -r;
+        } else if (Q->face == FACE_LEFT) {
+            t = q;
+            q = r;
+            r = -t;
+        }
+        /* Now compute phi and lam from the unit sphere coordinates. */
+        lp.phi = acos(-s) - M_HALFPI;
+        lp.lam = atan2(r, q);
+        if (Q->face == FACE_RIGHT) {
+            lp.lam = qsc_shift_lon_origin(lp.lam, -M_HALFPI);
+        } else if (Q->face == FACE_BACK) {
+            lp.lam = qsc_shift_lon_origin(lp.lam, -M_PI);
+        } else if (Q->face == FACE_LEFT) {
+            lp.lam = qsc_shift_lon_origin(lp.lam, +M_HALFPI);
+        }
+    }
+
+    /* Apply the shift from the sphere to the ellipsoid as described
+     * in [LK12]. */
+    if (P->es) {
+        int invert_sign;
+        double tanphi, xa;
+        invert_sign = (lp.phi < 0.0 ? 1 : 0);
+        tanphi = tan(lp.phi);
+        xa = Q->b / sqrt(tanphi * tanphi + Q->one_minus_f_squared);
+        lp.phi = atan(sqrt(P->a * P->a - xa * xa) / (Q->one_minus_f * xa));
+        if (invert_sign) {
+            lp.phi = -lp.phi;
+        }
+    }
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(qsc) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+    /* Determine the cube face from the center of projection. */
+    if (P->phi0 >= M_HALFPI - M_FORTPI / 2.0) {
+        Q->face = FACE_TOP;
+    } else if (P->phi0 <= -(M_HALFPI - M_FORTPI / 2.0)) {
+        Q->face = FACE_BOTTOM;
+    } else if (fabs(P->lam0) <= M_FORTPI) {
+        Q->face = FACE_FRONT;
+    } else if (fabs(P->lam0) <= M_HALFPI + M_FORTPI) {
+        Q->face = (P->lam0 > 0.0 ? FACE_RIGHT : FACE_LEFT);
+    } else {
+        Q->face = FACE_BACK;
+    }
+    /* Fill in useful values for the ellipsoid <-> sphere shift
+     * described in [LK12]. */
+    if (P->es) {
+        Q->a_squared = P->a * P->a;
+        Q->b = P->a * sqrt(1.0 - P->es);
+        Q->one_minus_f = 1.0 - (P->a - Q->b) / P->a;
+        Q->one_minus_f_squared = Q->one_minus_f * Q->one_minus_f;
+    }
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_qsc_selftest (void) {return 0;}
+#else
+
+int pj_qsc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=qsc   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=qsc   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 304638.450843852363,  164123.870923793991},
+        { 304638.450843852363, -164123.870923793991},
+        {-304638.450843852363,  164123.870923793962},
+        {-304638.450843852421, -164123.870923793904},
+    };
+
+    XY s_fwd_expect[] = {
+        { 305863.792402890511,  165827.722754715243},
+        { 305863.792402890511, -165827.722754715243},
+        {-305863.792402890511,  165827.722754715243},
+        {-305863.792402890569, -165827.722754715156},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.00132134098471627126,  0.000610652900922527926},
+        { 0.00132134098471627126, -0.000610652900922527926},
+        {-0.00132134098471627126,  0.000610652900922527926},
+        {-0.00132134098471627126, -0.000610652900922527926},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.00131682718763827234,  0.000604493198178676161},
+        { 0.00131682718763827234, -0.000604493198178676161},
+        {-0.00131682718763827234,  0.000604493198178676161},
+        {-0.00131682718763827234, -0.000604493198178676161},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_robin.c b/src/PJ_robin.c
index e8572ae..2237830 100644
--- a/src/PJ_robin.c
+++ b/src/PJ_robin.c
@@ -1,10 +1,12 @@
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(robin, "Robinson") "\n\tPCyl., Sph.";
+
 #define V(C,z) (C.c0 + z * (C.c1 + z * (C.c2 + z * C.c3)))
 #define DV(C,z) (C.c1 + z * (C.c2 + C.c2 + z * 3. * C.c3))
 
-/* 
+/*
 note: following terms based upon 5 deg. intervals in degrees.
 
 Some background on these coefficients is available at:
@@ -14,7 +16,7 @@ http://trac.osgeo.org/proj/ticket/113
 */
 
 struct COEFS {
-	float c0, c1, c2, c3;
+    float c0, c1, c2, c3;
 };
 
 static const struct COEFS X[] = {
@@ -38,6 +40,7 @@ static const struct COEFS X[] = {
     {0.5722, -0.00906601, 0.000182, 6.24051e-06},
     {0.5322, -0.00677797, 0.000275608, 6.24051e-06}
 };
+
 static const struct COEFS Y[] = {
     {-5.20417e-18, 0.0124, 1.21431e-18, -8.45284e-11},
     {0.062, 0.0124, -1.26793e-09, 4.22642e-10},
@@ -59,61 +62,135 @@ static const struct COEFS Y[] = {
     {0.9761, 0.00616527, -0.000256, -4.2106e-06},
     {1, 0.00328947, -0.000319159, -4.2106e-06}
 };
-#define FXC	0.8487
-#define FYC	1.3523
-#define C1	11.45915590261646417544
-#define RC1	0.08726646259971647884
-#define NODES	18
-#define ONEEPS	1.000001
-#define EPS	1e-8
-FORWARD(s_forward); /* spheroid */
-	int i;
-	double dphi;
-	(void) P;
-
-	i = floor((dphi = fabs(lp.phi)) * C1);
-	if (i >= NODES) i = NODES - 1;
-	dphi = RAD_TO_DEG * (dphi - RC1 * i);
-	xy.x = V(X[i], dphi) * FXC * lp.lam;
-	xy.y = V(Y[i], dphi) * FYC;
-	if (lp.phi < 0.) xy.y = -xy.y;
-	return (xy);
+
+#define FXC 0.8487
+#define FYC 1.3523
+#define C1  11.45915590261646417544
+#define RC1 0.08726646259971647884
+#define NODES   18
+#define ONEEPS  1.000001
+#define EPS 1e-8
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    int i;
+    double dphi;
+    (void) P;
+
+    i = floor((dphi = fabs(lp.phi)) * C1);
+    if (i >= NODES) i = NODES - 1;
+    dphi = RAD_TO_DEG * (dphi - RC1 * i);
+    xy.x = V(X[i], dphi) * FXC * lp.lam;
+    xy.y = V(Y[i], dphi) * FYC;
+    if (lp.phi < 0.) xy.y = -xy.y;
+
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    int i;
+    double t, t1;
+    struct COEFS T;
+
+    lp.lam = xy.x / FXC;
+    lp.phi = fabs(xy.y / FYC);
+    if (lp.phi >= 1.) { /* simple pathologic cases */
+        if (lp.phi > ONEEPS) I_ERROR
+        else {
+            lp.phi = xy.y < 0. ? -M_HALFPI : M_HALFPI;
+            lp.lam /= X[NODES].c0;
+        }
+    } else { /* general problem */
+        /* in Y space, reduce to table interval */
+        for (i = floor(lp.phi * NODES);;) {
+            if (Y[i].c0 > lp.phi) --i;
+            else if (Y[i+1].c0 <= lp.phi) ++i;
+            else break;
+        }
+        T = Y[i];
+        /* first guess, linear interp */
+        t = 5. * (lp.phi - T.c0)/(Y[i+1].c0 - T.c0);
+        /* make into root */
+        T.c0 -= lp.phi;
+        for (;;) { /* Newton-Raphson reduction */
+            t -= t1 = V(T,t) / DV(T,t);
+            if (fabs(t1) < EPS)
+                break;
+        }
+        lp.phi = (5 * i + t) * DEG_TO_RAD;
+        if (xy.y < 0.) lp.phi = -lp.phi;
+        lp.lam /= V(X[i], t);
+    }
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(s_inverse); /* spheroid */
-	int i;
-	double t, t1;
-	struct COEFS T;
-
-	lp.lam = xy.x / FXC;
-	lp.phi = fabs(xy.y / FYC);
-	if (lp.phi >= 1.) { /* simple pathologic cases */
-		if (lp.phi > ONEEPS) I_ERROR
-		else {
-			lp.phi = xy.y < 0. ? -HALFPI : HALFPI;
-			lp.lam /= X[NODES].c0;
-		}
-	} else { /* general problem */
-		/* in Y space, reduce to table interval */
-		for (i = floor(lp.phi * NODES);;) {
-			if (Y[i].c0 > lp.phi) --i;
-			else if (Y[i+1].c0 <= lp.phi) ++i;
-			else break;
-		}
-		T = Y[i];
-		/* first guess, linear interp */
-		t = 5. * (lp.phi - T.c0)/(Y[i+1].c0 - T.c0);
-		/* make into root */
-		T.c0 -= lp.phi;
-		for (;;) { /* Newton-Raphson reduction */
-			t -= t1 = V(T,t) / DV(T,t);
-			if (fabs(t1) < EPS)
-				break;
-		}
-		lp.phi = (5 * i + t) * DEG_TO_RAD;
-		if (xy.y < 0.) lp.phi = -lp.phi;
-		lp.lam /= V(X[i], t);
-	}
-	return (lp);
+
+
+PJ *PROJECTION(robin) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(robin) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_robin_selftest (void) {return 0;}
+#else
+
+int pj_robin_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=robin   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 189588.423282507836,  107318.530350702888},
+        { 189588.423282507836, -107318.530350702888},
+        {-189588.423282507836,  107318.530350702888},
+        {-189588.423282507836, -107318.530350702888},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.002109689065506131,  0.000931805533547745983},
+        { 0.002109689065506131, -0.000931805533547745983},
+        {-0.002109689065506131,  0.000931805533547745983},
+        {-0.002109689065506131, -0.000931805533547745983},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_rpoly.c b/src/PJ_rpoly.c
index 7a7670e..ad24091 100644
--- a/src/PJ_rpoly.c
+++ b/src/PJ_rpoly.c
@@ -1,35 +1,99 @@
-#define PROJ_PARMS__ \
-	double	phi1; \
-	double	fxa; \
-	double	fxb; \
-	int		mode;
-#define EPS	1e-9
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    double  phi1;
+    double  fxa;
+    double  fxb;
+    int     mode;
+};
+
 PROJ_HEAD(rpoly, "Rectangular Polyconic")
-	"\n\tConic, Sph., no inv.\n\tlat_ts=";
-FORWARD(s_forward); /* spheroid */
-	double fa;
-
-	if (P->mode)
-		fa = tan(lp.lam * P->fxb) * P->fxa;
-	else
-		fa = 0.5 * lp.lam;
-	if (fabs(lp.phi) < EPS) {
-		xy.x = fa + fa;
-		xy.y = - P->phi0;
-	} else {
-		xy.y = 1. / tan(lp.phi);
-		xy.x = sin(fa = 2. * atan(fa * sin(lp.phi))) * xy.y;
-		xy.y = lp.phi - P->phi0 + (1. - cos(fa)) * xy.y;
-	}
-	return (xy);
+    "\n\tConic, Sph., no inv.\n\tlat_ts=";
+
+#define EPS 1e-9
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double fa;
+
+    if (Q->mode)
+        fa = tan(lp.lam * Q->fxb) * Q->fxa;
+    else
+        fa = 0.5 * lp.lam;
+    if (fabs(lp.phi) < EPS) {
+        xy.x = fa + fa;
+        xy.y = - P->phi0;
+    } else {
+        xy.y = 1. / tan(lp.phi);
+        xy.x = sin(fa = 2. * atan(fa * sin(lp.phi))) * xy.y;
+        xy.y = lp.phi - P->phi0 + (1. - cos(fa)) * xy.y;
+    }
+    return xy;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(rpoly)
-	if ((P->mode = (P->phi1 = fabs(pj_param(P->ctx, P->params, "rlat_ts").f)) > EPS)) {
-		P->fxb = 0.5 * sin(P->phi1);
-		P->fxa = 0.5 / P->fxb;
-	}
-	P->es = 0.; P->fwd = s_forward;
-ENDENTRY(P)
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(rpoly) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    if ((Q->mode = (Q->phi1 = fabs(pj_param(P->ctx, P->params, "rlat_ts").f)) > EPS)) {
+        Q->fxb = 0.5 * sin(Q->phi1);
+        Q->fxa = 0.5 / Q->fxb;
+    }
+    P->es = 0.;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_rpoly_selftest (void) {return 0;}
+#else
+
+int pj_rpoly_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=rpoly   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223368.09830201423,  111769.110486991223},
+        { 223368.09830201423, -111769.110486991223},
+        {-223368.09830201423,  111769.110486991223},
+        {-223368.09830201423, -111769.110486991223},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_sch.c b/src/PJ_sch.c
new file mode 100644
index 0000000..048224e
--- /dev/null
+++ b/src/PJ_sch.c
@@ -0,0 +1,268 @@
+/******************************************************************************
+ * $Id$
+ *
+ * Project:  SCH Coordinate system
+ * Purpose:  Implementation of SCH Coordinate system
+ * References :
+ *      1. Hensley. Scott. SCH Coordinates and various transformations. June 15, 2000.
+ *      2. Buckley, Sean Monroe. Radar interferometry measurement of land subsidence. 2000..
+ *         PhD Thesis. UT Austin. (Appendix)
+ *      3. Hensley, Scott, Elaine Chapin, and T. Michel. "Improved processing of AIRSAR
+ *         data based on the GeoSAR processor." Airsar earth science and applications
+ *         workshop, March. 2002. (http://airsar.jpl.nasa.gov/documents/workshop2002/papers/T3.pdf)
+ *
+ * Author:   Piyush Agram (piyush.agram at jpl.nasa.gov)
+ * Copyright (c) 2015 California Institute of Technology.
+ * Government sponsorship acknowledged.
+ *
+ * NOTE:  The SCH coordinate system is a sensor aligned coordinate system
+ * developed at JPL for radar mapping missions. Details pertaining to the
+ * coordinate system have been release in the public domain (see references above).
+ * This code is an independent implementation of the SCH coordinate system
+ * that conforms to the PROJ.4 conventions and uses the details presented in these
+ * publicly released documents. All credit for the development of the coordinate
+ * system and its use should be directed towards the original developers at JPL.
+ ******************************************************************************
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ****************************************************************************/
+
+#define PJ_LIB__
+#include <projects.h>
+#include "geocent.h"
+
+struct pj_opaque {
+    double plat; /*Peg Latitude */
+    double plon; /*Peg Longitude*/
+    double phdg; /*Peg heading  */
+    double h0;   /*Average altitude */
+    double transMat[9];
+    double xyzoff[3];
+    double rcurv;
+    GeocentricInfo sph;
+    GeocentricInfo elp_0;
+};
+
+PROJ_HEAD(sch, "Spherical Cross-track Height") "\n\tMisc\n\tplat_0 = ,plon_0 = , phdg_0 = ,[h_0 = ]";
+
+static LPZ inverse3d(XYZ xyz, PJ *P) {
+    LPZ lpz = {0.0, 0.0, 0.0};
+    struct pj_opaque *Q = P->opaque;
+    double temp[3];
+    double pxyz[3];
+
+    /* Local lat,lon using radius */
+    pxyz[0] = xyz.y * P->a / Q->rcurv;
+    pxyz[1] = xyz.x * P->a / Q->rcurv;
+    pxyz[2] = xyz.z;
+
+    if( pj_Convert_Geodetic_To_Geocentric( &(Q->sph), pxyz[0], pxyz[1], pxyz[2],
+                temp, temp+1, temp+2) != 0)
+            I3_ERROR;
+
+    /* Apply rotation */
+    pxyz[0] = Q->transMat[0] * temp[0] + Q->transMat[1] * temp[1] + Q->transMat[2] * temp[2];
+    pxyz[1] = Q->transMat[3] * temp[0] + Q->transMat[4] * temp[1] + Q->transMat[5] * temp[2];
+    pxyz[2] = Q->transMat[6] * temp[0] + Q->transMat[7] * temp[1] + Q->transMat[8] * temp[2];
+
+    /* Apply offset */
+    pxyz[0] += Q->xyzoff[0];
+    pxyz[1] += Q->xyzoff[1];
+    pxyz[2] += Q->xyzoff[2];
+
+    /* Convert geocentric coordinates to lat lon */
+    pj_Convert_Geocentric_To_Geodetic( &(Q->elp_0), pxyz[0], pxyz[1], pxyz[2],
+            temp, temp+1, temp+2);
+
+
+    lpz.lam = temp[1] ;
+    lpz.phi = temp[0] ;
+    lpz.z = temp[2];
+
+#if 0
+    printf("INVERSE: \n");
+    printf("XYZ: %f %f %f \n", xyz.x, xyz.y, xyz.z);
+    printf("LPZ: %f %f %f \n", lpz.lam, lpz.phi, lpz.z);
+#endif
+    return lpz;
+}
+
+static XYZ forward3d(LPZ lpz, PJ *P) {
+    XYZ xyz = {0.0, 0.0, 0.0};
+    struct pj_opaque *Q = P->opaque;
+    double temp[3];
+    double pxyz[3];
+
+
+    /* Convert lat lon to geocentric coordinates */
+    if( pj_Convert_Geodetic_To_Geocentric( &(Q->elp_0), lpz.phi, lpz.lam, lpz.z,
+                temp, temp+1, temp+2 ) != 0 )
+        F3_ERROR;
+
+
+    /* Adjust for offset */
+    temp[0] -= Q->xyzoff[0];
+    temp[1] -= Q->xyzoff[1];
+    temp[2] -= Q->xyzoff[2];
+
+
+    /* Apply rotation */
+    pxyz[0] = Q->transMat[0] * temp[0] + Q->transMat[3] * temp[1] + Q->transMat[6] * temp[2];
+    pxyz[1] = Q->transMat[1] * temp[0] + Q->transMat[4] * temp[1] + Q->transMat[7] * temp[2];
+    pxyz[2] = Q->transMat[2] * temp[0] + Q->transMat[5] * temp[1] + Q->transMat[8] * temp[2];
+
+    /* Convert to local lat,lon */
+    pj_Convert_Geocentric_To_Geodetic( &(Q->sph), pxyz[0], pxyz[1], pxyz[2],
+            temp, temp+1, temp+2);
+
+
+    /* Scale by radius */
+    xyz.x = temp[1] * Q->rcurv / P->a;
+    xyz.y = temp[0] * Q->rcurv / P->a;
+    xyz.z = temp[2];
+
+#if 0
+    printf("FORWARD: \n");
+    printf("LPZ: %f %f %f \n", lpz.lam, lpz.phi, lpz.z);
+    printf("XYZ: %f %f %f \n", xyz.x, xyz.y, xyz.z);
+#endif
+    return xyz;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+static PJ *setup(PJ *P) { /* general initialization */
+    struct pj_opaque *Q = P->opaque;
+    double reast, rnorth;
+    double chdg, shdg;
+    double clt, slt;
+    double clo, slo;
+    double temp;
+    double pxyz[3];
+
+    temp = P->a * sqrt(1.0 - P->es);
+
+    /* Setup original geocentric system */
+    if ( pj_Set_Geocentric_Parameters(&(Q->elp_0), P->a, temp) != 0)
+            E_ERROR(-37);
+
+    clt = cos(Q->plat);
+    slt = sin(Q->plat);
+    clo = cos(Q->plon);
+    slo = sin(Q->plon);
+
+    /* Estimate the radius of curvature for given peg */
+    temp = sqrt(1.0 - (P->es) * slt * slt);
+    reast = (P->a)/temp;
+    rnorth = (P->a) * (1.0 - (P->es))/pow(temp,3);
+
+    chdg = cos(Q->phdg);
+    shdg = sin(Q->phdg);
+
+    Q->rcurv = Q->h0 + (reast*rnorth)/(reast * chdg * chdg + rnorth * shdg * shdg);
+
+#if 0
+    printf("North Radius: %f \n", rnorth);
+    printf("East Radius: %f \n", reast);
+    printf("Effective Radius: %f \n", Q->rcurv);
+#endif
+
+    /* Set up local sphere at the given peg point */
+    if ( pj_Set_Geocentric_Parameters(&(Q->sph), Q->rcurv, Q->rcurv) != 0)
+        E_ERROR(-37);
+
+    /* Set up the transformation matrices */
+    Q->transMat[0] = clt * clo;
+    Q->transMat[1] = -shdg*slo - slt*clo * chdg;
+    Q->transMat[2] =  slo*chdg - slt*clo*shdg;
+    Q->transMat[3] =  clt*slo;
+    Q->transMat[4] =  clo*shdg - slt*slo*chdg;
+    Q->transMat[5] = -clo*chdg - slt*slo*shdg;
+    Q->transMat[6] =  slt;
+    Q->transMat[7] =  clt*chdg;
+    Q->transMat[8] =  clt*shdg;
+
+
+    if( pj_Convert_Geodetic_To_Geocentric( &(Q->elp_0), Q->plat, Q->plon, Q->h0,
+                                           pxyz, pxyz+1, pxyz+2 ) != 0 )
+    {
+        E_ERROR(-14)
+    }
+
+
+    Q->xyzoff[0] = pxyz[0] - (Q->rcurv) * clt * clo;
+    Q->xyzoff[1] = pxyz[1] - (Q->rcurv) * clt * slo;
+    Q->xyzoff[2] = pxyz[2] - (Q->rcurv) * slt;
+
+#if 0
+    printf("Offset: %f %f %f \n", Q->xyzoff[0], Q->xyzoff[1], Q->xyzoff[2]);
+#endif
+
+    P->fwd3d = forward3d;
+    P->inv3d = inverse3d;
+    return P;
+}
+
+
+PJ *PROJECTION(sch) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->h0 = 0.0;
+
+    /* Check if peg latitude was defined */
+    if (pj_param(P->ctx, P->params, "tplat_0").i)
+        Q->plat = pj_param(P->ctx, P->params, "rplat_0").f;
+    else
+        E_ERROR(-37);
+
+    /* Check if peg longitude was defined */
+    if (pj_param(P->ctx, P->params, "tplon_0").i)
+        Q->plon = pj_param(P->ctx, P->params, "rplon_0").f;
+    else
+        E_ERROR(-37);
+
+    /* Check if peg latitude is defined */
+    if (pj_param(P->ctx, P->params, "tphdg_0").i)
+        Q->phdg = pj_param(P->ctx, P->params, "rphdg_0").f;
+    else
+        E_ERROR(-37);
+
+
+    /* Check if average height was defined - If so read it in */
+    if (pj_param(P->ctx, P->params, "th_0").i)
+        Q->h0 = pj_param(P->ctx, P->params, "dh_0").f;
+
+    /* Completed reading in the projection parameters */
+#if 0
+    printf("PSA: Lat = %f Lon = %f Hdg = %f \n", Q->plat, Q->plon, Q->phdg);
+#endif
+
+    return setup(P);
+}
+
+/* Skipping sef-test since the test system is not capable of handling
+ * 3D coordinate systems for the time being. Relying on tests in ../nad/
+ */
+int pj_sch_selftest (void) {return 0;}
diff --git a/src/PJ_sconics.c b/src/PJ_sconics.c
index 8c17533..1d85b0a 100644
--- a/src/PJ_sconics.c
+++ b/src/PJ_sconics.c
@@ -1,12 +1,17 @@
-#define PROJ_PARMS__ \
-	double	n; \
-	double	rho_c; \
-	double	rho_0; \
-	double	sig; \
-	double	c1, c2; \
-	int		type;
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
+
+struct pj_opaque {
+    double  n;
+    double  rho_c;
+    double  rho_0;
+    double  sig;
+    double  c1, c2;
+    int     type;
+};
+
+
 #define EULER 0
 #define MURD1 1
 #define MURD2 2
@@ -14,141 +19,677 @@
 #define PCONIC 4
 #define TISSOT 5
 #define VITK1 6
-#define EPS10	1.e-10
+#define EPS10   1.e-10
 #define EPS 1e-10
 #define LINE2 "\n\tConic, Sph\n\tlat_1= and lat_2="
-PROJ_HEAD(tissot, "Tissot")
-	LINE2;
-PROJ_HEAD(murd1, "Murdoch I")
-	LINE2;
-PROJ_HEAD(murd2, "Murdoch II")
-	LINE2;
-PROJ_HEAD(murd3, "Murdoch III")
-	LINE2;
-PROJ_HEAD(euler, "Euler")
-	LINE2;
-PROJ_HEAD(pconic, "Perspective Conic")
-	LINE2;
-PROJ_HEAD(vitk1, "Vitkovsky I")
-	LINE2;
+
+PROJ_HEAD(euler, "Euler")                LINE2;
+PROJ_HEAD(murd1, "Murdoch I")            LINE2;
+PROJ_HEAD(murd2, "Murdoch II")           LINE2;
+PROJ_HEAD(murd3, "Murdoch III")          LINE2;
+PROJ_HEAD(pconic, "Perspective Conic")   LINE2;
+PROJ_HEAD(tissot, "Tissot")              LINE2;
+PROJ_HEAD(vitk1, "Vitkovsky I")          LINE2;
+
+
+
 /* get common factors for simple conics */
-	static int
-phi12(PJ *P, double *del) {
-	double p1, p2;
-	int err = 0;
-
-	if (!pj_param(P->ctx, P->params, "tlat_1").i ||
-		!pj_param(P->ctx, P->params, "tlat_2").i) {
-		err = -41;
-	} else {
-		p1 = pj_param(P->ctx, P->params, "rlat_1").f;
-		p2 = pj_param(P->ctx, P->params, "rlat_2").f;
-		*del = 0.5 * (p2 - p1);
-		P->sig = 0.5 * (p2 + p1);
-		err = (fabs(*del) < EPS || fabs(P->sig) < EPS) ? -42 : 0;
-		*del = *del;
-	}
-	return err;
-}
-FORWARD(s_forward); /* spheroid */
-	double rho;
-
-	switch (P->type) {
-	case MURD2:
-		rho = P->rho_c + tan(P->sig - lp.phi);
-		break;
-	case PCONIC:
-		rho = P->c2 * (P->c1 - tan(lp.phi - P->sig));
-		break;
-	default:
-		rho = P->rho_c - lp.phi;
-		break;
-	}
-	xy.x = rho * sin( lp.lam *= P->n );
-	xy.y = P->rho_0 - rho * cos(lp.lam);
-	return (xy);
-}
-INVERSE(s_inverse); /* ellipsoid & spheroid */
-	double rho;
-
-	rho = hypot(xy.x, xy.y = P->rho_0 - xy.y);
-	if (P->n < 0.) {
-		rho = - rho;
-		xy.x = - xy.x;
-		xy.y = - xy.y;
-	}
-	lp.lam = atan2(xy.x, xy.y) / P->n;
-	switch (P->type) {
-	case PCONIC:
-		lp.phi = atan(P->c1 - rho / P->c2) + P->sig;
-		break;
-	case MURD2:
-		lp.phi = P->sig - atan(rho - P->rho_c);
-		break;
-	default:
-		lp.phi = P->rho_c - rho;
-	}
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) {
-	double del, cs;
-	int i;
-
-	if( (i = phi12(P, &del)) )
-		E_ERROR(i);
-	switch (P->type) {
-	case TISSOT:
-		P->n = sin(P->sig);
-		cs = cos(del);
-		P->rho_c = P->n / cs + cs / P->n;
-		P->rho_0 = sqrt((P->rho_c - 2 * sin(P->phi0))/P->n);
-		break;
-	case MURD1:
-		P->rho_c = sin(del)/(del * tan(P->sig)) + P->sig;
-		P->rho_0 = P->rho_c - P->phi0;
-		P->n = sin(P->sig);
-		break;
-	case MURD2:
-		P->rho_c = (cs = sqrt(cos(del))) / tan(P->sig);
-		P->rho_0 = P->rho_c + tan(P->sig - P->phi0);
-		P->n = sin(P->sig) * cs;
-		break;
-	case MURD3:
-		P->rho_c = del / (tan(P->sig) * tan(del)) + P->sig;
-		P->rho_0 = P->rho_c - P->phi0;
-		P->n = sin(P->sig) * sin(del) * tan(del) / (del * del);
-		break;
-	case EULER:
-		P->n = sin(P->sig) * sin(del) / del;
-		del *= 0.5;
-		P->rho_c = del / (tan(del) * tan(P->sig)) + P->sig;	
-		P->rho_0 = P->rho_c - P->phi0;
-		break;
-	case PCONIC:
-		P->n = sin(P->sig);
-		P->c2 = cos(del);
-		P->c1 = 1./tan(P->sig);
-		if (fabs(del = P->phi0 - P->sig) - EPS10 >= HALFPI)
-			E_ERROR(-43);
-		P->rho_0 = P->c2 * (P->c1 - tan(del));
-		break;
-	case VITK1:
-		P->n = (cs = tan(del)) * sin(P->sig) / del;
-		P->rho_c = del / (cs * tan(P->sig)) + P->sig;
-		P->rho_0 = P->rho_c - P->phi0;
-		break;
-	}
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-	P->es = 0;
-	return (P);
-}
-ENTRY0(euler) P->type = EULER; ENDENTRY(setup(P))
-ENTRY0(tissot) P->type = TISSOT; ENDENTRY(setup(P))
-ENTRY0(murd1) P->type = MURD1; ENDENTRY(setup(P))
-ENTRY0(murd2) P->type = MURD2; ENDENTRY(setup(P))
-ENTRY0(murd3) P->type = MURD3; ENDENTRY(setup(P))
-ENTRY0(pconic) P->type = PCONIC; ENDENTRY(setup(P))
-ENTRY0(vitk1) P->type = VITK1; ENDENTRY(setup(P))
+static int phi12(PJ *P, double *del) {
+    double p1, p2;
+    int err = 0;
+
+    if (!pj_param(P->ctx, P->params, "tlat_1").i ||
+        !pj_param(P->ctx, P->params, "tlat_2").i) {
+        err = -41;
+    } else {
+        p1 = pj_param(P->ctx, P->params, "rlat_1").f;
+        p2 = pj_param(P->ctx, P->params, "rlat_2").f;
+        *del = 0.5 * (p2 - p1);
+        P->opaque->sig = 0.5 * (p2 + p1);
+        err = (fabs(*del) < EPS || fabs(P->opaque->sig) < EPS) ? -42 : 0;
+        *del = *del;
+    }
+    return err;
+}
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0, 0.0};
+    struct pj_opaque *Q = P->opaque;
+    double rho;
+
+    switch (Q->type) {
+    case MURD2:
+        rho = Q->rho_c + tan (Q->sig - lp.phi);
+        break;
+    case PCONIC:
+        rho = Q->c2 * (Q->c1 - tan (lp.phi - Q->sig));
+        break;
+    default:
+        rho = Q->rho_c - lp.phi;
+        break;
+    }
+
+    xy.x = rho * sin ( lp.lam *= Q->n );
+    xy.y = Q->rho_0 - rho * cos (lp.lam);
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {  /* Spheroidal, (and ellipsoidal?) inverse */
+    LP lp = {0.0, 0.0};
+    struct pj_opaque *Q = P->opaque;
+    double rho;
+
+    rho = hypot (xy.x,  xy.y = Q->rho_0 - xy.y);
+    if (Q->n < 0.) {
+        rho = - rho;
+        xy.x = - xy.x;
+        xy.y = - xy.y;
+    }
+
+    lp.lam = atan2 (xy.x, xy.y) / Q->n;
+
+    switch (Q->type) {
+    case PCONIC:
+        lp.phi = atan (Q->c1 - rho / Q->c2) + Q->sig;
+        break;
+    case MURD2:
+        lp.phi = Q->sig - atan(rho - Q->rho_c);
+        break;
+    default:
+        lp.phi = Q->rho_c - rho;
+    }
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+static PJ *setup(PJ *P, int type) {
+    double del, cs;
+    int i;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+    Q->type = type;
+
+    i = phi12 (P, &del);
+    if(i)
+        E_ERROR(i);
+    switch (Q->type) {
+
+    case TISSOT:
+        Q->n = sin (Q->sig);
+        cs = cos (del);
+        Q->rho_c = Q->n / cs + cs / Q->n;
+        Q->rho_0 = sqrt ((Q->rho_c - 2 * sin (P->phi0)) / Q->n);
+        break;
+
+    case MURD1:
+        Q->rho_c = sin(del)/(del * tan(Q->sig)) + Q->sig;
+        Q->rho_0 = Q->rho_c - P->phi0;
+        Q->n = sin(Q->sig);
+        break;
+
+    case MURD2:
+        Q->rho_c = (cs = sqrt (cos (del))) / tan (Q->sig);
+        Q->rho_0 = Q->rho_c + tan (Q->sig - P->phi0);
+        Q->n = sin (Q->sig) * cs;
+        break;
+
+    case MURD3:
+        Q->rho_c = del / (tan(Q->sig) * tan(del)) + Q->sig;
+        Q->rho_0 = Q->rho_c - P->phi0;
+        Q->n = sin (Q->sig) * sin (del) * tan (del) / (del * del);
+        break;
+
+    case EULER:
+        Q->n = sin (Q->sig) * sin (del) / del;
+        del *= 0.5;
+        Q->rho_c = del / (tan (del) * tan (Q->sig)) + Q->sig;
+        Q->rho_0 = Q->rho_c - P->phi0;
+        break;
+
+    case PCONIC:
+        Q->n = sin (Q->sig);
+        Q->c2 = cos (del);
+        Q->c1 = 1./tan (Q->sig);
+        if (fabs (del = P->phi0 - Q->sig) - EPS10 >= M_HALFPI)
+            E_ERROR(-43);
+        Q->rho_0 = Q->c2 * (Q->c1 - tan (del));
+        break;
+
+    case VITK1:
+        Q->n = (cs = tan (del)) * sin (Q->sig) / del;
+        Q->rho_c = del / (cs * tan (Q->sig)) + Q->sig;
+        Q->rho_0 = Q->rho_c - P->phi0;
+        break;
+    }
+
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    P->es = 0;
+    return (P);
+}
+
+
+PJ *PROJECTION(euler) {
+    return setup(P, EULER);
+}
+
+
+PJ *PROJECTION(tissot) {
+    return setup(P, TISSOT);
+}
+
+
+PJ *PROJECTION(murd1) {
+    return setup(P, MURD1);
+}
+
+
+PJ *PROJECTION(murd2) {
+    return setup(P, MURD2);
+}
+
+
+PJ *PROJECTION(murd3) {
+    return setup(P, MURD3);
+}
+
+
+PJ *PROJECTION(pconic) {
+    return setup(P, PCONIC);
+}
+
+
+PJ *PROJECTION(vitk1) {
+    return setup(P, VITK1);
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_euler_selftest (void) {return 0;}
+#else
+
+int pj_euler_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=euler   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=euler   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222597.63465910763,  111404.24054991946},
+        {222767.16563187627,  -111234.6764910177},
+        {-222597.63465910763,  111404.24054991946},
+        {-222767.16563187627,  -111234.6764910177},
+    };
+
+    XY s_fwd_expect[] = {
+        {223360.65559869423,  111786.11238979101},
+        {223530.76769031584,  -111615.96709862351},
+        {-223360.65559869423,  111786.11238979101},
+        {-223530.76769031584,  -111615.96709862351},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017962807023075235,  0.0008983146697688839},
+        {0.0017962794738334226,  -0.00089831589842987965},
+        {-0.0017962807023075235,  0.0008983146697688839},
+        {-0.0017962794738334226,  -0.00089831589842987965},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017901444369360026,  0.00089524594522202015},
+        {0.001790143216840731,  -0.00089524716533368484},
+        {-0.0017901444369360026,  0.00089524594522202015},
+        {-0.001790143216840731,  -0.00089524716533368484},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
+
+
+
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_murd1_selftest (void) {return 0;}
+#else
+
+int pj_murd1_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=murd1   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=murd1   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222600.81347355421,  111404.24418054636},
+        {222770.3492878644,  -111234.6728566746},
+        {-222600.81347355421,  111404.24418054636},
+        {-222770.3492878644,  -111234.6728566746},
+    };
+
+    XY s_fwd_expect[] = {
+        {223363.84530949194,  111786.11603286299},
+        {223533.96225925098,  -111615.96345182261},
+        {-223363.84530949194,  111786.11603286299},
+        {-223533.96225925098,  -111615.96345182261},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017962550410516366,  0.0008983146697688839},
+        {0.0017962538125775522,  -0.00089831589842987965},
+        {-0.0017962550410516366,  0.0008983146697688839},
+        {-0.0017962538125775522,  -0.00089831589842987965},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017901188633413715,  0.00089524594522202015},
+        {0.0017901176432461162,  -0.00089524716492657387},
+        {-0.0017901188633413715,  0.00089524594522202015},
+        {-0.0017901176432461162,  -0.00089524716492657387},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_murd2_selftest (void) {return 0;}
+#else
+
+int pj_murd2_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=murd2   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=murd2   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222588.09975123021,  111426.14002741246},
+        {222757.72626701824,  -111341.43131750476},
+        {-222588.09975123021,  111426.14002741246},
+        {-222757.72626701824,  -111341.43131750476},
+    };
+
+    XY s_fwd_expect[] = {
+        {223351.08800702673,  111808.08693438848},
+        {223521.2959691704,  -111723.08785967289},
+        {-223351.08800702673,  111808.08693438848},
+        {-223521.2959691704,  -111723.08785967289},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017963574947305447,  0.00089788747830845382},
+        {0.0017963562661689487,  -0.00089788809264252983},
+        {-0.0017963574947305447,  0.00089788747830845382},
+        {-0.0017963562661689487,  -0.00089788809264252983},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017902209670287586,  0.00089482021163422854},
+        {0.0017902197468465887,  -0.00089482082161134206},
+        {-0.0017902209670287586,  0.00089482021163422854},
+        {-0.0017902197468465887,  -0.00089482082161134206},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
+
+
+
+
+
+
+
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_murd3_selftest (void) {return 0;}
+#else
+
+int pj_murd3_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=murd3   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=murd3   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222600.81407757697,  111404.24660137216},
+        {222770.35473389886,  -111234.67043217793},
+        {-222600.81407757697,  111404.24660137216},
+        {-222770.35473389886,  -111234.67043217793},
+    };
+
+    XY s_fwd_expect[] = {
+        {223363.84591558515,  111786.11846198692},
+        {223533.96772395336,  -111615.96101901523},
+        {-223363.84591558515,  111786.11846198692},
+        {-223533.96772395336,  -111615.96101901523},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017962550166583809,  0.0008983146697688839},
+        {0.0017962537881492445,  -0.00089831589842987965},
+        {-0.0017962550166583809,  0.0008983146697688839},
+        {-0.0017962537881492445,  -0.00089831589842987965},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017901188390313859,  0.00089524594522202015},
+        {0.0017901176189013177,  -0.00089524716533368484},
+        {-0.0017901188390313859,  0.00089524594522202015},
+        {-0.0017901176189013177,  -0.00089524716533368484},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_pconic_selftest (void) {return 0;}
+#else
+
+int pj_pconic_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=pconic   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=pconic   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222588.09884161691,  111416.60477006658},
+        {222757.71809109033,  -111331.88153107995},
+        {-222588.09884161691,  111416.60477006658},
+        {-222757.71809109033,  -111331.88153107995},
+    };
+
+    XY s_fwd_expect[] = {
+        {223351.08709429545,  111798.5189920546},
+        {223521.28776521701,  -111713.50533845725},
+        {-223351.08709429545,  111798.5189920546},
+        {-223521.28776521701,  -111713.50533845725},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017963575313784969,  0.0008979644089172499},
+        {0.0017963563027642206,  -0.00089796502355327969},
+        {-0.0017963575313784969,  0.0008979644089172499},
+        {-0.0017963563027642206,  -0.00089796502355327969},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017902210035514285,  0.0008948968793741558},
+        {0.0017902197833169374,  -0.00089489748965381963},
+        {-0.0017902210035514285,  0.0008948968793741558},
+        {-0.0017902197833169374,  -0.00089489748965381963},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_tissot_selftest (void) {return 0;}
+#else
+
+int pj_tissot_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=tissot   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=tissot   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222641.07869963095,  54347.828487281469},
+        {222810.61451394114,  -168291.08854993948},
+        {-222641.07869963095,  54347.828487281469},
+        {-222810.61451394114,  -168291.08854993948},
+    };
+
+    XY s_fwd_expect[] = {
+        {223404.24855684943,  54534.122161157939},
+        {223574.36550660848,  -168867.95732352766},
+        {-223404.24855684943,  54534.122161157939},
+        {-223574.36550660848,  -168867.95732352766},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017962807107425871,  0.51344495513064536},
+        {0.0017962794822333915,  0.51164832456244658},
+        {-0.0017962807107425871,  0.51344495513064536},
+        {-0.0017962794822333915,  0.51164832456244658},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017901444453421915,  0.51344188640609856},
+        {0.001790143225212064,  0.51165139329554277},
+        {-0.0017901444453421915,  0.51344188640609856},
+        {-0.001790143225212064,  0.51165139329554277},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
+
+
+
+
+
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_vitk1_selftest (void) {return 0;}
+#else
+
+int pj_vitk1_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=vitk1   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=vitk1   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222607.17121145778,  111404.25144243463},
+        {222776.71670959776,  -111234.66558744459},
+        {-222607.17121145778,  111404.25144243463},
+        {-222776.71670959776,  -111234.66558744459},
+    };
+
+    XY s_fwd_expect[] = {
+        {223370.22484047143,  111786.12331964359},
+        {223540.3515072545,  -111615.9561576751},
+        {-223370.22484047143,  111786.12331964359},
+        {-223540.3515072545,  -111615.9561576751},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017962037198570686,  0.0008983146697688839},
+        {0.0017962024913830157,  -0.00089831589842987965},
+        {-0.0017962037198570686,  0.0008983146697688839},
+        {-0.0017962024913830157,  -0.00089831589842987965},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017900677174648159,  0.00089524594522202015},
+        {0.0017900664973695916,  -0.00089524716533368484},
+        {-0.0017900677174648159,  0.00089524594522202015},
+        {-0.0017900664973695916,  -0.00089524716533368484},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_somerc.c b/src/PJ_somerc.c
index f7d1f11..380fbf5 100644
--- a/src/PJ_somerc.c
+++ b/src/PJ_somerc.c
@@ -1,66 +1,165 @@
-#define PROJ_PARMS__ \
-	double	K, c, hlf_e, kR, cosp0, sinp0;
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
 PROJ_HEAD(somerc, "Swiss. Obl. Mercator") "\n\tCyl, Ell\n\tFor CH1903";
-#define EPS	1.e-10
+
+struct pj_opaque {
+    double K, c, hlf_e, kR, cosp0, sinp0;
+};
+
+#define EPS 1.e-10
 #define NITER 6
-FORWARD(e_forward);
-	double phip, lamp, phipp, lampp, sp, cp;
-
-	sp = P->e * sin(lp.phi);
-	phip = 2.* atan( exp( P->c * (
-		log(tan(FORTPI + 0.5 * lp.phi)) - P->hlf_e * log((1. + sp)/(1. - sp)))
-		+ P->K)) - HALFPI;
-	lamp = P->c * lp.lam;
-	cp = cos(phip);
-	phipp = aasin(P->ctx,P->cosp0 * sin(phip) - P->sinp0 * cp * cos(lamp));
-	lampp = aasin(P->ctx,cp * sin(lamp) / cos(phipp));
-	xy.x = P->kR * lampp;
-	xy.y = P->kR * log(tan(FORTPI + 0.5 * phipp));
-	return (xy);
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0, 0.0};
+    double phip, lamp, phipp, lampp, sp, cp;
+    struct pj_opaque *Q = P->opaque;
+
+    sp = P->e * sin (lp.phi);
+    phip = 2.* atan ( exp ( Q->c * (
+        log (tan (M_FORTPI + 0.5 * lp.phi)) - Q->hlf_e * log ((1. + sp)/(1. - sp)))
+        + Q->K)) - M_HALFPI;
+    lamp = Q->c * lp.lam;
+    cp = cos(phip);
+    phipp = aasin (P->ctx, Q->cosp0 * sin (phip) - Q->sinp0 * cp * cos (lamp));
+    lampp = aasin (P->ctx, cp * sin (lamp) / cos (phipp));
+    xy.x = Q->kR * lampp;
+    xy.y = Q->kR * log (tan (M_FORTPI + 0.5 * phipp));
+    return xy;
 }
-INVERSE(e_inverse); /* ellipsoid & spheroid */
-	double phip, lamp, phipp, lampp, cp, esp, con, delp;
-	int i;
-
-	phipp = 2. * (atan(exp(xy.y / P->kR)) - FORTPI);
-	lampp = xy.x / P->kR;
-	cp = cos(phipp);
-	phip = aasin(P->ctx,P->cosp0 * sin(phipp) + P->sinp0 * cp * cos(lampp));
-	lamp = aasin(P->ctx,cp * sin(lampp) / cos(phip));
-	con = (P->K - log(tan(FORTPI + 0.5 * phip)))/P->c;
-	for (i = NITER; i ; --i) {
-		esp = P->e * sin(phip);
-		delp = (con + log(tan(FORTPI + 0.5 * phip)) - P->hlf_e *
-			log((1. + esp)/(1. - esp)) ) *
-			(1. - esp * esp) * cos(phip) * P->rone_es;
-		phip -= delp;
-		if (fabs(delp) < EPS)
-			break;
-	}
-	if (i) {
-		lp.phi = phip;
-		lp.lam = lamp / P->c;
-	} else
-		I_ERROR
-	return (lp);
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double phip, lamp, phipp, lampp, cp, esp, con, delp;
+    int i;
+
+    phipp = 2. * (atan (exp (xy.y / Q->kR)) - M_FORTPI);
+    lampp = xy.x / Q->kR;
+    cp = cos (phipp);
+    phip = aasin (P->ctx, Q->cosp0 * sin (phipp) + Q->sinp0 * cp * cos (lampp));
+    lamp = aasin (P->ctx, cp * sin (lampp) / cos (phip));
+    con = (Q->K - log (tan (M_FORTPI + 0.5 * phip)))/Q->c;
+    for (i = NITER; i ; --i) {
+        esp = P->e * sin(phip);
+        delp = (con + log(tan(M_FORTPI + 0.5 * phip)) - Q->hlf_e *
+            log((1. + esp)/(1. - esp)) ) *
+            (1. - esp * esp) * cos(phip) * P->rone_es;
+        phip -= delp;
+        if (fabs(delp) < EPS)
+            break;
+    }
+    if (i) {
+        lp.phi = phip;
+        lp.lam = lamp / Q->c;
+    } else
+        I_ERROR
+    return (lp);
 }
+
+
+#if 0
 FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(somerc)
-	double cp, phip0, sp;
-
-	P->hlf_e = 0.5 * P->e;
-	cp = cos(P->phi0);
-	cp *= cp;
-	P->c = sqrt(1 + P->es * cp * cp * P->rone_es);
-	sp = sin(P->phi0);
-	P->cosp0 = cos( phip0 = aasin(P->ctx, P->sinp0 = sp / P->c) );
-	sp *= P->e;
-	P->K = log(tan(FORTPI + 0.5 * phip0)) - P->c * (
-		log(tan(FORTPI + 0.5 * P->phi0)) - P->hlf_e *
-		log((1. + sp) / (1. - sp)));
-	P->kR = P->k0 * sqrt(P->one_es) / (1. - sp * sp);
-	P->inv = e_inverse;
-	P->fwd = e_forward;
-ENDENTRY(P)
+#endif
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(somerc) {
+    double cp, phip0, sp;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+
+    Q->hlf_e = 0.5 * P->e;
+    cp = cos (P->phi0);
+    cp *= cp;
+    Q->c = sqrt (1 + P->es * cp * cp * P->rone_es);
+    sp = sin (P->phi0);
+    Q->cosp0 = cos( phip0 = aasin (P->ctx, Q->sinp0 = sp / Q->c) );
+    sp *= P->e;
+    Q->K = log (tan (M_FORTPI + 0.5 * phip0)) - Q->c * (
+        log (tan (M_FORTPI + 0.5 * P->phi0)) - Q->hlf_e *
+        log ((1. + sp) / (1. - sp)));
+    Q->kR = P->k0 * sqrt(P->one_es) / (1. - sp * sp);
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_somerc_selftest (void) {return 0;}
+#else
+
+int pj_somerc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=somerc   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=somerc   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222638.98158654713,  110579.96521824898},
+        {222638.98158654713,  -110579.96521825089},
+        {-222638.98158654713,  110579.96521824898},
+        {-222638.98158654713,  -110579.96521825089},
+    };
+
+    XY s_fwd_expect[] = {
+        {223402.14425527418,  111706.74357494408},
+        {223402.14425527418,  -111706.74357494518},
+        {-223402.14425527418,  111706.74357494408},
+        {-223402.14425527418,  -111706.74357494518},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017966305682390426,  0.00090436947704129484},
+        {0.0017966305682390426,  -0.00090436947704377105},
+        {-0.0017966305682390426,  0.00090436947704129484},
+        {-0.0017966305682390426,  -0.00090436947704377105},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017904931097838226,  0.00089524655485801927},
+        {0.0017904931097838226,  -0.00089524655484529714},
+        {-0.0017904931097838226,  0.00089524655485801927},
+        {-0.0017904931097838226,  -0.00089524655484529714},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_stere.c b/src/PJ_stere.c
index a052462..762e55e 100644
--- a/src/PJ_stere.c
+++ b/src/PJ_stere.c
@@ -1,239 +1,409 @@
-#define PROJ_PARMS__ \
-	double phits; \
-	double sinX1; \
-	double cosX1; \
-	double akm1; \
-	int	mode;
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
 PROJ_HEAD(stere, "Stereographic") "\n\tAzi, Sph&Ell\n\tlat_ts=";
 PROJ_HEAD(ups, "Universal Polar Stereographic") "\n\tAzi, Sph&Ell\n\tsouth";
-#define sinph0	P->sinX1
-#define cosph0	P->cosX1
-#define EPS10	1.e-10
-#define TOL	1.e-8
-#define NITER	8
-#define CONV	1.e-10
-#define S_POLE	0
-#define N_POLE	1
-#define OBLIQ	2
-#define EQUIT	3
-	static double
-ssfn_(double phit, double sinphi, double eccen) {
-	sinphi *= eccen;
-	return (tan (.5 * (HALFPI + phit)) *
-	   pow((1. - sinphi) / (1. + sinphi), .5 * eccen));
+
+
+struct pj_opaque {
+    double phits;
+    double sinX1;
+    double cosX1;
+    double akm1;
+    int mode;
+};
+
+#define sinph0  P->opaque->sinX1
+#define cosph0  P->opaque->cosX1
+#define EPS10   1.e-10
+#define TOL 1.e-8
+#define NITER   8
+#define CONV    1.e-10
+#define S_POLE  0
+#define N_POLE  1
+#define OBLIQ   2
+#define EQUIT   3
+
+static double ssfn_ (double phit, double sinphi, double eccen) {
+    sinphi *= eccen;
+    return (tan (.5 * (M_HALFPI + phit)) *
+       pow ((1. - sinphi) / (1. + sinphi), .5 * eccen));
 }
-FORWARD(e_forward); /* ellipsoid */
-	double coslam, sinlam, sinX=0.0, cosX=0.0, X, A, sinphi;
-
-	coslam = cos(lp.lam);
-	sinlam = sin(lp.lam);
-	sinphi = sin(lp.phi);
-	if (P->mode == OBLIQ || P->mode == EQUIT) {
-		sinX = sin(X = 2. * atan(ssfn_(lp.phi, sinphi, P->e)) - HALFPI);
-		cosX = cos(X);
-	}
-	switch (P->mode) {
-	case OBLIQ:
-		A = P->akm1 / (P->cosX1 * (1. + P->sinX1 * sinX +
-		   P->cosX1 * cosX * coslam));
-		xy.y = A * (P->cosX1 * sinX - P->sinX1 * cosX * coslam);
-		goto xmul;
-	case EQUIT:
-		A = 2. * P->akm1 / (1. + cosX * coslam);
-		xy.y = A * sinX;
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double coslam, sinlam, sinX = 0.0, cosX = 0.0, X, A, sinphi;
+
+    coslam = cos (lp.lam);
+    sinlam = sin (lp.lam);
+    sinphi = sin (lp.phi);
+    if (Q->mode == OBLIQ || Q->mode == EQUIT) {
+        sinX = sin (X = 2. * atan(ssfn_(lp.phi, sinphi, P->e)) - M_HALFPI);
+        cosX = cos (X);
+    }
+
+    switch (Q->mode) {
+    case OBLIQ:
+        A = Q->akm1 / (Q->cosX1 * (1. + Q->sinX1 * sinX +
+           Q->cosX1 * cosX * coslam));
+        xy.y = A * (Q->cosX1 * sinX - Q->sinX1 * cosX * coslam);
+        goto xmul; /* but why not just  xy.x = A * cosX; break;  ? */
+
+    case EQUIT:
+        A = 2. * Q->akm1 / (1. + cosX * coslam);
+        xy.y = A * sinX;
 xmul:
-		xy.x = A * cosX;
-		break;
-	case S_POLE:
-		lp.phi = -lp.phi;
-		coslam = - coslam;
-		sinphi = -sinphi;
-	case N_POLE:
-		xy.x = P->akm1 * pj_tsfn(lp.phi, sinphi, P->e);
-		xy.y = - xy.x * coslam;
-		break;
-	}
-	xy.x = xy.x * sinlam;
-	return (xy);
+        xy.x = A * cosX;
+        break;
+
+    case S_POLE:
+        lp.phi = -lp.phi;
+        coslam = - coslam;
+        sinphi = -sinphi;
+    case N_POLE:
+        xy.x = Q->akm1 * pj_tsfn (lp.phi, sinphi, P->e);
+        xy.y = - xy.x * coslam;
+        break;
+    }
+
+    xy.x = xy.x * sinlam;
+    return xy;
 }
-FORWARD(s_forward); /* spheroid */
-	double  sinphi, cosphi, coslam, sinlam;
-
-	sinphi = sin(lp.phi);
-	cosphi = cos(lp.phi);
-	coslam = cos(lp.lam);
-	sinlam = sin(lp.lam);
-	switch (P->mode) {
-	case EQUIT:
-		xy.y = 1. + cosphi * coslam;
-		goto oblcon;
-	case OBLIQ:
-		xy.y = 1. + sinph0 * sinphi + cosph0 * cosphi * coslam;
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  sinphi, cosphi, coslam, sinlam;
+
+    sinphi = sin(lp.phi);
+    cosphi = cos(lp.phi);
+    coslam = cos(lp.lam);
+    sinlam = sin(lp.lam);
+
+    switch (Q->mode) {
+    case EQUIT:
+        xy.y = 1. + cosphi * coslam;
+        goto oblcon;
+    case OBLIQ:
+        xy.y = 1. + sinph0 * sinphi + cosph0 * cosphi * coslam;
 oblcon:
-		if (xy.y <= EPS10) F_ERROR;
-		xy.x = (xy.y = P->akm1 / xy.y) * cosphi * sinlam;
-		xy.y *= (P->mode == EQUIT) ? sinphi :
-		   cosph0 * sinphi - sinph0 * cosphi * coslam;
-		break;
-	case N_POLE:
-		coslam = - coslam;
-		lp.phi = - lp.phi;
-	case S_POLE:
-		if (fabs(lp.phi - HALFPI) < TOL) F_ERROR;
-		xy.x = sinlam * ( xy.y = P->akm1 * tan(FORTPI + .5 * lp.phi) );
-		xy.y *= coslam;
-		break;
-	}
-	return (xy);
+        if (xy.y <= EPS10) F_ERROR;
+        xy.x = (xy.y = Q->akm1 / xy.y) * cosphi * sinlam;
+        xy.y *= (Q->mode == EQUIT) ? sinphi :
+           cosph0 * sinphi - sinph0 * cosphi * coslam;
+        break;
+    case N_POLE:
+        coslam = - coslam;
+        lp.phi = - lp.phi;
+    case S_POLE:
+        if (fabs (lp.phi - M_HALFPI) < TOL) F_ERROR;
+        xy.x = sinlam * ( xy.y = Q->akm1 * tan (M_FORTPI + .5 * lp.phi) );
+        xy.y *= coslam;
+        break;
+    }
+    return xy;
 }
-INVERSE(e_inverse); /* ellipsoid */
-	double cosphi, sinphi, tp=0.0, phi_l=0.0, rho, halfe=0.0, halfpi=0.0;
-	int i;
-
-	rho = hypot(xy.x, xy.y);
-	switch (P->mode) {
-	case OBLIQ:
-	case EQUIT:
-		cosphi = cos( tp = 2. * atan2(rho * P->cosX1 , P->akm1) );
-		sinphi = sin(tp);
-                if( rho == 0.0 )
-		    phi_l = asin(cosphi * P->sinX1);
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double cosphi, sinphi, tp=0.0, phi_l=0.0, rho, halfe=0.0, halfpi=0.0;
+    int i;
+
+    rho = hypot (xy.x, xy.y);
+
+    switch (Q->mode) {
+    case OBLIQ:
+    case EQUIT:
+        cosphi = cos ( tp = 2. * atan2 (rho * Q->cosX1 , Q->akm1) );
+        sinphi = sin (tp);
+                if ( rho == 0.0 )
+            phi_l = asin (cosphi * Q->sinX1);
                 else
-		    phi_l = asin(cosphi * P->sinX1 + (xy.y * sinphi * P->cosX1 / rho));
-
-		tp = tan(.5 * (HALFPI + phi_l));
-		xy.x *= sinphi;
-		xy.y = rho * P->cosX1 * cosphi - xy.y * P->sinX1* sinphi;
-		halfpi = HALFPI;
-		halfe = .5 * P->e;
-		break;
-	case N_POLE:
-		xy.y = -xy.y;
-	case S_POLE:
-		phi_l = HALFPI - 2. * atan(tp = - rho / P->akm1);
-		halfpi = -HALFPI;
-		halfe = -.5 * P->e;
-		break;
-	}
-	for (i = NITER; i--; phi_l = lp.phi) {
-		sinphi = P->e * sin(phi_l);
-		lp.phi = 2. * atan(tp * pow((1.+sinphi)/(1.-sinphi),
-		   halfe)) - halfpi;
-		if (fabs(phi_l - lp.phi) < CONV) {
-			if (P->mode == S_POLE)
-				lp.phi = -lp.phi;
-			lp.lam = (xy.x == 0. && xy.y == 0.) ? 0. : atan2(xy.x, xy.y);
-			return (lp);
-		}
-	}
-	I_ERROR;
+            phi_l = asin (cosphi * Q->sinX1 + (xy.y * sinphi * Q->cosX1 / rho));
+
+        tp = tan (.5 * (M_HALFPI + phi_l));
+        xy.x *= sinphi;
+        xy.y = rho * Q->cosX1 * cosphi - xy.y * Q->sinX1* sinphi;
+        halfpi = M_HALFPI;
+        halfe = .5 * P->e;
+        break;
+    case N_POLE:
+        xy.y = -xy.y;
+    case S_POLE:
+        phi_l = M_HALFPI - 2. * atan (tp = - rho / Q->akm1);
+        halfpi = -M_HALFPI;
+        halfe = -.5 * P->e;
+        break;
+    }
+
+    for (i = NITER;  i--;  phi_l = lp.phi) {
+        sinphi = P->e * sin(phi_l);
+        lp.phi = 2. * atan (tp * pow ((1.+sinphi)/(1.-sinphi), halfe)) - halfpi;
+        if (fabs (phi_l - lp.phi) < CONV) {
+            if (Q->mode == S_POLE)
+                lp.phi = -lp.phi;
+            lp.lam = (xy.x == 0. && xy.y == 0.) ? 0. : atan2 (xy.x, xy.y);
+            return lp;
+        }
+    }
+    I_ERROR;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double  c, rh, sinc, cosc;
+
+    sinc = sin (c = 2. * atan ((rh = hypot (xy.x, xy.y)) / Q->akm1));
+    cosc = cos (c);
+    lp.lam = 0.;
+
+    switch (Q->mode) {
+    case EQUIT:
+        if (fabs (rh) <= EPS10)
+            lp.phi = 0.;
+        else
+            lp.phi = asin (xy.y * sinc / rh);
+        if (cosc != 0. || xy.x != 0.)
+            lp.lam = atan2 (xy.x * sinc, cosc * rh);
+        break;
+    case OBLIQ:
+        if (fabs (rh) <= EPS10)
+            lp.phi = P->phi0;
+        else
+            lp.phi = asin (cosc * sinph0 + xy.y * sinc * cosph0 / rh);
+        if ((c = cosc - sinph0 * sin (lp.phi)) != 0. || xy.x != 0.)
+            lp.lam = atan2 (xy.x * sinc * cosph0, c * rh);
+        break;
+    case N_POLE:
+        xy.y = -xy.y;
+    case S_POLE:
+        if (fabs (rh) <= EPS10)
+            lp.phi = P->phi0;
+        else
+            lp.phi = asin (Q->mode == S_POLE ? - cosc : cosc);
+        lp.lam = (xy.x == 0. && xy.y == 0.) ? 0. : atan2 (xy.x, xy.y);
+        break;
+    }
+    return lp;
 }
-INVERSE(s_inverse); /* spheroid */
-	double  c, rh, sinc, cosc;
-
-	sinc = sin(c = 2. * atan((rh = hypot(xy.x, xy.y)) / P->akm1));
-	cosc = cos(c);
-	lp.lam = 0.;
-	switch (P->mode) {
-	case EQUIT:
-		if (fabs(rh) <= EPS10)
-			lp.phi = 0.;
-		else
-			lp.phi = asin(xy.y * sinc / rh);
-		if (cosc != 0. || xy.x != 0.)
-			lp.lam = atan2(xy.x * sinc, cosc * rh);
-		break;
-	case OBLIQ:
-		if (fabs(rh) <= EPS10)
-			lp.phi = P->phi0;
-		else
-			lp.phi = asin(cosc * sinph0 + xy.y * sinc * cosph0 / rh);
-		if ((c = cosc - sinph0 * sin(lp.phi)) != 0. || xy.x != 0.)
-			lp.lam = atan2(xy.x * sinc * cosph0, c * rh);
-		break;
-	case N_POLE:
-		xy.y = -xy.y;
-	case S_POLE:
-		if (fabs(rh) <= EPS10)
-			lp.phi = P->phi0;
-		else
-			lp.phi = asin(P->mode == S_POLE ? - cosc : cosc);
-		lp.lam = (xy.x == 0. && xy.y == 0.) ? 0. : atan2(xy.x, xy.y);
-		break;
-	}
-	return (lp);
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+static PJ *setup(PJ *P) {                   /* general initialization */
+    double t;
+    struct pj_opaque *Q = P->opaque;
+
+    if (fabs ((t = fabs (P->phi0)) - M_HALFPI) < EPS10)
+        Q->mode = P->phi0 < 0. ? S_POLE : N_POLE;
+    else
+        Q->mode = t > EPS10 ? OBLIQ : EQUIT;
+    Q->phits = fabs (Q->phits);
+
+    if (P->es) {
+        double X;
+
+        switch (Q->mode) {
+        case N_POLE:
+        case S_POLE:
+            if (fabs (Q->phits - M_HALFPI) < EPS10)
+                Q->akm1 = 2. * P->k0 /
+                   sqrt (pow (1+P->e,1+P->e) * pow (1-P->e,1-P->e));
+            else {
+                Q->akm1 = cos (Q->phits) /
+                   pj_tsfn (Q->phits, t = sin (Q->phits), P->e);
+                t *= P->e;
+                Q->akm1 /= sqrt(1. - t * t);
+            }
+            break;
+        case EQUIT:
+        case OBLIQ:
+            t = sin (P->phi0);
+            X = 2. * atan (ssfn_(P->phi0, t, P->e)) - M_HALFPI;
+            t *= P->e;
+            Q->akm1 = 2. * P->k0 * cos (P->phi0) / sqrt(1. - t * t);
+            Q->sinX1 = sin (X);
+            Q->cosX1 = cos (X);
+            break;
+        }
+        P->inv = e_inverse;
+        P->fwd = e_forward;
+    } else {
+        switch (Q->mode) {
+        case OBLIQ:
+            sinph0 = sin (P->phi0);
+            cosph0 = cos (P->phi0);
+        case EQUIT:
+            Q->akm1 = 2. * P->k0;
+            break;
+        case S_POLE:
+        case N_POLE:
+            Q->akm1 = fabs (Q->phits - M_HALFPI) >= EPS10 ?
+               cos (Q->phits) / tan (M_FORTPI - .5 * Q->phits) :
+               2. * P->k0 ;
+            break;
+        }
+
+        P->inv = s_inverse;
+        P->fwd = s_forward;
+    }
+    return P;
 }
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) { /* general initialization */
-	double t;
-
-	if (fabs((t = fabs(P->phi0)) - HALFPI) < EPS10)
-		P->mode = P->phi0 < 0. ? S_POLE : N_POLE;
-	else
-		P->mode = t > EPS10 ? OBLIQ : EQUIT;
-	P->phits = fabs(P->phits);
-	if (P->es) {
-		double X;
-
-		switch (P->mode) {
-		case N_POLE:
-		case S_POLE:
-			if (fabs(P->phits - HALFPI) < EPS10)
-				P->akm1 = 2. * P->k0 /
-				   sqrt(pow(1+P->e,1+P->e)*pow(1-P->e,1-P->e));
-			else {
-				P->akm1 = cos(P->phits) /
-				   pj_tsfn(P->phits, t = sin(P->phits), P->e);
-				t *= P->e;
-				P->akm1 /= sqrt(1. - t * t);
-			}
-			break;
-		case EQUIT:
-		case OBLIQ:
-			t = sin(P->phi0);
-			X = 2. * atan(ssfn_(P->phi0, t, P->e)) - HALFPI;
-			t *= P->e;
-			P->akm1 = 2. * P->k0 * cos(P->phi0) / sqrt(1. - t * t);
-			P->sinX1 = sin(X);
-			P->cosX1 = cos(X);
-			break;
-		}
-		P->inv = e_inverse;
-		P->fwd = e_forward;
-	} else {
-		switch (P->mode) {
-		case OBLIQ:
-			sinph0 = sin(P->phi0);
-			cosph0 = cos(P->phi0);
-		case EQUIT:
-			P->akm1 = 2. * P->k0;
-			break;
-		case S_POLE:
-		case N_POLE:
-			P->akm1 = fabs(P->phits - HALFPI) >= EPS10 ?
-			   cos(P->phits) / tan(FORTPI - .5 * P->phits) :
-			   2. * P->k0 ;
-			break;
-		}
-		P->inv = s_inverse;
-		P->fwd = s_forward;
-	}
-	return P;
+
+
+PJ *PROJECTION(stere) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->phits = pj_param (P->ctx, P->params, "tlat_ts").i ?
+               pj_param (P->ctx, P->params, "rlat_ts").f : M_HALFPI;
+
+    return setup(P);
 }
-ENTRY0(stere)
-	P->phits = pj_param(P->ctx, P->params, "tlat_ts").i ?
-            pj_param(P->ctx, P->params, "rlat_ts").f : HALFPI;
-ENDENTRY(setup(P))
-ENTRY0(ups)
+
+
+PJ *PROJECTION(ups) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
 	/* International Ellipsoid */
-	P->phi0 = pj_param(P->ctx, P->params, "bsouth").i ? - HALFPI: HALFPI;
+	P->phi0 = pj_param(P->ctx, P->params, "bsouth").i ? - M_HALFPI: M_HALFPI;
 	if (!P->es) E_ERROR(-34);
 	P->k0 = .994;
 	P->x0 = 2000000.;
 	P->y0 = 2000000.;
-	P->phits = HALFPI;
+	Q->phits = M_HALFPI;
 	P->lam0 = 0.;
-ENDENTRY(setup(P))
+
+    return setup(P);
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_stere_selftest (void) {return 0;}
+#else
+
+int pj_stere_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=stere   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=stere   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 445289.70910023432,  221221.76694834774},
+        { 445289.70910023432, -221221.76694835056},
+        {-445289.70910023432,  221221.76694834774},
+        {-445289.70910023432, -221221.76694835056},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223407.81025950745,  111737.938996443},
+        { 223407.81025950745, -111737.938996443},
+        {-223407.81025950745,  111737.938996443},
+        {-223407.81025950745, -111737.938996443},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017966305682022392,  0.00090436947502443507},
+        { 0.0017966305682022392, -0.00090436947502443507},
+        {-0.0017966305682022392,  0.00090436947502443507},
+        {-0.0017966305682022392, -0.00090436947502443507},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.001790493109747395,  0.00089524655465513144},
+        { 0.001790493109747395, -0.00089524655465513144},
+        {-0.001790493109747395,  0.00089524655465513144},
+        {-0.001790493109747395, -0.00089524655465513144},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
+
+
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_ups_selftest (void) {return 0;}
+#else
+
+int pj_ups_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=ups   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {2433455.5634384668,  -10412543.301512826},
+        {2448749.1185681992,  -10850493.419804076},
+        {1566544.4365615332,  -10412543.301512826},
+        {1551250.8814318008,  -10850493.419804076},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {-44.998567498074834,  64.9182362867341},
+        {-44.995702709112308,  64.917020250675748},
+        {-45.004297076028529,  64.915804280954518},
+        {-45.001432287066002,  64.914588377560719},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
+
+
+#endif
diff --git a/src/PJ_sterea.c b/src/PJ_sterea.c
index fff2e95..9379901 100644
--- a/src/PJ_sterea.c
+++ b/src/PJ_sterea.c
@@ -23,61 +23,156 @@
 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
-#define PROJ_PARMS__ \
-	double phic0; \
-	double cosc0, sinc0; \
-	double R2; \
-	void *en;
-
 #define PJ_LIB__
-#include	<projects.h>
-
-PROJ_HEAD(sterea, "Oblique Stereographic Alternative")
-	"\n\tAzimuthal, Sph&Ell";
-# define DEL_TOL	1.e-14
-# define MAX_ITER	10
-
-FORWARD(e_forward); /* ellipsoid */
-	double cosc, sinc, cosl, k;
-
-	lp = pj_gauss(P->ctx, lp, P->en);
-	sinc = sin(lp.phi);
-	cosc = cos(lp.phi);
-	cosl = cos(lp.lam);
-	k = P->k0 * P->R2 / (1. + P->sinc0 * sinc + P->cosc0 * cosc * cosl);
-	xy.x = k * cosc * sin(lp.lam);
-	xy.y = k * (P->cosc0 * sinc - P->sinc0 * cosc * cosl);
-	return (xy);
+#include    <projects.h>
+
+
+struct pj_opaque {
+    double phic0;
+    double cosc0, sinc0;
+    double R2;
+    void *en;
+};
+
+
+PROJ_HEAD(sterea, "Oblique Stereographic Alternative") "\n\tAzimuthal, Sph&Ell";
+# define DEL_TOL    1.e-14
+# define MAX_ITER   10
+
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double cosc, sinc, cosl, k;
+
+    lp = pj_gauss(P->ctx, lp, Q->en);
+    sinc = sin(lp.phi);
+    cosc = cos(lp.phi);
+    cosl = cos(lp.lam);
+    k = P->k0 * Q->R2 / (1. + Q->sinc0 * sinc + Q->cosc0 * cosc * cosl);
+    xy.x = k * cosc * sin(lp.lam);
+    xy.y = k * (Q->cosc0 * sinc - Q->sinc0 * cosc * cosl);
+    return xy;
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double rho, c, sinc, cosc;
+
+    xy.x /= P->k0;
+    xy.y /= P->k0;
+    if ( (rho = hypot (xy.x, xy.y)) ) {
+        c = 2. * atan2 (rho, Q->R2);
+        sinc = sin (c);
+        cosc = cos (c);
+        lp.phi = asin (cosc * Q->sinc0 + xy.y * sinc * Q->cosc0 / rho);
+        lp.lam = atan2 (xy.x * sinc, rho * Q->cosc0 * cosc - xy.y * Q->sinc0 * sinc);
+    } else {
+        lp.phi = Q->phic0;
+        lp.lam = 0.;
+    }
+    return pj_inv_gauss(P->ctx, lp, Q->en);
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque->en);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(e_inverse); /* ellipsoid */
-	double rho, c, sinc, cosc;
-
-	xy.x /= P->k0;
-	xy.y /= P->k0;
-	if((rho = hypot(xy.x, xy.y))) {
-		c = 2. * atan2(rho, P->R2);
-		sinc = sin(c);
-		cosc = cos(c);
-		lp.phi = asin(cosc * P->sinc0 + xy.y * sinc * P->cosc0 / rho);
-		lp.lam = atan2(xy.x * sinc, rho * P->cosc0 * cosc -
-			xy.y * P->sinc0 * sinc);
-	} else {
-		lp.phi = P->phic0;
-		lp.lam = 0.;
-	}
-	return(pj_inv_gauss(P->ctx, lp, P->en));
+
+
+PJ *PROJECTION(sterea) {
+    double R;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->en = pj_gauss_ini(P->e, P->phi0, &(Q->phic0), &R);
+    if (0==Q->en)
+        return freeup_new (P);
+
+    Q->sinc0 = sin (Q->phic0);
+    Q->cosc0 = cos (Q->phic0);
+    Q->R2 = 2. * R;
+
+    P->inv = e_inverse;
+    P->fwd = e_forward;
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_sterea_selftest (void) {return 0;}
+#else
+
+int pj_sterea_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=sterea   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=sterea   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222644.89410919772,  110611.09187173686},
+        { 222644.89410919772, -110611.09187173827},
+        {-222644.89410919772,  110611.09187173686},
+        {-222644.89410919772, -110611.09187173827},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223407.81025950745,  111737.93899644315},
+        { 223407.81025950745, -111737.93899644315},
+        {-223407.81025950745,  111737.93899644315},
+        {-223407.81025950745, -111737.93899644315},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017966305682019911,  0.00090436947683099009},
+        { 0.0017966305682019911, -0.00090436947684371233},
+        {-0.0017966305682019911,  0.00090436947683099009},
+        {-0.0017966305682019911, -0.00090436947684371233},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.001790493109747395,  0.00089524655465446378},
+        { 0.001790493109747395, -0.00089524655465446378},
+        {-0.001790493109747395,  0.00089524655465446378},
+        {-0.001790493109747395, -0.00089524655465446378},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
 }
-FREEUP; if (P) { if (P->en) free(P->en); free(P); } }
-ENTRYA(sterea)
-
-        P->en=0; 
-ENTRYX
-	double R;
-
-	if (!(P->en = pj_gauss_ini(P->e, P->phi0, &(P->phic0), &R))) E_ERROR_0;
-	P->sinc0 = sin(P->phic0);
-	P->cosc0 = cos(P->phic0);
-	P->R2 = 2. * R;
-	P->inv = e_inverse;
-	P->fwd = e_forward;
-ENDENTRY(P)
+
+
+#endif
diff --git a/src/PJ_sts.c b/src/PJ_sts.c
index c35d5cf..347a730 100644
--- a/src/PJ_sts.c
+++ b/src/PJ_sts.c
@@ -1,54 +1,351 @@
-#define PROJ_PARMS__ \
-	double C_x, C_y, C_p; \
-	int tan_mode;
 #define PJ_LIB__
 # include	<projects.h>
-PROJ_HEAD(kav5, "Kavraisky V") "\n\tPCyl., Sph.";
-PROJ_HEAD(qua_aut, "Quartic Authalic") "\n\tPCyl., Sph.";
-PROJ_HEAD(mbt_s, "McBryde-Thomas Flat-Polar Sine (No. 1)") "\n\tPCyl., Sph.";
-PROJ_HEAD(fouc, "Foucaut") "\n\tPCyl., Sph.";
-FORWARD(s_forward); /* spheroid */
+
+PROJ_HEAD(kav5,    "Kavraisky V")         "\n\tPCyl., Sph.";
+PROJ_HEAD(qua_aut, "Quartic Authalic")    "\n\tPCyl., Sph.";
+PROJ_HEAD(fouc,    "Foucaut")             "\n\tPCyl., Sph.";
+PROJ_HEAD(mbt_s,   "McBryde-Thomas Flat-Polar Sine (No. 1)") "\n\tPCyl., Sph.";
+
+
+struct pj_opaque {
+	double C_x, C_y, C_p; \
+	int tan_mode;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double c;
 
-	xy.x = P->C_x * lp.lam * cos(lp.phi);
-	xy.y = P->C_y;
-	lp.phi *= P->C_p;
+	xy.x = Q->C_x * lp.lam * cos(lp.phi);
+	xy.y = Q->C_y;
+	lp.phi *= Q->C_p;
 	c = cos(lp.phi);
-	if (P->tan_mode) {
+	if (Q->tan_mode) {
 		xy.x *= c * c;
-		xy.y *= tan(lp.phi);
+		xy.y *= tan (lp.phi);
 	} else {
 		xy.x /= c;
-		xy.y *= sin(lp.phi);
+		xy.y *= sin (lp.phi);
 	}
-	return (xy);
+	return xy;
 }
-INVERSE(s_inverse); /* spheroid */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double c;
-	
-	xy.y /= P->C_y;
-	c = cos(lp.phi = P->tan_mode ? atan(xy.y) : aasin(P->ctx,xy.y));
-	lp.phi /= P->C_p;
-	lp.lam = xy.x / (P->C_x * cos(lp.phi));
-	if (P->tan_mode)
+
+	xy.y /= Q->C_y;
+	c = cos (lp.phi = Q->tan_mode ? atan (xy.y) : aasin (P->ctx, xy.y));
+	lp.phi /= Q->C_p;
+	lp.lam = xy.x / (Q->C_x * cos(lp.phi));
+	if (Q->tan_mode)
 		lp.lam /= c * c;
 	else
 		lp.lam *= c;
-	return (lp);
+	return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P, double p, double q, int mode) {
-	P->es = 0.;
+
+
+static PJ *setup(PJ *P, double p, double q, int mode) {
+	P->es  = 0.;
 	P->inv = s_inverse;
 	P->fwd = s_forward;
-	P->C_x = q / p;
-	P->C_y = p;
-	P->C_p = 1/ q;
-	P->tan_mode = mode;
+	P->opaque->C_x = q / p;
+	P->opaque->C_y = p;
+	P->opaque->C_p = 1/ q;
+	P->opaque->tan_mode = mode;
 	return P;
 }
-ENTRY0(kav5) ENDENTRY(setup(P, 1.50488, 1.35439, 0))
-ENTRY0(qua_aut) ENDENTRY(setup(P, 2., 2., 0))
-ENTRY0(mbt_s) ENDENTRY(setup(P, 1.48875, 1.36509, 0))
-ENTRY0(fouc) ENDENTRY(setup(P, 2., 2., 1))
+
+
+
+
+
+PJ *PROJECTION(fouc) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+    return setup(P, 2., 2., 1);
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_fouc_selftest (void) {return 0;}
+#else
+int pj_fouc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=fouc   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=fouc   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222588.12067589167,  111322.31670069379},
+        {222588.12067589167,  -111322.31670069379},
+        {-222588.12067589167,  111322.31670069379},
+        {-222588.12067589167,  -111322.31670069379},
+    };
+
+    XY s_fwd_expect[] = {
+        {223351.10900341379,  111703.9077217125},
+        {223351.10900341379,  -111703.9077217125},
+        {-223351.10900341379,  111703.9077217125},
+        {-223351.10900341379,  -111703.9077217125},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017966305685702751,  0.00089831528410111959},
+        {0.0017966305685702751,  -0.00089831528410111959},
+        {-0.0017966305685702751,  0.00089831528410111959},
+        {-0.0017966305685702751,  -0.00089831528410111959},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017904931101116717,  0.00089524655487369749},
+        {0.0017904931101116717,  -0.00089524655487369749},
+        {-0.0017904931101116717,  0.00089524655487369749},
+        {-0.0017904931101116717,  -0.00089524655487369749},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+#endif
+
+
+
+
+
+
+PJ *PROJECTION(kav5) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    return setup(P, 1.50488, 1.35439, 0);
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_kav5_selftest (void) {return 0;}
+#else
+int pj_kav5_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=kav5   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=kav5   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {200360.90530882866,  123685.08247699818},
+        {200360.90530882866,  -123685.08247699818},
+        {-200360.90530882866,  123685.08247699818},
+        {-200360.90530882866,  -123685.08247699818},
+    };
+
+    XY s_fwd_expect[] = {
+        {201047.7031108776,  124109.05062917093},
+        {201047.7031108776,  -124109.05062917093},
+        {-201047.7031108776,  124109.05062917093},
+        {-201047.7031108776,  -124109.05062917093},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0019962591348533314,  0.00080848256185253912},
+        {0.0019962591348533314,  -0.00080848256185253912},
+        {-0.0019962591348533314,  0.00080848256185253912},
+        {-0.0019962591348533314,  -0.00080848256185253912},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0019894397264987643,  0.00080572070962591153},
+        {0.0019894397264987643,  -0.00080572070962591153},
+        {-0.0019894397264987643,  0.00080572070962591153},
+        {-0.0019894397264987643,  -0.00080572070962591153},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+#endif
+
+
+
+
+
+PJ *PROJECTION(qua_aut) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+    return setup(P, 2., 2., 0);
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_qua_aut_selftest (void) {return 0;}
+#else
+int pj_qua_aut_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=qua_aut   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=qua_aut   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222613.54903309655,  111318.07788798446},
+        {222613.54903309655,  -111318.07788798446},
+        {-222613.54903309655,  111318.07788798446},
+        {-222613.54903309655,  -111318.07788798446},
+    };
+
+    XY s_fwd_expect[] = {
+        {223376.62452402918,  111699.65437918637},
+        {223376.62452402918,  -111699.65437918637},
+        {-223376.62452402918,  111699.65437918637},
+        {-223376.62452402918,  -111699.65437918637},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017966305684046586,  0.00089831528412872229},
+        {0.0017966305684046586,  -0.00089831528412872229},
+        {-0.0017966305684046586,  0.00089831528412872229},
+        {-0.0017966305684046586,  -0.00089831528412872229},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0017904931099477471,  0.00089524655490101819},
+        {0.0017904931099477471,  -0.00089524655490101819},
+        {-0.0017904931099477471,  0.00089524655490101819},
+        {-0.0017904931099477471,  -0.00089524655490101819},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+#endif
+
+
+
+
+
+PJ *PROJECTION(mbt_s) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+    return setup(P, 1.48875, 1.36509, 0);
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_mbt_s_selftest (void) {return 0;}
+#else
+int pj_mbt_s_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=mbt_s   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=mbt_s   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {204131.51785027285,  121400.33022550763},
+        {204131.51785027285,  -121400.33022550763},
+        {-204131.51785027285,  121400.33022550763},
+        {-204131.51785027285,  -121400.33022550763},
+    };
+
+    XY s_fwd_expect[] = {
+        {204831.24057099217,  121816.46669603503},
+        {204831.24057099217,  -121816.46669603503},
+        {-204831.24057099217,  121816.46669603503},
+        {-204831.24057099217,  -121816.46669603503},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0019593827209883237,  0.00082369854658027549},
+        {0.0019593827209883237,  -0.00082369854658027549},
+        {-0.0019593827209883237,  0.00082369854658027549},
+        {-0.0019593827209883237,  -0.00082369854658027549},
+    };
+
+    LP s_inv_expect[] = {
+        {0.0019526892859206603,  0.00082088471512331508},
+        {0.0019526892859206603,  -0.00082088471512331508},
+        {-0.0019526892859206603,  0.00082088471512331508},
+        {-0.0019526892859206603,  -0.00082088471512331508},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+#endif
diff --git a/src/PJ_tcc.c b/src/PJ_tcc.c
index 00cdb55..457924c 100644
--- a/src/PJ_tcc.c
+++ b/src/PJ_tcc.c
@@ -1,17 +1,65 @@
-#define PROJ_PARMS__ \
-	double ap;
-#define EPS10 1.e-10
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
 PROJ_HEAD(tcc, "Transverse Central Cylindrical") "\n\tCyl, Sph, no inv.";
-FORWARD(s_forward); /* spheroid */
-	double b, bt;
-
-	b = cos(lp.phi) * sin(lp.lam);
-	if ((bt = 1. - b * b) < EPS10) F_ERROR;
-	xy.x = b / sqrt(bt);
-	xy.y = atan2(tan(lp.phi) , cos(lp.lam));
-	return (xy);
+
+#define EPS10 1.e-10
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0, 0.0};
+    double b, bt;
+
+    b = cos (lp.phi) * sin (lp.lam);
+    if ((bt = 1. - b * b) < EPS10) F_ERROR;
+    xy.x = b / sqrt(bt);
+    xy.y = atan2 (tan (lp.phi) , cos (lp.lam));
+    return xy;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(tcc) {
+    P->es  = 0.;
+    P->fwd = s_forward;
+    P->inv = 0;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_tcc_selftest (void) {return 0;}
+#else
+int pj_tcc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=tcc   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {223458.84419245756,  111769.14504058579},
+        {223458.84419245756,  -111769.14504058579},
+        {-223458.84419245756,  111769.14504058579},
+        {-223458.84419245756,  -111769.14504058579},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(tcc) P->es = 0.; P->fwd = s_forward; ENDENTRY(P)
+#endif
diff --git a/src/PJ_tcea.c b/src/PJ_tcea.c
index 3626fa1..7b469d0 100644
--- a/src/PJ_tcea.c
+++ b/src/PJ_tcea.c
@@ -1,27 +1,85 @@
-#define PROJ_PARMS__ \
-	double rk0;
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
 PROJ_HEAD(tcea, "Transverse Cylindrical Equal Area") "\n\tCyl, Sph";
-FORWARD(s_forward); /* spheroid */
-	xy.x = P->rk0 * cos(lp.phi) * sin(lp.lam);
-	xy.y = P->k0 * (atan2(tan(lp.phi), cos(lp.lam)) - P->phi0);
-	return (xy);
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    xy.x = cos (lp.phi) * sin (lp.lam) / P->k0;
+    xy.y = P->k0 * (atan2 (tan (lp.phi), cos (lp.lam)) - P->phi0);
+    return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0, 0.0};
+    double t;
+
+    xy.y = xy.y / P->k0 + P->phi0;
+    xy.x *= P->k0;
+    t = sqrt (1. - xy.x * xy.x);
+    lp.phi = asin (t * sin (xy.y));
+    lp.lam = atan2 (xy.x, t * cos (xy.y));
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(s_inverse); /* spheroid */
-	double t;
-
-	xy.y = xy.y * P->rk0 + P->phi0;
-	xy.x *= P->k0;
-	t = sqrt(1. - xy.x * xy.x);
-	lp.phi = asin(t * sin(xy.y));
-	lp.lam = atan2(xy.x, t * cos(xy.y));
-	return (lp);
+
+
+PJ *PROJECTION(tcea) {
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    P->es = 0.;
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_tcea_selftest (void) {return 0;}
+#else
+int pj_tcea_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=tcea   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223322.76057672748,  111769.14504058579},
+        { 223322.76057672748, -111769.14504058579},
+        {-223322.76057672748,  111769.14504058579},
+        {-223322.76057672748, -111769.14504058579},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931102938101,  0.00089524655445477922},
+        { 0.0017904931102938101, -0.00089524655445477922},
+        {-0.0017904931102938101,  0.00089524655445477922},
+        {-0.0017904931102938101, -0.00089524655445477922},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(tcea)
-	P->rk0 = 1 / P->k0;
-	P->inv = s_inverse;
-	P->fwd = s_forward;
-	P->es = 0.;
-ENDENTRY(P)
+#endif
diff --git a/src/PJ_tmerc.c b/src/PJ_tmerc.c
index 3b1e0fb..ab77f4d 100644
--- a/src/PJ_tmerc.c
+++ b/src/PJ_tmerc.c
@@ -1,15 +1,16 @@
-#define PROJ_PARMS__ \
-	double	esp; \
-	double	ml0; \
-	double	*en;
 #define PJ_LIB__
-#include	<projects.h>
+#include    <projects.h>
+
 PROJ_HEAD(tmerc, "Transverse Mercator") "\n\tCyl, Sph&Ell";
-PROJ_HEAD(utm, "Universal Transverse Mercator (UTM)")
-	"\n\tCyl, Sph\n\tzone= south";
-#define EPS10	1.e-10
-#define aks0	P->esp
-#define aks5	P->ml0
+
+
+struct pj_opaque {
+    double  esp; \
+    double  ml0; \
+    double  *en;
+};
+
+#define EPS10   1.e-10
 #define FC1 1.
 #define FC2 .5
 #define FC3 .16666666666666666666
@@ -18,158 +19,234 @@ PROJ_HEAD(utm, "Universal Transverse Mercator (UTM)")
 #define FC6 .03333333333333333333
 #define FC7 .02380952380952380952
 #define FC8 .01785714285714285714
-FORWARD(e_forward); /* ellipse */
-	double al, als, n, cosphi, sinphi, t;
-
-        /*
-         * Fail if our longitude is more than 90 degrees from the 
-         * central meridian since the results are essentially garbage. 
-         * Is error -20 really an appropriate return value?
-         * 
-         *  http://trac.osgeo.org/proj/ticket/5
-         */
-        if( lp.lam < -HALFPI || lp.lam > HALFPI )
-        {
-            xy.x = HUGE_VAL;
-            xy.y = HUGE_VAL;
-            pj_ctx_set_errno( P->ctx, -14 );
-            return xy;
-        }
-
-	sinphi = sin(lp.phi); cosphi = cos(lp.phi);
-	t = fabs(cosphi) > 1e-10 ? sinphi/cosphi : 0.;
-	t *= t;
-	al = cosphi * lp.lam;
-	als = al * al;
-	al /= sqrt(1. - P->es * sinphi * sinphi);
-	n = P->esp * cosphi * cosphi;
-	xy.x = P->k0 * al * (FC1 +
-		FC3 * als * (1. - t + n +
-		FC5 * als * (5. + t * (t - 18.) + n * (14. - 58. * t)
-		+ FC7 * als * (61. + t * ( t * (179. - t) - 479. ) )
-		)));
-	xy.y = P->k0 * (pj_mlfn(lp.phi, sinphi, cosphi, P->en) - P->ml0 +
-		sinphi * al * lp.lam * FC2 * ( 1. +
-		FC4 * als * (5. - t + n * (9. + 4. * n) +
-		FC6 * als * (61. + t * (t - 58.) + n * (270. - 330 * t)
-		+ FC8 * als * (1385. + t * ( t * (543. - t) - 3111.) )
-		))));
-	return (xy);
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0, 0.0};
+    struct pj_opaque *Q = P->opaque;
+    double al, als, n, cosphi, sinphi, t;
+
+    /*
+     * Fail if our longitude is more than 90 degrees from the
+     * central meridian since the results are essentially garbage.
+     * Is error -20 really an appropriate return value?
+     *
+     *  http://trac.osgeo.org/proj/ticket/5
+     */
+    if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) {
+        xy.x = HUGE_VAL;
+        xy.y = HUGE_VAL;
+        pj_ctx_set_errno( P->ctx, -14 );
+        return xy;
+    }
+
+    sinphi = sin (lp.phi);
+    cosphi = cos (lp.phi);
+    t = fabs (cosphi) > 1e-10 ? sinphi/cosphi : 0.;
+    t *= t;
+    al = cosphi * lp.lam;
+    als = al * al;
+    al /= sqrt (1. - P->es * sinphi * sinphi);
+    n = Q->esp * cosphi * cosphi;
+    xy.x = P->k0 * al * (FC1 +
+        FC3 * als * (1. - t + n +
+        FC5 * als * (5. + t * (t - 18.) + n * (14. - 58. * t)
+        + FC7 * als * (61. + t * ( t * (179. - t) - 479. ) )
+        )));
+    xy.y = P->k0 * (pj_mlfn(lp.phi, sinphi, cosphi, Q->en) - Q->ml0 +
+        sinphi * al * lp.lam * FC2 * ( 1. +
+        FC4 * als * (5. - t + n * (9. + 4. * n) +
+        FC6 * als * (61. + t * (t - 58.) + n * (270. - 330 * t)
+        + FC8 * als * (1385. + t * ( t * (543. - t) - 3111.) )
+        ))));
+    return (xy);
+}
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double b, cosphi;
+
+    /*
+     * Fail if our longitude is more than 90 degrees from the
+     * central meridian since the results are essentially garbage.
+     * Is error -20 really an appropriate return value?
+     *
+     *  http://trac.osgeo.org/proj/ticket/5
+     */
+    if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) {
+        xy.x = HUGE_VAL;
+        xy.y = HUGE_VAL;
+        pj_ctx_set_errno( P->ctx, -14 );
+        return xy;
+    }
+
+    cosphi = cos(lp.phi);
+    b = cosphi * sin (lp.lam);
+    if (fabs (fabs (b) - 1.) <= EPS10)
+        F_ERROR;
+
+    xy.x = P->opaque->ml0 * log ((1. + b) / (1. - b));
+    xy.y = cosphi * cos (lp.lam) / sqrt (1. - b * b);
+
+    b = fabs ( xy.y );
+    if (b >= 1.) {
+        if ((b - 1.) > EPS10)
+            F_ERROR
+        else xy.y = 0.;
+    } else
+        xy.y = acos (xy.y);
+
+    if (lp.phi < 0.)
+        xy.y = -xy.y;
+    xy.y = P->opaque->esp * (xy.y - P->phi0);
+    return xy;
+}
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double n, con, cosphi, d, ds, sinphi, t;
+
+    lp.phi = pj_inv_mlfn(P->ctx, Q->ml0 + xy.y / P->k0, P->es, Q->en);
+    if (fabs(lp.phi) >= M_HALFPI) {
+        lp.phi = xy.y < 0. ? -M_HALFPI : M_HALFPI;
+        lp.lam = 0.;
+    } else {
+        sinphi = sin(lp.phi);
+        cosphi = cos(lp.phi);
+        t = fabs (cosphi) > 1e-10 ? sinphi/cosphi : 0.;
+        n = Q->esp * cosphi * cosphi;
+        d = xy.x * sqrt (con = 1. - P->es * sinphi * sinphi) / P->k0;
+        con *= t;
+        t *= t;
+        ds = d * d;
+        lp.phi -= (con * ds / (1.-P->es)) * FC2 * (1. -
+            ds * FC4 * (5. + t * (3. - 9. *  n) + n * (1. - 4 * n) -
+            ds * FC6 * (61. + t * (90. - 252. * n +
+                45. * t) + 46. * n
+           - ds * FC8 * (1385. + t * (3633. + t * (4095. + 1574. * t)) )
+            )));
+        lp.lam = d*(FC1 -
+            ds*FC3*( 1. + 2.*t + n -
+            ds*FC5*(5. + t*(28. + 24.*t + 8.*n) + 6.*n
+           - ds * FC7 * (61. + t * (662. + t * (1320. + 720. * t)) )
+        ))) / cosphi;
+    }
+    return lp;
 }
-FORWARD(s_forward); /* sphere */
-	double b, cosphi;
-
-        /*
-         * Fail if our longitude is more than 90 degrees from the 
-         * central meridian since the results are essentially garbage. 
-         * Is error -20 really an appropriate return value?
-         * 
-         *  http://trac.osgeo.org/proj/ticket/5
-         */
-        if( lp.lam < -HALFPI || lp.lam > HALFPI )
-        {
-            xy.x = HUGE_VAL;
-            xy.y = HUGE_VAL;
-            pj_ctx_set_errno( P->ctx, -14 );
-            return xy;
-        }
-
-	b = (cosphi = cos(lp.phi)) * sin(lp.lam);
-	if (fabs(fabs(b) - 1.) <= EPS10) F_ERROR;
-	xy.x = aks5 * log((1. + b) / (1. - b));
-	if ((b = fabs( xy.y = cosphi * cos(lp.lam) / sqrt(1. - b * b) )) >= 1.) {
-		if ((b - 1.) > EPS10) F_ERROR
-		else xy.y = 0.;
-	} else
-		xy.y = acos(xy.y);
-	if (lp.phi < 0.) xy.y = -xy.y;
-	xy.y = aks0 * (xy.y - P->phi0);
-	return (xy);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0, 0.0};
+    double h, g;
+
+    h = exp(xy.x / P->opaque->esp);
+    g = .5 * (h - 1. / h);
+    h = cos (P->phi0 + xy.y / P->opaque->esp);
+    lp.phi = asin(sqrt((1. - h * h) / (1. + g * g)));
+    if (xy.y < 0.) lp.phi = -lp.phi;
+    lp.lam = (g || h) ? atan2 (g, h) : 0.;
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+    pj_dealloc (P->opaque->en);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
-INVERSE(e_inverse); /* ellipsoid */
-	double n, con, cosphi, d, ds, sinphi, t;
-
-	lp.phi = pj_inv_mlfn(P->ctx, P->ml0 + xy.y / P->k0, P->es, P->en);
-	if (fabs(lp.phi) >= HALFPI) {
-		lp.phi = xy.y < 0. ? -HALFPI : HALFPI;
-		lp.lam = 0.;
-	} else {
-		sinphi = sin(lp.phi);
-		cosphi = cos(lp.phi);
-		t = fabs(cosphi) > 1e-10 ? sinphi/cosphi : 0.;
-		n = P->esp * cosphi * cosphi;
-		d = xy.x * sqrt(con = 1. - P->es * sinphi * sinphi) / P->k0;
-		con *= t;
-		t *= t;
-		ds = d * d;
-		lp.phi -= (con * ds / (1.-P->es)) * FC2 * (1. -
-			ds * FC4 * (5. + t * (3. - 9. *  n) + n * (1. - 4 * n) -
-			ds * FC6 * (61. + t * (90. - 252. * n +
-				45. * t) + 46. * n
-		   - ds * FC8 * (1385. + t * (3633. + t * (4095. + 1574. * t)) )
-			)));
-		lp.lam = d*(FC1 -
-			ds*FC3*( 1. + 2.*t + n -
-			ds*FC5*(5. + t*(28. + 24.*t + 8.*n) + 6.*n
-		   - ds * FC7 * (61. + t * (662. + t * (1320. + 720. * t)) )
-		))) / cosphi;
-	}
-	return (lp);
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-INVERSE(s_inverse); /* sphere */
-	double h, g;
-
-	h = exp(xy.x / aks0);
-	g = .5 * (h - 1. / h);
-	h = cos(P->phi0 + xy.y / aks0);
-	lp.phi = asin(sqrt((1. - h * h) / (1. + g * g)));
-	if (xy.y < 0.) lp.phi = -lp.phi;
-	lp.lam = (g || h) ? atan2(g, h) : 0.;
-	return (lp);
+
+static PJ *setup(PJ *P) {                   /* general initialization */
+    struct pj_opaque *Q = P->opaque;
+    if (P->es) {
+        if (!(Q->en = pj_enfn(P->es)))
+            E_ERROR_0;
+        Q->ml0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), Q->en);
+        Q->esp = P->es / (1. - P->es);
+        P->inv = e_inverse;
+        P->fwd = e_forward;
+    } else {
+        Q->esp = P->k0;
+        Q->ml0 = .5 * Q->esp;
+        P->inv = s_inverse;
+        P->fwd = s_forward;
+    }
+    return P;
 }
-FREEUP;
-	if (P) {
-		if (P->en)
-			pj_dalloc(P->en);
-		pj_dalloc(P);
-	}
+
+
+PJ *PROJECTION(tmerc) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+    return setup(P);
 }
-	static PJ *
-setup(PJ *P) { /* general initialization */
-	if (P->es) {
-		if (!(P->en = pj_enfn(P->es)))
-			E_ERROR_0;
-		P->ml0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), P->en);
-		P->esp = P->es / (1. - P->es);
-		P->inv = e_inverse;
-		P->fwd = e_forward;
-	} else {
-		aks0 = P->k0;
-		aks5 = .5 * aks0;
-		P->inv = s_inverse;
-		P->fwd = s_forward;
-	}
-	return P;
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_tmerc_selftest (void) {return 0;}
+#else
+int pj_tmerc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=tmerc   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=tmerc   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222650.79679577847,  110642.22941192707},
+        { 222650.79679577847, -110642.22941192707},
+        {-222650.79679577847,  110642.22941192707},
+        {-222650.79679577847, -110642.22941192707},
+    };
+
+    XY s_fwd_expect[] = {
+        { 223413.46640632232,  111769.14504059685},
+        { 223413.46640632232, -111769.14504059685},
+        {-223413.46640632208,  111769.14504059685},
+        {-223413.46640632208, -111769.14504059685},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017966305681649396,  0.00090436947663183841},
+        { 0.0017966305681649396, -0.00090436947663183841},
+        {-0.0017966305681649396,  0.00090436947663183841},
+        {-0.0017966305681649396, -0.00090436947663183841},
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931097048034,  0.00089524670602767842},
+        { 0.0017904931097048034, -0.00089524670602767842},
+        {-0.001790493109714345,   0.00089524670602767842},
+        {-0.001790493109714345,  -0.00089524670602767842},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
 }
-ENTRY1(tmerc, en)
-ENDENTRY(setup(P))
-ENTRY1(utm, en)
-	int zone;
-
-	if (!P->es) E_ERROR(-34);
-	P->y0 = pj_param(P->ctx, P->params, "bsouth").i ? 10000000. : 0.;
-	P->x0 = 500000.;
-	if (pj_param(P->ctx, P->params, "tzone").i) /* zone input ? */
-		if ((zone = pj_param(P->ctx, P->params, "izone").i) > 0 && zone <= 60)
-			--zone;
-		else
-			E_ERROR(-35)
-	else /* nearest central meridian input */
-		if ((zone = floor((adjlon(P->lam0) + PI) * 30. / PI)) < 0)
-			zone = 0;
-		else if (zone >= 60)
-			zone = 59;
-	P->lam0 = (zone + .5) * PI / 30. - PI;
-	P->k0 = 0.9996;
-	P->phi0 = 0.;
-ENDENTRY(setup(P))
+#endif
diff --git a/src/PJ_tpeqd.c b/src/PJ_tpeqd.c
index 4ab5cf4..e8bf8e1 100644
--- a/src/PJ_tpeqd.c
+++ b/src/PJ_tpeqd.c
@@ -1,76 +1,177 @@
-#define PROJ_PARMS__ \
-	double cp1, sp1, cp2, sp2, ccs, cs, sc, r2z0, z02, dlam2; \
-	double hz0, thz0, rhshz0, ca, sa, lp, lamc;
 #define PJ_LIB__
 #include	<projects.h>
+
+
 PROJ_HEAD(tpeqd, "Two Point Equidistant")
 	"\n\tMisc Sph\n\tlat_1= lon_1= lat_2= lon_2=";
-FORWARD(s_forward); /* sphere */
+
+struct pj_opaque {
+	double cp1, sp1, cp2, sp2, ccs, cs, sc, r2z0, z02, dlam2; \
+	double hz0, thz0, rhshz0, ca, sa, lp, lamc;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0, 0.0};
+    struct pj_opaque *Q = P->opaque;
 	double t, z1, z2, dl1, dl2, sp, cp;
 
 	sp = sin(lp.phi);
 	cp = cos(lp.phi);
-	z1 = aacos(P->ctx,P->sp1 * sp + P->cp1 * cp * cos(dl1 = lp.lam + P->dlam2));
-	z2 = aacos(P->ctx,P->sp2 * sp + P->cp2 * cp * cos(dl2 = lp.lam - P->dlam2));
+	z1 = aacos(P->ctx, Q->sp1 * sp + Q->cp1 * cp * cos (dl1 = lp.lam + Q->dlam2));
+	z2 = aacos(P->ctx, Q->sp2 * sp + Q->cp2 * cp * cos (dl2 = lp.lam - Q->dlam2));
 	z1 *= z1;
 	z2 *= z2;
-	xy.x = P->r2z0 * (t = z1 - z2);
-	t = P->z02 - t;
-	xy.y = P->r2z0 * asqrt(4. * P->z02 * z2 - t * t);
-	if ((P->ccs * sp - cp * (P->cs * sin(dl1) - P->sc * sin(dl2))) < 0.)
+
+	xy.x = Q->r2z0 * (t = z1 - z2);
+	t = Q->z02 - t;
+	xy.y = Q->r2z0 * asqrt (4. * Q->z02 * z2 - t * t);
+	if ((Q->ccs * sp - cp * (Q->cs * sin(dl1) - Q->sc * sin(dl2))) < 0.)
 		xy.y = -xy.y;
 	return xy;
 }
-INVERSE(s_inverse); /* sphere */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
 	double cz1, cz2, s, d, cp, sp;
 
-	cz1 = cos(hypot(xy.y, xy.x + P->hz0));
-	cz2 = cos(hypot(xy.y, xy.x - P->hz0));
+	cz1 = cos (hypot(xy.y, xy.x + Q->hz0));
+	cz2 = cos (hypot(xy.y, xy.x - Q->hz0));
 	s = cz1 + cz2;
 	d = cz1 - cz2;
-	lp.lam = - atan2(d, (s * P->thz0));
-	lp.phi = aacos(P->ctx,hypot(P->thz0 * s, d) * P->rhshz0);
+	lp.lam = - atan2(d, (s * Q->thz0));
+	lp.phi = aacos(P->ctx, hypot (Q->thz0 * s, d) * Q->rhshz0);
 	if ( xy.y < 0. )
 		lp.phi = - lp.phi;
 	/* lam--phi now in system relative to P1--P2 base equator */
-	sp = sin(lp.phi);
-	cp = cos(lp.phi);
-	lp.phi = aasin(P->ctx,P->sa * sp + P->ca * cp * (s = cos(lp.lam -= P->lp)));
-	lp.lam = atan2(cp * sin(lp.lam), P->sa * cp * s - P->ca * sp) + P->lamc;
+	sp = sin (lp.phi);
+	cp = cos (lp.phi);
+	lp.phi = aasin (P->ctx, Q->sa * sp + Q->ca * cp * (s = cos(lp.lam -= Q->lp)));
+	lp.lam = atan2 (cp * sin(lp.lam), Q->sa * cp * s - Q->ca * sp) + Q->lamc;
 	return lp;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(tpeqd)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(tpeqd) {
 	double lam_1, lam_2, phi_1, phi_2, A12, pp;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
 
 	/* get control point locations */
 	phi_1 = pj_param(P->ctx, P->params, "rlat_1").f;
 	lam_1 = pj_param(P->ctx, P->params, "rlon_1").f;
 	phi_2 = pj_param(P->ctx, P->params, "rlat_2").f;
 	lam_2 = pj_param(P->ctx, P->params, "rlon_2").f;
-	if (phi_1 == phi_2 && lam_1 == lam_2) E_ERROR(-25);
-	P->lam0 = adjlon(0.5 * (lam_1 + lam_2));
-	P->dlam2 = adjlon(lam_2 - lam_1);
-	P->cp1 = cos(phi_1);
-	P->cp2 = cos(phi_2);
-	P->sp1 = sin(phi_1);
-	P->sp2 = sin(phi_2);
-	P->cs = P->cp1 * P->sp2;
-	P->sc = P->sp1 * P->cp2;
-	P->ccs = P->cp1 * P->cp2 * sin(P->dlam2);
-	P->z02 = aacos(P->ctx,P->sp1 * P->sp2 + P->cp1 * P->cp2 * cos(P->dlam2));
-	P->hz0 = .5 * P->z02;
-	A12 = atan2(P->cp2 * sin(P->dlam2),
-		P->cp1 * P->sp2 - P->sp1 * P->cp2 * cos(P->dlam2));
-	P->ca = cos(pp = aasin(P->ctx,P->cp1 * sin(A12)));
-	P->sa = sin(pp);
-	P->lp = adjlon(atan2(P->cp1 * cos(A12), P->sp1) - P->hz0);
-	P->dlam2 *= .5;
-	P->lamc = HALFPI - atan2(sin(A12) * P->sp1, cos(A12)) - P->dlam2;
-	P->thz0 = tan(P->hz0);
-	P->rhshz0 = .5 / sin(P->hz0);
-	P->r2z0 = 0.5 / P->z02;
-	P->z02 *= P->z02;
-	P->inv = s_inverse; P->fwd = s_forward;
+
+	if (phi_1 == phi_2 && lam_1 == lam_2)
+        E_ERROR(-25);
+	P->lam0  = adjlon (0.5 * (lam_1 + lam_2));
+	Q->dlam2 = adjlon (lam_2 - lam_1);
+
+	Q->cp1 = cos (phi_1);
+	Q->cp2 = cos (phi_2);
+	Q->sp1 = sin (phi_1);
+	Q->sp2 = sin (phi_2);
+	Q->cs = Q->cp1 * Q->sp2;
+	Q->sc = Q->sp1 * Q->cp2;
+	Q->ccs = Q->cp1 * Q->cp2 * sin(Q->dlam2);
+	Q->z02 = aacos(P->ctx, Q->sp1 * Q->sp2 + Q->cp1 * Q->cp2 * cos (Q->dlam2));
+	Q->hz0 = .5 * Q->z02;
+	A12 = atan2(Q->cp2 * sin (Q->dlam2),
+		Q->cp1 * Q->sp2 - Q->sp1 * Q->cp2 * cos (Q->dlam2));
+	Q->ca = cos(pp = aasin(P->ctx, Q->cp1 * sin(A12)));
+	Q->sa = sin(pp);
+	Q->lp = adjlon ( atan2 (Q->cp1 * cos(A12), Q->sp1) - Q->hz0);
+	Q->dlam2 *= .5;
+	Q->lamc = M_HALFPI - atan2(sin(A12) * Q->sp1, cos(A12)) - Q->dlam2;
+	Q->thz0 = tan (Q->hz0);
+	Q->rhshz0 = .5 / sin (Q->hz0);
+	Q->r2z0 = 0.5 / Q->z02;
+	Q->z02 *= Q->z02;
+
+    P->inv = s_inverse;
+    P->fwd = s_forward;
 	P->es = 0.;
-ENDENTRY(P)
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_tpeqd_selftest (void) {return 0;}
+#else
+
+int pj_tpeqd_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=tpeqd   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5"};
+    char s_args[] = {"+proj=tpeqd   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {-27750.758831679042,  -222599.40369177726},
+        {-250434.93702403645,  -222655.93819326628},
+        {-27750.758831679042,  222599.40369177726},
+        {-250434.93702403645,  222655.93819326628},
+    };
+
+    XY s_fwd_expect[] = {
+        {-27845.882978485075,  -223362.43069526015},
+        {-251293.37876465076,  -223419.15898590829},
+        {-27845.882978485075,  223362.43069526015},
+        {-251293.37876465076,  223419.15898590829},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {-0.00089855554821257374,  1.2517966304145272},
+        {0.0008985555481998515,  1.2517966304145272},
+        {-0.00089855431859741167,  1.2482033692781642},
+        {0.00089855431859741167,  1.2482033692781642},
+    };
+
+    LP s_inv_expect[] = {
+        {-0.00089548606640108474,  1.2517904929571837},
+        {0.0008954860663883625,  1.2517904929571837},
+        {-0.000895484845182587,  1.248209506737604},
+        {0.00089548484516986475,  1.248209506737604},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_urm5.c b/src/PJ_urm5.c
index 9159df6..7a759b0 100644
--- a/src/PJ_urm5.c
+++ b/src/PJ_urm5.c
@@ -1,28 +1,81 @@
-#define PROJ_PARMS__ \
-	double m, rmn, q3, n;
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(urm5, "Urmaev V") "\n\tPCyl., Sph., no inv.\n\tn= q= alpha=";
-FORWARD(s_forward); /* spheroid */
-	double t;
-
-	t = lp.phi = aasin(P->ctx,P->n * sin(lp.phi));
-	xy.x = P->m * lp.lam * cos(lp.phi);
-	t *= t;
-	xy.y = lp.phi * (1. + t * P->q3) * P->rmn;
-	return xy;
+
+struct pj_opaque {
+    double m, rmn, q3, n;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0, 0.0};
+    struct pj_opaque *Q = P->opaque;
+    double t;
+
+    t = lp.phi = aasin (P->ctx, Q->n * sin (lp.phi));
+    xy.x = Q->m * lp.lam * cos (lp.phi);
+    t *= t;
+    xy.y = lp.phi * (1. + t * Q->q3) * Q->rmn;
+    return xy;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(urm5) {
+    double alpha, t;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->n  = pj_param(P->ctx, P->params, "dn").f;
+    Q->q3 = pj_param(P->ctx, P->params, "dq").f / 3.;
+    alpha = pj_param(P->ctx, P->params, "ralpha").f;
+    t = Q->n * sin (alpha);
+    Q->m = cos (alpha) / sqrt (1. - t * t);
+    Q->rmn = 1. / (Q->m * Q->n);
+
+    P->es = 0.;
+    P->inv = 0;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_urm5_selftest (void) {return 0;}
+#else
+int pj_urm5_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=urm5   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223393.6384339639,  111696.81878511712},
+        { 223393.6384339639, -111696.81878511712},
+        {-223393.6384339639,  111696.81878511712},
+        {-223393.6384339639, -111696.81878511712},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(urm5)
-	double alpha, t;
-
-	P->n = pj_param(P->ctx, P->params, "dn").f;
-	P->q3 = pj_param(P->ctx, P->params, "dq").f / 3.;
-	alpha = pj_param(P->ctx, P->params, "ralpha").f;
-	t = P->n * sin(alpha);
-	P->m = cos(alpha) / sqrt(1. - t * t);
-	P->rmn = 1. / (P->m * P->n);
-	P->es = 0.;
-	P->inv = 0;
-	P->fwd = s_forward;
-ENDENTRY(P)
+#endif
diff --git a/src/PJ_urmfps.c b/src/PJ_urmfps.c
index 5c5918a..2322aa0 100644
--- a/src/PJ_urmfps.c
+++ b/src/PJ_urmfps.c
@@ -1,40 +1,166 @@
-#define PROJ_PARMS__ \
-	double	n, C_y;
 #define PJ_LIB__
 #include	<projects.h>
+
 PROJ_HEAD(urmfps, "Urmaev Flat-Polar Sinusoidal") "\n\tPCyl, Sph.\n\tn=";
 PROJ_HEAD(wag1, "Wagner I (Kavraisky VI)") "\n\tPCyl, Sph.";
+
+struct pj_opaque {
+	double	n, C_y;
+};
+
 #define C_x 0.8773826753
 #define Cy 1.139753528477
-FORWARD(s_forward); /* sphere */
-	lp.phi = aasin(P->ctx,P->n * sin(lp.phi));
-	xy.x = C_x * lp.lam * cos(lp.phi);
-	xy.y = P->C_y * lp.phi;
-	return (xy);
-}
-INVERSE(s_inverse); /* sphere */
-	xy.y /= P->C_y;
-	lp.phi = aasin(P->ctx,sin(xy.y) / P->n);
-	lp.lam = xy.x / (C_x * cos(xy.y));
-	return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
-	static PJ *
-setup(PJ *P) {
-	P->C_y = Cy / P->n;
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0, 0.0};
+	lp.phi = aasin (P->ctx,P->opaque->n * sin (lp.phi));
+	xy.x = C_x * lp.lam * cos (lp.phi);
+	xy.y = P->opaque->C_y * lp.phi;
+	return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0, 0.0};
+	xy.y /= P->opaque->C_y;
+	lp.phi = aasin(P->ctx, sin (xy.y) / P->opaque->n);
+	lp.lam = xy.x / (C_x * cos (xy.y));
+	return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+static PJ *setup(PJ *P) {
+	P->opaque->C_y = Cy / P->opaque->n;
 	P->es = 0.;
 	P->inv = s_inverse;
 	P->fwd = s_forward;
 	return P;
 }
-ENTRY0(urmfps)
+
+
+PJ *PROJECTION(urmfps) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
 	if (pj_param(P->ctx, P->params, "tn").i) {
-		P->n = pj_param(P->ctx, P->params, "dn").f;
-		if (P->n <= 0. || P->n > 1.)
+		P->opaque->n = pj_param(P->ctx, P->params, "dn").f;
+		if (P->opaque->n <= 0. || P->opaque->n > 1.)
 			E_ERROR(-40)
 	} else
 		E_ERROR(-40)
-ENDENTRY(setup(P))
-ENTRY0(wag1)
-	P->n = 0.8660254037844386467637231707;
-ENDENTRY(setup(P))
+
+    return setup(P);
+}
+
+
+PJ *PROJECTION(wag1) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	P->opaque->n = 0.8660254037844386467637231707;
+    return setup(P);
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_urmfps_selftest (void) {return 0;}
+#else
+int pj_urmfps_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=urmfps   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 196001.70813419219,  127306.84332999329},
+        { 196001.70813419219, -127306.84332999329},
+        {-196001.70813419219,  127306.84332999329},
+        {-196001.70813419219, -127306.84332999329},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.002040720839642371,  0.00078547381740438178},
+        { 0.002040720839642371, -0.00078547381740438178},
+        {-0.002040720839642371,  0.00078547381740438178},
+        {-0.002040720839642371, -0.00078547381740438178},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+#endif
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_wag1_selftest (void) {return 0;}
+#else
+int pj_wag1_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=wag1   +a=6400000    +lat_1=0.5 +lat_2=2 +n=0.5"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 195986.78156115755,  127310.07506065986},
+        { 195986.78156115755, -127310.07506065986},
+        {-195986.78156115755,  127310.07506065986},
+        {-195986.78156115755, -127310.07506065986},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.002040720839738254,  0.00078547381739207999},
+        { 0.002040720839738254, -0.00078547381739207999},
+        {-0.002040720839738254,  0.00078547381739207999},
+        {-0.002040720839738254, -0.00078547381739207999},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+#endif
+
diff --git a/src/PJ_vandg.c b/src/PJ_vandg.c
index 784674b..e760375 100644
--- a/src/PJ_vandg.c
+++ b/src/PJ_vandg.c
@@ -1,78 +1,156 @@
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(vandg, "van der Grinten (I)") "\n\tMisc Sph";
-# define TOL		1.e-10
-# define THIRD		.33333333333333333333
-# define TWO_THRD	.66666666666666666666
-# define C2_27		.07407407407407407407
-# define PI4_3		4.18879020478639098458
-# define PISQ		9.86960440108935861869
-# define TPISQ		19.73920880217871723738
-# define HPISQ		4.93480220054467930934
-FORWARD(s_forward); /* spheroid */
-	double  al, al2, g, g2, p2;
-
-	p2 = fabs(lp.phi / HALFPI);
-	if ((p2 - TOL) > 1.) F_ERROR;
-	if (p2 > 1.)
-		p2 = 1.;
-	if (fabs(lp.phi) <= TOL) {
-		xy.x = lp.lam;
-		xy.y = 0.;
-	} else if (fabs(lp.lam) <= TOL || fabs(p2 - 1.) < TOL) {
-		xy.x = 0.;
-		xy.y = PI * tan(.5 * asin(p2));
-		if (lp.phi < 0.) xy.y = -xy.y;
-	} else {
-		al = .5 * fabs(PI / lp.lam - lp.lam / PI);
-		al2 = al * al;
-		g = sqrt(1. - p2 * p2);
-		g = g / (p2 + g - 1.);
-		g2 = g * g;
-		p2 = g * (2. / p2 - 1.);
-		p2 = p2 * p2;
-		xy.x = g - p2; g = p2 + al2;
-		xy.x = PI * (al * xy.x + sqrt(al2 * xy.x * xy.x - g * (g2 - p2))) / g;
-		if (lp.lam < 0.) xy.x = -xy.x;
-		xy.y = fabs(xy.x / PI);
-		xy.y = 1. - xy.y * (xy.y + 2. * al);
-		if (xy.y < -TOL) F_ERROR;
-		if (xy.y < 0.)	xy.y = 0.;
-		else		xy.y = sqrt(xy.y) * (lp.phi < 0. ? -PI : PI);
-	}
-	return (xy);
+
+# define TOL        1.e-10
+# define THIRD      .33333333333333333333
+# define TWO_THRD   .66666666666666666666
+# define C2_27      .07407407407407407407
+# define PI4_3      4.18879020478639098458
+# define PISQ       9.86960440108935861869
+# define TPISQ      19.73920880217871723738
+# define HPISQ      4.93480220054467930934
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double  al, al2, g, g2, p2;
+
+    p2 = fabs(lp.phi / M_HALFPI);
+    if ((p2 - TOL) > 1.) F_ERROR;
+    if (p2 > 1.)
+        p2 = 1.;
+    if (fabs(lp.phi) <= TOL) {
+        xy.x = lp.lam;
+        xy.y = 0.;
+    } else if (fabs(lp.lam) <= TOL || fabs(p2 - 1.) < TOL) {
+        xy.x = 0.;
+        xy.y = M_PI * tan(.5 * asin(p2));
+        if (lp.phi < 0.) xy.y = -xy.y;
+    } else {
+        al = .5 * fabs(M_PI / lp.lam - lp.lam / M_PI);
+        al2 = al * al;
+        g = sqrt(1. - p2 * p2);
+        g = g / (p2 + g - 1.);
+        g2 = g * g;
+        p2 = g * (2. / p2 - 1.);
+        p2 = p2 * p2;
+        xy.x = g - p2; g = p2 + al2;
+        xy.x = M_PI * (al * xy.x + sqrt(al2 * xy.x * xy.x - g * (g2 - p2))) / g;
+        if (lp.lam < 0.) xy.x = -xy.x;
+        xy.y = fabs(xy.x / M_PI);
+        xy.y = 1. - xy.y * (xy.y + 2. * al);
+        if (xy.y < -TOL) F_ERROR;
+        if (xy.y < 0.)
+            xy.y = 0.;
+        else
+            xy.y = sqrt(xy.y) * (lp.phi < 0. ? -M_PI : M_PI);
+    }
+
+    return xy;
 }
-INVERSE(s_inverse); /* spheroid */
-	double t, c0, c1, c2, c3, al, r2, r, m, d, ay, x2, y2;
-
-	x2 = xy.x * xy.x;
-	if ((ay = fabs(xy.y)) < TOL) {
-		lp.phi = 0.;
-		t = x2 * x2 + TPISQ * (x2 + HPISQ);
-		lp.lam = fabs(xy.x) <= TOL ? 0. :
-		   .5 * (x2 - PISQ + sqrt(t)) / xy.x;
-		return (lp);
-	}
-	y2 = xy.y * xy.y;
-	r = x2 + y2;	r2 = r * r;
-	c1 = - PI * ay * (r + PISQ);
-	c3 = r2 + TWOPI * (ay * r + PI * (y2 + PI * (ay + HALFPI)));
-	c2 = c1 + PISQ * (r - 3. *  y2);
-	c0 = PI * ay;
-	c2 /= c3;
-	al = c1 / c3 - THIRD * c2 * c2;
-	m = 2. * sqrt(-THIRD * al);
-	d = C2_27 * c2 * c2 * c2 + (c0 * c0 - THIRD * c2 * c1) / c3;
-	if (((t = fabs(d = 3. * d / (al * m))) - TOL) <= 1.) {
-		d = t > 1. ? (d > 0. ? 0. : PI) : acos(d);
-		lp.phi = PI * (m * cos(d * THIRD + PI4_3) - THIRD * c2);
-		if (xy.y < 0.) lp.phi = -lp.phi;
-		t = r2 + TPISQ * (x2 - y2 + HPISQ);
-		lp.lam = fabs(xy.x) <= TOL ? 0. :
-		   .5 * (r - PISQ + (t <= 0. ? 0. : sqrt(t))) / xy.x;
-	} else
-		I_ERROR;
-	return (lp);
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
+    double t, c0, c1, c2, c3, al, r2, r, m, d, ay, x2, y2;
+
+    x2 = xy.x * xy.x;
+    if ((ay = fabs(xy.y)) < TOL) {
+        lp.phi = 0.;
+        t = x2 * x2 + TPISQ * (x2 + HPISQ);
+        lp.lam = fabs(xy.x) <= TOL ? 0. :
+           .5 * (x2 - PISQ + sqrt(t)) / xy.x;
+        return (lp);
+    }
+    y2 = xy.y * xy.y;
+    r = x2 + y2;    r2 = r * r;
+    c1 = - M_PI * ay * (r + PISQ);
+    c3 = r2 + M_TWOPI * (ay * r + M_PI * (y2 + M_PI * (ay + M_HALFPI)));
+    c2 = c1 + PISQ * (r - 3. *  y2);
+    c0 = M_PI * ay;
+    c2 /= c3;
+    al = c1 / c3 - THIRD * c2 * c2;
+    m = 2. * sqrt(-THIRD * al);
+    d = C2_27 * c2 * c2 * c2 + (c0 * c0 - THIRD * c2 * c1) / c3;
+    if (((t = fabs(d = 3. * d / (al * m))) - TOL) <= 1.) {
+        d = t > 1. ? (d > 0. ? 0. : M_PI) : acos(d);
+        lp.phi = M_PI * (m * cos(d * THIRD + PI4_3) - THIRD * c2);
+        if (xy.y < 0.) lp.phi = -lp.phi;
+        t = r2 + TPISQ * (x2 - y2 + HPISQ);
+        lp.lam = fabs(xy.x) <= TOL ? 0. :
+           .5 * (r - PISQ + (t <= 0. ? 0. : sqrt(t))) / xy.x;
+    } else
+        I_ERROR;
+
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(vandg) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+PJ *PROJECTION(vandg) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_vandg_selftest (void) {return 0;}
+#else
+
+int pj_vandg_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=vandg   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223395.24954340671,  111704.59663367498},
+        { 223395.24954340671, -111704.59663367498},
+        {-223395.24954340671,  111704.59663367498},
+        {-223395.24954340671, -111704.59663367498},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.001790493715929761,  0.00089524655486993867},
+        { 0.001790493715929761, -0.00089524655486993867},
+        {-0.001790493715929761,  0.00089524655486993867},
+        {-0.001790493715929761, -0.00089524655486993867},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_vandg2.c b/src/PJ_vandg2.c
index 7bfa8f4..80da42c 100644
--- a/src/PJ_vandg2.c
+++ b/src/PJ_vandg2.c
@@ -1,45 +1,148 @@
-# define TOL	1e-10
-# define TWORPI	0.63661977236758134308
-#define PROJ_PARMS__ \
-	int	vdg3;
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    int vdg3;
+};
+
 PROJ_HEAD(vandg2, "van der Grinten II") "\n\tMisc Sph, no inv.";
 PROJ_HEAD(vandg3, "van der Grinten III") "\n\tMisc Sph, no inv.";
-FORWARD(s_forward); /* spheroid */
-	double x1, at, bt, ct;
-
-	bt = fabs(TWORPI * lp.phi);
-	if ((ct = 1. - bt * bt) < 0.)
-		ct = 0.;
-	else
-		ct = sqrt(ct);
-	if (fabs(lp.lam) < TOL) {
-		xy.x = 0.;
-		xy.y = PI * (lp.phi < 0. ? -bt : bt) / (1. + ct);
-	} else {
-		at = 0.5 * fabs(PI / lp.lam - lp.lam / PI);
-		if (P->vdg3) {
-			x1 = bt / (1. + ct);
-			xy.x = PI * (sqrt(at * at + 1. - x1 * x1) - at);
-			xy.y = PI * x1;
-		} else {
-			x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
-				(1. + at * at * bt * bt);
-			xy.x = PI * x1;
-			xy.y = PI * sqrt(1. - x1 * (x1 + 2. * at) + TOL);
-		}
-		if ( lp.lam < 0.) xy.x = -xy.x;
-		if ( lp.phi < 0.) xy.y = -xy.y;
-	}
-	return (xy);
+
+#define TOL    1e-10
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double x1, at, bt, ct;
+
+    bt = fabs(M_TWO_D_PI * lp.phi);
+    if ((ct = 1. - bt * bt) < 0.)
+        ct = 0.;
+    else
+        ct = sqrt(ct);
+    if (fabs(lp.lam) < TOL) {
+        xy.x = 0.;
+        xy.y = M_PI * (lp.phi < 0. ? -bt : bt) / (1. + ct);
+    } else {
+        at = 0.5 * fabs(M_PI / lp.lam - lp.lam / M_PI);
+        if (Q->vdg3) {
+            x1 = bt / (1. + ct);
+            xy.x = M_PI * (sqrt(at * at + 1. - x1 * x1) - at);
+            xy.y = M_PI * x1;
+        } else {
+            x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
+                (1. + at * at * bt * bt);
+            xy.x = M_PI * x1;
+            xy.y = M_PI * sqrt(1. - x1 * (x1 + 2. * at) + TOL);
+        }
+        if ( lp.lam < 0.) xy.x = -xy.x;
+        if ( lp.phi < 0.) xy.y = -xy.y;
+    }
+
+    return xy;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(vandg2) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->vdg3 = 0;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+PJ *PROJECTION(vandg3) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    Q->vdg3 = 1;
+    P->es = 0.;
+    P->fwd = s_forward;
+
+    return P;
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(vandg2)
-	P->vdg3 = 0;
-	P->inv = 0; P->fwd = s_forward;
-ENDENTRY(P)
-ENTRY0(vandg3)
-	P->vdg3 = 1;
-	P->es = 0.; P->fwd = s_forward;
-ENDENTRY(P)
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_vandg2_selftest (void) {return 0;}
+#else
+
+int pj_vandg2_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=vandg2   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223395.24785043663,  111718.49103722633},
+        { 223395.24785043663, -111718.49103722633},
+        {-223395.24785043663,  111718.49103722633},
+        {-223395.24785043663, -111718.49103722633},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_vandg3_selftest (void) {return 0;}
+#else
+
+int pj_vandg3_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=vandg3   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223395.24955283134,  111704.51990442065},
+        { 223395.24955283134, -111704.51990442065},
+        {-223395.24955283134,  111704.51990442065},
+        {-223395.24955283134, -111704.51990442065},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_vandg4.c b/src/PJ_vandg4.c
index 0229042..4d4032b 100644
--- a/src/PJ_vandg4.c
+++ b/src/PJ_vandg4.c
@@ -1,42 +1,97 @@
-#define PJ_LIB__
-#include	<projects.h>
-PROJ_HEAD(vandg4, "van der Grinten IV") "\n\tMisc Sph, no inv.";
-#define TOL	1e-10
-#define TWORPI	0.63661977236758134308
-FORWARD(s_forward); /* spheroid */
-	double x1, t, bt, ct, ft, bt2, ct2, dt, dt2;
-	(void) P;
-
-	if (fabs(lp.phi) < TOL) {
-		xy.x = lp.lam;
-		xy.y = 0.;
-	} else if (fabs(lp.lam) < TOL || fabs(fabs(lp.phi) - HALFPI) < TOL) {
-		xy.x = 0.;
-		xy.y = lp.phi;
-	} else {
-		bt = fabs(TWORPI * lp.phi);
-		bt2 = bt * bt;
-		ct = 0.5 * (bt * (8. - bt * (2. + bt2)) - 5.)
-			/ (bt2 * (bt - 1.));
-		ct2 = ct * ct;
-		dt = TWORPI * lp.lam;
-		dt = dt + 1. / dt;
-		dt = sqrt(dt * dt - 4.);
-		if ((fabs(lp.lam) - HALFPI) < 0.) dt = -dt;
-		dt2 = dt * dt;
-		x1 = bt + ct; x1 *= x1;
-		t = bt + 3.*ct;
-		ft = x1 * (bt2 + ct2 * dt2 - 1.) + (1.-bt2) * (
-			bt2 * (t * t + 4. * ct2) +
-			ct2 * (12. * bt * ct + 4. * ct2) );
-		x1 = (dt*(x1 + ct2 - 1.) + 2.*sqrt(ft)) /
-			(4.* x1 + dt2);
-		xy.x = HALFPI * x1;
-		xy.y = HALFPI * sqrt(1. + dt * fabs(x1) - x1 * x1);
-		if (lp.lam < 0.) xy.x = -xy.x;
-		if (lp.phi < 0.) xy.y = -xy.y;
-	}
-	return (xy);
-}
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(vandg4) P->es = 0.; P->fwd = s_forward; ENDENTRY(P)
+#define PJ_LIB__
+#include <projects.h>
+
+PROJ_HEAD(vandg4, "van der Grinten IV") "\n\tMisc Sph, no inv.";
+
+#define TOL 1e-10
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+    double x1, t, bt, ct, ft, bt2, ct2, dt, dt2;
+    (void) P;
+
+    if (fabs(lp.phi) < TOL) {
+        xy.x = lp.lam;
+        xy.y = 0.;
+    } else if (fabs(lp.lam) < TOL || fabs(fabs(lp.phi) - M_HALFPI) < TOL) {
+        xy.x = 0.;
+        xy.y = lp.phi;
+    } else {
+        bt = fabs(M_TWO_D_PI * lp.phi);
+        bt2 = bt * bt;
+        ct = 0.5 * (bt * (8. - bt * (2. + bt2)) - 5.)
+            / (bt2 * (bt - 1.));
+        ct2 = ct * ct;
+        dt = M_TWO_D_PI * lp.lam;
+        dt = dt + 1. / dt;
+        dt = sqrt(dt * dt - 4.);
+        if ((fabs(lp.lam) - M_HALFPI) < 0.) dt = -dt;
+        dt2 = dt * dt;
+        x1 = bt + ct; x1 *= x1;
+        t = bt + 3.*ct;
+        ft = x1 * (bt2 + ct2 * dt2 - 1.) + (1.-bt2) * (
+            bt2 * (t * t + 4. * ct2) +
+            ct2 * (12. * bt * ct + 4. * ct2) );
+        x1 = (dt*(x1 + ct2 - 1.) + 2.*sqrt(ft)) /
+            (4.* x1 + dt2);
+        xy.x = M_HALFPI * x1;
+        xy.y = M_HALFPI * sqrt(1. + dt * fabs(x1) - x1 * x1);
+        if (lp.lam < 0.) xy.x = -xy.x;
+        if (lp.phi < 0.) xy.y = -xy.y;
+    }
+    return xy;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(vandg4) {
+    P->es = 0.;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_vandg4_selftest (void) {return 0;}
+#else
+
+int pj_vandg4_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=vandg4   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223374.57729435508,  111701.19548415358
},
+        { 223374.57729435508, -111701.19548415358
},
+        {-223374.57729435508,  111701.19548415358
},
+        {-223374.57729435508, -111701.19548415358
},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+
+
+#endif
diff --git a/src/PJ_wag2.c b/src/PJ_wag2.c
index f4942bb..b70dcd4 100644
--- a/src/PJ_wag2.c
+++ b/src/PJ_wag2.c
@@ -5,17 +5,84 @@ PROJ_HEAD(wag2, "Wagner II") "\n\tPCyl., Sph.";
 #define C_y 1.38725
 #define C_p1 0.88022
 #define C_p2 0.88550
-FORWARD(s_forward); /* spheroid */
-	lp.phi = aasin(P->ctx,C_p1 * sin(C_p2 * lp.phi));
-	xy.x = C_x * lp.lam * cos(lp.phi);
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+	lp.phi = aasin (P->ctx,C_p1 * sin (C_p2 * lp.phi));
+	xy.x = C_x * lp.lam * cos (lp.phi);
 	xy.y = C_y * lp.phi;
 	return (xy);
 }
-INVERSE(s_inverse); /* spheroid */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
 	lp.phi = xy.y / C_y;
 	lp.lam = xy.x / (C_x * cos(lp.phi));
-	lp.phi = aasin(P->ctx,sin(lp.phi) / C_p1) / C_p2;
+	lp.phi = aasin (P->ctx,sin(lp.phi) / C_p1) / C_p2;
 	return (lp);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(wag2) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(wag2) {
+    P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_wag2_selftest (void) {return 0;}
+#else
+
+int pj_wag2_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=wag2   +a=6400000  +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 206589.88809996162,   120778.04035754716},
+        { 206589.88809996162,  -120778.04035754716},
+        {-206589.88809996162,   120778.04035754716},
+        {-206589.88809996162,  -120778.04035754716},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0019360240367390709,   0.00082795765763814082},
+        { 0.0019360240367390709,  -0.00082795765763814082},
+        {-0.0019360240367390709,   0.00082795765763814082},
+        {-0.0019360240367390709,  -0.00082795765763814082},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_wag3.c b/src/PJ_wag3.c
index 482e389..0539f4a 100644
--- a/src/PJ_wag3.c
+++ b/src/PJ_wag3.c
@@ -1,24 +1,101 @@
-#define PROJ_PARMS__ \
-	double	C_x;
 #define PJ_LIB__
 # include	<projects.h>
 PROJ_HEAD(wag3, "Wagner III") "\n\tPCyl., Sph.\n\tlat_ts=";
 #define TWOTHIRD 0.6666666666666666666667
-FORWARD(s_forward); /* spheroid */
-	xy.x = P->C_x * lp.lam * cos(TWOTHIRD * lp.phi);
+
+struct pj_opaque {
+	double	C_x;
+};
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+	xy.x = P->opaque->C_x * lp.lam * cos(TWOTHIRD * lp.phi);
 	xy.y = lp.phi;
-	return (xy);
+	return xy;
 }
+
+
+#if 0
 INVERSE(s_inverse); /* spheroid */
+#endif
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
 	lp.phi = xy.y;
-	lp.lam = xy.x / (P->C_x * cos(TWOTHIRD * lp.phi));
-	return (lp);
+	lp.lam = xy.x / (P->opaque->C_x * cos(TWOTHIRD * lp.phi));
+	return lp;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(wag3)
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(wag3) {
 	double ts;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	ts = pj_param (P->ctx, P->params, "rlat_ts").f;
+	P->opaque->C_x = cos (ts) / cos (2.*ts/3.);
+	P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_wag3_selftest (void) {return 0;}
+#else
+
+int pj_wag3_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=wag3   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        {223387.02171816575,  111701.07212763709},
+        {223387.02171816575,  -111701.07212763709},
+        {-223387.02171816575,  111701.07212763709},
+        {-223387.02171816575,  -111701.07212763709},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        {0.001790493109880963,  0.00089524655489191132},
+        {0.001790493109880963,  -0.00089524655489191132},
+        {-0.001790493109880963,  0.00089524655489191132},
+        {-0.001790493109880963,  -0.00089524655489191132},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
 
-	ts = pj_param(P->ctx, P->params, "rlat_ts").f;
-	P->C_x = cos(ts) / cos(2.*ts/3.);
-	P->es = 0.; P->inv = s_inverse; P->fwd = s_forward;
-ENDENTRY(P)
+#endif
diff --git a/src/PJ_wag7.c b/src/PJ_wag7.c
index db29ffb..847566d 100644
--- a/src/PJ_wag7.c
+++ b/src/PJ_wag7.c
@@ -1,15 +1,67 @@
 #define PJ_LIB__
 #include	<projects.h>
+
 PROJ_HEAD(wag7, "Wagner VII") "\n\tMisc Sph, no inv.";
-FORWARD(s_forward); /* sphere */
+
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0, 0.0};
 	double theta, ct, D;
-	(void) P;
 
-	theta = asin(xy.y = 0.90630778703664996 * sin(lp.phi));
-	xy.x = 2.66723 * (ct = cos(theta)) * sin(lp.lam /= 3.);
-	xy.y *= 1.24104 * (D = 1/(sqrt(0.5 * (1 + ct * cos(lp.lam)))));
+	(void) P; /* Shut up compiler warnnings about unused P */
+
+	theta = asin (xy.y = 0.90630778703664996 * sin(lp.phi));
+	xy.x  = 2.66723 * (ct = cos (theta)) * sin (lp.lam /= 3.);
+	xy.y *= 1.24104 * (D = 1/(sqrt (0.5 * (1 + ct * cos (lp.lam)))));
 	xy.x *= D;
 	return (xy);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(wag7) P->fwd = s_forward; P->inv = 0; P->es = 0.; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+
+PJ *PROJECTION(wag7) {
+    P->fwd = s_forward;
+    P->inv = 0;
+    P->es = 0.;
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_wag7_selftest (void) {return 0;}
+#else
+
+int pj_wag7_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=wag7   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 198601.87695731167,  125637.0457141714},
+        { 198601.87695731167, -125637.0457141714},
+        {-198601.87695731167,  125637.0457141714},
+        {-198601.87695731167, -125637.0457141714},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
+}
+#endif
diff --git a/src/PJ_wink1.c b/src/PJ_wink1.c
index dfb455e..f9d127c 100644
--- a/src/PJ_wink1.c
+++ b/src/PJ_wink1.c
@@ -1,20 +1,100 @@
-#define PROJ_PARMS__ \
-	double	cosphi1;
 #define PJ_LIB__
-# include	<projects.h>
+#include <projects.h>
 PROJ_HEAD(wink1, "Winkel I") "\n\tPCyl., Sph.\n\tlat_ts=";
-FORWARD(s_forward); /* spheroid */
-	xy.x = .5 * lp.lam * (P->cosphi1 + cos(lp.phi));
+
+
+struct pj_opaque {
+	double	cosphi1;
+};
+
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0,0.0};
+	xy.x = .5 * lp.lam * (P->opaque->cosphi1 + cos(lp.phi));
 	xy.y = lp.phi;
 	return (xy);
 }
-INVERSE(s_inverse); /* spheroid */
+
+
+static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
+    LP lp = {0.0,0.0};
 	lp.phi = xy.y;
-	lp.lam = 2. * xy.x / (P->cosphi1 + cos(lp.phi));
+	lp.lam = 2. * xy.x / (P->opaque->cosphi1 + cos(lp.phi));
 	return (lp);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(wink1)
-	P->cosphi1 = cos(pj_param(P->ctx, P->params, "rlat_ts").f);
-	P->es = 0.; P->inv = s_inverse; P->fwd = s_forward;
-ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(wink1) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	P->opaque->cosphi1 = cos (pj_param(P->ctx, P->params, "rlat_ts").f);
+	P->es = 0.;
+    P->inv = s_inverse;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_wink1_selftest (void) {return 0;}
+#else
+
+int pj_wink1_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=wink1   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223385.13164095284,  111701.07212763709},
+        { 223385.13164095284,  -111701.07212763709},
+        {-223385.13164095284,  111701.07212763709},
+        {-223385.13164095284,  -111701.07212763709},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP s_inv_expect[] = {
+        { 0.0017904931098931057,  0.00089524655489191132},
+        { 0.0017904931098931057, -0.00089524655489191132},
+        {-0.0017904931098931057,  0.00089524655489191132},
+        {-0.0017904931098931057, -0.00089524655489191132},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif
diff --git a/src/PJ_wink2.c b/src/PJ_wink2.c
index 388c790..5f2b44a 100644
--- a/src/PJ_wink2.c
+++ b/src/PJ_wink2.c
@@ -1,34 +1,92 @@
-#define PROJ_PARMS__ \
-	double	cosphi1;
 #define PJ_LIB__
 # include	<projects.h>
+
 PROJ_HEAD(wink2, "Winkel II") "\n\tPCyl., Sph., no inv.\n\tlat_1=";
+
+struct pj_opaque { double	cosphi1; };
+
 #define MAX_ITER    10
 #define LOOP_TOL    1e-7
-#define TWO_D_PI 0.636619772367581343
-FORWARD(s_forward); /* spheroid */
+
+
+static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
+    XY xy = {0.0, 0.0};
 	double k, V;
 	int i;
 
-	xy.y = lp.phi * TWO_D_PI;
-	k = PI * sin(lp.phi);
+	xy.y = lp.phi * M_TWO_D_PI;
+	k = M_PI * sin (lp.phi);
 	lp.phi *= 1.8;
 	for (i = MAX_ITER; i ; --i) {
-		lp.phi -= V = (lp.phi + sin(lp.phi) - k) /
-			(1. + cos(lp.phi));
-		if (fabs(V) < LOOP_TOL)
+		lp.phi -= V = (lp.phi + sin (lp.phi) - k) /
+			(1. + cos (lp.phi));
+		if (fabs (V) < LOOP_TOL)
 			break;
 	}
 	if (!i)
-		lp.phi = (lp.phi < 0.) ? -HALFPI : HALFPI;
+		lp.phi = (lp.phi < 0.) ? -M_HALFPI : M_HALFPI;
 	else
 		lp.phi *= 0.5;
-	xy.x = 0.5 * lp.lam * (cos(lp.phi) + P->cosphi1);
-	xy.y = FORTPI * (sin(lp.phi) + xy.y);
-	return (xy);
+	xy.x = 0.5 * lp.lam * (cos (lp.phi) + P->opaque->cosphi1);
+	xy.y = M_FORTPI * (sin (lp.phi) + xy.y);
+	return xy;
+}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+
+PJ *PROJECTION(wink2) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	P->opaque->cosphi1 = cos(pj_param(P->ctx, P->params, "rlat_1").f);
+	P->es  = 0.;
+    P->inv = 0;
+    P->fwd = s_forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_wink2_selftest (void) {return 0;}
+#else
+
+int pj_wink2_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char s_args[] = {"+proj=wink2   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY s_fwd_expect[] = {
+        { 223387.39643378611,  124752.03279744535},
+        { 223387.39643378611, -124752.03279744535},
+        {-223387.39643378611,  124752.03279744535},
+        {-223387.39643378611, -124752.03279744535},
+    };
+
+    return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
 }
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(wink2)
-	P->cosphi1 = cos(pj_param(P->ctx, P->params, "rlat_1").f);
-	P->es = 0.; P->inv = 0; P->fwd = s_forward;
-ENDENTRY(P)
+#endif
diff --git a/src/aasincos.c b/src/aasincos.c
index 6f39478..7cb6bd8 100644
--- a/src/aasincos.c
+++ b/src/aasincos.c
@@ -11,7 +11,7 @@ aasin(projCtx ctx,double v) {
 	if ((av = fabs(v)) >= 1.) {
 		if (av > ONE_TOL)
                         pj_ctx_set_errno( ctx, -19 );
-		return (v < 0. ? -HALFPI : HALFPI);
+		return (v < 0. ? -M_HALFPI : M_HALFPI);
 	}
 	return asin(v);
 }
@@ -23,7 +23,7 @@ aacos(projCtx ctx, double v) {
 	if ((av = fabs(v)) >= 1.) {
 		if (av > ONE_TOL)
                         pj_ctx_set_errno( ctx, -19 );
-		return (v < 0. ? PI : 0.);
+		return (v < 0. ? M_PI : 0.);
 	}
 	return acos(v);
 }
diff --git a/src/bchgen.c b/src/bchgen.c
index fe2ffe6..b441450 100644
--- a/src/bchgen.c
+++ b/src/bchgen.c
@@ -9,9 +9,9 @@ bchgen(projUV a, projUV b, int nu, int nv, projUV **f, projUV(*func)(projUV)) {
 	bma.u = 0.5 * (b.u - a.u); bma.v = 0.5 * (b.v - a.v);
 	bpa.u = 0.5 * (b.u + a.u); bpa.v = 0.5 * (b.v + a.v);
 	for ( i = 0; i < nu; ++i) {
-		arg.u = cos(PI * (i + 0.5) / nu) * bma.u + bpa.u;
+		arg.u = cos(M_PI * (i + 0.5) / nu) * bma.u + bpa.u;
 		for ( j = 0; j < nv; ++j) {
-			arg.v = cos(PI * (j + 0.5) / nv) * bma.v + bpa.v;
+			arg.v = cos(M_PI * (j + 0.5) / nv) * bma.v + bpa.v;
 			f[i][j] = (*func)(arg);
 			if ((f[i][j]).u == HUGE_VAL)
 				return(1);
@@ -23,7 +23,7 @@ bchgen(projUV a, projUV b, int nu, int nv, projUV **f, projUV(*func)(projUV)) {
 		for ( i = 0; i < nu; ++i) {
 			arg.u = arg.v = 0.;
 			for (k = 0; k < nu; ++k) {
-				d = cos(PI * i * (k + .5) / nu);
+				d = cos(M_PI * i * (k + .5) / nu);
 				arg.u += f[k][j].u * d;
 				arg.v += f[k][j].v * d;
 			}
@@ -42,7 +42,7 @@ bchgen(projUV a, projUV b, int nu, int nv, projUV **f, projUV(*func)(projUV)) {
 		for (j = 0; j < nv; ++j) {
 			arg.u = arg.v = 0.;
 			for (k = 0; k < nv; ++k) {
-				d = cos(PI * j * (k + .5) / nv);
+				d = cos(M_PI * j * (k + .5) / nv);
 				arg.u += t[k].u * d;
 				arg.v += t[k].v * d;
 			}
diff --git a/src/dmstor.c b/src/dmstor.c
index 62c06f3..9665d5a 100644
--- a/src/dmstor.c
+++ b/src/dmstor.c
@@ -11,7 +11,7 @@ static double proj_strtod(char *nptr, char **endptr);
 *sym = "NnEeSsWw";
 	static const double
 vm[] = {
-	.0174532925199433,
+	DEG_TO_RAD,
 	.0002908882086657216,
 	.0000048481368110953599
 };
diff --git a/src/gen_cheb.c b/src/gen_cheb.c
index f06a744..b7c41d8 100644
--- a/src/gen_cheb.c
+++ b/src/gen_cheb.c
@@ -18,10 +18,10 @@ gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, int iargc, char **
 	double (*input)(const char *, char **);
 
 	input = inverse ? strtod : dmstor;
-	if (*s) low.u = input(s, &s); else ++errin;
-	if (*s == ',') upp.u = input(s+1, &s); else ++errin;
-	if (*s == ',') low.v = input(s+1, &s); else ++errin;
-	if (*s == ',') upp.v = input(s+1, &s); else ++errin;
+	if (*s) low.u = input(s, &s); else { low.u = 0; ++errin; }
+	if (*s == ',') upp.u = input(s+1, &s); else { upp.u = 0; ++errin; }
+	if (*s == ',') low.v = input(s+1, &s); else { low.v = 0; ++errin; }
+	if (*s == ',') upp.v = input(s+1, &s); else { upp.v = 0; ++errin; }
 	if (errin)
 		emess(16,"null or absent -T parameters");
 	if (*s == ',') if (*++s != ',') res = strtol(s, &s, 10);
@@ -48,7 +48,7 @@ gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, int iargc, char **
 	if (low.u == upp.u || low.v >= upp.v)
 		emess(16,"approx. argument range error");
 	if (low.u > upp.u)
-		low.u -= TWOPI;
+		low.u -= M_TWOPI;
 	if (NU < 2 || NV < 2)
 		emess(16,"approx. work dimensions (%d %d) too small",NU,NV);
 	if (!(F = mk_cheby(low, upp, pow(10., (double)res)*.5, &resid, proj,
diff --git a/src/geod.c b/src/geod.c
index c429c51..12513cb 100644
--- a/src/geod.c
+++ b/src/geod.c
@@ -87,8 +87,8 @@ process(FILE *fid) {
 		}
 		if (!*s && (s > line)) --s; /* assumed we gobbled \n */
 		if (pos_azi) {
-			if (al12 < 0.) al12 += TWOPI;
-			if (al21 < 0.) al21 += TWOPI;
+			if (al12 < 0.) al12 += M_TWOPI;
+			if (al21 < 0.) al21 += M_TWOPI;
 		}
 		if (fullout) {
 			printLL(phi1, lam1); TAB;
diff --git a/src/geod_interface.c b/src/geod_interface.c
index 63b16b1..a30377a 100644
--- a/src/geod_interface.c
+++ b/src/geod_interface.c
@@ -1,20 +1,14 @@
 #include "projects.h"
 #include "geod_interface.h"
 
-/* DEG_IN is a crock to work around the problem that dmstor.c uses the wrong
- * value for pi/180 (namely .0174532925199433 which is an inaccurately
- * truncated version of DEG_TO_RAD).
- */
-#define DEG_IN .0174532925199433
-#define DEG_OUT DEG_TO_RAD;
-
 void geod_ini(void) {
   geod_init(&GlobalGeodesic, geod_a, geod_f);
 }
 
 void geod_pre(void) {
   double
-    lat1 = phi1 / DEG_IN, lon1 = lam1 / DEG_IN, azi1 = al12 / DEG_IN;
+    lat1 = phi1 / DEG_TO_RAD, lon1 = lam1 / DEG_TO_RAD,
+    azi1 = al12 / DEG_TO_RAD;
   geod_lineinit(&GlobalGeodesicLine, &GlobalGeodesic, lat1, lon1, azi1, 0U);
 }
 
@@ -23,17 +17,17 @@ void geod_for(void) {
     s12 = geod_S, lat2, lon2, azi2;
   geod_position(&GlobalGeodesicLine, s12, &lat2, &lon2, &azi2);
   azi2 += azi2 >= 0 ? -180 : 180; /* Compute back azimuth */
-  phi2 = lat2 * DEG_OUT;
-  lam2 = lon2 * DEG_OUT;
-  al21 = azi2 * DEG_OUT;
+  phi2 = lat2 * DEG_TO_RAD;
+  lam2 = lon2 * DEG_TO_RAD;
+  al21 = azi2 * DEG_TO_RAD;
 }
 
 void geod_inv(void) {
   double
-    lat1 = phi1 / DEG_IN, lon1 = lam1 / DEG_IN,
-    lat2 = phi2 / DEG_IN, lon2 = lam2 / DEG_IN,
+    lat1 = phi1 / DEG_TO_RAD, lon1 = lam1 / DEG_TO_RAD,
+    lat2 = phi2 / DEG_TO_RAD, lon2 = lam2 / DEG_TO_RAD,
     azi1, azi2, s12;
   geod_inverse(&GlobalGeodesic, lat1, lon1, lat2, lon2, &s12, &azi1, &azi2);
   azi2 += azi2 >= 0 ? -180 : 180; /* Compute back azimuth */
-  al12 = azi1 * DEG_OUT; al21 = azi2 * DEG_OUT; geod_S = s12;
+  al12 = azi1 * DEG_TO_RAD; al21 = azi2 * DEG_TO_RAD; geod_S = s12;
 }
diff --git a/src/geod_set.c b/src/geod_set.c
index e687c51..f61ab43 100644
--- a/src/geod_set.c
+++ b/src/geod_set.c
@@ -54,7 +54,7 @@ geod_set(int argc, char **argv) {
 			if (!(del_alpha = pj_param(NULL,start, "rdel_A").f))
 				emess(1,"del azimuth == 0");
 		} else if ((del_S = fabs(pj_param(NULL,start, "ddel_S").f)) != 0.) {
-			n_S = geod_S / del_S + .5;
+			n_S = (int)(geod_S / del_S + .5);
 		} else if ((n_S = pj_param(NULL,start, "in_S").i) <= 0)
 			emess(1,"no interval divisor selected");
 	}
diff --git a/src/geodesic.c b/src/geodesic.c
index 2dee45e..e897e89 100644
--- a/src/geodesic.c
+++ b/src/geodesic.c
@@ -14,11 +14,11 @@
  *   Algorithms for geodesics,
  *   J. Geodesy <b>87</b>, 43--55 (2013);
  *   https://dx.doi.org/10.1007/s00190-012-0578-z
- *   Addenda: http://geographiclib.sf.net/geod-addenda.html
+ *   Addenda: http://geographiclib.sourceforge.net/geod-addenda.html
  *
  * See the comments in geodesic.h for documentation.
  *
- * Copyright (c) Charles Karney (2012-2015) <charles at karney.com> and licensed
+ * Copyright (c) Charles Karney (2012-2016) <charles at karney.com> and licensed
  * under the MIT/X11 License.  For more information, see
  * http://geographiclib.sourceforge.net/
  */
@@ -119,6 +119,10 @@ static real atanhx(real x) {
   return x < 0 ? -y : y;
 }
 
+static real copysignx(real x, real y) {
+  return fabs(x) * (y < 0 || (y == 0 && 1/y < 0) ? -1 : 1);
+}
+
 static real hypotx(real x, real y)
 { return sqrt(x * x + y * y); }
 
@@ -133,7 +137,7 @@ static real sumx(real u, real v, real* t) {
   volatile real vpp = s - up;
   up -= u;
   vpp -= v;
-  *t = -(up + vpp);
+  if (t) *t = -(up + vpp);
   /* error-free sum:
    * u + v =       s      + t
    *       = round(u + v) + t */
@@ -146,11 +150,12 @@ static real polyval(int N, const real p[], real x) {
   return y;
 }
 
-static real minx(real x, real y)
-{ return x < y ? x : y; }
+/* mimic C++ std::min and std::max */
+static real minx(real a, real b)
+{ return (b < a) ? b : a; }
 
-static real maxx(real x, real y)
-{ return x > y ? x : y; }
+static real maxx(real a, real b)
+{ return (a < b) ? b : a; }
 
 static void swapx(real* x, real* y)
 { real t = *x; *x = *y; *y = t; }
@@ -169,7 +174,7 @@ static real AngNormalize(real x) {
 static real LatFix(real x)
 { return fabs(x) > 90 ? NaN : x; }
 
-static real AngDiff(real x, real y) {
+static real AngDiff(real x, real y, real* e) {
   real t, d = - AngNormalize(sumx(AngNormalize(x), AngNormalize(-y), &t));
   /* Here y - x = d - t (mod 360), exactly, where d is in (-180,180] and
    * abs(t) <= eps (eps = 2^-45 for doubles).  The only case where the
@@ -177,15 +182,17 @@ static real AngDiff(real x, real y) {
    * and t < 0.  The case, d = -180 + eps, t = eps, can't happen, since
    * sum would have returned the exact result in such a case (i.e., given t
    * = 0). */
-  return (d == 180 && t < 0 ? -180 : d) - t;
+  return sumx(d == 180 && t < 0 ? -180 : d, -t, e);
 }
 
 static real AngRound(real x) {
   const real z = 1/(real)(16);
-  volatile real y = fabs(x);
+  volatile real y;
+  if (x == 0) return 0;
+  y = fabs(x);
   /* The compiler mustn't "simplify" z - (z - y) to y */
   y = y < z ? z - (z - y) : y;
-  return x < 0 ? 0 - y : y;
+  return x < 0 ? -y : y;
 }
 
 static void sincosdx(real x, real* sinx, real* cosx) {
@@ -249,7 +256,7 @@ static real Astroid(real x, real y);
 static real InverseStart(const struct geod_geodesic* g,
                          real sbet1, real cbet1, real dn1,
                          real sbet2, real cbet2, real dn2,
-                         real lam12,
+                         real lam12, real slam12, real clam12,
                          real* psalp1, real* pcalp1,
                          /* Only updated if return val >= 0 */
                          real* psalp2, real* pcalp2,
@@ -261,11 +268,13 @@ static real Lambda12(const struct geod_geodesic* g,
                      real sbet1, real cbet1, real dn1,
                      real sbet2, real cbet2, real dn2,
                      real salp1, real calp1,
+                     real slam120, real clam120,
                      real* psalp2, real* pcalp2,
                      real* psig12,
                      real* pssig1, real* pcsig1,
                      real* pssig2, real* pcsig2,
-                     real* peps, real* pdomg12,
+                     real* peps,
+                     real* psomg12, real* pcomg12,
                      boolx diffp, real* pdlam12,
                      /* Scratch area of the right size */
                      real Ca[]);
@@ -288,7 +297,7 @@ static void accneg(real s[]);
 void geod_init(struct geod_geodesic* g, real a, real f) {
   if (!init) Init();
   g->a = a;
-  g->f = f <= 1 ? f : 1/f;
+  g->f = f;
   g->f1 = 1 - g->f;
   g->e2 = g->f * (2 - g->f);
   g->ep2 = g->e2 / sq(g->f1);   /* e2 / (1 - e2) */
@@ -315,9 +324,11 @@ void geod_init(struct geod_geodesic* g, real a, real f) {
   C4coeff(g);
 }
 
-void geod_lineinit(struct geod_geodesicline* l,
-                   const struct geod_geodesic* g,
-                   real lat1, real lon1, real azi1, unsigned caps) {
+static void geod_lineinit_int(struct geod_geodesicline* l,
+                              const struct geod_geodesic* g,
+                              real lat1, real lon1,
+                              real azi1, real salp1, real calp1,
+                              unsigned caps) {
   real cbet1, sbet1, eps;
   l->a = g->a;
   l->f = g->f;
@@ -331,9 +342,9 @@ void geod_lineinit(struct geod_geodesicline* l,
 
   l->lat1 = LatFix(lat1);
   l->lon1 = lon1;
-  l->azi1 = AngNormalize(azi1);
-  /* Guard against underflow in salp0 */
-  sincosdx(AngRound(l->azi1), &l->salp1, &l->calp1);
+  l->azi1 = azi1;
+  l->salp1 = salp1;
+  l->calp1 = calp1;
 
   sincosdx(AngRound(l->lat1), &sbet1, &cbet1); sbet1 *= l->f1;
   /* Ensure cbet1 = +epsilon at poles */
@@ -396,6 +407,34 @@ void geod_lineinit(struct geod_geodesicline* l,
     l->A4 = sq(l->a) * l->calp0 * l->salp0 * g->e2;
     l->B41 = SinCosSeries(FALSE, l->ssig1, l->csig1, l->C4a, nC4);
   }
+
+  l->a13 = l->s13 = NaN;
+}
+
+void geod_lineinit(struct geod_geodesicline* l,
+                   const struct geod_geodesic* g,
+                   real lat1, real lon1, real azi1, unsigned caps) {
+  real salp1, calp1;
+  azi1 = AngNormalize(azi1);
+  /* Guard against underflow in salp0 */
+  sincosdx(AngRound(azi1), &salp1, &calp1);
+  geod_lineinit_int(l, g, lat1, lon1, azi1, salp1, calp1, caps);
+}
+
+void geod_gendirectline(struct geod_geodesicline* l,
+                        const struct geod_geodesic* g,
+                        real lat1, real lon1, real azi1,
+                        unsigned flags, real a12_s12,
+                        unsigned caps) {
+  geod_lineinit(l, g, lat1, lon1, azi1, caps);
+  geod_gensetdistance(l, flags, a12_s12);
+}
+
+void geod_directline(struct geod_geodesicline* l,
+                        const struct geod_geodesic* g,
+                        real lat1, real lon1, real azi1,
+                        real s12, unsigned caps) {
+  geod_gendirectline(l, g, lat1, lon1, azi1, GEOD_NOFLAGS, s12, caps);
 }
 
 real geod_genposition(const struct geod_geodesicline* l,
@@ -421,7 +460,7 @@ real geod_genposition(const struct geod_geodesicline* l,
 
   outmask &= l->caps & OUT_ALL;
   if (!( TRUE /*Init()*/ &&
-         (flags & GEOD_ARCMODE || (l->caps & GEOD_DISTANCE_IN & OUT_ALL)) ))
+         (flags & GEOD_ARCMODE || (l->caps & (GEOD_DISTANCE_IN & OUT_ALL))) ))
     /* Uninitialized or impossible distance calculation requested */
     return NaN;
 
@@ -464,10 +503,9 @@ real geod_genposition(const struct geod_geodesicline* l,
        *      1/20   5376 146e3  10e3
        *      1/10  829e3  22e6 1.5e6
        *      1/5   157e6 3.8e9 280e6 */
-      real
-        ssig2 = l->ssig1 * csig12 + l->csig1 * ssig12,
-        csig2 = l->csig1 * csig12 - l->ssig1 * ssig12,
-        serr;
+      real serr;
+      ssig2 = l->ssig1 * csig12 + l->csig1 * ssig12;
+      csig2 = l->csig1 * csig12 - l->ssig1 * ssig12;
       B12 = SinCosSeries(TRUE, ssig2, csig2, l->C1a, nC1);
       serr = (1 + l->A1m1) * (sig12 + (B12 - l->B11)) - s12_a12 / l->b;
       sig12 = sig12 - serr / sqrt(1 + l->k2 * sq(ssig2));
@@ -499,7 +537,7 @@ real geod_genposition(const struct geod_geodesicline* l,
     s12 = flags & GEOD_ARCMODE ? l->b * ((1 + l->A1m1) * sig12 + AB1) : s12_a12;
 
   if (outmask & GEOD_LONGITUDE) {
-    int E = l->salp0 < 0 ? -1 : 1; /* east or west going? */
+    real E = copysignx(1, l->salp0); /* east or west going? */
     /* tan(omg2) = sin(alp0) * tan(sig2) */
     somg2 = l->salp0 * ssig2; comg2 = csig2;  /* No need to normalize */
     /* omg12 = omg2 - omg1 */
@@ -548,14 +586,6 @@ real geod_genposition(const struct geod_geodesicline* l,
       /* alp12 = alp2 - alp1, used in atan2 so no need to normalize */
       salp12 = salp2 * l->calp1 - calp2 * l->salp1;
       calp12 = calp2 * l->calp1 + salp2 * l->salp1;
-      /* The right thing appears to happen if alp1 = +/-180 and alp2 = 0, viz
-       * salp12 = -0 and alp12 = -180.  However this depends on the sign being
-       * attached to 0 correctly.  The following ensures the correct
-       * behavior. */
-      if (salp12 == 0 && calp12 < 0) {
-        salp12 = tiny * l->calp1;
-        calp12 = -1;
-      }
     } else {
       /* tan(alp) = tan(alp0) * sec(sig)
        * tan(alp2-alp1) = (tan(alp2) -tan(alp1)) / (tan(alp2)*tan(alp1)+1)
@@ -593,6 +623,21 @@ real geod_genposition(const struct geod_geodesicline* l,
   return flags & GEOD_ARCMODE ? s12_a12 : sig12 / degree;
 }
 
+void geod_setdistance(struct geod_geodesicline* l, real s13) {
+  l->s13 = s13;
+  l->a13 = geod_genposition(l, GEOD_NOFLAGS, l->s13, 0, 0, 0, 0, 0, 0, 0, 0);
+}
+
+static void geod_setarc(struct geod_geodesicline* l, real a13) {
+  l->a13 = a13; l->s13 = NaN;
+  geod_genposition(l, GEOD_ARCMODE, l->a13, 0, 0, 0, &l->s13, 0, 0, 0, 0);
+}
+
+void geod_gensetdistance(struct geod_geodesicline* l,
+ unsigned flags, real s13_a13) {
+  flags & GEOD_ARCMODE ? geod_setarc(l, s13_a13) : geod_setdistance(l, s13_a13);
+}
+
 void geod_position(const struct geod_geodesicline* l, real s12,
                    real* plat2, real* plon2, real* pazi2) {
   geod_genposition(l, FALSE, s12, plat2, plon2, pazi2, 0, 0, 0, 0, 0);
@@ -630,23 +675,26 @@ void geod_direct(const struct geod_geodesic* g,
                  0, 0, 0, 0, 0);
 }
 
-real geod_geninverse(const struct geod_geodesic* g,
-                     real lat1, real lon1, real lat2, real lon2,
-                     real* ps12, real* pazi1, real* pazi2,
-                     real* pm12, real* pM12, real* pM21, real* pS12) {
-  real s12 = 0, azi1 = 0, azi2 = 0, m12 = 0, M12 = 0, M21 = 0, S12 = 0;
-  real lon12;
+static real geod_geninverse_int(const struct geod_geodesic* g,
+                                real lat1, real lon1, real lat2, real lon2,
+                                real* ps12,
+                                real* psalp1, real* pcalp1,
+                                real* psalp2, real* pcalp2,
+                                real* pm12, real* pM12, real* pM21,
+                                real* pS12) {
+  real s12 = 0, m12 = 0, M12 = 0, M21 = 0, S12 = 0;
+  real lon12, lon12s;
   int latsign, lonsign, swapp;
   real sbet1, cbet1, sbet2, cbet2, s12x = 0, m12x = 0;
   real dn1, dn2, lam12, slam12, clam12;
   real a12 = 0, sig12, calp1 = 0, salp1 = 0, calp2 = 0, salp2 = 0;
   real Ca[nC];
   boolx meridian;
-  real omg12 = 0;
+  /* somg12 > 1 marks that it needs to be calculated */
+  real omg12 = 0, somg12 = 2, comg12 = 0;
 
   unsigned outmask =
     (ps12 ? GEOD_DISTANCE : 0U) |
-    (pazi1 || pazi2 ? GEOD_AZIMUTH : 0U) |
     (pm12 ? GEOD_REDUCEDLENGTH : 0U) |
     (pM12 || pM21 ? GEOD_GEODESICSCALE : 0U) |
     (pS12 ? GEOD_AREA : 0U);
@@ -655,16 +703,25 @@ real geod_geninverse(const struct geod_geodesic* g,
   /* Compute longitude difference (AngDiff does this carefully).  Result is
    * in [-180, 180] but -180 is only for west-going geodesics.  180 is for
    * east-going and meridional geodesics. */
-  /* If very close to being on the same half-meridian, then make it so. */
-  lon12 = AngRound(AngDiff(lon1, lon2));
+  lon12 = AngDiff(lon1, lon2, &lon12s);
   /* Make longitude difference positive. */
   lonsign = lon12 >= 0 ? 1 : -1;
-  lon12 *= lonsign;
+  /* If very close to being on the same half-meridian, then make it so. */
+  lon12 = lonsign * AngRound(lon12);
+  lon12s = AngRound((180 - lon12) - lonsign * lon12s);
+  lam12 = lon12 * degree;
+  if (lon12 > 90) {
+    sincosdx(lon12s, &slam12, &clam12);
+    clam12 = -clam12;
+  } else
+    sincosdx(lon12, &slam12, &clam12);
+
   /* If really close to the equator, treat as on equator. */
   lat1 = AngRound(LatFix(lat1));
   lat2 = AngRound(LatFix(lat2));
-  /* Swap points so that point with higher (abs) latitude is point 1 */
-  swapp = fabs(lat1) >= fabs(lat2) ? 1 : -1;
+  /* Swap points so that point with higher (abs) latitude is point 1
+   * If one latitude is a nan, then it becomes lat1. */
+  swapp = fabs(lat1) < fabs(lat2) ? -1 : 1;
   if (swapp < 0) {
     lonsign *= -1;
     swapx(&lat1, &lat2);
@@ -712,9 +769,6 @@ real geod_geninverse(const struct geod_geodesic* g,
   dn1 = sqrt(1 + g->ep2 * sq(sbet1));
   dn2 = sqrt(1 + g->ep2 * sq(sbet2));
 
-  lam12 = lon12 * degree;
-  sincosdx(lon12, &slam12, &clam12);
-
   meridian = lat1 == -90 || slam12 == 0;
 
   if (meridian) {
@@ -731,7 +785,7 @@ real geod_geninverse(const struct geod_geodesic* g,
     ssig2 = sbet2; csig2 = calp2 * cbet2;
 
     /* sig12 = sig2 - sig1 */
-    sig12 = atan2(maxx(csig1 * ssig2 - ssig1 * csig2, (real)(0)),
+    sig12 = atan2(maxx((real)(0), csig1 * ssig2 - ssig1 * csig2),
                   csig1 * csig2 + ssig1 * ssig2);
     Lengths(g, g->n, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2,
             cbet1, cbet2, &s12x, &m12x, 0,
@@ -760,7 +814,7 @@ real geod_geninverse(const struct geod_geodesic* g,
   if (!meridian &&
       sbet1 == 0 &&           /* and sbet2 == 0 */
       /* Mimic the way Lambda12 works with calp1 = 0 */
-      (g->f <= 0 || lam12 <= pi - g->f * pi)) {
+      (g->f <= 0 || lon12s >= g->f * 180)) {
 
     /* Geodesic runs along equator */
     calp1 = calp2 = 0; salp1 = salp2 = 1;
@@ -779,7 +833,7 @@ real geod_geninverse(const struct geod_geodesic* g,
     /* Figure a starting point for Newton's method */
     real dnm = 0;
     sig12 = InverseStart(g, sbet1, cbet1, dn1, sbet2, cbet2, dn2,
-                         lam12,
+                         lam12, slam12, clam12,
                          &salp1, &calp1, &salp2, &calp2, &dnm,
                          Ca);
 
@@ -813,13 +867,13 @@ real geod_geninverse(const struct geod_geodesic* g,
         /* the WGS84 test set: mean = 1.47, sd = 1.25, max = 16
          * WGS84 and random input: mean = 2.85, sd = 0.60 */
         real dv = 0,
-          v = (Lambda12(g, sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1,
+          v = Lambda12(g, sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1,
+                        slam12, clam12,
                         &salp2, &calp2, &sig12, &ssig1, &csig1, &ssig2, &csig2,
-                        &eps, &omg12, numit < maxit1, &dv, Ca)
-               - lam12);
+                        &eps, &somg12, &comg12, numit < maxit1, &dv, Ca);
         /* 2 * tol0 is approximately 1 ulp for a number in [0, pi]. */
         /* Reversed test to allow escape with NaNs */
-        if (tripb || !(fabs(v) >= (tripn ? 8 : 2) * tol0)) break;
+        if (tripb || !(fabs(v) >= (tripn ? 8 : 1) * tol0)) break;
         /* Update bracketing values */
         if (v > 0 && (numit > maxit1 || calp1/salp1 > calp1b/salp1b))
           { salp1b = salp1; calp1b = calp1; }
@@ -864,7 +918,6 @@ real geod_geninverse(const struct geod_geodesic* g,
       m12x *= g->b;
       s12x *= g->b;
       a12 = sig12 / degree;
-      omg12 = lam12 - omg12;
     }
   }
 
@@ -900,15 +953,22 @@ real geod_geninverse(const struct geod_geodesic* g,
       /* Avoid problems with indeterminate sig1, sig2 on equator */
       S12 = 0;
 
+    if (!meridian) {
+      if (somg12 > 1) {
+        somg12 = sin(omg12); comg12 = cos(omg12);
+      } else
+        norm2(&somg12, &comg12);
+    }
+
     if (!meridian &&
-        omg12 < (real)(0.75) * pi &&   /* Long difference too big */
-        sbet2 - sbet1 < (real)(1.75)) { /* Lat difference too big */
+        /* omg12 < 3/4 * pi */
+        comg12 > -(real)(0.7071) &&     /* Long difference not too big */
+        sbet2 - sbet1 < (real)(1.75)) { /* Lat difference not too big */
       /* Use tan(Gamma/2) = tan(omg12/2)
        * * (tan(bet1/2)+tan(bet2/2))/(1+tan(bet1/2)*tan(bet2/2))
        * with tan(x/2) = sin(x)/(1+cos(x)) */
       real
-        somg12 = sin(omg12), domg12 = 1 + cos(omg12),
-        dbet1 = 1 + cbet1, dbet2 = 1 + cbet2;
+        domg12 = 1 + comg12, dbet1 = 1 + cbet1, dbet2 = 1 + cbet2;
       alp12 = 2 * atan2( somg12 * ( sbet1 * dbet2 + sbet2 * dbet1 ),
                          domg12 * ( sbet1 * sbet2 + dbet1 * dbet2 ) );
     } else {
@@ -943,18 +1003,13 @@ real geod_geninverse(const struct geod_geodesic* g,
   salp1 *= swapp * lonsign; calp1 *= swapp * latsign;
   salp2 *= swapp * lonsign; calp2 *= swapp * latsign;
 
-  if (outmask & GEOD_AZIMUTH) {
-    /* minus signs give range [-180, 180). 0- converts -0 to +0. */
-    azi1 = atan2dx(salp1, calp1);
-    azi2 = atan2dx(salp2, calp2);
-  }
+  if (psalp1) *psalp1 = salp1;
+  if (pcalp1) *pcalp1 = calp1;
+  if (psalp2) *psalp2 = salp2;
+  if (pcalp2) *pcalp2 = calp2;
 
   if (outmask & GEOD_DISTANCE)
     *ps12 = s12;
-  if (outmask & GEOD_AZIMUTH) {
-    if (pazi1) *pazi1 = azi1;
-    if (pazi2) *pazi2 = azi2;
-  }
   if (outmask & GEOD_REDUCEDLENGTH)
     *pm12 = m12;
   if (outmask & GEOD_GEODESICSCALE) {
@@ -968,6 +1023,35 @@ real geod_geninverse(const struct geod_geodesic* g,
   return a12;
 }
 
+real geod_geninverse(const struct geod_geodesic* g,
+                     real lat1, real lon1, real lat2, real lon2,
+                     real* ps12, real* pazi1, real* pazi2,
+                     real* pm12, real* pM12, real* pM21, real* pS12) {
+  real salp1, calp1, salp2, calp2,
+    a12 = geod_geninverse_int(g, lat1, lon1, lat2, lon2, ps12,
+                              &salp1, &calp1, &salp2, &calp2,
+                              pm12, pM12, pM21, pS12);
+  if (pazi1) *pazi1 = atan2dx(salp1, calp1);
+  if (pazi2) *pazi2 = atan2dx(salp2, calp2);
+  return a12;
+}
+
+void geod_inverseline(struct geod_geodesicline* l,
+                      const struct geod_geodesic* g,
+                      real lat1, real lon1, real lat2, real lon2,
+                      unsigned caps) {
+  real salp1, calp1,
+    a12 = geod_geninverse_int(g, lat1, lon1, lat2, lon2, 0,
+                              &salp1, &calp1, 0, 0,
+                              0, 0, 0, 0),
+    azi1 = atan2dx(salp1, calp1);
+  caps = caps ? caps : GEOD_DISTANCE_IN | GEOD_LONGITUDE;
+  /* Ensure that a12 can be converted to a distance */
+  if (caps & (OUT_ALL & GEOD_DISTANCE_IN)) caps |= GEOD_DISTANCE;
+  geod_lineinit_int(l, g, lat1, lon1, azi1, salp1, calp1, caps);
+  geod_setarc(l, a12);
+}
+
 void geod_inverse(const struct geod_geodesic* g,
                   real lat1, real lon1, real lat2, real lon2,
                   real* ps12, real* pazi1, real* pazi2) {
@@ -1112,7 +1196,7 @@ real Astroid(real x, real y) {
 real InverseStart(const struct geod_geodesic* g,
                   real sbet1, real cbet1, real dn1,
                   real sbet2, real cbet2, real dn2,
-                  real lam12,
+                  real lam12, real slam12, real clam12,
                   real* psalp1, real* pcalp1,
                   /* Only updated if return val >= 0 */
                   real* psalp2, real* pcalp2,
@@ -1133,7 +1217,7 @@ real InverseStart(const struct geod_geodesic* g,
   real sbet12a;
   boolx shortline = cbet12 >= 0 && sbet12 < (real)(0.5) &&
     cbet2 * lam12 < (real)(0.5);
-  real omg12 = lam12, somg12, comg12, ssig12, csig12;
+  real somg12, comg12, ssig12, csig12;
 #if defined(__GNUC__) && __GNUC__ == 4 &&       \
   (__GNUC_MINOR__ < 6 || defined(__MINGW32__))
   /* Volatile declaration needed to fix inverse cases
@@ -1151,14 +1235,16 @@ real InverseStart(const struct geod_geodesic* g,
   sbet12a = sbet2 * cbet1 + cbet2 * sbet1;
 #endif
   if (shortline) {
-    real sbetm2 = sq(sbet1 + sbet2);
+    real sbetm2 = sq(sbet1 + sbet2), omg12;
     /* sin((bet1+bet2)/2)^2
      * =  (sbet1 + sbet2)^2 / ((sbet1 + sbet2)^2 + (cbet1 + cbet2)^2) */
     sbetm2 /= sbetm2 + sq(cbet1 + cbet2);
     dnm = sqrt(1 + g->ep2 * sbetm2);
-    omg12 /= g->f1 * dnm;
+    omg12 = lam12 / (g->f1 * dnm);
+    somg12 = sin(omg12); comg12 = cos(omg12);
+  } else {
+    somg12 = slam12; comg12 = clam12;
   }
-  somg12 = sin(omg12); comg12 = cos(omg12);
 
   salp1 = cbet2 * somg12;
   calp1 = comg12 >= 0 ?
@@ -1188,6 +1274,7 @@ real InverseStart(const struct geod_geodesic* g,
      * 56.320923501171 0 -56.320923501171 179.664747671772880215
      * which otherwise fails with g++ 4.4.4 x86 -O3 */
     volatile real x;
+    real lam12x = atan2(-slam12, -clam12); /* lam12 - pi */
     if (g->f >= 0) {            /* In fact f == 0 does not get here */
       /* x = dlong, y = dlat */
       {
@@ -1198,7 +1285,7 @@ real InverseStart(const struct geod_geodesic* g,
       }
       betscale = lamscale * cbet1;
 
-      x = (lam12 - pi) / lamscale;
+      x = lam12x / lamscale;
       y = sbet12a / betscale;
     } else {                    /* f < 0 */
       /* x = dlat, y = dlong */
@@ -1215,7 +1302,7 @@ real InverseStart(const struct geod_geodesic* g,
       betscale = x < -(real)(0.01) ? sbet12a / x :
         -g->f * sq(cbet1) * pi;
       lamscale = betscale / cbet1;
-      y = (lam12 - pi) / lamscale;
+      y = lam12x / lamscale;
     }
 
     if (y > -tol1 && x > -1 - xthresh) {
@@ -1292,19 +1379,22 @@ real Lambda12(const struct geod_geodesic* g,
               real sbet1, real cbet1, real dn1,
               real sbet2, real cbet2, real dn2,
               real salp1, real calp1,
+              real slam120, real clam120,
               real* psalp2, real* pcalp2,
               real* psig12,
               real* pssig1, real* pcsig1,
               real* pssig2, real* pcsig2,
-              real* peps, real* pdomg12,
+              real* peps,
+              real* psomg12, real* pcomg12,
               boolx diffp, real* pdlam12,
               /* Scratch area of the right size */
               real Ca[]) {
   real salp2 = 0, calp2 = 0, sig12 = 0,
-    ssig1 = 0, csig1 = 0, ssig2 = 0, csig2 = 0, eps = 0, domg12 = 0, dlam12 = 0;
+    ssig1 = 0, csig1 = 0, ssig2 = 0, csig2 = 0, eps = 0,
+    somg12 = 0, comg12 = 0, dlam12 = 0;
   real salp0, calp0;
-  real somg1, comg1, somg2, comg2, omg12, lam12;
-  real B312, h0, k2;
+  real somg1, comg1, somg2, comg2, lam12;
+  real B312, eta, k2;
 
   if (sbet1 == 0 && calp1 == 0)
     /* Break degeneracy of equatorial line.  This case has already been
@@ -1345,20 +1435,21 @@ real Lambda12(const struct geod_geodesic* g,
   /* norm2(&somg2, &comg2); -- don't need to normalize! */
 
   /* sig12 = sig2 - sig1, limit to [0, pi] */
-  sig12 = atan2(maxx(csig1 * ssig2 - ssig1 * csig2, (real)(0)),
+  sig12 = atan2(maxx((real)(0), csig1 * ssig2 - ssig1 * csig2),
                 csig1 * csig2 + ssig1 * ssig2);
 
   /* omg12 = omg2 - omg1, limit to [0, pi] */
-  omg12 = atan2(maxx(comg1 * somg2 - somg1 * comg2, (real)(0)),
-                comg1 * comg2 + somg1 * somg2);
+  somg12 = maxx((real)(0), comg1 * somg2 - somg1 * comg2);
+  comg12 =                 comg1 * comg2 + somg1 * somg2;
+  /* eta = omg12 - lam120 */
+  eta = atan2(somg12 * clam120 - comg12 * slam120,
+              comg12 * clam120 + somg12 * slam120);
   k2 = sq(calp0) * g->ep2;
   eps = k2 / (2 * (1 + sqrt(1 + k2)) + k2);
   C3f(g, eps, Ca);
   B312 = (SinCosSeries(TRUE, ssig2, csig2, Ca, nC3-1) -
           SinCosSeries(TRUE, ssig1, csig1, Ca, nC3-1));
-  h0 = -g->f * A3f(g, eps);
-  domg12 = salp0 * h0 * (sig12 + B312);
-  lam12 = omg12 + domg12;
+  lam12 = eta - g->f * A3f(g, eps) * salp0 * (sig12 + B312);
 
   if (diffp) {
     if (calp2 == 0)
@@ -1378,7 +1469,8 @@ real Lambda12(const struct geod_geodesic* g,
   *pssig2 = ssig2;
   *pcsig2 = csig2;
   *peps = eps;
-  *pdomg12 = domg12;
+  *psomg12 = somg12;
+  *pcomg12 = comg12;
   if (diffp)
     *pdlam12 = dlam12;
 
@@ -1653,7 +1745,7 @@ int transit(real lon1, real lon2) {
   /* Compute lon12 the same way as Geodesic::Inverse. */
   lon1 = AngNormalize(lon1);
   lon2 = AngNormalize(lon2);
-  lon12 = AngDiff(lon1, lon2);
+  lon12 = AngDiff(lon1, lon2, 0);
   return lon1 < 0 && lon2 >= 0 && lon12 > 0 ? 1 :
     (lon2 < 0 && lon1 >= 0 && lon12 < 0 ? -1 : 0);
 }
@@ -1699,8 +1791,12 @@ void accneg(real s[]) {
 }
 
 void geod_polygon_init(struct geod_polygon* p, boolx polylinep) {
-  p->lat0 = p->lon0 = p->lat = p->lon = NaN;
   p->polyline = (polylinep != 0);
+  geod_polygon_clear(p);
+}
+
+void geod_polygon_clear(struct geod_polygon* p) {
+  p->lat0 = p->lon0 = p->lat = p->lon = NaN;
   accini(p->P);
   accini(p->A);
   p->num = p->crossings = 0;
diff --git a/src/geodesic.h b/src/geodesic.h
index 7bd8270..c3f28c7 100644
--- a/src/geodesic.h
+++ b/src/geodesic.h
@@ -1,6 +1,6 @@
 /**
  * \file geodesic.h
- * \brief Header for the geodesic routines in C
+ * \brief API for the geodesic routines in C
  *
  * This an implementation in C of the geodesic algorithms described in
  * - C. F. F. Karney,
@@ -9,7 +9,7 @@
  *   J. Geodesy <b>87</b>, 43--55 (2013);
  *   DOI: <a href="https://dx.doi.org/10.1007/s00190-012-0578-z">
  *   10.1007/s00190-012-0578-z</a>;
- *   addenda: <a href="http://geographiclib.sf.net/geod-addenda.html">
+ *   addenda: <a href="http://geographiclib.sourceforge.net/geod-addenda.html">
  *   geod-addenda.html</a>.
  * .
  * The principal advantages of these algorithms over previous ones (e.g.,
@@ -75,30 +75,29 @@
  * (obviously) uniquely defined.  However, in a few special cases there are
  * multiple azimuths which yield the same shortest distance.  Here is a
  * catalog of those cases:
- * - \e lat1 = −\e lat2 (with neither point at a pole).  If \e azi1 =
- *   \e azi2, the geodesic is unique.  Otherwise there are two geodesics
- *   and the second one is obtained by setting [\e azi1, \e azi2] = [\e
- *   azi2, \e azi1], [\e M12, \e M21] = [\e M21, \e M12], \e S12 =
- *   −\e S12.  (This occurs when the longitude difference is near
- *   ±180° for oblate ellipsoids.)
- * - \e lon2 = \e lon1 ± 180° (with neither point at a pole).
- *   If \e azi1 = 0° or ±180°, the geodesic is unique.
- *   Otherwise there are two geodesics and the second one is obtained by
- *   setting [\e azi1, \e azi2] = [−\e azi1, −\e azi2], \e S12
- *   = −\e S12.  (This occurs when \e lat2 is near −\e lat1 for
+ * - \e lat1 = −\e lat2 (with neither point at a pole).  If \e azi1 = \e
+ *   azi2, the geodesic is unique.  Otherwise there are two geodesics and the
+ *   second one is obtained by setting [\e azi1, \e azi2] → [\e azi2, \e
+ *   azi1], [\e M12, \e M21] → [\e M21, \e M12], \e S12 → −\e
+ *   S12.  (This occurs when the longitude difference is near ±180°
+ *   for oblate ellipsoids.)
+ * - \e lon2 = \e lon1 ± 180° (with neither point at a pole).  If \e
+ *   azi1 = 0° or ±180°, the geodesic is unique.  Otherwise
+ *   there are two geodesics and the second one is obtained by setting [\e
+ *   azi1, \e azi2] → [−\e azi1, −\e azi2], \e S12 →
+ *   −\e S12.  (This occurs when \e lat2 is near −\e lat1 for
  *   prolate ellipsoids.)
- * - Points 1 and 2 at opposite poles.  There are infinitely many
- *   geodesics which can be generated by setting [\e azi1, \e azi2] =
- *   [\e azi1, \e azi2] + [\e d, −\e d], for arbitrary \e d.  (For
- *   spheres, this prescription applies when points 1 and 2 are
- *   antipodal.)
- * - \e s12 = 0 (coincident points).  There are infinitely many geodesics
- *   which can be generated by setting [\e azi1, \e azi2] = [\e azi1, \e
- *   azi2] + [\e d, \e d], for arbitrary \e d.
+ * - Points 1 and 2 at opposite poles.  There are infinitely many geodesics
+ *   which can be generated by setting [\e azi1, \e azi2] → [\e azi1, \e
+ *   azi2] + [\e d, −\e d], for arbitrary \e d.  (For spheres, this
+ *   prescription applies when points 1 and 2 are antipodal.)
+ * - \e s12 = 0 (coincident points).  There are infinitely many geodesics which
+ *   can be generated by setting [\e azi1, \e azi2] → [\e azi1, \e azi2] +
+ *   [\e d, \e d], for arbitrary \e d.
  *
  * These routines are a simple transcription of the corresponding C++ classes
- * in <a href="http://geographiclib.sf.net"> GeographicLib</a>.  The "class
- * data" is represented by the structs geod_geodesic, geod_geodesicline,
+ * in <a href="http://geographiclib.sourceforge.net"> GeographicLib</a>.  The
+ * "class data" is represented by the structs geod_geodesic, geod_geodesicline,
  * geod_polygon and pointers to these objects are passed as initial arguments
  * to the member functions.  Most of the internal comments have been retained.
  * However, in the process of transcription some documentation has been lost
@@ -108,12 +107,12 @@
  * twice about restructuring the internals of the C code since this may make
  * porting fixes from the C++ code more difficult.
  *
- * Copyright (c) Charles Karney (2012-2015) <charles at karney.com> and licensed
+ * Copyright (c) Charles Karney (2012-2016) <charles at karney.com> and licensed
  * under the MIT/X11 License.  For more information, see
  * http://geographiclib.sourceforge.net/
  *
  * This library was distributed with
- * <a href="../index.html">GeographicLib</a> 1.44.
+ * <a href="../index.html">GeographicLib</a> 1.46.
  **********************************************************************/
 
 #if !defined(GEODESIC_H)
@@ -128,12 +127,12 @@
  * The minor version of the geodesic library.  (This tracks the version of
  * GeographicLib.)
  **********************************************************************/
-#define GEODESIC_VERSION_MINOR 44
+#define GEODESIC_VERSION_MINOR 46
 /**
  * The patch level of the geodesic library.  (This tracks the version of
  * GeographicLib.)
  **********************************************************************/
-#define GEODESIC_VERSION_PATCH 0
+#define GEODESIC_VERSION_PATCH 1
 
 /**
  * Pack the version components into a single integer.  Users should not rely on
@@ -177,7 +176,8 @@ extern "C" {
 
   /**
    * The struct containing information about a single geodesic.  This must be
-   * initialized by geod_lineinit() before use.
+   * initialized by geod_lineinit(), geod_directline(), geod_gendirectline(),
+   * or geod_inverseline() before use.
    **********************************************************************/
   struct geod_geodesicline {
     double lat1;                /**< the starting latitude */
@@ -185,9 +185,13 @@ extern "C" {
     double azi1;                /**< the starting azimuth */
     double a;                   /**< the equatorial radius */
     double f;                   /**< the flattening */
+    double salp1;               /**< sine of \e azi1 */
+    double calp1;               /**< cosine of \e azi1 */
+    double a13;                 /**< arc length to reference point */
+    double s13;                 /**< distance to reference point */
     /**< @cond SKIP */
     double b, c2, f1, salp0, calp0, k2,
-      salp1, calp1, ssig1, csig1, dn1, stau1, ctau1, somg1, comg1,
+      ssig1, csig1, dn1, stau1, ctau1, somg1, comg1,
       A1m1, A2m1, A3c, B11, B21, B31, A4, B41;
     double C1a[6+1], C1pa[6+1], C2a[6+1], C3a[6], C4a[6];
     /**< @endcond */
@@ -223,46 +227,6 @@ extern "C" {
   void geod_init(struct geod_geodesic* g, double a, double f);
 
   /**
-   * Initialize a geod_geodesicline object.
-   *
-   * @param[out] l a pointer to the object to be initialized.
-   * @param[in] g a pointer to the geod_geodesic object specifying the
-   *   ellipsoid.
-   * @param[in] lat1 latitude of point 1 (degrees).
-   * @param[in] lon1 longitude of point 1 (degrees).
-   * @param[in] azi1 azimuth at point 1 (degrees).
-   * @param[in] caps bitor'ed combination of geod_mask() values specifying the
-   *   capabilities the geod_geodesicline object should possess, i.e., which
-   *   quantities can be returned in calls to geod_position() and
-   *   geod_genposition().
-   *
-   * \e g must have been initialized with a call to geod_init().  \e lat1
-   * should be in the range [−90°, 90°].
-   *
-   * The geod_mask values are [see geod_mask()]:
-   * - \e caps |= GEOD_LATITUDE for the latitude \e lat2; this is
-   *   added automatically,
-   * - \e caps |= GEOD_LONGITUDE for the latitude \e lon2,
-   * - \e caps |= GEOD_AZIMUTH for the latitude \e azi2; this is
-   *   added automatically,
-   * - \e caps |= GEOD_DISTANCE for the distance \e s12,
-   * - \e caps |= GEOD_REDUCEDLENGTH for the reduced length \e m12,
-   * - \e caps |= GEOD_GEODESICSCALE for the geodesic scales \e M12
-   *   and \e M21,
-   * - \e caps |= GEOD_AREA for the area \e S12,
-   * - \e caps |= GEOD_DISTANCE_IN permits the length of the
-   *   geodesic to be given in terms of \e s12; without this capability the
-   *   length can only be specified in terms of arc length.
-   * .
-   * A value of \e caps = 0 is treated as GEOD_LATITUDE | GEOD_LONGITUDE |
-   * GEOD_AZIMUTH | GEOD_DISTANCE_IN (to support the solution of the "standard"
-   * direct problem).
-   **********************************************************************/
-  void geod_lineinit(struct geod_geodesicline* l,
-                     const struct geod_geodesic* g,
-                     double lat1, double lon1, double azi1, unsigned caps);
-
-  /**
    * Solve the direct geodesic problem.
    *
    * @param[in] g a pointer to the geod_geodesic object specifying the
@@ -270,7 +234,7 @@ extern "C" {
    * @param[in] lat1 latitude of point 1 (degrees).
    * @param[in] lon1 longitude of point 1 (degrees).
    * @param[in] azi1 azimuth at point 1 (degrees).
-   * @param[in] s12 distance between point 1 and point 2 (meters); it can be
+   * @param[in] s12 distance from point 1 to point 2 (meters); it can be
    *   negative.
    * @param[out] plat2 pointer to the latitude of point 2 (degrees).
    * @param[out] plon2 pointer to the longitude of point 2 (degrees).
@@ -303,6 +267,51 @@ extern "C" {
                    double* plat2, double* plon2, double* pazi2);
 
   /**
+   * The general direct geodesic problem.
+   *
+   * @param[in] g a pointer to the geod_geodesic object specifying the
+   *   ellipsoid.
+   * @param[in] lat1 latitude of point 1 (degrees).
+   * @param[in] lon1 longitude of point 1 (degrees).
+   * @param[in] azi1 azimuth at point 1 (degrees).
+   * @param[in] flags bitor'ed combination of geod_flags(); \e flags &
+   *   GEOD_ARCMODE determines the meaning of \e s12_a12 and \e flags &
+   *   GEOD_LONG_UNROLL "unrolls" \e lon2.
+   * @param[in] s12_a12 if \e flags & GEOD_ARCMODE is 0, this is the distance
+   *   from point 1 to point 2 (meters); otherwise it is the arc length
+   *   from point 1 to point 2 (degrees); it can be negative.
+   * @param[out] plat2 pointer to the latitude of point 2 (degrees).
+   * @param[out] plon2 pointer to the longitude of point 2 (degrees).
+   * @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
+   * @param[out] ps12 pointer to the distance from point 1 to point 2
+   *   (meters).
+   * @param[out] pm12 pointer to the reduced length of geodesic (meters).
+   * @param[out] pM12 pointer to the geodesic scale of point 2 relative to
+   *   point 1 (dimensionless).
+   * @param[out] pM21 pointer to the geodesic scale of point 1 relative to
+   *   point 2 (dimensionless).
+   * @param[out] pS12 pointer to the area under the geodesic
+   *   (meters<sup>2</sup>).
+   * @return \e a12 arc length from point 1 to point 2 (degrees).
+   *
+   * \e g must have been initialized with a call to geod_init().  \e lat1
+   * should be in the range [−90°, 90°].  The function value \e
+   * a12 equals \e s12_a12 if \e flags & GEOD_ARCMODE.  Any of the "return"
+   * arguments, \e plat2, etc., may be replaced by 0, if you do not need some
+   * quantities computed.
+   *
+   * With \e flags & GEOD_LONG_UNROLL bit set, the longitude is "unrolled" so
+   * that the quantity \e lon2 − \e lon1 indicates how many times and in
+   * what sense the geodesic encircles the ellipsoid.
+   **********************************************************************/
+  double geod_gendirect(const struct geod_geodesic* g,
+                        double lat1, double lon1, double azi1,
+                        unsigned flags, double s12_a12,
+                        double* plat2, double* plon2, double* pazi2,
+                        double* ps12, double* pm12, double* pM12, double* pM21,
+                        double* pS12);
+
+  /**
    * Solve the inverse geodesic problem.
    *
    * @param[in] g a pointer to the geod_geodesic object specifying the
@@ -311,7 +320,7 @@ extern "C" {
    * @param[in] lon1 longitude of point 1 (degrees).
    * @param[in] lat2 latitude of point 2 (degrees).
    * @param[in] lon2 longitude of point 2 (degrees).
-   * @param[out] ps12 pointer to the distance between point 1 and point 2
+   * @param[out] ps12 pointer to the distance from point 1 to point 2
    *   (meters).
    * @param[out] pazi1 pointer to the azimuth at point 1 (degrees).
    * @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
@@ -345,22 +354,180 @@ extern "C" {
                     double* ps12, double* pazi1, double* pazi2);
 
   /**
+   * The general inverse geodesic calculation.
+   *
+   * @param[in] g a pointer to the geod_geodesic object specifying the
+   *   ellipsoid.
+   * @param[in] lat1 latitude of point 1 (degrees).
+   * @param[in] lon1 longitude of point 1 (degrees).
+   * @param[in] lat2 latitude of point 2 (degrees).
+   * @param[in] lon2 longitude of point 2 (degrees).
+   * @param[out] ps12 pointer to the distance from point 1 to point 2
+   *  (meters).
+   * @param[out] pazi1 pointer to the azimuth at point 1 (degrees).
+   * @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
+   * @param[out] pm12 pointer to the reduced length of geodesic (meters).
+   * @param[out] pM12 pointer to the geodesic scale of point 2 relative to
+   *   point 1 (dimensionless).
+   * @param[out] pM21 pointer to the geodesic scale of point 1 relative to
+   *   point 2 (dimensionless).
+   * @param[out] pS12 pointer to the area under the geodesic
+   *   (meters<sup>2</sup>).
+   * @return \e a12 arc length from point 1 to point 2 (degrees).
+   *
+   * \e g must have been initialized with a call to geod_init().  \e lat1 and
+   * \e lat2 should be in the range [−90°, 90°].  Any of the
+   * "return" arguments \e ps12, etc., may be replaced by 0, if you do not need
+   * some quantities computed.
+   **********************************************************************/
+  double geod_geninverse(const struct geod_geodesic* g,
+                         double lat1, double lon1, double lat2, double lon2,
+                         double* ps12, double* pazi1, double* pazi2,
+                         double* pm12, double* pM12, double* pM21,
+                         double* pS12);
+
+  /**
+   * Initialize a geod_geodesicline object.
+   *
+   * @param[out] l a pointer to the object to be initialized.
+   * @param[in] g a pointer to the geod_geodesic object specifying the
+   *   ellipsoid.
+   * @param[in] lat1 latitude of point 1 (degrees).
+   * @param[in] lon1 longitude of point 1 (degrees).
+   * @param[in] azi1 azimuth at point 1 (degrees).
+   * @param[in] caps bitor'ed combination of geod_mask() values specifying the
+   *   capabilities the geod_geodesicline object should possess, i.e., which
+   *   quantities can be returned in calls to geod_position() and
+   *   geod_genposition().
+   *
+   * \e g must have been initialized with a call to geod_init().  \e lat1
+   * should be in the range [−90°, 90°].
+   *
+   * The geod_mask values are [see geod_mask()]:
+   * - \e caps |= GEOD_LATITUDE for the latitude \e lat2; this is
+   *   added automatically,
+   * - \e caps |= GEOD_LONGITUDE for the latitude \e lon2,
+   * - \e caps |= GEOD_AZIMUTH for the latitude \e azi2; this is
+   *   added automatically,
+   * - \e caps |= GEOD_DISTANCE for the distance \e s12,
+   * - \e caps |= GEOD_REDUCEDLENGTH for the reduced length \e m12,
+   * - \e caps |= GEOD_GEODESICSCALE for the geodesic scales \e M12
+   *   and \e M21,
+   * - \e caps |= GEOD_AREA for the area \e S12,
+   * - \e caps |= GEOD_DISTANCE_IN permits the length of the
+   *   geodesic to be given in terms of \e s12; without this capability the
+   *   length can only be specified in terms of arc length.
+   * .
+   * A value of \e caps = 0 is treated as GEOD_LATITUDE | GEOD_LONGITUDE |
+   * GEOD_AZIMUTH | GEOD_DISTANCE_IN (to support the solution of the "standard"
+   * direct problem).
+   *
+   * When initialized by this function, point 3 is undefined (l->s13 = l->a13 =
+   * NaN).
+   **********************************************************************/
+  void geod_lineinit(struct geod_geodesicline* l,
+                     const struct geod_geodesic* g,
+                     double lat1, double lon1, double azi1, unsigned caps);
+
+  /**
+   * Initialize a geod_geodesicline object in terms of the direct geodesic
+   * problem.
+   *
+   * @param[out] l a pointer to the object to be initialized.
+   * @param[in] g a pointer to the geod_geodesic object specifying the
+   *   ellipsoid.
+   * @param[in] lat1 latitude of point 1 (degrees).
+   * @param[in] lon1 longitude of point 1 (degrees).
+   * @param[in] azi1 azimuth at point 1 (degrees).
+   * @param[in] s12 distance from point 1 to point 2 (meters); it can be
+   *   negative.
+   * @param[in] caps bitor'ed combination of geod_mask() values specifying the
+   *   capabilities the geod_geodesicline object should possess, i.e., which
+   *   quantities can be returned in calls to geod_position() and
+   *   geod_genposition().
+   *
+   * This function sets point 3 of the geod_geodesicline to correspond to point
+   * 2 of the direct geodesic problem.  See geod_lineinit() for more
+   * informaion.
+   **********************************************************************/
+  void geod_directline(struct geod_geodesicline* l,
+                       const struct geod_geodesic* g,
+                       double lat1, double lon1, double azi1, double s12,
+                       unsigned caps);
+
+  /**
+   * Initialize a geod_geodesicline object in terms of the direct geodesic
+   * problem spacified in terms of either distance or arc length.
+   *
+   * @param[out] l a pointer to the object to be initialized.
+   * @param[in] g a pointer to the geod_geodesic object specifying the
+   *   ellipsoid.
+   * @param[in] lat1 latitude of point 1 (degrees).
+   * @param[in] lon1 longitude of point 1 (degrees).
+   * @param[in] azi1 azimuth at point 1 (degrees).
+   * @param[in] flags either GEOD_NOFLAGS or GEOD_ARCMODE to determining the
+   *   meaning of the \e s12_a12.
+   * @param[in] s12_a12 if \e flags = GEOD_NOFLAGS, this is the distance
+   *   from point 1 to point 2 (meters); if \e flags = GEOD_ARCMODE, it is
+   *   the arc length from point 1 to point 2 (degrees); it can be
+   *   negative.
+   * @param[in] caps bitor'ed combination of geod_mask() values specifying the
+   *   capabilities the geod_geodesicline object should possess, i.e., which
+   *   quantities can be returned in calls to geod_position() and
+   *   geod_genposition().
+   *
+   * This function sets point 3 of the geod_geodesicline to correspond to point
+   * 2 of the direct geodesic problem.  See geod_lineinit() for more
+   * informaion.
+   **********************************************************************/
+  void geod_gendirectline(struct geod_geodesicline* l,
+                          const struct geod_geodesic* g,
+                          double lat1, double lon1, double azi1,
+                          unsigned flags, double s12_a12,
+                          unsigned caps);
+
+  /**
+   * Initialize a geod_geodesicline object in terms of the inverse geodesic
+   * problem.
+   *
+   * @param[out] l a pointer to the object to be initialized.
+   * @param[in] g a pointer to the geod_geodesic object specifying the
+   *   ellipsoid.
+   * @param[in] lat1 latitude of point 1 (degrees).
+   * @param[in] lon1 longitude of point 1 (degrees).
+   * @param[in] lat2 latitude of point 2 (degrees).
+   * @param[in] lon2 longitude of point 2 (degrees).
+   * @param[in] caps bitor'ed combination of geod_mask() values specifying the
+   *   capabilities the geod_geodesicline object should possess, i.e., which
+   *   quantities can be returned in calls to geod_position() and
+   *   geod_genposition().
+   *
+   * This function sets point 3 of the geod_geodesicline to correspond to point
+   * 2 of the inverse geodesic problem.  See geod_lineinit() for more
+   * informaion.
+   **********************************************************************/
+  void geod_inverseline(struct geod_geodesicline* l,
+                       const struct geod_geodesic* g,
+                       double lat1, double lon1, double lat2, double lon2,
+                       unsigned caps);
+
+  /**
    * Compute the position along a geod_geodesicline.
    *
    * @param[in] l a pointer to the geod_geodesicline object specifying the
    *   geodesic line.
-   * @param[in] s12 distance between point 1 and point 2 (meters); it can be
+   * @param[in] s12 distance from point 1 to point 2 (meters); it can be
    *   negative.
    * @param[out] plat2 pointer to the latitude of point 2 (degrees).
    * @param[out] plon2 pointer to the longitude of point 2 (degrees); requires
    *   that \e l was initialized with \e caps |= GEOD_LONGITUDE.
    * @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
    *
-   * \e l must have been initialized with a call to geod_lineinit() with \e
-   * caps |= GEOD_DISTANCE_IN.  The values of \e lon2 and \e azi2 returned are
-   * in the range [−180°, 180°).  Any of the "return" arguments
-   * \e plat2, etc., may be replaced by 0, if you do not need some quantities
-   * computed.
+   * \e l must have been initialized with a call, e.g., to geod_lineinit(),
+   * with \e caps |= GEOD_DISTANCE_IN.  The values of \e lon2 and \e azi2
+   * returned are in the range [−180°, 180°).  Any of the
+   * "return" arguments \e plat2, etc., may be replaced by 0, if you do not
+   * need some quantities computed.
    *
    * Example, compute way points between JFK and Singapore Changi Airport
    * the "obvious" way using geod_direct():
@@ -379,13 +546,12 @@ extern "C" {
    @code{.c}
    struct geod_geodesic g;
    struct geod_geodesicline l;
-   double s12, azi1, lat[101],lon[101];
+   double lat[101],lon[101];
    int i;
    geod_init(&g, 6378137, 1/298.257223563);
-   geod_inverse(&g, 40.64, -73.78, 1.36, 103.99, &s12, &azi1, 0);
-   geod_lineinit(&l, &g, 40.64, -73.78, azi1, 0);
-   for (i = 0; i < 101; ++i) {
-     geod_position(&l, i * s12 * 0.01, lat + i, lon + i, 0);
+   geod_inverseline(&l, &g, 40.64, -73.78, 1.36, 103.99, 0);
+   for (i = 0; i <= 100; ++i) {
+     geod_position(&l, i * l.s13 * 0.01, lat + i, lon + i, 0);
      printf("%.5f %.5f\n", lat[i], lon[i]);
    }
    @endcode
@@ -394,84 +560,6 @@ extern "C" {
                      double* plat2, double* plon2, double* pazi2);
 
   /**
-   * The general direct geodesic problem.
-   *
-   * @param[in] g a pointer to the geod_geodesic object specifying the
-   *   ellipsoid.
-   * @param[in] lat1 latitude of point 1 (degrees).
-   * @param[in] lon1 longitude of point 1 (degrees).
-   * @param[in] azi1 azimuth at point 1 (degrees).
-   * @param[in] flags bitor'ed combination of geod_flags(); \e flags &
-   *   GEOD_ARCMODE determines the meaning of \e s12_a12 and \e flags &
-   *   GEOD_LONG_UNROLL "unrolls" \e lon2.
-   * @param[in] s12_a12 if \e flags & GEOD_ARCMODE is 0, this is the distance
-   *   between point 1 and point 2 (meters); otherwise it is the arc length
-   *   between point 1 and point 2 (degrees); it can be negative.
-   * @param[out] plat2 pointer to the latitude of point 2 (degrees).
-   * @param[out] plon2 pointer to the longitude of point 2 (degrees).
-   * @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
-   * @param[out] ps12 pointer to the distance between point 1 and point 2
-   *   (meters).
-   * @param[out] pm12 pointer to the reduced length of geodesic (meters).
-   * @param[out] pM12 pointer to the geodesic scale of point 2 relative to
-   *   point 1 (dimensionless).
-   * @param[out] pM21 pointer to the geodesic scale of point 1 relative to
-   *   point 2 (dimensionless).
-   * @param[out] pS12 pointer to the area under the geodesic
-   *   (meters<sup>2</sup>).
-   * @return \e a12 arc length of between point 1 and point 2 (degrees).
-   *
-   * \e g must have been initialized with a call to geod_init().  \e lat1
-   * should be in the range [−90°, 90°].  The function value \e
-   * a12 equals \e s12_a12 if \e flags & GEOD_ARCMODE.  Any of the "return"
-   * arguments, \e plat2, etc., may be replaced by 0, if you do not need some
-   * quantities computed.
-   *
-   * With \e flags & GEOD_LONG_UNROLL bit set, the longitude is "unrolled" so
-   * that the quantity \e lon2 − \e lon1 indicates how many times and in
-   * what sense the geodesic encircles the ellipsoid.
-   **********************************************************************/
-  double geod_gendirect(const struct geod_geodesic* g,
-                        double lat1, double lon1, double azi1,
-                        unsigned flags, double s12_a12,
-                        double* plat2, double* plon2, double* pazi2,
-                        double* ps12, double* pm12, double* pM12, double* pM21,
-                        double* pS12);
-
-  /**
-   * The general inverse geodesic calculation.
-   *
-   * @param[in] g a pointer to the geod_geodesic object specifying the
-   *   ellipsoid.
-   * @param[in] lat1 latitude of point 1 (degrees).
-   * @param[in] lon1 longitude of point 1 (degrees).
-   * @param[in] lat2 latitude of point 2 (degrees).
-   * @param[in] lon2 longitude of point 2 (degrees).
-   * @param[out] ps12 pointer to the distance between point 1 and point 2
-   *  (meters).
-   * @param[out] pazi1 pointer to the azimuth at point 1 (degrees).
-   * @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
-   * @param[out] pm12 pointer to the reduced length of geodesic (meters).
-   * @param[out] pM12 pointer to the geodesic scale of point 2 relative to
-   *   point 1 (dimensionless).
-   * @param[out] pM21 pointer to the geodesic scale of point 1 relative to
-   *   point 2 (dimensionless).
-   * @param[out] pS12 pointer to the area under the geodesic
-   *   (meters<sup>2</sup>).
-   * @return \e a12 arc length of between point 1 and point 2 (degrees).
-   *
-   * \e g must have been initialized with a call to geod_init().  \e lat1 and
-   * \e lat2 should be in the range [−90°, 90°].  Any of the
-   * "return" arguments \e ps12, etc., may be replaced by 0, if you do not need
-   * some quantities computed.
-   **********************************************************************/
-  double geod_geninverse(const struct geod_geodesic* g,
-                         double lat1, double lon1, double lat2, double lon2,
-                         double* ps12, double* pazi1, double* pazi2,
-                         double* pm12, double* pM12, double* pM21,
-                         double* pS12);
-
-  /**
    * The general position function.
    *
    * @param[in] l a pointer to the geod_geodesicline object specifying the
@@ -481,14 +569,14 @@ extern "C" {
    *   GEOD_LONG_UNROLL "unrolls" \e lon2; if \e flags & GEOD_ARCMODE is 0,
    *   then \e l must have been initialized with \e caps |= GEOD_DISTANCE_IN.
    * @param[in] s12_a12 if \e flags & GEOD_ARCMODE is 0, this is the
-   *   distance between point 1 and point 2 (meters); otherwise it is the
-   *   arc length between point 1 and point 2 (degrees); it can be
+   *   distance from point 1 to point 2 (meters); otherwise it is the
+   *   arc length from point 1 to point 2 (degrees); it can be
    *   negative.
    * @param[out] plat2 pointer to the latitude of point 2 (degrees).
    * @param[out] plon2 pointer to the longitude of point 2 (degrees); requires
    *   that \e l was initialized with \e caps |= GEOD_LONGITUDE.
    * @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
-   * @param[out] ps12 pointer to the distance between point 1 and point 2
+   * @param[out] ps12 pointer to the distance from point 1 to point 2
    *   (meters); requires that \e l was initialized with \e caps |=
    *   GEOD_DISTANCE.
    * @param[out] pm12 pointer to the reduced length of geodesic (meters);
@@ -502,7 +590,7 @@ extern "C" {
    * @param[out] pS12 pointer to the area under the geodesic
    *   (meters<sup>2</sup>); requires that \e l was initialized with \e caps |=
    *   GEOD_AREA.
-   * @return \e a12 arc length of between point 1 and point 2 (degrees).
+   * @return \e a12 arc length from point 1 to point 2 (degrees).
    *
    * \e l must have been initialized with a call to geod_lineinit() with \e
    * caps |= GEOD_DISTANCE_IN.  The value \e azi2 returned is in the range
@@ -515,22 +603,21 @@ extern "C" {
    * that the quantity \e lon2 − \e lon1 indicates how many times and in
    * what sense the geodesic encircles the ellipsoid.
    *
-   * Example, compute way points between JFK and Singapore Changi Airport
-   * using geod_genposition().  In this example, the points are evenly space in
-   * arc length (and so only approximately equally space in distance).  This is
-   * faster than using geod_position() would be appropriate if drawing the path
-   * on a map.
+   * Example, compute way points between JFK and Singapore Changi Airport using
+   * geod_genposition().  In this example, the points are evenly space in arc
+   * length (and so only approximately equally spaced in distance).  This is
+   * faster than using geod_position() and would be appropriate if drawing the
+   * path on a map.
    @code{.c}
    struct geod_geodesic g;
    struct geod_geodesicline l;
-   double a12, azi1, lat[101], lon[101];
+   double lat[101], lon[101];
    int i;
    geod_init(&g, 6378137, 1/298.257223563);
-   a12 = geod_geninverse(&g, 40.64, -73.78, 1.36, 103.99,
-                         0, &azi1, 0, 0, 0, 0, 0);
-   geod_lineinit(&l, &g, 40.64, -73.78, azi1, GEOD_LATITUDE | GEOD_LONGITUDE);
-   for (i = 0; i < 101; ++i) {
-     geod_genposition(&l, 1, i * a12 * 0.01,
+   geod_inverseline(&l, &g, 40.64, -73.78, 1.36, 103.99,
+                    GEOD_LATITUDE | GEOD_LONGITUDE);
+   for (i = 0; i <= 100; ++i) {
+     geod_genposition(&l, GEOD_ARCMODE, i * l.a13 * 0.01,
                       lat + i, lon + i, 0, 0, 0, 0, 0, 0);
      printf("%.5f %.5f\n", lat[i], lon[i]);
    }
@@ -544,6 +631,36 @@ extern "C" {
                           double* pS12);
 
   /**
+   * Specify position of point 3 in terms of distance.
+   *
+   * @param[inout] l a pointer to the geod_geodesicline object.
+   * @param[in] s13 the distance from point 1 to point 3 (meters); it
+   *   can be negative.
+   *
+   * This is only useful if the geod_geodesicline object has been constructed
+   * with \e caps |= GEOD_DISTANCE_IN.
+   **********************************************************************/
+  void geod_setdistance(struct geod_geodesicline* l, double s13);
+
+  /**
+   * Specify position of point 3 in terms of either distance or arc length.
+   *
+   * @param[inout] l a pointer to the geod_geodesicline object.
+   * @param[in] flags either GEOD_NOFLAGS or GEOD_ARCMODE to determining the
+   *   meaning of the \e s13_a13.
+   * @param[in] s13_a13 if \e flags = GEOD_NOFLAGS, this is the distance
+   *   from point 1 to point 3 (meters); if \e flags = GEOD_ARCMODE, it is
+   *   the arc length from point 1 to point 3 (degrees); it can be
+   *   negative.
+   *
+   * If flags = GEOD_NOFLAGS, this calls geod_setdistance().  If flags =
+   * GEOD_ARCMODE, the \e s13 is only set if the geod_geodesicline object has
+   * been constructed with \e caps |= GEOD_DISTANCE.
+   **********************************************************************/
+  void geod_gensetdistance(struct geod_geodesicline* l,
+                           unsigned flags, double s13_a13);
+
+  /**
    * Initialize a geod_polygon object.
    *
    * @param[out] p a pointer to the object to be initialized.
@@ -565,6 +682,13 @@ extern "C" {
   void geod_polygon_init(struct geod_polygon* p, int polylinep);
 
   /**
+   * Clear the polygon, allowing a new polygon to be started.
+   *
+   * @param[in,out] p a pointer to the object to be cleared.
+   **********************************************************************/
+  void geod_polygon_clear(struct geod_polygon* p);
+
+  /**
    * Add a point to the polygon or polyline.
    *
    * @param[in] g a pointer to the geod_geodesic object specifying the
@@ -630,6 +754,8 @@ extern "C" {
    * vertex.  Set \e pA or \e pP to zero, if you do not want the corresponding
    * quantity returned.
    *
+   * More points can be added to the polygon after this call.
+   *
    * Example, compute the perimeter and area of the geodesic triangle with
    * vertices (0°N,0°E), (0°N,90°E), (90°N,0°E).
    @code{.c}
@@ -774,10 +900,7 @@ extern "C" {
   enum geod_flags {
     GEOD_NOFLAGS      = 0U,     /**< No flags */
     GEOD_ARCMODE      = 1U<<0,  /**< Position given in terms of arc distance */
-    GEOD_LONG_UNROLL  = 1U<<15, /**< Unroll the longitude */
-    /**< @cond SKIP */
-    GEOD_LONG_NOWRAP  = GEOD_LONG_UNROLL /* For backward compatibility only */
-    /**< @endcond */
+    GEOD_LONG_UNROLL  = 1U<<15  /**< Unroll the longitude */
   };
 
 #if defined(__cplusplus)
diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake
index 8a6349d..7b8ec96 100644
--- a/src/lib_proj.cmake
+++ b/src/lib_proj.cmake
@@ -55,6 +55,7 @@ SET(SRC_LIBPROJ_PJ
         PJ_cea.c
         PJ_chamb.c
         PJ_collg.c
+        PJ_comill.c
         PJ_crast.c
         PJ_denoy.c
         PJ_eck1.c
@@ -88,6 +89,7 @@ SET(SRC_LIBPROJ_PJ
         PJ_lcc.c
         PJ_loxim.c
         PJ_lsat.c
+        PJ_misrsom.c
         PJ_mbt_fps.c
         PJ_mbtfpp.c
         PJ_mbtfpq.c
@@ -96,6 +98,7 @@ SET(SRC_LIBPROJ_PJ
         PJ_mod_ster.c
         PJ_moll.c
         PJ_natearth.c
+        PJ_natearth2.c
         PJ_nell.c
         PJ_nell_h.c
         PJ_nocol.c
@@ -106,6 +109,7 @@ SET(SRC_LIBPROJ_PJ
         PJ_oea.c
         PJ_omerc.c
         PJ_ortho.c
+        PJ_patterson.c
         PJ_poly.c
         PJ_putp2.c
         PJ_putp3.c
@@ -115,6 +119,7 @@ SET(SRC_LIBPROJ_PJ
         PJ_qsc.c
         PJ_robin.c
         PJ_rpoly.c
+        PJ_sch.c
         PJ_sconics.c
         PJ_somerc.c
         PJ_sterea.c
@@ -166,8 +171,10 @@ SET(SRC_LIBPROJ_CORE
         pj_errno.c
         pj_factors.c
         pj_fwd.c
+        pj_fwd3d.c
         pj_gauss.c
         pj_gc_reader.c
+        pj_generic_selftest.c
         pj_geocent.c
         pj_gridcatalog.c
         pj_gridinfo.c
@@ -176,6 +183,7 @@ SET(SRC_LIBPROJ_CORE
         pj_init.c
         pj_initcache.c
         pj_inv.c
+        pj_inv3d.c
         pj_latlong.c
         pj_list.c
         pj_list.h
@@ -190,6 +198,7 @@ SET(SRC_LIBPROJ_CORE
         pj_pr_list.c
         pj_qsfn.c
         pj_release.c
+        pj_run_selftests.c
         pj_strerrno.c
         pj_transform.c
         pj_tsfn.c
@@ -291,15 +300,15 @@ set_target_properties(${PROJ_CORE_TARGET}
 # Link properties
 ##############################################
 set(PROJ_LIBRARIES ${PROJ_CORE_TARGET} )
-if(UNIX AND BUILD_LIBPROJ_SHARED)
+if(UNIX)
     find_library(M_LIB m)
     if(M_LIB)
       TARGET_LINK_LIBRARIES(${PROJ_CORE_TARGET} -lm)
     endif()
-endif(UNIX AND BUILD_LIBPROJ_SHARED)
-if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT AND BUILD_LIBPROJ_SHARED)
+endif(UNIX)
+if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
    TARGET_LINK_LIBRARIES(${PROJ_CORE_TARGET} ${CMAKE_THREAD_LIBS_INIT})
-endif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT AND BUILD_LIBPROJ_SHARED)
+endif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
 
 
 ##############################################
diff --git a/src/makefile.vc b/src/makefile.vc
index 41b7dca..2efad1f 100644
--- a/src/makefile.vc
+++ b/src/makefile.vc
@@ -15,18 +15,18 @@ conic = \
 
 cylinder = \
 	PJ_cass.obj PJ_cc.obj PJ_cea.obj PJ_eqc.obj \
-	PJ_gall.obj PJ_labrd.obj PJ_lsat.obj PJ_merc.obj \
-	PJ_mill.obj PJ_ocea.obj PJ_omerc.obj PJ_somerc.obj \
+	PJ_gall.obj PJ_labrd.obj PJ_lsat.obj PJ_misrsom.obj PJ_merc.obj \
+	PJ_mill.obj PJ_ocea.obj PJ_omerc.obj PJ_patterson.obj PJ_somerc.obj \
 	PJ_tcc.obj PJ_tcea.obj PJ_tmerc.obj PJ_geos.obj \
-	PJ_gstmerc.obj proj_etmerc.obj 
+	PJ_gstmerc.obj proj_etmerc.obj PJ_comill.obj
 
 misc = \
 	PJ_airy.obj PJ_aitoff.obj PJ_august.obj PJ_bacon.obj \
 	PJ_chamb.obj PJ_hammer.obj PJ_lagrng.obj PJ_larr.obj \
 	PJ_lask.obj PJ_nocol.obj PJ_ob_tran.obj PJ_oea.obj \
-	PJ_tpeqd.obj PJ_vandg.obj PJ_vandg2.obj PJ_vandg4.obj \
-	PJ_wag7.obj pj_latlong.obj PJ_krovak.obj pj_geocent.obj \
-	PJ_healpix.obj PJ_natearth.obj PJ_qsc.obj
+	PJ_sch.obj PJ_tpeqd.obj PJ_vandg.obj PJ_vandg2.obj \
+    PJ_vandg4.obj PJ_wag7.obj pj_latlong.obj PJ_krovak.obj \
+    pj_geocent.obj PJ_healpix.obj PJ_qsc.obj
 
 pseudo = \
 	PJ_boggs.obj PJ_collg.obj PJ_crast.obj PJ_denoy.obj \
@@ -38,13 +38,14 @@ pseudo = \
 	PJ_putp4p.obj PJ_putp5.obj PJ_putp6.obj PJ_robin.obj \
 	PJ_sts.obj PJ_urm5.obj PJ_urmfps.obj PJ_wag2.obj \
 	PJ_wag3.obj PJ_wink1.obj PJ_wink2.obj PJ_isea.obj \
-	PJ_calcofi.obj 
+	PJ_calcofi.obj PJ_natearth.obj PJ_natearth2.obj
 
 support = \
 	aasincos.obj adjlon.obj bch2bps.obj bchgen.obj pj_gauss.obj \
 	biveval.obj dmstor.obj mk_cheby.obj pj_auth.obj \
 	pj_deriv.obj pj_ell_set.obj pj_ellps.obj pj_errno.obj \
 	pj_factors.obj pj_fwd.obj pj_init.obj pj_inv.obj \
+    pj_fwd3d.obj pj_inv3d.obj \
 	pj_list.obj pj_malloc.obj pj_mlfn.obj pj_msfn.obj \
 	pj_open_lib.obj pj_param.obj pj_phi2.obj pj_pr_list.obj \
 	pj_qsfn.obj pj_strerrno.obj pj_tsfn.obj pj_units.obj \
@@ -55,7 +56,7 @@ support = \
 	pj_utils.obj pj_gridlist.obj pj_gridinfo.obj \
 	proj_mdist.obj pj_mutex.obj pj_initcache.obj \
 	pj_ctx.obj pj_fileapi.obj pj_log.obj pj_apply_vgridshift.obj \
-	pj_strtod.obj
+	pj_strtod.obj pj_run_selftests.obj pj_generic_selftest.obj
 
 geodesic = geodesic.obj
 LIBOBJ	=	$(support) $(pseudo) $(azimuthal) $(conic) $(cylinder) $(misc) \
@@ -145,4 +146,4 @@ install: all
 	copy proj_api.h $(INSTDIR)\include
 	copy projects.h $(INSTDIR)\include
 	copy geodesic.h $(INSTDIR)\include
-	
+
diff --git a/src/nad2bin.c b/src/nad2bin.c
index 6587c63..59ec165 100644
--- a/src/nad2bin.c
+++ b/src/nad2bin.c
@@ -98,6 +98,7 @@ int main(int argc, char **argv) {
 /*      Read the ASCII Table                                            */
 /* ==================================================================== */
 
+    memset(ct.id,0,MAX_TAB_ID);
     if ( NULL == fgets(ct.id, MAX_TAB_ID, stdin) ) {
         perror("fgets");
         exit(1);
@@ -349,8 +350,8 @@ int main(int argc, char **argv) {
                         + (ct.lim.lam - i - 1);
 
                     /* convert radians to seconds */
-                    row_buf[i*4+0] = cvs->phi * (3600.0 / (PI/180.0));
-                    row_buf[i*4+1] = cvs->lam * (3600.0 / (PI/180.0));
+                    row_buf[i*4+0] = cvs->phi * (3600.0 / (M_PI/180.0));
+                    row_buf[i*4+1] = cvs->lam * (3600.0 / (M_PI/180.0));
 
                     /* We leave the accuracy values as zero */
                 }
diff --git a/src/nad_cvt.c b/src/nad_cvt.c
index 36fe6cb..f48f9e0 100644
--- a/src/nad_cvt.c
+++ b/src/nad_cvt.c
@@ -12,7 +12,7 @@ nad_cvt(LP in, int inverse, struct CTABLE *ct) {
 	tb = in;
 	tb.lam -= ct->ll.lam;
 	tb.phi -= ct->ll.phi;
-	tb.lam = adjlon(tb.lam - PI) + PI;
+	tb.lam = adjlon(tb.lam - M_PI) + M_PI;
 	t = nad_intr(tb, ct);
 	if (inverse) {
 		LP del, dif;
diff --git a/src/pj_apply_vgridshift.c b/src/pj_apply_vgridshift.c
index 7f82d83..297211c 100644
--- a/src/pj_apply_vgridshift.c
+++ b/src/pj_apply_vgridshift.c
@@ -151,7 +151,11 @@ int pj_apply_vgridshift( PJ *defn, const char *listname,
                 + cvs[grid_ix + 1 + (grid_iy+1) * ct->lim.lam] 
                 * (grid_x) * (grid_y);
 
-            if( value == -88.88880f ) /* nodata? */
+            /* nodata?  */
+            /* GTX official nodata value if  -88.88880f, but some grids also */
+            /* use other  big values for nodata (e.g naptrans2008.gtx has */
+            /* nodata values like -2147479936), so test them too */
+            if( value > 1000 || value < -1000 || value == -88.88880f )
                 value = HUGE_VAL;
             else
             {
diff --git a/src/pj_deriv.c b/src/pj_deriv.c
index 7b4ef62..2f88647 100644
--- a/src/pj_deriv.c
+++ b/src/pj_deriv.c
@@ -7,13 +7,13 @@ pj_deriv(LP lp, double h, PJ *P, struct DERIVS *der) {
 
 	lp.lam += h;
 	lp.phi += h;
-	if (fabs(lp.phi) > HALFPI) return 1;
+	if (fabs(lp.phi) > M_HALFPI) return 1;
 	h += h;
 	t = (*P->fwd)(lp, P);
 	if (t.x == HUGE_VAL) return 1;
 	der->x_l = t.x; der->y_p = t.y; der->x_p = -t.x; der->y_l = -t.y;
 	lp.phi -= h;
-	if (fabs(lp.phi) > HALFPI) return 1;
+	if (fabs(lp.phi) > M_HALFPI) return 1;
 	t = (*P->fwd)(lp, P);
 	if (t.x == HUGE_VAL) return 1;
 	der->x_l += t.x; der->y_p -= t.y; der->x_p += t.x; der->y_l -= t.y;
diff --git a/src/pj_ell_set.c b/src/pj_ell_set.c
index af825be..7ca88ed 100644
--- a/src/pj_ell_set.c
+++ b/src/pj_ell_set.c
@@ -77,7 +77,7 @@ pj_ell_set(projCtx ctx, paralist *pl, double *a, double *es) {
 			double tmp;
 
 			tmp = sin(pj_param(ctx,pl, i ? "rR_lat_a" : "rR_lat_g").f);
-			if (fabs(tmp) > HALFPI) {
+			if (fabs(tmp) > M_HALFPI) {
                                 pj_ctx_set_errno(ctx,-11);
 				goto bomb;
 			}
diff --git a/src/pj_factors.c b/src/pj_factors.c
index 6a4db92..f7cb75e 100644
--- a/src/pj_factors.c
+++ b/src/pj_factors.c
@@ -12,7 +12,7 @@ pj_factors(LP lp, PJ *P, double h, struct FACTORS *fac) {
 	double cosphi, t, n, r;
 
 	/* check for forward and latitude or longitude overange */
-	if ((t = fabs(lp.phi)-HALFPI) > EPS || fabs(lp.lam) > 10.) {
+	if ((t = fabs(lp.phi)-M_HALFPI) > EPS || fabs(lp.lam) > 10.) {
                 pj_ctx_set_errno( P->ctx, -14);
 		return 1;
 	} else { /* proceed */
@@ -21,9 +21,9 @@ pj_factors(LP lp, PJ *P, double h, struct FACTORS *fac) {
 
 		if (h < EPS)
 			h = DEFAULT_H;
-		if (fabs(lp.phi) > (HALFPI - h)) 
+		if (fabs(lp.phi) > (M_HALFPI - h)) 
                 /* adjust to value around pi/2 where derived still exists*/
-		        lp.phi = lp.phi < 0. ? (-HALFPI+h) : (HALFPI-h);
+		        lp.phi = lp.phi < 0. ? (-M_HALFPI+h) : (M_HALFPI-h);
 		else if (P->geoc)
 			lp.phi = atan(P->rone_es * tan(lp.phi));
 		lp.lam -= P->lam0;	/* compute del lp.lam */
diff --git a/src/pj_fwd.c b/src/pj_fwd.c
index b70b424..469e9a4 100644
--- a/src/pj_fwd.c
+++ b/src/pj_fwd.c
@@ -9,7 +9,7 @@ pj_fwd(LP lp, PJ *P) {
 	double t;
 
 	/* check for forward and latitude or longitude overange */
-	if ((t = fabs(lp.phi)-HALFPI) > EPS || fabs(lp.lam) > 10.) {
+	if ((t = fabs(lp.phi)-M_HALFPI) > EPS || fabs(lp.lam) > 10.) {
 		xy.x = xy.y = HUGE_VAL;
 		pj_ctx_set_errno( P->ctx, -14);
 	} else { /* proceed with projection */
@@ -18,20 +18,29 @@ pj_fwd(LP lp, PJ *P) {
                 errno = 0;
 
 		if (fabs(t) <= EPS)
-			lp.phi = lp.phi < 0. ? -HALFPI : HALFPI;
+			lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
 		else if (P->geoc)
 			lp.phi = atan(P->rone_es * tan(lp.phi));
 		lp.lam -= P->lam0;	/* compute del lp.lam */
 		if (!P->over)
 			lp.lam = adjlon(lp.lam); /* adjust del longitude */
-		xy = (*P->fwd)(lp, P); /* project */
-		if ( P->ctx->last_errno )
+
+                /* Check for NULL pointer */
+                if (P->fwd != NULL)
+                {
+		    xy = (*P->fwd)(lp, P); /* project */
+		    if ( P->ctx->last_errno )
 			xy.x = xy.y = HUGE_VAL;
-		/* adjust for major axis and easting/northings */
-		else {
+		    /* adjust for major axis and easting/northings */
+		    else {
 			xy.x = P->fr_meter * (P->a * xy.x + P->x0);
 			xy.y = P->fr_meter * (P->a * xy.y + P->y0);
-		}
+		    }
+                }
+                else
+                {
+                    xy.x = xy.y = HUGE_VAL;
+                }
 	}
 	return xy;
 }
diff --git a/src/pj_fwd3d.c b/src/pj_fwd3d.c
new file mode 100644
index 0000000..63fc529
--- /dev/null
+++ b/src/pj_fwd3d.c
@@ -0,0 +1,47 @@
+/* general forward projection */
+#define PJ_LIB__
+#include <projects.h>
+#include <errno.h>
+# define EPS 1.0e-12
+	XYZ /* forward projection entry */
+pj_fwd3d(LPZ lpz, PJ *P) {
+	XYZ xyz;
+	double t;
+
+	/* check for forward and latitude or longitude overange */
+	if ((t = fabs(lpz.phi)-M_HALFPI) > EPS || fabs(lpz.lam) > 10.) {
+		xyz.x = xyz.y = xyz.z = HUGE_VAL;
+		pj_ctx_set_errno( P->ctx, -14);
+	} else { /* proceed with projection */
+                P->ctx->last_errno = 0;
+                pj_errno = 0;
+                errno = 0;
+
+		if (fabs(t) <= EPS)
+			lpz.phi = lpz.phi < 0. ? -M_HALFPI : M_HALFPI;
+		else if (P->geoc)   /* Maybe redundant and never used. */
+			lpz.phi = atan(P->rone_es * tan(lpz.phi));
+		lpz.lam -= P->lam0;	/* compute del lp.lam */
+		if (!P->over)
+			lpz.lam = adjlon(lpz.lam); /* adjust del longitude */
+
+                /* Check for NULL pointer */
+                if (P->fwd3d != NULL)
+                {
+		    xyz = (*P->fwd3d)(lpz, P); /* project */
+		    if ( P->ctx->last_errno )
+			xyz.x = xyz.y = xyz.z = HUGE_VAL;
+		    /* adjust for major axis and easting/northings */
+		    else {
+			xyz.x = P->fr_meter * (P->a * xyz.x + P->x0);
+			xyz.y = P->fr_meter * (P->a * xyz.y + P->y0);
+                        /* z is not scaled since this handled by vto_meter outside */
+		    }
+                }
+                else
+                {
+                    xyz.x = xyz.y = xyz.z = HUGE_VAL;
+                }
+	}
+	return xyz;
+}
diff --git a/src/pj_gauss.c b/src/pj_gauss.c
index b4b965f..67a1ab0 100644
--- a/src/pj_gauss.c
+++ b/src/pj_gauss.c
@@ -56,8 +56,8 @@ pj_gauss_ini(double e, double phi0, double *chi, double *rc) {
 	EN->C = sqrt(1. + es * cphi * cphi / (1. - es));
 	*chi = asin(sphi / EN->C);
 	EN->ratexp = 0.5 * EN->C * e;
-	EN->K = tan(.5 * *chi + FORTPI) / (
-		pow(tan(.5 * phi0 + FORTPI), EN->C) *
+	EN->K = tan(.5 * *chi + M_FORTPI) / (
+		pow(tan(.5 * phi0 + M_FORTPI), EN->C) *
 		srat(EN->e * sphi, EN->ratexp)  );
 	return ((void *)en);
 }
@@ -67,8 +67,8 @@ pj_gauss(projCtx ctx, LP elp, const void *en) {
 	(void) ctx;
 
 	slp.phi = 2. * atan( EN->K *
-		pow(tan(.5 * elp.phi + FORTPI), EN->C) *
-		srat(EN->e * sin(elp.phi), EN->ratexp) ) - HALFPI;
+		pow(tan(.5 * elp.phi + M_FORTPI), EN->C) *
+		srat(EN->e * sin(elp.phi), EN->ratexp) ) - M_HALFPI;
 	slp.lam = EN->C * (elp.lam);
 	return(slp);
 }
@@ -79,10 +79,10 @@ pj_inv_gauss(projCtx ctx, LP slp, const void *en) {
 	int i;
 
 	elp.lam = slp.lam / EN->C;
-	num = pow(tan(.5 * slp.phi + FORTPI)/EN->K, 1./EN->C);
+	num = pow(tan(.5 * slp.phi + M_FORTPI)/EN->K, 1./EN->C);
 	for (i = MAX_ITER; i; --i) {
 		elp.phi = 2. * atan(num * srat(EN->e * sin(slp.phi), -.5 * EN->e))
-			- HALFPI;
+			- M_HALFPI;
 		if (fabs(elp.phi - slp.phi) < DEL_TOL) break;
 			slp.phi = elp.phi;
 	}	
diff --git a/src/pj_generic_selftest.c b/src/pj_generic_selftest.c
new file mode 100644
index 0000000..88b5c30
--- /dev/null
+++ b/src/pj_generic_selftest.c
@@ -0,0 +1,197 @@
+/******************************************************************************
+ * Project:  PROJ.4
+ * Purpose:  Generic regression test for PROJ.4 projection algorithms.
+ * Author:   Thomas Knudsen
+ *
+ ******************************************************************************
+ * Copyright (c) 2016, Thomas Knudsen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *****************************************************************************/
+
+
+#include <stdio.h>
+#define PJ_LIB__
+#include <projects.h>
+
+
+static int deviates_xy (XY expected, XY got, double tolerance);
+static int deviates_lp (LP expected, LP got, double tolerance);
+static XY pj_fwd_deg (LP in, PJ *P);
+
+
+/**********************************************************************/
+int pj_generic_selftest (
+/**********************************************************************/
+    char *e_args,
+    char *s_args,
+    double tolerance_xy,
+    double tolerance_lp,
+    int n_fwd,
+    int n_inv,
+    LP *fwd_in,
+    XY *e_fwd_expect,
+    XY *s_fwd_expect,
+    XY *inv_in,
+    LP *e_inv_expect,
+    LP *s_inv_expect
+) {
+/***********************************************************************
+
+Generic regression test for PROJ.4 projection algorithms, testing both
+ellipsoidal ("e_") and spheroidal ("s_") versions of the projection
+algorithms in both forward ("_fwd_") and inverse ("_inv_") mode.
+
+Compares the "known good" results in <e_fwd_expect> and <s_fwd_expect>
+with the actual results obtained by transforming the forward input data
+set in <fwd_in> with pj_fwd() using setup arguments <e_args> and
+<s_args>, respectively.
+
+Then
+
+Compares the "known good" results in <e_inv_expect> and <s_inv_expect>
+with the actual results obtained by transforming the inverse input data
+set in <inv_in> with pj_inv() using setup arguments <e_args> and
+<s_args>, respectively.
+
+Any of the pointers passed may be set to 0, indicating "don't test this
+part".
+
+Returns 0 if all data agree to within the accuracy specified in
+<tolerance_xy> and <tolerance_lp>. Non-zero otherwise.
+
+***********************************************************************/
+    int i;
+
+    PJ *P;
+
+    if (e_args) {
+        P = pj_init_plus(e_args);
+        if (0==P)
+            return 2;
+
+        /* Test forward ellipsoidal */
+        if (e_fwd_expect) {
+            for (i = 0; i < n_fwd; i++)
+                if (deviates_xy (e_fwd_expect[i], pj_fwd_deg ( fwd_in[i], P ), tolerance_xy))
+                    break;
+            if ( i != n_fwd )
+                return 100 + i;
+        }
+
+        /* Test inverse ellipsoidal */
+        if (e_inv_expect)  {
+            for (i = 0; i < n_inv; i++)
+                if (deviates_lp (e_inv_expect[i], pj_inv ( inv_in[i], P ), tolerance_lp))
+                    break;
+            if ( i != n_inv )
+                return 200 + i;
+        }
+
+        pj_free (P);
+    }
+
+
+    if (s_args) {
+        P = pj_init_plus(s_args);
+        if (0==P)
+            return 3;
+
+        /* Test forward spherical */
+        if (s_fwd_expect)  {
+            for (i = 0; i < n_fwd; i++)
+                if (deviates_xy (s_fwd_expect[i], pj_fwd_deg ( fwd_in[i], P ), tolerance_xy))
+                    break;
+            if ( i != n_fwd )
+                return 300 + i;
+        }
+
+        /* Test inverse spherical */
+        if (s_inv_expect)  {
+            for (i = 0; i < n_inv; i++)
+                if (deviates_lp (s_inv_expect[i], pj_inv ( inv_in[i], P ), tolerance_lp))
+                    break;
+            if ( i != n_inv )
+                return 400 + i;
+        }
+
+        pj_free (P);
+    }
+
+    return 0;
+}
+
+
+
+/**********************************************************************/
+static int deviates_xy (XY expected, XY got, double tolerance) {
+/***********************************************************************
+
+    Determine whether two XYs deviate by more than <tolerance>.
+
+    The test material ("expected" values) may contain coordinates that
+    are indeterminate. For those cases, we test the other coordinate
+    only by forcing expected and actual ("got") coordinates to 0.
+
+***********************************************************************/
+    if (HUGE_VAL== expected.x)
+        return 0;
+    if (HUGE_VAL== expected.y)
+        return 0;
+    if (hypot ( expected.x - got.x, expected.y - got.y ) > tolerance)
+        return 1;
+    return 0;
+}
+
+
+/**********************************************************************/
+static int deviates_lp (LP expected, LP got, double tolerance) {
+/***********************************************************************
+
+    Determine whether two LPs deviate by more than <tolerance>.
+
+    This one is slightly tricky, since the <expected> LP is
+    supposed to be represented as degrees (since it was at some
+    time written down by a real human), whereas the <got> LP is
+    represented in radians (since it is supposed to be the result
+    output from pj_inv)
+
+***********************************************************************/
+    if (HUGE_VAL== expected.lam)
+        return 0;
+    if (HUGE_VAL== expected.phi)
+        return 0;
+    if (hypot ( DEG_TO_RAD * expected.lam - got.lam, DEG_TO_RAD * expected.phi - got.phi ) > tolerance)
+        return 1;
+    return 0;
+}
+
+
+/**********************************************************************/
+static XY pj_fwd_deg (LP in, PJ *P) {
+/***********************************************************************
+
+    Wrapper for pj_fwd, accepting input in degrees.
+
+***********************************************************************/
+    LP in_rad;
+    in_rad.lam = DEG_TO_RAD * in.lam;
+    in_rad.phi = DEG_TO_RAD * in.phi;
+    return  pj_fwd (in_rad, P);
+}
diff --git a/src/pj_geocent.c b/src/pj_geocent.c
index 6b2f302..fa01b01 100644
--- a/src/pj_geocent.c
+++ b/src/pj_geocent.c
@@ -32,24 +32,88 @@
 
 PROJ_HEAD(geocent, "Geocentric")  "\n\t";
 
-FORWARD(forward);
-	(void) P;
-        xy.x = lp.lam;
-        xy.y = lp.phi;
-        return xy;
+static XY forward(LP lp, PJ *P) {
+    XY xy = {0.0,0.0};
+    (void) P;
+    xy.x = lp.lam;
+    xy.y = lp.phi;
+    return xy;
 }
-INVERSE(inverse);
-	(void) P;
-        lp.phi = xy.y;
-        lp.lam = xy.x;
-        return lp;
+
+static LP inverse(XY xy, PJ *P) {
+    LP lp = {0.0,0.0};
+    (void) P;
+    lp.phi = xy.y;
+    lp.lam = xy.x;
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
 }
-FREEUP; if (P) pj_dalloc(P); }
 
-ENTRY0(geocent)
-    P->is_geocent = 1; 
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
+
+PJ *PROJECTION(geocent) {
+    P->is_geocent = 1;
     P->x0 = 0.0;
     P->y0 = 0.0;
-    P->inv = inverse; P->fwd = forward;
-ENDENTRY(P)
+    P->inv = inverse;
+    P->fwd = forward;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_geocent_selftest (void) {return 0;}
+#else
+
+int pj_geocent_selftest (void) {
+
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=geocent   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+    char s_args[] = {"+proj=geocent   +a=6400000    +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222638.98158654713,  111319.49079327357},
+        { 222638.98158654713, -111319.49079327357},
+        {-222638.98158654713,  111319.49079327357},
+        {-222638.98158654713, -111319.49079327357},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017966305682390426,  0.00089831528411952132},
+        { 0.0017966305682390426, -0.00089831528411952132},
+        {-0.0017966305682390426,  0.00089831528411952132},
+        {-0.0017966305682390426, -0.00089831528411952132},
+    };
+
+    return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
+
+#endif
 
diff --git a/src/pj_gridinfo.c b/src/pj_gridinfo.c
index 3d34dd7..48ef7b8 100644
--- a/src/pj_gridinfo.c
+++ b/src/pj_gridinfo.c
@@ -244,8 +244,8 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi )
                 cvs = ct_tmp.cvs + (row) * gi->ct->lim.lam
                     + (gi->ct->lim.lam - i - 1);
 
-                cvs->phi = *(diff_seconds++) * ((PI/180.0) / 3600.0);
-                cvs->lam = *(diff_seconds++) * ((PI/180.0) / 3600.0);
+                cvs->phi = *(diff_seconds++) * ((M_PI/180.0) / 3600.0);
+                cvs->lam = *(diff_seconds++) * ((M_PI/180.0) / 3600.0);
             }
         }
 
@@ -312,7 +312,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi )
                 return 0;
             }
 
-            if( !IS_LSB )
+            if( gi->must_swap )
                 swap_words( (unsigned char *) row_buf, 4,
                             gi->ct->lim.lam*4 );
 
@@ -324,8 +324,8 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi )
                 cvs = ct_tmp.cvs + (row) * gi->ct->lim.lam
                     + (gi->ct->lim.lam - i - 1);
 
-                cvs->phi = *(diff_seconds++) * ((PI/180.0) / 3600.0);
-                cvs->lam = *(diff_seconds++) * ((PI/180.0) / 3600.0);
+                cvs->phi = *(diff_seconds++) * ((M_PI/180.0) / 3600.0);
+                cvs->lam = *(diff_seconds++) * ((M_PI/180.0) / 3600.0);
                 diff_seconds += 2; /* skip accuracy values */
             }
         }
@@ -392,12 +392,12 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi )
 }
 
 /************************************************************************/
-/*                       pj_gridinfo_init_ntv2()                        */
+/*                        pj_gridinfo_parent()                          */
 /*                                                                      */
 /*      Seek a parent grid file by name from a grid list                */
 /************************************************************************/
 
-static PJ_GRIDINFO* pj_gridinfo_parent( PJ_GRIDINFO *gilist, 
+static PJ_GRIDINFO* pj_gridinfo_parent( PJ_GRIDINFO *gilist,
         const char *name, int length )
 {
     while( gilist )
@@ -423,6 +423,7 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist )
 {
     unsigned char header[11*16];
     int num_subfiles, subfile;
+    int must_swap;
 
     assert( sizeof(int) == 4 );
     assert( sizeof(double) == 8 );
@@ -442,11 +443,16 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist )
         pj_ctx_set_errno( ctx, -38 );
         return 0;
     }
+    
+    if( header[8] == 11 )
+        must_swap = !IS_LSB;
+    else
+        must_swap = IS_LSB;
 
 /* -------------------------------------------------------------------- */
 /*      Byte swap interesting fields if needed.                         */
 /* -------------------------------------------------------------------- */
-    if( !IS_LSB )
+    if( must_swap )
     {
         swap_words( header+8, 4, 1 );
         swap_words( header+8+16, 4, 1 );
@@ -490,7 +496,7 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist )
 /* -------------------------------------------------------------------- */
 /*      Byte swap interesting fields if needed.                         */
 /* -------------------------------------------------------------------- */
-        if( !IS_LSB )
+        if( must_swap )
         {
             swap_words( header+8+16*4, 8, 1 );
             swap_words( header+8+16*5, 8, 1 );
@@ -561,6 +567,7 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist )
             gi->next = NULL;
         }
 
+        gi->must_swap = must_swap;
         gi->ct = ct;
         gi->format = "ntv2";
         gi->grid_offset = pj_ctx_ftell( ctx, fid );
@@ -858,9 +865,8 @@ PJ_GRIDINFO *pj_gridinfo_init( projCtx ctx, const char *gridname )
 /* -------------------------------------------------------------------- */
     if( pj_ctx_fread( ctx, header, sizeof(header), 1, fp ) != 1 )
     {
-        pj_ctx_fclose( ctx, fp );
-        pj_ctx_set_errno( ctx, -38 );
-        return gilist;
+        /* some files may be smaller that sizeof(header), eg 160, so */
+        ctx->last_errno = 0; /* don't treat as a persistent error */
     }
 
     pj_ctx_fseek( ctx, fp, SEEK_SET, 0 );
diff --git a/src/pj_gridlist.c b/src/pj_gridlist.c
index 0cfab76..a54dbe6 100644
--- a/src/pj_gridlist.c
+++ b/src/pj_gridlist.c
@@ -43,6 +43,7 @@
 #endif /* _WIN32_WCE */
 
 static PJ_GRIDINFO *grid_list = NULL;
+#define PJ_MAX_PATH_LENGTH 1024
 
 /************************************************************************/
 /*                        pj_deallocate_grids()                         */
@@ -177,8 +178,8 @@ PJ_GRIDINFO **pj_gridlist_from_nadgrids( projCtx ctx, const char *nadgrids,
     for( s = nadgrids; *s != '\0'; )
     {
         size_t end_char;
-        int   required = 1;
-        char  name[128];
+        int    required = 1;
+        char   name[PJ_MAX_PATH_LENGTH];
 
         if( *s == '@' )
         {
diff --git a/src/pj_init.c b/src/pj_init.c
index 13d469d..79b64bb 100644
--- a/src/pj_init.c
+++ b/src/pj_init.c
@@ -110,7 +110,7 @@ get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next,
     *sword = 't';
 
     /* loop till we find our target keyword */
-    while (*next_char) 
+    while (*next_char)
     {
         next_char = fill_buffer(state, next_char);
 
@@ -119,9 +119,9 @@ get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next,
             next_char++;
 
         next_char = fill_buffer(state, next_char);
-        
+
         /* for comments, skip past end of line. */
-        if( *next_char == '#' ) 
+        if( *next_char == '#' )
         {
             while( *next_char && *next_char != '\n' )
                 next_char++;
@@ -131,11 +131,11 @@ get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next,
                 next_char++;
             if (*next_char == '\r')
                 next_char++;
-            
-        } 
+
+        }
 
         /* Is this our target? */
-        else if( *next_char == '<' ) 
+        else if( *next_char == '<' )
         {
             /* terminate processing target on the next block definition */
             if (in_target)
@@ -143,7 +143,7 @@ get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next,
 
             next_char++;
             if (strncmp(name, next_char, len) == 0
-                && next_char[len] == '>') 
+                && next_char[len] == '>')
             {
                 /* skip past target word */
                 next_char += len + 1;
@@ -151,14 +151,14 @@ get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next,
                 if(found_def)
                     *found_def = 1;
             }
-            else 
+            else
             {
                 /* skip past end of line */
                 while( *next_char && *next_char != '\n' )
                     next_char++;
             }
         }
-        else if (in_target) 
+        else if (in_target)
         {
             const char *start_of_word = next_char;
             int word_len = 0;
@@ -183,27 +183,27 @@ get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next,
             if (!pj_param(ctx, *start, sword).i) {
                 /* don't default ellipse if datum, ellps or any earth model
                    information is set. */
-                if( strncmp(sword+1,"ellps=",6) != 0 
-                    || (!pj_param(ctx, *start, "tdatum").i 
-                        && !pj_param(ctx, *start, "tellps").i 
-                        && !pj_param(ctx, *start, "ta").i 
-                        && !pj_param(ctx, *start, "tb").i 
-                        && !pj_param(ctx, *start, "trf").i 
+                if( strncmp(sword+1,"ellps=",6) != 0
+                    || (!pj_param(ctx, *start, "tdatum").i
+                        && !pj_param(ctx, *start, "tellps").i
+                        && !pj_param(ctx, *start, "ta").i
+                        && !pj_param(ctx, *start, "tb").i
+                        && !pj_param(ctx, *start, "trf").i
                         && !pj_param(ctx, *start, "tf").i) )
                 {
                     next = next->next = pj_mkparam(sword+1);
                 }
             }
-            
+
         }
-        else 
+        else
         {
             /* skip past word */
             while( *next_char && !isspace(*next_char) )
                 next_char++;
-            
+
         }
-    }        
+    }
 
     if (errno == 25)
         errno = 0;
@@ -229,7 +229,7 @@ get_defaults(projCtx ctx, paralist **start, paralist *next, char *name) {
     if (errno)
         errno = 0; /* don't care if can't open file */
     ctx->last_errno = 0;
-    
+
     return next;
 }
 
@@ -245,11 +245,11 @@ get_init(projCtx ctx, paralist **start, paralist *next, char *name,
     const paralist *orig_next = next;
 
     (void)strncpy(fname, name, MAX_PATH_FILENAME + ID_TAG_MAX + 1);
-	
-    /* 
-    ** Search for file/key pair in cache 
+
+    /*
+    ** Search for file/key pair in cache
     */
-	
+
     init_items = pj_search_initcache( name );
     if( init_items != NULL )
     {
@@ -275,8 +275,8 @@ get_init(projCtx ctx, paralist **start, paralist *next, char *name,
     if (errno == 25)
         errno = 0; /* unknown problem with some sys errno<-25 */
 
-    /* 
-    ** If we seem to have gotten a result, insert it into the 
+    /*
+    ** If we seem to have gotten a result, insert it into the
     ** init file cache.
     */
     if( next != NULL && next != orig_next )
@@ -308,7 +308,7 @@ pj_init_plus_ctx( projCtx ctx, const char *definition )
     char	*defn_copy;
     int		argc = 0, i, blank_count = 0;
     PJ	    *result = NULL;
-    
+
     /* make a copy that we can manipulate */
     defn_copy = (char *) pj_malloc( strlen(definition)+1 );
     strcpy( defn_copy, definition );
@@ -328,13 +328,13 @@ pj_init_plus_ctx( projCtx ctx, const char *definition )
                     defn_copy[i - blank_count] = '\0';
                     blank_count = 0;
                 }
-                
+
                 if( argc+1 == MAX_ARG )
                 {
                     pj_ctx_set_errno( ctx, -44 );
                     goto bum_call;
                 }
-                
+
                 argv[argc++] = defn_copy + i + 1;
             }
             break;
@@ -455,7 +455,7 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
     PIN->rone_es = 1./PIN->one_es;
 
     /* Now that we have ellipse information check for WGS84 datum */
-    if( PIN->datum_type == PJD_3PARAM 
+    if( PIN->datum_type == PJD_3PARAM
         && PIN->datum_params[0] == 0.0
         && PIN->datum_params[1] == 0.0
         && PIN->datum_params[2] == 0.0
@@ -464,7 +464,7 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
     {
         PIN->datum_type = PJD_WGS84;
     }
-        
+
     /* set PIN->geoc coordinate system */
     PIN->geoc = (PIN->es && pj_param(ctx, start, "bgeoc").i);
 
@@ -532,7 +532,7 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
 
     /* set units */
     s = 0;
-    if ((name = pj_param(ctx, start, "sunits").s) != NULL) { 
+    if ((name = pj_param(ctx, start, "sunits").s) != NULL) {
         for (i = 0; (s = pj_units[i].id) && strcmp(name, s) ; ++i) ;
         if (!s) { pj_ctx_set_errno( ctx, -7 ); goto bum_call; }
         s = pj_units[i].to_meter;
@@ -547,7 +547,7 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
 
     /* set vertical units */
     s = 0;
-    if ((name = pj_param(ctx, start, "svunits").s) != NULL) { 
+    if ((name = pj_param(ctx, start, "svunits").s) != NULL) {
         for (i = 0; (s = pj_units[i].id) && strcmp(name, s) ; ++i) ;
         if (!s) { pj_ctx_set_errno( ctx, -7 ); goto bum_call; }
         s = pj_units[i].to_meter;
@@ -564,7 +564,7 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
 
     /* prime meridian */
     s = 0;
-    if ((name = pj_param(ctx, start, "spm").s) != NULL) { 
+    if ((name = pj_param(ctx, start, "spm").s) != NULL) {
         const char *value = NULL;
         char *next_str = NULL;
 
@@ -576,8 +576,8 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
                 break;
             }
         }
-            
-        if( value == NULL 
+
+        if( value == NULL
             && (dmstor_ctx(ctx,name,&next_str) != 0.0  || *name == '0')
             && *next_str == '\0' )
             value = name;
@@ -639,3 +639,27 @@ pj_free(PJ *P) {
         P->pfree(P);
     }
 }
+
+
+
+
+
+
+
+
+/************************************************************************/
+/*                              pj_prepare()                            */
+/*                                                                      */
+/*      Helper function for the PJ_xxxx functions providing the         */
+/*      projection specific setup for each projection type.             */
+/*                                                                      */
+/*      Currently not used, but placed here as part of the  material    */
+/*      Demonstrating the idea for a future PJ_xxx architecture         */
+/*      (cf. pj_minimal.c)                                              */
+/*                                                                      */
+/************************************************************************/
+void pj_prepare (PJ *P, const char *description, void (*freeup)(struct PJconsts *), size_t sizeof_struct_opaque) {
+    P->descr = description;
+    P->pfree = freeup;
+    P->opaque  = pj_calloc (1, sizeof_struct_opaque);
+}
diff --git a/src/pj_inv.c b/src/pj_inv.c
index a418ccd..9a34176 100644
--- a/src/pj_inv.c
+++ b/src/pj_inv.c
@@ -19,15 +19,24 @@ pj_inv(XY xy, PJ *P) {
 
 	xy.x = (xy.x * P->to_meter - P->x0) * P->ra; /* descale and de-offset */
 	xy.y = (xy.y * P->to_meter - P->y0) * P->ra;
-	lp = (*P->inv)(xy, P); /* inverse project */
-	if (P->ctx->last_errno )
+
+        /* Check for NULL pointer */
+        if (P->inv != NULL)
+        {
+	    lp = (*P->inv)(xy, P); /* inverse project */
+	    if (P->ctx->last_errno )
 		lp.lam = lp.phi = HUGE_VAL;
-	else {
+	    else {
 		lp.lam += P->lam0; /* reduce from del lp.lam */
 		if (!P->over)
 			lp.lam = adjlon(lp.lam); /* adjust longitude to CM */
-		if (P->geoc && fabs(fabs(lp.phi)-HALFPI) > EPS)
+		if (P->geoc && fabs(fabs(lp.phi)-M_HALFPI) > EPS)
 			lp.phi = atan(P->one_es * tan(lp.phi));
-	}
+	    }
+        }
+        else
+        {
+           lp.lam = lp.phi = HUGE_VAL;
+        }
 	return lp;
 }
diff --git a/src/pj_inv3d.c b/src/pj_inv3d.c
new file mode 100644
index 0000000..bf6a932
--- /dev/null
+++ b/src/pj_inv3d.c
@@ -0,0 +1,45 @@
+/* general inverse projection */
+#define PJ_LIB__
+#include <projects.h>
+#include <errno.h>
+# define EPS 1.0e-12
+	LPZ /* inverse projection entry */
+pj_inv3d(XYZ xyz, PJ *P) {
+	LPZ lpz;
+
+	/* can't do as much preliminary checking as with forward */
+	if (xyz.x == HUGE_VAL || xyz.y == HUGE_VAL || xyz.z == HUGE_VAL ) {
+		lpz.lam = lpz.phi = lpz.z = HUGE_VAL;
+		pj_ctx_set_errno( P->ctx, -15);
+                return lpz;
+	}
+
+	errno = pj_errno = 0;
+        P->ctx->last_errno = 0;
+
+	xyz.x = (xyz.x * P->to_meter - P->x0) * P->ra; /* descale and de-offset */
+	xyz.y = (xyz.y * P->to_meter - P->y0) * P->ra;
+        /* z is not scaled since that is handled by vto_meter before we get here */
+
+        /* Check for NULL pointer */
+        if (P->inv3d != NULL)
+        {
+	    lpz = (*P->inv3d)(xyz, P); /* inverse project */
+	    if (P->ctx->last_errno )
+		lpz.lam = lpz.phi = lpz.z = HUGE_VAL;
+	    else {
+		lpz.lam += P->lam0; /* reduce from del lp.lam */
+		if (!P->over)
+			lpz.lam = adjlon(lpz.lam); /* adjust longitude to CM */
+
+                /* This may be redundant and never used */
+		if (P->geoc && fabs(fabs(lpz.phi)-M_HALFPI) > EPS)
+			lpz.phi = atan(P->one_es * tan(lpz.phi));
+	    }
+        }
+        else
+        {
+            lpz.lam = lpz.phi = lpz.z = HUGE_VAL;
+        }
+	return lpz;
+}
diff --git a/src/pj_latlong.c b/src/pj_latlong.c
index b7a771a..761eadc 100644
--- a/src/pj_latlong.c
+++ b/src/pj_latlong.c
@@ -29,50 +29,94 @@
 
 /* very loosely based upon DMA code by Bradford W. Drew */
 #define PJ_LIB__
-#include	<projects.h>
+#include <projects.h>
+
 PROJ_HEAD(lonlat, "Lat/long (Geodetic)")  "\n\t";
 PROJ_HEAD(latlon, "Lat/long (Geodetic alias)")  "\n\t";
 PROJ_HEAD(latlong, "Lat/long (Geodetic alias)")  "\n\t";
 PROJ_HEAD(longlat, "Lat/long (Geodetic alias)")  "\n\t";
 
-FORWARD(forward);
 
-        xy.x = lp.lam / P->a;
-        xy.y = lp.phi / P->a;
-        return xy;
+ static XY forward(LP lp, PJ *P) {
+    XY xy = {0.0,0.0};
+    xy.x = lp.lam / P->a;
+    xy.y = lp.phi / P->a;
+    return xy;
+}
+
+
+static LP inverse(XY xy, PJ *P) {
+    LP lp = {0.0,0.0};
+    lp.phi = xy.y * P->a;
+    lp.lam = xy.x * P->a;
+    return lp;
+}
+
+
+static void *freeup_new (PJ *P) {
+    if (0==P)
+        return 0;
+
+    return pj_dealloc(P);
 }
-INVERSE(inverse);
 
-        lp.phi = xy.y * P->a;
-        lp.lam = xy.x * P->a;
-        return lp;
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-FREEUP; if (P) pj_dalloc(P); }
-
-ENTRY0(latlong)
-        P->is_latlong = 1;
-        P->x0 = 0.0;
-        P->y0 = 0.0;
-	P->inv = inverse; P->fwd = forward;
-ENDENTRY(P)
-
-ENTRY0(longlat)
-        P->is_latlong = 1;
-        P->x0 = 0.0;
-        P->y0 = 0.0;
-	P->inv = inverse; P->fwd = forward;
-ENDENTRY(P)
-
-ENTRY0(latlon)
-        P->is_latlong = 1;
-        P->x0 = 0.0;
-        P->y0 = 0.0;
-	P->inv = inverse; P->fwd = forward;
-ENDENTRY(P)
-
-ENTRY0(lonlat)
-        P->is_latlong = 1;
-        P->x0 = 0.0;
-        P->y0 = 0.0;
-	P->inv = inverse; P->fwd = forward;
-ENDENTRY(P)
+
+
+PJ *PROJECTION(latlong) {
+    P->is_latlong = 1;
+    P->x0 = 0.0;
+    P->y0 = 0.0;
+    P->inv = inverse;
+    P->fwd = forward;
+
+    return P;
+}
+
+
+PJ *PROJECTION(longlat) {
+    P->is_latlong = 1;
+    P->x0 = 0.0;
+    P->y0 = 0.0;
+    P->inv = inverse;
+    P->fwd = forward;
+
+    return P;
+}
+
+
+PJ *PROJECTION(latlon) {
+    P->is_latlong = 1;
+    P->x0 = 0.0;
+    P->y0 = 0.0;
+    P->inv = inverse;
+    P->fwd = forward;
+
+    return P;
+}
+
+
+PJ *PROJECTION(lonlat) {
+    P->is_latlong = 1;
+    P->x0 = 0.0;
+    P->y0 = 0.0;
+    P->inv = inverse; P->fwd = forward;
+
+    return P;
+}
+
+
+/* Bogus self-test functions. Self-tests can't be implemented the usual way for
+ * these "projections" since they can't be used directly from proj.
+ * We still need them though, as all projections are automatically added to
+ * the list of self-test functions.
+ *
+ * The code should be covered by the tests in nad/.
+ * */
+int pj_latlong_selftest (void) {return 0;}
+int pj_longlat_selftest (void) {return 0;}
+int pj_latlon_selftest (void) {return 0;}
+int pj_lonlat_selftest (void) {return 0;}
diff --git a/src/pj_list.c b/src/pj_list.c
index bb56ade..a8f171a 100644
--- a/src/pj_list.c
+++ b/src/pj_list.c
@@ -1,11 +1,56 @@
 /* Projection System: default list of projections
 ** Use local definition of PJ_LIST_H for subset.
 */
+
 #define USE_PJ_LIST_H 1
 #include "projects.h"
 
-struct PJ_LIST  *pj_get_list_ref()
 
-{
+
+#define PASTE(a,b) a##b
+
+/* Generate prototypes for projection functions */
+#define PROJ_HEAD(id, name) struct PJconsts *pj_##id(struct PJconsts*);
+#include "pj_list.h"
+#undef PROJ_HEAD
+
+/* Generate prototypes for projection selftest functions */
+#define PROJ_HEAD(id, name) int PASTE(pj_##id, _selftest) (void);
+#include "pj_list.h"
+#undef PROJ_HEAD
+
+
+/* Generate extern declarations for description strings */
+#define PROJ_HEAD(id, name) extern char * const pj_s_##id;
+#include "pj_list.h"
+#undef PROJ_HEAD
+
+
+/* Generate the null-terminated list of projection functions with associated mnemonics and descriptions */
+#define PROJ_HEAD(id, name) {#id, pj_##id, &pj_s_##id},
+struct PJ_LIST pj_list[] = {
+#include "pj_list.h"
+		{0,     0,  0},
+	};
+#undef PROJ_HEAD
+
+
+/* Generate the null-terminated list of projection selftest functions with associated mnemonics */
+#define PROJ_HEAD(id, name) {#id, PASTE(pj_##id, _selftest)},
+struct PJ_SELFTEST_LIST pj_selftest_list[] = {
+#include "pj_list.h"
+		{0,     0},
+	};
+#undef PROJ_HEAD
+#undef PASTE
+
+
+struct PJ_LIST  *pj_get_list_ref (void) {
     return pj_list;
 }
+
+
+struct PJ_SELFTEST_LIST  *pj_get_selftest_list_ref (void) {
+    return pj_selftest_list;
+}
+
diff --git a/src/pj_list.h b/src/pj_list.h
index 194bcc6..baacacc 100644
--- a/src/pj_list.h
+++ b/src/pj_list.h
@@ -22,6 +22,7 @@ PROJ_HEAD(cc, "Central Cylindrical")
 PROJ_HEAD(cea, "Equal Area Cylindrical")
 PROJ_HEAD(chamb, "Chamberlin Trimetric")
 PROJ_HEAD(collg, "Collignon")
+PROJ_HEAD(comill, "Compact Miller")
 PROJ_HEAD(crast, "Craster Parabolic (Putnins P4)")
 PROJ_HEAD(denoy, "Denoyer Semi-Elliptical")
 PROJ_HEAD(eck1, "Eckert I")
@@ -79,11 +80,13 @@ PROJ_HEAD(mbtfps, "McBryde-Thomas Flat-Polar Sinusoidal")
 PROJ_HEAD(merc, "Mercator")
 PROJ_HEAD(mil_os, "Miller Oblated Stereographic")
 PROJ_HEAD(mill, "Miller Cylindrical")
+PROJ_HEAD(misrsom, "Space oblique for MISR")
 PROJ_HEAD(moll, "Mollweide")
 PROJ_HEAD(murd1, "Murdoch I")
 PROJ_HEAD(murd2, "Murdoch II")
 PROJ_HEAD(murd3, "Murdoch III")
 PROJ_HEAD(natearth, "Natural Earth")
+PROJ_HEAD(natearth2, "Natural Earth II")
 PROJ_HEAD(nell, "Nell")
 PROJ_HEAD(nell_h, "Nell-Hammer")
 PROJ_HEAD(nicol, "Nicolosi Globular")
@@ -96,6 +99,7 @@ PROJ_HEAD(omerc, "Oblique Mercator")
 PROJ_HEAD(ortel, "Ortelius Oval")
 PROJ_HEAD(ortho, "Orthographic")
 PROJ_HEAD(pconic, "Perspective Conic")
+PROJ_HEAD(patterson, "Patterson Cylindrical")
 PROJ_HEAD(poly, "Polyconic (American)")
 PROJ_HEAD(putp1, "Putnins P1")
 PROJ_HEAD(putp2, "Putnins P2")
@@ -111,6 +115,7 @@ PROJ_HEAD(qsc, "Quadrilateralized Spherical Cube")
 PROJ_HEAD(robin, "Robinson")
 PROJ_HEAD(rouss, "Roussilhe Stereographic")
 PROJ_HEAD(rpoly, "Rectangular Polyconic")
+PROJ_HEAD(sch, "Spherical Cross-track Height")
 PROJ_HEAD(sinu, "Sinusoidal (Sanson-Flamsteed)")
 PROJ_HEAD(somerc, "Swiss. Obl. Mercator")
 PROJ_HEAD(stere, "Stereographic")
@@ -142,3 +147,4 @@ PROJ_HEAD(weren, "Werenskiold I")
 PROJ_HEAD(wink1, "Winkel I")
 PROJ_HEAD(wink2, "Winkel II")
 PROJ_HEAD(wintri, "Winkel Tripel")
+
diff --git a/src/pj_malloc.c b/src/pj_malloc.c
index 80443a2..aab69e9 100644
--- a/src/pj_malloc.c
+++ b/src/pj_malloc.c
@@ -9,19 +9,64 @@
 pj_malloc(size_t size) {
 /*
 / Currently, pj_malloc is a hack to solve an errno problem.
-/ The problem is described in more details at 
-/ https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=86420. 
-/ It seems, that pj_init and similar functions incorrectly 
-/ (under debian/glibs-2.3.2) assume that pj_malloc resets 
+/ The problem is described in more details at
+/ https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=86420.
+/ It seems, that pj_init and similar functions incorrectly
+/ (under debian/glibs-2.3.2) assume that pj_malloc resets
 / errno after success. pj_malloc tries to mimic this.
 */
         int old_errno = errno;
-        void *res = malloc(size);       
+        void *res = malloc(size);
         if ( res && !old_errno )
-                errno = 0;        	 
+                errno = 0;
         return res;
 }
 	void
 pj_dalloc(void *ptr) {
 	free(ptr);
 }
+
+
+/**********************************************************************/
+void *pj_calloc (size_t n, size_t size) {
+/***********************************************************************
+
+pj_calloc is the pj-equivalent of calloc().
+
+It allocates space for an array of <n> elements of size <size>.
+The array is initialized to zeros.
+
+***********************************************************************/
+    void *res = pj_malloc (n*size);
+    if (0==res)
+        return 0;
+    memset (res, 0, n*size);
+    return res;
+}
+
+
+/**********************************************************************/
+void *pj_dealloc (void *ptr) {
+/***********************************************************************
+
+pj_dealloc supports the common use case of "clean up and return a null
+pointer" to signal an error in a multi level allocation:
+
+    struct foo { int bar; int *baz; };
+
+    struct foo *p = pj_calloc (1, sizeof (struct foo));
+    if (0==p)
+        return 0;
+
+    p->baz = pj_calloc (10, sizeof(int));
+    if (0==p->baz)
+        return pj_dealloc (p); // clean up + signal error by 0-return
+
+    return p;  // success
+
+***********************************************************************/
+    if (0==ptr)
+        return 0;
+    pj_dalloc (ptr);
+    return 0;
+}
diff --git a/src/pj_mutex.c b/src/pj_mutex.c
index dc484c6..1590daa 100644
--- a/src/pj_mutex.c
+++ b/src/pj_mutex.c
@@ -29,7 +29,7 @@
 /* projects.h and windows.h conflict - avoid this! */
 
 #if defined(MUTEX_pthread) && !defined(_XOPEN_SOURCE)
-// For pthread_mutexattr_settype
+/* For pthread_mutexattr_settype */
 #define _XOPEN_SOURCE 500
 #endif
 
@@ -43,7 +43,9 @@
 
 /* on win32 we always use win32 mutexes, even if pthreads are available */
 #if defined(_WIN32) && !defined(MUTEX_stub)
+#ifndef MUTEX_win32
 #  define MUTEX_win32
+#endif
 #  undef  MUTEX_pthread
 #endif
 
@@ -86,7 +88,7 @@ void pj_cleanup_lock()
 {
 }
 
-#endif // def MUTEX_stub
+#endif /* def MUTEX_stub */
 
 /************************************************************************/
 /* ==================================================================== */
@@ -154,7 +156,7 @@ void pj_cleanup_lock()
 {
 }
 
-#endif // def MUTEX_pthread
+#endif /* def MUTEX_pthread */
 
 /************************************************************************/
 /* ==================================================================== */
@@ -219,4 +221,4 @@ void pj_cleanup_lock()
     }
 }
 
-#endif // def MUTEX_win32
+#endif /* def MUTEX_win32 */
diff --git a/src/pj_phi2.c b/src/pj_phi2.c
index 5c81da4..60b36ec 100644
--- a/src/pj_phi2.c
+++ b/src/pj_phi2.c
@@ -1,7 +1,6 @@
 /* determine latitude angle phi-2 */
 #include <projects.h>
 
-#define HALFPI		1.5707963267948966
 #define TOL 1.0e-10
 #define N_ITER 15
 
@@ -11,11 +10,11 @@ pj_phi2(projCtx ctx, double ts, double e) {
 	int i;
 
 	eccnth = .5 * e;
-	Phi = HALFPI - 2. * atan (ts);
+	Phi = M_HALFPI - 2. * atan (ts);
 	i = N_ITER;
 	do {
 		con = e * sin (Phi);
-		dphi = HALFPI - 2. * atan (ts * pow((1. - con) /
+		dphi = M_HALFPI - 2. * atan (ts * pow((1. - con) /
 		   (1. + con), eccnth)) - Phi;
 		Phi += dphi;
 	} while ( fabs(dphi) > TOL && --i);
diff --git a/src/pj_release.c b/src/pj_release.c
index c3736b4..1758a53 100644
--- a/src/pj_release.c
+++ b/src/pj_release.c
@@ -2,7 +2,7 @@
 
 #include <projects.h>
 
-char const pj_release[]="Rel. 4.9.2, 08 September 2015";
+char const pj_release[]="Rel. 4.9.3, 15 August 2016";
 
 const char *pj_get_release()
 
diff --git a/src/pj_run_selftests.c b/src/pj_run_selftests.c
new file mode 100644
index 0000000..cede496
--- /dev/null
+++ b/src/pj_run_selftests.c
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * Project:  PROJ.4
+ * Purpose:  Generic regression test for PROJ.4 projection algorithms.
+ * Author:   Thomas Knudsen
+ *
+ ******************************************************************************
+ * Copyright (c) 2016, Thomas Knudsen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *****************************************************************************/
+
+#include <stdio.h>
+#define PJ_LIB__
+#include <projects.h>
+
+
+static void run_one_test (const char *mnemonic, int (testfunc)(void), int verbosity, int *n_ok, int *n_ko, int *n_stubs) {
+    int ret = testfunc ();
+    switch (ret) {
+        case 0:      (*n_ok)++;     break;
+        case 10000:  (*n_stubs)++;  break;
+        default:     (*n_ko)++;
+    }
+
+    if (verbosity) {
+        if (ret==10000)
+            printf ("Testing: %10s - [stub]\n", mnemonic);
+        else
+            printf ("Testing: %10s - return code: %d\n", mnemonic, ret);
+    }
+    return;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_run_selftests (int verbosity) {
+    printf ("This version of libproj is not configured for internal regression tests.\n");
+    return 0;
+}
+#else
+
+
+int pj_run_selftests (int verbosity) {
+    int n_ok = 0, n_ko = 0, n_stubs = 0, i = 0;
+
+    struct PJ_SELFTEST_LIST *tests = pj_get_selftest_list_ref ();
+
+    if (0==tests)
+        printf ("This version of libproj is not configured for internal regression tests.\n");
+
+    if (verbosity)
+       printf ("Running internal regression tests\n");
+
+    for (i = 0; tests[i].testfunc != 0; i++)
+        run_one_test (tests[i].id,     tests[i].testfunc,      verbosity, &n_ok, &n_ko, &n_stubs);
+
+    if (0==verbosity)
+       printf ("Internal regression tests done. ");
+    printf ("[Stubs: %d]          Total: %d. Failure: %d. Success: %d\n", n_stubs, n_ok+n_ko, n_ko, n_ok);
+    return n_ko;
+}
+#endif
diff --git a/src/pj_strtod.c b/src/pj_strtod.c
index 9aac07e..7c2da9a 100644
--- a/src/pj_strtod.c
+++ b/src/pj_strtod.c
@@ -76,7 +76,13 @@ static char* pj_replace_point_by_locale_point(const char* pszNumber, char point,
                                               char* pszWorkBuffer)
 {
 #if !defined(HAVE_LOCALECONV) || defined(_WIN32_WCE)
+
+#if defined(_MSC_VER)  /* Visual C++ */
+#pragma message("localeconv not available")
+#else
 #warning "localeconv not available"
+#endif
+
     static char byPoint = 0;
     if (byPoint == 0)
     {
diff --git a/src/pj_transform.c b/src/pj_transform.c
index 6fe571c..1794678 100644
--- a/src/pj_transform.c
+++ b/src/pj_transform.c
@@ -1,6 +1,6 @@
 /******************************************************************************
  * Project:  PROJ.4
- * Purpose:  Perform overall coordinate system to coordinate system 
+ * Purpose:  Perform overall coordinate system to coordinate system
  *           transformations (pj_transform() function) including reprojection
  *           and datum shifting.
  * Author:   Frank Warmerdam, warmerdam at pobox.com
@@ -33,7 +33,7 @@
 #include "geocent.h"
 
 static int pj_adjust_axis( projCtx ctx, const char *axis, int denormalize_flag,
-                           long point_count, int point_offset, 
+                           long point_count, int point_offset,
                            double *x, double *y, double *z );
 
 #ifndef SRS_WGS84_SEMIMAJOR
@@ -52,23 +52,23 @@ static int pj_adjust_axis( projCtx ctx, const char *axis, int denormalize_flag,
 #define Rz_BF (defn->datum_params[5])
 #define M_BF  (defn->datum_params[6])
 
-/* 
-** This table is intended to indicate for any given error code in 
+/*
+** This table is intended to indicate for any given error code in
 ** the range 0 to -44, whether that error will occur for all locations (ie.
 ** it is a problem with the coordinate system as a whole) in which case the
 ** value would be 0, or if the problem is with the point being transformed
-** in which case the value is 1. 
+** in which case the value is 1.
 **
 ** At some point we might want to move this array in with the error message
-** list or something, but while experimenting with it this should be fine. 
+** list or something, but while experimenting with it this should be fine.
 */
 
 static const int transient_error[50] = {
     /*             0  1  2  3  4  5  6  7  8  9   */
-    /* 0 to 9 */   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-    /* 10 to 19 */ 0, 0, 0, 0, 1, 1, 0, 1, 1, 1,  
-    /* 20 to 29 */ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 
-    /* 30 to 39 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+    /* 0 to 9 */   0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    /* 10 to 19 */ 0, 0, 0, 0, 1, 1, 0, 1, 1, 1,
+    /* 20 to 29 */ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
+    /* 30 to 39 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     /* 40 to 49 */ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 };
 
 /************************************************************************/
@@ -101,7 +101,7 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
     {
         int err;
 
-        err = pj_adjust_axis( srcdefn->ctx, srcdefn->axis, 
+        err = pj_adjust_axis( srcdefn->ctx, srcdefn->axis,
                               0, point_count, point_offset, x, y, z );
         if( err != 0 )
             return err;
@@ -140,7 +140,7 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
         }
 
         err = pj_geocentric_to_geodetic( srcdefn->a_orig, srcdefn->es_orig,
-                                         point_count, point_offset, 
+                                         point_count, point_offset,
                                          x, y, z );
         if( err != 0 )
             return err;
@@ -152,43 +152,95 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
 /* -------------------------------------------------------------------- */
     else if( !srcdefn->is_latlong )
     {
-        if( srcdefn->inv == NULL )
+
+        /* Check first if projection is invertible. */
+        if( (srcdefn->inv3d == NULL) && (srcdefn->inv == NULL))
         {
             pj_ctx_set_errno( pj_get_ctx(srcdefn), -17 );
-            pj_log( pj_get_ctx(srcdefn), PJ_LOG_ERROR, 
+            pj_log( pj_get_ctx(srcdefn), PJ_LOG_ERROR,
                     "pj_transform(): source projection not invertable" );
             return -17;
         }
 
-        for( i = 0; i < point_count; i++ )
+        /* If invertible - First try inv3d if defined */
+        if (srcdefn->inv3d != NULL)
         {
-            XY         projected_loc;
-            LP	       geodetic_loc;
+            /* Three dimensions must be defined */
+            if ( z == NULL)
+            {
+                pj_ctx_set_errno( pj_get_ctx(srcdefn), PJD_ERR_GEOCENTRIC);
+                return PJD_ERR_GEOCENTRIC;
+            }
 
-            projected_loc.u = x[point_offset*i];
-            projected_loc.v = y[point_offset*i];
+            for (i=0; i < point_count; i++)
+            {
+                XYZ projected_loc;
+                XYZ geodetic_loc;
 
-            if( projected_loc.u == HUGE_VAL )
-                continue;
+                projected_loc.u = x[point_offset*i];
+                projected_loc.v = y[point_offset*i];
+                projected_loc.w = z[point_offset*i];
 
-            geodetic_loc = pj_inv( projected_loc, srcdefn );
-            if( srcdefn->ctx->last_errno != 0 )
-            {
-                if( (srcdefn->ctx->last_errno != 33 /*EDOM*/ 
-                     && srcdefn->ctx->last_errno != 34 /*ERANGE*/ )
-                    && (srcdefn->ctx->last_errno > 0 
-                        || srcdefn->ctx->last_errno < -44 || point_count == 1
-                        || transient_error[-srcdefn->ctx->last_errno] == 0 ) )
-                    return srcdefn->ctx->last_errno;
-                else
+                if (projected_loc.u == HUGE_VAL)
+                    continue;
+
+                geodetic_loc = pj_inv3d(projected_loc, srcdefn);
+                if( srcdefn->ctx->last_errno != 0 )
                 {
-                    geodetic_loc.u = HUGE_VAL;
-                    geodetic_loc.v = HUGE_VAL;
+                    if( (srcdefn->ctx->last_errno != 33 /*EDOM*/
+                         && srcdefn->ctx->last_errno != 34 /*ERANGE*/ )
+                        && (srcdefn->ctx->last_errno > 0
+                            || srcdefn->ctx->last_errno < -44 || point_count == 1
+                            || transient_error[-srcdefn->ctx->last_errno] == 0 ) )
+                        return srcdefn->ctx->last_errno;
+                    else
+                    {
+                        geodetic_loc.u = HUGE_VAL;
+                        geodetic_loc.v = HUGE_VAL;
+                        geodetic_loc.w = HUGE_VAL;
+                    }
                 }
+
+                x[point_offset*i] = geodetic_loc.u;
+                y[point_offset*i] = geodetic_loc.v;
+                z[point_offset*i] = geodetic_loc.w;
+
             }
 
-            x[point_offset*i] = geodetic_loc.u;
-            y[point_offset*i] = geodetic_loc.v;
+        }
+        else
+        {
+            /* Fallback to the original PROJ.4 API 2d inversion - inv */
+            for( i = 0; i < point_count; i++ )
+            {
+                XY         projected_loc;
+                LP	       geodetic_loc;
+
+                projected_loc.u = x[point_offset*i];
+                projected_loc.v = y[point_offset*i];
+
+                if( projected_loc.u == HUGE_VAL )
+                    continue;
+
+                geodetic_loc = pj_inv( projected_loc, srcdefn );
+                if( srcdefn->ctx->last_errno != 0 )
+                {
+                    if( (srcdefn->ctx->last_errno != 33 /*EDOM*/
+                         && srcdefn->ctx->last_errno != 34 /*ERANGE*/ )
+                        && (srcdefn->ctx->last_errno > 0
+                            || srcdefn->ctx->last_errno < -44 || point_count == 1
+                            || transient_error[-srcdefn->ctx->last_errno] == 0 ) )
+                        return srcdefn->ctx->last_errno;
+                    else
+                    {
+                        geodetic_loc.u = HUGE_VAL;
+                        geodetic_loc.v = HUGE_VAL;
+                    }
+                }
+
+                x[point_offset*i] = geodetic_loc.u;
+                y[point_offset*i] = geodetic_loc.v;
+            }
         }
     }
 /* -------------------------------------------------------------------- */
@@ -210,17 +262,17 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
 /* -------------------------------------------------------------------- */
     if( srcdefn->has_geoid_vgrids && z != NULL )
     {
-        if( pj_apply_vgridshift( srcdefn, "sgeoidgrids", 
-                                 &(srcdefn->vgridlist_geoid), 
+        if( pj_apply_vgridshift( srcdefn, "sgeoidgrids",
+                                 &(srcdefn->vgridlist_geoid),
                                  &(srcdefn->vgridlist_geoid_count),
                                  0, point_count, point_offset, x, y, z ) != 0 )
             return pj_ctx_get_errno(srcdefn->ctx);
     }
-        
+
 /* -------------------------------------------------------------------- */
 /*      Convert datums if needed, and possible.                         */
 /* -------------------------------------------------------------------- */
-    if( pj_datum_transform( srcdefn, dstdefn, point_count, point_offset, 
+    if( pj_datum_transform( srcdefn, dstdefn, point_count, point_offset,
                             x, y, z ) != 0 )
     {
         if( srcdefn->ctx->last_errno != 0 )
@@ -235,13 +287,13 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
 /* -------------------------------------------------------------------- */
     if( dstdefn->has_geoid_vgrids && z != NULL )
     {
-        if( pj_apply_vgridshift( dstdefn, "sgeoidgrids", 
-                                 &(dstdefn->vgridlist_geoid), 
+        if( pj_apply_vgridshift( dstdefn, "sgeoidgrids",
+                                 &(dstdefn->vgridlist_geoid),
                                  &(dstdefn->vgridlist_geoid_count),
                                  1, point_count, point_offset, x, y, z ) != 0 )
             return dstdefn->ctx->last_errno;
     }
-        
+
 /* -------------------------------------------------------------------- */
 /*      But if they are staying lat long, adjust for the prime          */
 /*      meridian if there is one in effect.                             */
@@ -289,35 +341,76 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
 /* -------------------------------------------------------------------- */
     else if( !dstdefn->is_latlong )
     {
-        for( i = 0; i < point_count; i++ )
+
+        if( dstdefn->fwd3d != NULL)
         {
-            XY         projected_loc;
-            LP	       geodetic_loc;
+            for( i = 0; i < point_count; i++ )
+            {
+                XYZ projected_loc;
+                LPZ geodetic_loc;
 
-            geodetic_loc.u = x[point_offset*i];
-            geodetic_loc.v = y[point_offset*i];
+                geodetic_loc.u = x[point_offset*i];
+                geodetic_loc.v = y[point_offset*i];
+                geodetic_loc.w = z[point_offset*i];
 
-            if( geodetic_loc.u == HUGE_VAL )
-                continue;
+                if (geodetic_loc.u == HUGE_VAL)
+                    continue;
 
-            projected_loc = pj_fwd( geodetic_loc, dstdefn );
-            if( dstdefn->ctx->last_errno != 0 )
-            {
-                if( (dstdefn->ctx->last_errno != 33 /*EDOM*/ 
-                     && dstdefn->ctx->last_errno != 34 /*ERANGE*/ )
-                    && (dstdefn->ctx->last_errno > 0 
-                        || dstdefn->ctx->last_errno < -44 || point_count == 1
-                        || transient_error[-dstdefn->ctx->last_errno] == 0 ) )
-                    return dstdefn->ctx->last_errno;
-                else
+                projected_loc = pj_fwd3d( geodetic_loc, dstdefn);
+                if( dstdefn->ctx->last_errno != 0 )
                 {
-                    projected_loc.u = HUGE_VAL;
-                    projected_loc.v = HUGE_VAL;
+                    if( (dstdefn->ctx->last_errno != 33 /*EDOM*/
+                         && dstdefn->ctx->last_errno != 34 /*ERANGE*/ )
+                        && (dstdefn->ctx->last_errno > 0
+                            || dstdefn->ctx->last_errno < -44 || point_count == 1
+                            || transient_error[-dstdefn->ctx->last_errno] == 0 ) )
+                        return dstdefn->ctx->last_errno;
+                    else
+                    {
+                        projected_loc.u = HUGE_VAL;
+                        projected_loc.v = HUGE_VAL;
+                        projected_loc.w = HUGE_VAL;
+                    }
                 }
+
+                x[point_offset*i] = projected_loc.u;
+                y[point_offset*i] = projected_loc.v;
+                z[point_offset*i] = projected_loc.w;
             }
 
-            x[point_offset*i] = projected_loc.u;
-            y[point_offset*i] = projected_loc.v;
+        }
+        else
+        {
+            for( i = 0; i < point_count; i++ )
+            {
+                XY         projected_loc;
+                LP	       geodetic_loc;
+
+                geodetic_loc.u = x[point_offset*i];
+                geodetic_loc.v = y[point_offset*i];
+
+                if( geodetic_loc.u == HUGE_VAL )
+                    continue;
+
+                projected_loc = pj_fwd( geodetic_loc, dstdefn );
+                if( dstdefn->ctx->last_errno != 0 )
+                {
+                    if( (dstdefn->ctx->last_errno != 33 /*EDOM*/
+                         && dstdefn->ctx->last_errno != 34 /*ERANGE*/ )
+                        && (dstdefn->ctx->last_errno > 0
+                            || dstdefn->ctx->last_errno < -44 || point_count == 1
+                            || transient_error[-dstdefn->ctx->last_errno] == 0 ) )
+                        return dstdefn->ctx->last_errno;
+                    else
+                    {
+                        projected_loc.u = HUGE_VAL;
+                        projected_loc.v = HUGE_VAL;
+                    }
+                }
+
+                x[point_offset*i] = projected_loc.u;
+                y[point_offset*i] = projected_loc.v;
+            }
         }
     }
 
@@ -332,10 +425,10 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
             if( x[point_offset*i] == HUGE_VAL )
                 continue;
 
-            while( x[point_offset*i] < dstdefn->long_wrap_center - PI )
-                x[point_offset*i] += TWOPI;
-            while( x[point_offset*i] > dstdefn->long_wrap_center + PI )
-                x[point_offset*i] -= TWOPI;
+            while( x[point_offset*i] < dstdefn->long_wrap_center - M_PI )
+                x[point_offset*i] += M_TWOPI;
+            while( x[point_offset*i] > dstdefn->long_wrap_center + M_PI )
+                x[point_offset*i] -= M_TWOPI;
         }
     }
 
@@ -356,7 +449,7 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
     {
         int err;
 
-        err = pj_adjust_axis( dstdefn->ctx, dstdefn->axis, 
+        err = pj_adjust_axis( dstdefn->ctx, dstdefn->axis,
                               1, point_count, point_offset, x, y, z );
         if( err != 0 )
             return err;
@@ -369,7 +462,7 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
 /*                     pj_geodetic_to_geocentric()                      */
 /************************************************************************/
 
-int pj_geodetic_to_geocentric( double a, double es, 
+int pj_geodetic_to_geocentric( double a, double es,
                                long point_count, int point_offset,
                                double *x, double *y, double *z )
 
@@ -396,7 +489,7 @@ int pj_geodetic_to_geocentric( double a, double es,
         if( x[io] == HUGE_VAL  )
             continue;
 
-        if( pj_Convert_Geodetic_To_Geocentric( &gi, y[io], x[io], z[io], 
+        if( pj_Convert_Geodetic_To_Geocentric( &gi, y[io], x[io], z[io],
                                                x+io, y+io, z+io ) != 0 )
         {
             ret_errno = -14;
@@ -412,7 +505,7 @@ int pj_geodetic_to_geocentric( double a, double es,
 /*                     pj_geodetic_to_geocentric()                      */
 /************************************************************************/
 
-int pj_geocentric_to_geodetic( double a, double es, 
+int pj_geocentric_to_geodetic( double a, double es,
                                long point_count, int point_offset,
                                double *x, double *y, double *z )
 
@@ -438,7 +531,7 @@ int pj_geocentric_to_geodetic( double a, double es,
         if( x[io] == HUGE_VAL )
             continue;
 
-        pj_Convert_Geocentric_To_Geodetic( &gi, x[io], y[io], z[io], 
+        pj_Convert_Geocentric_To_Geodetic( &gi, x[io], y[io], z[io],
                                            y+io, x+io, z+io );
     }
 
@@ -459,7 +552,7 @@ int pj_compare_datums( PJ *srcdefn, PJ *dstdefn )
     {
         return 0;
     }
-    else if( srcdefn->a_orig != dstdefn->a_orig 
+    else if( srcdefn->a_orig != dstdefn->a_orig
              || ABS(srcdefn->es_orig - dstdefn->es_orig) > 0.000000000050 )
     {
         /* the tolerence for es is to ensure that GRS80 and WGS84 are
@@ -495,7 +588,7 @@ int pj_compare_datums( PJ *srcdefn, PJ *dstdefn )
 /*                       pj_geocentic_to_wgs84()                        */
 /************************************************************************/
 
-int pj_geocentric_to_wgs84( PJ *defn, 
+int pj_geocentric_to_wgs84( PJ *defn,
                             long point_count, int point_offset,
                             double *x, double *y, double *z )
 
@@ -507,7 +600,7 @@ int pj_geocentric_to_wgs84( PJ *defn,
         for( i = 0; i < point_count; i++ )
         {
             long io = i * point_offset;
-            
+
             if( x[io] == HUGE_VAL )
                 continue;
 
@@ -543,7 +636,7 @@ int pj_geocentric_to_wgs84( PJ *defn,
 /*                      pj_geocentic_from_wgs84()                       */
 /************************************************************************/
 
-int pj_geocentric_from_wgs84( PJ *defn, 
+int pj_geocentric_from_wgs84( PJ *defn,
                               long point_count, int point_offset,
                               double *x, double *y, double *z )
 
@@ -558,7 +651,7 @@ int pj_geocentric_from_wgs84( PJ *defn,
 
             if( x[io] == HUGE_VAL )
                 continue;
-            
+
             x[io] = x[io] - Dx_BF;
             y[io] = y[io] - Dy_BF;
             z[io] = z[io] - Dz_BF;
@@ -595,7 +688,7 @@ int pj_geocentric_from_wgs84( PJ *defn,
 /*      coordinates in radians in the destination datum.                */
 /************************************************************************/
 
-int pj_datum_transform( PJ *srcdefn, PJ *dstdefn, 
+int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
                         long point_count, int point_offset,
                         double *x, double *y, double *z )
 
@@ -661,15 +754,15 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
 /*      Do we need to go through geocentric coordinates?                */
 /* ==================================================================== */
     if( src_es != dst_es || src_a != dst_a
-        || srcdefn->datum_type == PJD_3PARAM 
+        || srcdefn->datum_type == PJD_3PARAM
         || srcdefn->datum_type == PJD_7PARAM
-        || dstdefn->datum_type == PJD_3PARAM 
+        || dstdefn->datum_type == PJD_3PARAM
         || dstdefn->datum_type == PJD_7PARAM)
     {
 /* -------------------------------------------------------------------- */
 /*      Convert to geocentric coordinates.                              */
 /* -------------------------------------------------------------------- */
-        srcdefn->ctx->last_errno = 
+        srcdefn->ctx->last_errno =
             pj_geodetic_to_geocentric( src_a, src_es,
                                        point_count, point_offset, x, y, z );
         CHECK_RETURN(srcdefn);
@@ -677,14 +770,14 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
 /* -------------------------------------------------------------------- */
 /*      Convert between datums.                                         */
 /* -------------------------------------------------------------------- */
-        if( srcdefn->datum_type == PJD_3PARAM 
+        if( srcdefn->datum_type == PJD_3PARAM
             || srcdefn->datum_type == PJD_7PARAM )
         {
             pj_geocentric_to_wgs84( srcdefn, point_count, point_offset,x,y,z);
             CHECK_RETURN(srcdefn);
         }
 
-        if( dstdefn->datum_type == PJD_3PARAM 
+        if( dstdefn->datum_type == PJD_3PARAM
             || dstdefn->datum_type == PJD_7PARAM )
         {
             pj_geocentric_from_wgs84( dstdefn, point_count,point_offset,x,y,z);
@@ -694,7 +787,7 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
 /* -------------------------------------------------------------------- */
 /*      Convert back to geodetic coordinates.                           */
 /* -------------------------------------------------------------------- */
-        dstdefn->ctx->last_errno = 
+        dstdefn->ctx->last_errno =
             pj_geocentric_to_geodetic( dst_a, dst_es,
                                        point_count, point_offset, x, y, z );
         CHECK_RETURN(dstdefn);
@@ -721,9 +814,9 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
 /*      Normalize or de-normalized the x/y/z axes.  The normal form     */
 /*      is "enu" (easting, northing, up).                               */
 /************************************************************************/
-static int pj_adjust_axis( projCtx ctx, 
+static int pj_adjust_axis( projCtx ctx,
                            const char *axis, int denormalize_flag,
-                           long point_count, int point_offset, 
+                           long point_count, int point_offset,
                            double *x, double *y, double *z )
 
 {
@@ -738,7 +831,7 @@ static int pj_adjust_axis( projCtx ctx,
             y_in = y[point_offset*i];
             if( z )
                 z_in = z[point_offset*i];
-     
+
             for( i_axis = 0; i_axis < 3; i_axis++ )
             {
                 double value;
@@ -749,7 +842,7 @@ static int pj_adjust_axis( projCtx ctx,
                     value = y_in;
                 else
                     value = z_in;
-                
+
                 switch( axis[i_axis] )
                 {
                   case 'e':
@@ -780,7 +873,7 @@ static int pj_adjust_axis( projCtx ctx,
             y_in = y[point_offset*i];
             if( z )
                 z_in = z[point_offset*i];
-     
+
             for( i_axis = 0; i_axis < 3; i_axis++ )
             {
                 double *target;
@@ -794,7 +887,7 @@ static int pj_adjust_axis( projCtx ctx,
                     target = y;
                 else
                     target = z;
-                
+
                 switch( axis[i_axis] )
                 {
                   case 'e':
@@ -816,7 +909,6 @@ static int pj_adjust_axis( projCtx ctx,
             } /* i_axis */
         } /* i (point) */
     }
-    
+
     return 0;
 }
-
diff --git a/src/pj_tsfn.c b/src/pj_tsfn.c
index d9dc0bc..448aae9 100644
--- a/src/pj_tsfn.c
+++ b/src/pj_tsfn.c
@@ -1,10 +1,10 @@
 /* determine small t */
 #include <math.h>
 #include <projects.h>
-#define HALFPI		1.5707963267948966
+
 	double
 pj_tsfn(double phi, double sinphi, double e) {
 	sinphi *= e;
-	return (tan (.5 * (HALFPI - phi)) /
+	return (tan (.5 * (M_HALFPI - phi)) /
 	   pow((1. - sinphi) / (1. + sinphi), .5 * e));
 }
diff --git a/src/pj_utils.c b/src/pj_utils.c
index f11081f..203c637 100644
--- a/src/pj_utils.c
+++ b/src/pj_utils.c
@@ -78,27 +78,27 @@ PJ *pj_latlong_from_proj( PJ *pj_in )
     if( pj_param(pj_in->ctx, pj_in->params, "tdatum").i )
     {
         got_datum = TRUE;
-        sprintf( defn+strlen(defn), " +datum=%s", 
+        sprintf( defn+strlen(defn), " +datum=%s",
                  pj_param(pj_in->ctx, pj_in->params,"sdatum").s );
     }
     else if( pj_param(pj_in->ctx, pj_in->params, "tellps").i )
     {
-        sprintf( defn+strlen(defn), " +ellps=%s", 
+        sprintf( defn+strlen(defn), " +ellps=%s",
                  pj_param(pj_in->ctx, pj_in->params,"sellps").s );
     }
     else if( pj_param(pj_in->ctx,pj_in->params, "ta").i )
     {
-        sprintf( defn+strlen(defn), " +a=%s", 
+        sprintf( defn+strlen(defn), " +a=%s",
                  pj_param(pj_in->ctx,pj_in->params,"sa").s );
-            
+
         if( pj_param(pj_in->ctx,pj_in->params, "tb").i )
-            sprintf( defn+strlen(defn), " +b=%s", 
+            sprintf( defn+strlen(defn), " +b=%s",
                      pj_param(pj_in->ctx,pj_in->params,"sb").s );
         else if( pj_param(pj_in->ctx,pj_in->params, "tes").i )
-            sprintf( defn+strlen(defn), " +es=%s", 
+            sprintf( defn+strlen(defn), " +es=%s",
                      pj_param(pj_in->ctx,pj_in->params,"ses").s );
         else if( pj_param(pj_in->ctx,pj_in->params, "tf").i )
-            sprintf( defn+strlen(defn), " +f=%s", 
+            sprintf( defn+strlen(defn), " +f=%s",
                      pj_param(pj_in->ctx,pj_in->params,"sf").s );
         else
         {
@@ -121,17 +121,17 @@ PJ *pj_latlong_from_proj( PJ *pj_in )
     if( !got_datum )
     {
         if( pj_param(pj_in->ctx,pj_in->params, "ttowgs84").i )
-            sprintf( defn+strlen(defn), " +towgs84=%s", 
+            sprintf( defn+strlen(defn), " +towgs84=%s",
                      pj_param(pj_in->ctx,pj_in->params,"stowgs84").s );
 
         if( pj_param(pj_in->ctx,pj_in->params, "tnadgrids").i )
-            sprintf( defn+strlen(defn), " +nadgrids=%s", 
+            sprintf( defn+strlen(defn), " +nadgrids=%s",
                      pj_param(pj_in->ctx,pj_in->params,"snadgrids").s );
     }
 
     /* copy over some other information related to ellipsoid */
     if( pj_param(pj_in->ctx,pj_in->params, "tR").i )
-        sprintf( defn+strlen(defn), " +R=%s", 
+        sprintf( defn+strlen(defn), " +R=%s",
                  pj_param(pj_in->ctx,pj_in->params,"sR").s );
 
     if( pj_param(pj_in->ctx,pj_in->params, "tR_A").i )
@@ -144,16 +144,16 @@ PJ *pj_latlong_from_proj( PJ *pj_in )
         sprintf( defn+strlen(defn), " +R_a" );
 
     if( pj_param(pj_in->ctx,pj_in->params, "tR_lat_a").i )
-        sprintf( defn+strlen(defn), " +R_lat_a=%s", 
+        sprintf( defn+strlen(defn), " +R_lat_a=%s",
                  pj_param(pj_in->ctx,pj_in->params,"sR_lat_a").s );
 
     if( pj_param(pj_in->ctx,pj_in->params, "tR_lat_g").i )
-        sprintf( defn+strlen(defn), " +R_lat_g=%s", 
+        sprintf( defn+strlen(defn), " +R_lat_g=%s",
                  pj_param(pj_in->ctx,pj_in->params,"sR_lat_g").s );
 
     /* copy over prime meridian */
     if( pj_param(pj_in->ctx,pj_in->params, "tpm").i )
-        sprintf( defn+strlen(defn), " +pm=%s", 
+        sprintf( defn+strlen(defn), " +pm=%s",
                  pj_param(pj_in->ctx,pj_in->params,"spm").s );
 
     return pj_init_plus_ctx( pj_in->ctx, defn );
@@ -172,7 +172,7 @@ void pj_get_spheroid_defn(projPJ defn, double *major_axis, double *eccentricity_
 {
 	if ( major_axis )
 		*major_axis = defn->a;
-		
+
 	if ( eccentricity_squared )
 		*eccentricity_squared = defn->es;
-};
+}
diff --git a/src/pj_zpoly1.c b/src/pj_zpoly1.c
index fa163de..3d6418b 100644
--- a/src/pj_zpoly1.c
+++ b/src/pj_zpoly1.c
@@ -26,10 +26,10 @@ pj_zpolyd1(COMPLEX z, COMPLEX *C, int n, COMPLEX *der) {
 	int first = 1;
 
 	a = *(C += n);
+	b = a;
 	while (n-- > 0) {
 		if (first) {
 			first = 0;
-			b = a;
 		} else {
 			b.r = a.r + z.r * (t = b.r) - z.i * b.i;
 			b.i = a.i + z.r * b.i + z.i * t;
diff --git a/src/proj.c b/src/proj.c
index 23f9cca..e452467 100644
--- a/src/proj.c
+++ b/src/proj.c
@@ -42,7 +42,7 @@ postscale = 0;
 *oform = (char *)0,	/* output format for x-y or decimal degrees */
 *oterr = "*\t*",	/* output line for unprojectable input */
 *usage =
-"%s\nusage: %s [ -beEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ]\n";
+"%s\nusage: %s [ -bCeEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ]\n";
 	static struct FACTORS
 facs;
 	static double
@@ -158,7 +158,7 @@ vprocess(FILE *fid) {
 	if (!oform)
 		oform = "%.3f";
 	if (bin_in || bin_out)
-		emess(1,"binary I/O not available in -V option");	
+		emess(1,"binary I/O not available in -V option");
 	for (;;) {
 		++emess_dat.File_line;
 		if (!(s = fgets(line, MAX_LINE, fid)))
@@ -267,6 +267,9 @@ int main(int argc, char **argv) {
               case 'b': /* binary I/O */
                 bin_in = bin_out = 1;
                 continue;
+              case 'C': /* Check - run internal regression tests */
+                return pj_run_selftests (very_verby);
+                continue;
               case 'v': /* monitor dump of initialization */
                 mon = 1;
                 continue;
@@ -300,8 +303,8 @@ int main(int argc, char **argv) {
                     char *str;
 
                     for (lp = pj_get_list_ref() ; lp->id ; ++lp) {
-                        if( strcmp(lp->id,"latlong") == 0 
-                            || strcmp(lp->id,"longlat") == 0 
+                        if( strcmp(lp->id,"latlong") == 0
+                            || strcmp(lp->id,"longlat") == 0
                             || strcmp(lp->id,"geocent") == 0 )
                             continue;
 
@@ -353,7 +356,7 @@ int main(int argc, char **argv) {
                 continue; /* artificial */
               case 'e': /* error line alternative */
                 if (--argc <= 0)
-                    noargument:			   
+                    noargument:
                 emess(1,"missing argument for -%c",*arg);
                 oterr = *++argv;
                 continue;
@@ -364,7 +367,7 @@ int main(int argc, char **argv) {
               case 'm': /* cartesian multiplier */
                 if (--argc <= 0) goto noargument;
                 postscale = 1;
-                if (!strncmp("1/",*++argv,2) || 
+                if (!strncmp("1/",*++argv,2) ||
                     !strncmp("1:",*argv,2)) {
                     if((fscale = atof((*argv)+2)) == 0.)
                         goto badscale;
diff --git a/src/proj.def b/src/proj.def
index f314655..1f228a6 100644
--- a/src/proj.def
+++ b/src/proj.def
@@ -1,76 +1,91 @@
-VERSION	  1.2
+VERSION   1.2
 EXPORTS
-	pj_init			@1
-	pj_fwd			@2
-	pj_inv			@3
-	pj_free			@4
-	pj_transform		@5
-	pj_geocentric_to_geodetic @6
-	pj_geodetic_to_geocentric @7
-	pj_deallocate_grids	@8
-	pj_init_plus		@9
-	pj_latlong_from_proj	@10
-	pj_is_latlong		@11
-	pj_get_errno_ref	@12
-	pj_set_finder		@13
-	pj_strerrno		@14
-	pj_errno		@15
-	pj_get_def		@16
-	pj_dalloc		@17
-	pj_is_geocent		@18
-	pj_get_release		@19
-	pj_malloc		@20
-	pj_pr_list		@21
-	pj_compare_datums	@22
-	pj_apply_gridshift	@23
-	pj_datum_transform	@24
-	pj_set_searchpath	@25
-	dmstor			@26
-	pj_get_ellps_ref	@27
-	pj_get_datums_ref	@28
-	pj_get_units_ref	@29
-	pj_get_list_ref		@30
-	pj_get_prime_meridians_ref @31
-	rtodms			@32
-	set_rtodms		@33
-	pj_factors		@34
-	mk_cheby		@35
-	adjlon			@36
-	pj_param		@37
-	pj_ell_set		@38
-	pj_mkparam		@39
-	pj_init_ctx		@40
-	pj_init_plus_ctx	@41
-	pj_get_default_ctx	@42
-	pj_get_ctx		@43
-	pj_set_ctx		@44
-	pj_ctx_alloc		@45
-	pj_ctx_free		@46
-	pj_ctx_get_errno	@47
-	pj_ctx_set_errno	@48
-	pj_ctx_set_debug	@49
-	pj_ctx_set_logger	@50
-	pj_ctx_set_app_data	@51
-	pj_ctx_get_app_data	@52
-	pj_log			@53
-	pj_clear_initcache	@54
-	geod_init		@55
-	geod_lineinit		@56
-	geod_genposition	@57
-	geod_position		@58
-	geod_gendirect		@59
-	geod_direct		@60
-	geod_geninverse		@61
-	geod_inverse		@62
-	geod_polygonarea	@63
-	pj_get_spheroid_defn	@64
-	pj_get_default_fileapi  @65
-	pj_ctx_set_fileapi      @66
-	pj_ctx_get_fileapi      @67
-	pj_ctx_fopen            @68
-	pj_ctx_fread            @69
-	pj_ctx_ftell            @70
-	pj_ctx_fclose           @71
-	pj_open_lib             @72
-	pj_atof                 @73
-	pj_strtod               @74
+    pj_init                         @1
+    pj_fwd                          @2
+    pj_inv                          @3
+    pj_free                         @4
+    pj_transform                    @5
+    pj_geocentric_to_geodetic       @6
+    pj_geodetic_to_geocentric       @7
+    pj_deallocate_grids             @8
+    pj_init_plus                    @9
+    pj_latlong_from_proj            @10
+    pj_is_latlong                   @11
+    pj_get_errno_ref                @12
+    pj_set_finder                   @13
+    pj_strerrno                     @14
+    pj_errno                        @15
+    pj_get_def                      @16
+    pj_dalloc                       @17
+    pj_is_geocent                   @18
+    pj_get_release                  @19
+    pj_malloc                       @20
+    pj_pr_list                      @21
+    pj_compare_datums               @22
+    pj_apply_gridshift              @23
+    pj_datum_transform              @24
+    pj_set_searchpath               @25
+    dmstor                          @26
+    pj_get_ellps_ref                @27
+    pj_get_datums_ref               @28
+    pj_get_units_ref                @29
+    pj_get_list_ref                 @30
+    pj_get_prime_meridians_ref      @31
+    rtodms                          @32
+    set_rtodms                      @33
+    pj_factors                      @34
+    mk_cheby                        @35
+    adjlon                          @36
+    pj_param                        @37
+    pj_ell_set                      @38
+    pj_mkparam                      @39
+    pj_init_ctx                     @40
+    pj_init_plus_ctx                @41
+    pj_get_default_ctx              @42
+    pj_get_ctx                      @43
+    pj_set_ctx                      @44
+    pj_ctx_alloc                    @45
+    pj_ctx_free                     @46
+    pj_ctx_get_errno                @47
+    pj_ctx_set_errno                @48
+    pj_ctx_set_debug                @49
+    pj_ctx_set_logger               @50
+    pj_ctx_set_app_data             @51
+    pj_ctx_get_app_data             @52
+    pj_log                          @53
+    pj_clear_initcache              @54
+    geod_init                       @55
+    geod_lineinit                   @56
+    geod_genposition                @57
+    geod_position                   @58
+    geod_gendirect                  @59
+    geod_direct                     @60
+    geod_geninverse                 @61
+    geod_inverse                    @62
+    geod_polygonarea                @63
+    pj_get_spheroid_defn            @64
+    pj_get_default_fileapi          @65
+    pj_ctx_set_fileapi              @66
+    pj_ctx_get_fileapi              @67
+    pj_ctx_fopen                    @68
+    pj_ctx_fread                    @69
+    pj_ctx_ftell                    @70
+    pj_ctx_fclose                   @71
+    pj_open_lib                     @72
+    pj_atof                         @73
+    pj_strtod                       @74
+    pj_fwd3d                        @75
+    pj_inv3d                        @76
+    geod_gensetdistance             @77
+    geod_setdistance                @78
+    geod_gendirectline              @79
+    geod_directline                 @80
+    geod_inverseline                @81
+    geod_polygon_init               @82
+    geod_polygon_addedge            @83
+    geod_polygon_addpoint           @84
+    geod_polygon_compute            @85
+    geod_polygon_testedge           @86
+    geod_polygon_testpoint          @87
+    geod_polygon_clear              @88
+    pj_run_selftests                @89
diff --git a/src/proj_api.h b/src/proj_api.h
index 99faeaf..24a6f05 100644
--- a/src/proj_api.h
+++ b/src/proj_api.h
@@ -37,8 +37,19 @@
 extern "C" {
 #endif
 
-/* Try to update this every version! */
-#define PJ_VERSION 492
+/*
+ * This version number should be updated with every release!  The format of
+ * PJ_VERSION is
+ *
+ * * Before version 4.10.0: PJ_VERSION=MNP where M, N, and P are the major,
+ *   minor, and patch numbers; e.g., PJ_VERSION=493 for version 4.9.3.
+ *
+ * * Version 4.10.0 and later: PJ_VERSION=MMMNNNPP later where MMM, NNN, PP
+ *   are the major, minor, and patch numbers (the minor and patch numbers
+ *   are padded with leading zeros if necessary); e.g., PJ_VERSION=401000
+ *   for version 4.10.0.
+ */
+#define PJ_VERSION 493
 
 /* pj_init() and similar functions can be used with a non-C locale */
 /* Can be detected too at runtime if the symbol pj_atof exists */
@@ -46,23 +57,28 @@ extern "C" {
 
 extern char const pj_release[]; /* global release id string */
 
-#define RAD_TO_DEG	57.29577951308232
-#define DEG_TO_RAD	.0174532925199432958
+#define RAD_TO_DEG	57.295779513082321
+#define DEG_TO_RAD	.017453292519943296
 
 
 extern int pj_errno;	/* global error return code */
 
 #if !defined(PROJECTS_H)
     typedef struct { double u, v; } projUV;
+    typedef struct { double u, v, w; } projUVW;
     typedef void *projPJ;
     #define projXY projUV
     #define projLP projUV
+    #define projXYZ projUVW
+    #define projLPZ projUVW
     typedef void *projCtx;
 #else
     typedef PJ *projPJ;
     typedef projCtx_t *projCtx;
 #   define projXY	XY
 #   define projLP       LP
+#   define projXYZ      XYZ
+#   define projLPZ      LPZ
 #endif
 
 /* file reading api, like stdio */
@@ -80,6 +96,9 @@ typedef struct projFileAPI_t {
 projXY pj_fwd(projLP, projPJ);
 projLP pj_inv(projXY, projPJ);
 
+projXYZ pj_fwd3d(projLPZ, projPJ);
+projLPZ pj_inv3d(projXYZ, projPJ);
+
 int pj_transform( projPJ src, projPJ dst, long point_count, int point_offset,
                   double *x, double *y, double *z );
 int pj_datum_transform( projPJ src, projPJ dst, long point_count, int point_offset,
@@ -111,6 +130,8 @@ char *pj_get_def(projPJ, int);
 projPJ pj_latlong_from_proj( projPJ );
 void *pj_malloc(size_t);
 void pj_dalloc(void *);
+void *pj_calloc (size_t n, size_t size);
+void *pj_dealloc (void *ptr);
 char *pj_strerrno(int);
 int *pj_get_errno_ref(void);
 const char *pj_get_release(void);
@@ -147,6 +168,9 @@ char  *pj_ctx_fgets(projCtx ctx, char *line, int size, PAFile file);
 
 PAFile pj_open_lib(projCtx, const char *, const char *);
 
+int pj_run_selftests (int verbosity);
+
+
 #define PJ_LOG_NONE        0
 #define PJ_LOG_ERROR       1
 #define PJ_LOG_DEBUG_MAJOR 2
diff --git a/src/proj_config.h.in b/src/proj_config.h.in
index 9e3c731..f78a8d3 100644
--- a/src/proj_config.h.in
+++ b/src/proj_config.h.in
@@ -1,4 +1,4 @@
-/* src/proj_config.h.in.  Generated from configure.in by autoheader.  */
+/* src/proj_config.h.in.  Generated from configure.ac by autoheader.  */
 
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
@@ -48,8 +48,7 @@
 /* Enabled for Java/JNI Support */
 #undef JNI_ENABLED
 
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
 /* Name of package */
diff --git a/src/proj_etmerc.c b/src/proj_etmerc.c
index 1097eb3..61ba41a 100644
--- a/src/proj_etmerc.c
+++ b/src/proj_etmerc.c
@@ -35,31 +35,37 @@
  *
  * Modified and used here by permission of Reference Networks
  * Division, Kort og Matrikelstyrelsen (KMS), Copenhagen, Denmark
+ *
 */
 
-#define PROJ_PARMS__ \
+
+#define PROJ_LIB__
+#define PJ_LIB__
+
+#include <projects.h>
+
+
+struct pj_opaque {
     double    Qn;    /* Merid. quad., scaled to the projection */ \
     double    Zb;    /* Radius vector in polar coord. systems  */ \
     double    cgb[6]; /* Constants for Gauss -> Geo lat */ \
     double    cbg[6]; /* Constants for Geo lat -> Gauss */ \
     double    utg[6]; /* Constants for transv. merc. -> geo */ \
     double    gtu[6]; /* Constants for geo -> transv. merc. */
-
-#define PROJ_LIB__
-#define PJ_LIB__
-
-#include <projects.h>
+};
 
 PROJ_HEAD(etmerc, "Extended Transverse Mercator")
     "\n\tCyl, Sph\n\tlat_ts=(0)\nlat_0=(0)";
+PROJ_HEAD(utm, "Universal Transverse Mercator (UTM)")
+	"\n\tCyl, Sph\n\tzone= south";
 
 #define PROJ_ETMERC_ORDER 6
 
+
 #ifdef _GNU_SOURCE
     inline
 #endif
-    static double
-log1py(double x) {              /* Compute log(1+x) accurately */
+static double log1py(double x) {              /* Compute log(1+x) accurately */
     volatile double
       y = 1 + x,
       z = y - 1;
@@ -70,21 +76,21 @@ log1py(double x) {              /* Compute log(1+x) accurately */
     return z == 0 ? x : x * log(y) / z;
 }
 
+
 #ifdef _GNU_SOURCE
     inline
 #endif
-    static double
-asinhy(double x) {              /* Compute asinh(x) accurately */
+static double asinhy(double x) {              /* Compute asinh(x) accurately */
     double y = fabs(x);         /* Enforce odd parity */
     y = log1py(y * (1 + y/(hypot(1.0, y) + 1)));
     return x < 0 ? -y : y;
 }
 
+
 #ifdef _GNU_SOURCE
     inline
 #endif
-    static double
-gatg(double *p1, int len_p1, double B) {
+static double gatg(double *p1, int len_p1, double B) {
     double *p;
     double h = 0, h1, h2 = 0, cos_2B;
 
@@ -94,11 +100,11 @@ gatg(double *p1, int len_p1, double B) {
     return (B + h*sin(2*B));
 }
 
+/* Complex Clenshaw summation */
 #ifdef _GNU_SOURCE
     inline
 #endif
-    static double
-clenS(double *a, int size, double arg_r, double arg_i, double *R, double *I) {
+static double clenS(double *a, int size, double arg_r, double arg_i, double *R, double *I) {
     double      *p, r, i, hr, hr1, hr2, hi, hi1, hi2;
     double      sin_arg_r, cos_arg_r, sinh_arg_i, cosh_arg_i;
 
@@ -114,6 +120,7 @@ clenS(double *a, int size, double arg_r, double arg_i, double *R, double *I) {
     cosh_arg_i = cosh(arg_i);
     r          =  2*cos_arg_r*cosh_arg_i;
     i          = -2*sin_arg_r*sinh_arg_i;
+
     /* summation loop */
     for (hi1 = hr1 = hi = 0, hr = *--p; a - p;) {
         hr2 = hr1;
@@ -123,99 +130,132 @@ clenS(double *a, int size, double arg_r, double arg_i, double *R, double *I) {
         hr  = -hr2 + r*hr1 - i*hi1 + *--p;
         hi  = -hi2 + i*hr1 + r*hi1;
     }
+
     r   = sin_arg_r*cosh_arg_i;
     i   = cos_arg_r*sinh_arg_i;
     *R  = r*hr - i*hi;
     *I  = r*hi + i*hr;
-    return(*R);
+    return *R;
 }
-    static double
-clens(double *a, int size, double arg_r) {
+
+
+/* Real Clenshaw summation */
+static double clens(double *a, int size, double arg_r) {
     double      *p, r, hr, hr1, hr2, cos_arg_r;
 
     p = a + size;
     cos_arg_r  = cos(arg_r);
     r          =  2*cos_arg_r;
+
     /* summation loop */
     for (hr1 = 0, hr = *--p; a - p;) {
         hr2 = hr1;
         hr1 = hr;
         hr  = -hr2 + r*hr1 + *--p;
     }
-    return(sin(arg_r)*hr);
+    return sin (arg_r)*hr;
 }
 
-FORWARD(e_forward); /* ellipsoid */
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
     double sin_Cn, cos_Cn, cos_Ce, sin_Ce, dCn, dCe;
     double Cn = lp.phi, Ce = lp.lam;
 
     /* ell. LAT, LNG -> Gaussian LAT, LNG */
-    Cn  = gatg(P->cbg, PROJ_ETMERC_ORDER, Cn);
+    Cn  = gatg (Q->cbg, PROJ_ETMERC_ORDER, Cn);
     /* Gaussian LAT, LNG -> compl. sph. LAT */
 #ifdef _GNU_SOURCE
-    sincos(Cn, &sin_Cn, &cos_Cn);
-    sincos(Ce, &sin_Ce, &cos_Ce);
+    sincos (Cn, &sin_Cn, &cos_Cn);
+    sincos (Ce, &sin_Ce, &cos_Ce);
 #else
-    sin_Cn = sin(Cn);
-    cos_Cn = cos(Cn);
-    sin_Ce = sin(Ce);
-    cos_Ce = cos(Ce);
+    sin_Cn = sin (Cn);
+    cos_Cn = cos (Cn);
+    sin_Ce = sin (Ce);
+    cos_Ce = cos (Ce);
 #endif
 
-    Cn     = atan2(sin_Cn, cos_Ce*cos_Cn);
-    Ce     = atan2(sin_Ce*cos_Cn, hypot(sin_Cn, cos_Cn*cos_Ce));
+    Cn     = atan2 (sin_Cn, cos_Ce*cos_Cn);
+    Ce     = atan2 (sin_Ce*cos_Cn,  hypot (sin_Cn, cos_Cn*cos_Ce));
+
     /* compl. sph. N, E -> ell. norm. N, E */
-    Ce  = asinhy(tan(Ce));     /* Replaces: Ce  = log(tan(FORTPI + Ce*0.5)); */
-    Cn += clenS(P->gtu, PROJ_ETMERC_ORDER, 2*Cn, 2*Ce, &dCn, &dCe);
+    Ce  = asinhy ( tan (Ce) );     /* Replaces: Ce  = log(tan(FORTPI + Ce*0.5)); */
+    Cn += clenS (Q->gtu, PROJ_ETMERC_ORDER, 2*Cn, 2*Ce, &dCn, &dCe);
     Ce += dCe;
-    if (fabs(Ce) <= 2.623395162778) {
-        xy.y  = P->Qn * Cn + P->Zb;  /* Northing */
-        xy.x  = P->Qn * Ce;  /* Easting  */
+    if (fabs (Ce) <= 2.623395162778) {
+        xy.y  = Q->Qn * Cn + Q->Zb;  /* Northing */
+        xy.x  = Q->Qn * Ce;          /* Easting  */
     } else
         xy.x = xy.y = HUGE_VAL;
-    return (xy);
+    return xy;
 }
 
-INVERSE(e_inverse); /* ellipsoid */
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
     double sin_Cn, cos_Cn, cos_Ce, sin_Ce, dCn, dCe;
     double Cn = xy.y, Ce = xy.x;
 
     /* normalize N, E */
-    Cn = (Cn - P->Zb)/P->Qn;
-    Ce = Ce/P->Qn;
+    Cn = (Cn - Q->Zb)/Q->Qn;
+    Ce = Ce/Q->Qn;
+
     if (fabs(Ce) <= 2.623395162778) { /* 150 degrees */
-    /* norm. N, E -> compl. sph. LAT, LNG */
-        Cn += clenS(P->utg, PROJ_ETMERC_ORDER, 2*Cn, 2*Ce, &dCn, &dCe);
+        /* norm. N, E -> compl. sph. LAT, LNG */
+        Cn += clenS(Q->utg, PROJ_ETMERC_ORDER, 2*Cn, 2*Ce, &dCn, &dCe);
         Ce += dCe;
-        Ce = atan(sinh(Ce)); /* Replaces: Ce = 2*(atan(exp(Ce)) - FORTPI); */
+        Ce = atan (sinh (Ce)); /* Replaces: Ce = 2*(atan(exp(Ce)) - FORTPI); */
         /* compl. sph. LAT -> Gaussian LAT, LNG */
 #ifdef _GNU_SOURCE
-        sincos(Cn, &sin_Cn, &cos_Cn);
-        sincos(Ce, &sin_Ce, &cos_Ce);
+        sincos (Cn, &sin_Cn, &cos_Cn);
+        sincos (Ce, &sin_Ce, &cos_Ce);
 #else
-        sin_Cn = sin(Cn);
-        cos_Cn = cos(Cn);
-        sin_Ce = sin(Ce);
-        cos_Ce = cos(Ce);
+        sin_Cn = sin (Cn);
+        cos_Cn = cos (Cn);
+        sin_Ce = sin (Ce);
+        cos_Ce = cos (Ce);
 #endif
-        Ce     = atan2(sin_Ce, cos_Ce*cos_Cn);
-        Cn     = atan2(sin_Cn*cos_Ce, hypot(sin_Ce, cos_Ce*cos_Cn));
+        Ce     = atan2 (sin_Ce, cos_Ce*cos_Cn);
+        Cn     = atan2 (sin_Cn*cos_Ce,  hypot (sin_Ce, cos_Ce*cos_Cn));
         /* Gaussian LAT, LNG -> ell. LAT, LNG */
-        lp.phi = gatg(P->cgb,  PROJ_ETMERC_ORDER, Cn);
+        lp.phi = gatg (Q->cgb,  PROJ_ETMERC_ORDER, Cn);
         lp.lam = Ce;
     }
     else
         lp.phi = lp.lam = HUGE_VAL;
-    return (lp);
+    return lp;
+}
+
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
 }
 
-FREEUP; if (P) free(P); }
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
+}
 
-ENTRY0(etmerc)
+static PJ *setup(PJ *P) { /* general initialization */
     double f, n, np, Z;
+    struct pj_opaque *Q = P->opaque;
+
+    if (P->es <= 0)
+        E_ERROR(-34);
+
+    /* flattening */
+    f = P->es / (1 + sqrt (1 -  P->es)); /* Replaces: f = 1 - sqrt(1-P->es); */
 
-    if (P->es <= 0) E_ERROR(-34);
-    f = P->es / (1 + sqrt(1 -  P->es)); /* Replaces: f = 1 - sqrt(1-P->es); */
     /* third flattening */
     np = n = f/(2 - f);
 
@@ -223,67 +263,217 @@ ENTRY0(etmerc)
     /* cgb := Gaussian -> Geodetic, KW p190 - 191 (61) - (62) */
     /* cbg := Geodetic -> Gaussian, KW p186 - 187 (51) - (52) */
     /* PROJ_ETMERC_ORDER = 6th degree : Engsager and Poder: ICC2007 */
-    P->cgb[0] = n*( 2 + n*(-2/3.0  + n*(-2      + n*(116/45.0 + n*(26/45.0 +
+
+    Q->cgb[0] = n*( 2 + n*(-2/3.0  + n*(-2      + n*(116/45.0 + n*(26/45.0 +
                 n*(-2854/675.0 ))))));
-    P->cbg[0] = n*(-2 + n*( 2/3.0  + n*( 4/3.0  + n*(-82/45.0 + n*(32/45.0 +
+    Q->cbg[0] = n*(-2 + n*( 2/3.0  + n*( 4/3.0  + n*(-82/45.0 + n*(32/45.0 +
                 n*( 4642/4725.0))))));
     np     *= n;
-    P->cgb[1] = np*(7/3.0 + n*( -8/5.0  + n*(-227/45.0 + n*(2704/315.0 +
+    Q->cgb[1] = np*(7/3.0 + n*( -8/5.0  + n*(-227/45.0 + n*(2704/315.0 +
                 n*( 2323/945.0)))));
-    P->cbg[1] = np*(5/3.0 + n*(-16/15.0 + n*( -13/9.0  + n*( 904/315.0 +
+    Q->cbg[1] = np*(5/3.0 + n*(-16/15.0 + n*( -13/9.0  + n*( 904/315.0 +
                 n*(-1522/945.0)))));
     np     *= n;
     /* n^5 coeff corrected from 1262/105 -> -1262/105 */
-    P->cgb[2] = np*( 56/15.0  + n*(-136/35.0 + n*(-1262/105.0 +
+    Q->cgb[2] = np*( 56/15.0  + n*(-136/35.0 + n*(-1262/105.0 +
                 n*( 73814/2835.0))));
-    P->cbg[2] = np*(-26/15.0  + n*(  34/21.0 + n*(    8/5.0   +
+    Q->cbg[2] = np*(-26/15.0  + n*(  34/21.0 + n*(    8/5.0   +
                 n*(-12686/2835.0))));
     np     *= n;
     /* n^5 coeff corrected from 322/35 -> 332/35 */
-    P->cgb[3] = np*(4279/630.0 + n*(-332/35.0 + n*(-399572/14175.0)));
-    P->cbg[3] = np*(1237/630.0 + n*( -12/5.0  + n*( -24832/14175.0)));
+    Q->cgb[3] = np*(4279/630.0 + n*(-332/35.0 + n*(-399572/14175.0)));
+    Q->cbg[3] = np*(1237/630.0 + n*( -12/5.0  + n*( -24832/14175.0)));
     np     *= n;
-    P->cgb[4] = np*(4174/315.0 + n*(-144838/6237.0 ));
-    P->cbg[4] = np*(-734/315.0 + n*( 109598/31185.0));
+    Q->cgb[4] = np*(4174/315.0 + n*(-144838/6237.0 ));
+    Q->cbg[4] = np*(-734/315.0 + n*( 109598/31185.0));
     np     *= n;
-    P->cgb[5] = np*(601676/22275.0 );
-    P->cbg[5] = np*(444337/155925.0);
+    Q->cgb[5] = np*(601676/22275.0 );
+    Q->cbg[5] = np*(444337/155925.0);
 
     /* Constants of the projections */
     /* Transverse Mercator (UTM, ITM, etc) */
     np = n*n;
     /* Norm. mer. quad, K&W p.50 (96), p.19 (38b), p.5 (2) */
-    P->Qn = P->k0/(1 + n) * (1 + np*(1/4.0 + np*(1/64.0 + np/256.0)));
+    Q->Qn = P->k0/(1 + n) * (1 + np*(1/4.0 + np*(1/64.0 + np/256.0)));
     /* coef of trig series */
     /* utg := ell. N, E -> sph. N, E,  KW p194 (65) */
     /* gtu := sph. N, E -> ell. N, E,  KW p196 (69) */
-    P->utg[0] = n*(-0.5  + n*( 2/3.0 + n*(-37/96.0 + n*( 1/360.0 +
+    Q->utg[0] = n*(-0.5  + n*( 2/3.0 + n*(-37/96.0 + n*( 1/360.0 +
                 n*(  81/512.0 + n*(-96199/604800.0))))));
-    P->gtu[0] = n*( 0.5  + n*(-2/3.0 + n*(  5/16.0 + n*(41/180.0 +
+    Q->gtu[0] = n*( 0.5  + n*(-2/3.0 + n*(  5/16.0 + n*(41/180.0 +
                 n*(-127/288.0 + n*(  7891/37800.0 ))))));
-    P->utg[1] = np*(-1/48.0 + n*(-1/15.0 + n*(437/1440.0 + n*(-46/105.0 +
+    Q->utg[1] = np*(-1/48.0 + n*(-1/15.0 + n*(437/1440.0 + n*(-46/105.0 +
                 n*( 1118711/3870720.0)))));
-    P->gtu[1] = np*(13/48.0 + n*(-3/5.0  + n*(557/1440.0 + n*(281/630.0 +
+    Q->gtu[1] = np*(13/48.0 + n*(-3/5.0  + n*(557/1440.0 + n*(281/630.0 +
                 n*(-1983433/1935360.0)))));
     np      *= n;
-    P->utg[2] = np*(-17/480.0 + n*(  37/840.0 + n*(  209/4480.0  +
+    Q->utg[2] = np*(-17/480.0 + n*(  37/840.0 + n*(  209/4480.0  +
                 n*( -5569/90720.0 ))));
-    P->gtu[2] = np*( 61/240.0 + n*(-103/140.0 + n*(15061/26880.0 +
+    Q->gtu[2] = np*( 61/240.0 + n*(-103/140.0 + n*(15061/26880.0 +
                 n*(167603/181440.0))));
     np      *= n;
-    P->utg[3] = np*(-4397/161280.0 + n*(  11/504.0 + n*( 830251/7257600.0)));
-    P->gtu[3] = np*(49561/161280.0 + n*(-179/168.0 + n*(6601661/7257600.0)));
+    Q->utg[3] = np*(-4397/161280.0 + n*(  11/504.0 + n*( 830251/7257600.0)));
+    Q->gtu[3] = np*(49561/161280.0 + n*(-179/168.0 + n*(6601661/7257600.0)));
     np     *= n;
-    P->utg[4] = np*(-4583/161280.0 + n*(  108847/3991680.0));
-    P->gtu[4] = np*(34729/80640.0  + n*(-3418889/1995840.0));
+    Q->utg[4] = np*(-4583/161280.0 + n*(  108847/3991680.0));
+    Q->gtu[4] = np*(34729/80640.0  + n*(-3418889/1995840.0));
     np     *= n;
-    P->utg[5] = np*(-20648693/638668800.0);
-    P->gtu[5] = np*(212378941/319334400.0);
+    Q->utg[5] = np*(-20648693/638668800.0);
+    Q->gtu[5] = np*(212378941/319334400.0);
+
     /* Gaussian latitude value of the origin latitude */
-    Z = gatg(P->cbg, PROJ_ETMERC_ORDER, P->phi0);
+    Z = gatg (Q->cbg, PROJ_ETMERC_ORDER, P->phi0);
+
     /* Origin northing minus true northing at the origin latitude */
     /* i.e. true northing = N - P->Zb                         */
-    P->Zb  = - P->Qn*(Z + clens(P->gtu, PROJ_ETMERC_ORDER, 2*Z));
+    Q->Zb  = - Q->Qn*(Z + clens(Q->gtu, PROJ_ETMERC_ORDER, 2*Z));
     P->inv = e_inverse;
     P->fwd = e_forward;
-ENDENTRY(P)
+	return P;
+}
+
+
+
+PJ *PROJECTION(etmerc) {
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+   return setup (P);
+}
+
+
+
+
+
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_etmerc_selftest (void) {return 0;}
+#else
+
+int pj_etmerc_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=etmerc   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5 +zone=30"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {222650.79679758562,  110642.22941193319},
+        {222650.79679758562,  -110642.22941193319},
+        {-222650.79679758562,  110642.22941193319},
+        {-222650.79679758562,  -110642.22941193319},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {0.0017966305681649398,  0.00090436947663183873},
+        {0.0017966305681649398,  -0.00090436947663183873},
+        {-0.0017966305681649398,  0.00090436947663183873},
+        {-0.0017966305681649398,  -0.00090436947663183873},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+/* utm uses etmerc for the underlying projection */
+
+
+PJ *PROJECTION(utm) {
+	int zone;
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+	if (!P->es)
+        E_ERROR(-34);
+	P->y0 = pj_param (P->ctx, P->params, "bsouth").i ? 10000000. : 0.;
+	P->x0 = 500000.;
+	if (pj_param (P->ctx, P->params, "tzone").i) /* zone input ? */
+		if ((zone = pj_param(P->ctx, P->params, "izone").i) > 0 && zone <= 60)
+			--zone;
+		else
+			E_ERROR(-35)
+	else /* nearest central meridian input */
+		if ((zone = (int)(floor ((adjlon (P->lam0) + M_PI) * 30. / M_PI))) < 0)
+			zone = 0;
+		else if (zone >= 60)
+			zone = 59;
+	P->lam0 = (zone + .5) * M_PI / 30. - M_PI;
+	P->k0 = 0.9996;
+	P->phi0 = 0.;
+
+    return setup (P);
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_utm_selftest (void) {return 0;}
+#else
+
+int pj_utm_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=utm   +ellps=GRS80  +lat_1=0.5 +lat_2=2 +n=0.5 +zone=30"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        {1057002.4054912981,  110955.14117594929},
+        {1057002.4054912981,  -110955.14117594929},
+        {611263.81227890507,  110547.10569680421},
+        {611263.81227890507,  -110547.10569680421},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        {-7.4869520833902357,  0.00090193980983462605},
+        {-7.4869520833902357,  -0.00090193980983462605},
+        {-7.4905356820622613,  0.00090193535121489081},
+        {-7.4905356820622613,  -0.00090193535121489081},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
+#endif
+
+
+
diff --git a/src/proj_rouss.c b/src/proj_rouss.c
index f1c2f5a..fc9918b 100644
--- a/src/proj_rouss.c
+++ b/src/proj_rouss.c
@@ -23,98 +23,176 @@
 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
-#define PROJ_PARMS__ \
-	double s0; \
-	double A1, A2, A3, A4, A5, A6; \
-	double B1, B2, B3, B4, B5, B6, B7, B8; \
-	double C1, C2, C3, C4, C5, C6, C7, C8; \
-	double D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11; \
-	void *en;
 #define PJ_LIB__
-# include <projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+    double s0;
+    double A1, A2, A3, A4, A5, A6;
+    double B1, B2, B3, B4, B5, B6, B7, B8;
+    double C1, C2, C3, C4, C5, C6, C7, C8;
+    double D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11;
+    void *en;
+};
 PROJ_HEAD(rouss, "Roussilhe Stereographic") "\n\tAzi., Ellps.";
-FORWARD(e_forward); /* ellipsoid */
-	double s, al, cp, sp, al2, s2;
-	
-	cp = cos(lp.phi);
-	sp = sin(lp.phi);
-	s = proj_mdist(lp.phi, sp, cp,  P->en) - P->s0;
-	s2 = s * s;
-	al = lp.lam * cp / sqrt(1. - P->es * sp * sp);
-	al2 = al * al;
-	xy.x = P->k0 * al*(1.+s2*(P->A1+s2*P->A4)-al2*(P->A2+s*P->A3+s2*P->A5
-				+al2*P->A6));
-	xy.y = P->k0 * (al2*(P->B1+al2*P->B4)+
-		s*(1.+al2*(P->B3-al2*P->B6)+s2*(P->B2+s2*P->B8)+
-		s*al2*(P->B5+s*P->B7)));
-	return (xy);
+
+
+static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
+    XY xy = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double s, al, cp, sp, al2, s2;
+
+    cp = cos(lp.phi);
+    sp = sin(lp.phi);
+    s = proj_mdist(lp.phi, sp, cp,  Q->en) - Q->s0;
+    s2 = s * s;
+    al = lp.lam * cp / sqrt(1. - P->es * sp * sp);
+    al2 = al * al;
+    xy.x = P->k0 * al*(1.+s2*(Q->A1+s2*Q->A4)-al2*(Q->A2+s*Q->A3+s2*Q->A5
+                +al2*Q->A6));
+    xy.y = P->k0 * (al2*(Q->B1+al2*Q->B4)+
+        s*(1.+al2*(Q->B3-al2*Q->B6)+s2*(Q->B2+s2*Q->B8)+
+        s*al2*(Q->B5+s*Q->B7)));
+
+    return xy;
 }
-INVERSE(e_inverse); /* ellipsoid */
-	double s, al, x = xy.x / P->k0, y = xy.y / P->k0, x2, y2;;
-
-	x2 = x * x;
-	y2 = y * y;
-	al = x*(1.-P->C1*y2+x2*(P->C2+P->C3*y-P->C4*x2+P->C5*y2-P->C7*x2*y)
-		+y2*(P->C6*y2-P->C8*x2*y));
-	s = P->s0 + y*(1.+y2*(-P->D2+P->D8*y2))+
-		x2*(-P->D1+y*(-P->D3+y*(-P->D5+y*(-P->D7+y*P->D11)))+
-		x2*(P->D4+y*(P->D6+y*P->D10)-x2*P->D9));
-	lp.phi=proj_inv_mdist(P->ctx, s, P->en);
-	s = sin(lp.phi);
-	lp.lam=al * sqrt(1. - P->es * s * s)/cos(lp.phi);
-	return (lp);
+
+
+static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
+    LP lp = {0.0,0.0};
+    struct pj_opaque *Q = P->opaque;
+    double s, al, x = xy.x / P->k0, y = xy.y / P->k0, x2, y2;;
+
+    x2 = x * x;
+    y2 = y * y;
+    al = x*(1.-Q->C1*y2+x2*(Q->C2+Q->C3*y-Q->C4*x2+Q->C5*y2-Q->C7*x2*y)
+        +y2*(Q->C6*y2-Q->C8*x2*y));
+    s = Q->s0 + y*(1.+y2*(-Q->D2+Q->D8*y2))+
+        x2*(-Q->D1+y*(-Q->D3+y*(-Q->D5+y*(-Q->D7+y*Q->D11)))+
+        x2*(Q->D4+y*(Q->D6+y*Q->D10)-x2*Q->D9));
+    lp.phi=proj_inv_mdist(P->ctx, s, Q->en);
+    s = sin(lp.phi);
+    lp.lam=al * sqrt(1. - P->es * s * s)/cos(lp.phi);
+
+    return lp;
 }
-FREEUP;
-	if (P) {
-		if (P->en)
-			free(P->en);
-		free(P);
-	}
+
+
+static void *freeup_new (PJ *P) {                       /* Destructor */
+    if (0==P)
+        return 0;
+    if (0==P->opaque)
+        return pj_dealloc (P);
+
+    if (P->opaque->en)
+        pj_dealloc (P->opaque->en);
+    pj_dealloc (P->opaque);
+    return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+    freeup_new (P);
+    return;
 }
-ENTRY1(rouss, en)
-	double N0, es2, t, t2, R_R0_2, R_R0_4;
-
-	if (!((P->en = proj_mdist_ini(P->es))))
-		E_ERROR_0;
-	es2 = sin(P->phi0);
-	P->s0 = proj_mdist(P->phi0, es2, cos(P->phi0), P->en);
-	t = 1. - (es2 = P->es * es2 * es2);
-	N0 = 1./sqrt(t);
-	R_R0_2 = t * t / P->one_es;
-	R_R0_4 = R_R0_2 * R_R0_2;
-	t = tan(P->phi0);
-	t2 = t * t;
-	P->C1 = P->A1 = R_R0_2 / 4.;
-	P->C2 = P->A2 = R_R0_2 * (2 * t2 - 1. - 2. * es2) / 12.;
-	P->A3 = R_R0_2 * t * (1. + 4. * t2)/ ( 12. * N0);
-	P->A4 = R_R0_4 / 24.;
-	P->A5 = R_R0_4 * ( -1. + t2 * (11. + 12. * t2))/24.;
-	P->A6 = R_R0_4 * ( -2. + t2 * (11. - 2. * t2))/240.;
-	P->B1 = t / (2. * N0);
-	P->B2 = R_R0_2 / 12.;
-	P->B3 = R_R0_2 * (1. + 2. * t2 - 2. * es2)/4.;
-	P->B4 = R_R0_2 * t * (2. - t2)/(24. * N0);
-	P->B5 = R_R0_2 * t * (5. + 4.* t2)/(8. * N0);
-	P->B6 = R_R0_4 * (-2. + t2 * (-5. + 6. * t2))/48.;
-	P->B7 = R_R0_4 * (5. + t2 * (19. + 12. * t2))/24.;
-	P->B8 = R_R0_4 / 120.;
-	P->C3 = R_R0_2 * t * (1. + t2)/(3. * N0);
-	P->C4 = R_R0_4 * (-3. + t2 * (34. + 22. * t2))/240.;
-	P->C5 = R_R0_4 * (4. + t2 * (13. + 12. * t2))/24.;
-	P->C6 = R_R0_4 / 16.;
-	P->C7 = R_R0_4 * t * (11. + t2 * (33. + t2 * 16.))/(48. * N0);
-	P->C8 = R_R0_4 * t * (1. + t2 * 4.)/(36. * N0);
-	P->D1 = t / (2. * N0);
-	P->D2 = R_R0_2 / 12.;
-	P->D3 = R_R0_2 * (2 * t2 + 1. - 2. * es2) / 4.;
-	P->D4 = R_R0_2 * t * (1. + t2)/(8. * N0);
-	P->D5 = R_R0_2 * t * (1. + t2 * 2.)/(4. * N0);
-	P->D6 = R_R0_4 * (1. + t2 * (6. + t2 * 6.))/16.;
-	P->D7 = R_R0_4 * t2 * (3. + t2 * 4.)/8.;
-	P->D8 = R_R0_4 / 80.;
-	P->D9 = R_R0_4 * t * (-21. + t2 * (178. - t2 * 26.))/720.;
-	P->D10 = R_R0_4 * t * (29. + t2 * (86. + t2 * 48.))/(96. * N0);
-	P->D11 = R_R0_4 * t * (37. + t2 * 44.)/(96. * N0);
-	P->fwd = e_forward;
-	P->inv = e_inverse;
-	ENDENTRY(P)
+
+
+PJ *PROJECTION(rouss) {
+    double N0, es2, t, t2, R_R0_2, R_R0_4;
+
+    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+    if (0==Q)
+        return freeup_new (P);
+    P->opaque = Q;
+
+    if (!((Q->en = proj_mdist_ini(P->es))))
+        E_ERROR_0;
+    es2 = sin(P->phi0);
+    Q->s0 = proj_mdist(P->phi0, es2, cos(P->phi0), Q->en);
+    t = 1. - (es2 = P->es * es2 * es2);
+    N0 = 1./sqrt(t);
+    R_R0_2 = t * t / P->one_es;
+    R_R0_4 = R_R0_2 * R_R0_2;
+    t = tan(P->phi0);
+    t2 = t * t;
+    Q->C1 = Q->A1 = R_R0_2 / 4.;
+    Q->C2 = Q->A2 = R_R0_2 * (2 * t2 - 1. - 2. * es2) / 12.;
+    Q->A3 = R_R0_2 * t * (1. + 4. * t2)/ ( 12. * N0);
+    Q->A4 = R_R0_4 / 24.;
+    Q->A5 = R_R0_4 * ( -1. + t2 * (11. + 12. * t2))/24.;
+    Q->A6 = R_R0_4 * ( -2. + t2 * (11. - 2. * t2))/240.;
+    Q->B1 = t / (2. * N0);
+    Q->B2 = R_R0_2 / 12.;
+    Q->B3 = R_R0_2 * (1. + 2. * t2 - 2. * es2)/4.;
+    Q->B4 = R_R0_2 * t * (2. - t2)/(24. * N0);
+    Q->B5 = R_R0_2 * t * (5. + 4.* t2)/(8. * N0);
+    Q->B6 = R_R0_4 * (-2. + t2 * (-5. + 6. * t2))/48.;
+    Q->B7 = R_R0_4 * (5. + t2 * (19. + 12. * t2))/24.;
+    Q->B8 = R_R0_4 / 120.;
+    Q->C3 = R_R0_2 * t * (1. + t2)/(3. * N0);
+    Q->C4 = R_R0_4 * (-3. + t2 * (34. + 22. * t2))/240.;
+    Q->C5 = R_R0_4 * (4. + t2 * (13. + 12. * t2))/24.;
+    Q->C6 = R_R0_4 / 16.;
+    Q->C7 = R_R0_4 * t * (11. + t2 * (33. + t2 * 16.))/(48. * N0);
+    Q->C8 = R_R0_4 * t * (1. + t2 * 4.)/(36. * N0);
+    Q->D1 = t / (2. * N0);
+    Q->D2 = R_R0_2 / 12.;
+    Q->D3 = R_R0_2 * (2 * t2 + 1. - 2. * es2) / 4.;
+    Q->D4 = R_R0_2 * t * (1. + t2)/(8. * N0);
+    Q->D5 = R_R0_2 * t * (1. + t2 * 2.)/(4. * N0);
+    Q->D6 = R_R0_4 * (1. + t2 * (6. + t2 * 6.))/16.;
+    Q->D7 = R_R0_4 * t2 * (3. + t2 * 4.)/8.;
+    Q->D8 = R_R0_4 / 80.;
+    Q->D9 = R_R0_4 * t * (-21. + t2 * (178. - t2 * 26.))/720.;
+    Q->D10 = R_R0_4 * t * (29. + t2 * (86. + t2 * 48.))/(96. * N0);
+    Q->D11 = R_R0_4 * t * (37. + t2 * 44.)/(96. * N0);
+
+    P->fwd = e_forward;
+    P->inv = e_inverse;
+
+    return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_rouss_selftest (void) {return 0;}
+#else
+
+int pj_rouss_selftest (void) {
+    double tolerance_lp = 1e-10;
+    double tolerance_xy = 1e-7;
+
+    char e_args[] = {"+proj=rouss   +ellps=GRS80  +lat_1=0.5 +lat_2=2"};
+
+    LP fwd_in[] = {
+        { 2, 1},
+        { 2,-1},
+        {-2, 1},
+        {-2,-1}
+    };
+
+    XY e_fwd_expect[] = {
+        { 222644.89413161727,  110611.09186837047},
+        { 222644.89413161727, -110611.09186837047},
+        {-222644.89413161727,  110611.09186837047},
+        {-222644.89413161727, -110611.09186837047},
+    };
+
+    XY inv_in[] = {
+        { 200, 100},
+        { 200,-100},
+        {-200, 100},
+        {-200,-100}
+    };
+
+    LP e_inv_expect[] = {
+        { 0.0017966305682019911,  0.00090436947683699559},
+        { 0.0017966305682019911, -0.00090436947683699559},
+        {-0.0017966305682019911,  0.00090436947683699559},
+        {-0.0017966305682019911, -0.00090436947683699559},
+    };
+
+    return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
+}
+
+
+#endif
diff --git a/src/projects.h b/src/projects.h
index fe6a44c..9aca7d9 100644
--- a/src/projects.h
+++ b/src/projects.h
@@ -48,7 +48,7 @@
 #define C_NAMESPACE extern "C"
 #define C_NAMESPACE_VAR extern "C"
 extern "C" {
-#else    
+#else
 #define C_NAMESPACE extern
 #define C_NAMESPACE_VAR
 #endif
@@ -92,11 +92,21 @@ extern double hypot(double, double);
 #  define hypot _hypot
 #endif
 
-	/* some useful constants */
-#define HALFPI		1.5707963267948966
-#define FORTPI		0.78539816339744833
-#define PI		3.14159265358979323846
-#define TWOPI		6.2831853071795864769
+/* enable predefined math constants M_* for MS Visual Studio workaround */
+#ifdef _MSC_VER
+#define _USE_MATH_DEFINES
+#endif
+
+/* some more useful math constants and aliases */
+#define M_FORTPI         M_PI_4                   /* pi/4 */
+#define M_HALFPI         M_PI_2                   /* pi/2 */
+/* M_PI                                               pi */
+#define M_PI_HALFPI      4.71238898038468985769   /* 1.5*pi */
+#define M_TWOPI      	 6.28318530717958647693   /* 2*pi */
+#define M_TWO_D_PI       M_2_PI                   /* 2/pi */
+#define M_TWOPI_HALFPI   7.85398163397448309616   /* 2.5*pi */
+/* M_SQRT2                                           sqrt(2) */
+
 
 /* maximum tag id length for +init and default files */
 #ifndef ID_TAG_MAX
@@ -132,8 +142,8 @@ typedef struct {
 
 /* datum_type values */
 #define PJD_UNKNOWN   0
-#define PJD_3PARAM    1   
-#define PJD_7PARAM    2   
+#define PJD_3PARAM    1
+#define PJD_7PARAM    2
 #define PJD_GRIDSHIFT 3
 #define PJD_WGS84     4   /* WGS84 (or anything considered equivelent) */
 
@@ -143,27 +153,39 @@ typedef struct {
 #define PJD_ERR_GRID_AREA           -48
 #define PJD_ERR_CATALOG             -49
 
-#define USE_PROJUV 
+#define USE_PROJUV
 
 typedef struct { double u, v; } projUV;
 typedef struct { double r, i; }	COMPLEX;
+typedef struct { double u, v, w; } projUVW;
 
 #ifndef PJ_LIB__
 #define XY projUV
 #define LP projUV
+#define XYZ projUVW
+#define LPZ projUVW
 #else
 typedef struct { double x, y; }     XY;
 typedef struct { double lam, phi; } LP;
+typedef struct { double x, y, z; } XYZ;
+typedef struct { double lam, phi, z; } LPZ;
 #endif
 
 typedef union { double  f; int  i; char *s; } PROJVALUE;
 struct PJconsts;
-    
+
 struct PJ_LIST {
 	char	*id;		/* projection keyword */
 	struct PJconsts	*(*proj)(struct PJconsts*);/* projection entry point */
 	char 	* const *descr;	/* description text */
 };
+
+/* Merging this into the PJ_LIST infrastructure is tempting, but may imply ABI breakage. Perhaps at next major version? */
+struct PJ_SELFTEST_LIST {
+    char    *id;                                /* projection keyword */
+    int     (* testfunc)(void);             /* projection entry point */
+};
+
 struct PJ_ELLPS {
 	char	*id;	/* ellipse keyword name */
 	char	*major;	/* a= value */
@@ -192,14 +214,14 @@ typedef struct {
     double ll_long;      /* lower left corner coordinates (radians) */
     double ll_lat;
     double ur_long;      /* upper right corner coordinates (radians) */
-    double ur_lat; 
+    double ur_lat;
 } PJ_Region;
 
 struct DERIVS {
     double x_l, x_p; /* derivatives of x for lambda-phi */
     double y_l, y_p; /* derivatives of y for lambda-phi */
 };
-    
+
 struct FACTORS {
 	struct DERIVS der;
 	double h, k;	/* meridinal, parallel scales */
@@ -221,10 +243,18 @@ typedef struct ARG_list {
 	/* base projection data structure */
 
 
+#ifdef PJ_LIB__
+    /* we need this forward declaration in order to be able to add a
+       pointer to struct opaque to the typedef struct PJconsts below */
+    struct pj_opaque;
+#endif
+
 typedef struct PJconsts {
     projCtx_t *ctx;
 	XY  (*fwd)(LP, struct PJconsts *);
 	LP  (*inv)(XY, struct PJconsts *);
+        XYZ (*fwd3d)(LPZ, struct PJconsts *);
+        LPZ (*inv3d)(XYZ, struct PJconsts *);
 	void (*spc)(LP, struct PJconsts *, struct FACTORS *);
 	void (*pfree)(struct PJconsts *);
 	const char *descr;
@@ -246,7 +276,7 @@ typedef struct PJconsts {
 		x0, y0, /* easting and northing */
 		k0,	/* general scaling factor */
 		to_meter, fr_meter; /* cartesian scaling */
-    
+
         int     datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
         double  datum_params[7];
         struct _pj_gi **gridlist;
@@ -265,9 +295,9 @@ typedef struct PJconsts {
         /* New Datum Shift Grid Catalogs */
         char   *catalog_name;
         struct _PJ_GridCatalog *catalog;
-    
+
         double   datum_date;
-    
+
         struct _pj_gi *last_before_grid;
         PJ_Region     last_before_region;
         double        last_before_date;
@@ -276,6 +306,10 @@ typedef struct PJconsts {
         PJ_Region     last_after_region;
         double        last_after_date;
 
+#ifdef PJ_LIB__
+        struct pj_opaque *opaque;
+#endif
+
 #ifdef PROJ_PARMS__
 PROJ_PARMS__
 #endif /* end of optional extensions */
@@ -284,24 +318,16 @@ PROJ_PARMS__
 /* public API */
 #include "proj_api.h"
 
+
 /* Generate pj_list external or make list from include file */
+
 #ifndef USE_PJ_LIST_H
 extern struct PJ_LIST pj_list[];
-#else
-#define PROJ_HEAD(id, name) \
-    struct PJconsts *pj_##id(struct PJconsts*); extern char * const pj_s_##id;
-    
-#include "pj_list.h"
-#undef PROJ_HEAD
-#define PROJ_HEAD(id, name) {#id, pj_##id, &pj_s_##id},
-	struct PJ_LIST
-pj_list[] = {
-#include "pj_list.h"
-		{0,     0,  0},
-	};
-#undef PROJ_HEAD
+extern struct PJ_SELFTEST_LIST pj_selftest_list[];
 #endif
 
+
+
 #ifndef PJ_ELLPS__
 extern struct PJ_ELLPS pj_ellps[];
 #endif
@@ -316,7 +342,7 @@ extern struct PJ_PRIME_MERIDIANS pj_prime_meridians[];
 #endif
 
 #ifdef PJ_LIB__
-    /* repeatative projection code */
+    /* repetitive projection code */
 #define PROJ_HEAD(id, name) static const char des_##id [] = name
 #define ENTRYA(name) \
         C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \
@@ -324,6 +350,7 @@ extern struct PJ_PRIME_MERIDIANS pj_prime_meridians[];
 	if( (P = (PJ*) pj_malloc(sizeof(PJ))) != NULL) { \
         memset( P, 0, sizeof(PJ) ); \
 	P->pfree = freeup; P->fwd = 0; P->inv = 0; \
+        P->fwd3d = 0; P->inv3d = 0; \
 	P->spc = 0; P->descr = des_##name;
 #define ENTRYX } return P; } else {
 #define ENTRY0(name) ENTRYA(name) ENTRYX
@@ -333,12 +360,54 @@ extern struct PJ_PRIME_MERIDIANS pj_prime_meridians[];
 #define E_ERROR(err) { pj_ctx_set_errno( P->ctx, err); freeup(P); return(0); }
 #define E_ERROR_0 { freeup(P); return(0); }
 #define F_ERROR { pj_ctx_set_errno( P->ctx, -20); return(xy); }
+#define F3_ERROR { pj_ctx_set_errno( P->ctx, -20); return(xyz); }
 #define I_ERROR { pj_ctx_set_errno( P->ctx, -20); return(lp); }
+#define I3_ERROR { pj_ctx_set_errno( P->ctx, -20); return(lpz); }
 #define FORWARD(name) static XY name(LP lp, PJ *P) { XY xy = {0.0,0.0}
 #define INVERSE(name) static LP name(XY xy, PJ *P) { LP lp = {0.0,0.0}
+#define FORWARD3D(name) static XYZ name(LPZ lpz, PJ *P) {XYZ xyz = {0.0, 0.0, 0.0}
+#define INVERSE3D(name) static LPZ name(XYZ xyz, PJ *P) {LPZ lpz = {0.0, 0.0, 0.0}
 #define FREEUP static void freeup(PJ *P) {
 #define SPECIAL(name) static void name(LP lp, PJ *P, struct FACTORS *fac)
+#define ELLIPSOIDAL(P) ((P->es==0)? (FALSE): (TRUE))
+
+/* cleaned up alternative to most of the "repetitive projection code" macros */
+#define PROJECTION(name)                                     \
+pj_projection_specific_setup_##name (PJ *P);                 \
+C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \
+C_NAMESPACE PJ *pj_##name (PJ *P) {                          \
+    if (P)                                                   \
+        return pj_projection_specific_setup_##name (P);      \
+    P = (PJ*) pj_calloc (1, sizeof(PJ));                     \
+    if (0==P)                                                \
+        return 0;                                            \
+    P->pfree = freeup;                                       \
+    P->descr = des_##name;                                   \
+    return P;                                                \
+}                                                            \
+PJ *pj_projection_specific_setup_##name (PJ *P)
+
 #endif
+
+
+int pj_generic_selftest (
+    char *e_args,
+    char *s_args,
+    double tolerance_xy,
+    double tolerance_lp,
+    int n_fwd,
+    int n_inv,
+    LP *fwd_in,
+    XY *e_fwd_expect,
+    XY *s_fwd_expect,
+    XY *inv_in,
+    LP *e_inv_expect,
+    LP *s_inv_expect
+);
+
+
+
+
 #define MAX_TAB_ID 80
 typedef struct { float lam, phi; } FLP;
 typedef struct { int lam, phi; } ILP;
@@ -354,11 +423,12 @@ struct CTABLE {
 typedef struct _pj_gi {
     char *gridname;   /* identifying name of grid, eg "conus" or ntv2_0.gsb */
     char *filename;   /* full path to filename */
-    
-    const char *format; /* format of this grid, ie "ctable", "ntv1", 
+
+    const char *format; /* format of this grid, ie "ctable", "ntv1",
                            "ntv2" or "missing". */
 
     int   grid_offset; /* offset in file, for delayed loading */
+    int   must_swap; /* only for NTv2 */
 
     struct CTABLE *ct;
 
@@ -401,6 +471,7 @@ int pj_ell_set(projCtx ctx, paralist *, double *, double *);
 int pj_datum_set(projCtx,paralist *, PJ *);
 int pj_prime_meridian_set(paralist *, PJ *);
 int pj_angular_units_set(paralist *, PJ *);
+void pj_prepare (PJ *P, const char *description, void (*freeup)(struct PJconsts *), size_t sizeof_struct_opaque);
 
 paralist *pj_clone_paralist( const paralist* );
 paralist*pj_search_initcache( const char *filekey );
@@ -426,7 +497,7 @@ struct PW_COEF {/* row coefficient structure */
     int m;		/* number of c coefficients (=0 for none) */
     double *c;	/* power coefficients */
 };
- 
+
 /* Approximation structures and procedures */
 typedef struct {	/* Chebyshev or Power series structure */
 	projUV a, b;		/* power series range for evaluation */
@@ -444,6 +515,7 @@ void **vector2(int, int, int);
 void freev2(void **v, int nrows);
 int bchgen(projUV, projUV, int, int, projUV **, projUV(*)(projUV));
 int bch2bps(projUV, projUV, projUV **, int, int);
+
 /* nadcon related protos */
 LP nad_intr(LP, struct CTABLE *);
 LP nad_cvt(LP, int, struct CTABLE *);
@@ -457,15 +529,15 @@ void nad_free(struct CTABLE *);
 /* higher level handling of datum grid shift files */
 
 int pj_apply_vgridshift( PJ *defn, const char *listname,
-                         PJ_GRIDINFO ***gridlist_p, 
+                         PJ_GRIDINFO ***gridlist_p,
                          int *gridlist_count_p,
-                         int inverse, 
+                         int inverse,
                          long point_count, int point_offset,
                          double *x, double *y, double *z );
-int pj_apply_gridshift_2( PJ *defn, int inverse, 
+int pj_apply_gridshift_2( PJ *defn, int inverse,
                           long point_count, int point_offset,
                           double *x, double *y, double *z );
-int pj_apply_gridshift_3( projCtx ctx, 
+int pj_apply_gridshift_3( projCtx ctx,
                           PJ_GRIDINFO **gridlist, int gridlist_count,
                           int inverse, long point_count, int point_offset,
                           double *x, double *y, double *z );
@@ -480,15 +552,15 @@ void pj_gridinfo_free( projCtx, PJ_GRIDINFO * );
 PJ_GridCatalog *pj_gc_findcatalog( projCtx, const char * );
 PJ_GridCatalog *pj_gc_readcatalog( projCtx, const char * );
 void pj_gc_unloadall( projCtx );
-int pj_gc_apply_gridshift( PJ *defn, int inverse, 
+int pj_gc_apply_gridshift( PJ *defn, int inverse,
                            long point_count, int point_offset,
                            double *x, double *y, double *z );
-int pj_gc_apply_gridshift( PJ *defn, int inverse, 
+int pj_gc_apply_gridshift( PJ *defn, int inverse,
                            long point_count, int point_offset,
                            double *x, double *y, double *z );
 
-PJ_GRIDINFO *pj_gc_findgrid( projCtx ctx, 
-                             PJ_GridCatalog *catalog, int after, 
+PJ_GRIDINFO *pj_gc_findgrid( projCtx ctx,
+                             PJ_GridCatalog *catalog, int after,
                              LP location, double date,
                              PJ_Region *optional_region,
                              double *grid_date );
@@ -508,6 +580,7 @@ struct PJ_ELLPS *pj_get_ellps_ref( void );
 struct PJ_DATUMS *pj_get_datums_ref( void );
 struct PJ_UNITS *pj_get_units_ref( void );
 struct PJ_LIST  *pj_get_list_ref( void );
+struct PJ_SELFTEST_LIST  *pj_get_selftest_list_ref ( void );
 struct PJ_PRIME_MERIDIANS  *pj_get_prime_meridians_ref( void );
 
 double pj_atof( const char* nptr );
diff --git a/src/rtodms.c b/src/rtodms.c
index abf6bc1..fa5c3cd 100644
--- a/src/rtodms.c
+++ b/src/rtodms.c
@@ -10,7 +10,7 @@
 	static double
 RES = 1000.,
 RES60 = 60000.,
-CONV = 206264806.24709635515796003417;
+CONV = 206264806.24709635516;
 	static char
 format[50] = "%dd%d'%.3f\"%c";
 	static int
@@ -25,7 +25,7 @@ set_rtodms(int fract, int con_w) {
 		for (i = 0; i < fract; ++i)
 			RES *= 10.;
 		RES60 = RES * 60.;
-		CONV = 180. * 3600. * RES / PI;
+		CONV = 180. * 3600. * RES / M_PI;
 		if (! con_w)
 			(void)sprintf(format,"%%dd%%d'%%.%df\"%%c", fract);
 		else
@@ -57,13 +57,15 @@ rtodms(char *s, double r, int pos, int neg) {
 		(void)sprintf(ss,format,deg,min,sec,sign);
 	else if (sec) {
 		char *p, *q;
+		/* double prime + pos/neg suffix (if included) + NUL */
+		size_t suffix_len = sign ? 3 : 2;
 
 		(void)sprintf(ss,format,deg,min,sec,sign);
-		for (q = p = ss + strlen(ss) - (sign ? 3 : 2); *p == '0'; --p) ;
+		for (q = p = ss + strlen(ss) - suffix_len; *p == '0'; --p) ;
 		if (*p != '.')
 			++p;
 		if (++q != p)
-			(void)strcpy(p, q);
+			(void)memmove(p, q, suffix_len);
 	} else if (min)
 		(void)sprintf(ss,"%dd%d'%c",deg,min,sign);
 	else
diff --git a/src/test228.c b/src/test228.c
index cdfc865..a8e55c4 100644
--- a/src/test228.c
+++ b/src/test228.c
@@ -1,4 +1,6 @@
 #include <proj_api.h>
+#include <stdio.h> /* for printf declaration */
+
 
 #ifdef _WIN32
 
@@ -33,7 +35,7 @@ void* thread_main(void* unused)
     p_OSGB36_proj=pj_init_plus_ctx(p_proj_ctxt,
             "+proj=longlat +ellps=airy +datum=OSGB36 +nadgrids=OSTN02_NTv2.gsb "
             "+no_defs");
-    
+
     while(run)
     {
         double x, y;
@@ -73,4 +75,4 @@ int main(int argc, char* argv[])
     return 0;
 }
 
-#endif /* _WIN32 */
\ No newline at end of file
+#endif /* _WIN32 */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/proj.git



More information about the Pkg-grass-devel mailing list