diff --git a/Makefile.am b/Makefile.am
index 56c86434241bcfd7925fb30f75eb1a0a7668b12d..7cc05bc8ad1ecc3b89d908f4480b7034782805a8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 #
-DISTCHECK_CONFIGURE_FLAGS = 
+DISTCHECK_CONFIGURE_FLAGS =  --enable-cdi-lib
 #
 SUBDIRS = src interfaces app examples tests
 #
diff --git a/Makefile.in b/Makefile.in
index fd0a5d95f7eddfc17f0e6cefaca5018e3f71e744..017fcd043a8bab00eabffd282fac6f28c0c29ee0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -135,6 +135,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_CDI_LIB = @ENABLE_CDI_LIB@
 ENABLE_CGRIBEX = @ENABLE_CGRIBEX@
 ENABLE_EXTRA = @ENABLE_EXTRA@
 ENABLE_GRIB = @ENABLE_GRIB@
@@ -186,6 +187,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PROJ_INCLUDE = @PROJ_INCLUDE@
+PROJ_LDFLAGS = @PROJ_LDFLAGS@
 PYTHON = @PYTHON@
 RANLIB = @RANLIB@
 RUBY = @RUBY@
@@ -251,6 +254,7 @@ psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
+subdirs = @subdirs@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
@@ -258,7 +262,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 
 #
-DISTCHECK_CONFIGURE_FLAGS = 
+DISTCHECK_CONFIGURE_FLAGS = --enable-cdi-lib
 #
 SUBDIRS = src interfaces app examples tests
 #
diff --git a/app/Makefile.am b/app/Makefile.am
index f4d3b18759e721b1652969a253f9d95ca5fce466..8a2248eb712f894da789fe9475e40026a2bf9c75 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -1,11 +1,18 @@
 ## Process this file with automake to produce Makefile.in
 #
-bin_PROGRAMS        = cdi
+bin_PROGRAMS    =
+noinst_PROGRAMS =
+if ENABLE_CDI_LIB
+  bin_PROGRAMS    += cdi
+else
+  noinst_PROGRAMS += cdi
+endif
+#
 if CREATE_ALL_STATIC
 bin_PROGRAMS       += cdi_static
 endif
 #
-noinst_PROGRAMS     = createtable
+noinst_PROGRAMS    += createtable
 #
 cdi_SOURCES         = cdi.c printinfo.h
 cdi_LDADD           = $(top_builddir)/src/libcdi.la
diff --git a/app/Makefile.in b/app/Makefile.in
index d6e8f8a78a2d5ac85af34a66f2d237e131c8d76b..a9b5e2b280661f156ff81d870cfa9af73dbe80de 100644
--- a/app/Makefile.in
+++ b/app/Makefile.in
@@ -34,9 +34,12 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-bin_PROGRAMS = cdi$(EXEEXT) $(am__EXEEXT_1)
-@CREATE_ALL_STATIC_TRUE@am__append_1 = cdi_static
-noinst_PROGRAMS = createtable$(EXEEXT)
+bin_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2)
+noinst_PROGRAMS = $(am__EXEEXT_3) createtable$(EXEEXT)
+@ENABLE_CDI_LIB_TRUE@am__append_1 = cdi
+@ENABLE_CDI_LIB_FALSE@am__append_2 = cdi
+#
+@CREATE_ALL_STATIC_TRUE@am__append_3 = cdi_static
 subdir = app
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -52,8 +55,10 @@ mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/src/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
-@CREATE_ALL_STATIC_TRUE@am__EXEEXT_1 = cdi_static$(EXEEXT)
+@ENABLE_CDI_LIB_TRUE@am__EXEEXT_1 = cdi$(EXEEXT)
+@CREATE_ALL_STATIC_TRUE@am__EXEEXT_2 = cdi_static$(EXEEXT)
 am__installdirs = "$(DESTDIR)$(bindir)"
+@ENABLE_CDI_LIB_FALSE@am__EXEEXT_3 = cdi$(EXEEXT)
 PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
 am_cdi_OBJECTS = cdi.$(OBJEXT)
 cdi_OBJECTS = $(am_cdi_OBJECTS)
@@ -113,6 +118,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_CDI_LIB = @ENABLE_CDI_LIB@
 ENABLE_CGRIBEX = @ENABLE_CGRIBEX@
 ENABLE_EXTRA = @ENABLE_EXTRA@
 ENABLE_GRIB = @ENABLE_GRIB@
@@ -164,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PROJ_INCLUDE = @PROJ_INCLUDE@
+PROJ_LDFLAGS = @PROJ_LDFLAGS@
 PYTHON = @PYTHON@
 RANLIB = @RANLIB@
 RUBY = @RUBY@
@@ -229,6 +237,7 @@ psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
+subdirs = @subdirs@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
diff --git a/app/cdi.c b/app/cdi.c
index edb45c5ee4e9ce2cde95520b3e3a208f273117d4..a63b5af6e4cc2ba39a7ef20d9b5467a11814ed72 100644
--- a/app/cdi.c
+++ b/app/cdi.c
@@ -10,7 +10,7 @@
 #include <unistd.h>
 #include <math.h>
 
-#include "cdi.h"
+#include <cdi.h>
 int      vlistInqVarMissvalUsed(int vlistID, int varID);
 #ifndef DBL_IS_NAN
 #if  defined  (HAVE_ISNAN)
diff --git a/cdi.settings.in b/cdi.settings.in
index 564ce24bc8a572930c3e178676aff899e9f1a61c..d953f17a8740ad0f7aa7907977a9e309a89d0b3e 100644
--- a/cdi.settings.in
+++ b/cdi.settings.in
@@ -18,11 +18,12 @@
    "RANLIB"   : "@RANLIB@",
    "INSTALL"  : "@INSTALL@",
   },
-  "grib"     : "@ENABLE_GRIB@",
-  "cgribex"  : "@ENABLE_CGRIBEX@",
-  "service"  : "@ENABLE_SERVICE@",
-  "extra"    : "@ENABLE_EXTRA@",
-  "ieg"      : "@ENABLE_IEG@",
+  "enable_cdi_lib" : @ENABLE_CDI_LIB@,
+  "grib"           : "@ENABLE_GRIB@",
+  "cgribex"        : "@ENABLE_CGRIBEX@",
+  "service"        : "@ENABLE_SERVICE@",
+  "extra"          : "@ENABLE_EXTRA@",
+  "ieg"            : "@ENABLE_IEG@",
   "threads"    : {
     "lib"      : "@THREADS_LDFLAGS@",
     "include"  : "@THREADS_INCLUDE@"
diff --git a/configure b/configure
index b81c352c1544a1c4f7355733f9f7a29f226ff545..50e34aa369ec0a2223fdbe7d7bc4ae72bc6b1cb3 100755
--- a/configure
+++ b/configure
@@ -604,6 +604,7 @@ ac_includes_default="\
 #endif"
 
 ac_header_list=
+enable_option_checking=no
 ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
@@ -623,6 +624,12 @@ FCMODCASE
 FCMODEXT
 CREATE_ISOC_FALSE
 CREATE_ISOC_TRUE
+subdirs
+ENABLE_CDI_LIB
+ENABLE_CDI_LIB_FALSE
+ENABLE_CDI_LIB_TRUE
+PROJ_INCLUDE
+PROJ_LDFLAGS
 ENABLE_IEG
 ENABLE_EXTRA
 ENABLE_SERVICE
@@ -788,6 +795,8 @@ enable_cgribex
 enable_service
 enable_extra
 enable_ieg
+with_proj
+enable_cdi_lib
 enable_mpi
 enable_iso_c_interface
 enable_swig
@@ -812,7 +821,7 @@ CXXFLAGS
 CCC
 CXXCPP
 FCMODEXT'
-
+ac_subdirs_all='libcdi'
 
 # Initialize some variables set by options.
 ac_init_help=
@@ -1446,6 +1455,8 @@ Optional Features:
   --enable-service        Use the service library [default=yes]
   --enable-extra          Use the extra library [default=yes]
   --enable-ieg            Use the ieg library [default=yes]
+  --enable-cdi-lib        build + install a CDI library [default=no] and link
+                          CDO to it |CDO build only|
   --enable-mpi            Compile with MPI compiler [default=no]
   --enable-iso-c-interface
                           Create Fortran Interface via iso_c_bindings facility
@@ -1478,10 +1489,12 @@ Optional Packages:
   --with-jasper=<directory>
                           Specify location of JASPER library. You must specify
                           its location if GRIB_API was built with JASPER.
-  --with-jasper=<yes|no|directory>
+  --with-grib-api=<yes|no|directory>
                           library for grib2 compression; if a directory is
                           given, it will be used as a value for
                           --with-jasper-root
+  --with-proj=<directory> Specify location of PROJ library for cartographic
+                          projections.
 
 Some influential environment variables:
   CC          C compiler command
@@ -21940,6 +21953,8 @@ fi
 #  ----------------------------------------------------------------------
 # Add basic configure options
 
+
+
 #  ----------------------------------------------------------------------
 #  Checks for pthread library
 
@@ -23468,6 +23483,229 @@ fi
 $as_echo "$enable_ieg" >&6; }
 ENABLE_IEG=$enable_ieg
 
+#  ----------------------------------------------------------------------
+#  Checks for PROJ.4 library
+
+# Check whether --with-proj was given.
+if test "${with_proj+set}" = set; then :
+  withval=$with_proj; case "$with_proj" in #(
+  no) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for proj library" >&5
+$as_echo_n "checking for proj library... " >&6; }
+                           { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
+$as_echo "suppressed" >&6; } ;; #(
+  yes) :
+    for ac_header in projects.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "projects.h" "ac_cv_header_projects_h" "$ac_includes_default"
+if test "x$ac_cv_header_projects_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_PROJECTS_H 1
+_ACEOF
+
+fi
+
+done
+
+                            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pj_init" >&5
+$as_echo_n "checking for library containing pj_init... " >&6; }
+if test "${ac_cv_search_pj_init+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pj_init ();
+int
+main ()
+{
+return pj_init ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' proj; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_pj_init=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_pj_init+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_pj_init+set}" = set; then :
+
+else
+  ac_cv_search_pj_init=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pj_init" >&5
+$as_echo "$ac_cv_search_pj_init" >&6; }
+ac_res=$ac_cv_search_pj_init
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+$as_echo "#define HAVE_LIBPROJ 1" >>confdefs.h
+
+else
+  as_fn_error $? "Could not link to PROJ library!" "$LINENO" 5
+fi
+
+                            PROJ_LDFLAGS=" -lproj"
+
+                            PROJ_INCLUDE=""
+ ;; #(
+  *) :
+    PROJ_ROOT=$with_proj
+                          if test -d "$PROJ_ROOT"; then :
+  LDFLAGS="$LDFLAGS -L$PROJ_ROOT/lib"
+                                 CPPFLAGS="$CPPFLAGS -I$PROJ_ROOT/include"
+                                 for ac_header in projects.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "projects.h" "ac_cv_header_projects_h" "$ac_includes_default"
+if test "x$ac_cv_header_projects_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_PROJECTS_H 1
+_ACEOF
+
+fi
+
+done
+
+                                 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pj_init" >&5
+$as_echo_n "checking for library containing pj_init... " >&6; }
+if test "${ac_cv_search_pj_init+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pj_init ();
+int
+main ()
+{
+return pj_init ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' proj; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_pj_init=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_pj_init+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_pj_init+set}" = set; then :
+
+else
+  ac_cv_search_pj_init=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pj_init" >&5
+$as_echo "$ac_cv_search_pj_init" >&6; }
+ac_res=$ac_cv_search_pj_init
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+$as_echo "#define HAVE_LIBPROJ 1" >>confdefs.h
+
+else
+  as_fn_error $? "Could not link to PROJ library!" "$LINENO" 5
+fi
+
+                                 PROJ_LDFLAGS=" -L$PROJ_ROOT/lib -lproj"
+
+                                 PROJ_INCLUDE=" -I$PROJ_ROOT/include"
+
+else
+  as_fn_error $? "$PROJ_ROOT is not a directory! PROJ suppressed" "$LINENO" 5
+fi ;; #(
+  *) :
+     ;;
+esac
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the PROJ library" >&5
+$as_echo_n "checking for the PROJ library... " >&6; }
+             { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
+$as_echo "suppressed" >&6; }
+fi
+
+#  ----------------------------------------------------------------------
+#  How to build CDI into CDI?
+INTERNAL_CDI_DIR=libcdi
+# At the moment, there are two possible CDI bindings
+# (default)             linking directly to CDI's object files in ./libcdi/src
+# (--enable-cdi-lib) build and link to a shared CDI library
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for build a separate CDI library and link CDO to it |valid for CDO build only|" >&5
+$as_echo_n "checking for build a separate CDI library and link CDO to it |valid for CDO build only|... " >&6; }
+# Check whether --enable-cdi-lib was given.
+if test "${enable_cdi_lib+set}" = set; then :
+  enableval=$enable_cdi_lib; if test "x$enable_cdi_lib" != "xno"; then :
+  enable_cdi_lib=yes
+else
+  enable_cdi_lib=no
+fi
+else
+  enable_cdi_lib=no
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_cdi_lib" >&5
+$as_echo "$enable_cdi_lib" >&6; }
+# save CDI binding mode for later automake use
+ if test x$enable_cdi_lib = 'xyes'; then
+  ENABLE_CDI_LIB_TRUE=
+  ENABLE_CDI_LIB_FALSE='#'
+else
+  ENABLE_CDI_LIB_TRUE='#'
+  ENABLE_CDI_LIB_FALSE=
+fi
+
+# create shell variables for the representation of configure results
+if test x$enable_cdi_lib = 'xno'; then :
+  ENABLE_CDI_LIB=false
+
+else
+  ENABLE_CDI_LIB=true
+
+fi
+# scan libcdi for CDI as a subproject
+subdirs="$subdirs libcdi"
+
 
 #  ----------------------------------------------------------------------
 # Compile with MPI support
@@ -23987,6 +24225,10 @@ if test -z "${CREATE_ALL_STATIC_TRUE}" && test -z "${CREATE_ALL_STATIC_FALSE}";
   as_fn_error $? "conditional \"CREATE_ALL_STATIC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${ENABLE_CDI_LIB_TRUE}" && test -z "${ENABLE_CDI_LIB_FALSE}"; then
+  as_fn_error $? "conditional \"ENABLE_CDI_LIB\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${CREATE_ISOC_TRUE}" && test -z "${CREATE_ISOC_FALSE}"; then
   as_fn_error $? "conditional \"CREATE_ISOC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -26995,6 +27237,151 @@ if test "$no_create" != yes; then
   # would make configure fail if this is the last instruction.
   $ac_cs_success || as_fn_exit 1
 fi
+
+#
+# CONFIG_SUBDIRS section.
+#
+if test "$no_recursion" != yes; then
+
+  # Remove --cache-file, --srcdir, and --disable-option-checking arguments
+  # so they do not pile up.
+  ac_sub_configure_args=
+  ac_prev=
+  eval "set x $ac_configure_args"
+  shift
+  for ac_arg
+  do
+    if test -n "$ac_prev"; then
+      ac_prev=
+      continue
+    fi
+    case $ac_arg in
+    -cache-file | --cache-file | --cache-fil | --cache-fi \
+    | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+      ac_prev=cache_file ;;
+    -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+    | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
+    | --c=*)
+      ;;
+    --config-cache | -C)
+      ;;
+    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+      ac_prev=srcdir ;;
+    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+      ;;
+    -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+      ac_prev=prefix ;;
+    -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+      ;;
+    --disable-option-checking)
+      ;;
+    *)
+      case $ac_arg in
+      *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+      esac
+      as_fn_append ac_sub_configure_args " '$ac_arg'" ;;
+    esac
+  done
+
+  # Always prepend --prefix to ensure using the same prefix
+  # in subdir configurations.
+  ac_arg="--prefix=$prefix"
+  case $ac_arg in
+  *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+  esac
+  ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"
+
+  # Pass --silent
+  if test "$silent" = yes; then
+    ac_sub_configure_args="--silent $ac_sub_configure_args"
+  fi
+
+  # Always prepend --disable-option-checking to silence warnings, since
+  # different subdirs can have different --enable and --with options.
+  ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args"
+
+  ac_popdir=`pwd`
+  for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
+
+    # Do not complain, so a configure script can configure whichever
+    # parts of a large source tree are present.
+    test -d "$srcdir/$ac_dir" || continue
+
+    ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
+    $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5
+    $as_echo "$ac_msg" >&6
+    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
+
+
+    cd "$ac_dir"
+
+    # Check for guested configure; otherwise get Cygnus style configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      ac_sub_configure=$ac_srcdir/configure.gnu
+    elif test -f "$ac_srcdir/configure"; then
+      ac_sub_configure=$ac_srcdir/configure
+    elif test -f "$ac_srcdir/configure.in"; then
+      # This should be Cygnus configure.
+      ac_sub_configure=$ac_aux_dir/configure
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: no configuration information is in $ac_dir" >&5
+$as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;}
+      ac_sub_configure=
+    fi
+
+    # The recursion is here.
+    if test -n "$ac_sub_configure"; then
+      # Make the cache file name correct relative to the subdirectory.
+      case $cache_file in
+      [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;;
+      *) # Relative name.
+	ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
+      esac
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5
+$as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;}
+      # The eval makes quoting arguments work.
+      eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
+	   --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
+	as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5
+    fi
+
+    cd "$ac_popdir"
+  done
+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;}
diff --git a/examples/Makefile.in b/examples/Makefile.in
index b0c321f0eeded9a332bc3308bcb30ddd16cc140e..3154d9dcaf75663b6075a8fb60322edf42e4f265 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -134,6 +134,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_CDI_LIB = @ENABLE_CDI_LIB@
 ENABLE_CGRIBEX = @ENABLE_CGRIBEX@
 ENABLE_EXTRA = @ENABLE_EXTRA@
 ENABLE_GRIB = @ENABLE_GRIB@
@@ -185,6 +186,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PROJ_INCLUDE = @PROJ_INCLUDE@
+PROJ_LDFLAGS = @PROJ_LDFLAGS@
 PYTHON = @PYTHON@
 RANLIB = @RANLIB@
 RUBY = @RUBY@
@@ -250,6 +253,7 @@ psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
+subdirs = @subdirs@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
diff --git a/interfaces/Makefile.in b/interfaces/Makefile.in
index 97b07ee930c1c83a1a2d620402ea496640830547..ced8a6284686fc0723b914fc2a921c9052a2741d 100644
--- a/interfaces/Makefile.in
+++ b/interfaces/Makefile.in
@@ -119,6 +119,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_CDI_LIB = @ENABLE_CDI_LIB@
 ENABLE_CGRIBEX = @ENABLE_CGRIBEX@
 ENABLE_EXTRA = @ENABLE_EXTRA@
 ENABLE_GRIB = @ENABLE_GRIB@
@@ -170,6 +171,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PROJ_INCLUDE = @PROJ_INCLUDE@
+PROJ_LDFLAGS = @PROJ_LDFLAGS@
 PYTHON = @PYTHON@
 RANLIB = @RANLIB@
 RUBY = @RUBY@
@@ -235,6 +238,7 @@ psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
+subdirs = @subdirs@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
diff --git a/m4/acx_options.m4 b/m4/acx_options.m4
index 8f7de619090369dd2d62d3df51a4ab92f33c67e0..14b27b39dfd19f0023b22e0010c40fb4d602f909 100644
--- a/m4/acx_options.m4
+++ b/m4/acx_options.m4
@@ -168,7 +168,7 @@ AC_ARG_WITH([jasper],
 #  ----------------------------------------------------------------------
 #  Compile application with GRIB_API library (for GRIB2 support)
 AC_ARG_WITH([grib_api],
-            [AS_HELP_STRING([--with-jasper=<yes|no|directory>],
+            [AS_HELP_STRING([--with-grib-api=<yes|no|directory>],
                             [library for grib2 compression; if a directory is given, it will be used as a value for --with-jasper-root])],
             [AS_CASE(["$with_grib_api"],
                      [no],[AC_MSG_CHECKING([for GRIB_API library])
@@ -252,4 +252,50 @@ AC_ARG_ENABLE([ieg],
                enable_ieg=yes])
 AC_MSG_RESULT([$enable_ieg])
 AC_SUBST([ENABLE_IEG],[$enable_ieg])
+#  ----------------------------------------------------------------------
+#  Checks for PROJ.4 library
+AC_ARG_WITH([proj],
+            [AS_HELP_STRING([--with-proj=<directory>],
+                            [Specify location of PROJ library for cartographic projections.])],
+            [AS_CASE(["$with_proj"],
+                     [no],[AC_MSG_CHECKING([for proj library])
+                           AC_MSG_RESULT([suppressed])],
+                     [yes],[AC_CHECK_HEADERS([projects.h])
+                            AC_SEARCH_LIBS([pj_init],[proj],[AC_DEFINE([HAVE_LIBPROJ],[1],[Define to 1 for PROJ support])],
+                                           [AC_MSG_ERROR([Could not link to PROJ library!])])
+                            AC_SUBST([PROJ_LDFLAGS],[" -lproj"])
+                            AC_SUBST([PROJ_INCLUDE],[""])],
+                     [*],[PROJ_ROOT=$with_proj
+                          AS_IF([test -d "$PROJ_ROOT"],
+                                [LDFLAGS="$LDFLAGS -L$PROJ_ROOT/lib"
+                                 CPPFLAGS="$CPPFLAGS -I$PROJ_ROOT/include"
+                                 AC_CHECK_HEADERS([projects.h])
+                                 AC_SEARCH_LIBS([pj_init],
+                                                [proj],
+                                                [AC_DEFINE([HAVE_LIBPROJ],[1],[Define to 1 for PROJ support])],
+                                                [AC_MSG_ERROR([Could not link to PROJ library!])])
+                                 AC_SUBST([PROJ_LDFLAGS],[" -L$PROJ_ROOT/lib -lproj"])
+                                 AC_SUBST([PROJ_INCLUDE],[" -I$PROJ_ROOT/include"])],
+                                [AC_MSG_ERROR([$PROJ_ROOT is not a directory! PROJ suppressed])])])],
+            [AC_MSG_CHECKING([for the PROJ library])
+             AC_MSG_RESULT([suppressed])])
+#  ----------------------------------------------------------------------
+#  How to build CDI into CDI? 
+INTERNAL_CDI_DIR=libcdi
+# At the moment, there are two possible CDI bindings
+# (default)             linking directly to CDI's object files in ./libcdi/src
+# (--enable-cdi-lib) build and link to a shared CDI library
+AC_MSG_CHECKING([for build a separate CDI library and link CDO to it |valid for CDO build only|])
+AC_ARG_ENABLE([cdi-lib],
+              [AS_HELP_STRING([--enable-cdi-lib],[build + install a CDI library [default=no] and link CDO to it |CDO build only|])],
+              [AS_IF([test "x$enable_cdi_lib" != "xno"],
+                     [enable_cdi_lib=yes],
+                     [enable_cdi_lib=no])],[enable_cdi_lib=no])
+AC_MSG_RESULT([$enable_cdi_lib])
+# save CDI binding mode for later automake use
+AM_CONDITIONAL([ENABLE_CDI_LIB],[test x$enable_cdi_lib = 'xyes'])
+# create shell variables for the representation of configure results
+AS_IF([test x$enable_cdi_lib = 'xno'],[AC_SUBST([ENABLE_CDI_LIB],[false])],[AC_SUBST([ENABLE_CDI_LIB],[true])])
+# scan libcdi for CDI as a subproject
+AC_CONFIG_SUBDIRS([libcdi])
 ])
diff --git a/src/Makefile.am b/src/Makefile.am
index f59ba1d481117769d06ed244f1ab1b4a939937a1..4c3e7058a1c03d6a7e4b6bbfe73a87b4772dc32a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,9 +2,13 @@
 #
 EXTRA_DIST = make_cdilib mo_cdi.f90
 
-lib_LTLIBRARIES    = libcdi.la
+if ENABLE_CDI_LIB
+  lib_LTLIBRARIES    = libcdi.la
+  include_HEADERS = cdi.h cdi.inc
+else
+  noinst_LTLIBRARIES = libcdi.la
+endif
 
-include_HEADERS = cdi.h cdi.inc
 
 libcdi_la_SOURCES = 	 \
 	basetime.c     	 \
diff --git a/src/Makefile.in b/src/Makefile.in
index fc6c148abf4a1b994371c1e26d68a0a15f728919..c7ba1e62130df74fa91866dcd84a5ea9e208b01e 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -38,7 +38,7 @@ host_triplet = @host@
 @CREATE_ISOC_TRUE@am__append_1 = mo_cdi.o mo_cdi.$(FCMODEXT)
 @CREATE_ISOC_TRUE@am__append_2 = $(top_builddir)/src/mo_cdi.$(FCMODEXT) $(top_builddir)/src/mo_cdi.o
 subdir = src
-DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
+DIST_COMMON = $(am__include_HEADERS_DIST) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/config.h.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/acx_options.m4 \
@@ -75,7 +75,7 @@ am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
-LTLIBRARIES = $(lib_LTLIBRARIES)
+LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
 libcdi_la_DEPENDENCIES = @LTLIBOBJS@
 am_libcdi_la_OBJECTS = basetime.lo binary.lo calendar.lo cdf.lo \
 	cdf_int.lo cdi_error.lo cdi_util.lo cdiFortran.lo \
@@ -88,6 +88,8 @@ am_libcdi_la_OBJECTS = basetime.lo binary.lo calendar.lo cdf.lo \
 	tsteps.lo util.lo varscan.lo version.lo vlist.lo vlist_att.lo \
 	vlist_var.lo zaxis.lo stream.lo swap.lo
 libcdi_la_OBJECTS = $(am_libcdi_la_OBJECTS)
+@ENABLE_CDI_LIB_FALSE@am_libcdi_la_rpath =
+@ENABLE_CDI_LIB_TRUE@am_libcdi_la_rpath = -rpath $(libdir)
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
 am__depfiles_maybe = depfiles
@@ -103,6 +105,7 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	$(LDFLAGS) -o $@
 SOURCES = $(libcdi_la_SOURCES)
 DIST_SOURCES = $(libcdi_la_SOURCES)
+am__include_HEADERS_DIST = cdi.h cdi.inc
 HEADERS = $(include_HEADERS)
 ETAGS = etags
 CTAGS = ctags
@@ -134,6 +137,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_CDI_LIB = @ENABLE_CDI_LIB@
 ENABLE_CGRIBEX = @ENABLE_CGRIBEX@
 ENABLE_EXTRA = @ENABLE_EXTRA@
 ENABLE_GRIB = @ENABLE_GRIB@
@@ -185,6 +189,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PROJ_INCLUDE = @PROJ_INCLUDE@
+PROJ_LDFLAGS = @PROJ_LDFLAGS@
 PYTHON = @PYTHON@
 RANLIB = @RANLIB@
 RUBY = @RUBY@
@@ -250,6 +256,7 @@ psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
+subdirs = @subdirs@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
@@ -258,8 +265,9 @@ top_srcdir = @top_srcdir@
 
 #
 EXTRA_DIST = make_cdilib mo_cdi.f90
-lib_LTLIBRARIES = libcdi.la
-include_HEADERS = cdi.h cdi.inc
+@ENABLE_CDI_LIB_TRUE@lib_LTLIBRARIES = libcdi.la
+@ENABLE_CDI_LIB_TRUE@include_HEADERS = cdi.h cdi.inc
+@ENABLE_CDI_LIB_FALSE@noinst_LTLIBRARIES = libcdi.la
 libcdi_la_SOURCES = \
 	basetime.c     	 \
 	basetime.h	 \
@@ -428,8 +436,17 @@ clean-libLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
 libcdi.la: $(libcdi_la_OBJECTS) $(libcdi_la_DEPENDENCIES) 
-	$(LINK) -rpath $(libdir) $(libcdi_la_OBJECTS) $(libcdi_la_LIBADD) $(LIBS)
+	$(LINK) $(am_libcdi_la_rpath) $(libcdi_la_OBJECTS) $(libcdi_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -647,7 +664,7 @@ maintainer-clean-generic:
 clean: clean-am
 
 clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
-	mostlyclean-am
+	clean-noinstLTLIBRARIES mostlyclean-am
 
 distclean: distclean-am
 	-rm -rf ./$(DEPDIR)
@@ -718,16 +735,16 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
 .MAKE: all install-am install-strip
 
 .PHONY: CTAGS GTAGS all all-am all-local check check-am clean \
-	clean-generic clean-libLTLIBRARIES clean-libtool ctags \
-	distclean distclean-compile distclean-generic distclean-hdr \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am \
-	install-includeHEADERS install-info install-info-am \
-	install-libLTLIBRARIES install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
+	clean-generic clean-libLTLIBRARIES clean-libtool \
+	clean-noinstLTLIBRARIES ctags distclean distclean-compile \
+	distclean-generic distclean-hdr distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-includeHEADERS install-info \
+	install-info-am install-libLTLIBRARIES install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags uninstall uninstall-am uninstall-includeHEADERS \
diff --git a/src/config.h.in b/src/config.h.in
index 1fc73b3b1602d227539c429ee6f59083282f6fb1..c87cba208e06eb2a99a8955c33d66a40922953ed 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -54,6 +54,9 @@
 /* Define to 1 for NETCDF support */
 #undef HAVE_LIBNETCDF
 
+/* Define to 1 for PROJ support */
+#undef HAVE_LIBPROJ
+
 /* Define to 1 if you have the `pthread' library (-lpthread). */
 #undef HAVE_LIBPTHREAD
 
@@ -81,6 +84,9 @@
 /* Define to 1 if you have the <netcdf.h> header file. */
 #undef HAVE_NETCDF_H
 
+/* Define to 1 if you have the <projects.h> header file. */
+#undef HAVE_PROJECTS_H
+
 /* Define to 1 if you have the <pthread.h> header file. */
 #undef HAVE_PTHREAD_H
 
diff --git a/tests/Makefile.in b/tests/Makefile.in
index d14a8a24b99da1a19e223c07b864e9d68e7edc81..d62683f26a9c17c9817dea649b05d9820b0d6dba 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -100,6 +100,7 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_CDI_LIB = @ENABLE_CDI_LIB@
 ENABLE_CGRIBEX = @ENABLE_CGRIBEX@
 ENABLE_EXTRA = @ENABLE_EXTRA@
 ENABLE_GRIB = @ENABLE_GRIB@
@@ -151,6 +152,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PROJ_INCLUDE = @PROJ_INCLUDE@
+PROJ_LDFLAGS = @PROJ_LDFLAGS@
 PYTHON = @PYTHON@
 RANLIB = @RANLIB@
 RUBY = @RUBY@
@@ -216,6 +219,7 @@ psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
+subdirs = @subdirs@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@