[pktools] 02/19: Imported Upstream version 2.5.4

Bas Couwenberg sebastic at xs4all.nl
Fri Nov 14 22:43:02 UTC 2014


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

sebastic-guest pushed a commit to branch master
in repository pktools.

commit 7da1b47dc54b302b031f4eb764e1174f54ba38a2
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Nov 8 19:57:07 2014 +0100

    Imported Upstream version 2.5.4
---
 ChangeLog                                          |   36 +-
 Makefile.in                                        |  346 ++---
 aclocal.m4                                         |  687 ++++++----
 compile                                            |  347 +++++
 config.guess                                       |  184 +--
 config.sub                                         |   97 +-
 configure                                          |  333 +++--
 configure.ac                                       |    5 +-
 src/algorithms/CostFactory.h                       |    8 +-
 src/algorithms/CostFactorySVM.cc                   |  178 +++
 .../pkfssvm.h => algorithms/CostFactorySVM.h}      |   19 +-
 src/algorithms/Filter.cc                           |  112 +-
 src/algorithms/Filter.h                            |  451 ++++---
 src/algorithms/Filter2d.cc                         |    2 +-
 src/algorithms/Filter2d.h                          |    6 +-
 src/algorithms/ImgRegression.cc                    |    2 +-
 src/algorithms/Makefile.am                         |    4 +-
 src/algorithms/Makefile.in                         |  314 +++--
 src/algorithms/myfann_cpp.h                        |   30 +-
 src/apps/Makefile.am                               |   25 +-
 src/apps/Makefile.in                               |  554 ++++----
 src/apps/pkann.cc                                  |   12 +-
 src/apps/pkcomposite.cc                            |   48 +-
 src/apps/pkcrop.cc                                 |    4 +-
 src/apps/pkdumpogr.cc                              |  243 ++--
 src/apps/pkextract.cc                              | 1325 ++++++++++----------
 src/apps/pkfilter.cc                               |   32 +-
 src/apps/pkfsann.cc                                |   16 +-
 src/apps/pkfssvm.cc                                |  340 +++--
 src/apps/pkinfo.cc                                 |   64 +-
 src/apps/pkkalman.cc                               |  392 ++++--
 src/apps/pkoptsvm.cc                               |  375 +++---
 src/apps/pksvm.cc                                  |   12 +-
 src/base/Makefile.in                               |  262 ++--
 src/fileclasses/Makefile.in                        |  274 ++--
 src/imageclasses/ImgReaderGdal.h                   |   27 +-
 src/imageclasses/ImgReaderOgr.cc                   |    4 +-
 src/imageclasses/ImgReaderOgr.h                    |    2 +-
 src/imageclasses/ImgWriterOgr.cc                   |   65 +-
 src/imageclasses/Makefile.in                       |  274 ++--
 src/lasclasses/Makefile.in                         |  274 ++--
 41 files changed, 4940 insertions(+), 2845 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e0a265c..0e626a5 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -301,7 +301,39 @@ version 2.5.2
 version 2.5.3
  - pklas2img
 	libLAS 1.8.0 support (ticket #42951)
+ - myfann_cpp.h
+	Fix build failure on ARM due to va_list usage in myfann_cpp.h
 
-Next versions: 
- - todo for API: ImgReaderGdal (ImgWriterGdal) open in update mode (check gdal_edit.py: http://searchcode.com/codesearch/view/18938404)
+
+version 2.5.4
+ - pkinfo
+	Support multiple input bands when calculating statistics
+ - pkfilter
+	Support filtering and statistics in spectral domain (see ticket #43252)
+	Support different padding strategies (currently only supported for spectral/temporal filtering)
+	Renamed "majority" to "mode" for majority voting filter
+ - pkextract
+	bug fix for proportion rule
+	support standard deviation rule (stdev) for polygon features (ticket #43193)
+	support overwrite vector files (ticket #43194)
+	support statistic rules (mean, stdev, median, etc.) for point features by taking into account buffer (default= 3 by 3 pixels). If option -polygon is set, output ogr features are polygons defining the buffer.
+	changed names for maximum and minumum rule to max and min respectively
+	new options -rand and -grid to support simple random sampling and systematic grid (do not provide sample vector dataset)
+ - pksvm
+	replaced options s|start and e|end with bs|bstart and be|bend
+ - pkann
+	replaced options s|start and e|end with bs|bstart and be|bend
+ - pkfssvm
+	replaced options s|start and e|end with bs|bstart and be|bend
+ - pkfsann
+	replaced options s|start and e|end with bs|bstart and be|bend
+ - pkoptsvm
+	replaced options s|start and e|end with bs|bstart and be|bend
+ - ImgWriteOgr
+	overwrite existing ogr datasets per default
+
+Todo:
+ - todo for API
+	ImgReaderGdal (ImgWriterGdal) open in update mode (check gdal_edit.py: http://searchcode.com/codesearch/view/18938404)
+	Img[Reader|Writer]Ogr replace OGRDataSource with GDALDataset conform to GDAL API 2.x
 
diff --git a/Makefile.in b/Makefile.in
index a2b41a4..3246c9a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,23 +16,51 @@
 
 
 VPATH = @srcdir@
-am__make_dryrun = \
-  { \
-    am__dry=no; \
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
     case $$MAKEFLAGS in \
       *\\[\ \	]*) \
-        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
-          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
-      *) \
-        for am__flg in $$MAKEFLAGS; do \
-          case $$am__flg in \
-            *=*|--*) ;; \
-            *n*) am__dry=yes; break;; \
-          esac; \
-        done;; \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
     esac; \
-    test $$am__dry = yes; \
-  }
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -53,11 +80,11 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = .
-DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
-	$(srcdir)/pktools.pc.in $(top_srcdir)/configure AUTHORS \
-	COPYING ChangeLog INSTALL NEWS config.guess config.sub depcomp \
-	install-sh ltmain.sh missing
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/configure $(am__configure_deps) \
+	$(srcdir)/config.h.in $(srcdir)/pktools.pc.in AUTHORS COPYING \
+	ChangeLog INSTALL NEWS README compile config.guess config.sub \
+	depcomp install-sh missing ltmain.sh
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -71,15 +98,28 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES = pktools.pc
 CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 SOURCES =
 DIST_SOURCES =
-RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
-	html-recursive info-recursive install-data-recursive \
-	install-dvi-recursive install-exec-recursive \
-	install-html-recursive install-info-recursive \
-	install-pdf-recursive install-ps-recursive install-recursive \
-	installcheck-recursive installdirs-recursive pdf-recursive \
-	ps-recursive uninstall-recursive
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+	ctags-recursive dvi-recursive html-recursive info-recursive \
+	install-data-recursive install-dvi-recursive \
+	install-exec-recursive install-html-recursive \
+	install-info-recursive install-pdf-recursive \
+	install-ps-recursive install-recursive installcheck-recursive \
+	installdirs-recursive pdf-recursive ps-recursive \
+	tags-recursive uninstall-recursive
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -118,11 +158,33 @@ DATA = $(pkgconfig_DATA)
 HEADERS = $(nodist_pktools_libinclude_HEADERS)
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
-AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
-	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
-	distdir dist dist-all distcheck
+am__recursive_targets = \
+  $(RECURSIVE_TARGETS) \
+  $(RECURSIVE_CLEAN_TARGETS) \
+  $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+	cscope distdir dist dist-all distcheck
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
+	$(LISP)config.h.in
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+CSCOPE = cscope
 DIST_SUBDIRS = $(SUBDIRS)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
@@ -133,6 +195,7 @@ am__remove_distdir = \
       && rm -rf "$(distdir)" \
       || { sleep 5 && rm -rf "$(distdir)"; }; \
   else :; fi
+am__post_remove_distdir = $(am__remove_distdir)
 am__relativize = \
   dir0=`pwd`; \
   sed_first='s,^\([^/]*\)/.*$$,\1,'; \
@@ -160,6 +223,7 @@ am__relativize = \
   reldir="$$dir2"
 DIST_ARCHIVES = $(distdir).tar.gz
 GZIP_ENV = --best
+DIST_TARGETS = dist-gzip
 distuninstallcheck_listfiles = find . -type f -print
 am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
   | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
@@ -167,6 +231,7 @@ distcleancheck_listfiles = find . -type f -print
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_CXXFLAGS = @AM_CXXFLAGS@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AM_LDFLAGS = @AM_LDFLAGS@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
@@ -360,8 +425,8 @@ $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 $(am__aclocal_m4_deps):
 
 config.h: stamp-h1
-	@if test ! -f $@; then rm -f stamp-h1; else :; fi
-	@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
+	@test -f $@ || rm -f stamp-h1
+	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
 
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
@@ -428,22 +493,25 @@ uninstall-nodist_pktools_libincludeHEADERS:
 	dir='$(DESTDIR)$(pktools_libincludedir)'; $(am__uninstall_files_from_dir)
 
 # This directory's subdirectories are mostly independent; you can cd
-# into them and run `make' without going through this Makefile.
-# To change the values of `make' variables: instead of editing Makefiles,
-# (1) if the variable is set in `config.status', edit `config.status'
-#     (which will cause the Makefiles to be regenerated when you run `make');
-# (2) otherwise, pass the desired values on the `make' command line.
-$(RECURSIVE_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+#     (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+	@fail=; \
+	if $(am__make_keepgoing); then \
+	  failcom='fail=yes'; \
+	else \
+	  failcom='exit 1'; \
+	fi; \
 	dot_seen=no; \
 	target=`echo $@ | sed s/-recursive//`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	for subdir in $$list; do \
 	  echo "Making $$target in $$subdir"; \
 	  if test "$$subdir" = "."; then \
 	    dot_seen=yes; \
@@ -458,57 +526,12 @@ $(RECURSIVE_TARGETS):
 	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
 	fi; test -z "$$fail"
 
-$(RECURSIVE_CLEAN_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
-	dot_seen=no; \
-	case "$@" in \
-	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
-	  *) list='$(SUBDIRS)' ;; \
-	esac; \
-	rev=''; for subdir in $$list; do \
-	  if test "$$subdir" = "."; then :; else \
-	    rev="$$subdir $$rev"; \
-	  fi; \
-	done; \
-	rev="$$rev ."; \
-	target=`echo $@ | sed s/-recursive//`; \
-	for subdir in $$rev; do \
-	  echo "Making $$target in $$subdir"; \
-	  if test "$$subdir" = "."; then \
-	    local_target="$$target-am"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
-	done && test -z "$$fail"
-tags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
-	done
-ctags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
-	done
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
 	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
@@ -524,12 +547,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
 	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
-	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -541,15 +559,11 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -558,9 +572,31 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscope: cscope.files
+	test ! -s cscope.files \
+	  || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+clean-cscope:
+	-rm -f cscope.files
+cscope.files: clean-cscope cscopelist
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
 
 distdir: $(DISTFILES)
 	$(am__remove_distdir)
@@ -628,40 +664,42 @@ distdir: $(DISTFILES)
 	|| chmod -R a+r "$(distdir)"
 dist-gzip: distdir
 	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-bzip2: distdir
 	tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-lzip: distdir
 	tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
-	$(am__remove_distdir)
-
-dist-lzma: distdir
-	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-xz: distdir
 	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
+	@echo WARNING: "Support for shar distribution archives 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__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-shar: distdir
+	@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
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-zip: distdir
 	-rm -f $(distdir).zip
 	zip -rq $(distdir).zip $(distdir)
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
-dist dist-all: distdir
-	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-	$(am__remove_distdir)
+dist dist-all:
+	$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+	$(am__post_remove_distdir)
 
 # This target untars the dist file and tries a VPATH configuration.  Then
 # it guarantees that the distribution is self-contained by making another
@@ -672,8 +710,6 @@ distcheck: dist
 	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
 	*.tar.bz2*) \
 	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
-	*.tar.lzma*) \
-	  lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
 	*.tar.lz*) \
 	  lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
 	*.tar.xz*) \
@@ -685,18 +721,19 @@ distcheck: dist
 	*.zip*) \
 	  unzip $(distdir).zip ;;\
 	esac
-	chmod -R a-w $(distdir); chmod u+w $(distdir)
-	mkdir $(distdir)/_build
-	mkdir $(distdir)/_inst
+	chmod -R a-w $(distdir)
+	chmod u+w $(distdir)
+	mkdir $(distdir)/_build $(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 --srcdir=.. --prefix="$$dc_install_base" \
+	  && ../configure \
 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
+	    --srcdir=.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
@@ -719,7 +756,7 @@ distcheck: dist
 	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
 	  && cd "$$am__cwd" \
 	  || exit 1
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 	@(echo "$(distdir) archives ready for distribution: "; \
 	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
 	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
@@ -859,26 +896,25 @@ ps-am:
 uninstall-am: uninstall-nodist_pktools_libincludeHEADERS \
 	uninstall-pkgconfigDATA
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
-	ctags-recursive install-am install-strip tags-recursive
-
-.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
-	all all-am am--refresh check check-am clean clean-generic \
-	clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
-	dist-gzip dist-lzip dist-lzma dist-shar dist-tarZ dist-xz \
-	dist-zip distcheck distclean distclean-generic distclean-hdr \
-	distclean-libtool distclean-tags distcleancheck distdir \
-	distuninstallcheck 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-info install-info-am install-man \
-	install-nodist_pktools_libincludeHEADERS install-pdf \
-	install-pdf-am install-pkgconfigDATA install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	installdirs-am maintainer-clean maintainer-clean-generic \
-	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
-	ps ps-am tags tags-recursive uninstall uninstall-am \
-	uninstall-nodist_pktools_libincludeHEADERS \
+.MAKE: $(am__recursive_targets) all install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
+	am--refresh check check-am clean clean-cscope clean-generic \
+	clean-libtool cscope cscopelist-am ctags ctags-am dist \
+	dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \
+	dist-xz dist-zip distcheck distclean distclean-generic \
+	distclean-hdr distclean-libtool distclean-tags distcleancheck \
+	distdir distuninstallcheck 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-info install-info-am \
+	install-man install-nodist_pktools_libincludeHEADERS \
+	install-pdf install-pdf-am install-pkgconfigDATA install-ps \
+	install-ps-am install-strip installcheck installcheck-am \
+	installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
+	uninstall-am uninstall-nodist_pktools_libincludeHEADERS \
 	uninstall-pkgconfigDATA
 
 
diff --git a/aclocal.m4 b/aclocal.m4
index 3ddcf5f..e223108 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,8 +1,7 @@
-# generated automatically by aclocal 1.11.6 -*- Autoconf -*-
+# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -12,13 +11,14 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
 [m4_warning([this file was generated for autoconf 2.69.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
-To do so, use the procedure documented by the package, typically `autoreconf'.])])
+To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
 # pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
 # serial 1 (pkg-config-0.24)
@@ -180,25 +180,22 @@ else
 fi[]dnl
 ])# PKG_CHECK_MODULES
 
-# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 2002-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.
 
-# serial 1
-
 # AM_AUTOMAKE_VERSION(VERSION)
 # ----------------------------
 # Automake X.Y traces this macro to ensure aclocal.m4 has been
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.11'
+[am__api_version='1.14'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.11.6], [],
+m4_if([$1], [1.14.1], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -214,24 +211,22 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.11.6])dnl
+[AM_AUTOMAKE_VERSION([1.14.1])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, 2003, 2005, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2001-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.
 
-# serial 1
-
 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
-# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
-# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
+# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
 #
 # Of course, Automake must honor this variable whenever it calls a
 # tool from the auxiliary directory.  The problem is that $srcdir (and
@@ -250,7 +245,7 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 #
 # The reason of the latter failure is that $top_srcdir and $ac_aux_dir
 # are both prefixed by $srcdir.  In an in-source build this is usually
-# harmless because $srcdir is `.', but things will broke when you
+# harmless because $srcdir is '.', but things will broke when you
 # start a VPATH build or use an absolute $srcdir.
 #
 # So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
@@ -276,14 +271,12 @@ am_aux_dir=`cd $ac_aux_dir && pwd`
 
 # AM_COND_IF                                            -*- Autoconf -*-
 
-# Copyright (C) 2008, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2008-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.
 
-# serial 3
-
 # _AM_COND_IF
 # _AM_COND_ELSE
 # _AM_COND_ENDIF
@@ -293,7 +286,6 @@ m4_define([_AM_COND_IF])
 m4_define([_AM_COND_ELSE])
 m4_define([_AM_COND_ENDIF])
 
-
 # AM_COND_IF(COND, [IF-TRUE], [IF-FALSE])
 # ---------------------------------------
 # If the shell condition COND is true, execute IF-TRUE, otherwise execute
@@ -316,22 +308,19 @@ fi[]dnl
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 1997-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.
 
-# serial 9
-
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -------------------------------------
 # Define a conditional.
 AC_DEFUN([AM_CONDITIONAL],
-[AC_PREREQ(2.52)dnl
- ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
-	[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
 AC_SUBST([$1_TRUE])dnl
 AC_SUBST([$1_FALSE])dnl
 _AM_SUBST_NOTMAKE([$1_TRUE])dnl
@@ -350,16 +339,14 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009,
-# 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 1999-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.
 
-# serial 12
 
-# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
 # will think it sees a *use*, and therefore will trigger all it's
 # C support machinery.  Also note that it means that autoscan, seeing
@@ -369,7 +356,7 @@ fi])])
 # _AM_DEPENDENCIES(NAME)
 # ----------------------
 # See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
 # We try a few techniques and use that to set a single cache variable.
 #
 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
@@ -382,12 +369,13 @@ AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
 AC_REQUIRE([AM_DEP_TRACK])dnl
 
-ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
-       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
-       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
-       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
-       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
-                   [depcc="$$1"   am_compiler_list=])
+m4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
+      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
+      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
+      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
+      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                    [depcc="$$1"   am_compiler_list=])
 
 AC_CACHE_CHECK([dependency style of $depcc],
                [am_cv_$1_dependencies_compiler_type],
@@ -395,8 +383,8 @@ AC_CACHE_CHECK([dependency style of $depcc],
   # We make a subdir and do the tests there.  Otherwise we can end up
   # making bogus files that we don't know about and never remove.  For
   # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
   rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
@@ -436,16 +424,16 @@ AC_CACHE_CHECK([dependency style of $depcc],
     : > sub/conftest.c
     for i in 1 2 3 4 5 6; do
       echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
     # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
     am__obj=sub/conftest.${OBJEXT-o}
     am__minus_obj="-o $am__obj"
     case $depmode in
@@ -454,8 +442,8 @@ AC_CACHE_CHECK([dependency style of $depcc],
       test "$am__universal" = false || continue
       ;;
     nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
       if test "x$enable_dependency_tracking" = xyes; then
 	continue
       else
@@ -463,7 +451,7 @@ AC_CACHE_CHECK([dependency style of $depcc],
       fi
       ;;
     msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
+      # This compiler won't grok '-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
       am__obj=conftest.${OBJEXT-o}
@@ -511,7 +499,7 @@ AM_CONDITIONAL([am__fastdep$1], [
 # AM_SET_DEPDIR
 # -------------
 # Choose a directory name for dependency files.
-# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
 AC_DEFUN([AM_SET_DEPDIR],
 [AC_REQUIRE([AM_SET_LEADING_DOT])dnl
 AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
@@ -521,9 +509,13 @@ AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
 # AM_DEP_TRACK
 # ------------
 AC_DEFUN([AM_DEP_TRACK],
-[AC_ARG_ENABLE(dependency-tracking,
-[  --disable-dependency-tracking  speeds up one-time build
-  --enable-dependency-tracking   do not reject slow dependency extractors])
+[AC_ARG_ENABLE([dependency-tracking], [dnl
+AS_HELP_STRING(
+  [--enable-dependency-tracking],
+  [do not reject slow dependency extractors])
+AS_HELP_STRING(
+  [--disable-dependency-tracking],
+  [speeds up one-time build])])
 if test "x$enable_dependency_tracking" != xno; then
   am_depcomp="$ac_aux_dir/depcomp"
   AMDEPBACKSLASH='\'
@@ -538,20 +530,18 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 1999-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.
 
-#serial 5
 
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
 [{
-  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # 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
@@ -564,7 +554,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
     # Strip MF so we end up with the name of the file.
     mf=`echo "$mf" | sed -e 's/:.*$//'`
     # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named `Makefile.in', but
+    # We used to match only the files named 'Makefile.in', but
     # some people rename them; so instead we look at the file content.
     # Grep'ing the first line is not enough: some people post-process
     # each Makefile.in and add a new line on top of each file to say so.
@@ -576,21 +566,19 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
       continue
     fi
     # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running `make'.
+    # from the Makefile without running 'make'.
     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     test -z "$DEPDIR" && continue
     am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "am__include" && continue
+    test -z "$am__include" && continue
     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # When using ansi2knr, U may be empty or an underscore; expand it
-    U=`sed -n 's/^U = //p' < "$mf"`
     # Find all dependency output files, they are included files with
     # $(DEPDIR) in their names.  We invoke sed twice because it is the
     # simplest approach to changing $(DEPDIR) to its actual value in the
     # expansion.
     for file in `sed -n "
       s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
       # Make sure the directory exists.
       test -f "$dirpart/$file" && continue
       fdir=`AS_DIRNAME(["$file"])`
@@ -608,7 +596,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
 # This macro should only be invoked once -- use via AC_REQUIRE.
 #
 # This code is only required when automatic dependency tracking
-# is enabled.  FIXME.  This creates each `.P' file that we will
+# is enabled.  FIXME.  This creates each '.P' file that we will
 # need in order to bootstrap the dependency handling code.
 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 [AC_CONFIG_COMMANDS([depfiles],
@@ -618,18 +606,21 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+# Copyright (C) 1996-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.
 
-# serial 16
-
 # This macro actually does too much.  Some checks are only needed if
 # your package does certain things.  But this isn't really a big deal.
 
+dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
+m4_define([AC_PROG_CC],
+m4_defn([AC_PROG_CC])
+[_AM_PROG_CC_C_O
+])
+
 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
 # AM_INIT_AUTOMAKE([OPTIONS])
 # -----------------------------------------------
@@ -642,7 +633,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 # arguments mandatory, and then we can depend on a new Autoconf
 # release and drop the old call support.
 AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_PREREQ([2.62])dnl
+[AC_PREREQ([2.65])dnl
 dnl Autoconf wants to disallow AM_ names.  We explicitly allow
 dnl the ones we care about.
 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
@@ -671,31 +662,40 @@ AC_SUBST([CYGPATH_W])
 # Define the identity of the package.
 dnl Distinguish between old-style and new-style calls.
 m4_ifval([$2],
-[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+[AC_DIAGNOSE([obsolete],
+             [$0: two- and three-arguments forms are deprecated.])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
  AC_SUBST([PACKAGE], [$1])dnl
  AC_SUBST([VERSION], [$2])],
 [_AM_SET_OPTIONS([$1])dnl
 dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
-m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+m4_if(
+  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+  [ok:ok],,
   [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
  AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
  AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
 
 _AM_IF_OPTION([no-define],,
-[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
- AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+ AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
 
 # Some tools Automake needs.
 AC_REQUIRE([AM_SANITY_CHECK])dnl
 AC_REQUIRE([AC_ARG_PROGRAM])dnl
-AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
-AM_MISSING_PROG(AUTOCONF, autoconf)
-AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
-AM_MISSING_PROG(AUTOHEADER, autoheader)
-AM_MISSING_PROG(MAKEINFO, makeinfo)
+AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
+AM_MISSING_PROG([AUTOCONF], [autoconf])
+AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
+AM_MISSING_PROG([AUTOHEADER], [autoheader])
+AM_MISSING_PROG([MAKEINFO], [makeinfo])
 AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
 AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
-AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
 # We need awk for the "check" target.  The system "awk" is bad on
 # some platforms.
 AC_REQUIRE([AC_PROG_AWK])dnl
@@ -706,34 +706,78 @@ _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
 			     [_AM_PROG_TAR([v7])])])
 _AM_IF_OPTION([no-dependencies],,
 [AC_PROVIDE_IFELSE([AC_PROG_CC],
-		  [_AM_DEPENDENCIES(CC)],
-		  [define([AC_PROG_CC],
-			  defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+		  [_AM_DEPENDENCIES([CC])],
+		  [m4_define([AC_PROG_CC],
+			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_CXX],
-		  [_AM_DEPENDENCIES(CXX)],
-		  [define([AC_PROG_CXX],
-			  defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+		  [_AM_DEPENDENCIES([CXX])],
+		  [m4_define([AC_PROG_CXX],
+			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_OBJC],
-		  [_AM_DEPENDENCIES(OBJC)],
-		  [define([AC_PROG_OBJC],
-			  defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+		  [_AM_DEPENDENCIES([OBJC])],
+		  [m4_define([AC_PROG_OBJC],
+			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+		  [_AM_DEPENDENCIES([OBJCXX])],
+		  [m4_define([AC_PROG_OBJCXX],
+			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
 ])
-_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
-dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
-dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
-dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_REQUIRE([AM_SILENT_RULES])dnl
+dnl The testsuite driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
+dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
 AC_CONFIG_COMMANDS_PRE(dnl
 [m4_provide_if([_AM_COMPILER_EXEEXT],
   [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
-])
 
-dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes.  So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+  cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present.  This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake at gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message.  This
+can help us improve future automake versions.
+
+END
+  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+    echo 'Configuration will proceed anyway, since you have set the' >&2
+    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+    echo >&2
+  else
+    cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
+  fi
+fi])
+
+dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
 dnl mangled by Autoconf and run in a shell conditional statement.
 m4_define([_AC_COMPILER_EXEEXT],
 m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
 
-
 # When config.status generates a header, we must update the stamp-h file.
 # This file resides in the same directory as the config header
 # that is generated.  The stamp files are numbered to have different names.
@@ -755,15 +799,12 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2001-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.
 
-# serial 1
-
 # AM_PROG_INSTALL_SH
 # ------------------
 # Define $install_sh.
@@ -777,16 +818,14 @@ if test x"${install_sh}" != xset; then
     install_sh="\${SHELL} $am_aux_dir/install-sh"
   esac
 fi
-AC_SUBST(install_sh)])
+AC_SUBST([install_sh])])
 
-# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2003-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.
 
-# serial 2
-
 # Check whether the underlying file-system supports filenames
 # with a leading dot.  For instance MS-DOS doesn't.
 AC_DEFUN([AM_SET_LEADING_DOT],
@@ -802,14 +841,12 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
+# Copyright (C) 2001-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.
 
-# serial 4
-
 # AM_MAKE_INCLUDE()
 # -----------------
 # Check to see how make treats includes.
@@ -827,7 +864,7 @@ am__quote=
 _am_result=none
 # First try GNU make style include.
 echo "include confinc" > confmf
-# Ignore all kinds of additional output from `make'.
+# Ignore all kinds of additional output from 'make'.
 case `$am_make -s -f confmf 2> /dev/null` in #(
 *the\ am__doit\ target*)
   am__include=include
@@ -854,15 +891,12 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 1997-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.
 
-# serial 6
-
 # AM_MISSING_PROG(NAME, PROGRAM)
 # ------------------------------
 AC_DEFUN([AM_MISSING_PROG],
@@ -870,11 +904,10 @@ AC_DEFUN([AM_MISSING_PROG],
 $1=${$1-"${am_missing_run}$2"}
 AC_SUBST($1)])
 
-
 # AM_MISSING_HAS_RUN
 # ------------------
-# Define MISSING if not defined so far and test if it supports --run.
-# If it does, set am_missing_run to use it, otherwise, to nothing.
+# Define MISSING if not defined so far and test if it is modern enough.
+# If it is, set am_missing_run to use it, otherwise, to nothing.
 AC_DEFUN([AM_MISSING_HAS_RUN],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 AC_REQUIRE_AUX_FILE([missing])dnl
@@ -887,54 +920,22 @@ if test x"${MISSING+set}" != xset; then
   esac
 fi
 # Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
-  am_missing_run="$MISSING --run "
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
 else
   am_missing_run=
-  AC_MSG_WARN([`missing' script is too old or missing])
+  AC_MSG_WARN(['missing' script is too old or missing])
 fi
 ])
 
-# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation,
-# Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 1
-
-# AM_PROG_MKDIR_P
-# ---------------
-# Check for `mkdir -p'.
-AC_DEFUN([AM_PROG_MKDIR_P],
-[AC_PREREQ([2.60])dnl
-AC_REQUIRE([AC_PROG_MKDIR_P])dnl
-dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
-dnl while keeping a definition of mkdir_p for backward compatibility.
-dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
-dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
-dnl Makefile.ins that do not define MKDIR_P, so we do our own
-dnl adjustment using top_builddir (which is defined more often than
-dnl MKDIR_P).
-AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
-case $mkdir_p in
-  [[\\/$]]* | ?:[[\\/]]*) ;;
-  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
-esac
-])
-
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 2001-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.
 
-# serial 5
-
 # _AM_MANGLE_OPTION(NAME)
 # -----------------------
 AC_DEFUN([_AM_MANGLE_OPTION],
@@ -944,7 +945,7 @@ AC_DEFUN([_AM_MANGLE_OPTION],
 # --------------------
 # Set option NAME.  Presently that only means defining a flag for this option.
 AC_DEFUN([_AM_SET_OPTION],
-[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
 
 # _AM_SET_OPTIONS(OPTIONS)
 # ------------------------
@@ -958,24 +959,82 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+# Copyright (C) 1999-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_PROG_CC_C_O
+# ---------------
+# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
+# to automatically call this.
+AC_DEFUN([_AM_PROG_CC_C_O],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+AC_LANG_PUSH([C])dnl
+AC_CACHE_CHECK(
+  [whether $CC understands -c and -o together],
+  [am_cv_prog_cc_c_o],
+  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
+  # Make sure it works both with $CC and with simple cc.
+  # Following AC_PROG_CC_C_O, we do the test twice because some
+  # compilers refuse to overwrite an existing .o file with -o,
+  # though they will create one.
+  am_cv_prog_cc_c_o=yes
+  for am_i in 1 2; do
+    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
+         && test -f conftest2.$ac_objext; then
+      : OK
+    else
+      am_cv_prog_cc_c_o=no
+      break
+    fi
+  done
+  rm -f core conftest*
+  unset am_i])
+if test "$am_cv_prog_cc_c_o" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+AC_LANG_POP([C])])
+
+# For backward compatibility.
+AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 2001-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.
 
-# serial 5
+# AM_RUN_LOG(COMMAND)
+# -------------------
+# Run COMMAND, save the exit status in ac_status, and log it.
+# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+AC_DEFUN([AM_RUN_LOG],
+[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   (exit $ac_status); }])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# 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_SANITY_CHECK
 # ---------------
 AC_DEFUN([AM_SANITY_CHECK],
 [AC_MSG_CHECKING([whether build environment is sane])
-# Just in case
-sleep 1
-echo timestamp > conftest.file
 # Reject unsafe characters in $srcdir or the absolute working directory
 # name.  Accept space and tab only in the latter.
 am_lf='
@@ -986,32 +1045,40 @@ case `pwd` in
 esac
 case $srcdir in
   *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
-    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
 esac
 
-# Do `set' in a subshell so we don't clobber the current shell's
+# Do 'set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
-   if test "$[*]" = "X"; then
-      # -L didn't work.
-      set X `ls -t "$srcdir/configure" conftest.file`
-   fi
-   rm -f conftest.file
-   if test "$[*]" != "X $srcdir/configure conftest.file" \
-      && test "$[*]" != "X conftest.file $srcdir/configure"; then
-
-      # If neither matched, then we have a broken ls.  This can happen
-      # if, for instance, CONFIG_SHELL is bash and it inherits a
-      # broken ls alias from the environment.  This has actually
-      # happened.  Such a system could not be considered "sane".
-      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
-alias in your environment])
-   fi
-
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$[*]" = "X"; then
+	# -L didn't work.
+	set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$[*]" != "X $srcdir/configure conftest.file" \
+	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+	# If neither matched, then we have a broken ls.  This can happen
+	# if, for instance, CONFIG_SHELL is bash and it inherits a
+	# broken ls alias from the environment.  This has actually
+	# happened.  Such a system could not be considered "sane".
+	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment])
+     fi
+     if test "$[2]" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
    test "$[2]" = conftest.file
    )
 then
@@ -1021,46 +1088,118 @@ else
    AC_MSG_ERROR([newly created file is older than distributed files!
 Check your system clock])
 fi
-AC_MSG_RESULT(yes)])
+AC_MSG_RESULT([yes])
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+AC_CONFIG_COMMANDS_PRE(
+  [AC_MSG_CHECKING([that generated files are newer than configure])
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   AC_MSG_RESULT([done])])
+rm -f conftest.file
+])
 
-# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2009-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.
 
-# serial 1
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# ("yes" being less verbose, "no" or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules], [dnl
+AS_HELP_STRING(
+  [--enable-silent-rules],
+  [less verbose build output (undo: "make V=1")])
+AS_HELP_STRING(
+  [--disable-silent-rules],
+  [verbose build output (undo: "make V=0")])dnl
+])
+case $enable_silent_rules in @%:@ (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+dnl
+dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
+dnl do not support nested variable expansions.
+dnl See automake bug#9928 and bug#10237.
+am_make=${MAKE-make}
+AC_CACHE_CHECK([whether $am_make supports nested variables],
+   [am_cv_make_support_nested_variables],
+   [if AS_ECHO([['TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi])
+if test $am_cv_make_support_nested_variables = yes; then
+  dnl Using '$V' instead of '$(V)' breaks IRIX make.
+  AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AC_SUBST([AM_V])dnl
+AM_SUBST_NOTMAKE([AM_V])dnl
+AC_SUBST([AM_DEFAULT_V])dnl
+AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
+
+# Copyright (C) 2001-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_PROG_INSTALL_STRIP
 # ---------------------
-# One issue with vendor `install' (even GNU) is that you can't
+# One issue with vendor 'install' (even GNU) is that you can't
 # specify the program used to strip binaries.  This is especially
 # annoying in cross-compiling environments, where the build's strip
 # is unlikely to handle the host's binaries.
 # Fortunately install-sh will honor a STRIPPROG variable, so we
-# always use install-sh in `make install-strip', and initialize
+# always use install-sh in "make install-strip", and initialize
 # STRIPPROG with the value of the STRIP variable (set by the user).
 AC_DEFUN([AM_PROG_INSTALL_STRIP],
 [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'.  However `strip' might not be the right
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
 # tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+# will honor the 'STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
 if test "$cross_compiling" != no; then
   AC_CHECK_TOOL([STRIP], [strip], :)
 fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2006-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.
 
-# serial 3
-
 # _AM_SUBST_NOTMAKE(VARIABLE)
 # ---------------------------
 # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
@@ -1074,18 +1213,16 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc.
+# Copyright (C) 2004-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.
 
-# serial 2
-
 # _AM_PROG_TAR(FORMAT)
 # --------------------
 # Check how to create a tarball in format FORMAT.
-# FORMAT should be one of `v7', `ustar', or `pax'.
+# FORMAT should be one of 'v7', 'ustar', or 'pax'.
 #
 # Substitute a variable $(am__tar) that is a command
 # writing to stdout a FORMAT-tarball containing the directory
@@ -1095,76 +1232,114 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 # Substitute a variable $(am__untar) that extract such
 # a tarball read from stdin.
 #     $(am__untar) < result.tar
+#
 AC_DEFUN([_AM_PROG_TAR],
 [# Always define AMTAR for backward compatibility.  Yes, it's still used
 # in the wild :-(  We should find a proper way to deprecate it ...
 AC_SUBST([AMTAR], ['$${TAR-tar}'])
-m4_if([$1], [v7],
-     [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
-     [m4_case([$1], [ustar],, [pax],,
-              [m4_fatal([Unknown tar format])])
-AC_MSG_CHECKING([how to create a $1 tar archive])
-# Loop over all known methods to create a tar archive until one works.
+
+# We'll loop over all known methods to create a tar archive until one works.
 _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
-_am_tools=${am_cv_prog_tar_$1-$_am_tools}
-# Do not fold the above two line into one, because Tru64 sh and
-# Solaris sh will not grok spaces in the rhs of `-'.
-for _am_tool in $_am_tools
-do
-  case $_am_tool in
-  gnutar)
-    for _am_tar in tar gnutar gtar;
-    do
-      AM_RUN_LOG([$_am_tar --version]) && break
-    done
-    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
-    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
-    am__untar="$_am_tar -xf -"
-    ;;
-  plaintar)
-    # Must skip GNU tar: if it does not support --format= it doesn't create
-    # ustar tarball either.
-    (tar --version) >/dev/null 2>&1 && continue
-    am__tar='tar chf - "$$tardir"'
-    am__tar_='tar chf - "$tardir"'
-    am__untar='tar xf -'
-    ;;
-  pax)
-    am__tar='pax -L -x $1 -w "$$tardir"'
-    am__tar_='pax -L -x $1 -w "$tardir"'
-    am__untar='pax -r'
-    ;;
-  cpio)
-    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
-    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
-    am__untar='cpio -i -H $1 -d'
-    ;;
-  none)
-    am__tar=false
-    am__tar_=false
-    am__untar=false
-    ;;
-  esac
 
-  # If the value was cached, stop now.  We just wanted to have am__tar
-  # and am__untar set.
-  test -n "${am_cv_prog_tar_$1}" && break
+m4_if([$1], [v7],
+  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
+
+  [m4_case([$1],
+    [ustar],
+     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
+      # There is notably a 21 bits limit for the UID and the GID.  In fact,
+      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
+      # and bug#13588).
+      am_max_uid=2097151 # 2^21 - 1
+      am_max_gid=$am_max_uid
+      # The $UID and $GID variables are not portable, so we need to resort
+      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
+      # below are definitely unexpected, so allow the users to see them
+      # (that is, avoid stderr redirection).
+      am_uid=`id -u || echo unknown`
+      am_gid=`id -g || echo unknown`
+      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
+      if test $am_uid -le $am_max_uid; then
+         AC_MSG_RESULT([yes])
+      else
+         AC_MSG_RESULT([no])
+         _am_tools=none
+      fi
+      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
+      if test $am_gid -le $am_max_gid; then
+         AC_MSG_RESULT([yes])
+      else
+        AC_MSG_RESULT([no])
+        _am_tools=none
+      fi],
+
+  [pax],
+    [],
+
+  [m4_fatal([Unknown tar format])])
+
+  AC_MSG_CHECKING([how to create a $1 tar archive])
+
+  # Go ahead even if we have the value already cached.  We do so because we
+  # need to set the values for the 'am__tar' and 'am__untar' variables.
+  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
+
+  for _am_tool in $_am_tools; do
+    case $_am_tool in
+    gnutar)
+      for _am_tar in tar gnutar gtar; do
+        AM_RUN_LOG([$_am_tar --version]) && break
+      done
+      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+      am__untar="$_am_tar -xf -"
+      ;;
+    plaintar)
+      # Must skip GNU tar: if it does not support --format= it doesn't create
+      # ustar tarball either.
+      (tar --version) >/dev/null 2>&1 && continue
+      am__tar='tar chf - "$$tardir"'
+      am__tar_='tar chf - "$tardir"'
+      am__untar='tar xf -'
+      ;;
+    pax)
+      am__tar='pax -L -x $1 -w "$$tardir"'
+      am__tar_='pax -L -x $1 -w "$tardir"'
+      am__untar='pax -r'
+      ;;
+    cpio)
+      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+      am__untar='cpio -i -H $1 -d'
+      ;;
+    none)
+      am__tar=false
+      am__tar_=false
+      am__untar=false
+      ;;
+    esac
 
-  # tar/untar a dummy directory, and stop if the command works
-  rm -rf conftest.dir
-  mkdir conftest.dir
-  echo GrepMe > conftest.dir/file
-  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+    # If the value was cached, stop now.  We just wanted to have am__tar
+    # and am__untar set.
+    test -n "${am_cv_prog_tar_$1}" && break
+
+    # tar/untar a dummy directory, and stop if the command works.
+    rm -rf conftest.dir
+    mkdir conftest.dir
+    echo GrepMe > conftest.dir/file
+    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+    rm -rf conftest.dir
+    if test -s conftest.tar; then
+      AM_RUN_LOG([$am__untar <conftest.tar])
+      AM_RUN_LOG([cat conftest.dir/file])
+      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+    fi
+  done
   rm -rf conftest.dir
-  if test -s conftest.tar; then
-    AM_RUN_LOG([$am__untar <conftest.tar])
-    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
-  fi
-done
-rm -rf conftest.dir
 
-AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
-AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+
 AC_SUBST([am__tar])
 AC_SUBST([am__untar])
 ]) # _AM_PROG_TAR
diff --git a/compile b/compile
new file mode 100755
index 0000000..531136b
--- /dev/null
+++ b/compile
@@ -0,0 +1,347 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand '-c -o'.
+
+scriptversion=2012-10-14.11; # UTC
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey at cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake at gnu.org> or send patches to
+# <automake-patches at gnu.org>.
+
+nl='
+'
+
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent tools from complaining about whitespace usage.
+IFS=" ""	$nl"
+
+file_conv=
+
+# func_file_conv build_file lazy
+# Convert a $build file to $host form and store it in $file
+# Currently only supports Windows hosts. If the determined conversion
+# type is listed in (the comma separated) LAZY, no conversion will
+# take place.
+func_file_conv ()
+{
+  file=$1
+  case $file in
+    / | /[!/]*) # absolute file, and not a UNC file
+      if test -z "$file_conv"; then
+	# lazily determine how to convert abs files
+	case `uname -s` in
+	  MINGW*)
+	    file_conv=mingw
+	    ;;
+	  CYGWIN*)
+	    file_conv=cygwin
+	    ;;
+	  *)
+	    file_conv=wine
+	    ;;
+	esac
+      fi
+      case $file_conv/,$2, in
+	*,$file_conv,*)
+	  ;;
+	mingw/*)
+	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
+	  ;;
+	cygwin/*)
+	  file=`cygpath -m "$file" || echo "$file"`
+	  ;;
+	wine/*)
+	  file=`winepath -w "$file" || echo "$file"`
+	  ;;
+      esac
+      ;;
+  esac
+}
+
+# func_cl_dashL linkdir
+# Make cl look for libraries in LINKDIR
+func_cl_dashL ()
+{
+  func_file_conv "$1"
+  if test -z "$lib_path"; then
+    lib_path=$file
+  else
+    lib_path="$lib_path;$file"
+  fi
+  linker_opts="$linker_opts -LIBPATH:$file"
+}
+
+# func_cl_dashl library
+# Do a library search-path lookup for cl
+func_cl_dashl ()
+{
+  lib=$1
+  found=no
+  save_IFS=$IFS
+  IFS=';'
+  for dir in $lib_path $LIB
+  do
+    IFS=$save_IFS
+    if $shared && test -f "$dir/$lib.dll.lib"; then
+      found=yes
+      lib=$dir/$lib.dll.lib
+      break
+    fi
+    if test -f "$dir/$lib.lib"; then
+      found=yes
+      lib=$dir/$lib.lib
+      break
+    fi
+    if test -f "$dir/lib$lib.a"; then
+      found=yes
+      lib=$dir/lib$lib.a
+      break
+    fi
+  done
+  IFS=$save_IFS
+
+  if test "$found" != yes; then
+    lib=$lib.lib
+  fi
+}
+
+# func_cl_wrapper cl arg...
+# Adjust compile command to suit cl
+func_cl_wrapper ()
+{
+  # Assume a capable shell
+  lib_path=
+  shared=:
+  linker_opts=
+  for arg
+  do
+    if test -n "$eat"; then
+      eat=
+    else
+      case $1 in
+	-o)
+	  # configure might choose to run compile as 'compile cc -o foo foo.c'.
+	  eat=1
+	  case $2 in
+	    *.o | *.[oO][bB][jJ])
+	      func_file_conv "$2"
+	      set x "$@" -Fo"$file"
+	      shift
+	      ;;
+	    *)
+	      func_file_conv "$2"
+	      set x "$@" -Fe"$file"
+	      shift
+	      ;;
+	  esac
+	  ;;
+	-I)
+	  eat=1
+	  func_file_conv "$2" mingw
+	  set x "$@" -I"$file"
+	  shift
+	  ;;
+	-I*)
+	  func_file_conv "${1#-I}" mingw
+	  set x "$@" -I"$file"
+	  shift
+	  ;;
+	-l)
+	  eat=1
+	  func_cl_dashl "$2"
+	  set x "$@" "$lib"
+	  shift
+	  ;;
+	-l*)
+	  func_cl_dashl "${1#-l}"
+	  set x "$@" "$lib"
+	  shift
+	  ;;
+	-L)
+	  eat=1
+	  func_cl_dashL "$2"
+	  ;;
+	-L*)
+	  func_cl_dashL "${1#-L}"
+	  ;;
+	-static)
+	  shared=false
+	  ;;
+	-Wl,*)
+	  arg=${1#-Wl,}
+	  save_ifs="$IFS"; IFS=','
+	  for flag in $arg; do
+	    IFS="$save_ifs"
+	    linker_opts="$linker_opts $flag"
+	  done
+	  IFS="$save_ifs"
+	  ;;
+	-Xlinker)
+	  eat=1
+	  linker_opts="$linker_opts $2"
+	  ;;
+	-*)
+	  set x "$@" "$1"
+	  shift
+	  ;;
+	*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
+	  func_file_conv "$1"
+	  set x "$@" -Tp"$file"
+	  shift
+	  ;;
+	*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
+	  func_file_conv "$1" mingw
+	  set x "$@" "$file"
+	  shift
+	  ;;
+	*)
+	  set x "$@" "$1"
+	  shift
+	  ;;
+      esac
+    fi
+    shift
+  done
+  if test -n "$linker_opts"; then
+    linker_opts="-link$linker_opts"
+  fi
+  exec "$@" $linker_opts
+  exit 1
+}
+
+eat=
+
+case $1 in
+  '')
+     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand '-c -o'.
+Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file 'INSTALL'.
+
+Report bugs to <bug-automake at gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "compile $scriptversion"
+    exit $?
+    ;;
+  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+    func_cl_wrapper "$@"      # Doesn't return...
+    ;;
+esac
+
+ofile=
+cfile=
+
+for arg
+do
+  if test -n "$eat"; then
+    eat=
+  else
+    case $1 in
+      -o)
+	# configure might choose to run compile as 'compile cc -o foo foo.c'.
+	# So we strip '-o arg' only if arg is an object.
+	eat=1
+	case $2 in
+	  *.o | *.obj)
+	    ofile=$2
+	    ;;
+	  *)
+	    set x "$@" -o "$2"
+	    shift
+	    ;;
+	esac
+	;;
+      *.c)
+	cfile=$1
+	set x "$@" "$1"
+	shift
+	;;
+      *)
+	set x "$@" "$1"
+	shift
+	;;
+    esac
+  fi
+  shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+  # If no '-o' option was seen then we might have been invoked from a
+  # pattern rule where we don't need one.  That is ok -- this is a
+  # normal compilation that the losing compiler can handle.  If no
+  # '.c' file was seen then we are probably linking.  That is also
+  # ok.
+  exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use '[/\\:.-]' here to ensure that we don't use the same name
+# that we are using for the .o file.  Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
+while true; do
+  if mkdir "$lockdir" >/dev/null 2>&1; then
+    break
+  fi
+  sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+  test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+  test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# 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/config.guess b/config.guess
index d622a44..b79252d 100755
--- a/config.guess
+++ b/config.guess
@@ -1,14 +1,12 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#   2011, 2012 Free Software Foundation, Inc.
+#   Copyright 1992-2013 Free Software Foundation, Inc.
 
-timestamp='2012-02-10'
+timestamp='2013-06-10'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# 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
@@ -22,19 +20,17 @@ timestamp='2012-02-10'
 # 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.
-
-
-# Originally written by Per Bothner.  Please send patches (context
-# diff format) to <config-patches at gnu.org> and include a ChangeLog
-# entry.
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
 #
-# This script attempts to guess a canonical system name similar to
-# config.sub.  If it succeeds, it prints the system name on stdout, and
-# exits with 0.  Otherwise, it exits with 1.
+# Originally written by Per Bothner.
 #
 # You can get the latest version of this script from:
 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+#
+# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+
 
 me=`echo "$0" | sed -e 's,.*/,,'`
 
@@ -54,9 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+Copyright 1992-2013 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."
@@ -138,6 +132,27 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
 UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
+case "${UNAME_SYSTEM}" in
+Linux|GNU|GNU/*)
+	# If the system lacks a compiler, then just pick glibc.
+	# We could probably try harder.
+	LIBC=gnu
+
+	eval $set_cc_for_build
+	cat <<-EOF > $dummy.c
+	#include <features.h>
+	#if defined(__UCLIBC__)
+	LIBC=uclibc
+	#elif defined(__dietlibc__)
+	LIBC=dietlibc
+	#else
+	LIBC=gnu
+	#endif
+	EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+	;;
+esac
+
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
@@ -200,6 +215,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
 	echo "${machine}-${os}${release}"
 	exit ;;
+    *:Bitrig:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+	exit ;;
     *:OpenBSD:*:*)
 	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
 	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
@@ -302,7 +321,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
 	exit ;;
-    arm:riscos:*:*|arm:RISCOS:*:*)
+    arm*:riscos:*:*|arm*:RISCOS:*:*)
 	echo arm-unknown-riscos
 	exit ;;
     SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
@@ -801,6 +820,9 @@ EOF
     i*:CYGWIN*:*)
 	echo ${UNAME_MACHINE}-pc-cygwin
 	exit ;;
+    *:MINGW64*:*)
+	echo ${UNAME_MACHINE}-pc-mingw64
+	exit ;;
     *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
@@ -852,21 +874,21 @@ EOF
 	exit ;;
     *:GNU:*:*)
 	# the GNU system
-	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
 	exit ;;
     *:GNU/*:*:*)
 	# other systems with GNU libc and userland
-	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
 	exit ;;
     i*86:Minix:*:*)
 	echo ${UNAME_MACHINE}-pc-minix
 	exit ;;
     aarch64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     aarch64_be:Linux:*:*)
 	UNAME_MACHINE=aarch64_be
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     alpha:Linux:*:*)
 	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@@ -879,59 +901,54 @@ EOF
 	  EV68*) UNAME_MACHINE=alphaev68 ;;
 	esac
 	objdump --private-headers /bin/sh | grep -q ld.so.1
-	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
-	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    arc:Linux:*:* | arceb:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     arm*:Linux:*:*)
 	eval $set_cc_for_build
 	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
 	    | grep -q __ARM_EABI__
 	then
-	    echo ${UNAME_MACHINE}-unknown-linux-gnu
+	    echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	else
 	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
 		| grep -q __ARM_PCS_VFP
 	    then
-		echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+		echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
 	    else
-		echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
+		echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
 	    fi
 	fi
 	exit ;;
     avr32*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     cris:Linux:*:*)
-	echo ${UNAME_MACHINE}-axis-linux-gnu
+	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 	exit ;;
     crisv32:Linux:*:*)
-	echo ${UNAME_MACHINE}-axis-linux-gnu
+	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 	exit ;;
     frv:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     hexagon:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     i*86:Linux:*:*)
-	LIBC=gnu
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#ifdef __dietlibc__
-	LIBC=dietlibc
-	#endif
-EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
-	echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+	echo ${UNAME_MACHINE}-pc-linux-${LIBC}
 	exit ;;
     ia64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     m32r*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     m68*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     mips:Linux:*:* | mips64:Linux:*:*)
 	eval $set_cc_for_build
@@ -950,54 +967,63 @@ EOF
 	#endif
 EOF
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
-	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
 	;;
+    or1k:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     or32:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     padre:Linux:*:*)
-	echo sparc-unknown-linux-gnu
+	echo sparc-unknown-linux-${LIBC}
 	exit ;;
     parisc64:Linux:*:* | hppa64:Linux:*:*)
-	echo hppa64-unknown-linux-gnu
+	echo hppa64-unknown-linux-${LIBC}
 	exit ;;
     parisc:Linux:*:* | hppa:Linux:*:*)
 	# Look for CPU level
 	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
-	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
-	  *)    echo hppa-unknown-linux-gnu ;;
+	  PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
+	  PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+	  *)    echo hppa-unknown-linux-${LIBC} ;;
 	esac
 	exit ;;
     ppc64:Linux:*:*)
-	echo powerpc64-unknown-linux-gnu
+	echo powerpc64-unknown-linux-${LIBC}
 	exit ;;
     ppc:Linux:*:*)
-	echo powerpc-unknown-linux-gnu
+	echo powerpc-unknown-linux-${LIBC}
+	exit ;;
+    ppc64le:Linux:*:*)
+	echo powerpc64le-unknown-linux-${LIBC}
+	exit ;;
+    ppcle:Linux:*:*)
+	echo powerpcle-unknown-linux-${LIBC}
 	exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
-	echo ${UNAME_MACHINE}-ibm-linux
+	echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
 	exit ;;
     sh64*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     sh*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     tile*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     vax:Linux:*:*)
-	echo ${UNAME_MACHINE}-dec-linux-gnu
+	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
 	exit ;;
     x86_64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     xtensa*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     i*86:DYNIX/ptx:4*:*)
 	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -1201,6 +1227,9 @@ EOF
     BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
 	echo i586-pc-haiku
 	exit ;;
+    x86_64:Haiku:*:*)
+	echo x86_64-unknown-haiku
+	exit ;;
     SX-4:SUPER-UX:*:*)
 	echo sx4-nec-superux${UNAME_RELEASE}
 	exit ;;
@@ -1227,19 +1256,21 @@ EOF
 	exit ;;
     *:Darwin:*:*)
 	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-	case $UNAME_PROCESSOR in
-	    i386)
-		eval $set_cc_for_build
-		if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-		  if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-		      (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-		      grep IS_64BIT_ARCH >/dev/null
-		  then
-		      UNAME_PROCESSOR="x86_64"
-		  fi
-		fi ;;
-	    unknown) UNAME_PROCESSOR=powerpc ;;
-	esac
+	eval $set_cc_for_build
+	if test "$UNAME_PROCESSOR" = unknown ; then
+	    UNAME_PROCESSOR=powerpc
+	fi
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		grep IS_64BIT_ARCH >/dev/null
+	    then
+		case $UNAME_PROCESSOR in
+		    i386) UNAME_PROCESSOR=x86_64 ;;
+		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
+		esac
+	    fi
+	fi
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 	exit ;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
@@ -1256,7 +1287,7 @@ EOF
     NEO-?:NONSTOP_KERNEL:*:*)
 	echo neo-tandem-nsk${UNAME_RELEASE}
 	exit ;;
-    NSE-?:NONSTOP_KERNEL:*:*)
+    NSE-*:NONSTOP_KERNEL:*:*)
 	echo nse-tandem-nsk${UNAME_RELEASE}
 	exit ;;
     NSR-?:NONSTOP_KERNEL:*:*)
@@ -1330,9 +1361,6 @@ EOF
 	exit ;;
 esac
 
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
 eval $set_cc_for_build
 cat >$dummy.c <<EOF
 #ifdef _SEQUENT_
diff --git a/config.sub b/config.sub
index 6205f84..9633db7 100755
--- a/config.sub
+++ b/config.sub
@@ -1,24 +1,18 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#   2011, 2012 Free Software Foundation, Inc.
+#   Copyright 1992-2013 Free Software Foundation, Inc.
 
-timestamp='2012-04-18'
+timestamp='2013-08-10'
 
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine.  It does not imply ALL GNU software can.
-#
-# 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
+# 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 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.
+# 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/>.
@@ -26,11 +20,12 @@ timestamp='2012-04-18'
 # 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.
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
 
 
-# Please send patches to <config-patches at gnu.org>.  Submit a context
-# diff and a properly formatted GNU ChangeLog entry.
+# Please send patches with a ChangeLog entry to config-patches at gnu.org.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
@@ -73,9 +68,7 @@ Report bugs and patches to <config-patches at gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+Copyright 1992-2013 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -123,7 +116,7 @@ esac
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
-  linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
   knetbsd*-gnu* | netbsd*-gnu* | \
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
@@ -156,7 +149,7 @@ case $os in
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis | -knuth | -cray | -microblaze)
+	-apple | -axis | -knuth | -cray | -microblaze*)
 		os=
 		basic_machine=$1
 		;;
@@ -259,10 +252,12 @@ case $basic_machine in
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
-	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
-        | be32 | be64 \
+	| arc | arceb \
+	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+	| avr | avr32 \
+	| be32 | be64 \
 	| bfin \
-	| c4x | clipper \
+	| c4x | c8051 | clipper \
 	| d10v | d30v | dlx | dsp16xx \
 	| epiphany \
 	| fido | fr30 | frv \
@@ -273,7 +268,7 @@ case $basic_machine in
 	| le32 | le64 \
 	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
-	| maxq | mb | microblaze | mcore | mep | metag \
+	| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
@@ -291,16 +286,17 @@ case $basic_machine in
 	| mipsisa64r2 | mipsisa64r2el \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipsr5900 | mipsr5900el \
 	| mipstx39 | mipstx39el \
 	| mn10200 | mn10300 \
 	| moxie \
 	| mt \
 	| msp430 \
 	| nds32 | nds32le | nds32be \
-	| nios | nios2 \
+	| nios | nios2 | nios2eb | nios2el \
 	| ns16k | ns32k \
 	| open8 \
-	| or32 \
+	| or1k | or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
@@ -370,13 +366,13 @@ case $basic_machine in
 	| aarch64-* | aarch64_be-* \
 	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
-	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
 	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* \
-	| clipper-* | craynv-* | cydra-* \
+	| c8051-* | clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
 	| elxsi-* \
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
@@ -389,7 +385,8 @@ case $basic_machine in
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+	| microblaze-* | microblazeel-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
@@ -407,12 +404,13 @@ case $basic_machine in
 	| mipsisa64r2-* | mipsisa64r2el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipsr5900-* | mipsr5900el-* \
 	| mipstx39-* | mipstx39el-* \
 	| mmix-* \
 	| mt-* \
 	| msp430-* \
 	| nds32-* | nds32le-* | nds32be-* \
-	| nios-* | nios2-* \
+	| nios-* | nios2-* | nios2eb-* | nios2el-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| open8-* \
 	| orion-* \
@@ -788,11 +786,15 @@ case $basic_machine in
 		basic_machine=ns32k-utek
 		os=-sysv
 		;;
-	microblaze)
+	microblaze*)
 		basic_machine=microblaze-xilinx
 		;;
+	mingw64)
+		basic_machine=x86_64-pc
+		os=-mingw64
+		;;
 	mingw32)
-		basic_machine=i386-pc
+		basic_machine=i686-pc
 		os=-mingw32
 		;;
 	mingw32ce)
@@ -828,7 +830,7 @@ case $basic_machine in
 		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
 		;;
 	msys)
-		basic_machine=i386-pc
+		basic_machine=i686-pc
 		os=-msys
 		;;
 	mvs)
@@ -1019,7 +1021,11 @@ case $basic_machine in
 		basic_machine=i586-unknown
 		os=-pw32
 		;;
-	rdos)
+	rdos | rdos64)
+		basic_machine=x86_64-pc
+		os=-rdos
+		;;
+	rdos32)
 		basic_machine=i386-pc
 		os=-rdos
 		;;
@@ -1346,21 +1352,21 @@ case $os in
 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
-	      | -sym* | -kopensolaris* \
+	      | -sym* | -kopensolaris* | -plan9* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 	      | -aos* | -aros* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-	      | -openbsd* | -solidbsd* \
+	      | -bitrig* | -openbsd* | -solidbsd* \
 	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
 	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* | -cegcc* \
 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -linux-android* \
-	      | -linux-newlib* | -linux-uclibc* \
+	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
@@ -1492,9 +1498,6 @@ case $os in
 	-aros*)
 		os=-aros
 		;;
-	-kaos*)
-		os=-kaos
-		;;
 	-zvmoe)
 		os=-zvmoe
 		;;
@@ -1543,6 +1546,9 @@ case $basic_machine in
 	c4x-* | tic4x-*)
 		os=-coff
 		;;
+	c8051-*)
+		os=-elf
+		;;
 	hexagon-*)
 		os=-elf
 		;;
@@ -1586,6 +1592,9 @@ case $basic_machine in
 	mips*-*)
 		os=-elf
 		;;
+	or1k-*)
+		os=-elf
+		;;
 	or32-*)
 		os=-coff
 		;;
diff --git a/configure b/configure
index 9884298..133beec 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 pktools 2.5.3.
+# Generated by GNU Autoconf 2.69 for pktools 2.5.4.
 #
 # Report bugs to <kempenep at gmail.com>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='pktools'
 PACKAGE_TARNAME='pktools'
-PACKAGE_VERSION='2.5.3'
-PACKAGE_STRING='pktools 2.5.3'
+PACKAGE_VERSION='2.5.4'
+PACKAGE_STRING='pktools 2.5.4'
 PACKAGE_BUGREPORT='kempenep at gmail.com'
 PACKAGE_URL=''
 
@@ -720,6 +720,10 @@ GDAL_LDFLAGS
 GDAL_CFLAGS
 GDAL_VERSION
 GDAL_CONFIG
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+AM_DEFAULT_V
+AM_V
 am__untar
 am__tar
 AMTAR
@@ -784,6 +788,7 @@ SHELL'
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
+enable_silent_rules
 with_gdal
 enable_dependency_tracking
 enable_shared
@@ -1361,7 +1366,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 pktools 2.5.3 to adapt to many kinds of systems.
+\`configure' configures pktools 2.5.4 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1431,7 +1436,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of pktools 2.5.3:";;
+     short | recursive ) echo "Configuration of pktools 2.5.4:";;
    esac
   cat <<\_ACEOF
 
@@ -1439,8 +1444,12 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --disable-dependency-tracking  speeds up one-time build
-  --enable-dependency-tracking   do not reject slow dependency extractors
+  --enable-silent-rules   less verbose build output (undo: "make V=1")
+  --disable-silent-rules  verbose build output (undo: "make V=0")
+  --enable-dependency-tracking
+                          do not reject slow dependency extractors
+  --disable-dependency-tracking
+                          speeds up one-time build
   --enable-shared[=PKGS]  build shared libraries [default=yes]
   --enable-static[=PKGS]  build static libraries [default=yes]
   --enable-fast-install[=PKGS]
@@ -1553,7 +1562,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-pktools configure 2.5.3
+pktools configure 2.5.4
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2314,7 +2323,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 pktools $as_me 2.5.3, which was
+It was created by pktools $as_me 2.5.4, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2663,7 +2672,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 #AM_INIT_AUTOMAKE([-Wall -Werror foreign])
-am__api_version='1.11'
+am__api_version='1.14'
 
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
@@ -2789,9 +2798,6 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
 $as_echo_n "checking whether build environment is sane... " >&6; }
-# Just in case
-sleep 1
-echo timestamp > conftest.file
 # Reject unsafe characters in $srcdir or the absolute working directory
 # name.  Accept space and tab only in the latter.
 am_lf='
@@ -2802,32 +2808,40 @@ case `pwd` in
 esac
 case $srcdir in
   *[\\\"\#\$\&\'\`$am_lf\ \	]*)
-    as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
+    as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
 esac
 
-# Do `set' in a subshell so we don't clobber the current shell's
+# Do 'set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
-   if test "$*" = "X"; then
-      # -L didn't work.
-      set X `ls -t "$srcdir/configure" conftest.file`
-   fi
-   rm -f conftest.file
-   if test "$*" != "X $srcdir/configure conftest.file" \
-      && test "$*" != "X conftest.file $srcdir/configure"; then
-
-      # If neither matched, then we have a broken ls.  This can happen
-      # if, for instance, CONFIG_SHELL is bash and it inherits a
-      # broken ls alias from the environment.  This has actually
-      # happened.  Such a system could not be considered "sane".
-      as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
-alias in your environment" "$LINENO" 5
-   fi
-
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$*" = "X"; then
+	# -L didn't work.
+	set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$*" != "X $srcdir/configure conftest.file" \
+	&& test "$*" != "X conftest.file $srcdir/configure"; then
+
+	# If neither matched, then we have a broken ls.  This can happen
+	# if, for instance, CONFIG_SHELL is bash and it inherits a
+	# broken ls alias from the environment.  This has actually
+	# happened.  Such a system could not be considered "sane".
+	as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment" "$LINENO" 5
+     fi
+     if test "$2" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
    test "$2" = conftest.file
    )
 then
@@ -2839,6 +2853,16 @@ Check your system clock" "$LINENO" 5
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+
+rm -f conftest.file
+
 test "$program_prefix" != NONE &&
   program_transform_name="s&^&$program_prefix&;$program_transform_name"
 # Use a double $ so make ignores it.
@@ -2861,12 +2885,12 @@ if test x"${MISSING+set}" != xset; then
   esac
 fi
 # Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
-  am_missing_run="$MISSING --run "
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
 else
   am_missing_run=
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
-$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
 fi
 
 if test x"${install_sh}" != xset; then
@@ -2878,10 +2902,10 @@ if test x"${install_sh}" != xset; then
   esac
 fi
 
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'.  However `strip' might not be the right
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
 # tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
+# will honor the 'STRIP' environment variable to overrule this program.
 if test "$cross_compiling" != no; then
   if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
@@ -3020,12 +3044,6 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
 $as_echo "$MKDIR_P" >&6; }
 
-mkdir_p="$MKDIR_P"
-case $mkdir_p in
-  [\\/$]* | ?:[\\/]*) ;;
-  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
-esac
-
 for ac_prog in gawk mawk nawk awk
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -3108,6 +3126,45 @@ else
 fi
 rmdir .tst 2>/dev/null
 
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+  enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in # (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=1;;
+esac
+am_make=${MAKE-make}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
+if ${am_cv_make_support_nested_variables+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if $as_echo 'TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+$as_echo "$am_cv_make_support_nested_variables" >&6; }
+if test $am_cv_make_support_nested_variables = yes; then
+    AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AM_BACKSLASH='\'
+
 if test "`cd $srcdir && pwd`" != "`pwd`"; then
   # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
   # is not polluted with repeated "-I."
@@ -3130,7 +3187,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='pktools'
- VERSION='2.5.3'
+ VERSION='2.5.4'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3158,12 +3215,22 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
 
 MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+mkdir_p='$(MKDIR_P)'
+
 # We need awk for the "check" target.  The system "awk" is bad on
 # some platforms.
 # Always define AMTAR for backward compatibility.  Yes, it's still used
 # in the wild :-(  We should find a proper way to deprecate it ...
 AMTAR='$${TAR-tar}'
 
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar  pax cpio none'
+
 am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
@@ -3171,6 +3238,49 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
 
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes.  So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+  cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present.  This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake at gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message.  This
+can help us improve future automake versions.
+
+END
+  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+    echo 'Configuration will proceed anyway, since you have set the' >&2
+    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+    echo >&2
+  else
+    cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+    as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
+  fi
+fi
+#AM_INIT_AUTOMAKE([subdir-objects]) #not working due to bug in autoconf, see Debian list: Bug #752993)
+
 
 
 
@@ -3893,7 +4003,7 @@ am__quote=
 _am_result=none
 # First try GNU make style include.
 echo "include confinc" > confmf
-# Ignore all kinds of additional output from `make'.
+# Ignore all kinds of additional output from 'make'.
 case `$am_make -s -f confmf 2> /dev/null` in #(
 *the\ am__doit\ target*)
   am__include=include
@@ -3949,8 +4059,8 @@ else
   # We make a subdir and do the tests there.  Otherwise we can end up
   # making bogus files that we don't know about and never remove.  For
   # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
   rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
@@ -3985,16 +4095,16 @@ else
     : > sub/conftest.c
     for i in 1 2 3 4 5 6; do
       echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
     # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
     am__obj=sub/conftest.${OBJEXT-o}
     am__minus_obj="-o $am__obj"
     case $depmode in
@@ -4003,8 +4113,8 @@ else
       test "$am__universal" = false || continue
       ;;
     nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
       if test "x$enable_dependency_tracking" = xyes; then
 	continue
       else
@@ -4012,7 +4122,7 @@ else
       fi
       ;;
     msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
+      # This compiler won't grok '-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
       am__obj=conftest.${OBJEXT-o}
@@ -4981,6 +5091,65 @@ 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
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
+$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
+if ${am_cv_prog_cc_c_o+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+  # Make sure it works both with $CC and with simple cc.
+  # Following AC_PROG_CC_C_O, we do the test twice because some
+  # compilers refuse to overwrite an existing .o file with -o,
+  # though they will create one.
+  am_cv_prog_cc_c_o=yes
+  for am_i in 1 2; do
+    if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
+   ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); } \
+         && test -f conftest2.$ac_objext; then
+      : OK
+    else
+      am_cv_prog_cc_c_o=no
+      break
+    fi
+  done
+  rm -f core conftest*
+  unset am_i
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
+$as_echo "$am_cv_prog_cc_c_o" >&6; }
+if test "$am_cv_prog_cc_c_o" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
 depcc="$CC"   am_compiler_list=
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
@@ -4992,8 +5161,8 @@ else
   # We make a subdir and do the tests there.  Otherwise we can end up
   # making bogus files that we don't know about and never remove.  For
   # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
   rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
@@ -5028,16 +5197,16 @@ else
     : > sub/conftest.c
     for i in 1 2 3 4 5 6; do
       echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
     # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
     am__obj=sub/conftest.${OBJEXT-o}
     am__minus_obj="-o $am__obj"
     case $depmode in
@@ -5046,8 +5215,8 @@ else
       test "$am__universal" = false || continue
       ;;
     nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
       if test "x$enable_dependency_tracking" = xyes; then
 	continue
       else
@@ -5055,7 +5224,7 @@ else
       fi
       ;;
     msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
+      # This compiler won't grok '-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
       am__obj=conftest.${OBJEXT-o}
@@ -19419,7 +19588,7 @@ fi
 # For information on how to properly maintain the library version information,
 # refer to the libtool manual, section "Updating library version information":
 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-PKTOOLS_SO_VERSION=1:0:0
+PKTOOLS_SO_VERSION=1:2:0
 
 
 # files to generate via autotools (.am or .in source files)
@@ -19544,6 +19713,14 @@ LIBOBJS=$ac_libobjs
 LTLIBOBJS=$ac_ltlibobjs
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
+$as_echo_n "checking that generated files are newer than configure... " >&6; }
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
+$as_echo "done" >&6; }
  if test -n "$EXEEXT"; then
   am__EXEEXT_TRUE=
   am__EXEEXT_FALSE='#'
@@ -19989,7 +20166,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 pktools $as_me 2.5.3, which was
+This file was extended by pktools $as_me 2.5.4, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -20055,7 +20232,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="\\
-pktools config.status 2.5.3
+pktools config.status 2.5.4
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -21252,7 +21429,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
 
   case $ac_file$ac_mode in
     "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
-  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # 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
@@ -21265,7 +21442,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
     # Strip MF so we end up with the name of the file.
     mf=`echo "$mf" | sed -e 's/:.*$//'`
     # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named `Makefile.in', but
+    # We used to match only the files named 'Makefile.in', but
     # some people rename them; so instead we look at the file content.
     # Grep'ing the first line is not enough: some people post-process
     # each Makefile.in and add a new line on top of each file to say so.
@@ -21299,21 +21476,19 @@ $as_echo X"$mf" |
       continue
     fi
     # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running `make'.
+    # from the Makefile without running 'make'.
     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     test -z "$DEPDIR" && continue
     am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "am__include" && continue
+    test -z "$am__include" && continue
     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # When using ansi2knr, U may be empty or an underscore; expand it
-    U=`sed -n 's/^U = //p' < "$mf"`
     # Find all dependency output files, they are included files with
     # $(DEPDIR) in their names.  We invoke sed twice because it is the
     # simplest approach to changing $(DEPDIR) to its actual value in the
     # expansion.
     for file in `sed -n "
       s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
       # Make sure the directory exists.
       test -f "$dirpart/$file" && continue
       fdir=`$as_dirname -- "$file" ||
diff --git a/configure.ac b/configure.ac
index 99895c2..e769ba1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,7 @@
-AC_INIT([pktools], [2.5.3], [kempenep at gmail.com])
+AC_INIT([pktools], [2.5.4], [kempenep at gmail.com])
 #AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AM_INIT_AUTOMAKE([-Wall -Wno-extra-portability foreign])
+#AM_INIT_AUTOMAKE([subdir-objects]) #not working due to bug in autoconf, see Debian list: Bug #752993)
 AC_CONFIG_MACRO_DIR([m4])
 
 AX_LIB_GDAL()
@@ -96,7 +97,7 @@ AC_SUBST([LIBS])
 # For information on how to properly maintain the library version information,
 # refer to the libtool manual, section "Updating library version information":
 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-AC_SUBST([PKTOOLS_SO_VERSION], [1:0:0])
+AC_SUBST([PKTOOLS_SO_VERSION], [1:2:0])
 
 # files to generate via autotools (.am or .in source files)
 AC_CONFIG_HEADERS([config.h])
diff --git a/src/algorithms/CostFactory.h b/src/algorithms/CostFactory.h
index 82d3a12..441279e 100644
--- a/src/algorithms/CostFactory.h
+++ b/src/algorithms/CostFactory.h
@@ -38,8 +38,10 @@ public:
   std::map<std::string,short> getClassValueMap(){return m_classValueMap;};
   std::vector<std::string> getNameVector(){return m_nameVector;};
   void setNameVector(std::vector<std::string>& nameVector){m_nameVector=nameVector;};
-  unsigned short getClassIndex(std::string classname) const {return m_cm.getClassIndex(classname);};
+  int getClassIndex(std::string classname) const {return m_cm.getClassIndex(classname);};
+  //pushBackClassName is for confusion matrix
   void pushBackClassName(std::string classname){m_cm.pushBackClassName(classname,true);};//doSort=true
+  //pushBackName is for nameVector in CostFactory
   void pushBackName(std::string classname){m_nameVector.push_back(classname);};
   void setNcTraining(const std::vector<unsigned int> nctraining){m_nctraining=nctraining;};
   void setNcTest(const std::vector<unsigned int> nctest){m_nctest=nctest;};
@@ -53,8 +55,8 @@ protected:
   std::vector<unsigned int> m_nctraining;
   std::vector<unsigned int> m_nctest;
   unsigned short m_cv;
-  std::string m_classname;
+  /* std::string m_classname; */
   short m_classvalue;
   short m_verbose;
 };
-#endif /* _FEATURESELECTOR_H_ */
+#endif
diff --git a/src/algorithms/CostFactorySVM.cc b/src/algorithms/CostFactorySVM.cc
new file mode 100644
index 0000000..7a23e7f
--- /dev/null
+++ b/src/algorithms/CostFactorySVM.cc
@@ -0,0 +1,178 @@
+/**********************************************************************
+CostFactorySVM.cc: select features, typical use: feature selection for classification
+Copyright (C) 2008-2014 Pieter Kempeneers
+
+This file is part of pktools
+
+pktools 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.
+
+pktools 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 pktools.  If not, see <http://www.gnu.org/licenses/>.
+***********************************************************************/
+#include "CostFactorySVM.h"
+#include "svm.h"
+
+#define Malloc(type,n) (type *)malloc((n)*sizeof(type))
+
+CostFactorySVM::CostFactorySVM()
+    : CostFactory(2,0), m_svm_type("C_SVC"), m_kernel_type("radial"), m_kernel_degree(3), m_gamma(1.0), m_coef0(0), m_ccost(1000), m_nu(0.5),  m_epsilon_loss(100), m_cache(100), m_epsilon_tol(0.001), m_shrinking(false), m_prob_est(true){
+}
+
+CostFactorySVM::~CostFactorySVM(){
+}
+
+CostFactorySVM::CostFactorySVM(std::string svm_type, std::string kernel_type, unsigned short kernel_degree, float gamma, float coef0, float ccost, float nu,  float epsilon_loss, int cache, float epsilon_tol, bool shrinking, bool prob_est, unsigned short cv, short verbose)
+    : CostFactory(cv,verbose), m_svm_type(svm_type), m_kernel_type(kernel_type), m_kernel_degree(kernel_degree), m_gamma(gamma), m_coef0(coef0), m_ccost(ccost), m_nu(nu),  m_epsilon_loss(epsilon_loss), m_cache(cache), m_epsilon_tol(epsilon_tol), m_shrinking(shrinking), m_prob_est(prob_est){};
+
+double CostFactorySVM::getCost(const std::vector<Vector2d<float> > &trainingFeatures){
+  std::map<std::string, svm::SVM_TYPE> svmMap;
+
+  svmMap["C_SVC"]=svm::C_SVC;
+  svmMap["nu_SVC"]=svm::nu_SVC;
+  svmMap["one_class"]=svm::one_class;
+  svmMap["epsilon_SVR"]=svm::epsilon_SVR;
+  svmMap["nu_SVR"]=svm::nu_SVR;
+
+  std::map<std::string, svm::KERNEL_TYPE> kernelMap;
+
+  kernelMap["linear"]=svm::linear;
+  kernelMap["polynomial"]=svm::polynomial;
+  kernelMap["radial"]=svm::radial;
+  kernelMap["sigmoid;"]=svm::sigmoid;
+
+  unsigned short nclass=trainingFeatures.size();
+  unsigned int ntraining=0;
+  unsigned int ntest=0;
+  for(int iclass=0;iclass<nclass;++iclass){
+    ntraining+=m_nctraining[iclass];
+    ntest+=m_nctest[iclass];
+  }
+  if(ntest)
+    assert(!m_cv);
+  if(!m_cv)
+    assert(ntest);
+  unsigned short nFeatures=trainingFeatures[0][0].size();
+
+  struct svm_parameter param;
+  param.svm_type = svmMap[m_svm_type];
+  param.kernel_type = kernelMap[m_kernel_type];
+  param.degree = m_kernel_degree;
+  param.gamma = (m_gamma>0)? m_gamma : 1.0/nFeatures;
+  param.coef0 = m_coef0;
+  param.nu = m_nu;
+  param.cache_size = m_cache;
+  param.C = m_ccost;
+  param.eps = m_epsilon_tol;
+  param.p = m_epsilon_loss;
+  param.shrinking = (m_shrinking)? 1 : 0;
+  param.probability = (m_prob_est)? 1 : 0;
+  param.nr_weight = 0;//not used: I use priors and balancing
+  param.weight_label = NULL;
+  param.weight = NULL;
+  param.verbose=(m_verbose>1)? true:false;
+  struct svm_model* svm;
+  struct svm_problem prob;
+  struct svm_node* x_space;
+
+  prob.l=ntraining;
+  prob.y = Malloc(double,prob.l);
+  prob.x = Malloc(struct svm_node *,prob.l);
+  x_space = Malloc(struct svm_node,(nFeatures+1)*ntraining);
+  unsigned long int spaceIndex=0;
+  int lIndex=0;
+  for(int iclass=0;iclass<nclass;++iclass){
+    // for(int isample=0;isample<trainingFeatures[iclass].size();++isample){
+    for(int isample=0;isample<m_nctraining[iclass];++isample){
+      prob.x[lIndex]=&(x_space[spaceIndex]);
+      for(int ifeature=0;ifeature<nFeatures;++ifeature){
+        x_space[spaceIndex].index=ifeature+1;
+        x_space[spaceIndex].value=trainingFeatures[iclass][isample][ifeature];
+        ++spaceIndex;
+      }
+      x_space[spaceIndex++].index=-1;
+      prob.y[lIndex]=iclass;
+      ++lIndex;
+    }
+  }
+
+  assert(lIndex==prob.l);
+  if(m_verbose>2)
+    std::cout << "checking parameters" << std::endl;
+  svm_check_parameter(&prob,&param);
+  if(m_verbose>2)
+    std::cout << "parameters ok, training" << std::endl;
+  svm=svm_train(&prob,&param);
+  if(m_verbose>2)
+    std::cout << "SVM is now trained" << std::endl;
+
+  m_cm.clearResults();
+  if(m_cv>1){
+    double *target = Malloc(double,prob.l);
+    svm_cross_validation(&prob,&param,m_cv,target);
+    assert(param.svm_type != EPSILON_SVR&&param.svm_type != NU_SVR);//only for regression
+    for(int i=0;i<prob.l;i++){
+      std::string refClassName=m_nameVector[prob.y[i]];
+      std::string className=m_nameVector[target[i]];
+      if(m_classValueMap.size())
+	m_cm.incrementResult(type2string<short>(m_classValueMap[refClassName]),type2string<short>(m_classValueMap[className]),1.0);
+      else
+	m_cm.incrementResult(m_cm.getClass(prob.y[i]),m_cm.getClass(target[i]),1.0);
+    }
+    free(target);
+  }
+  else{
+    struct svm_node *x_test;
+    std::vector<double> result(nclass);
+    x_test = Malloc(struct svm_node,(nFeatures+1));
+    for(int iclass=0;iclass<nclass;++iclass){
+      for(int isample=0;isample<m_nctest[iclass];++isample){
+	for(int ifeature=0;ifeature<nFeatures;++ifeature){
+	  x_test[ifeature].index=ifeature+1;
+	  x_test[ifeature].value=trainingFeatures[iclass][m_nctraining[iclass]+isample][ifeature];
+	}
+	x_test[nFeatures].index=-1;
+	double predict_label=0;
+	assert(svm_check_probability_model(svm));
+	predict_label = svm_predict_probability(svm,x_test,&(result[0]));
+	// predict_label = svm_predict(svm,x_test);
+	std::string refClassName=m_nameVector[iclass];
+	std::string className=m_nameVector[static_cast<short>(predict_label)];
+	if(m_classValueMap.size())
+	  m_cm.incrementResult(type2string<short>(m_classValueMap[refClassName]),type2string<short>(m_classValueMap[className]),1.0);
+	else
+	  m_cm.incrementResult(refClassName,className,1.0);
+      }
+    }
+    free(x_test);
+  }
+  if(m_verbose>1)
+    std::cout << m_cm << std::endl;
+  assert(m_cm.nReference());
+  // if(m_verbose)
+
+  // std::cout << m_cm << std::endl;
+  // std::cout << "Kappa: " << m_cm.kappa() << std::endl;
+  // double se95_oa=0;
+  // double doa=0;
+  // doa=m_cm.oa_pct(&se95_oa);
+  // std::cout << "Overall Accuracy: " << doa << " (" << se95_oa << ")"  << std::endl;
+
+  // *NOTE* Because svm_model contains pointers to svm_problem, you can
+  // not free the memory used by svm_problem if you are still using the
+  // svm_model produced by svm_train(). 
+  // however, we will re-train the svm later on after the feature selection
+  free(prob.y);
+  free(prob.x);
+  free(x_space);
+  svm_free_and_destroy_model(&(svm));
+
+  return(m_cm.kappa());
+}
diff --git a/src/apps/pkfssvm.h b/src/algorithms/CostFactorySVM.h
similarity index 83%
rename from src/apps/pkfssvm.h
rename to src/algorithms/CostFactorySVM.h
index c4d3f72..2d73ccf 100644
--- a/src/apps/pkfssvm.h
+++ b/src/algorithms/CostFactorySVM.h
@@ -1,6 +1,6 @@
 /**********************************************************************
-pkfssvm.h: feature selection for svm classifier
-Copyright (C) 2008-2014 Pieter Kempeneers
+CostFactorySVM.h: select features, typical use: feature selection for classification
+Copyright (C) 2008-2012 Pieter Kempeneers
 
 This file is part of pktools
 
@@ -17,24 +17,25 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 ***********************************************************************/
-#include <string>
+#ifndef _COSTFACTORYSVM_H_
+#define _COSTFACTORYSVM_H_
+
+#include <math.h>
 #include <vector>
+#include <map>
 #include "base/Vector2d.h"
+#include "CostFactory.h"
 
-#ifndef _PKFSSVMH_H_
-#define _PKFSSVMH_H_
 namespace svm{
   enum SVM_TYPE {C_SVC=0, nu_SVC=1,one_class=2, epsilon_SVR=3, nu_SVR=4};
   enum KERNEL_TYPE {linear=0,polynomial=1,radial=2,sigmoid=3};
 }
 
-enum SelectorValue  { NA=0, SFFS=1, SFS=2, SBS=3, BFS=4};
-
 class CostFactorySVM : public CostFactory
 {
 public:
 CostFactorySVM();
-CostFactorySVM(std::string svm_type, std::string kernel_type, unsigned short kernel_degree, float gamma, float coef0, float ccost, float nu,  float epsilon_loss, int cache, float epsilon_tol, bool shrinking, bool prob_est, unsigned short cv, bool verbose);
+CostFactorySVM(std::string svm_type, std::string kernel_type, unsigned short kernel_degree, float gamma, float coef0, float ccost, float nu,  float epsilon_loss, int cache, float epsilon_tol, bool shrinking, bool prob_est, unsigned short cv, short verbose);
 ~CostFactorySVM();
 double getCost(const std::vector<Vector2d<float> > &trainingFeatures);
   
@@ -52,6 +53,4 @@ float m_epsilon_tol;
 bool m_shrinking;
 bool m_prob_est;
 };
-
-
 #endif
diff --git a/src/algorithms/Filter.cc b/src/algorithms/Filter.cc
index eb2ddb4..4241d41 100644
--- a/src/algorithms/Filter.cc
+++ b/src/algorithms/Filter.cc
@@ -25,11 +25,13 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 using namespace std;
 
 filter::Filter::Filter(void)
+  : m_padding("symmetric")
 {
 }
 
 
 filter::Filter::Filter(const vector<double> &taps)
+  : m_padding("symmetric")
 {
   setTaps(taps);
 }
@@ -178,6 +180,7 @@ void filter::Filter::dwtCutFrom(const ImgReaderGdal& input, ImgWriterGdal& outpu
   }
 }
 
+//todo: support different padding strategies
 void filter::Filter::dwtForward(std::vector<double>& data, const std::string& wavelet_type, int family){
   int origsize=data.size();
   //make sure data size if power of 2
@@ -196,6 +199,7 @@ void filter::Filter::dwtForward(std::vector<double>& data, const std::string& wa
   gsl_wavelet_workspace_free (work);
 }
 
+//todo: support different padding strategies
 void filter::Filter::dwtInverse(std::vector<double>& data, const std::string& wavelet_type, int family){
   int origsize=data.size();
   //make sure data size if power of 2
@@ -213,6 +217,7 @@ void filter::Filter::dwtInverse(std::vector<double>& data, const std::string& wa
   gsl_wavelet_workspace_free (work);
 }
 
+//todo: support different padding strategies
 void filter::Filter::dwtCut(std::vector<double>& data, const std::string& wavelet_type, int family, double cut){
   int origsize=data.size();
   //make sure data size if power of 2
@@ -241,9 +246,9 @@ void filter::Filter::dwtCut(std::vector<double>& data, const std::string& wavele
   gsl_wavelet_workspace_free (work);
 }
 
-void filter::Filter::morphology(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dim, short down, int offset, short verbose)
+void filter::Filter::morphology(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dim, short verbose)
 {
-  bool bverbose=(verbose>1)? true:false;
+  // bool bverbose=(verbose>1)? true:false;
   Vector2d<double> lineInput(input.nrOfBand(),input.nrOfCol());
   Vector2d<double> lineOutput(input.nrOfBand(),input.nrOfCol());
   const char* pszMessage;
@@ -258,7 +263,8 @@ void filter::Filter::morphology(const ImgReaderGdal& input, ImgWriterGdal& outpu
     vector<double> pixelOutput(input.nrOfBand());
     for(int x=0;x<input.nrOfCol();++x){
       pixelInput=lineInput.selectCol(x);
-      morphology(pixelInput,pixelOutput,method,dim,down,offset,bverbose);
+      filter(pixelInput,pixelOutput,method,dim);
+      // morphology(pixelInput,pixelOutput,method,dim,bverbose);
       for(int iband=0;iband<input.nrOfBand();++iband)
         lineOutput[iband][x]=pixelOutput[iband];
     }
@@ -275,13 +281,13 @@ void filter::Filter::morphology(const ImgReaderGdal& input, ImgWriterGdal& outpu
   }
 }
 
-void filter::Filter::smooth(const ImgReaderGdal& input, ImgWriterGdal& output, short dim, short down, int offset)
+void filter::Filter::smooth(const ImgReaderGdal& input, ImgWriterGdal& output, short dim)
 {
   assert(dim>0);
   m_taps.resize(dim);
   for(int itap=0;itap<dim;++itap)
     m_taps[itap]=1.0/dim;
-  filter(input,output,down,offset);
+  filter(input,output);
 }
 
 // void filter::Filter::smoothnodata(const ImgReaderGdal& input, ImgWriterGdal& output, short dim, short down, int offset)
@@ -293,7 +299,7 @@ void filter::Filter::smooth(const ImgReaderGdal& input, ImgWriterGdal& output, s
 //   filter(input,output,down,offset);
 // }
 
-void filter::Filter::filter(const ImgReaderGdal& input, ImgWriterGdal& output, short down, int offset)
+void filter::Filter::filter(const ImgReaderGdal& input, ImgWriterGdal& output)
 {
   Vector2d<double> lineInput(input.nrOfBand(),input.nrOfCol());
   Vector2d<double> lineOutput(input.nrOfBand(),input.nrOfCol());
@@ -309,7 +315,7 @@ void filter::Filter::filter(const ImgReaderGdal& input, ImgWriterGdal& output, s
     vector<double> pixelOutput(input.nrOfBand());
     for(int x=0;x<input.nrOfCol();++x){
       pixelInput=lineInput.selectCol(x);
-      filter(pixelInput,pixelOutput,down,offset);
+      filter(pixelInput,pixelOutput);
       for(int iband=0;iband<input.nrOfBand();++iband)
         lineOutput[iband][x]=pixelOutput[iband];
     }
@@ -326,6 +332,98 @@ void filter::Filter::filter(const ImgReaderGdal& input, ImgWriterGdal& output, s
   }
 }
 
+void filter::Filter::stat(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method)
+{
+  Vector2d<double> lineInput(input.nrOfBand(),input.nrOfCol());
+  assert(output.nrOfCol()==input.nrOfCol());
+  vector<double> lineOutput(output.nrOfCol());
+  statfactory::StatFactory stat;
+  const char* pszMessage;
+  void* pProgressArg=NULL;
+  GDALProgressFunc pfnProgress=GDALTermProgress;
+  double progress=0;
+  pfnProgress(progress,pszMessage,pProgressArg);
+  for(int y=0;y<input.nrOfRow();++y){
+    for(int iband=0;iband<input.nrOfBand();++iband)
+      input.readData(lineInput[iband],GDT_Float64,y,iband);
+    vector<double> pixelInput(input.nrOfBand());
+    for(int x=0;x<input.nrOfCol();++x){
+      pixelInput=lineInput.selectCol(x);
+      switch(getFilterType(method)){
+      case(filter::median):
+	lineOutput[x]=stat.median(pixelInput);
+	break;
+      case(filter::min):
+	lineOutput[x]=stat.mymin(pixelInput);
+	break;
+      case(filter::max):
+	lineOutput[x]=stat.mymax(pixelInput);
+	break;
+      case(filter::sum):
+	lineOutput[x]=stat.sum(pixelInput);
+	break;
+      case(filter::var):
+	lineOutput[x]=stat.var(pixelInput);
+	break;
+      case(filter::stdev):
+	lineOutput[x]=sqrt(stat.var(pixelInput));
+	break;
+      case(filter::mean):
+	lineOutput[x]=stat.mean(pixelInput);
+	break;
+      default:
+	std::string errorString="method not supported";
+	throw(errorString);
+	break;
+      }
+    }
+    try{
+      output.writeData(lineOutput,GDT_Float64,y);
+    }
+    catch(string errorstring){
+      cerr << errorstring << "in line " << y << endl;
+    }
+    progress=(1.0+y)/output.nrOfRow();
+    pfnProgress(progress,pszMessage,pProgressArg);
+  }
+}
+
+void filter::Filter::filter(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dim)
+{
+  Vector2d<double> lineInput(input.nrOfBand(),input.nrOfCol());
+  Vector2d<double> lineOutput(input.nrOfBand(),input.nrOfCol());;
+  const char* pszMessage;
+  void* pProgressArg=NULL;
+  GDALProgressFunc pfnProgress=GDALTermProgress;
+  double progress=0;
+  pfnProgress(progress,pszMessage,pProgressArg);
+  for(int y=0;y<input.nrOfRow();++y){
+    for(int iband=0;iband<input.nrOfBand();++iband)
+      input.readData(lineInput[iband],GDT_Float64,y,iband);
+    vector<double> pixelInput(input.nrOfBand());
+    vector<double> pixelOutput;
+    for(int x=0;x<input.nrOfCol();++x){
+      pixelInput=lineInput.selectCol(x);
+      filter(pixelInput,pixelOutput,method,dim);
+      for(int iband=0;iband<pixelOutput.size();++iband){
+        lineOutput[iband][x]=pixelOutput[iband];
+	// if(pixelInput[iband]!=0)
+	//   assert(pixelOutput[iband]!=0);
+      }
+    }
+    for(int iband=0;iband<input.nrOfBand();++iband){
+      try{
+        output.writeData(lineOutput[iband],GDT_Float64,y,iband);
+      }
+      catch(string errorstring){
+        cerr << errorstring << "in band " << iband << ", line " << y << endl;
+      }
+    }
+    progress=(1.0+y)/output.nrOfRow();
+    pfnProgress(progress,pszMessage,pProgressArg);
+  }
+}
+
 double filter::Filter::getCentreWavelength(const std::vector<double> &wavelengthIn, const Vector2d<double>& srf, const std::string& interpolationType, double delta, bool verbose)
 {  
   assert(srf.size()==2);//[0]: wavelength, [1]: response function
diff --git a/src/algorithms/Filter.h b/src/algorithms/Filter.h
index dc4cc12..705bfc6 100644
--- a/src/algorithms/Filter.h
+++ b/src/algorithms/Filter.h
@@ -33,7 +33,9 @@ extern "C" {
 namespace filter
 {
   
-  enum FILTER_TYPE { median=0, var=1 , min=2, max=3, sum=4, mean=5, minmax=6, dilate=7, erode=8, close=9, open=10, homog=11, sobelx=12, sobely=13, sobelxy=14, sobelyx=-14, smooth=15, density=16, majority=17, mixed=18, smoothnodata=19, threshold=20, ismin=21, ismax=22, heterog=23, order=24, stdev=25, dwt=26, dwti=27, dwt_cut=28, dwt_cut_from=29};
+  enum FILTER_TYPE { median=0, var=1 , min=2, max=3, sum=4, mean=5, minmax=6, dilate=7, erode=8, close=9, open=10, homog=11, sobelx=12, sobely=13, sobelxy=14, sobelyx=-14, smooth=15, density=16, mode=17, mixed=18, smoothnodata=19, threshold=20, ismin=21, ismax=22, heterog=23, order=24, stdev=25, dwt=26, dwti=27, dwt_cut=28, dwt_cut_from=29};
+
+   enum PADDING { symmetric=0, replicate=1, circular=2, constant=3};
 
 class Filter
 {
@@ -41,6 +43,11 @@ public:
   Filter(void);
   Filter(const std::vector<double> &taps);
   virtual ~Filter(){};
+
+  void setPadding(const std::string& padString){
+    m_padding=padString;
+  };
+
   static const gsl_wavelet_type* getWaveletType(const std::string waveletType){
     if(waveletType=="daubechies") return(gsl_wavelet_daubechies);
     if(waveletType=="daubechies_centered") return(gsl_wavelet_daubechies_centered);
@@ -54,17 +61,21 @@ public:
     initFilterMap(m_filterMap);
     return m_filterMap[filterType];
   };
+
   void setTaps(const std::vector<double> &taps, bool normalize=true);
   void pushClass(short theClass=1){m_class.push_back(theClass);};
   void pushMask(short theMask=0){m_mask.push_back(theMask);};
-  template<class T> void filter(const std::vector<T>& input, std::vector<T>& output, int down=1, int offset=0);
-  template<class T> void smooth(const std::vector<T>& input, std::vector<T>& output, short dim, int down=1, int offset=0);
-  template<class T> void filter(T* input, int inputSize, std::vector<T>& output, int down=1, int offset=0);
-  template<class T> void smooth(T* input, int inputSize, std::vector<T>& output, short dim, int down=1, int offset=0);
-  template<class T> void morphology(const std::vector<T>& input, std::vector<T>& output, const std::string& method, int dim, short down=1, int offset=0, bool verbose=false);
-  void morphology(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dim, short down=1, int offset=0, short verbose=0);
-  void filter(const ImgReaderGdal& input, ImgWriterGdal& output, short down=1, int offset=0);
-  void smooth(const ImgReaderGdal& input, ImgWriterGdal& output, short dim, short down=1, int offset=0);
+  template<class T> void filter(const std::vector<T>& input, std::vector<T>& output);
+  template<class T> void filter(const std::vector<T>& input, std::vector<T>& output, const std::string& method, int dim);
+  template<class T> void smooth(const std::vector<T>& input, std::vector<T>& output, short dim);
+  template<class T> void filter(T* input, int inputSize, std::vector<T>& output);
+  template<class T> void smooth(T* input, int inputSize, std::vector<T>& output, short dim);
+  //template<class T> void morphology(const std::vector<T>& input, std::vector<T>& output, const std::string& method, int dim, bool verbose=false);
+  void morphology(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dim, short verbose=0);
+  void filter(const ImgReaderGdal& input, ImgWriterGdal& output);
+  void stat(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method);
+  void filter(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dim);
+  void smooth(const ImgReaderGdal& input, ImgWriterGdal& output, short dim);
   double getCentreWavelength(const std::vector<double> &wavelengthIn, const Vector2d<double>& srf, const std::string& interpolationType, double delta=1.0, bool verbose=false);
   template<class T> double applySrf(const std::vector<double> &wavelengthIn, const std::vector<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, T& output, double delta=1.0, bool normalize=false, bool verbose=false);
   template<class T> double applySrf(const std::vector<double> &wavelengthIn, const Vector2d<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, std::vector<T>& output, double delta=1.0, bool normalize=false, int down=1, bool transposeInput=false, bool verbose=false);
@@ -105,7 +116,7 @@ private:
     m_filterMap["sobelyx"]=filter::sobelyx;
     m_filterMap["smooth"]=filter::smooth;
     m_filterMap["density"]=filter::density;
-    m_filterMap["majority"]=filter::majority;
+    m_filterMap["mode"]=filter::mode;
     m_filterMap["mixed"]=filter::mixed;
     m_filterMap["smoothnodata"]=filter::smoothnodata;
     m_filterMap["threshold"]=filter::threshold;
@@ -115,11 +126,24 @@ private:
     m_filterMap["order"]=filter::order;
     m_filterMap["median"]=filter::median;
   }
+
+
+  static PADDING getPadding(const std::string& padString){
+    std::map<std::string, PADDING> padMap;
+    padMap["constant"]=filter::constant;
+    padMap["symmetric"]=filter::symmetric;
+    padMap["replicate"]=filter::replicate;
+    padMap["circular"]=filter::circular;
+    return(padMap[padString]);
+  };
+
   std::vector<double> m_taps;
   std::vector<short> m_class;
   std::vector<short> m_mask;
+   std::string m_padding;
 };
 
+
 //input[band], output
 //returns wavelength for which srf is maximum
   template<class T> double Filter::applySrf(const std::vector<double> &wavelengthIn, const std::vector<T>& input, const Vector2d<double>& srf, const std::string& interpolationType, T& output, double delta, bool normalize, bool verbose)
@@ -192,15 +216,6 @@ private:
   gsl_spline_free(splineOut);
   gsl_interp_accel_free(accOut);
 
-  // double maxResponse=0;
-  // int maxIndex=0;
-  // for(int index=0;index<srf[1].size();++index){
-    // if(maxResponse<srf[1][index]){
-    //   maxResponse=srf[1][index];
-    //   maxIndex=index;
-    // }
-  // }
-  // return(srf[0][maxIndex]);
   return(centreWavelength);
 }
 
@@ -288,15 +303,6 @@ private:
   gsl_spline_free(splineOut);
   gsl_interp_accel_free(accOut);
 
-  // double maxResponse=0;
-  // int maxIndex=0;
-  // for(int index=0;index<srf[1].size();++index){
-    // if(maxResponse<srf[1][index]){
-    //   maxResponse=srf[1][index];
-    //   maxIndex=index;
-    // }
-  // }
-  // return(srf[0][maxIndex]);
   return(centreWavelength);
 }
 
@@ -402,61 +408,99 @@ template<class T> void Filter::applyFwhm(const std::vector<double> &wavelengthIn
   }
 }
 
-  template<class T> void Filter::smooth(const std::vector<T>& input, std::vector<T>& output, short dim, int down, int offset)
+  template<class T> void Filter::smooth(const std::vector<T>& input, std::vector<T>& output, short dim)
 {
   assert(dim>0);
   m_taps.resize(dim);
   for(int itap=0;itap<dim;++itap)
     m_taps[itap]=1.0/dim;
-  filter(input,output,down,offset);
+  filter(input,output);
  }
 
-template<class T> void Filter::filter(const std::vector<T>& input, std::vector<T>& output, int down, int offset)
+template<class T> void Filter::filter(const std::vector<T>& input, std::vector<T>& output)
 {
-  output.resize((input.size()-offset+down-1)/down);
+  assert(input.size()>m_taps.size());
+  output.resize(input.size());
   int i=0;
-  //start: extend input with mirrored version of itself
-  for(i=offset;i<m_taps.size()/2;++i){
-    if((i-offset)%down)
-      continue;
+  //start: extend input by padding
+  for(i=0;i<m_taps.size()/2;++i){
     //todo:introduce nodata
-    output[(i-offset+down-1)/down]=m_taps[m_taps.size()/2]*input[i];
-    for(int t=1;t<=m_taps.size()/2;++t)
-      output[(i-offset+down-1)/down]+=(m_taps[m_taps.size()/2+t]+m_taps[m_taps.size()/2-t])*input[i+t];
+    output[i]=m_taps[m_taps.size()/2]*input[i];
+    for(int t=1;t<=m_taps.size()/2;++t){
+      output[i]+=m_taps[m_taps.size()/2+t]*input[i+t];
+      if(i>=t)
+	output[i]+=m_taps[m_taps.size()/2-t]*input[i-t];
+      else{
+	switch(getPadding(m_padding)){
+	case(replicate):
+	  output[i]+=m_taps[m_taps.size()/2-t]*input[0];
+	  break;
+	case(circular):
+	  output[i]+=m_taps[m_taps.size()/2-t]*input[input.size()+i-t];
+	  break;
+	case(constant):
+	  output[i]+=m_taps[m_taps.size()/2-t]*0;
+	  break;
+	case(symmetric):
+	default:
+	  output[i]+=m_taps[m_taps.size()/2-t]*input[t-i];
+	  break;
+	}
+      }
+    }
   }
   //main
-  for(i=offset+m_taps.size()/2;i<input.size()-m_taps.size()/2;++i){
-    if((i-offset)%down)
-      continue;
+  for(i=m_taps.size()/2;i<input.size()-m_taps.size()/2;++i){
     //todo:introduce nodata
     T leaveOut=(*(m_taps.begin()))*input[i-m_taps.size()/2];
     T include=(m_taps.back())*input[i+m_taps.size()/2];
-    output[(i-offset+down-1)/down]=0;
+    output[i]=0;
     for(int t=0;t<m_taps.size();++t)
-      output[(i-offset+down-1)/down]+=input[i-m_taps.size()/2+t]*m_taps[t];
+      output[i]+=input[i-m_taps.size()/2+t]*m_taps[t];
   }
-  //end: extend input with mirrored version of itself
+  //end: extend input by padding
   for(i=input.size()-m_taps.size()/2;i<input.size();++i){
-    if((i-offset)%down)
-      continue;
     //todo:introduce nodata
-    output[(i-offset+down-1)/down]=m_taps[m_taps.size()/2]*input[i];
+    output[i]=m_taps[m_taps.size()/2]*input[i];
     //todo:introduce nodata
-    for(int t=1;t<=m_taps.size()/2;++t)
-      output[(i-offset+down-1)/down]+=(m_taps[m_taps.size()/2+t]+m_taps[m_taps.size()/2-t])*input[i-t];
+    for(int t=1;t<=m_taps.size()/2;++t){
+      output[i]+=m_taps[m_taps.size()/2-t]*input[i-t];
+      if(i+t<input.size())
+	output[i]+=m_taps[m_taps.size()/2+t]*input[i+t];
+      else{
+	switch(getPadding(m_padding)){
+	case(replicate):
+	  output[i]+=m_taps[m_taps.size()/2+t]*input.back();
+	  break;
+	case(circular):
+	  output[i]+=m_taps[m_taps.size()/2+t]*input[t-1];
+	  break;
+	case(constant):
+	  output[i]+=m_taps[m_taps.size()/2+t]*0;
+	  break;
+	case(symmetric):
+	default:
+	  output[i]+=m_taps[m_taps.size()/2+t]*input[i-t];
+	  break;
+	}
+      }
+    //output[i]+=(m_taps[m_taps.size()/2+t]+m_taps[m_taps.size()/2-t])*input[i-t];
+    }
   }
 }
 
-template<class T> void Filter::morphology(const std::vector<T>& input, std::vector<T>& output, const std::string& method, int dim, short down, int offset, bool verbose)
+//todo: filling statBuffer can be optimized (no need to clear and fill entire buffer, just push back new value...)
+ template<class T> void Filter::filter(const std::vector<T>& input, std::vector<T>& output, const std::string& method, int dim)
 {
+  bool verbose=false;
   assert(dim);
-  output.resize((input.size()-offset+down-1)/down);
+  output.resize(input.size());
   int i=0;
   statfactory::StatFactory stat;
   std::vector<T> statBuffer;
   short binValue=0;
-  //start: extend input with mirrored version of itself
-  for(i=offset;i<dim/2;++i){
+  //start: extend input by padding
+  for(i=0;i<dim/2;++i){
     binValue=0;
     for(int iclass=0;iclass<m_class.size();++iclass){
       if(input[i]==m_class[iclass]){
@@ -468,50 +512,82 @@ template<class T> void Filter::morphology(const std::vector<T>& input, std::vect
       statBuffer.push_back(binValue);
     else
       statBuffer.push_back(input[i]);
+
     for(int t=1;t<=dim/2;++t){
-      binValue=0;
+      T theValue=input[i+t];
       for(int iclass=0;iclass<m_class.size();++iclass){
-        if(input[i+t]==m_class[iclass]){
+        if(theValue==m_class[iclass]){
           binValue=m_class[0];
           break;
         }
       }
-      if(m_class.size()){
-        statBuffer.push_back(binValue);
-        statBuffer.push_back(binValue);
+      if(m_class.size())
+	statBuffer.push_back(binValue);
+      else
+	statBuffer.push_back(theValue);
+
+      if(i>=t){
+	theValue=input[i-t];
       }
       else{
-        statBuffer.push_back(input[i+t]);
-        statBuffer.push_back(input[i+t]);
+	switch(getPadding(m_padding)){
+	case(replicate):
+	  theValue=input[0];
+	  break;
+	case(circular):
+	  theValue=input[input.size()+i-t];
+	  break;
+	case(constant):
+	  theValue=0;
+	  break;
+	case(symmetric):
+	default:
+	  theValue=input[t-i];
+	  break;
+	}
       }
+      for(int iclass=0;iclass<m_class.size();++iclass){
+        if(theValue==m_class[iclass]){
+          binValue=m_class[0];
+          break;
+        }
+      }
+      if(m_class.size())
+	statBuffer.push_back(binValue);
+      else
+	statBuffer.push_back(theValue);
     }
-    assert(statBuffer.size()==dim);
-    if((i-offset)%down){
-      statBuffer.clear();
-      continue;
-    }
+
     switch(getFilterType(method)){
-    case(filter::dilate):
-      output[(i-offset+down-1)/down]=stat.mymax(statBuffer);
+    case(filter::median):
+      output[i]=stat.median(statBuffer);
       break;
+    case(filter::min):
     case(filter::erode):
-      output[(i-offset+down-1)/down]=stat.mymin(statBuffer);
+      output[i]=stat.mymin(statBuffer);
+      break;
+    case(filter::max):
+    case(filter::dilate):
+      output[i]=stat.mymax(statBuffer);
+      break;
+    case(filter::sum):
+      output[i]=sqrt(stat.sum(statBuffer));
+      break;
+    case(filter::var):
+      output[i]=stat.var(statBuffer);
+      break;
+    case(filter::mean):
+      output[i]=stat.mean(statBuffer);
       break;
     default:
       std::string errorString="method not supported";
       throw(errorString);
       break;
     }
-    if(verbose){
-      std::cout << "buffer: ";
-      for(int ibuf=0;ibuf<statBuffer.size();++ibuf)
-        std::cout << statBuffer[ibuf] << " ";
-      std::cout << "->" << output[(i-offset+down-1)/down] << std::endl;
-    }
   }
   //main
   statBuffer.clear();
-  for(i=offset+dim/2;i<input.size()-dim/2;++i){
+  for(i=dim/2;i<input.size()-dim/2;++i){
     binValue=0;
     for(int t=0;t<dim;++t){
       for(int iclass=0;iclass<m_class.size();++iclass){
@@ -525,126 +601,201 @@ template<class T> void Filter::morphology(const std::vector<T>& input, std::vect
       else
         statBuffer.push_back(input[i-dim/2+t]);
     }
-    assert(statBuffer.size()==dim);
-    if((i-offset)%down){
-      statBuffer.clear();
-      continue;
-    }
     switch(getFilterType(method)){
-    case(filter::dilate):
-      output[(i-offset+down-1)/down]=stat.mymax(statBuffer);
+    case(filter::median):
+      output[i]=stat.median(statBuffer);
       break;
+    case(filter::min):
     case(filter::erode):
-      output[(i-offset+down-1)/down]=stat.mymin(statBuffer);
+      output[i]=stat.mymin(statBuffer);
+      break;
+    case(filter::max):
+    case(filter::dilate):
+      output[i]=stat.mymax(statBuffer);
+      break;
+    case(filter::sum):
+      output[i]=sqrt(stat.sum(statBuffer));
+      break;
+    case(filter::var):
+      output[i]=stat.var(statBuffer);
+      break;
+    case(filter::mean):
+      output[i]=stat.mean(statBuffer);
       break;
     default:
       std::string errorString="method not supported";
       throw(errorString);
       break;
     }
-    if(verbose){
-      std::cout << "buffer: ";
-      for(int ibuf=0;ibuf<statBuffer.size();++ibuf)
-        std::cout << statBuffer[ibuf] << " ";
-      std::cout << "->" << output[(i-offset+down-1)/down] << std::endl;
-    }
     statBuffer.clear();
   }
-  //end: extend input with mirrored version of itself
+  //end: extend input by padding
   for(i=input.size()-dim/2;i<input.size();++i){
-      binValue=0;
+    binValue=0;
+    for(int iclass=0;iclass<m_class.size();++iclass){
+      if(input[i]==m_class[iclass]){
+	binValue=m_class[0];
+	break;
+      }
+    }
+    if(m_class.size())
+      statBuffer.push_back(binValue);
+    else
+      statBuffer.push_back(input[i]);
+
+    for(int t=1;t<=dim/2;++t){
+      T theValue=input[i-t];
       for(int iclass=0;iclass<m_class.size();++iclass){
-        if(input[i]==m_class[iclass]){
-          binValue=m_class[0];
-          break;
-        }
+	if(theValue==m_class[iclass]){
+	  binValue=m_class[0];
+	  break;
+	}
       }
       if(m_class.size())
-        statBuffer.push_back(binValue);
+	statBuffer.push_back(binValue);
       else
-        statBuffer.push_back(input[i]);
-      for(int t=1;t<=dim/2;++t){
-        binValue=0;
-        for(int iclass=0;iclass<m_class.size();++iclass){
-          if(input[i-t]==m_class[iclass]){
-            binValue=m_class[0];
-            break;
-          }
-        }
-        if(m_class.size()){
-          statBuffer.push_back(binValue);
-          statBuffer.push_back(binValue);
-        }
-        else{
-          statBuffer.push_back(input[i-t]);
-          statBuffer.push_back(input[i-t]);
-        }
+	statBuffer.push_back(theValue);
+      if(i+t<input.size())
+	theValue=input[i+t];
+      else{
+	switch(getPadding(m_padding)){
+	case(replicate):
+	  theValue=input.back();
+	  break;
+	case(circular):
+	  theValue=input[t-1];
+	  break;
+	case(constant):
+	  theValue=0;
+	  break;
+	case(symmetric):
+	default:
+	  theValue=input[i-t];
+	  break;
+	}
       }
-    if((i-offset)%down){
-      statBuffer.clear();
-      continue;
+      for(int iclass=0;iclass<m_class.size();++iclass){
+	if(theValue==m_class[iclass]){
+	  binValue=m_class[0];
+	  break;
+	}
+      }
+      if(m_class.size())
+	statBuffer.push_back(binValue);
+      else
+	statBuffer.push_back(theValue);
     }
     switch(getFilterType(method)){
-    case(filter::dilate):
-      output[(i-offset+down-1)/down]=stat.mymax(statBuffer);
+    case(filter::median):
+      output[i]=stat.median(statBuffer);
       break;
+    case(filter::min):
     case(filter::erode):
-      output[(i-offset+down-1)/down]=stat.mymin(statBuffer);
+      output[i]=stat.mymin(statBuffer);
+      break;
+    case(filter::max):
+    case(filter::dilate):
+      output[i]=stat.mymax(statBuffer);
+      break;
+    case(filter::sum):
+      output[i]=sqrt(stat.sum(statBuffer));
+      break;
+    case(filter::var):
+      output[i]=stat.var(statBuffer);
+      break;
+    case(filter::mean):
+      output[i]=stat.mean(statBuffer);
       break;
     default:
       std::string errorString="method not supported";
       throw(errorString);
       break;
     }
-    if(verbose){
-      std::cout << "buffer: ";
-      for(int ibuf=0;ibuf<statBuffer.size();++ibuf)
-        std::cout << statBuffer[ibuf] << " ";
-      std::cout << "->" << output[(i-offset+down-1)/down] << std::endl;
-    }
   }
-}
+ }
 
- template<class T> void Filter::smooth(T* input, int inputSize, std::vector<T>& output, short dim, int down, int offset)
+ template<class T> void Filter::smooth(T* input, int inputSize, std::vector<T>& output, short dim)
 {
   assert(dim>0);
   m_taps.resize(dim);
   for(int itap=0;itap<dim;++itap)
     m_taps[itap]=1.0/dim;
-  filter(input,output,down,offset);
+  filter(input,output);
  }
 
-template<class T> void Filter::filter(T* input, int inputSize, std::vector<T>& output, int down, int offset)
+template<class T> void Filter::filter(T* input, int inputSize, std::vector<T>& output)
 {
-  output.resize((inputSize-offset+down-1)/down);
+  assert(inputSize>m_taps.size());
+  output.resize(inputSize);
   int i=0;
-  //start: extend input with mirrored version of itself
-  for(i=offset;i<m_taps.size()/2;++i){
-    if((i-offset)%down)
-      continue;
-    output[(i-offset+down-1)/down]=m_taps[m_taps.size()/2]*input[i];
-    for(int t=1;t<=m_taps.size()/2;++t)
-      output[(i-offset+down-1)/down]+=(m_taps[m_taps.size()/2+t]+m_taps[m_taps.size()/2-t])*input[i+t];
+
+  //start: extend input by padding
+  for(i=0;i<m_taps.size()/2;++i){
+    //todo:introduce nodata
+    output[i]=m_taps[m_taps.size()/2]*input[i];
+
+    for(int t=1;t<=m_taps.size()/2;++t){
+      output[i]+=m_taps[m_taps.size()/2+t]*input[i+t];
+      if(i>=t)
+	output[i]+=m_taps[m_taps.size()/2-t]*input[i-t];
+      else{
+	switch(getPadding(m_padding)){
+	case(replicate):
+	  output[i]+=m_taps[m_taps.size()/2-t]*input[0];
+	  break;
+	case(circular):
+	  output[i]+=m_taps[m_taps.size()/2-t]*input[input.size()+i-t];
+	  break;
+	case(constant):
+	  output[i]+=m_taps[m_taps.size()/2-t]*0;
+	  break;
+	case(symmetric):
+	default:
+	  output[i]+=m_taps[m_taps.size()/2-t]*input[t-i];
+	  break;
+	}
+      }
+    }
   }
   //main
-  for(i=offset+m_taps.size()/2;i<inputSize-m_taps.size()/2;++i){
-    if((i-offset)%down)
-      continue;
+  for(i=m_taps.size()/2;i<input.size()-m_taps.size()/2;++i){
+    //todo:introduce nodata
     T leaveOut=(*(m_taps.begin()))*input[i-m_taps.size()/2];
     T include=(m_taps.back())*input[i+m_taps.size()/2];
-    output[(i-offset+down-1)/down]=0;
+    output[i]=0;
     for(int t=0;t<m_taps.size();++t)
-      output[(i-offset+down-1)/down]+=input[i-m_taps.size()/2+t]*m_taps[t];
+      output[i]+=input[i-m_taps.size()/2+t]*m_taps[t];
   }
-  //end: extend input with mirrored version of itself
-  for(i=inputSize-m_taps.size()/2;i<inputSize;++i){
-    if((i-offset)%down)
-      continue;
-    output[(i-offset+down-1)/down]=m_taps[m_taps.size()/2]*input[i];
-    for(int t=1;t<=m_taps.size()/2;++t)
-      output[(i-offset+down-1)/down]+=(m_taps[m_taps.size()/2+t]+m_taps[m_taps.size()/2-t])*input[i-t];
+  //end: extend input by padding
+  for(i=input.size()-m_taps.size()/2;i<input.size();++i){
+    //todo:introduce nodata
+    output[i]=m_taps[m_taps.size()/2]*input[i];
+    //todo:introduce nodata
+    for(int t=1;t<=m_taps.size()/2;++t){
+      output[i]+=m_taps[m_taps.size()/2-t]*input[i-t];
+      if(i+t<input.size())
+	output[i]+=m_taps[m_taps.size()/2+t]*input[i+t];
+      else{
+	switch(getPadding(m_padding)){
+	case(replicate):
+	  output[i]+=m_taps[m_taps.size()/2+t]*input.back();
+	  break;
+	case(circular):
+	  output[i]+=m_taps[m_taps.size()/2+t]*input[t-1];
+	  break;
+	case(constant):
+	  output[i]+=m_taps[m_taps.size()/2+t]*0;
+	  break;
+	case(symmetric):
+	default:
+	  output[i]+=m_taps[m_taps.size()/2+t]*input[i-t];
+	  break;
+	}
+      }
+    }
   }
 }
+
 }
 
 #endif /* _MYFILTER_H_ */
diff --git a/src/algorithms/Filter2d.cc b/src/algorithms/Filter2d.cc
index 0fc643a..2d02182 100644
--- a/src/algorithms/Filter2d.cc
+++ b/src/algorithms/Filter2d.cc
@@ -581,7 +581,7 @@ void filter2d::Filter2d::doit(const ImgReaderGdal& input, ImgWriterGdal& output,
 	    outBuffer[x/down]=(m_noDataValues.size())? m_noDataValues[0] : 0;
           break;
 	}
-        case(filter2d::majority):{
+        case(filter2d::mode):{
 	  if(occurrence.size()){
             std::map<long int,int>::const_iterator maxit=occurrence.begin();
             for(std::map<long int,int>::const_iterator mit=occurrence.begin();mit!=occurrence.end();++mit){
diff --git a/src/algorithms/Filter2d.h b/src/algorithms/Filter2d.h
index deb27d8..d4e1917 100644
--- a/src/algorithms/Filter2d.h
+++ b/src/algorithms/Filter2d.h
@@ -58,7 +58,7 @@ extern "C" {
 
 namespace filter2d
 {
-  enum FILTER_TYPE { median=100, var=101 , min=102, max=103, sum=104, mean=105, minmax=106, dilate=107, erode=108, close=109, open=110, homog=111, sobelx=112, sobely=113, sobelxy=114, sobelyx=115, smooth=116, density=117, majority=118, mixed=119, threshold=120, ismin=121, ismax=122, heterog=123, order=124, stdev=125, mrf=126, dwt=127, dwti=128, dwt_cut=129, scramble=130, shift=131, linearfeature=132, smoothnodata=133, countid=134, dwt_cut_from=135};
+  enum FILTER_TYPE { median=100, var=101 , min=102, max=103, sum=104, mean=105, minmax=106, dilate=107, erode=108, close=109, open=110, homog=111, sobelx=112, sobely=113, sobelxy=114, sobelyx=115, smooth=116, density=117, mode=118, mixed=119, threshold=120, ismin=121, ismax=122, heterog=123, order=124, stdev=125, mrf=126, dwt=127, dwti=128, dwt_cut=129, scramble=130, shift=131, linearfeature=132, smoothnodata=133, countid=134, dwt_cut_from=135};
 
   enum RESAMPLE { NEAR = 0, BILINEAR = 1, BICUBIC = 2 };//bicubic not supported yet...
   
@@ -149,7 +149,7 @@ private:
     m_filterMap["sobelyx"]=filter2d::sobelyx;
     m_filterMap["smooth"]=filter2d::smooth;
     m_filterMap["density"]=filter2d::density;
-    m_filterMap["majority"]=filter2d::majority;
+    m_filterMap["mode"]=filter2d::mode;
     m_filterMap["mixed"]=filter2d::mixed;
     m_filterMap["smoothnodata"]=filter2d::smoothnodata;
     m_filterMap["threshold"]=filter2d::threshold;
@@ -453,7 +453,7 @@ template<class T1, class T2> void Filter2d::doit(const Vector2d<T1>& inputVector
           outBuffer[x/down]=noDataValue;
         break;
       }
-      case(filter2d::majority):{
+      case(filter2d::mode):{
         if(occurrence.size()){
           std::map<int,int>::const_iterator maxit=occurrence.begin();
           for(std::map<int,int>::const_iterator mit=occurrence.begin();mit!=occurrence.end();++mit){
diff --git a/src/algorithms/ImgRegression.cc b/src/algorithms/ImgRegression.cc
index 55b3c2f..e1de847 100644
--- a/src/algorithms/ImgRegression.cc
+++ b/src/algorithms/ImgRegression.cc
@@ -81,7 +81,7 @@ double ImgRegression::getRMSE(const ImgReaderGdal& imgReader1, const ImgReaderGd
     }
   }
   double err=0;
-  if(buffer1.size()||buffer2.size()){
+  if(buffer1.size()&&buffer2.size()){
     statfactory::StatFactory stat;
     err=stat.linear_regression_err(buffer1,buffer2,c0,c1);
   }
diff --git a/src/algorithms/Makefile.am b/src/algorithms/Makefile.am
index ab568ab..e25cf61 100644
--- a/src/algorithms/Makefile.am
+++ b/src/algorithms/Makefile.am
@@ -25,7 +25,7 @@ libalgorithms_ladir = $(includedir)/pktools/algorithms
 libalgorithms_la_LDFLAGS = -version-info $(PKTOOLS_SO_VERSION) $(AM_LDFLAGS)
 
 # the list of header files that belong to the library (to be installed later)
-libalgorithms_la_HEADERS = Egcs.h Filter2d.h Filter.h StatFactory.h ConfusionMatrix.h svm.h CostFactory.h FeatureSelector.h
+libalgorithms_la_HEADERS = Egcs.h Filter2d.h Filter.h StatFactory.h ConfusionMatrix.h svm.h CostFactory.h CostFactorySVM.h FeatureSelector.h
 
 if USE_FANN
 libalgorithms_la_HEADERS += myfann_cpp.h
@@ -36,7 +36,7 @@ libalgorithms_la_HEADERS += OptFactory.h
 endif
 
 # the sources to add to the library and to add to the source distribution
-libalgorithms_la_SOURCES = $(libalgorithms_la_HEADERS) Egcs.cc Filter2d.cc Filter.cc ConfusionMatrix.cc svm.cpp
+libalgorithms_la_SOURCES = $(libalgorithms_la_HEADERS) Egcs.cc Filter2d.cc Filter.cc ConfusionMatrix.cc svm.cpp CostFactorySVM.cc
 ###############################################################################
 
 # list of sources for the binaries
diff --git a/src/algorithms/Makefile.in b/src/algorithms/Makefile.in
index a524535..6cbf186 100644
--- a/src/algorithms/Makefile.in
+++ b/src/algorithms/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,23 +16,51 @@
 
 
 VPATH = @srcdir@
-am__make_dryrun = \
-  { \
-    am__dry=no; \
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
     case $$MAKEFLAGS in \
       *\\[\ \	]*) \
-        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
-          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
-      *) \
-        for am__flg in $$MAKEFLAGS; do \
-          case $$am__flg in \
-            *=*|--*) ;; \
-            *n*) am__dry=yes; break;; \
-          esac; \
-        done;; \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
     esac; \
-    test $$am__dry = yes; \
-  }
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -55,8 +82,8 @@ host_triplet = @host@
 @USE_FANN_TRUE at am__append_1 = myfann_cpp.h
 @USE_NLOPT_TRUE at am__append_2 = OptFactory.h
 subdir = src/algorithms
-DIST_COMMON = $(am__libalgorithms_la_HEADERS_DIST) \
-	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/depcomp $(am__libalgorithms_la_HEADERS_DIST)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -101,38 +128,74 @@ LTLIBRARIES = $(lib_LTLIBRARIES)
 libalgorithms_la_LIBADD =
 am__libalgorithms_la_SOURCES_DIST = Egcs.h Filter2d.h Filter.h \
 	StatFactory.h ConfusionMatrix.h svm.h CostFactory.h \
-	FeatureSelector.h myfann_cpp.h OptFactory.h Egcs.cc \
-	Filter2d.cc Filter.cc ConfusionMatrix.cc svm.cpp
+	CostFactorySVM.h FeatureSelector.h myfann_cpp.h OptFactory.h \
+	Egcs.cc Filter2d.cc Filter.cc ConfusionMatrix.cc svm.cpp \
+	CostFactorySVM.cc
 am__objects_1 =
 am__objects_2 = $(am__objects_1) $(am__objects_1)
 am_libalgorithms_la_OBJECTS = $(am__objects_2) Egcs.lo Filter2d.lo \
-	Filter.lo ConfusionMatrix.lo svm.lo
+	Filter.lo ConfusionMatrix.lo svm.lo CostFactorySVM.lo
 libalgorithms_la_OBJECTS = $(am_libalgorithms_la_OBJECTS)
-libalgorithms_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-	$(CXXFLAGS) $(libalgorithms_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_lt = $(am__v_lt_ at AM_V@)
+am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+libalgorithms_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(AM_CXXFLAGS) $(CXXFLAGS) $(libalgorithms_la_LDFLAGS) \
+	$(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 am__mv = mv -f
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_ at AM_V@)
+am__v_CXX_ = $(am__v_CXX_ at AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
 CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_ at AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_ at AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_ at AM_V@)
+am__v_CC_ = $(am__v_CC_ at AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
 CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
 SOURCES = $(libalgorithms_la_SOURCES)
 DIST_SOURCES = $(am__libalgorithms_la_SOURCES_DIST)
 am__can_run_installinfo = \
@@ -142,14 +205,32 @@ am__can_run_installinfo = \
   esac
 am__libalgorithms_la_HEADERS_DIST = Egcs.h Filter2d.h Filter.h \
 	StatFactory.h ConfusionMatrix.h svm.h CostFactory.h \
-	FeatureSelector.h myfann_cpp.h OptFactory.h
+	CostFactorySVM.h FeatureSelector.h myfann_cpp.h OptFactory.h
 HEADERS = $(libalgorithms_la_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_CXXFLAGS = -I$(top_srcdir)/src $(GDAL_CFLAGS) @AM_CXXFLAGS@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AM_LDFLAGS = $(GSL_LIBS) $(GDAL_LDFLAGS) @AM_LDFLAGS@ 
 AR = @AR@
 AUTOCONF = @AUTOCONF@
@@ -309,11 +390,11 @@ libalgorithms_la_LDFLAGS = -version-info $(PKTOOLS_SO_VERSION) $(AM_LDFLAGS)
 
 # the list of header files that belong to the library (to be installed later)
 libalgorithms_la_HEADERS = Egcs.h Filter2d.h Filter.h StatFactory.h \
-	ConfusionMatrix.h svm.h CostFactory.h FeatureSelector.h \
-	$(am__append_1) $(am__append_2)
+	ConfusionMatrix.h svm.h CostFactory.h CostFactorySVM.h \
+	FeatureSelector.h $(am__append_1) $(am__append_2)
 
 # the sources to add to the library and to add to the source distribution
-libalgorithms_la_SOURCES = $(libalgorithms_la_HEADERS) Egcs.cc Filter2d.cc Filter.cc ConfusionMatrix.cc svm.cpp
+libalgorithms_la_SOURCES = $(libalgorithms_la_HEADERS) Egcs.cc Filter2d.cc Filter.cc ConfusionMatrix.cc svm.cpp CostFactorySVM.cc
 all: all-am
 
 .SUFFIXES:
@@ -348,6 +429,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
 	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
@@ -374,14 +456,17 @@ uninstall-libLTLIBRARIES:
 
 clean-libLTLIBRARIES:
 	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-	  test "$$dir" != "$$p" || dir=.; \
-	  echo "rm -f \"$${dir}/so_locations\""; \
-	  rm -f "$${dir}/so_locations"; \
-	done
+	@list='$(lib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
+
 libalgorithms.la: $(libalgorithms_la_OBJECTS) $(libalgorithms_la_DEPENDENCIES) $(EXTRA_libalgorithms_la_DEPENDENCIES) 
-	$(libalgorithms_la_LINK) -rpath $(libdir) $(libalgorithms_la_OBJECTS) $(libalgorithms_la_LIBADD) $(LIBS)
+	$(AM_V_CXXLD)$(libalgorithms_la_LINK) -rpath $(libdir) $(libalgorithms_la_OBJECTS) $(libalgorithms_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -390,52 +475,53 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ConfusionMatrix.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CostFactorySVM.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Egcs.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Filter.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Filter2d.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/svm.Plo at am__quote@
 
 .cc.o:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ $<
 
 .cc.obj:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cc.lo:
- at am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 .cpp.o:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ $<
 
 .cpp.obj:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cpp.lo:
- at am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -464,26 +550,15 @@ uninstall-libalgorithms_laHEADERS:
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 	dir='$(DESTDIR)$(libalgorithms_ladir)'; $(am__uninstall_files_from_dir)
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -495,15 +570,11 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -512,6 +583,21 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -657,20 +743,20 @@ uninstall-am: uninstall-libLTLIBRARIES \
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libLTLIBRARIES clean-libtool ctags distclean \
-	distclean-compile distclean-generic 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-info install-info-am \
-	install-libLTLIBRARIES install-libalgorithms_laHEADERS \
-	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-libLTLIBRARIES \
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+	clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \
+	ctags-am distclean distclean-compile distclean-generic \
+	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-info \
+	install-info-am install-libLTLIBRARIES \
+	install-libalgorithms_laHEADERS 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 tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
 	uninstall-libalgorithms_laHEADERS
 
 ###############################################################################
diff --git a/src/algorithms/myfann_cpp.h b/src/algorithms/myfann_cpp.h
index 7938379..29e8997 100644
--- a/src/algorithms/myfann_cpp.h
+++ b/src/algorithms/myfann_cpp.h
@@ -1061,9 +1061,14 @@ public:
         bool create_standard(unsigned int num_layers, ...)
         {
             va_list layers;
+            unsigned int arr[num_layers];
+
             va_start(layers, num_layers);
-            bool status = create_standard_array(num_layers,
-                reinterpret_cast<const unsigned int *>(layers));
+            /* bool status = create_standard_array(num_layers, */
+            /*     reinterpret_cast<const unsigned int *>(layers)); */
+            for (unsigned int ii = 0; ii < num_layers; ii++)
+                arr[ii] = va_arg(layers, unsigned int);
+            bool status = create_standard_array(num_layers, arr);
             va_end(layers);
             return status;
         }
@@ -1111,9 +1116,16 @@ public:
         bool create_sparse(float connection_rate, unsigned int num_layers, ...)
         {
             va_list layers;
+            unsigned int arr[num_layers];
+
             va_start(layers, num_layers);
-            bool status = create_sparse_array(connection_rate, num_layers,
-                reinterpret_cast<const unsigned int *>(layers));
+            /* bool status = create_sparse_array(connection_rate, num_layers, */
+            /*     reinterpret_cast<const unsigned int *>(layers)); */
+
+            for (unsigned int ii = 0; ii < num_layers; ii++)
+                arr[ii] = va_arg(layers, unsigned int);
+            bool status = create_sparse_array(connection_rate, num_layers, arr);
+  
             va_end(layers);
             return status;
         }
@@ -1158,9 +1170,15 @@ public:
         bool create_shortcut(unsigned int num_layers, ...)
         {
             va_list layers;
+            unsigned int arr[num_layers];
+
             va_start(layers, num_layers);
-            bool status = create_shortcut_array(num_layers,
-                reinterpret_cast<const unsigned int *>(layers));
+            /* bool status = create_shortcut_array(num_layers, */
+            /*     reinterpret_cast<const unsigned int *>(layers)); */
+            for (unsigned int ii = 0; ii < num_layers; ii++)
+                arr[ii] = va_arg(layers, unsigned int);
+            bool status = create_shortcut_array(num_layers, arr);
+
             va_end(layers);
             return status;
         }
diff --git a/src/apps/Makefile.am b/src/apps/Makefile.am
index 6aeeeae..0e130df 100644
--- a/src/apps/Makefile.am
+++ b/src/apps/Makefile.am
@@ -15,10 +15,10 @@ if USE_FANN
 bin_PROGRAMS += pkann pkfsann pkregann
 pkann_SOURCES = $(top_srcdir)/src/algorithms/myfann_cpp.h pkann.cc
 pkann_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/base $(FANN_CFLAGS) -I$(top_srcdir)/src/algorithms $(AM_CXXFLAGS)
-pkann_LDADD = $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS)
+pkann_LDADD = $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS) -lgsl
 pkfsann_SOURCES = $(top_srcdir)/src/algorithms/myfann_cpp.h $(top_srcdir)/src/algorithms/CostFactory.h pkfsann.h pkfsann.cc
 pkfsann_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/base $(FANN_CFLAGS) -I$(top_srcdir)/src/algorithms $(AM_CXXFLAGS)
-pkfsann_LDADD = $(GSL_LIBS) $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS) -lalgorithms
+pkfsann_LDADD = $(GSL_LIBS) $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS) -lalgorithms -lgsl
 pkregann_SOURCES = $(top_srcdir)/src/algorithms/myfann_cpp.h pkregann.cc
 pkregann_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/base $(FANN_CFLAGS) -I$(top_srcdir)/src/algorithms $(AM_CXXFLAGS)
 pkregann_LDADD = $(GSL_LIBS) $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS)
@@ -31,14 +31,17 @@ pklas2img_LDADD = $(top_srcdir)/src/lasclasses/liblasClasses.la -llas $(AM_LDFLA
 endif
 if USE_NLOPT
 bin_PROGRAMS += pkoptsvm
-pkoptsvm_SOURCES = $(top_srcdir)/src/algorithms/OptFactory.h pkoptsvm.cc
-pkoptsvm_LDADD = $(GSL_LIBS) $(AM_LDFLAGS) -lnlopt
+pkoptsvm_SOURCES = $(top_srcdir)/src/algorithms/OptFactory.h $(top_srcdir)/src/algorithms/CostFactorySVM.h pkoptsvm.cc
+pkoptsvm_LDADD = $(GSL_LIBS) $(AM_LDFLAGS) -lnlopt -lgsl
 endif
 # list of sources for the binaries
 pkinfo_SOURCES = pkinfo.cc
+pkinfo_LDADD = -lgsl
 pkcrop_SOURCES = pkcrop.cc
+pkcrop_LDADD = -lgsl
 pkreclass_SOURCES = pkreclass.cc
 pkdiff_SOURCES = pkdiff.cc
+pkdiff_LDADD = -lgsl
 pkgetmask_SOURCES = pkgetmask.cc
 pksetmask_SOURCES = pksetmask.cc
 pkcreatect_SOURCES = pkcreatect.cc
@@ -46,28 +49,32 @@ pkdumpimg_SOURCES = pkdumpimg.cc
 pkdumpogr_SOURCES = pkdumpogr.h pkdumpogr.cc
 pksieve_SOURCES = pksieve.cc
 pkstatascii_SOURCES = $(top_srcdir)/src/algorithms/StatFactory.h pkstatascii.cc
-pkstatascii_LDADD = $(GSL_LIBS) $(AM_LDFLAGS)
+pkstatascii_LDADD = -lgsl -lgslcblas $(GSL_LIBS) $(AM_LDFLAGS)
 pkstatogr_SOURCES = pkstatogr.cc
+pkstatogr_LDADD = -lgsl
 pkegcs_SOURCES = pkegcs.cc
-pkegcs_LDADD = -lgdal $(AM_LDFLAGS) -lgdal
+pkegcs_LDADD = $(AM_LDFLAGS) -lgsl -lgdal
 pkextract_SOURCES = pkextract.cc
 pkfillnodata_SOURCES = pkfillnodata.cc
 pkfilter_SOURCES = pkfilter.cc
 pkfilter_LDADD = $(GSL_LIBS) $(AM_LDFLAGS) -lgsl -lgdal
 pkkalman_SOURCES = pkkalman.cc $(top_srcdir)/src/algorithms/ImgRegression.h $(top_srcdir)/src/algorithms/ImgRegression.cc
-pkkalman_LDADD = -lalgorithms $(GSL_LIBS) $(AM_LDFLAGS) -lalgorithms
+pkkalman_LDADD = -lalgorithms -lgsl $(GSL_LIBS) $(AM_LDFLAGS) -lalgorithms
 pkfilterdem_SOURCES = pkfilterdem.cc
+pkfilterdem_LDADD = -lgsl
 pkenhance_SOURCES = pkenhance.cc
 pkenhance_LDADD = $(AM_LDFLAGS) -lgdal
 pkfilterascii_SOURCES = pkfilterascii.cc
 pkfilterascii_LDADD = $(GSL_LIBS) $(AM_LDFLAGS) -lgsl -lgdal
 pkdsm2shadow_SOURCES = pkdsm2shadow.cc
+pkdsm2shadow_LDADD = -lgsl
 pkcomposite_SOURCES = pkcomposite.cc
 pkndvi_SOURCES = pkndvi.cc
 pkpolygonize_SOURCES = pkpolygonize.cc
 pksvm_SOURCES = $(top_srcdir)/src/algorithms/svm.h $(top_srcdir)/src/algorithms/svm.cpp pksvm.cc
-pkfssvm_SOURCES = $(top_srcdir)/src/algorithms/svm.h $(top_srcdir)/src/algorithms/FeatureSelector.h  $(top_srcdir)/src/algorithms/CostFactory.h $(top_srcdir)/src/algorithms/svm.cpp pkfssvm.h pkfssvm.cc
-pkfssvm_LDADD = $(GSL_LIBS) $(AM_LDFLAGS) -lalgorithms
+pksvm_LDADD = -lgsl
+pkfssvm_SOURCES = $(top_srcdir)/src/algorithms/svm.h $(top_srcdir)/src/algorithms/FeatureSelector.h  $(top_srcdir)/src/algorithms/CostFactorySVM.h $(top_srcdir)/src/algorithms/svm.cpp pkfssvm.cc
+pkfssvm_LDADD = -lgsl $(GSL_LIBS) $(AM_LDFLAGS) -lalgorithms
 pkascii2img_SOURCES = pkascii2img.cc
 pkascii2ogr_SOURCES = pkascii2ogr.cc
 pkeditogr_SOURCES = pkeditogr.cc
diff --git a/src/apps/Makefile.in b/src/apps/Makefile.in
index 734ad41..fe20b40 100644
--- a/src/apps/Makefile.in
+++ b/src/apps/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -16,23 +15,51 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
-am__make_dryrun = \
-  { \
-    am__dry=no; \
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
     case $$MAKEFLAGS in \
       *\\[\ \	]*) \
-        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
-          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
-      *) \
-        for am__flg in $$MAKEFLAGS; do \
-          case $$am__flg in \
-            *=*|--*) ;; \
-            *n*) am__dry=yes; break;; \
-          esac; \
-        done;; \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
     esac; \
-    test $$am__dry = yes; \
-  }
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -69,7 +96,8 @@ bin_PROGRAMS = pkinfo$(EXEEXT) pkcrop$(EXEEXT) pkreclass$(EXEEXT) \
 @USE_LAS_TRUE at am__append_2 = pklas2img
 @USE_NLOPT_TRUE at am__append_3 = pkoptsvm
 subdir = src/apps
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -99,9 +127,13 @@ am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/base/libbase.la
 @USE_FANN_TRUE at pkann_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 @USE_FANN_TRUE@	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
-pkann_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(pkann_CXXFLAGS) $(CXXFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_lt = $(am__v_lt_ at AM_V@)
+am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+pkann_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(pkann_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 am_pkascii2img_OBJECTS = pkascii2img.$(OBJEXT)
 pkascii2img_OBJECTS = $(am_pkascii2img_OBJECTS)
 pkascii2img_LDADD = $(LDADD)
@@ -136,29 +168,13 @@ pkcreatect_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/base/libbase.la
 am_pkcrop_OBJECTS = pkcrop.$(OBJEXT)
 pkcrop_OBJECTS = $(am_pkcrop_OBJECTS)
-pkcrop_LDADD = $(LDADD)
-pkcrop_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(top_builddir)/src/algorithms/libalgorithms.la \
-	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+pkcrop_DEPENDENCIES =
 am_pkdiff_OBJECTS = pkdiff.$(OBJEXT)
 pkdiff_OBJECTS = $(am_pkdiff_OBJECTS)
-pkdiff_LDADD = $(LDADD)
-pkdiff_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(top_builddir)/src/algorithms/libalgorithms.la \
-	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+pkdiff_DEPENDENCIES =
 am_pkdsm2shadow_OBJECTS = pkdsm2shadow.$(OBJEXT)
 pkdsm2shadow_OBJECTS = $(am_pkdsm2shadow_OBJECTS)
-pkdsm2shadow_LDADD = $(LDADD)
-pkdsm2shadow_DEPENDENCIES = $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) \
-	$(top_builddir)/src/algorithms/libalgorithms.la \
-	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+pkdsm2shadow_DEPENDENCIES =
 am_pkdumpimg_OBJECTS = pkdumpimg.$(OBJEXT)
 pkdumpimg_OBJECTS = $(am_pkdumpimg_OBJECTS)
 pkdumpimg_LDADD = $(LDADD)
@@ -210,12 +226,7 @@ pkfilterascii_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_2)
 am_pkfilterdem_OBJECTS = pkfilterdem.$(OBJEXT)
 pkfilterdem_OBJECTS = $(am_pkfilterdem_OBJECTS)
-pkfilterdem_LDADD = $(LDADD)
-pkfilterdem_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(top_builddir)/src/algorithms/libalgorithms.la \
-	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+pkfilterdem_DEPENDENCIES =
 am__pkfsann_SOURCES_DIST = $(top_srcdir)/src/algorithms/myfann_cpp.h \
 	$(top_srcdir)/src/algorithms/CostFactory.h pkfsann.h \
 	pkfsann.cc
@@ -224,9 +235,9 @@ pkfsann_OBJECTS = $(am_pkfsann_OBJECTS)
 @USE_FANN_TRUE at pkfsann_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 @USE_FANN_TRUE@	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 @USE_FANN_TRUE@	$(am__DEPENDENCIES_2)
-pkfsann_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(pkfsann_CXXFLAGS) $(CXXFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+pkfsann_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(pkfsann_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 am_pkfssvm_OBJECTS = svm.$(OBJEXT) pkfssvm.$(OBJEXT)
 pkfssvm_OBJECTS = $(am_pkfssvm_OBJECTS)
 pkfssvm_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
@@ -240,12 +251,7 @@ pkgetmask_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/base/libbase.la
 am_pkinfo_OBJECTS = pkinfo.$(OBJEXT)
 pkinfo_OBJECTS = $(am_pkinfo_OBJECTS)
-pkinfo_LDADD = $(LDADD)
-pkinfo_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(top_builddir)/src/algorithms/libalgorithms.la \
-	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+pkinfo_DEPENDENCIES =
 am_pkkalman_OBJECTS = pkkalman.$(OBJEXT) ImgRegression.$(OBJEXT)
 pkkalman_OBJECTS = $(am_pkkalman_OBJECTS)
 pkkalman_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
@@ -264,7 +270,7 @@ pkndvi_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/fileclasses/libfileClasses.la \
 	$(top_builddir)/src/base/libbase.la
 am__pkoptsvm_SOURCES_DIST = $(top_srcdir)/src/algorithms/OptFactory.h \
-	pkoptsvm.cc
+	$(top_srcdir)/src/algorithms/CostFactorySVM.h pkoptsvm.cc
 @USE_NLOPT_TRUE at am_pkoptsvm_OBJECTS = pkoptsvm.$(OBJEXT)
 pkoptsvm_OBJECTS = $(am_pkoptsvm_OBJECTS)
 @USE_NLOPT_TRUE at pkoptsvm_DEPENDENCIES = $(am__DEPENDENCIES_1) \
@@ -293,7 +299,7 @@ pkregann_OBJECTS = $(am_pkregann_OBJECTS)
 @USE_FANN_TRUE at pkregann_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 @USE_FANN_TRUE@	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 @USE_FANN_TRUE@	$(am__DEPENDENCIES_2)
-pkregann_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+pkregann_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(pkregann_CXXFLAGS) \
 	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 am_pksetmask_OBJECTS = pksetmask.$(OBJEXT)
@@ -317,42 +323,62 @@ pkstatascii_OBJECTS = $(am_pkstatascii_OBJECTS)
 pkstatascii_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
 am_pkstatogr_OBJECTS = pkstatogr.$(OBJEXT)
 pkstatogr_OBJECTS = $(am_pkstatogr_OBJECTS)
-pkstatogr_LDADD = $(LDADD)
-pkstatogr_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(top_builddir)/src/algorithms/libalgorithms.la \
-	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+pkstatogr_DEPENDENCIES =
 am_pksvm_OBJECTS = svm.$(OBJEXT) pksvm.$(OBJEXT)
 pksvm_OBJECTS = $(am_pksvm_OBJECTS)
-pksvm_LDADD = $(LDADD)
-pksvm_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(top_builddir)/src/algorithms/libalgorithms.la \
-	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+pksvm_DEPENDENCIES =
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 am__mv = mv -f
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_ at AM_V@)
+am__v_CXX_ = $(am__v_CXX_ at AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
 CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_ at AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_ at AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_ at AM_V@)
+am__v_CC_ = $(am__v_CC_ at AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
 CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
 SOURCES = $(pkann_SOURCES) $(pkascii2img_SOURCES) \
 	$(pkascii2ogr_SOURCES) $(pkcomposite_SOURCES) \
 	$(pkcreatect_SOURCES) $(pkcrop_SOURCES) $(pkdiff_SOURCES) \
@@ -387,12 +413,30 @@ am__can_run_installinfo = \
     n|no|NO) false;; \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/base $(GDAL_CFLAGS) @AM_CXXFLAGS@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AM_LDFLAGS = $(GSL_LIBS) $(GDAL_LDFLAGS) $(top_builddir)/src/algorithms/libalgorithms.la $(top_builddir)/src/imageclasses/libimageClasses.la $(top_builddir)/src/fileclasses/libfileClasses.la $(top_builddir)/src/base/libbase.la @AM_LDFLAGS@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
@@ -533,22 +577,25 @@ top_srcdir = @top_srcdir@
 LDADD = $(GSL_LIBS) $(GDAL_LDFLAGS) $(top_builddir)/src/algorithms/libalgorithms.la $(top_builddir)/src/imageclasses/libimageClasses.la $(top_builddir)/src/fileclasses/libfileClasses.la $(top_builddir)/src/base/libbase.la
 @USE_FANN_TRUE at pkann_SOURCES = $(top_srcdir)/src/algorithms/myfann_cpp.h pkann.cc
 @USE_FANN_TRUE at pkann_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/base $(FANN_CFLAGS) -I$(top_srcdir)/src/algorithms $(AM_CXXFLAGS)
- at USE_FANN_TRUE@pkann_LDADD = $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS)
+ at USE_FANN_TRUE@pkann_LDADD = $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS) -lgsl
 @USE_FANN_TRUE at pkfsann_SOURCES = $(top_srcdir)/src/algorithms/myfann_cpp.h $(top_srcdir)/src/algorithms/CostFactory.h pkfsann.h pkfsann.cc
 @USE_FANN_TRUE at pkfsann_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/base $(FANN_CFLAGS) -I$(top_srcdir)/src/algorithms $(AM_CXXFLAGS)
- at USE_FANN_TRUE@pkfsann_LDADD = $(GSL_LIBS) $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS) -lalgorithms
+ at USE_FANN_TRUE@pkfsann_LDADD = $(GSL_LIBS) $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS) -lalgorithms -lgsl
 @USE_FANN_TRUE at pkregann_SOURCES = $(top_srcdir)/src/algorithms/myfann_cpp.h pkregann.cc
 @USE_FANN_TRUE at pkregann_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/base $(FANN_CFLAGS) -I$(top_srcdir)/src/algorithms $(AM_CXXFLAGS)
 @USE_FANN_TRUE at pkregann_LDADD = $(GSL_LIBS) $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS)
 @USE_LAS_TRUE at pklas2img_SOURCES = pklas2img.cc
 @USE_LAS_TRUE at pklas2img_LDADD = $(top_srcdir)/src/lasclasses/liblasClasses.la -llas $(AM_LDFLAGS)
- at USE_NLOPT_TRUE@pkoptsvm_SOURCES = $(top_srcdir)/src/algorithms/OptFactory.h pkoptsvm.cc
- at USE_NLOPT_TRUE@pkoptsvm_LDADD = $(GSL_LIBS) $(AM_LDFLAGS) -lnlopt
+ at USE_NLOPT_TRUE@pkoptsvm_SOURCES = $(top_srcdir)/src/algorithms/OptFactory.h $(top_srcdir)/src/algorithms/CostFactorySVM.h pkoptsvm.cc
+ at USE_NLOPT_TRUE@pkoptsvm_LDADD = $(GSL_LIBS) $(AM_LDFLAGS) -lnlopt -lgsl
 # list of sources for the binaries
 pkinfo_SOURCES = pkinfo.cc
+pkinfo_LDADD = -lgsl
 pkcrop_SOURCES = pkcrop.cc
+pkcrop_LDADD = -lgsl
 pkreclass_SOURCES = pkreclass.cc
 pkdiff_SOURCES = pkdiff.cc
+pkdiff_LDADD = -lgsl
 pkgetmask_SOURCES = pkgetmask.cc
 pksetmask_SOURCES = pksetmask.cc
 pkcreatect_SOURCES = pkcreatect.cc
@@ -556,28 +603,32 @@ pkdumpimg_SOURCES = pkdumpimg.cc
 pkdumpogr_SOURCES = pkdumpogr.h pkdumpogr.cc
 pksieve_SOURCES = pksieve.cc
 pkstatascii_SOURCES = $(top_srcdir)/src/algorithms/StatFactory.h pkstatascii.cc
-pkstatascii_LDADD = $(GSL_LIBS) $(AM_LDFLAGS)
+pkstatascii_LDADD = -lgsl -lgslcblas $(GSL_LIBS) $(AM_LDFLAGS)
 pkstatogr_SOURCES = pkstatogr.cc
+pkstatogr_LDADD = -lgsl
 pkegcs_SOURCES = pkegcs.cc
-pkegcs_LDADD = -lgdal $(AM_LDFLAGS) -lgdal
+pkegcs_LDADD = $(AM_LDFLAGS) -lgsl -lgdal
 pkextract_SOURCES = pkextract.cc
 pkfillnodata_SOURCES = pkfillnodata.cc
 pkfilter_SOURCES = pkfilter.cc
 pkfilter_LDADD = $(GSL_LIBS) $(AM_LDFLAGS) -lgsl -lgdal
 pkkalman_SOURCES = pkkalman.cc $(top_srcdir)/src/algorithms/ImgRegression.h $(top_srcdir)/src/algorithms/ImgRegression.cc
-pkkalman_LDADD = -lalgorithms $(GSL_LIBS) $(AM_LDFLAGS) -lalgorithms
+pkkalman_LDADD = -lalgorithms -lgsl $(GSL_LIBS) $(AM_LDFLAGS) -lalgorithms
 pkfilterdem_SOURCES = pkfilterdem.cc
+pkfilterdem_LDADD = -lgsl
 pkenhance_SOURCES = pkenhance.cc
 pkenhance_LDADD = $(AM_LDFLAGS) -lgdal
 pkfilterascii_SOURCES = pkfilterascii.cc
 pkfilterascii_LDADD = $(GSL_LIBS) $(AM_LDFLAGS) -lgsl -lgdal
 pkdsm2shadow_SOURCES = pkdsm2shadow.cc
+pkdsm2shadow_LDADD = -lgsl
 pkcomposite_SOURCES = pkcomposite.cc
 pkndvi_SOURCES = pkndvi.cc
 pkpolygonize_SOURCES = pkpolygonize.cc
 pksvm_SOURCES = $(top_srcdir)/src/algorithms/svm.h $(top_srcdir)/src/algorithms/svm.cpp pksvm.cc
-pkfssvm_SOURCES = $(top_srcdir)/src/algorithms/svm.h $(top_srcdir)/src/algorithms/FeatureSelector.h  $(top_srcdir)/src/algorithms/CostFactory.h $(top_srcdir)/src/algorithms/svm.cpp pkfssvm.h pkfssvm.cc
-pkfssvm_LDADD = $(GSL_LIBS) $(AM_LDFLAGS) -lalgorithms
+pksvm_LDADD = -lgsl
+pkfssvm_SOURCES = $(top_srcdir)/src/algorithms/svm.h $(top_srcdir)/src/algorithms/FeatureSelector.h  $(top_srcdir)/src/algorithms/CostFactorySVM.h $(top_srcdir)/src/algorithms/svm.cpp pkfssvm.cc
+pkfssvm_LDADD = -lgsl $(GSL_LIBS) $(AM_LDFLAGS) -lalgorithms
 pkascii2img_SOURCES = pkascii2img.cc
 pkascii2ogr_SOURCES = pkascii2ogr.cc
 pkeditogr_SOURCES = pkeditogr.cc
@@ -625,10 +676,12 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	fi; \
 	for p in $$list; do echo "$$p $$p"; done | \
 	sed 's/$(EXEEXT)$$//' | \
-	while read p p1; do if test -f $$p || test -f $$p1; \
-	  then echo "$$p"; echo "$$p"; else :; fi; \
+	while read p p1; do if test -f $$p \
+	 || test -f $$p1 \
+	  ; then echo "$$p"; echo "$$p"; else :; fi; \
 	done | \
-	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	sed -e 'p;s,.*/,,;n;h' \
+	    -e 's|.*|.|' \
 	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
 	sed 'N;N;N;s,\n, ,g' | \
 	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
@@ -649,7 +702,8 @@ uninstall-binPROGRAMS:
 	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
 	files=`for p in $$list; do echo "$$p"; done | \
 	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-	      -e 's/$$/$(EXEEXT)/' `; \
+	      -e 's/$$/$(EXEEXT)/' \
+	`; \
 	test -n "$$list" || exit 0; \
 	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
 	cd "$(DESTDIR)$(bindir)" && rm -f $$files
@@ -662,108 +716,142 @@ clean-binPROGRAMS:
 	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
 	echo " rm -f" $$list; \
 	rm -f $$list
+
 pkann$(EXEEXT): $(pkann_OBJECTS) $(pkann_DEPENDENCIES) $(EXTRA_pkann_DEPENDENCIES) 
 	@rm -f pkann$(EXEEXT)
-	$(pkann_LINK) $(pkann_OBJECTS) $(pkann_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(pkann_LINK) $(pkann_OBJECTS) $(pkann_LDADD) $(LIBS)
+
 pkascii2img$(EXEEXT): $(pkascii2img_OBJECTS) $(pkascii2img_DEPENDENCIES) $(EXTRA_pkascii2img_DEPENDENCIES) 
 	@rm -f pkascii2img$(EXEEXT)
-	$(CXXLINK) $(pkascii2img_OBJECTS) $(pkascii2img_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkascii2img_OBJECTS) $(pkascii2img_LDADD) $(LIBS)
+
 pkascii2ogr$(EXEEXT): $(pkascii2ogr_OBJECTS) $(pkascii2ogr_DEPENDENCIES) $(EXTRA_pkascii2ogr_DEPENDENCIES) 
 	@rm -f pkascii2ogr$(EXEEXT)
-	$(CXXLINK) $(pkascii2ogr_OBJECTS) $(pkascii2ogr_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkascii2ogr_OBJECTS) $(pkascii2ogr_LDADD) $(LIBS)
+
 pkcomposite$(EXEEXT): $(pkcomposite_OBJECTS) $(pkcomposite_DEPENDENCIES) $(EXTRA_pkcomposite_DEPENDENCIES) 
 	@rm -f pkcomposite$(EXEEXT)
-	$(CXXLINK) $(pkcomposite_OBJECTS) $(pkcomposite_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkcomposite_OBJECTS) $(pkcomposite_LDADD) $(LIBS)
+
 pkcreatect$(EXEEXT): $(pkcreatect_OBJECTS) $(pkcreatect_DEPENDENCIES) $(EXTRA_pkcreatect_DEPENDENCIES) 
 	@rm -f pkcreatect$(EXEEXT)
-	$(CXXLINK) $(pkcreatect_OBJECTS) $(pkcreatect_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkcreatect_OBJECTS) $(pkcreatect_LDADD) $(LIBS)
+
 pkcrop$(EXEEXT): $(pkcrop_OBJECTS) $(pkcrop_DEPENDENCIES) $(EXTRA_pkcrop_DEPENDENCIES) 
 	@rm -f pkcrop$(EXEEXT)
-	$(CXXLINK) $(pkcrop_OBJECTS) $(pkcrop_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkcrop_OBJECTS) $(pkcrop_LDADD) $(LIBS)
+
 pkdiff$(EXEEXT): $(pkdiff_OBJECTS) $(pkdiff_DEPENDENCIES) $(EXTRA_pkdiff_DEPENDENCIES) 
 	@rm -f pkdiff$(EXEEXT)
-	$(CXXLINK) $(pkdiff_OBJECTS) $(pkdiff_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkdiff_OBJECTS) $(pkdiff_LDADD) $(LIBS)
+
 pkdsm2shadow$(EXEEXT): $(pkdsm2shadow_OBJECTS) $(pkdsm2shadow_DEPENDENCIES) $(EXTRA_pkdsm2shadow_DEPENDENCIES) 
 	@rm -f pkdsm2shadow$(EXEEXT)
-	$(CXXLINK) $(pkdsm2shadow_OBJECTS) $(pkdsm2shadow_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkdsm2shadow_OBJECTS) $(pkdsm2shadow_LDADD) $(LIBS)
+
 pkdumpimg$(EXEEXT): $(pkdumpimg_OBJECTS) $(pkdumpimg_DEPENDENCIES) $(EXTRA_pkdumpimg_DEPENDENCIES) 
 	@rm -f pkdumpimg$(EXEEXT)
-	$(CXXLINK) $(pkdumpimg_OBJECTS) $(pkdumpimg_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkdumpimg_OBJECTS) $(pkdumpimg_LDADD) $(LIBS)
+
 pkdumpogr$(EXEEXT): $(pkdumpogr_OBJECTS) $(pkdumpogr_DEPENDENCIES) $(EXTRA_pkdumpogr_DEPENDENCIES) 
 	@rm -f pkdumpogr$(EXEEXT)
-	$(CXXLINK) $(pkdumpogr_OBJECTS) $(pkdumpogr_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkdumpogr_OBJECTS) $(pkdumpogr_LDADD) $(LIBS)
+
 pkeditogr$(EXEEXT): $(pkeditogr_OBJECTS) $(pkeditogr_DEPENDENCIES) $(EXTRA_pkeditogr_DEPENDENCIES) 
 	@rm -f pkeditogr$(EXEEXT)
-	$(CXXLINK) $(pkeditogr_OBJECTS) $(pkeditogr_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkeditogr_OBJECTS) $(pkeditogr_LDADD) $(LIBS)
+
 pkegcs$(EXEEXT): $(pkegcs_OBJECTS) $(pkegcs_DEPENDENCIES) $(EXTRA_pkegcs_DEPENDENCIES) 
 	@rm -f pkegcs$(EXEEXT)
-	$(CXXLINK) $(pkegcs_OBJECTS) $(pkegcs_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkegcs_OBJECTS) $(pkegcs_LDADD) $(LIBS)
+
 pkenhance$(EXEEXT): $(pkenhance_OBJECTS) $(pkenhance_DEPENDENCIES) $(EXTRA_pkenhance_DEPENDENCIES) 
 	@rm -f pkenhance$(EXEEXT)
-	$(CXXLINK) $(pkenhance_OBJECTS) $(pkenhance_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkenhance_OBJECTS) $(pkenhance_LDADD) $(LIBS)
+
 pkextract$(EXEEXT): $(pkextract_OBJECTS) $(pkextract_DEPENDENCIES) $(EXTRA_pkextract_DEPENDENCIES) 
 	@rm -f pkextract$(EXEEXT)
-	$(CXXLINK) $(pkextract_OBJECTS) $(pkextract_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkextract_OBJECTS) $(pkextract_LDADD) $(LIBS)
+
 pkfillnodata$(EXEEXT): $(pkfillnodata_OBJECTS) $(pkfillnodata_DEPENDENCIES) $(EXTRA_pkfillnodata_DEPENDENCIES) 
 	@rm -f pkfillnodata$(EXEEXT)
-	$(CXXLINK) $(pkfillnodata_OBJECTS) $(pkfillnodata_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkfillnodata_OBJECTS) $(pkfillnodata_LDADD) $(LIBS)
+
 pkfilter$(EXEEXT): $(pkfilter_OBJECTS) $(pkfilter_DEPENDENCIES) $(EXTRA_pkfilter_DEPENDENCIES) 
 	@rm -f pkfilter$(EXEEXT)
-	$(CXXLINK) $(pkfilter_OBJECTS) $(pkfilter_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkfilter_OBJECTS) $(pkfilter_LDADD) $(LIBS)
+
 pkfilterascii$(EXEEXT): $(pkfilterascii_OBJECTS) $(pkfilterascii_DEPENDENCIES) $(EXTRA_pkfilterascii_DEPENDENCIES) 
 	@rm -f pkfilterascii$(EXEEXT)
-	$(CXXLINK) $(pkfilterascii_OBJECTS) $(pkfilterascii_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkfilterascii_OBJECTS) $(pkfilterascii_LDADD) $(LIBS)
+
 pkfilterdem$(EXEEXT): $(pkfilterdem_OBJECTS) $(pkfilterdem_DEPENDENCIES) $(EXTRA_pkfilterdem_DEPENDENCIES) 
 	@rm -f pkfilterdem$(EXEEXT)
-	$(CXXLINK) $(pkfilterdem_OBJECTS) $(pkfilterdem_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkfilterdem_OBJECTS) $(pkfilterdem_LDADD) $(LIBS)
+
 pkfsann$(EXEEXT): $(pkfsann_OBJECTS) $(pkfsann_DEPENDENCIES) $(EXTRA_pkfsann_DEPENDENCIES) 
 	@rm -f pkfsann$(EXEEXT)
-	$(pkfsann_LINK) $(pkfsann_OBJECTS) $(pkfsann_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(pkfsann_LINK) $(pkfsann_OBJECTS) $(pkfsann_LDADD) $(LIBS)
+
 pkfssvm$(EXEEXT): $(pkfssvm_OBJECTS) $(pkfssvm_DEPENDENCIES) $(EXTRA_pkfssvm_DEPENDENCIES) 
 	@rm -f pkfssvm$(EXEEXT)
-	$(CXXLINK) $(pkfssvm_OBJECTS) $(pkfssvm_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkfssvm_OBJECTS) $(pkfssvm_LDADD) $(LIBS)
+
 pkgetmask$(EXEEXT): $(pkgetmask_OBJECTS) $(pkgetmask_DEPENDENCIES) $(EXTRA_pkgetmask_DEPENDENCIES) 
 	@rm -f pkgetmask$(EXEEXT)
-	$(CXXLINK) $(pkgetmask_OBJECTS) $(pkgetmask_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkgetmask_OBJECTS) $(pkgetmask_LDADD) $(LIBS)
+
 pkinfo$(EXEEXT): $(pkinfo_OBJECTS) $(pkinfo_DEPENDENCIES) $(EXTRA_pkinfo_DEPENDENCIES) 
 	@rm -f pkinfo$(EXEEXT)
-	$(CXXLINK) $(pkinfo_OBJECTS) $(pkinfo_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkinfo_OBJECTS) $(pkinfo_LDADD) $(LIBS)
+
 pkkalman$(EXEEXT): $(pkkalman_OBJECTS) $(pkkalman_DEPENDENCIES) $(EXTRA_pkkalman_DEPENDENCIES) 
 	@rm -f pkkalman$(EXEEXT)
-	$(CXXLINK) $(pkkalman_OBJECTS) $(pkkalman_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkkalman_OBJECTS) $(pkkalman_LDADD) $(LIBS)
+
 pklas2img$(EXEEXT): $(pklas2img_OBJECTS) $(pklas2img_DEPENDENCIES) $(EXTRA_pklas2img_DEPENDENCIES) 
 	@rm -f pklas2img$(EXEEXT)
-	$(CXXLINK) $(pklas2img_OBJECTS) $(pklas2img_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pklas2img_OBJECTS) $(pklas2img_LDADD) $(LIBS)
+
 pkndvi$(EXEEXT): $(pkndvi_OBJECTS) $(pkndvi_DEPENDENCIES) $(EXTRA_pkndvi_DEPENDENCIES) 
 	@rm -f pkndvi$(EXEEXT)
-	$(CXXLINK) $(pkndvi_OBJECTS) $(pkndvi_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkndvi_OBJECTS) $(pkndvi_LDADD) $(LIBS)
+
 pkoptsvm$(EXEEXT): $(pkoptsvm_OBJECTS) $(pkoptsvm_DEPENDENCIES) $(EXTRA_pkoptsvm_DEPENDENCIES) 
 	@rm -f pkoptsvm$(EXEEXT)
-	$(CXXLINK) $(pkoptsvm_OBJECTS) $(pkoptsvm_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkoptsvm_OBJECTS) $(pkoptsvm_LDADD) $(LIBS)
+
 pkpolygonize$(EXEEXT): $(pkpolygonize_OBJECTS) $(pkpolygonize_DEPENDENCIES) $(EXTRA_pkpolygonize_DEPENDENCIES) 
 	@rm -f pkpolygonize$(EXEEXT)
-	$(CXXLINK) $(pkpolygonize_OBJECTS) $(pkpolygonize_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkpolygonize_OBJECTS) $(pkpolygonize_LDADD) $(LIBS)
+
 pkreclass$(EXEEXT): $(pkreclass_OBJECTS) $(pkreclass_DEPENDENCIES) $(EXTRA_pkreclass_DEPENDENCIES) 
 	@rm -f pkreclass$(EXEEXT)
-	$(CXXLINK) $(pkreclass_OBJECTS) $(pkreclass_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkreclass_OBJECTS) $(pkreclass_LDADD) $(LIBS)
+
 pkregann$(EXEEXT): $(pkregann_OBJECTS) $(pkregann_DEPENDENCIES) $(EXTRA_pkregann_DEPENDENCIES) 
 	@rm -f pkregann$(EXEEXT)
-	$(pkregann_LINK) $(pkregann_OBJECTS) $(pkregann_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(pkregann_LINK) $(pkregann_OBJECTS) $(pkregann_LDADD) $(LIBS)
+
 pksetmask$(EXEEXT): $(pksetmask_OBJECTS) $(pksetmask_DEPENDENCIES) $(EXTRA_pksetmask_DEPENDENCIES) 
 	@rm -f pksetmask$(EXEEXT)
-	$(CXXLINK) $(pksetmask_OBJECTS) $(pksetmask_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pksetmask_OBJECTS) $(pksetmask_LDADD) $(LIBS)
+
 pksieve$(EXEEXT): $(pksieve_OBJECTS) $(pksieve_DEPENDENCIES) $(EXTRA_pksieve_DEPENDENCIES) 
 	@rm -f pksieve$(EXEEXT)
-	$(CXXLINK) $(pksieve_OBJECTS) $(pksieve_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pksieve_OBJECTS) $(pksieve_LDADD) $(LIBS)
+
 pkstatascii$(EXEEXT): $(pkstatascii_OBJECTS) $(pkstatascii_DEPENDENCIES) $(EXTRA_pkstatascii_DEPENDENCIES) 
 	@rm -f pkstatascii$(EXEEXT)
-	$(CXXLINK) $(pkstatascii_OBJECTS) $(pkstatascii_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkstatascii_OBJECTS) $(pkstatascii_LDADD) $(LIBS)
+
 pkstatogr$(EXEEXT): $(pkstatogr_OBJECTS) $(pkstatogr_DEPENDENCIES) $(EXTRA_pkstatogr_DEPENDENCIES) 
 	@rm -f pkstatogr$(EXEEXT)
-	$(CXXLINK) $(pkstatogr_OBJECTS) $(pkstatogr_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pkstatogr_OBJECTS) $(pkstatogr_LDADD) $(LIBS)
+
 pksvm$(EXEEXT): $(pksvm_OBJECTS) $(pksvm_DEPENDENCIES) $(EXTRA_pksvm_DEPENDENCIES) 
 	@rm -f pksvm$(EXEEXT)
-	$(CXXLINK) $(pksvm_OBJECTS) $(pksvm_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pksvm_OBJECTS) $(pksvm_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -809,116 +897,116 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/svm.Po at am__quote@
 
 .cc.o:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ $<
 
 .cc.obj:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cc.lo:
- at am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 pkann-pkann.o: pkann.cc
- at am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkann_CXXFLAGS) $(CXXFLAGS) -MT pkann-pkann.o -MD -MP -MF $(DEPDIR)/pkann-pkann.Tpo -c -o pkann-pkann.o `test -f 'pkann.cc' || echo '$(srcdir)/'`pkann.cc
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/pkann-pkann.Tpo $(DEPDIR)/pkann-pkann.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='pkann.cc' object='pkann-pkann.o' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkann_CXXFLAGS) $(CXXFLAGS) -MT pkann-pkann.o -MD -MP -MF $(DEPDIR)/pkann-pkann.Tpo -c -o pkann-pkann.o `test -f 'pkann.cc' || echo '$(srcdir)/'`pkann.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/pkann-pkann.Tpo $(DEPDIR)/pkann-pkann.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='pkann.cc' object='pkann-pkann.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkann_CXXFLAGS) $(CXXFLAGS) -c -o pkann-pkann.o `test -f 'pkann.cc' || echo '$(srcdir)/'`pkann.cc
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkann_CXXFLAGS) $(CXXFLAGS) -c -o pkann-pkann.o `test -f 'pkann.cc' || echo '$(srcdir)/'`pkann.cc
 
 pkann-pkann.obj: pkann.cc
- at am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkann_CXXFLAGS) $(CXXFLAGS) -MT pkann-pkann.obj -MD -MP -MF $(DEPDIR)/pkann-pkann.Tpo -c -o pkann-pkann.obj `if test -f 'pkann.cc'; then $(CYGPATH_W) 'pkann.cc'; else $(CYGPATH_W) '$(srcdir)/pkann.cc'; fi`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/pkann-pkann.Tpo $(DEPDIR)/pkann-pkann.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='pkann.cc' object='pkann-pkann.obj' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkann_CXXFLAGS) $(CXXFLAGS) -MT pkann-pkann.obj -MD -MP -MF $(DEPDIR)/pkann-pkann.Tpo -c -o pkann-pkann.obj `if test -f 'pkann.cc'; then $(CYGPATH_W) 'pkann.cc'; else $(CYGPATH_W) '$(srcdir)/pkann.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/pkann-pkann.Tpo $(DEPDIR)/pkann-pkann.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='pkann.cc' object='pkann-pkann.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkann_CXXFLAGS) $(CXXFLAGS) -c -o pkann-pkann.obj `if test -f 'pkann.cc'; then $(CYGPATH_W) 'pkann.cc'; else $(CYGPATH_W) '$(srcdir)/pkann.cc'; fi`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkann_CXXFLAGS) $(CXXFLAGS) -c -o pkann-pkann.obj `if test -f 'pkann.cc'; then $(CYGPATH_W) 'pkann.cc'; else $(CYGPATH_W) '$(srcdir)/pkann.cc'; fi`
 
 pkfsann-pkfsann.o: pkfsann.cc
- at am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkfsann_CXXFLAGS) $(CXXFLAGS) -MT pkfsann-pkfsann.o -MD -MP -MF $(DEPDIR)/pkfsann-pkfsann.Tpo -c -o pkfsann-pkfsann.o `test -f 'pkfsann.cc' || echo '$(srcdir)/'`pkfsann.cc
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/pkfsann-pkfsann.Tpo $(DEPDIR)/pkfsann-pkfsann.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='pkfsann.cc' object='pkfsann-pkfsann.o' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkfsann_CXXFLAGS) $(CXXFLAGS) -MT pkfsann-pkfsann.o -MD -MP -MF $(DEPDIR)/pkfsann-pkfsann.Tpo -c -o pkfsann-pkfsann.o `test -f 'pkfsann.cc' || echo '$(srcdir)/'`pkfsann.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/pkfsann-pkfsann.Tpo $(DEPDIR)/pkfsann-pkfsann.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='pkfsann.cc' object='pkfsann-pkfsann.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkfsann_CXXFLAGS) $(CXXFLAGS) -c -o pkfsann-pkfsann.o `test -f 'pkfsann.cc' || echo '$(srcdir)/'`pkfsann.cc
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkfsann_CXXFLAGS) $(CXXFLAGS) -c -o pkfsann-pkfsann.o `test -f 'pkfsann.cc' || echo '$(srcdir)/'`pkfsann.cc
 
 pkfsann-pkfsann.obj: pkfsann.cc
- at am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkfsann_CXXFLAGS) $(CXXFLAGS) -MT pkfsann-pkfsann.obj -MD -MP -MF $(DEPDIR)/pkfsann-pkfsann.Tpo -c -o pkfsann-pkfsann.obj `if test -f 'pkfsann.cc'; then $(CYGPATH_W) 'pkfsann.cc'; else $(CYGPATH_W) '$(srcdir)/pkfsann.cc'; fi`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/pkfsann-pkfsann.Tpo $(DEPDIR)/pkfsann-pkfsann.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='pkfsann.cc' object='pkfsann-pkfsann.obj' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkfsann_CXXFLAGS) $(CXXFLAGS) -MT pkfsann-pkfsann.obj -MD -MP -MF $(DEPDIR)/pkfsann-pkfsann.Tpo -c -o pkfsann-pkfsann.obj `if test -f 'pkfsann.cc'; then $(CYGPATH_W) 'pkfsann.cc'; else $(CYGPATH_W) '$(srcdir)/pkfsann.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/pkfsann-pkfsann.Tpo $(DEPDIR)/pkfsann-pkfsann.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='pkfsann.cc' object='pkfsann-pkfsann.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkfsann_CXXFLAGS) $(CXXFLAGS) -c -o pkfsann-pkfsann.obj `if test -f 'pkfsann.cc'; then $(CYGPATH_W) 'pkfsann.cc'; else $(CYGPATH_W) '$(srcdir)/pkfsann.cc'; fi`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkfsann_CXXFLAGS) $(CXXFLAGS) -c -o pkfsann-pkfsann.obj `if test -f 'pkfsann.cc'; then $(CYGPATH_W) 'pkfsann.cc'; else $(CYGPATH_W) '$(srcdir)/pkfsann.cc'; fi`
 
 svm.o: $(top_srcdir)/src/algorithms/svm.cpp
- at am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT svm.o -MD -MP -MF $(DEPDIR)/svm.Tpo -c -o svm.o `test -f '$(top_srcdir)/src/algorithms/svm.cpp' || echo '$(srcdir)/'`$(top_srcdir)/src/algorithms/svm.cpp
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/svm.Tpo $(DEPDIR)/svm.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$(top_srcdir)/src/algorithms/svm.cpp' object='svm.o' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT svm.o -MD -MP -MF $(DEPDIR)/svm.Tpo -c -o svm.o `test -f '$(top_srcdir)/src/algorithms/svm.cpp' || echo '$(srcdir)/'`$(top_srcdir)/src/algorithms/svm.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/svm.Tpo $(DEPDIR)/svm.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$(top_srcdir)/src/algorithms/svm.cpp' object='svm.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o svm.o `test -f '$(top_srcdir)/src/algorithms/svm.cpp' || echo '$(srcdir)/'`$(top_srcdir)/src/algorithms/svm.cpp
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o svm.o `test -f '$(top_srcdir)/src/algorithms/svm.cpp' || echo '$(srcdir)/'`$(top_srcdir)/src/algorithms/svm.cpp
 
 svm.obj: $(top_srcdir)/src/algorithms/svm.cpp
- at am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT svm.obj -MD -MP -MF $(DEPDIR)/svm.Tpo -c -o svm.obj `if test -f '$(top_srcdir)/src/algorithms/svm.cpp'; then $(CYGPATH_W) '$(top_srcdir)/src/algorithms/svm.cpp'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/algorithms/svm.cpp'; fi`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/svm.Tpo $(DEPDIR)/svm.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$(top_srcdir)/src/algorithms/svm.cpp' object='svm.obj' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT svm.obj -MD -MP -MF $(DEPDIR)/svm.Tpo -c -o svm.obj `if test -f '$(top_srcdir)/src/algorithms/svm.cpp'; then $(CYGPATH_W) '$(top_srcdir)/src/algorithms/svm.cpp'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/algorithms/svm.cpp'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/svm.Tpo $(DEPDIR)/svm.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$(top_srcdir)/src/algorithms/svm.cpp' object='svm.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o svm.obj `if test -f '$(top_srcdir)/src/algorithms/svm.cpp'; then $(CYGPATH_W) '$(top_srcdir)/src/algorithms/svm.cpp'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/algorithms/svm.cpp'; fi`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o svm.obj `if test -f '$(top_srcdir)/src/algorithms/svm.cpp'; then $(CYGPATH_W) '$(top_srcdir)/src/algorithms/svm.cpp'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/algorithms/svm.cpp'; fi`
 
 ImgRegression.o: $(top_srcdir)/src/algorithms/ImgRegression.cc
- at am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ImgRegression.o -MD -MP -MF $(DEPDIR)/ImgRegression.Tpo -c -o ImgRegression.o `test -f '$(top_srcdir)/src/algorithms/ImgRegression.cc' || echo '$(srcdir)/'`$(top_srcdir)/src/algorithms/ImgRegression.cc
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/ImgRegression.Tpo $(DEPDIR)/ImgRegression.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$(top_srcdir)/src/algorithms/ImgRegression.cc' object='ImgRegression.o' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ImgRegression.o -MD -MP -MF $(DEPDIR)/ImgRegression.Tpo -c -o ImgRegression.o `test -f '$(top_srcdir)/src/algorithms/ImgRegression.cc' || echo '$(srcdir)/'`$(top_srcdir)/src/algorithms/ImgRegression.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/ImgRegression.Tpo $(DEPDIR)/ImgRegression.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$(top_srcdir)/src/algorithms/ImgRegression.cc' object='ImgRegression.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ImgRegression.o `test -f '$(top_srcdir)/src/algorithms/ImgRegression.cc' || echo '$(srcdir)/'`$(top_srcdir)/src/algorithms/ImgRegression.cc
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ImgRegression.o `test -f '$(top_srcdir)/src/algorithms/ImgRegression.cc' || echo '$(srcdir)/'`$(top_srcdir)/src/algorithms/ImgRegression.cc
 
 ImgRegression.obj: $(top_srcdir)/src/algorithms/ImgRegression.cc
- at am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ImgRegression.obj -MD -MP -MF $(DEPDIR)/ImgRegression.Tpo -c -o ImgRegression.obj `if test -f '$(top_srcdir)/src/algorithms/ImgRegression.cc'; then $(CYGPATH_W) '$(top_srcdir)/src/algorithms/ImgRegression.cc'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/algorithms/ImgRegression.cc'; fi`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/ImgRegression.Tpo $(DEPDIR)/ImgRegression.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$(top_srcdir)/src/algorithms/ImgRegression.cc' object='ImgRegression.obj' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ImgRegression.obj -MD -MP -MF $(DEPDIR)/ImgRegression.Tpo -c -o ImgRegression.obj `if test -f '$(top_srcdir)/src/algorithms/ImgRegression.cc'; then $(CYGPATH_W) '$(top_srcdir)/src/algorithms/ImgRegression.cc'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/algorithms/ImgRegression.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/ImgRegression.Tpo $(DEPDIR)/ImgRegression.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$(top_srcdir)/src/algorithms/ImgRegression.cc' object='ImgRegression.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ImgRegression.obj `if test -f '$(top_srcdir)/src/algorithms/ImgRegression.cc'; then $(CYGPATH_W) '$(top_srcdir)/src/algorithms/ImgRegression.cc'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/algorithms/ImgRegression.cc'; fi`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ImgRegression.obj `if test -f '$(top_srcdir)/src/algorithms/ImgRegression.cc'; then $(CYGPATH_W) '$(top_srcdir)/src/algorithms/ImgRegression.cc'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/algorithms/ImgRegression.cc'; fi`
 
 pkregann-pkregann.o: pkregann.cc
- at am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkregann_CXXFLAGS) $(CXXFLAGS) -MT pkregann-pkregann.o -MD -MP -MF $(DEPDIR)/pkregann-pkregann.Tpo -c -o pkregann-pkregann.o `test -f 'pkregann.cc' || echo '$(srcdir)/'`pkregann.cc
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/pkregann-pkregann.Tpo $(DEPDIR)/pkregann-pkregann.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='pkregann.cc' object='pkregann-pkregann.o' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkregann_CXXFLAGS) $(CXXFLAGS) -MT pkregann-pkregann.o -MD -MP -MF $(DEPDIR)/pkregann-pkregann.Tpo -c -o pkregann-pkregann.o `test -f 'pkregann.cc' || echo '$(srcdir)/'`pkregann.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/pkregann-pkregann.Tpo $(DEPDIR)/pkregann-pkregann.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='pkregann.cc' object='pkregann-pkregann.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkregann_CXXFLAGS) $(CXXFLAGS) -c -o pkregann-pkregann.o `test -f 'pkregann.cc' || echo '$(srcdir)/'`pkregann.cc
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkregann_CXXFLAGS) $(CXXFLAGS) -c -o pkregann-pkregann.o `test -f 'pkregann.cc' || echo '$(srcdir)/'`pkregann.cc
 
 pkregann-pkregann.obj: pkregann.cc
- at am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkregann_CXXFLAGS) $(CXXFLAGS) -MT pkregann-pkregann.obj -MD -MP -MF $(DEPDIR)/pkregann-pkregann.Tpo -c -o pkregann-pkregann.obj `if test -f 'pkregann.cc'; then $(CYGPATH_W) 'pkregann.cc'; else $(CYGPATH_W) '$(srcdir)/pkregann.cc'; fi`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/pkregann-pkregann.Tpo $(DEPDIR)/pkregann-pkregann.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='pkregann.cc' object='pkregann-pkregann.obj' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkregann_CXXFLAGS) $(CXXFLAGS) -MT pkregann-pkregann.obj -MD -MP -MF $(DEPDIR)/pkregann-pkregann.Tpo -c -o pkregann-pkregann.obj `if test -f 'pkregann.cc'; then $(CYGPATH_W) 'pkregann.cc'; else $(CYGPATH_W) '$(srcdir)/pkregann.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/pkregann-pkregann.Tpo $(DEPDIR)/pkregann-pkregann.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='pkregann.cc' object='pkregann-pkregann.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkregann_CXXFLAGS) $(CXXFLAGS) -c -o pkregann-pkregann.obj `if test -f 'pkregann.cc'; then $(CYGPATH_W) 'pkregann.cc'; else $(CYGPATH_W) '$(srcdir)/pkregann.cc'; fi`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pkregann_CXXFLAGS) $(CXXFLAGS) -c -o pkregann-pkregann.obj `if test -f 'pkregann.cc'; then $(CYGPATH_W) 'pkregann.cc'; else $(CYGPATH_W) '$(srcdir)/pkregann.cc'; fi`
 
 .cpp.o:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ $<
 
 .cpp.obj:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cpp.lo:
- at am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -926,26 +1014,15 @@ mostlyclean-libtool:
 clean-libtool:
 	-rm -rf .libs _libs
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -957,15 +1034,11 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -974,6 +1047,21 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -1117,19 +1205,19 @@ uninstall-am: uninstall-binPROGRAMS
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
-	clean-generic clean-libtool ctags distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-binPROGRAMS install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-html \
-	install-html-am install-info install-info-am install-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-binPROGRAMS
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
+	clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \
+	ctags ctags-am distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-binPROGRAMS \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-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 tags-am uninstall uninstall-am uninstall-binPROGRAMS
 
 ###############################################################################
 
diff --git a/src/apps/pkann.cc b/src/apps/pkann.cc
index bccd66d..64c34e4 100644
--- a/src/apps/pkann.cc
+++ b/src/apps/pkann.cc
@@ -45,9 +45,9 @@ int main(int argc, char *argv[])
   Optionpk<unsigned int> balance_opt("bal", "balance", "balance the input data to this number of samples for each class", 0);
   Optionpk<bool> random_opt("random", "random", "in case of balance, randomize input data", true,2);
   Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account (0: consider all classes)", 0);
-  Optionpk<double> start_opt("s", "start", "start band sequence number",0); 
-  Optionpk<double> end_opt("e", "end", "end band sequence number (set to 0 to include bands)", 0); 
   Optionpk<short> band_opt("b", "band", "band index (starting from 0, either use band option or use start to end)");
+  Optionpk<double> bstart_opt("bs", "bstart", "start band sequence number",0); 
+  Optionpk<double> bend_opt("be", "bend", "end band sequence number (set to 0 to include bands)", 0); 
   Optionpk<double> offset_opt("\0", "offset", "offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
   Optionpk<unsigned short> aggreg_opt("a", "aggreg", "how to combine aggregated classifiers, see also rc option (1: sum rule, 2: max rule).",1);
@@ -89,9 +89,9 @@ int main(int argc, char *argv[])
     balance_opt.retrieveOption(argc,argv);
     random_opt.retrieveOption(argc,argv);
     minSize_opt.retrieveOption(argc,argv);
-    start_opt.retrieveOption(argc,argv);
-    end_opt.retrieveOption(argc,argv);
     band_opt.retrieveOption(argc,argv);
+    bstart_opt.retrieveOption(argc,argv);
+    bend_opt.retrieveOption(argc,argv);
     offset_opt.retrieveOption(argc,argv);
     scale_opt.retrieveOption(argc,argv);
     aggreg_opt.retrieveOption(argc,argv);
@@ -222,7 +222,7 @@ int main(int argc, char *argv[])
         if(band_opt.size())
           totalSamples=trainingReaderBag.readDataImageOgr(trainingMap,fields,band_opt,label_opt[0],tlayer_opt,verbose_opt[0]);
         else
-          totalSamples=trainingReaderBag.readDataImageOgr(trainingMap,fields,start_opt[0],end_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
+          totalSamples=trainingReaderBag.readDataImageOgr(trainingMap,fields,bstart_opt[0],bend_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
         if(trainingMap.size()<2){
           string errorstring="Error: could not read at least two classes from training file, did you provide class labels in training sample (see option label)?";
           throw(errorstring);
@@ -723,7 +723,7 @@ int main(int argc, char *argv[])
           }
         }
         else{
-          for(int iband=start_opt[0];iband<start_opt[0]+nband;++iband){
+          for(int iband=bstart_opt[0];iband<bstart_opt[0]+nband;++iband){
             if(verbose_opt[0]==2)
               std::cout << "reading band " << iband << std::endl;
             assert(iband>=0);
diff --git a/src/apps/pkcomposite.cc b/src/apps/pkcomposite.cc
index f39ca56..04e9897 100644
--- a/src/apps/pkcomposite.cc
+++ b/src/apps/pkcomposite.cc
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
   Optionpk<double>  uly_opt("uly", "uly", "Upper left y value bounding box", 0.0);
   Optionpk<double>  lrx_opt("lrx", "lrx", "Lower right x value bounding box", 0.0);
   Optionpk<double>  lry_opt("lry", "lry", "Lower right y value bounding box", 0.0);
-  Optionpk<string> crule_opt("cr", "crule", "Composite rule for mosaic (overwrite, maxndvi, maxband, minband, mean, mode (only for byte images), median, sum", "overwrite");
+  Optionpk<string> crule_opt("cr", "crule", "Composite rule (overwrite, maxndvi, maxband, minband, mean, mode (only for byte images), median, sum", "overwrite");
   Optionpk<int> ruleBand_opt("cb", "cband", "band index used for the composite rule (e.g., for ndvi, use --cband=0 --cband=1 with 0 and 1 indices for red and nir band respectively", 0);
   Optionpk<double> srcnodata_opt("srcnodata", "srcnodata", "invalid value for input image", 0);
   Optionpk<int> bndnodata_opt("bndnodata", "bndnodata", "Bands in input image to check if pixel is valid (used for srcnodata, min and max options)", 0);
@@ -58,10 +58,10 @@ int main(int argc, char *argv[])
   Optionpk<string>  oformat_opt("of", "oformat", "Output image format (see also gdal_translate). Empty string: inherit from input image");
   Optionpk<string> option_opt("co", "co", "Creation option for output file. Multiple options can be specified.");
   Optionpk<string>  projection_opt("a_srs", "a_srs", "Override the spatial reference for the output file (leave blank to copy from input file, use epsg:3035 to use European projection and force to European grid");
-  Optionpk<bool> file_opt("file", "file", "write number of observations for each pixels as additional layer in mosaic", false);
-  Optionpk<short> weight_opt("w", "weight", "Weights (type: short) for the mosaic, use one weight for each input file in same order as input files are provided). Use value 1 for equal weights.", 1);
-  Optionpk<short> class_opt("c", "class", "classes for multi-band output image: each band represents the number of observations for one specific class. Use value 0 for no multi-band output image).", 0);
-  Optionpk<string>  colorTable_opt("ct", "ct", "color table (file with 5 columns: id R G B ALFA (0: transparent, 255: solid)");
+  Optionpk<bool> file_opt("file", "file", "write number of observations for each pixels as additional layer in composite", false);
+  Optionpk<short> weight_opt("w", "weight", "Weights (type: short) for the composite, use one weight for each input file in same order as input files are provided). Use value 1 for equal weights.", 1);
+  Optionpk<short> class_opt("c", "class", "classes for multi-band output image: each band represents the number of observations for one specific class. Use value 0 for no multi-band output image.", 0);
+  Optionpk<string>  colorTable_opt("ct", "ct", "color table file with 5 columns: id R G B ALFA (0: transparent, 255: solid)");
   Optionpk<string>  description_opt("d", "description", "Set image description");
   Optionpk<bool>  verbose_opt("v", "verbose", "verbose", false);
 
@@ -228,7 +228,7 @@ int main(int argc, char *argv[])
     double theULX, theULY, theLRX, theLRY;
     imgReader.getBoundingBox(theULX,theULY,theLRX,theLRY);
     if(theLRY>theULY){
-      cerr << "Error: " << input_opt[ifile] << " is not georeferenced, only referenced images are supported for pkmosaic " << endl;
+      cerr << "Error: " << input_opt[ifile] << " is not georeferenced, only referenced images are supported for pkcomposite " << endl;
       exit(1);
     }
     if(verbose_opt[0])
@@ -238,31 +238,31 @@ int main(int argc, char *argv[])
         switch(cruleMap[crule_opt[0]]){
         default:
         case(crule::overwrite):
-          cout << "Mosaic rule: overwrite" << endl;
+          cout << "Composite rule: overwrite" << endl;
           break;
         case(crule::maxndvi):
-          cout << "Mosaic rule: max ndvi" << endl;
+          cout << "Composite rule: max ndvi" << endl;
           break;
         case(crule::maxband):
-          cout << "Mosaic rule: max band" << endl;
+          cout << "Composite rule: max band" << endl;
           break;
         case(crule::minband):
-          cout << "Mosaic rule: min band" << endl;
+          cout << "Composite rule: min band" << endl;
           break;
         case(crule::validband):
-          cout << "Mosaic rule: valid band" << endl;
+          cout << "Composite rule: valid band" << endl;
           break;
         case(crule::mean):
-          cout << "Mosaic rule: mean value" << endl;
+          cout << "Composite rule: mean value" << endl;
           break;
         case(crule::mode):
-          cout << "Mosaic rule: max voting (only for byte images)" << endl;
+          cout << "Composite rule: max voting (only for byte images)" << endl;
           break;
         case(crule::median):
-          cout << "Mosaic rule: median" << endl;
+          cout << "Composite rule: median" << endl;
           break;
         case(crule::sum):
-          cout << "Mosaic rule: sum" << endl;
+          cout << "Composite rule: sum" << endl;
           break;
         }
       }
@@ -362,10 +362,10 @@ int main(int argc, char *argv[])
   }
 
   if(verbose_opt[0])
-    cout << "bounding box mosaic image (ULX ULY LRX LRY): " << fixed << setprecision(6) << minULX << " " << maxULY << " " << maxLRX << " " << minLRY << endl;
+    cout << "bounding box composite image (ULX ULY LRX LRY): " << fixed << setprecision(6) << minULX << " " << maxULY << " " << maxLRX << " " << minLRY << endl;
   //initialize image
   if(verbose_opt[0])
-    cout << "initializing mosaic image..." << endl;
+    cout << "initializing composite image..." << endl;
 //   double dcol=(maxLRX-minULX+dx-1)/dx;
 //   double drow=(maxULY-minLRY+dy-1)/dy;
 //   int ncol=static_cast<int>(dcol);
@@ -375,7 +375,7 @@ int main(int argc, char *argv[])
   int nrow=ceil((maxULY-minLRY)/dy);
 
   if(verbose_opt[0])
-    cout << "mosaic image dim (nrow x ncol): " << nrow << " x " << ncol << endl;
+    cout << "composite image dim (nrow x ncol): " << nrow << " x " << ncol << endl;
   ImgWriterGdal imgWriter;
   while(weight_opt.size()<input_opt.size())
     weight_opt.push_back(weight_opt[0]);
@@ -430,9 +430,9 @@ int main(int argc, char *argv[])
     else if(theColorTable)
       imgWriter.setColorTable(theColorTable);
   }
-  //create mosaic image
+  //create composite image
   if(verbose_opt[0])
-     cout << "creating mosaic image" << endl;
+     cout << "creating composite image" << endl;
   Vector2d<double> writeBuffer(nband,imgWriter.nrOfCol());
   vector<short> fileBuffer(ncol);//holds the number of used files
   Vector2d<short> maxBuffer;//buffer used for maximum voting
@@ -627,8 +627,8 @@ int main(int argc, char *argv[])
                     val_new=(readCol-0.5-lowerCol)*readBuffer[iband][upperCol-startCol]+(1-readCol+0.5+lowerCol)*readBuffer[iband][lowerCol-startCol];
                     writeBuffer[iband][ib]=val_new;
                   }
-                  // fileBuffer[ib]=ifile;
-                  ++fileBuffer[ib];
+                  fileBuffer[ib]=ifile;
+                  // ++fileBuffer[ib];
                 }
                 break;
               default:
@@ -642,8 +642,8 @@ int main(int argc, char *argv[])
                     val_new=readBuffer[iband][readCol-startCol];
                     writeBuffer[iband][ib]=val_new;
                   }
-                  ++fileBuffer[ib];
-                  // fileBuffer[ib]=ifile;
+                  fileBuffer[ib]=ifile;
+                  // ++fileBuffer[ib];
                 }
                 break;
               }
diff --git a/src/apps/pkcrop.cc b/src/apps/pkcrop.cc
index 2684cd8..d926b91 100644
--- a/src/apps/pkcrop.cc
+++ b/src/apps/pkcrop.cc
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
   Optionpk<double>  nodata_opt("nodata", "nodata", "Nodata value to put in image if out of bounds.");
   Optionpk<string>  resample_opt("r", "resampling-method", "Resampling method (near: nearest neighbor, bilinear: bi-linear interpolation).", "near");
   Optionpk<string>  description_opt("d", "description", "Set image description");
-  Optionpk<bool>  verbose_opt("v", "verbose", "verbose", false);
+  Optionpk<short>  verbose_opt("v", "verbose", "verbose", 0);
 
   bool doProcess;//stop process when program was invoked with help option (-h --help)
   try{
@@ -479,7 +479,7 @@ int main(int argc, char *argv[])
 	    writeBuffer.push_back(nodataValue);
 	}
 	else{
-	  if(verbose_opt[0])
+	  if(verbose_opt[0]>1)
 	    cout << "reading row: " << readRow << endl;
 	  try{
             if(endCol<imgReader.nrOfCol()-1)
diff --git a/src/apps/pkdumpogr.cc b/src/apps/pkdumpogr.cc
index 44b1239..2a4e305 100644
--- a/src/apps/pkdumpogr.cc
+++ b/src/apps/pkdumpogr.cc
@@ -28,6 +28,7 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 int main(int argc, char *argv[])
 {
   Optionpk<string> input_opt("i", "input", "Input shape file");
+  Optionpk<string> layer_opt("ln", "lname", "Layer name(s) in sample (leave empty to select all)");
   Optionpk<string> output_opt("o", "output", "Output ASCII file");
   Optionpk<string> attribute_opt("n", "name", "names of the attributes to select. Each attribute is stored in a separate band. Default is ALL: write all attributes", "ALL");
   Optionpk<bool> pos_opt("pos","pos","include position (x and y)",false);
@@ -37,6 +38,7 @@ int main(int argc, char *argv[])
   bool doProcess;//stop process when program was invoked with help option (-h --help)
   try{
     doProcess=input_opt.retrieveOption(argc,argv);
+    layer_opt.retrieveOption(argc,argv);
     output_opt.retrieveOption(argc,argv);
     attribute_opt.retrieveOption(argc,argv);
     pos_opt.retrieveOption(argc,argv);
@@ -65,124 +67,143 @@ int main(int argc, char *argv[])
     outputFile.open(output_opt[0].c_str(),ios::out);
 
   ImgReaderOgr inputReader(input_opt[0]);
-  if(attribute_opt[0]!="ALL"){
-    vector<double> xvector;
-    vector<double> yvector;
-    if(inputReader.getGeometryType()==wkbPoint)
-      inputReader.readXY(xvector,yvector);
-    Vector2d<std::string> theData(attribute_opt.size());
-    for(int ifield=0;ifield<attribute_opt.size();++ifield){
-      if(verbose_opt[0])
-        cout << "field: " << ifield << endl;
-      theData[ifield].clear();
-      inputReader.readData(theData[ifield],OFTReal,attribute_opt[ifield],0,verbose_opt[0]);
-    }
-    if(verbose_opt[0]){
-      std::cout << "number of fields: " << theData.size() << std::endl;
-      std::cout << "number of samples: " << theData[0].size() << std::endl;
-    }
-    if(transpose_opt[0]){
-      if(pos_opt[0]&&(inputReader.getGeometryType()==wkbPoint)){
-        if(output_opt.size()){
-          outputFile << "X" << " ";
-          for(int isample=0;isample<xvector.size();++isample){
-            outputFile << xvector[isample];
-            if(isample<xvector.size()-1)
-              outputFile << " ";
-            else
-              outputFile << std::endl;
-          }
-          outputFile << "Y" << " ";
-          for(int isample=0;isample<yvector.size();++isample){
-            outputFile << yvector[isample];
-            if(isample<yvector.size()-1)
-              outputFile << " ";
-            else
-              outputFile << std::endl;
-          }
-        }
-        else{
-          std::cout << "X" << " ";
-          for(int isample=0;isample<xvector.size();++isample){
-            std::cout << xvector[isample];
-            if(isample<xvector.size()-1)
-              std::cout << " ";
-            else
-              std::cout << std::endl;
-          }
-          std::cout << "Y" << " ";
-          for(int isample=0;isample<yvector.size();++isample){
-            std::cout << yvector[isample];
-            if(isample<yvector.size()-1)
-              std::cout << " ";
-            else
-              std::cout << std::endl;
-          }
-        }
+
+  //support multiple layers
+  int nlayerRead=inputReader.getDataSource()->GetLayerCount();
+  if(verbose_opt[0])
+    cout << "number of layers: " << nlayerRead << endl;
+      
+  for(int ilayer=0;ilayer<nlayerRead;++ilayer){
+    OGRLayer *readLayer=inputReader.getLayer(ilayer);
+    string currentLayername=readLayer->GetName();
+    if(layer_opt.size())
+      if(find(layer_opt.begin(),layer_opt.end(),currentLayername)==layer_opt.end())
+	continue;
+    if(verbose_opt[0])
+      cout << "processing layer " << currentLayername << endl;
+    if(layer_opt.size())
+      cout << " --lname " << currentLayername;
+      
+    if(attribute_opt[0]!="ALL"){
+      vector<double> xvector;
+      vector<double> yvector;
+      if(inputReader.getGeometryType()==wkbPoint)
+	inputReader.readXY(xvector,yvector);
+      Vector2d<std::string> theData(attribute_opt.size());
+      for(int ifield=0;ifield<attribute_opt.size();++ifield){
+	if(verbose_opt[0])
+	  cout << "field: " << ifield << endl;
+	theData[ifield].clear();
+	inputReader.readData(theData[ifield],OFTReal,attribute_opt[ifield],ilayer,verbose_opt[0]);
+      }
+      if(verbose_opt[0]){
+	std::cout << "number of fields: " << theData.size() << std::endl;
+	std::cout << "number of samples: " << theData[0].size() << std::endl;
       }
-      for(int ifield=0;ifield<theData.size();++ifield){
-        if(output_opt.size()){
-          outputFile << ifield << " ";
-          for(int isample=0;isample<theData[0].size();++isample){
-            outputFile << theData[ifield][isample];
-            if(isample<theData[0].size()-1)
-              outputFile << " ";
-            else
-              outputFile << std::endl;
-          }
-        }
-        else{
-          std::cout << ifield << " ";
-          for(int isample=0;isample<theData[0].size();++isample){
-            std::cout << theData[ifield][isample];
-            if(isample<theData[0].size()-1)
-              std::cout << " ";
-            else
-              std::cout << std::endl;
-          }
-        }
+      if(transpose_opt[0]){
+	if(pos_opt[0]&&(inputReader.getGeometryType()==wkbPoint)){
+	  if(output_opt.size()){
+	    outputFile << "X" << " ";
+	    for(int isample=0;isample<xvector.size();++isample){
+	      outputFile << xvector[isample];
+	      if(isample<xvector.size()-1)
+		outputFile << " ";
+	      else
+		outputFile << std::endl;
+	    }
+	    outputFile << "Y" << " ";
+	    for(int isample=0;isample<yvector.size();++isample){
+	      outputFile << yvector[isample];
+	      if(isample<yvector.size()-1)
+		outputFile << " ";
+	      else
+		outputFile << std::endl;
+	    }
+	  }
+	  else{
+	    std::cout << "X" << " ";
+	    for(int isample=0;isample<xvector.size();++isample){
+	      std::cout << xvector[isample];
+	      if(isample<xvector.size()-1)
+		std::cout << " ";
+	      else
+		std::cout << std::endl;
+	    }
+	    std::cout << "Y" << " ";
+	    for(int isample=0;isample<yvector.size();++isample){
+	      std::cout << yvector[isample];
+	      if(isample<yvector.size()-1)
+		std::cout << " ";
+	      else
+		std::cout << std::endl;
+	    }
+	  }
+	}
+	for(int ifield=0;ifield<theData.size();++ifield){
+	  if(output_opt.size()){
+	    outputFile << ifield << " ";
+	    for(int isample=0;isample<theData[0].size();++isample){
+	      outputFile << theData[ifield][isample];
+	      if(isample<theData[0].size()-1)
+		outputFile << " ";
+	      else
+		outputFile << std::endl;
+	    }
+	  }
+	  else{
+	    std::cout << ifield << " ";
+	    for(int isample=0;isample<theData[0].size();++isample){
+	      std::cout << theData[ifield][isample];
+	      if(isample<theData[0].size()-1)
+		std::cout << " ";
+	      else
+		std::cout << std::endl;
+	    }
+	  }
+	}
       }
+      else{
+	for(int isample=0;isample<theData[0].size();++isample){
+	  if(output_opt.size()){
+	    outputFile << isample << " ";
+	    if(pos_opt[0])
+	      outputFile << xvector[isample] << " " << yvector[isample] << " ";
+	    for(int ifield=0;ifield<theData.size();++ifield){
+	      outputFile << theData[ifield][isample];
+	      if(ifield<theData.size()-1)
+		outputFile << " ";
+	      else
+		outputFile << std::endl;
+	    }
+	  }
+	  else{
+	    std::cout << isample << " ";
+	    if(pos_opt[0])
+	      std::cout  << xvector[isample] << " " << yvector[isample] << " ";
+	    for(int ifield=0;ifield<theData.size();++ifield){
+	      std::cout << theData[ifield][isample];
+	      if(ifield<theData.size()-1)
+		std::cout << " ";
+	      else
+		std::cout << std::endl;
+	    }
+	  }
+	}
+      }
+      if(output_opt.size())
+	outputFile.close();
     }
     else{
-      for(int isample=0;isample<theData[0].size();++isample){
-        if(output_opt.size()){
-          outputFile << isample << " ";
-          if(pos_opt[0])
-            outputFile << xvector[isample] << " " << yvector[isample] << " ";
-          for(int ifield=0;ifield<theData.size();++ifield){
-            outputFile << theData[ifield][isample];
-            if(ifield<theData.size()-1)
-              outputFile << " ";
-            else
-              outputFile << std::endl;
-          }
-        }
-        else{
-          std::cout << isample << " ";
-          if(pos_opt[0])
-            std::cout  << xvector[isample] << " " << yvector[isample] << " ";
-          for(int ifield=0;ifield<theData.size();++ifield){
-            std::cout << theData[ifield][isample];
-            if(ifield<theData.size()-1)
-              std::cout << " ";
-            else
-              std::cout << std::endl;
-          }
-        }
+      if(output_opt.size()){
+	ofstream outputFile(output_opt[0].c_str(),ios::out);
+	outputFile << imgReader;
+	outputFile.close();
       }
+      else
+	std::cout << imgReader;
     }
-    if(output_opt.size())
-      outputFile.close();
-  }
-  else{
-    if(output_opt.size()){
-      ofstream outputFile(output_opt[0].c_str(),ios::out);
-      outputFile << imgReader;
-      outputFile.close();
-    }
-    else
-      std::cout << imgReader;
   }
+  inputReader.close();
   imgReader.close();
 }
 
diff --git a/src/apps/pkextract.cc b/src/apps/pkextract.cc
index 51646cc..8ec5bd6 100644
--- a/src/apps/pkextract.cc
+++ b/src/apps/pkextract.cc
@@ -35,7 +35,7 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #endif
 
 namespace rule{
-  enum RULE_TYPE {point=0, mean=1, proportion=2, custom=3, minimum=4, maximum=5, maxvote=6, centroid=7, sum=8, median=9};
+  enum RULE_TYPE {point=0, mean=1, proportion=2, custom=3, min=4, max=5, mode=6, centroid=7, sum=8, median=9, stdev=10};
 }
 
 using namespace std;
@@ -43,32 +43,29 @@ using namespace std;
 int main(int argc, char *argv[])
 {
   Optionpk<string> image_opt("i", "input", "Raster input dataset containing band information");
-  Optionpk<string> sample_opt("s", "sample", "OGR vector file with features to be extracted from input data. Output will contain features with input band information included. Sample image can also be GDAL raster dataset.");
+  Optionpk<string> sample_opt("s", "sample", "OGR vector dataset with features to be extracted from input data. Output will contain features with input band information included. Sample image can also be GDAL raster dataset.");
   Optionpk<string> layer_opt("ln", "ln", "Layer name(s) in sample (leave empty to select all)");
-  Optionpk<string> output_opt("o", "output", "Output sample file (image file)");
-  Optionpk<int> class_opt("c", "class", "Class(es) to extract from input sample image. Leave empty to extract all valid data pixels from sample file. Make sure to set classes if rule is set to maxvote or proportion");
-  Optionpk<float> threshold_opt("t", "threshold", "Probability threshold for selecting samples (randomly). Provide probability in percentage (>0) or absolute (<0). Use a single threshold for vector sample files. If using raster land cover maps as a sample file, you can provide a threshold value for each class (e.g. -t 80 -t 60). Use value 100 to select all pixels for selected class(es)", 100);
-  Optionpk<string> ogrformat_opt("f", "f", "Output sample file format","SQLite");
+  Optionpk<unsigned int> random_opt("rand", "random", "Create simple random sample of points. Provide number of points to generate");
+  Optionpk<double> grid_opt("grid", "grid", "Create systematic grid of points. Provide cell grid size (in projected units, e.g,. m)");
+  Optionpk<string> output_opt("o", "output", "Output sample dataset");
+  Optionpk<int> class_opt("c", "class", "Class(es) to extract from input sample image. Leave empty to extract all valid data pixels from sample dataset. Make sure to set classes if rule is set to mode or proportion");
+  Optionpk<float> threshold_opt("t", "threshold", "Probability threshold for selecting samples (randomly). Provide probability in percentage (>0) or absolute (<0). Use a single threshold for vector sample datasets. If using raster land cover maps as a sample dataset, you can provide a threshold value for each class (e.g. -t 80 -t 60). Use value 100 to select all pixels for selected class(es)", 100);
+  Optionpk<string> ogrformat_opt("f", "f", "Output sample dataset format","SQLite");
   Optionpk<string> ftype_opt("ft", "ftype", "Field type (only Real or Integer)", "Real");
   Optionpk<string> ltype_opt("lt", "ltype", "Label type: In16 or String", "Integer");
-  Optionpk<bool> polygon_opt("polygon", "polygon", "Create OGRPolygon as geometry instead of OGRPoint. Only valid if sample features are polygons.", false);
-  Optionpk<int> band_opt("b", "band", "Band index(es) to extract. Use -1 to use all bands)", -1);
-  Optionpk<string> rule_opt("r", "rule", "Rule how to report image information per feature (only for vector sample). point (value at each point or at centroid if polygon), centroid, mean (of polygon), median (of polygon), proportion, minimum (of polygon), maximum (of polygon), maxvote, sum.", "point");
+  Optionpk<bool> polygon_opt("polygon", "polygon", "Create OGRPolygon as geometry instead of OGRPoint.", false);
+  Optionpk<int> band_opt("b", "band", "Band index(es) to extract. Leave empty to use all bands");
+  Optionpk<string> rule_opt("r", "rule", "Rule how to report image information per feature (only for vector sample). point (value at each point or at centroid if polygon), centroid, mean, stdev, median, proportion, min, max, mode, sum.", "centroid");
   Optionpk<double> srcnodata_opt("srcnodata", "srcnodata", "Invalid value(s) for input image");
   Optionpk<int> bndnodata_opt("bndnodata", "bndnodata", "Band(s) in input image to check if pixel is valid (used for srcnodata)", 0);
-  // Optionpk<string> mask_opt("m", "mask", "Mask image file");
-  // Optionpk<int> msknodata_opt("msknodata", "msknodata", "Mask value where image is invalid. If a single mask is used, more nodata values can be set. If more masks are used, use one value for each mask.", 1);
-  // Optionpk<string> bufferOutput_opt("bu", "bu", "Buffer output shape file");
   Optionpk<float> polythreshold_opt("tp", "thresholdPolygon", "(absolute) threshold for selecting samples in each polygon");
-  Optionpk<string> test_opt("test", "test", "Test sample file (use this option in combination with threshold<100 to create a training (output) and test set");
+  Optionpk<string> test_opt("test", "test", "Test sample dataset (use this option in combination with threshold<100 to create a training (output) and test set");
   Optionpk<string> fieldname_opt("bn", "bname", "For single band input data, this extra attribute name will correspond to the raster values. For multi-band input data, multiple attributes with this prefix will be added (e.g. b0, b1, b2, etc.)", "b");
-  Optionpk<string> label_opt("cn", "cname", "Name of the class label in the output vector file", "label");
-  Optionpk<short> geo_opt("g", "geo", "Use geo coordinates (set to 0 to use image coordinates)", 1);
+  Optionpk<string> label_opt("cn", "cname", "Name of the class label in the output vector dataset", "label");
+  Optionpk<short> geo_opt("geo", "geo", "Use geo coordinates (set to 0 to use image coordinates)", 1);
   Optionpk<short> down_opt("down", "down", "Down sampling factor (for raster sample datasets only). Can be used to create grid points", 1);
-  Optionpk<short> boundary_opt("bo", "boundary", "Boundary for selecting the sample (for vector sample datasets only) ", 1);
-  Optionpk<short> disc_opt("circ", "circular", "Circular disc kernel boundary (for vector sample datasets only, use in combination with boundary option)", 0);
-  // Optionpk<short> rbox_opt("rb", "rbox", "rectangular boundary box (total width in m) to draw around the selected pixel. Can not combined with class option. Use multiple rbox options for multiple boundary boxes. Use value 0 for no box)", 0);
-  // Optionpk<short> cbox_opt("cbox", "cbox", "circular boundary (diameter in m) to draw around the selected pixel. Can not combined with class option. Use multiple cbox options for multiple boundary boxes. Use value 0 for no box)", 0);
+  Optionpk<short> buffer_opt("buf", "buffer", "Buffer for calculating statistics for point features ");
+  Optionpk<bool> disc_opt("circ", "circular", "Use a circular disc kernel buffer (for vector point sample datasets only, use in combination with buffer option)", false);
   Optionpk<short> verbose_opt("v", "verbose", "Verbose mode if > 0", 0);
 
   bool doProcess;//stop process when program was invoked with help option (-h --help)
@@ -76,6 +73,8 @@ int main(int argc, char *argv[])
     doProcess=image_opt.retrieveOption(argc,argv);
     sample_opt.retrieveOption(argc,argv);
     layer_opt.retrieveOption(argc,argv);
+    random_opt.retrieveOption(argc,argv);
+    grid_opt.retrieveOption(argc,argv);
     output_opt.retrieveOption(argc,argv);
     class_opt.retrieveOption(argc,argv);
     threshold_opt.retrieveOption(argc,argv);
@@ -88,18 +87,15 @@ int main(int argc, char *argv[])
     bndnodata_opt.retrieveOption(argc,argv);
     srcnodata_opt.retrieveOption(argc,argv);
     polythreshold_opt.retrieveOption(argc,argv);
-    // mask_opt.retrieveOption(argc,argv);
-    // msknodata_opt.retrieveOption(argc,argv);
-    // bufferOutput_opt.retrieveOption(argc,argv);
     test_opt.retrieveOption(argc,argv);
     fieldname_opt.retrieveOption(argc,argv);
     label_opt.retrieveOption(argc,argv);
     geo_opt.retrieveOption(argc,argv);
     down_opt.retrieveOption(argc,argv);
-    boundary_opt.retrieveOption(argc,argv);
+    buffer_opt.retrieveOption(argc,argv);
+    disc_opt.retrieveOption(argc,argv);
     // rbox_opt.retrieveOption(argc,argv);
     // cbox_opt.retrieveOption(argc,argv);
-    disc_opt.retrieveOption(argc,argv);
     verbose_opt.retrieveOption(argc,argv);
   }
   catch(string predefinedString){
@@ -116,12 +112,13 @@ int main(int argc, char *argv[])
   ruleMap["point"]=rule::point;
   ruleMap["centroid"]=rule::centroid;
   ruleMap["mean"]=rule::mean;
+  ruleMap["stdev"]=rule::stdev;
   ruleMap["median"]=rule::median;
   ruleMap["proportion"]=rule::proportion;
-  ruleMap["minimum"]=rule::minimum;
-  ruleMap["maximum"]=rule::maximum;
+  ruleMap["min"]=rule::min;
+  ruleMap["max"]=rule::max;
   ruleMap["custom"]=rule::custom;
-  ruleMap["maxvote"]=rule::maxvote;
+  ruleMap["mode"]=rule::mode;
   ruleMap["sum"]=rule::sum;
 
   if(srcnodata_opt.size()){
@@ -144,22 +141,16 @@ int main(int argc, char *argv[])
     nvalid[it]=0;
     ninvalid[it]=0;
   }
-  short theDim=boundary_opt[0];
-  if(verbose_opt[0]>1)
-    std::cout << "boundary: " << boundary_opt[0] << std::endl;
+
   ImgReaderGdal imgReader;
   if(image_opt.empty()){
-    std::cerr << "No image file provided (use option -i). Use --help for help information";
+    std::cerr << "No image dataset provided (use option -i). Use --help for help information";
       exit(0);
   }
   if(output_opt.empty()){
-    std::cerr << "No output file provided (use option -o). Use --help for help information";
+    std::cerr << "No output dataset provided (use option -o). Use --help for help information";
       exit(0);
   }
-  if(sample_opt.empty()){
-    std::cerr << "No sample file provided (use option -s). Use --help for help information";
-    exit(0);
-  }
   try{
     imgReader.open(image_opt[0]);
   }
@@ -167,14 +158,15 @@ int main(int argc, char *argv[])
     std::cout << errorstring << std::endl;
     exit(0);
   }
-  int nband=(band_opt[0]<0)?imgReader.nrOfBand():band_opt.size();
+  
+  int nband=(band_opt.size()) ? band_opt.size() : imgReader.nrOfBand();
 
   if(fieldname_opt.size()<nband){
     std::string bandString=fieldname_opt[0];
     fieldname_opt.clear();
     fieldname_opt.resize(nband);
     for(int iband=0;iband<nband;++iband){
-      int theBand=(band_opt[0]<0)?iband:band_opt[iband];
+      int theBand=(band_opt.size()) ? band_opt[iband] : iband;
       ostringstream fs;
       fs << bandString << theBand;
       fieldname_opt[iband]=fs.str();
@@ -183,27 +175,6 @@ int main(int argc, char *argv[])
 
   if(verbose_opt[0])
     std::cout << fieldname_opt << std::endl;
-  vector<ImgReaderGdal> maskReader;
-  // if(mask_opt.size()){
-  //   maskReader.resize(mask_opt.size());
-  //   for(int imask=0;imask<mask_opt.size();++imask){
-  //     if(verbose_opt[0]>1)
-  //       std::cout << "opening mask image file " << mask_opt[imask] << std::endl;
-  //     maskReader[imask].open(mask_opt[0]);
-  //     if(imgReader.isGeoRef())
-  //       assert(maskReader[imask].isGeoRef());
-  //   }
-  // }
-
-  // Vector2d<int> maskBuffer;
-  // if(mask_opt.size()){
-  //   maskBuffer.resize(mask_opt.size());
-  //   for(int imask=0;imask<maskReader.size();++imask)
-  //     maskBuffer[imask].resize(maskReader[imask].nrOfCol());
-  // }
-  // vector<double> oldmaskrow(mask_opt.size());
-  // for(int imask=0;imask<mask_opt.size();++imask)
-  //   oldmaskrow[imask]=-1;
   
   if(verbose_opt[0]>1)
     std::cout << "Number of bands in input image: " << imgReader.nrOfBand() << std::endl;
@@ -259,12 +230,78 @@ int main(int argc, char *argv[])
   srand(time(NULL));
 
   bool sampleIsRaster=false;
+  bool sampleIsVirtual=false;
+
   ImgReaderOgr sampleReaderOgr;
-  try{
-    sampleReaderOgr.open(sample_opt[0]);
+  ImgWriterOgr sampleWriterOgr;
+
+  if(sample_opt.size()){
+    try{
+      sampleReaderOgr.open(sample_opt[0]);
+    }
+    catch(string errorString){
+      sampleIsRaster=true;
+    }
   }
-  catch(string errorString){
-    sampleIsRaster=true;
+  else{
+    sampleWriterOgr.open("/vsimem/sample",ogrformat_opt[0]);
+    char     **papszOptions=NULL;
+    sampleWriterOgr.createLayer("points", imgReader.getProjection(), wkbPoint, papszOptions);
+    sampleIsVirtual=true;
+
+    // string fieldName="label";
+    // string fieldValue="class";
+    // sampleWriterOgr.createField(fieldName,OFTString);
+    if(random_opt.size()){
+      //create simple random sampling within boundary
+      OGRPoint pt;
+      double ulx,uly,lrx,lry;
+      imgReader.getBoundingBox(ulx,uly,lrx,lry);
+      for(unsigned int ipoint=1;ipoint<=random_opt[0];++ipoint){
+	OGRFeature *pointFeature;
+	pointFeature=sampleWriterOgr.createFeature();
+	// pointFeature->SetField(fieldName.c_str(),fieldValue.c_str());
+	double theX=ulx+static_cast<double>(rand())/(RAND_MAX)*(lrx-ulx);
+	double theY=uly-static_cast<double>(rand())/(RAND_MAX)*(uly-lry);
+	pt.setX(theX);
+	pt.setY(theY);
+	pointFeature->SetGeometry( &pt ); 
+	if(sampleWriterOgr.createFeature(pointFeature) != OGRERR_NONE ){
+	  cerr << "Failed to create feature in shapefile" << endl;
+	  exit( 1 );
+	}
+	OGRFeature::DestroyFeature(pointFeature);
+      }
+    }
+    else if(grid_opt.size()){
+      //create systematic grid of points 
+      OGRPoint pt;
+      double ulx,uly,lrx,lry;
+      imgReader.getBoundingBox(ulx,uly,lrx,lry);
+      unsigned int ipoint=0;
+      for(double theY=uly-grid_opt[0]/2;theY>lry;theY-=grid_opt[0]){
+	for(double theX=ulx+grid_opt[0]/2;theX<lrx;theX+=grid_opt[0]){
+	  if(verbose_opt[0]>1)
+	    cout << "position: " << theX << " " << theY << endl;
+	  OGRFeature *pointFeature;
+	  pointFeature=sampleWriterOgr.createFeature();
+	  // pointFeature->SetField(fieldName.c_str(),fieldValue.c_str());
+	  pt.setX(theX);
+	  pt.setY(theY);
+	  pointFeature->SetGeometry( &pt ); 
+	  if(sampleWriterOgr.createFeature(pointFeature) != OGRERR_NONE ){
+	    cerr << "Failed to create feature in shapefile" << endl;
+	    exit( 1 );
+	  }
+	  OGRFeature::DestroyFeature(pointFeature);
+	}
+      }
+    }
+    else{
+      std::cerr << "No sample dataset provided (use option -s). Use --help for help information";
+      exit(0);
+    }
+    sampleReaderOgr.open("/vsimem/sample");
   }
 
   if(sampleIsRaster){
@@ -272,16 +309,7 @@ int main(int argc, char *argv[])
       // std::cout << "Warning: no classes selected, if a classes must be extracted, set to -1 for all classes using option -c -1" << std::endl;
       ImgReaderGdal classReader;
       ImgWriterOgr ogrWriter;
-      // if(verbose_opt[0]>1){
-      //   std::cout << "reading position from " << sample_opt[0] << std::endl;
-      //   std::cout << "class thresholds: " << std::endl;
-      //   for(int iclass=0;iclass<class_opt.size();++iclass){
-      //     if(threshold_opt.size()>1)
-      //       std::cout << class_opt[iclass] << ": " << threshold_opt[iclass] << std::endl;
-      //     else
-      //       std::cout << class_opt[iclass] << ": " << threshold_opt[0] << std::endl;
-      //   }
-      // }
+      assert(sample_opt.size());
       classReader.open(sample_opt[0]);
       // vector<int> classBuffer(classReader.nrOfCol());
       vector<double> classBuffer(classReader.nrOfCol());
@@ -360,7 +388,7 @@ int main(int argc, char *argv[])
             if(static_cast<int>(jimg)!=static_cast<int>(oldimgrow)){
               assert(imgBuffer.size()==nband);
               for(int iband=0;iband<nband;++iband){
-                int theBand=(band_opt[0]<0)?iband:band_opt[iband];
+		int theBand=(band_opt.size()) ? band_opt[iband] : iband;
                 imgReader.readData(imgBuffer[iband],GDT_Float64,static_cast<int>(jimg),theBand);
                 assert(imgBuffer[iband].size()==imgReader.nrOfCol());
 		if(srcnodata_opt.size()){
@@ -376,67 +404,7 @@ int main(int argc, char *argv[])
 	      }
               oldimgrow=jimg;
 	    }
-	    
-            // for(int imask=0;imask<mask_opt.size();++imask){
-            //   double colMask,rowMask;//image coordinates in mask image
-            //   if(mask_opt.size()>1){//multiple masks
-            //     if(geo_opt[0])
-            //       maskReader[imask].geo2image(x,y,colMask,rowMask);
-            //     else{
-            //       colMask=icol;
-            //       rowMask=irow;
-            //     }
-            //     //nearest neighbour
-            //     rowMask=static_cast<int>(rowMask);
-            //     colMask=static_cast<int>(colMask);
-            //     if(static_cast<int>(colMask)<0||static_cast<int>(colMask)>=maskReader[imask].nrOfCol())
-            //       continue;
-            //     if(static_cast<int>(rowMask)!=static_cast<int>(oldmaskrow[imask])){
-            //       if(static_cast<int>(rowMask)<0||static_cast<int>(rowMask)>=maskReader[imask].nrOfRow())
-            //         continue;
-            //       else{
-            //         maskReader[imask].readData(maskBuffer[imask],GDT_Int32,static_cast<int>(rowMask));
-            //         oldmaskrow[imask]=rowMask;
-            //       }
-            //     }
-            //     int ivalue=0;
-            //     if(mask_opt.size()==msknodata_opt.size())//one invalid value for each mask
-            //       ivalue=static_cast<int>(msknodata_opt[imask]);
-            //     else//use same invalid value for each mask
-            //       ivalue=static_cast<int>(msknodata_opt[0]);
-            //     if(maskBuffer[imask][colMask]==ivalue){
-            //       valid=false;
-            //       break;
-            //     }
-            //   }
-            //   else if(maskReader.size()){
-            //     if(geo_opt[0])
-            //       maskReader[0].geo2image(x,y,colMask,rowMask);
-            //     else{
-            //       colMask=icol;
-            //       rowMask=irow;
-            //     }
-            //     //nearest neighbour
-            //     rowMask=static_cast<int>(rowMask);
-            //     colMask=static_cast<int>(colMask);
-            //     if(static_cast<int>(colMask)<0||static_cast<int>(colMask)>=maskReader[0].nrOfCol())
-            //       continue;
-            //     if(static_cast<int>(rowMask)!=static_cast<int>(oldmaskrow[0])){
-            //       if(static_cast<int>(rowMask)<0||static_cast<int>(rowMask)>=maskReader[0].nrOfRow())
-            //         continue;
-            //       else{
-            //         maskReader[0].readData(maskBuffer[0],GDT_Int32,static_cast<int>(rowMask));
-            //         oldmaskrow[0]=rowMask;
-            //       }
-            //     }
-            //     for(int ivalue=0;ivalue<msknodata_opt.size();++ivalue){
-            //       if(maskBuffer[0][colMask]==static_cast<int>(msknodata_opt[ivalue])){
-            //         valid=false;
-            //         break;
-            //       }
-            //     }
-            //   }
-            // }
+
             if(valid){
               for(int iband=0;iband<imgBuffer.size();++iband){
                 if(imgBuffer[iband].size()!=imgReader.nrOfCol()){
@@ -489,7 +457,7 @@ int main(int argc, char *argv[])
         map<std::string,double> pointAttributes;
         ogrWriter.createField(label_opt[0],labelType);
         for(int iband=0;iband<nband;++iband){
-          int theBand=(band_opt[0]<0)?iband:band_opt[iband];
+	  int theBand=(band_opt.size()) ? band_opt[iband] : iband;
           ogrWriter.createField(fieldname_opt[iband],fieldType);
         }
         std::cout << "writing sample to " << output_opt[0] << "..." << std::endl;
@@ -500,7 +468,7 @@ int main(int argc, char *argv[])
             std::cout << "writing sample " << isample << std::endl;
           pointAttributes[label_opt[0]]=writeBufferClass[isample];
           for(int iband=0;iband<writeBuffer[0].size()-2;++iband){
-            int theBand=(band_opt[0]<0)?iband:band_opt[iband];
+	    int theBand=(band_opt.size()) ? band_opt[iband] : iband;
             // ostringstream fs;
             // if(nband==1)
             //   fs << fieldname_opt[0];
@@ -532,7 +500,7 @@ int main(int argc, char *argv[])
       ImgReaderGdal classReader;
       ImgWriterOgr ogrWriter;
       if(verbose_opt[0]>1){
-        std::cout << "reading position from " << sample_opt[0] << std::endl;
+        std::cout << "reading position from sample dataset " << std::endl;
         std::cout << "class thresholds: " << std::endl;
         for(int iclass=0;iclass<class_opt.size();++iclass){
           if(threshold_opt.size()>1)
@@ -617,7 +585,7 @@ int main(int argc, char *argv[])
             if(static_cast<int>(jimg)!=static_cast<int>(oldimgrow)){
               assert(imgBuffer.size()==nband);
               for(int iband=0;iband<nband;++iband){
-                int theBand=(band_opt[0]<0)?iband:band_opt[iband];
+		int theBand=(band_opt.size()) ? band_opt[iband] : iband;
                 imgReader.readData(imgBuffer[iband],GDT_Float64,static_cast<int>(jimg),theBand);
                 assert(imgBuffer[iband].size()==imgReader.nrOfCol());
 		if(srcnodata_opt.size()){
@@ -630,66 +598,6 @@ int main(int argc, char *argv[])
               }
               oldimgrow=jimg;
             }
-            // for(int imask=0;imask<mask_opt.size();++imask){
-            //   double colMask,rowMask;//image coordinates in mask image
-            //   if(mask_opt.size()>1){//multiple masks
-            //     if(geo_opt[0])
-            //       maskReader[imask].geo2image(x,y,colMask,rowMask);
-            //     else{
-            //       colMask=icol;
-            //       rowMask=irow;
-            //     }
-            //     //nearest neighbour
-            //     rowMask=static_cast<int>(rowMask);
-            //     colMask=static_cast<int>(colMask);
-            //     if(static_cast<int>(colMask)<0||static_cast<int>(colMask)>=maskReader[imask].nrOfCol())
-            //       continue;
-            //     if(static_cast<int>(rowMask)!=static_cast<int>(oldmaskrow[imask])){
-            //       if(static_cast<int>(rowMask)<0||static_cast<int>(rowMask)>=maskReader[imask].nrOfRow())
-            //         continue;
-            //       else{
-            //         maskReader[imask].readData(maskBuffer[imask],GDT_Int32,static_cast<int>(rowMask));
-            //         oldmaskrow[imask]=rowMask;
-            //       }
-            //     }
-            //     int ivalue=0;
-            //     if(mask_opt.size()==msknodata_opt.size())//one invalid value for each mask
-            //       ivalue=static_cast<int>(msknodata_opt[imask]);
-            //     else//use same invalid value for each mask
-            //       ivalue=static_cast<int>(msknodata_opt[0]);
-            //     if(maskBuffer[imask][colMask]==ivalue){
-            //       valid=false;
-            //       break;
-            //     }
-            //   }
-            //   else if(maskReader.size()){
-            //     if(geo_opt[0])
-            //       maskReader[0].geo2image(x,y,colMask,rowMask);
-            //     else{
-            //       colMask=icol;
-            //       rowMask=irow;
-            //     }
-            //     //nearest neighbour
-            //     rowMask=static_cast<int>(rowMask);
-            //     colMask=static_cast<int>(colMask);
-            //     if(static_cast<int>(colMask)<0||static_cast<int>(colMask)>=maskReader[0].nrOfCol())
-            //       continue;
-            //     if(static_cast<int>(rowMask)!=static_cast<int>(oldmaskrow[0])){
-            //       if(static_cast<int>(rowMask)<0||static_cast<int>(rowMask)>=maskReader[0].nrOfRow())
-            //         continue;
-            //       else{
-            //         maskReader[0].readData(maskBuffer[0],GDT_Int32,static_cast<int>(rowMask));
-            //         oldmaskrow[0]=rowMask;
-            //       }
-            //     }
-            //     for(int ivalue=0;ivalue<msknodata_opt.size();++ivalue){
-            //       if(maskBuffer[0][colMask]==static_cast<int>(msknodata_opt[ivalue])){
-            //         valid=false;
-            //         break;
-            //       }
-            //     }
-            //   }
-            // }
             if(valid){
               for(int iband=0;iband<imgBuffer.size();++iband){
                 if(imgBuffer[iband].size()!=imgReader.nrOfCol()){
@@ -742,7 +650,7 @@ int main(int argc, char *argv[])
         //         ogrWriter.createField(label_opt[0],OFTInteger);
         ogrWriter.createField(label_opt[0],labelType);
         for(int iband=0;iband<nband;++iband){
-          int theBand=(band_opt[0]<0)?iband:band_opt[iband];
+	  int theBand=(band_opt.size()) ? band_opt[iband] : iband;
           // ostringstream fs;
           // if(nband==1)
           //   fs << fieldname_opt[0];
@@ -758,7 +666,7 @@ int main(int argc, char *argv[])
         for(int isample=0;isample<writeBuffer.size();++isample){
           pointAttributes[label_opt[0]]=writeBufferClass[isample];
           for(int iband=0;iband<writeBuffer[0].size()-2;++iband){
-            int theBand=(band_opt[0]<0)?iband:band_opt[iband];
+	    int theBand=(band_opt.size()) ? band_opt[iband] : iband;
             // ostringstream fs;
             // if(nband==1)
             //   fs << fieldname_opt[0];
@@ -787,7 +695,7 @@ int main(int argc, char *argv[])
       }
     }
   }
-  else{//vector file
+  else{//vector dataset
     if(verbose_opt[0]>1)
       std::cout << "creating image sample writer " << output_opt[0] << std::endl;
     ImgWriterOgr ogrWriter;
@@ -852,7 +760,6 @@ int main(int argc, char *argv[])
       // assert(fieldnames.size()==ogrWriter.getFieldCount(ilayerWrite));
       // map<std::string,double> pointAttributes;
 
-      //todo: support multiple rules and write attribute for each rule...
       if(class_opt.size()){
 	switch(ruleMap[rule_opt[0]]){
 	case(rule::proportion):{//proportion for each class
@@ -864,7 +771,7 @@ int main(int argc, char *argv[])
 	  break;
 	}
 	case(rule::custom):
-	case(rule::maxvote):
+	case(rule::mode):
 	  ogrWriter.createField(label_opt[0],fieldType,ilayerWrite);
 	if(test_opt.size())
 	  ogrTestWriter.createField(label_opt[0],fieldType,ilayerWrite);
@@ -872,25 +779,16 @@ int main(int argc, char *argv[])
 	}
       }
       else{
-	for(int windowJ=-theDim/2;windowJ<(theDim+1)/2;++windowJ){
-	  for(int windowI=-theDim/2;windowI<(theDim+1)/2;++windowI){
-	    if(disc_opt[0]&&(windowI*windowI+windowJ*windowJ>(theDim/2)*(theDim/2)))
-	      continue;
-	    for(int iband=0;iband<nband;++iband){
-	      int theBand=(band_opt[0]<0)?iband:band_opt[iband];
-	      ostringstream fs;
-	      if(theDim>1)
-		fs << fieldname_opt[iband] << "_" << windowJ << "_" << windowI;
-	      else
-		fs << fieldname_opt[iband];
-	      if(verbose_opt[0]>1)
-		std::cout << "creating field " << fs.str() << std::endl;
-
-	      ogrWriter.createField(fs.str(),fieldType,ilayerWrite);
-	      if(test_opt.size())
-		ogrTestWriter.createField(fs.str(),fieldType,ilayerWrite);
-	    }
-	  }
+	for(int iband=0;iband<nband;++iband){
+	  int theBand=(band_opt.size()) ? band_opt[iband] : iband;
+	  ostringstream fs;
+	  fs << fieldname_opt[iband];
+	  if(verbose_opt[0]>1)
+	    std::cout << "creating field " << fs.str() << std::endl;
+
+	  ogrWriter.createField(fs.str(),fieldType,ilayerWrite);
+	  if(test_opt.size())
+	    ogrTestWriter.createField(fs.str(),fieldType,ilayerWrite);
 	}
       }
       OGRFeature *readFeature;
@@ -930,76 +828,33 @@ int main(int argc, char *argv[])
 	assert(poGeometry!=NULL);
 	try{
 	  if(wkbFlatten(poGeometry->getGeometryType()) == wkbPoint ){
-	    assert(class_opt.size()<=1);//class_opt not implemented for point yet
+
+	    if(!buffer_opt.size()){
+	      switch(ruleMap[rule_opt[0]]){
+	      case(rule::point):
+	      case(rule::centroid):
+		buffer_opt.push_back(1);//default
+	      break;
+	      default:
+		buffer_opt.push_back(3);//default
+	      }
+	    }
+
+	    if(verbose_opt[0]>1)
+	      std::cout << "boundary: " << buffer_opt[0] << std::endl;
+
+	    OGRPolygon writePolygon;
+	    OGRLinearRing writeRing;
+	    OGRPoint writeCentroidPoint;
+	    OGRFeature *writePolygonFeature;
+	    OGRFeature *writeCentroidFeature;
+
 	    OGRPoint *poPoint = (OGRPoint *) poGeometry;
+	    writeCentroidPoint=*poPoint;
+
 	    x=poPoint->getX();
 	    y=poPoint->getY();
 
-	    bool valid=true;
-
-	    // for(int imask=0;imask<mask_opt.size();++imask){
-	    //   double colMask,rowMask;//image coordinates in mask image
-	    //   if(mask_opt.size()>1){//multiple masks
-	    // 	maskReader[imask].geo2image(x,y,colMask,rowMask);
-	    // 	//nearest neighbour
-	    // 	rowMask=static_cast<int>(rowMask);
-	    // 	colMask=static_cast<int>(colMask);
-	    // 	if(static_cast<int>(colMask)<0||static_cast<int>(colMask)>=maskReader[imask].nrOfCol())
-	    // 	  continue;
-	    // 	if(static_cast<int>(rowMask)!=static_cast<int>(oldmaskrow[imask])){
-	    // 	  if(static_cast<int>(rowMask)<0||static_cast<int>(rowMask)>=maskReader[imask].nrOfRow())
-	    // 	    continue;
-	    // 	  else{
-	    // 	    maskReader[imask].readData(maskBuffer[imask],GDT_Int32,static_cast<int>(rowMask));
-	    // 	    oldmaskrow[imask]=rowMask;
-	    // 	    assert(maskBuffer.size()==maskReader[imask].nrOfBand());
-	    // 	  }
-	    // 	}
-	    // 	//               char ivalue=0;
-	    // 	int ivalue=0;
-	    // 	if(mask_opt.size()==msknodata_opt.size())//one invalid value for each mask
-	    // 	  ivalue=static_cast<int>(msknodata_opt[imask]);
-	    // 	else//use same invalid value for each mask
-	    // 	  ivalue=static_cast<int>(msknodata_opt[0]);
-	    // 	if(maskBuffer[imask][colMask]==ivalue){
-	    // 	  valid=false;
-	    // 	  break;
-	    // 	}
-	    //   }
-	    //   else if(maskReader.size()){
-	    // 	maskReader[0].geo2image(x,y,colMask,rowMask);
-	    // 	//nearest neighbour
-	    // 	rowMask=static_cast<int>(rowMask);
-	    // 	colMask=static_cast<int>(colMask);
-	    // 	if(static_cast<int>(colMask)<0||static_cast<int>(colMask)>=maskReader[0].nrOfCol()){
-	    // 	  continue;
-	    // 	  // cerr << colMask << " out of mask col range!" << std::endl;
-	    // 	  // cerr << x << " " << y << " " << colMask << " " << rowMask << std::endl;
-	    // 	  // assert(static_cast<int>(colMask)>=0&&static_cast<int>(colMask)<maskReader[0].nrOfCol());
-	    // 	}
-              
-	    // 	if(static_cast<int>(rowMask)!=static_cast<int>(oldmaskrow[0])){
-	    // 	  if(static_cast<int>(rowMask)<0||static_cast<int>(rowMask)>=maskReader[0].nrOfRow()){
-	    // 	    continue;
-	    // 	    // cerr << rowMask << " out of mask row range!" << std::endl;
-	    // 	    // cerr << x << " " << y << " " << colMask << " " << rowMask << std::endl;
-	    // 	    // assert(static_cast<int>(rowMask)>=0&&static_cast<int>(rowMask)<imgReader.nrOfRow());
-	    // 	  }
-	    // 	  else{
-	    // 	    maskReader[0].readData(maskBuffer[0],GDT_Int32,static_cast<int>(rowMask));
-	    // 	    oldmaskrow[0]=rowMask;
-	    // 	  }
-	    // 	}
-	    // 	for(int ivalue=0;ivalue<msknodata_opt.size();++ivalue){
-	    // 	  if(maskBuffer[0][colMask]==static_cast<int>(msknodata_opt[ivalue])){
-	    // 	    valid=false;
-	    // 	    break;
-	    // 	  }
-	    // 	}
-	    //   }
-	    // }
-
-	    double value;
 	    double i_centre,j_centre;
 	    if(geo_opt[0])
 	      imgReader.geo2image(x,y,i_centre,j_centre);
@@ -1010,192 +865,461 @@ int main(int argc, char *argv[])
 	    //nearest neighbour
 	    j_centre=static_cast<int>(j_centre);
 	    i_centre=static_cast<int>(i_centre);
-	    //check if j_centre is out of bounds
-	    if(static_cast<int>(j_centre)<0||static_cast<int>(j_centre)>=imgReader.nrOfRow())
+
+	    double uli=i_centre-buffer_opt[0]/2;
+	    double ulj=j_centre-buffer_opt[0]/2;
+	    double lri=i_centre+buffer_opt[0]/2;
+	    double lrj=j_centre+buffer_opt[0]/2;
+	    // double uli=i_centre-buffer_opt[0]/2-0.5;
+	    // double ulj=j_centre-buffer_opt[0]/2-0.5;
+	    // double lri=i_centre+buffer_opt[0]/2+0.5;
+	    // double lrj=j_centre+buffer_opt[0]/2+0.5;
+
+	    //nearest neighbour
+	    ulj=static_cast<int>(ulj);
+	    uli=static_cast<int>(uli);
+	    lrj=static_cast<int>(lrj);
+	    lri=static_cast<int>(lri);
+
+	    if((polygon_opt[0]&&ruleMap[rule_opt[0]]==rule::point)||(ruleMap[rule_opt[0]]==rule::centroid)){
+	      uli=i_centre;
+	      ulj=j_centre;
+	      lri=i_centre;
+	      lrj=j_centre;
+	    }
+
+	    //check if j is out of bounds
+	    if(static_cast<int>(ulj)<0||static_cast<int>(ulj)>=imgReader.nrOfRow())
 	      continue;
-	    //check if i_centre is out of bounds
-	    if(static_cast<int>(i_centre)<0||static_cast<int>(i_centre)>=imgReader.nrOfCol())
+	    //check if j is out of bounds
+	    if(static_cast<int>(uli)<0||static_cast<int>(lri)>=imgReader.nrOfCol())
 	      continue;
 
-	    // if(rbox_opt[0]){
-	    //   assert(test_opt.empty());//not implemented
-	    //   vector< vector<OGRPoint*> > points;
-	    //   points.resize(rbox_opt.size());
-	    //   if(verbose_opt[0]>1)
-	    //     std::cout << "creating rectangular box for sample " << isample << ": ";
-	    //   for(int ibox=0;ibox<rbox_opt.size();++ibox){
-	    //     int npoint=4;
-	    //     if(verbose_opt[0]>1)
-	    //       std::cout << ibox << " ";
-	    //     points[ibox].resize(npoint+1);
-	    //     vector<OGRPoint> pbPoint(npoint+1);
-	    //     pbPoint[0].setX(x-0.5*rbox_opt[ibox]);
-	    //     pbPoint[0].setY(y+0.5*rbox_opt[ibox]);
-	    //     points[ibox][0]=&(pbPoint[0]);//start point UL
-	    //     points[ibox][4]=&(pbPoint[0]);//end point
-	    //     pbPoint[1].setX(x+0.5*rbox_opt[ibox]);
-	    //     pbPoint[1].setY(y+0.5*rbox_opt[ibox]);
-	    //     points[ibox][1]=&(pbPoint[1]);//UR
-	    //     pbPoint[2].setX(x+0.5*rbox_opt[ibox]);
-	    //     pbPoint[2].setY(y-0.5*rbox_opt[ibox]);
-	    //     points[ibox][2]=&(pbPoint[2]);//LR
-	    //     pbPoint[3].setX(x-0.5*rbox_opt[ibox]);
-	    //     pbPoint[3].setY(y-0.5*rbox_opt[ibox]);
-	    //     points[ibox][3]=&(pbPoint[3]);//LL
-	    //     std::string fieldname="fid";//number of the point
-	    //     boxWriter.addRing(points[ibox],fieldname,isample);
-	    //     // boxWriter.addLineString(points[ibox],fieldname,isample);
-	    //   }
-	    //   if(verbose_opt[0]>1)
-	    //     std::cout << std::endl;
-	    // }
-	    // if(cbox_opt[0]>0){
-	    //   vector< vector<OGRPoint*> > points;
-	    //   points.resize(cbox_opt.size());
-	    //   if(verbose_opt[0]>1)
-	    //     std::cout << "creating circular box ";
-	    //   for(int ibox=0;ibox<cbox_opt.size();++ibox){
-	    //     int npoint=50;
-	    //     if(verbose_opt[0]>1)
-	    //       std::cout << ibox << " ";
-	    //     points[ibox].resize(npoint+1);
-	    //     vector<OGRPoint> pbPoint(npoint+1);
-	    //     double radius=cbox_opt[ibox]/2.0;
-	    //     double alpha=0;
-	    //     for(int ipoint=0;ipoint<npoint;++ipoint){
-	    //       alpha=ipoint*2.0*PI/static_cast<double>(npoint);
-	    //       pbPoint[ipoint].setX(x+radius*cos(alpha));
-	    //       pbPoint[ipoint].setY(y+radius*sin(alpha));
-	    //       points[ibox][ipoint]=&(pbPoint[ipoint]);
-	    //     }
-	    //     alpha=0;
-	    //     pbPoint[npoint].setX(x+radius*cos(alpha));
-	    //     pbPoint[npoint].setY(y+radius*sin(alpha));
-	    //     points[ibox][npoint]=&(pbPoint[npoint]);
-	    //     std::string fieldname="fid";//number of the point
-	    //     boxWriter.addRing(points[ibox],fieldname,isample);
-	    //     // boxWriter.addLineString(points[ibox],fieldname,isample);
-	    //   }
-	    //   if(verbose_opt[0]>1)
-	    //     std::cout << std::endl;
-	    // }
-      
-	    OGRFeature *writeFeature;
-	    if(verbose_opt[0]>1)
-	      std::cout << "create feature " << sample_opt[0] << std::endl;
-	    if(writeTest)
-	      writeFeature = OGRFeature::CreateFeature(writeTestLayer->GetLayerDefn());
-	    else
-	      writeFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
-	    if(verbose_opt[0]>1)
-	      std::cout << "copying fields from points " << sample_opt[0] << std::endl;
-	    if(writeFeature->SetFrom(readFeature)!= OGRERR_NONE)
-	      cerr << "writing feature failed" << std::endl;
+	    OGRPoint ulPoint,urPoint,llPoint,lrPoint;
+	    double ulx,uly;
+	    double urx,ury;
 
-	    if(verbose_opt[0]>1)
-	      std::cout << "write feature has " << writeFeature->GetFieldCount() << " fields" << std::endl;
-
-	    // //hiero
-	    // for(int vband=0;vband<bndnodata_opt.size();++vband){
-	    //   value=((readValues[bndnodata_opt[vband]])[j-ulj])[i-uli];
-	    //   if(value==srcnodata_opt[vband]){
-	    // 	valid=false;
-	    // 	break;
-	    //   }
-	    // }
+	    if(polygon_opt[0]){
+	      if(disc_opt[0]){
+		double gt[6];// { 444720, 30, 0, 3751320, 0, -30 };
+		double radius=buffer_opt[0]/2.0*sqrt(imgReader.getDeltaX()*imgReader.getDeltaY());
+		unsigned short nstep = 25;
+		for(int i=0;i<nstep;++i){
+		  OGRPoint aPoint;
+		  aPoint.setX(x+radius*cos(2*PI*i/nstep));
+		  aPoint.setY(y+radius*sin(2*PI*i/nstep));
+		  writeRing.addPoint(&aPoint);
+		}
+		writePolygon.addRing(&writeRing);
+		writePolygon.closeRings();
+	      }
+	      else{
+		double llx,lly;
+		double lrx,lry;
+		imgReader.image2geo(uli,ulj,ulx,uly);
+		imgReader.image2geo(lri,lrj,lrx,lry);
+		ulPoint.setX(ulx-imgReader.getDeltaX()/2.0);
+		ulPoint.setY(uly+imgReader.getDeltaY()/2.0);
+		lrPoint.setX(lrx+imgReader.getDeltaX()/2.0);
+		lrPoint.setY(lry-imgReader.getDeltaY()/2.0);
+		urPoint.setX(lrx+imgReader.getDeltaX()/2.0);
+		urPoint.setY(uly+imgReader.getDeltaY()/2.0);
+		llPoint.setX(ulx-imgReader.getDeltaX()/2.0);
+		llPoint.setY(lry-imgReader.getDeltaY()/2.0);
+
+		writeRing.addPoint(&ulPoint);
+		writeRing.addPoint(&urPoint);
+		writeRing.addPoint(&lrPoint);
+		writeRing.addPoint(&llPoint);
+		writePolygon.addRing(&writeRing);
+		writePolygon.closeRings();
+	      }
+	    }
 
-	    // if(!valid)
-	    //   continue;
-	    // else
-	    //   validFeature=true;
+	    int nPointWindow=0;//similar to nPointPolygon for polygons
+	    if(polygon_opt[0]){
+	      if(writeTest)
+		writePolygonFeature = OGRFeature::CreateFeature(writeTestLayer->GetLayerDefn());
+	      else
+		writePolygonFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
+	    }
+	    else if(ruleMap[rule_opt[0]]!=rule::point){
+	      if(writeTest)
+		writeCentroidFeature = OGRFeature::CreateFeature(writeTestLayer->GetLayerDefn());
+	      else
+		writeCentroidFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
+	    }
+	    Vector2d<double> windowValues;
+	    vector<double> windowClassValues;
 
-	    vector<double> windowBuffer;
-	    for(int windowJ=-theDim/2;windowJ<(theDim+1)/2;++windowJ){
-	      for(int windowI=-theDim/2;windowI<(theDim+1)/2;++windowI){
-		if(disc_opt[0]&&(windowI*windowI+windowJ*windowJ>(theDim/2)*(theDim/2)))
+	    if(class_opt.size()){
+	      windowClassValues.resize(class_opt.size());
+	      //initialize
+	      for(int iclass=0;iclass<class_opt.size();++iclass)
+		windowClassValues[iclass]=0;
+	    }
+	    else
+	      windowValues.resize(nband);
+	    vector< Vector2d<double> > readValues(nband);
+	    for(int iband=0;iband<nband;++iband){
+	      int theBand=(band_opt.size()) ? band_opt[iband] : iband;
+	      //test
+	      assert(uli>=0);
+	      assert(uli<imgReader.nrOfCol());	      
+	      assert(lri>=0);
+	      assert(lri<imgReader.nrOfCol());	      
+	      assert(ulj>=0);
+	      assert(ulj<imgReader.nrOfRow());	      
+	      assert(lrj>=0);
+	      assert(lrj<imgReader.nrOfRow());	      
+	      imgReader.readDataBlock(readValues[iband],GDT_Float64,uli,lri,ulj,lrj,theBand);
+	    }
+
+	    OGRPoint thePoint;
+	    for(int j=ulj;j<=lrj;++j){
+	      for(int i=uli;i<=lri;++i){
+		//check if within raster image
+		if(i<0||i>=imgReader.nrOfCol())
 		  continue;
-		int j=j_centre+windowJ;
-		//check if j is out of bounds
-		if(static_cast<int>(j)<0||static_cast<int>(j)>=imgReader.nrOfRow())
+		if(j<0||j>=imgReader.nrOfRow())
 		  continue;
-		int i=i_centre+windowI;
-		//check if i is out of bounds
-		if(static_cast<int>(i)<0||static_cast<int>(i)>=imgReader.nrOfCol())
+		//no need to check if point is on surface
+		double theX=0;
+		double theY=0;
+		imgReader.image2geo(i,j,theX,theY);
+		thePoint.setX(theX);
+		thePoint.setY(theY);
+
+		if(disc_opt[0]&&buffer_opt[0]>1){
+		  double radius=buffer_opt[0]/2.0*sqrt(imgReader.getDeltaX()*imgReader.getDeltaY());
+		  if((theX-x)*(theX-x)+(theY-y)*(theY-y)>radius*radius)
+		    continue;
+		}
+		bool valid=true;
+
+		if(srcnodata_opt.size()){
+		  for(int vband=0;vband<bndnodata_opt.size();++vband){
+		    double value=((readValues[bndnodata_opt[vband]])[j-ulj])[i-uli];
+		    if(value==srcnodata_opt[vband]){
+		      valid=false;
+		      break;
+		    }
+		  }
+		}
+
+		if(!valid)
 		  continue;
-		if(verbose_opt[0]>1)
-		  std::cout << "reading image value at " << i << "," << j;
-		for(int iband=0;iband<nband;++iband){
-		  int theBand=(band_opt[0]<0)?iband:band_opt[iband];
-		  imgReader.readData(value,GDT_Float64,i,j,theBand);
+		else
+		  validFeature=true;
 
-		  if(srcnodata_opt.size()){
-		    Optionpk<int>::const_iterator bndit=find(bndnodata_opt.begin(),bndnodata_opt.end(),theBand);
-		    if(bndit!=bndnodata_opt.end()){
-		      if(value==srcnodata_opt[theBand])
-			valid=false;
+		// writeRing.addPoint(&thePoint);//already done
+
+		++nPointWindow;
+		OGRFeature *writePointFeature;
+		if(!polygon_opt[0]){
+		  //create feature
+		  if(ruleMap[rule_opt[0]]==rule::point){//do not create in case of mean, stdev, median, sum or centroid (only create point at centroid)
+		    if(writeTest)
+		      writePointFeature = OGRFeature::CreateFeature(writeTestLayer->GetLayerDefn());
+		    else
+		      writePointFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
+		    if(verbose_opt[0]>1)
+		      std::cout << "copying fields from polygons " << std::endl;
+		    if(writePointFeature->SetFrom(readFeature)!= OGRERR_NONE)
+		      cerr << "writing feature failed" << std::endl;
+		    writePointFeature->SetGeometry(&thePoint);
+		    OGRGeometry *updateGeometry;
+		    updateGeometry = writePointFeature->GetGeometryRef();
+		    OGRPoint *poPoint = (OGRPoint *) updateGeometry;
+		    if(verbose_opt[0]>1)
+		      std::cout << "write feature has " << writePointFeature->GetFieldCount() << " fields" << std::endl;
+		  }
+		}
+		if(class_opt.size()){
+		  short value=((readValues[0])[j-ulj])[i-uli];
+		  for(int iclass=0;iclass<class_opt.size();++iclass){
+		    if(value==class_opt[iclass])
+		      windowClassValues[iclass]+=1;
+		  }
+		}
+		else{
+		  for(int iband=0;iband<nband;++iband){
+		    int theBand=(band_opt.size()) ? band_opt[iband] : iband;
+		    assert(j-ulj>=0);
+		    assert(j-ulj<readValues[iband].size());
+		    assert(i-uli>=0);
+		    assert(i-uli<((readValues[iband])[j-ulj]).size());
+		    double value=((readValues[iband])[j-ulj])[i-uli];
+		    // imgReader.readData(value,GDT_Float64,i,j,theBand);
+		    if(verbose_opt[0]>1)
+		      std::cout << ": " << value << std::endl;
+		    if(polygon_opt[0]||ruleMap[rule_opt[0]]!=rule::point){
+		      windowValues[iband].push_back(value);
 		    }
+		    else{
+		      if(verbose_opt[0]>1)
+			std::cout << "set field " << fieldname_opt[iband] << " to " << value << std::endl;
+		      switch( fieldType ){
+		      case OFTInteger:
+		      case OFTReal:
+			writePointFeature->SetField(fieldname_opt[iband].c_str(),value);
+			break;
+		      case OFTString:
+			writePointFeature->SetField(fieldname_opt[iband].c_str(),type2string<double>(value).c_str());
+			break;
+		      default://not supported
+			assert(0);
+			break;
+		      }
+		    }//else
+		  }//iband
+		}//else (class_opt.size())
+		if(!polygon_opt[0]){
+		  if(ruleMap[rule_opt[0]]==rule::point){//do not create in case of mean or median value (only at centroid)
+		    //write feature
+		    if(verbose_opt[0]>1)
+		      std::cout << "creating point feature" << std::endl;
+		    if(writeTest){
+		      if(writeTestLayer->CreateFeature( writePointFeature ) != OGRERR_NONE ){
+			std::string errorString="Failed to create feature in test ogr vector dataset";
+			throw(errorString);
+		      }
+		    }
+		    else{
+		      if(writeLayer->CreateFeature( writePointFeature ) != OGRERR_NONE ){
+			std::string errorString="Failed to create feature in ogr vector dataset";
+			throw(errorString);
+		      }
+		    }
+		    //destroy feature
+		    OGRFeature::DestroyFeature( writePointFeature );
+		    ++ntotalvalid;
+		    if(verbose_opt[0])
+		      std::cout << "ntotalvalid(2): " << ntotalvalid << std::endl;
 		  }
+		}
+	      }
+	    }
+	    if(polygon_opt[0]||ruleMap[rule_opt[0]]!=rule::point){
+	      //do not create if no points found within polygon
+	      if(!nPointWindow){
+		if(verbose_opt[0])
+		  cout << "no points found in window, continuing" << endl;
+		continue;
+	      }
+	      //add ring to polygon
+	      if(polygon_opt[0]){
+		// writePolygon.addRing(&writeRing);//already done
+		// writePolygon.closeRings();//already done
+		//write geometry of writePolygon
+		if(writePolygonFeature->SetFrom(readFeature)!= OGRERR_NONE)
+		  cerr << "writing feature failed" << std::endl;
+		writePolygonFeature->SetGeometry(&writePolygon);
+		if(verbose_opt[0]>1)
+		  std::cout << "copying new fields write polygon " << std::endl;
+		if(verbose_opt[0]>1)
+		  std::cout << "write feature has " << writePolygonFeature->GetFieldCount() << " fields" << std::endl;
+		//write polygon feature
+	      }
+	      else{//write value of polygon to centroid point
+		//create feature
+		if(verbose_opt[0]>1)
+		  std::cout << "copying fields from polygons " << std::endl;
+		if(writeCentroidFeature->SetFrom(readFeature)!= OGRERR_NONE)
+		  cerr << "writing feature failed" << std::endl;
+		writeCentroidFeature->SetGeometry(&writeCentroidPoint);
+		OGRGeometry *updateGeometry;
+		updateGeometry = writeCentroidFeature->GetGeometryRef();
+		assert(wkbFlatten(updateGeometry->getGeometryType()) == wkbPoint );
+		if(verbose_opt[0]>1)
+		  std::cout << "write feature has " << writeCentroidFeature->GetFieldCount() << " fields" << std::endl;
+	      }
+	      if(class_opt.empty()){
+		if(ruleMap[rule_opt[0]]==rule::point){//value at centroid of polygon
+		  if(verbose_opt[0])
+		    std::cout << "number of points in window: " << nPointWindow << std::endl;
+		  for(int index=0;index<windowValues.size();++index){
+		    //test
+		    if(windowValues[index].size()!=1){
+		      cerr << "Error: windowValues[index].size()=" << windowValues[index].size() << endl;
+		      assert(windowValues[index].size()==1);
+		    }
+		    double theValue=windowValues[index].back();
 
-		  if(verbose_opt[0]>1)
-		    std::cout << ": " << value << std::endl;
-		  ostringstream fs;
-		  if(theDim>1)
-		    fs << fieldname_opt[iband] << "_" << windowJ << "_" << windowI;
-		  else
-		    fs << fieldname_opt[iband];
-		  if(verbose_opt[0]>1)
-		    std::cout << "set field " << fs.str() << " to " << value << std::endl;
-		  switch( fieldType ){
-		  case OFTInteger:
-		    writeFeature->SetField(fs.str().c_str(),static_cast<int>(value));
-		    break;
-		  case OFTString:
-		    {
-		      ostringstream os;
-		      os << value;
-		      writeFeature->SetField(fs.str().c_str(),os.str().c_str());
+		    if(verbose_opt[0])
+		      std::cout << "number of points in window: " << nPointWindow << std::endl;
+		    int theBand=(band_opt.size()) ? band_opt[index] : index;
+
+		    if(verbose_opt[0]>1)
+		      std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
+		    switch( fieldType ){
+		    case OFTInteger:
+		    case OFTReal:
+		      if(polygon_opt[0])
+			writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
+		      else
+			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
+		      break;
+		    case OFTString:
+		      if(polygon_opt[0])
+			writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+		      else
+			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+		      break;
+		    default://not supported
+		      std::cout << "field type not supported yet..." << std::endl;
 		      break;
 		    }
-		  case OFTReal:
-		    writeFeature->SetField(fs.str().c_str(),value);
-		    break;
-		  case OFTRealList:{
-		    int fieldIndex=writeFeature->GetFieldIndex(fs.str().c_str());
-		    int nCount;
-		    const double *theList;
-		    theList=writeFeature->GetFieldAsDoubleList(fieldIndex,&nCount);
-		    vector<double> vectorList(nCount+1);
-		    for(int index=0;index<nCount;++index)
-		      vectorList[nCount]=value;
-		    writeFeature->SetField(fieldIndex,vectorList.size(),&(vectorList[0]));
-		    break;
 		  }
-		  default://not supported
-		    assert(0);
-		    break;
+		}
+		else{//ruleMap[rule_opt[0]] is not rule::point
+		  double theValue=0;
+		  for(int index=0;index<windowValues.size();++index){
+		    if(windowValues[index].size()!=buffer_opt[0]*buffer_opt[0]){
+		      cerr << "Error: windowValues[index].size()=" << windowValues[index].size() << endl;
+		    }
+		    if(ruleMap[rule_opt[0]]==rule::mean)
+		      theValue=stat.mean(windowValues[index]);
+		    else if(ruleMap[rule_opt[0]]==rule::stdev)
+		      theValue=sqrt(stat.var(windowValues[index]));
+		    else if(ruleMap[rule_opt[0]]==rule::median)
+		      theValue=stat.median(windowValues[index]);
+		    else if(ruleMap[rule_opt[0]]==rule::sum)
+		      theValue=stat.sum(windowValues[index]);
+		    else if(ruleMap[rule_opt[0]]==rule::max)
+		      theValue=stat.mymax(windowValues[index]);
+		    else if(ruleMap[rule_opt[0]]==rule::min)
+		      theValue=stat.mymin(windowValues[index]);
+		    else{//rule::centroid
+		      if(verbose_opt[0])
+			std::cout << "number of points in polygon: " << nPointWindow << std::endl;
+		      assert(nPointWindow<=1);
+		      assert(nPointWindow==windowValues[index].size());
+		      theValue=windowValues[index].back();
+		    }
+		    if(verbose_opt[0]>1)
+		      std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
+		    switch( fieldType ){
+		    case OFTInteger:
+		    case OFTReal:
+		      if(polygon_opt[0])
+			writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
+		      else
+			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
+		      break;
+		    case OFTString:
+		      if(polygon_opt[0])
+			writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+		      else
+			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+		      break;
+		    default://not supported
+		      std::cout << "field type not supported yet..." << std::endl;
+		      break;
+		    }
 		  }
 		}
 	      }
-	    }
-	    if(verbose_opt[0]>1)
-	      std::cout << "creating point feature" << std::endl;
-	    if(writeTest){
-	      if(writeTestLayer->CreateFeature( writeFeature ) != OGRERR_NONE ){
-		std::string errorString="Failed to create feature in ogr vector file";
-		throw(errorString);
+	      else{//class_opt is set
+		if(ruleMap[rule_opt[0]]==rule::proportion){
+		  if(verbose_opt[0])
+		    std::cout << "number of points in polygon: " << nPointWindow << std::endl;
+		  stat.normalize_pct(windowClassValues);
+		  for(int index=0;index<windowClassValues.size();++index){
+		    double theValue=windowClassValues[index];
+		    ostringstream fs;
+		    fs << class_opt[index];
+		    if(polygon_opt[0])
+		      writePolygonFeature->SetField(fs.str().c_str(),static_cast<int>(theValue));
+		    else
+		      writeCentroidFeature->SetField(fs.str().c_str(),static_cast<int>(theValue));
+		  }
+		}
+		else if(ruleMap[rule_opt[0]]==rule::custom){
+		  assert(polygon_opt[0]);//not implemented for points
+		  if(verbose_opt[0])
+		    std::cout << "number of points in polygon: " << nPointWindow << std::endl;
+		  stat.normalize_pct(windowClassValues);
+		  assert(windowClassValues.size()==2);//11:broadleaved, 12:coniferous
+		  if(windowClassValues[0]>=75)//broadleaved
+		    writePolygonFeature->SetField(label_opt[0].c_str(),static_cast<int>(11));
+		  else if(windowClassValues[1]>=75)//coniferous
+		    writePolygonFeature->SetField(label_opt[0].c_str(),static_cast<int>(12));
+		  else if(windowClassValues[0]>25&&windowClassValues[1]>25)//mixed
+		    writePolygonFeature->SetField(label_opt[0].c_str(),static_cast<int>(13));
+		  else{
+		    if(verbose_opt[0]){
+		      std::cout << "No valid value in windowClassValues..." << std::endl;
+		      for(int index=0;index<windowClassValues.size();++index){
+			double theValue=windowClassValues[index];
+			std::cout << theValue << " ";
+		      }
+		      std::cout << std::endl;
+		    }
+		    writePolygonFeature->SetField(label_opt[0].c_str(),static_cast<int>(20));
+		  }
+		}
+		else if(ruleMap[rule_opt[0]]==rule::mode){
+		  //maximum votes in polygon
+		  if(verbose_opt[0])
+		    std::cout << "number of points in window: " << nPointWindow << std::endl;
+		  //search for class with maximum votes
+		  int maxClass=stat.mymin(class_opt);
+		  vector<double>::iterator maxit;
+		  maxit=stat.mymax(windowClassValues,windowClassValues.begin(),windowClassValues.end());
+		  int maxIndex=distance(windowClassValues.begin(),maxit);
+		  maxClass=class_opt[maxIndex];
+		  if(verbose_opt[0]>0)
+		    std::cout << "maxClass: " << maxClass << std::endl;
+		  if(polygon_opt[0])
+		    writePolygonFeature->SetField(label_opt[0].c_str(),maxClass);
+		  else
+		    writeCentroidFeature->SetField(label_opt[0].c_str(),maxClass);
+		}
 	      }
-	    }
-	    else{
-	      if(writeLayer->CreateFeature( writeFeature ) != OGRERR_NONE ){
-		std::string errorString="Failed to create feature in ogr vector file";
-		throw(errorString);
+	      if(polygon_opt[0]){
+		if(verbose_opt[0]>1)
+		  std::cout << "creating polygon feature" << std::endl;
+		if(writeTest){
+		  if(writeTestLayer->CreateFeature( writePolygonFeature ) != OGRERR_NONE ){
+		    std::string errorString="Failed to create polygon feature in ogr vector dataset";
+		    throw(errorString);
+		  }
+		}
+		else{
+		  if(writeLayer->CreateFeature( writePolygonFeature ) != OGRERR_NONE ){
+		    std::string errorString="Failed to create polygon feature in ogr vector dataset";
+		    throw(errorString);
+		  }
+		}
+		OGRFeature::DestroyFeature( writePolygonFeature );
+		++ntotalvalid;
+		if(verbose_opt[0])
+		  std::cout << "ntotalvalid(1): " << ntotalvalid << std::endl;
+	      }
+	      else{
+		if(verbose_opt[0]>1)
+		  std::cout << "creating point feature in centroid" << std::endl;
+		if(writeTest){
+		  if(writeTestLayer->CreateFeature( writeCentroidFeature ) != OGRERR_NONE ){
+		    std::string errorString="Failed to create point feature in ogr vector dataset";
+		    throw(errorString);
+		  }
+		}
+		else{
+		  //test
+		  assert(validFeature);
+		  if(writeLayer->CreateFeature( writeCentroidFeature ) != OGRERR_NONE ){
+		    std::string errorString="Failed to create point feature in ogr vector dataset";
+		    throw(errorString);
+		  }
+		}
+		OGRFeature::DestroyFeature( writeCentroidFeature );
+		++ntotalvalid;
+		if(verbose_opt[0])
+		  std::cout << "ntotalvalid: " << ntotalvalid << std::endl;
 	      }
 	    }
-	    OGRFeature::DestroyFeature( writeFeature );
-	    // ++isample;
-	    ++ntotalvalid;
-	    if(verbose_opt[0])
-	      std::cout << "ntotalvalid: " << ntotalvalid << std::endl;
 	  }//if wkbPoint
 	  else if(wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon){
             
@@ -1302,7 +1426,7 @@ int main(int argc, char *argv[])
 	      polyValues.resize(nband);
 	    vector< Vector2d<double> > readValues(nband);
 	    for(int iband=0;iband<nband;++iband){
-	      int theBand=(band_opt[0]<0)?iband:band_opt[iband];
+	      int theBand=(band_opt.size()) ? band_opt[iband] : iband;
 	      //test
 	      assert(uli>=0);
 	      assert(uli<imgReader.nrOfCol());	      
@@ -1324,11 +1448,11 @@ int main(int argc, char *argv[])
 		if(j<0||j>=imgReader.nrOfRow())
 		  continue;
 		//check if point is on surface
-		double x=0;
-		double y=0;
-		imgReader.image2geo(i,j,x,y);
-		thePoint.setX(x);
-		thePoint.setY(y);
+		double theX=0;
+		double theY=0;
+		imgReader.image2geo(i,j,theX,theY);
+		thePoint.setX(theX);
+		thePoint.setY(theY);
 		
 		if(ruleMap[rule_opt[0]]!=rule::centroid&&!readPolygon.Contains(&thePoint))
 		  continue;
@@ -1345,64 +1469,12 @@ int main(int argc, char *argv[])
 		  }
 		}
 
-		// for(int imask=0;imask<mask_opt.size();++imask){
-		//   double colMask,rowMask;//image coordinates in mask image
-		//   if(mask_opt.size()>1){//multiple masks
-		//     maskReader[imask].geo2image(x,y,colMask,rowMask);
-		//     //nearest neighbour
-		//     rowMask=static_cast<int>(rowMask);
-		//     colMask=static_cast<int>(colMask);
-		//     if(static_cast<int>(colMask)<0||static_cast<int>(colMask)>=maskReader[imask].nrOfCol())
-		//       continue;
-              
-		//     if(static_cast<int>(rowMask)!=static_cast<int>(oldmaskrow[imask])){
-		//       if(static_cast<int>(rowMask)<0||static_cast<int>(rowMask)>=maskReader[imask].nrOfRow())
-		// 	continue;
-		//       else{
-		// 	maskReader[imask].readData(maskBuffer[imask],GDT_Int32,static_cast<int>(rowMask));
-		// 	oldmaskrow[imask]=rowMask;
-		// 	assert(maskBuffer.size()==maskReader[imask].nrOfBand());
-		//       }
-		//     }
-		//     int ivalue=0;
-		//     if(mask_opt.size()==msknodata_opt.size())//one invalid value for each mask
-		//       ivalue=static_cast<int>(msknodata_opt[imask]);
-		//     else//use same invalid value for each mask
-		//       ivalue=static_cast<int>(msknodata_opt[0]);
-		//     if(maskBuffer[imask][colMask]==ivalue){
-		//       valid=false;
-		//       break;
-		//     }
-		//   }
-		//   else if(maskReader.size()){
-		//     maskReader[0].geo2image(x,y,colMask,rowMask);
-		//     //nearest neighbour
-		//     rowMask=static_cast<int>(rowMask);
-		//     colMask=static_cast<int>(colMask);
-		//     if(static_cast<int>(colMask)<0||static_cast<int>(colMask)>=maskReader[0].nrOfCol())
-		//       continue;
-              
-		//     if(static_cast<int>(rowMask)!=static_cast<int>(oldmaskrow[0])){
-		//       if(static_cast<int>(rowMask)<0||static_cast<int>(rowMask)>=maskReader[0].nrOfRow())
-		// 	continue;
-		//       else{
-		// 	maskReader[0].readData(maskBuffer[0],GDT_Int32,static_cast<int>(rowMask));
-		// 	oldmaskrow[0]=rowMask;
-		//       }
-		//     }
-		//     for(int ivalue=0;ivalue<msknodata_opt.size();++ivalue){
-		//       if(maskBuffer[0][colMask]==static_cast<int>(msknodata_opt[ivalue])){
-		// 	valid=false;
-		// 	break;
-		//       }
-		//     }
-		//   }
-		// }
 		if(!valid)
 		  continue;
 		else
 		  validFeature=true;
-		writeRing.addPoint(&thePoint);
+
+		writeRing.addPoint(&thePoint);//todo: check if I need to add all interior points to ring or do I need to check if point is on ring first?
 		if(verbose_opt[0]>1)
 		  std::cout << "point is on surface:" << thePoint.getX() << "," << thePoint.getY() << std::endl;
 		++nPointPolygon;
@@ -1414,13 +1486,13 @@ int main(int argc, char *argv[])
 		OGRFeature *writePointFeature;
 		if(!polygon_opt[0]){
 		  //create feature
-		  if(ruleMap[rule_opt[0]]==rule::point){//do not create in case of mean, median, sum or centroid (only create point at centroid)
+		  if(ruleMap[rule_opt[0]]==rule::point){//do not create in case of mean, stdev, median, sum or centroid (only create point at centroid)
 		    if(writeTest)
 		      writePointFeature = OGRFeature::CreateFeature(writeTestLayer->GetLayerDefn());
 		    else
 		      writePointFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
 		    if(verbose_opt[0]>1)
-		      std::cout << "copying fields from polygons " << sample_opt[0] << std::endl;
+		      std::cout << "copying fields from polygons " << std::endl;
 		    if(writePointFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		      cerr << "writing feature failed" << std::endl;
 		    writePointFeature->SetGeometry(&thePoint);
@@ -1440,7 +1512,7 @@ int main(int argc, char *argv[])
 		}
 		else{
 		  for(int iband=0;iband<nband;++iband){
-		    int theBand=(band_opt[0]<0)?iband:band_opt[iband];
+		    int theBand=(band_opt.size()) ? band_opt[iband] : iband;
 		    assert(j-ulj>=0);
 		    assert(j-ulj<readValues[iband].size());
 		    assert(i-uli>=0);
@@ -1462,17 +1534,6 @@ int main(int argc, char *argv[])
 		      case OFTString:
 			writePointFeature->SetField(fieldname_opt[iband].c_str(),type2string<double>(value).c_str());
 			break;
-			// case OFTRealList:{
-			//   int fieldIndex=writePointFeature->GetFieldIndex(fieldname_opt[iband].c_str());
-			//   int nCount;
-			//   const double *theList;
-			//   theList=writePointFeature->GetFieldAsDoubleList(fieldIndex,&nCount);
-			//   vector<double> vectorList(nCount+1);
-			//   for(int index=0;index<nCount;++index)
-			// 	vectorList[nCount]=value;
-			//   writePointFeature->SetField(fieldIndex,vectorList.size(),&(vectorList[0]));
-			//   break;
-			// }
 		      default://not supported
 			assert(0);
 			break;
@@ -1487,13 +1548,13 @@ int main(int argc, char *argv[])
 		      std::cout << "creating point feature" << std::endl;
 		    if(writeTest){
 		      if(writeTestLayer->CreateFeature( writePointFeature ) != OGRERR_NONE ){
-			std::string errorString="Failed to create feature in test ogr vector file";
+			std::string errorString="Failed to create feature in test ogr vector dataset";
 			throw(errorString);
 		      }
 		    }
 		    else{
 		      if(writeLayer->CreateFeature( writePointFeature ) != OGRERR_NONE ){
-			std::string errorString="Failed to create feature in ogr vector file";
+			std::string errorString="Failed to create feature in ogr vector dataset";
 			throw(errorString);
 		      }
 		    }
@@ -1518,11 +1579,11 @@ int main(int argc, char *argv[])
 		writePolygon.addRing(&writeRing);
 		writePolygon.closeRings();
 		//write geometry of writePolygon
-		writePolygonFeature->SetGeometry(&writePolygon);
 		if(writePolygonFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		  cerr << "writing feature failed" << std::endl;
+		writePolygonFeature->SetGeometry(&writePolygon);
 		if(verbose_opt[0]>1)
-		  std::cout << "copying new fields write polygon " << sample_opt[0] << std::endl;
+		  std::cout << "copying new fields write polygon " << std::endl;
 		if(verbose_opt[0]>1)
 		  std::cout << "write feature has " << writePolygonFeature->GetFieldCount() << " fields" << std::endl;
 		//write polygon feature
@@ -1530,7 +1591,7 @@ int main(int argc, char *argv[])
 	      else{//write value of polygon to centroid point
 		//create feature
 		if(verbose_opt[0]>1)
-		  std::cout << "copying fields from polygons " << sample_opt[0] << std::endl;
+		  std::cout << "copying fields from polygons " << std::endl;
 		if(writeCentroidFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		  cerr << "writing feature failed" << std::endl;
 		writeCentroidFeature->SetGeometry(&writeCentroidPoint);
@@ -1541,7 +1602,7 @@ int main(int argc, char *argv[])
 		  std::cout << "write feature has " << writeCentroidFeature->GetFieldCount() << " fields" << std::endl;
 	      }
 	      if(class_opt.empty()){
-		if(ruleMap[rule_opt[0]]==rule::point){//value at each point (or at centroid of polygon if line is set)
+		if(ruleMap[rule_opt[0]]==rule::point){//value at centroid of polygon
 		  if(verbose_opt[0])
 		    std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
 		  for(int index=0;index<polyValues.size();++index){
@@ -1551,7 +1612,7 @@ int main(int argc, char *argv[])
 
 		    if(verbose_opt[0])
 		      std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
-		    int theBand=(band_opt[0]<0)?index:band_opt[index];
+		    int theBand=(band_opt.size()) ? band_opt[index] : index;
 
 		    if(verbose_opt[0]>1)
 		      std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
@@ -1569,31 +1630,6 @@ int main(int argc, char *argv[])
 		      else
 			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
 		      break;
-		      // case OFTRealList:{
-		      //   int fieldIndex;
-		      //   int nCount;
-		      //   const double *theList;
-		      //   vector<double> vectorList;
-		      //   if(polygon_opt[0]){
-		      //     fieldIndex=writePolygonFeature->GetFieldIndex(fieldname_opt[index].c_str());
-		      //     theList=writePolygonFeature->GetFieldAsDoubleList(fieldIndex,&nCount);
-		      //     vectorList.resize(nCount+1);
-		      //     for(int index=0;index<nCount;++index)
-		      // 	vectorList[index]=theList[index];
-		      //     vectorList[nCount]=theValue;
-		      //     writePolygonFeature->SetField(fieldIndex,vectorList.size(),&(vectorList[0]));
-		      //   }
-		      //   else{
-		      //     fieldIndex=writeCentroidFeature->GetFieldIndex(fieldname_opt[index].c_str());
-		      //     theList=writeCentroidFeature->GetFieldAsDoubleList(fieldIndex,&nCount);
-		      //     vectorList.resize(nCount+1);
-		      //     for(int index=0;index<nCount;++index)
-		      // 	vectorList[index]=theList[index];
-		      //     vectorList[nCount]=theValue;
-		      //     writeCentroidFeature->SetField(fieldIndex,vectorList.size(),&(vectorList[0]));
-		      //   }
-		      //   break;
-		      // }
 		    default://not supported
 		      std::cout << "field type not supported yet..." << std::endl;
 		      break;
@@ -1605,13 +1641,15 @@ int main(int argc, char *argv[])
 		  for(int index=0;index<polyValues.size();++index){
 		    if(ruleMap[rule_opt[0]]==rule::mean)
 		      theValue=stat.mean(polyValues[index]);
+		    else if(ruleMap[rule_opt[0]]==rule::stdev)
+		      theValue=sqrt(stat.var(polyValues[index]));
 		    else if(ruleMap[rule_opt[0]]==rule::median)
 		      theValue=stat.median(polyValues[index]);
 		    else if(ruleMap[rule_opt[0]]==rule::sum)
 		      theValue=stat.sum(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::maximum)
+		    else if(ruleMap[rule_opt[0]]==rule::max)
 		      theValue=stat.mymax(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::minimum)
+		    else if(ruleMap[rule_opt[0]]==rule::min)
 		      theValue=stat.mymin(polyValues[index]);
 		    else{//rule::centroid
 		      if(verbose_opt[0])
@@ -1636,31 +1674,6 @@ int main(int argc, char *argv[])
 		      else
 			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
 		      break;
-		      // case OFTRealList:{
-		      // int fieldIndex;
-		      // int nCount;
-		      // const double *theList;
-		      // vector<double> vectorList;
-		      // if(polygon_opt[0]){
-		      //   fieldIndex=writePolygonFeature->GetFieldIndex(fieldname_opt[index].c_str());
-		      //   theList=writePolygonFeature->GetFieldAsDoubleList(fieldIndex,&nCount);
-		      //   vectorList.resize(nCount+1);
-		      //   for(int index=0;index<nCount;++index)
-		      // 	vectorList[index]=theList[index];
-		      //   vectorList[nCount]=theValue;
-		      //   writePolygonFeature->SetField(fieldIndex,vectorList.size(),&(vectorList[0]));
-		      // }
-		      // else{
-		      //   fieldIndex=writeCentroidFeature->GetFieldIndex(fieldname_opt[index].c_str());
-		      //   theList=writeCentroidFeature->GetFieldAsDoubleList(fieldIndex,&nCount);
-		      //   vectorList.resize(nCount+1);
-		      //   for(int index=0;index<nCount;++index)
-		      // 	vectorList[index]=theList[index];
-		      //   vectorList[nCount]=theValue;
-		      //   writeCentroidFeature->SetField(fieldIndex,vectorList.size(),&(vectorList[0]));
-		      // }
-		      // break;
-		      //}
 		    default://not supported
 		      std::cout << "field type not supported yet..." << std::endl;
 		      break;
@@ -1673,7 +1686,7 @@ int main(int argc, char *argv[])
 		  if(verbose_opt[0])
 		    std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
 		  stat.normalize_pct(polyClassValues);
-		  for(int index=0;index<polyValues.size();++index){
+		  for(int index=0;index<polyClassValues.size();++index){
 		    double theValue=polyClassValues[index];
 		    ostringstream fs;
 		    fs << class_opt[index];
@@ -1707,7 +1720,7 @@ int main(int argc, char *argv[])
 		    writePolygonFeature->SetField(label_opt[0].c_str(),static_cast<int>(20));
 		  }
 		}
-		else if(ruleMap[rule_opt[0]]==rule::maxvote){
+		else if(ruleMap[rule_opt[0]]==rule::mode){
 		  //maximum votes in polygon
 		  if(verbose_opt[0])
 		    std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
@@ -1730,13 +1743,13 @@ int main(int argc, char *argv[])
 		  std::cout << "creating polygon feature" << std::endl;
 		if(writeTest){
 		  if(writeTestLayer->CreateFeature( writePolygonFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create polygon feature in ogr vector file";
+		    std::string errorString="Failed to create polygon feature in ogr vector dataset";
 		    throw(errorString);
 		  }
 		}
 		else{
 		  if(writeLayer->CreateFeature( writePolygonFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create polygon feature in ogr vector file";
+		    std::string errorString="Failed to create polygon feature in ogr vector dataset";
 		    throw(errorString);
 		  }
 		}
@@ -1750,7 +1763,7 @@ int main(int argc, char *argv[])
 		  std::cout << "creating point feature in centroid" << std::endl;
 		if(writeTest){
 		  if(writeTestLayer->CreateFeature( writeCentroidFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create point feature in ogr vector file";
+		    std::string errorString="Failed to create point feature in ogr vector dataset";
 		    throw(errorString);
 		  }
 		}
@@ -1758,7 +1771,7 @@ int main(int argc, char *argv[])
 		  //test
 		  assert(validFeature);
 		  if(writeLayer->CreateFeature( writeCentroidFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create point feature in ogr vector file";
+		    std::string errorString="Failed to create point feature in ogr vector dataset";
 		    throw(errorString);
 		  }
 		}
@@ -1869,7 +1882,7 @@ int main(int argc, char *argv[])
 	      polyValues.resize(nband);
 	    vector< Vector2d<double> > readValues(nband);
 	    for(int iband=0;iband<nband;++iband){
-	      int theBand=(band_opt[0]<0)?iband:band_opt[iband];
+	      int theBand=(band_opt.size()) ? band_opt[iband] : iband;
 	      //test
 	      assert(uli>=0);
 	      assert(uli<imgReader.nrOfCol());	      
@@ -1881,7 +1894,7 @@ int main(int argc, char *argv[])
 	      assert(lrj<imgReader.nrOfRow());	      
 	      imgReader.readDataBlock(readValues[iband],GDT_Float64,uli,lri,ulj,lrj,theBand);
 	    }
-	    //todo: readDataBlock for maskReader...
+
 	    OGRPoint thePoint;
 	    for(int j=ulj;j<=lrj;++j){
 	      for(int i=uli;i<=lri;++i){
@@ -1891,11 +1904,11 @@ int main(int argc, char *argv[])
 		if(j<0||j>=imgReader.nrOfRow())
 		  continue;
 		//check if point is on surface
-		double x=0;
-		double y=0;
-		imgReader.image2geo(i,j,x,y);
-		thePoint.setX(x);
-		thePoint.setY(y);
+		double theX=0;
+		double theY=0;
+		imgReader.image2geo(i,j,theX,theY);
+		thePoint.setX(theX);
+		thePoint.setY(theY);
 
 		if(ruleMap[rule_opt[0]]!=rule::centroid&&!readPolygon.Contains(&thePoint))
 		  continue;
@@ -1911,66 +1924,14 @@ int main(int argc, char *argv[])
 		    }
 		  }
 		}
-		// for(int imask=0;imask<mask_opt.size();++imask){
-		//     double colMask,rowMask;//image coordinates in mask image
-		//     if(mask_opt.size()>1){//multiple masks
-		//       maskReader[imask].geo2image(x,y,colMask,rowMask);
-		//       //nearest neighbour
-		//       rowMask=static_cast<int>(rowMask);
-		//       colMask=static_cast<int>(colMask);
-		//       if(static_cast<int>(colMask)<0||static_cast<int>(colMask)>=maskReader[imask].nrOfCol())
-		// 	continue;
-              
-		//       if(static_cast<int>(rowMask)!=static_cast<int>(oldmaskrow[imask])){
-		// 	if(static_cast<int>(rowMask)<0||static_cast<int>(rowMask)>=maskReader[imask].nrOfRow())
-		// 	  continue;
-		// 	else{
-		// 	  maskReader[imask].readData(maskBuffer[imask],GDT_Int32,static_cast<int>(rowMask));
-		// 	  oldmaskrow[imask]=rowMask;
-		// 	  assert(maskBuffer.size()==maskReader[imask].nrOfBand());
-		// 	}
-		//       }
-		//       int ivalue=0;
-		//       if(mask_opt.size()==msknodata_opt.size())//one invalid value for each mask
-		// 	ivalue=static_cast<int>(msknodata_opt[imask]);
-		//       else//use same invalid value for each mask
-		// 	ivalue=static_cast<int>(msknodata_opt[0]);
-		//       if(maskBuffer[imask][colMask]==ivalue){
-		// 	valid=false;
-		// 	break;
-		//       }
-		//     }
-		//     else if(maskReader.size()){
-		//       maskReader[0].geo2image(x,y,colMask,rowMask);
-		//       //nearest neighbour
-		//       rowMask=static_cast<int>(rowMask);
-		//       colMask=static_cast<int>(colMask);
-		//       if(static_cast<int>(colMask)<0||static_cast<int>(colMask)>=maskReader[0].nrOfCol())
-		// 	continue;
-              
-		//       if(static_cast<int>(rowMask)!=static_cast<int>(oldmaskrow[0])){
-		// 	if(static_cast<int>(rowMask)<0||static_cast<int>(rowMask)>=maskReader[0].nrOfRow())
-		// 	  continue;
-		// 	else{
-		// 	  maskReader[0].readData(maskBuffer[0],GDT_Int32,static_cast<int>(rowMask));
-		// 	  oldmaskrow[0]=rowMask;
-		// 	}
-		//       }
-		//       for(int ivalue=0;ivalue<msknodata_opt.size();++ivalue){
-		// 	if(maskBuffer[0][colMask]==static_cast<int>(msknodata_opt[ivalue])){
-		// 	  valid=false;
-		// 	  break;
-		// 	}
-		//       }
-		//     }
-		//   }
-
-		  if(!valid)
-		    continue;
-		  else
-		    validFeature=true;
-		  writeRing.addPoint(&thePoint);
-		  if(verbose_opt[0]>1)
+
+		if(!valid)
+		  continue;
+		else
+		  validFeature=true;
+		
+		writeRing.addPoint(&thePoint);
+		if(verbose_opt[0]>1)
 		    std::cout << "point is on surface:" << thePoint.getX() << "," << thePoint.getY() << std::endl;
 		  ++nPointPolygon;
 
@@ -1981,13 +1942,13 @@ int main(int argc, char *argv[])
 		  OGRFeature *writePointFeature;
 		  if(!polygon_opt[0]){
 		    //create feature
-		    if(ruleMap[rule_opt[0]]==rule::point){//do not create in case of mean, mean or sum (only create point at centroid)
+		    if(ruleMap[rule_opt[0]]==rule::point){//do not create in case of mean, stdev, median or sum (only create point at centroid)
 		      if(writeTest)
 			writePointFeature = OGRFeature::CreateFeature(writeTestLayer->GetLayerDefn());
 		      else
 			writePointFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
 		      if(verbose_opt[0]>1)
-			std::cout << "copying fields from polygons " << sample_opt[0] << std::endl;
+			std::cout << "copying fields from polygons " << std::endl;
 		      if(writePointFeature->SetFrom(readFeature)!= OGRERR_NONE)
 			cerr << "writing feature failed" << std::endl;
 		      writePointFeature->SetGeometry(&thePoint);
@@ -2048,19 +2009,19 @@ int main(int argc, char *argv[])
 		    }//iband
 		  }//else (class_opt.size())
 		  if(!polygon_opt[0]){
-		    if(ruleMap[rule_opt[0]]==rule::point){//do not create in case of mean /median value (only at centroid)
+		    if(ruleMap[rule_opt[0]]==rule::point){//do not create in case of mean, stdev or median value (only at centroid)
 		      //write feature
 		      if(verbose_opt[0]>1)
 			std::cout << "creating point feature" << std::endl;
 		      if(writeTest){
 			if(writeTestLayer->CreateFeature( writePointFeature ) != OGRERR_NONE ){
-			  std::string errorString="Failed to create feature in ogr vector file";
+			  std::string errorString="Failed to create feature in ogr vector dataset";
 			  throw(errorString);
 			}
 		      }
 		      else{
 			if(writeLayer->CreateFeature( writePointFeature ) != OGRERR_NONE ){
-			  std::string errorString="Failed to create feature in ogr vector file";
+			  std::string errorString="Failed to create feature in ogr vector dataset";
 			  throw(errorString);
 			}
 		      }
@@ -2087,19 +2048,19 @@ int main(int argc, char *argv[])
 		writePolygon.addRing(&writeRing);
 		writePolygon.closeRings();
 		//write geometry of writePolygon
-		writePolygonFeature->SetGeometry(&writePolygon);
 		if(writePolygonFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		  cerr << "writing feature failed" << std::endl;
+		writePolygonFeature->SetGeometry(&writePolygon);
 		if(verbose_opt[0]>1)
-		  std::cout << "copying new fields write polygon " << sample_opt[0] << std::endl;
+		  std::cout << "copying new fields write polygon " << std::endl;
 		if(verbose_opt[0]>1)
 		  std::cout << "write feature has " << writePolygonFeature->GetFieldCount() << " fields" << std::endl;
 		//write polygon feature
 	      }
-	      else{//write mean /median value of polygon to centroid point (ruleMap[rule_opt[0]]==rule::mean /median )
+	      else{//write mean /median value of polygon to centroid point (ruleMap[rule_opt[0]]==rule::mean, stdev or median )
 		//create feature
 		if(verbose_opt[0]>1)
-		  std::cout << "copying fields from polygons " << sample_opt[0] << std::endl;
+		  std::cout << "copying fields from polygons " << std::endl;
 		if(writeCentroidFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		  cerr << "writing feature failed" << std::endl;
 		writeCentroidFeature->SetGeometry(&writeCentroidPoint);
@@ -2110,7 +2071,7 @@ int main(int argc, char *argv[])
 		  std::cout << "write feature has " << writeCentroidFeature->GetFieldCount() << " fields" << std::endl;
 	      }
 	      if(class_opt.empty()){
-		if(ruleMap[rule_opt[0]]==rule::point){//value at each point (or at centroid of polygon if line is set)
+		if(ruleMap[rule_opt[0]]==rule::point){//value at centroid of polygon
 		  if(verbose_opt[0])
 		    std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
 		  for(int index=0;index<polyValues.size();++index){
@@ -2119,7 +2080,7 @@ int main(int argc, char *argv[])
 		    double theValue=polyValues[index].back();
 		    if(verbose_opt[0])
 		      std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
-		    int theBand=(band_opt[0]<0)?index:band_opt[index];
+		    int theBand=(band_opt.size()) ? band_opt[index] : index;
 
 		    if(verbose_opt[0]>1)
 		      std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
@@ -2173,13 +2134,15 @@ int main(int argc, char *argv[])
 		  for(int index=0;index<polyValues.size();++index){
 		    if(ruleMap[rule_opt[0]]==rule::mean)
 		      theValue=stat.mean(polyValues[index]);
+		    else if(ruleMap[rule_opt[0]]==rule::stdev)
+		      theValue=sqrt(stat.var(polyValues[index]));
 		    else if(ruleMap[rule_opt[0]]==rule::median)
 		      theValue=stat.median(polyValues[index]);
 		    else if(ruleMap[rule_opt[0]]==rule::sum)
 		      theValue=stat.sum(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::maximum)
+		    else if(ruleMap[rule_opt[0]]==rule::max)
 		      theValue=stat.mymax(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::minimum)
+		    else if(ruleMap[rule_opt[0]]==rule::min)
 		      theValue=stat.mymin(polyValues[index]);
 		    else{//rule::centroid
 		      if(verbose_opt[0])
@@ -2241,7 +2204,7 @@ int main(int argc, char *argv[])
 		  if(verbose_opt[0])
 		    std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
 		  stat.normalize_pct(polyClassValues);
-		  for(int index=0;index<polyValues.size();++index){
+		  for(int index=0;index<polyClassValues.size();++index){
 		    double theValue=polyClassValues[index];
 		    ostringstream fs;
 		    fs << class_opt[index];
@@ -2275,7 +2238,7 @@ int main(int argc, char *argv[])
 		    writePolygonFeature->SetField(label_opt[0].c_str(),static_cast<int>(20));
 		  }
 		}
-		else if(ruleMap[rule_opt[0]]==rule::maxvote){
+		else if(ruleMap[rule_opt[0]]==rule::mode){
 		  //maximum votes in polygon
 		  if(verbose_opt[0])
 		    std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
@@ -2299,13 +2262,13 @@ int main(int argc, char *argv[])
 		  std::cout << "creating polygon feature" << std::endl;
 		if(writeTest){
 		  if(writeTestLayer->CreateFeature( writePolygonFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create polygon feature in ogr vector file";
+		    std::string errorString="Failed to create polygon feature in ogr vector dataset";
 		    throw(errorString);
 		  }
 		}
 		else{
 		  if(writeLayer->CreateFeature( writePolygonFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create polygon feature in ogr vector file";
+		    std::string errorString="Failed to create polygon feature in ogr vector dataset";
 		    throw(errorString);
 		  }
 		}
@@ -2319,7 +2282,7 @@ int main(int argc, char *argv[])
 		  std::cout << "creating point feature in centroid" << std::endl;
 		if(writeTest){
 		  if(writeTestLayer->CreateFeature( writeCentroidFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create point feature in ogr vector file";
+		    std::string errorString="Failed to create point feature in ogr vector dataset";
 		    throw(errorString);
 		  }
 		}
@@ -2327,7 +2290,7 @@ int main(int argc, char *argv[])
 		  //test
 		  assert(validFeature);
 		  if(writeLayer->CreateFeature( writeCentroidFeature ) != OGRERR_NONE ){
-		    std::string errorString="Failed to create point feature in ogr vector file";
+		    std::string errorString="Failed to create point feature in ogr vector dataset";
 		    throw(errorString);
 		  }
 		}
@@ -2364,11 +2327,13 @@ int main(int argc, char *argv[])
       progress=1.0;
       pfnProgress(progress,pszMessage,pProgressArg);
       ++ilayerWrite;
-    }
+    }//for ilayer
     ogrWriter.close();
+    if(sampleIsVirtual)
+      sampleWriterOgr.close();
     if(test_opt.size())
       ogrTestWriter.close();
-  }
+  }//else (vector)
   progress=1.0;
   pfnProgress(progress,pszMessage,pProgressArg);
   imgReader.close();
diff --git a/src/apps/pkfilter.cc b/src/apps/pkfilter.cc
index 4ea7e06..2645f1b 100644
--- a/src/apps/pkfilter.cc
+++ b/src/apps/pkfilter.cc
@@ -42,7 +42,7 @@ int main(int argc,char **argv) {
   Optionpk<std::string> tmpdir_opt("tmp", "tmp", "Temporary directory","/tmp",2);
   Optionpk<bool> disc_opt("circ", "circular", "circular disc kernel for dilation and erosion", false);
   // Optionpk<double> angle_opt("a", "angle", "angle used for directional filtering in dilation (North=0, East=90, South=180, West=270).");
-  Optionpk<std::string> method_opt("f", "filter", "filter function (median, var, min, max, sum, mean, dilate, erode, close, open, homog (central pixel must be identical to all other pixels within window), heterog, sobelx (horizontal edge detection), sobely (vertical edge detection), sobelxy (diagonal edge detection NE-SW),sobelyx (diagonal edge detection NW-SE), smooth, density, countid, majority voting (only for classes), smoothnodata (smooth nodata values only) values, threshold local  [...]
+  Optionpk<std::string> method_opt("f", "filter", "filter function (median, var, min, max, sum, mean, dilate, erode, close, open, homog (central pixel must be identical to all other pixels within window), heterog, sobelx (horizontal edge detection), sobely (vertical edge detection), sobelxy (diagonal edge detection NE-SW),sobelyx (diagonal edge detection NW-SE), smooth, density, countid, mode (majority voting, only for classes), smoothnodata (smooth nodata values only) values, threshold  [...]
   Optionpk<std::string> resample_opt("r", "resampling-method", "Resampling method for shifting operation (near: nearest neighbour, bilinear: bi-linear interpolation).", "near");
   Optionpk<double> dimX_opt("dx", "dx", "filter kernel size in x, better use odd value to avoid image shift", 3);
   Optionpk<double> dimY_opt("dy", "dy", "filter kernel size in y, better use odd value to avoid image shift", 3);
@@ -54,6 +54,7 @@ int main(int argc,char **argv) {
   Optionpk<short> nodata_opt("nodata", "nodata", "nodata value(s) for smoothnodata filter");
   Optionpk<std::string> tap_opt("tap", "tap", "text file containing taps used for spatial filtering (from ul to lr). Use dimX and dimY to specify tap dimensions in x and y. Leave empty for not using taps");
   Optionpk<double> tapz_opt("tapz", "tapz", "taps used for spectral filtering");
+  Optionpk<string> padding_opt("pad","pad", "Padding method for filtering (how to handle edge effects). Choose between: symmetric, replicate, circular, constant (pad with 0).", "symmetric");
   Optionpk<double> fwhm_opt("fwhm", "fwhm", "list of full width half to apply spectral filtering (-fwhm band1 -fwhm band2 ...)");
   Optionpk<std::string> srf_opt("srf", "srf", "list of ASCII files containing spectral response functions (two columns: wavelength response)");
   Optionpk<double> wavelengthIn_opt("win", "wavelengthIn", "list of wavelengths in input spectrum (-win band1 -win band2 ...)");
@@ -92,6 +93,7 @@ int main(int argc,char **argv) {
     nodata_opt.retrieveOption(argc,argv);
     tap_opt.retrieveOption(argc,argv);
     tapz_opt.retrieveOption(argc,argv);
+    padding_opt.retrieveOption(argc,argv);
     fwhm_opt.retrieveOption(argc,argv);
     srf_opt.retrieveOption(argc,argv);
     wavelengthIn_opt.retrieveOption(argc,argv);
@@ -188,8 +190,13 @@ int main(int argc,char **argv) {
       int nband=fwhm_opt.size()? fwhm_opt.size():srf_opt.size();
       output.open(output_opt[0],(input.nrOfCol()+down_opt[0]-1)/down_opt[0],(input.nrOfRow()+down_opt[0]-1)/down_opt[0],nband,theType,imageType,option_opt);
     }
-    else
-      output.open(output_opt[0],(input.nrOfCol()+down_opt[0]-1)/down_opt[0],(input.nrOfRow()+down_opt[0]-1)/down_opt[0],input.nrOfBand(),theType,imageType,option_opt);
+    else{
+      int nband=input.nrOfBand();
+      if(dimZ_opt.size())
+	if(dimZ_opt[0]==1)
+	  nband=1;
+      output.open(output_opt[0],(input.nrOfCol()+down_opt[0]-1)/down_opt[0],(input.nrOfRow()+down_opt[0]-1)/down_opt[0],nband,theType,imageType,option_opt);
+    }
   }
   catch(string errorstring){
     cout << errorstring << endl;
@@ -220,6 +227,9 @@ int main(int argc,char **argv) {
 
   filter2d::Filter2d filter2d;
   filter::Filter filter1d;
+  if(verbose_opt[0])
+    cout << "Set padding to " << padding_opt[0] << endl;
+  filter1d.setPadding(padding_opt[0]);
   if(class_opt.size()){
     if(verbose_opt[0])
       std::cout<< "class values: ";
@@ -234,6 +244,7 @@ int main(int argc,char **argv) {
     if(verbose_opt[0])
       std::cout<< std::endl;
   }
+
   if(nodata_opt.size()){
     if(verbose_opt[0])
       std::cout<< "mask values: ";
@@ -276,7 +287,7 @@ int main(int argc,char **argv) {
       std::cout<< std::endl;
     }
     filter1d.setTaps(tapz_opt);    
-    filter1d.filter(input,output,down_opt[0]);
+    filter1d.filter(input,output);
   }
   else if(fwhm_opt.size()){
     if(verbose_opt[0])
@@ -383,7 +394,7 @@ int main(int argc,char **argv) {
       if(dimZ_opt.size()){
         if(verbose_opt[0])
           std::cout<< "1-D filtering: dilate" << std::endl;
-        filter1d.morphology(input,output,"dilate",dimZ_opt[0],1,0,verbose_opt[0]);
+        filter1d.morphology(input,output,"dilate",dimZ_opt[0],verbose_opt[0]);
       }
       else{
 	filter2d.morphology(input,output,"dilate",dimX_opt[0],dimY_opt[0],angle_opt,disc_opt[0]);
@@ -706,7 +717,16 @@ int main(int argc,char **argv) {
       if(verbose_opt[0])
 	std::cout << "classes set" << std::endl;
     default:
-      filter2d.doit(input,output,method_opt[0],dimX_opt[0],dimY_opt[0],down_opt[0],disc_opt[0]);
+      if(dimZ_opt.size()){
+	if(dimZ_opt[0]==1)
+	  filter1d.stat(input,output,method_opt[0]);
+	else{
+	  assert(down_opt[0]==1);//not implemented yet...
+	  filter1d.filter(input,output,method_opt[0],dimZ_opt[0]);
+	}
+      }
+      else
+	filter2d.doit(input,output,method_opt[0],dimX_opt[0],dimY_opt[0],down_opt[0],disc_opt[0]);
       break;
     }
   }
diff --git a/src/apps/pkfsann.cc b/src/apps/pkfsann.cc
index a28faa1..d155158 100644
--- a/src/apps/pkfsann.cc
+++ b/src/apps/pkfsann.cc
@@ -174,14 +174,14 @@ int main(int argc, char *argv[])
   Optionpk<string> input_opt("i", "input", "input test set (leave empty to perform a cross validation based on training only)"); 
   Optionpk<string> training_opt("t", "training", "training vector file. A single vector file contains all training features (must be set as: B0, B1, B2,...) for all classes (class numbers identified by label option). Use multiple training files for bootstrap aggregation (alternative to the bag and bsize options, where a random subset is taken from a single training file)"); 
   Optionpk<string> tlayer_opt("tln", "tln", "training layer name(s)");
-  Optionpk<string> label_opt("\0", "label", "identifier for class label in training vector file.","label"); 
+  Optionpk<string> label_opt("label", "label", "identifier for class label in training vector file.","label"); 
   Optionpk<unsigned short> maxFeatures_opt("n", "nf", "number of features to select (0 to select optimal number, see also ecost option)", 0);
   Optionpk<unsigned int> balance_opt("\0", "balance", "balance the input data to this number of samples for each class", 0);
   Optionpk<bool> random_opt("random","random", "in case of balance, randomize input data", true);
-  Optionpk<int> minSize_opt("m", "min", "if number of training pixels is less then min, do not take this class into account", 0);
-  Optionpk<double> start_opt("s", "start", "start band sequence number",0); 
-  Optionpk<double> end_opt("e", "end", "end band sequence number (set to 0 to include all bands)", 0); 
+  Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account", 0);
   Optionpk<short> band_opt("b", "band", "band index (starting from 0, either use band option or use start to end)");
+  Optionpk<double> bstart_opt("bs", "bstart", "start band sequence number",0); 
+  Optionpk<double> bend_opt("be", "bend", "end band sequence number (set to 0 to include all bands)", 0); 
   Optionpk<double> offset_opt("\0", "offset", "offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
   Optionpk<unsigned short> aggreg_opt("a", "aggreg", "how to combine aggregated classifiers, see also rc option (0: no aggregation, 1: sum rule, 2: max rule).",0);
@@ -208,9 +208,9 @@ int main(int argc, char *argv[])
     balance_opt.retrieveOption(argc,argv);
     random_opt.retrieveOption(argc,argv);
     minSize_opt.retrieveOption(argc,argv);
-    start_opt.retrieveOption(argc,argv);
-    end_opt.retrieveOption(argc,argv);
     band_opt.retrieveOption(argc,argv);
+    bstart_opt.retrieveOption(argc,argv);
+    bend_opt.retrieveOption(argc,argv);
     offset_opt.retrieveOption(argc,argv);
     scale_opt.retrieveOption(argc,argv);
     aggreg_opt.retrieveOption(argc,argv);
@@ -316,10 +316,10 @@ int main(int argc, char *argv[])
       }
     }
     else{
-      totalSamples=trainingReader.readDataImageOgr(trainingMap,fields,start_opt[0],end_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
+      totalSamples=trainingReader.readDataImageOgr(trainingMap,fields,bstart_opt[0],bend_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
       if(input_opt.size()){
 	ImgReaderOgr inputReader(input_opt[0]);
-	totalTestSamples=trainingReader.readDataImageOgr(testMap,fields,start_opt[0],end_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
+	totalTestSamples=trainingReader.readDataImageOgr(testMap,fields,bstart_opt[0],bend_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
 	inputReader.close();
       }
     }
diff --git a/src/apps/pkfssvm.cc b/src/apps/pkfssvm.cc
index 7d5fb50..67c96d0 100644
--- a/src/apps/pkfssvm.cc
+++ b/src/apps/pkfssvm.cc
@@ -24,11 +24,10 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include <algorithm>
 #include "base/Optionpk.h"
 #include "algorithms/ConfusionMatrix.h"
-#include "algorithms/CostFactory.h"
+#include "algorithms/CostFactorySVM.h"
 #include "algorithms/FeatureSelector.h"
 #include "algorithms/svm.h"
 #include "imageclasses/ImgReaderOgr.h"
-#include "pkfssvm.h"
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -36,169 +35,162 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 
 using namespace std;
 
-#define Malloc(type,n) (type *)malloc((n)*sizeof(type))
-
-//global parameters used in cost function getCost
-// ConfusionMatrix cm;
-// map<string,short> classValueMap;
-// vector<std::string> nameVector;
-// vector<unsigned int> nctraining;
-// vector<unsigned int> nctest;
-
-CostFactorySVM::CostFactorySVM()
-    : CostFactory(2,0), m_svm_type("C_SVC"), m_kernel_type("radial"), m_kernel_degree(3), m_gamma(1.0), m_coef0(0), m_ccost(1000), m_nu(0.5),  m_epsilon_loss(100), m_cache(100), m_epsilon_tol(0.001), m_shrinking(false), m_prob_est(true){
-}
-
-CostFactorySVM::~CostFactorySVM(){
-}
-
-CostFactorySVM::CostFactorySVM(std::string svm_type, std::string kernel_type, unsigned short kernel_degree, float gamma, float coef0, float ccost, float nu,  float epsilon_loss, int cache, float epsilon_tol, bool shrinking, bool prob_est, unsigned short cv, bool verbose)
-    : CostFactory(cv,verbose), m_svm_type(svm_type), m_kernel_type(kernel_type), m_kernel_degree(kernel_degree), m_gamma(gamma), m_coef0(coef0), m_ccost(ccost), m_nu(nu),  m_epsilon_loss(epsilon_loss), m_cache(cache), m_epsilon_tol(epsilon_tol), m_shrinking(shrinking), m_prob_est(prob_est){};
-
-double CostFactorySVM::getCost(const vector<Vector2d<float> > &trainingFeatures){
-  std::map<std::string, svm::SVM_TYPE> svmMap;
-
-  svmMap["C_SVC"]=svm::C_SVC;
-  svmMap["nu_SVC"]=svm::nu_SVC;
-  svmMap["one_class"]=svm::one_class;
-  svmMap["epsilon_SVR"]=svm::epsilon_SVR;
-  svmMap["nu_SVR"]=svm::nu_SVR;
-
-  std::map<std::string, svm::KERNEL_TYPE> kernelMap;
-
-  kernelMap["linear"]=svm::linear;
-  kernelMap["polynomial"]=svm::polynomial;
-  kernelMap["radial"]=svm::radial;
-  kernelMap["sigmoid;"]=svm::sigmoid;
-
-  unsigned short nclass=trainingFeatures.size();
-  unsigned int ntraining=0;
-  unsigned int ntest=0;
-  for(int iclass=0;iclass<nclass;++iclass){
-    ntraining+=m_nctraining[iclass];
-    ntest+=m_nctest[iclass];
-  }
-  if(ntest)
-    assert(!m_cv);
-  if(!m_cv)
-    assert(ntest);
-  unsigned short nFeatures=trainingFeatures[0][0].size();
-
-  struct svm_parameter param;
-  param.svm_type = svmMap[m_svm_type];
-  param.kernel_type = kernelMap[m_kernel_type];
-  param.degree = m_kernel_degree;
-  param.gamma = (m_gamma>0)? m_gamma : 1.0/nFeatures;
-  param.coef0 = m_coef0;
-  param.nu = m_nu;
-  param.cache_size = m_cache;
-  param.C = m_ccost;
-  param.eps = m_epsilon_tol;
-  param.p = m_epsilon_loss;
-  param.shrinking = (m_shrinking)? 1 : 0;
-  param.probability = (m_prob_est)? 1 : 0;
-  param.nr_weight = 0;//not used: I use priors and balancing
-  param.weight_label = NULL;
-  param.weight = NULL;
-  param.verbose=(m_verbose>1)? true:false;
-  struct svm_model* svm;
-  struct svm_problem prob;
-  struct svm_node* x_space;
-
-  prob.l=ntraining;
-  prob.y = Malloc(double,prob.l);
-  prob.x = Malloc(struct svm_node *,prob.l);
-  x_space = Malloc(struct svm_node,(nFeatures+1)*ntraining);
-  unsigned long int spaceIndex=0;
-  int lIndex=0;
-  for(int iclass=0;iclass<nclass;++iclass){
-    // for(int isample=0;isample<trainingFeatures[iclass].size();++isample){
-    for(int isample=0;isample<m_nctraining[iclass];++isample){
-      prob.x[lIndex]=&(x_space[spaceIndex]);
-      for(int ifeature=0;ifeature<nFeatures;++ifeature){
-        x_space[spaceIndex].index=ifeature+1;
-        x_space[spaceIndex].value=trainingFeatures[iclass][isample][ifeature];
-        ++spaceIndex;
-      }
-      x_space[spaceIndex++].index=-1;
-      prob.y[lIndex]=iclass;
-      ++lIndex;
-    }
-  }
-
-  assert(lIndex==prob.l);
-  if(m_verbose>2)
-    std::cout << "checking parameters" << std::endl;
-  svm_check_parameter(&prob,&param);
-  if(m_verbose>2)
-    std::cout << "parameters ok, training" << std::endl;
-  svm=svm_train(&prob,&param);
-  if(m_verbose>2)
-    std::cout << "SVM is now trained" << std::endl;
-
-  m_cm.clearResults();
-  if(m_cv>1){
-    double *target = Malloc(double,prob.l);
-    svm_cross_validation(&prob,&param,m_cv,target);
-    assert(param.svm_type != EPSILON_SVR&&param.svm_type != NU_SVR);//only for regression
-    for(int i=0;i<prob.l;i++){
-      string refClassName=m_nameVector[prob.y[i]];
-      string className=m_nameVector[target[i]];
-      if(m_classValueMap.size())
-	m_cm.incrementResult(type2string<short>(m_classValueMap[refClassName]),type2string<short>(m_classValueMap[className]),1.0);
-      else
-	m_cm.incrementResult(m_cm.getClass(prob.y[i]),m_cm.getClass(target[i]),1.0);
-    }
-    free(target);
-  }
-  else{
-    struct svm_node *x_test;
-    vector<double> result(nclass);
-    x_test = Malloc(struct svm_node,(nFeatures+1));
-    for(int iclass=0;iclass<nclass;++iclass){
-      for(int isample=0;isample<m_nctest[iclass];++isample){
-	for(int ifeature=0;ifeature<nFeatures;++ifeature){
-	  x_test[ifeature].index=ifeature+1;
-	  x_test[ifeature].value=trainingFeatures[iclass][m_nctraining[iclass]+isample][ifeature];
-	}
-	x_test[nFeatures].index=-1;
-	double predict_label=0;
-	assert(svm_check_probability_model(svm));
-	predict_label = svm_predict_probability(svm,x_test,&(result[0]));
-	// predict_label = svm_predict(svm,x_test);
-	string refClassName=m_nameVector[iclass];
-	string className=m_nameVector[static_cast<short>(predict_label)];
-	if(m_classValueMap.size())
-	  m_cm.incrementResult(type2string<short>(m_classValueMap[refClassName]),type2string<short>(m_classValueMap[className]),1.0);
-	else
-	  m_cm.incrementResult(refClassName,className,1.0);
-      }
-    }
-    free(x_test);
-  }
-  if(m_verbose>1)
-    std::cout << m_cm << std::endl;
-  assert(m_cm.nReference());
-  // if(m_verbose)
-
-  // std::cout << m_cm << std::endl;
-  // std::cout << "Kappa: " << m_cm.kappa() << std::endl;
-  // double se95_oa=0;
-  // double doa=0;
-  // doa=m_cm.oa_pct(&se95_oa);
-  // std::cout << "Overall Accuracy: " << doa << " (" << se95_oa << ")"  << std::endl;
-
-  // *NOTE* Because svm_model contains pointers to svm_problem, you can
-  // not free the memory used by svm_problem if you are still using the
-  // svm_model produced by svm_train(). 
-  // however, we will re-train the svm later on after the feature selection
-  free(prob.y);
-  free(prob.x);
-  free(x_space);
-  svm_free_and_destroy_model(&(svm));
-
-  return(m_cm.kappa());
-}
+enum SelectorValue  { NA=0, SFFS=1, SFS=2, SBS=3, BFS=4};
+
+// CostFactorySVM::CostFactorySVM()
+//     : CostFactory(2,0), m_svm_type("C_SVC"), m_kernel_type("radial"), m_kernel_degree(3), m_gamma(1.0), m_coef0(0), m_ccost(1000), m_nu(0.5),  m_epsilon_loss(100), m_cache(100), m_epsilon_tol(0.001), m_shrinking(false), m_prob_est(true){
+// }
+
+// CostFactorySVM::~CostFactorySVM(){
+// }
+
+// CostFactorySVM::CostFactorySVM(std::string svm_type, std::string kernel_type, unsigned short kernel_degree, float gamma, float coef0, float ccost, float nu,  float epsilon_loss, int cache, float epsilon_tol, bool shrinking, bool prob_est, unsigned short cv, bool verbose)
+//     : CostFactory(cv,verbose), m_svm_type(svm_type), m_kernel_type(kernel_type), m_kernel_degree(kernel_degree), m_gamma(gamma), m_coef0(coef0), m_ccost(ccost), m_nu(nu),  m_epsilon_loss(epsilon_loss), m_cache(cache), m_epsilon_tol(epsilon_tol), m_shrinking(shrinking), m_prob_est(prob_est){};
+
+// double CostFactorySVM::getCost(const vector<Vector2d<float> > &trainingFeatures){
+//   std::map<std::string, svm::SVM_TYPE> svmMap;
+
+//   svmMap["C_SVC"]=svm::C_SVC;
+//   svmMap["nu_SVC"]=svm::nu_SVC;
+//   svmMap["one_class"]=svm::one_class;
+//   svmMap["epsilon_SVR"]=svm::epsilon_SVR;
+//   svmMap["nu_SVR"]=svm::nu_SVR;
+
+//   std::map<std::string, svm::KERNEL_TYPE> kernelMap;
+
+//   kernelMap["linear"]=svm::linear;
+//   kernelMap["polynomial"]=svm::polynomial;
+//   kernelMap["radial"]=svm::radial;
+//   kernelMap["sigmoid;"]=svm::sigmoid;
+
+//   unsigned short nclass=trainingFeatures.size();
+//   unsigned int ntraining=0;
+//   unsigned int ntest=0;
+//   for(int iclass=0;iclass<nclass;++iclass){
+//     ntraining+=m_nctraining[iclass];
+//     ntest+=m_nctest[iclass];
+//   }
+//   if(ntest)
+//     assert(!m_cv);
+//   if(!m_cv)
+//     assert(ntest);
+//   unsigned short nFeatures=trainingFeatures[0][0].size();
+
+//   struct svm_parameter param;
+//   param.svm_type = svmMap[m_svm_type];
+//   param.kernel_type = kernelMap[m_kernel_type];
+//   param.degree = m_kernel_degree;
+//   param.gamma = (m_gamma>0)? m_gamma : 1.0/nFeatures;
+//   param.coef0 = m_coef0;
+//   param.nu = m_nu;
+//   param.cache_size = m_cache;
+//   param.C = m_ccost;
+//   param.eps = m_epsilon_tol;
+//   param.p = m_epsilon_loss;
+//   param.shrinking = (m_shrinking)? 1 : 0;
+//   param.probability = (m_prob_est)? 1 : 0;
+//   param.nr_weight = 0;//not used: I use priors and balancing
+//   param.weight_label = NULL;
+//   param.weight = NULL;
+//   param.verbose=(m_verbose>1)? true:false;
+//   struct svm_model* svm;
+//   struct svm_problem prob;
+//   struct svm_node* x_space;
+
+//   prob.l=ntraining;
+//   prob.y = Malloc(double,prob.l);
+//   prob.x = Malloc(struct svm_node *,prob.l);
+//   x_space = Malloc(struct svm_node,(nFeatures+1)*ntraining);
+//   unsigned long int spaceIndex=0;
+//   int lIndex=0;
+//   for(int iclass=0;iclass<nclass;++iclass){
+//     // for(int isample=0;isample<trainingFeatures[iclass].size();++isample){
+//     for(int isample=0;isample<m_nctraining[iclass];++isample){
+//       prob.x[lIndex]=&(x_space[spaceIndex]);
+//       for(int ifeature=0;ifeature<nFeatures;++ifeature){
+//         x_space[spaceIndex].index=ifeature+1;
+//         x_space[spaceIndex].value=trainingFeatures[iclass][isample][ifeature];
+//         ++spaceIndex;
+//       }
+//       x_space[spaceIndex++].index=-1;
+//       prob.y[lIndex]=iclass;
+//       ++lIndex;
+//     }
+//   }
+
+//   assert(lIndex==prob.l);
+//   if(m_verbose>2)
+//     std::cout << "checking parameters" << std::endl;
+//   svm_check_parameter(&prob,&param);
+//   if(m_verbose>2)
+//     std::cout << "parameters ok, training" << std::endl;
+//   svm=svm_train(&prob,&param);
+//   if(m_verbose>2)
+//     std::cout << "SVM is now trained" << std::endl;
+
+//   m_cm.clearResults();
+//   if(m_cv>1){
+//     double *target = Malloc(double,prob.l);
+//     svm_cross_validation(&prob,&param,m_cv,target);
+//     assert(param.svm_type != EPSILON_SVR&&param.svm_type != NU_SVR);//only for regression
+//     for(int i=0;i<prob.l;i++){
+//       string refClassName=m_nameVector[prob.y[i]];
+//       string className=m_nameVector[target[i]];
+//       if(m_classValueMap.size())
+// 	m_cm.incrementResult(type2string<short>(m_classValueMap[refClassName]),type2string<short>(m_classValueMap[className]),1.0);
+//       else
+// 	m_cm.incrementResult(m_cm.getClass(prob.y[i]),m_cm.getClass(target[i]),1.0);
+//     }
+//     free(target);
+//   }
+//   else{
+//     struct svm_node *x_test;
+//     vector<double> result(nclass);
+//     x_test = Malloc(struct svm_node,(nFeatures+1));
+//     for(int iclass=0;iclass<nclass;++iclass){
+//       for(int isample=0;isample<m_nctest[iclass];++isample){
+// 	for(int ifeature=0;ifeature<nFeatures;++ifeature){
+// 	  x_test[ifeature].index=ifeature+1;
+// 	  x_test[ifeature].value=trainingFeatures[iclass][m_nctraining[iclass]+isample][ifeature];
+// 	}
+// 	x_test[nFeatures].index=-1;
+// 	double predict_label=0;
+// 	assert(svm_check_probability_model(svm));
+// 	predict_label = svm_predict_probability(svm,x_test,&(result[0]));
+// 	// predict_label = svm_predict(svm,x_test);
+// 	string refClassName=m_nameVector[iclass];
+// 	string className=m_nameVector[static_cast<short>(predict_label)];
+// 	if(m_classValueMap.size())
+// 	  m_cm.incrementResult(type2string<short>(m_classValueMap[refClassName]),type2string<short>(m_classValueMap[className]),1.0);
+// 	else
+// 	  m_cm.incrementResult(refClassName,className,1.0);
+//       }
+//     }
+//     free(x_test);
+//   }
+//   if(m_verbose>1)
+//     std::cout << m_cm << std::endl;
+//   assert(m_cm.nReference());
+//   // if(m_verbose)
+
+//   // std::cout << m_cm << std::endl;
+//   // std::cout << "Kappa: " << m_cm.kappa() << std::endl;
+//   // double se95_oa=0;
+//   // double doa=0;
+//   // doa=m_cm.oa_pct(&se95_oa);
+//   // std::cout << "Overall Accuracy: " << doa << " (" << se95_oa << ")"  << std::endl;
+
+//   // *NOTE* Because svm_model contains pointers to svm_problem, you can
+//   // not free the memory used by svm_problem if you are still using the
+//   // svm_model produced by svm_train(). 
+//   // however, we will re-train the svm later on after the feature selection
+//   free(prob.y);
+//   free(prob.x);
+//   free(x_space);
+//   svm_free_and_destroy_model(&(svm));
+
+//   return(m_cm.kappa());
+// }
 
 int main(int argc, char *argv[])
 {
@@ -208,14 +200,14 @@ int main(int argc, char *argv[])
   Optionpk<string> input_opt("i", "input", "input test set (leave empty to perform a cross validation based on training only)"); 
   Optionpk<string> training_opt("t", "training", "training vector file. A single vector file contains all training features (must be set as: B0, B1, B2,...) for all classes (class numbers identified by label option)."); 
   Optionpk<string> tlayer_opt("tln", "tln", "training layer name(s)");
-  Optionpk<string> label_opt("\0", "label", "identifier for class label in training vector file.","label"); 
+  Optionpk<string> label_opt("label", "label", "identifier for class label in training vector file.","label"); 
   Optionpk<unsigned short> maxFeatures_opt("n", "nf", "number of features to select (0 to select optimal number, see also ecost option)", 0);
-  Optionpk<unsigned int> balance_opt("\0", "balance", "balance the input data to this number of samples for each class", 0);
+  Optionpk<unsigned int> balance_opt("bal", "balance", "balance the input data to this number of samples for each class", 0);
   Optionpk<bool> random_opt("random","random", "in case of balance, randomize input data", true);
-  Optionpk<int> minSize_opt("m", "min", "if number of training pixels is less then min, do not take this class into account", 0);
-  Optionpk<double> start_opt("s", "start", "start band sequence number",0); 
-  Optionpk<double> end_opt("e", "end", "end band sequence number (set to 0 to include all bands)", 0); 
+  Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account", 0);
   Optionpk<short> band_opt("b", "band", "band index (starting from 0, either use band option or use start to end)");
+  Optionpk<double> bstart_opt("bs", "bstart", "start band sequence number",0); 
+  Optionpk<double> bend_opt("be", "bend", "end band sequence number (set to 0 to include all bands)", 0); 
   Optionpk<double> offset_opt("\0", "offset", "offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
   Optionpk<string> selector_opt("sm", "sm", "feature selection method (sffs=sequential floating forward search,sfs=sequential forward search, sbs, sequential backward search ,bfs=brute force search)","sffs"); 
@@ -248,9 +240,9 @@ int main(int argc, char *argv[])
     balance_opt.retrieveOption(argc,argv);
     random_opt.retrieveOption(argc,argv);
     minSize_opt.retrieveOption(argc,argv);
-    start_opt.retrieveOption(argc,argv);
-    end_opt.retrieveOption(argc,argv);
     band_opt.retrieveOption(argc,argv);
+    bstart_opt.retrieveOption(argc,argv);
+    bend_opt.retrieveOption(argc,argv);
     offset_opt.retrieveOption(argc,argv);
     scale_opt.retrieveOption(argc,argv);
     // priors_opt.retrieveOption(argc,argv);
@@ -358,10 +350,10 @@ int main(int argc, char *argv[])
       }
     }
     else{
-      totalSamples=trainingReader.readDataImageOgr(trainingMap,fields,start_opt[0],end_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
+      totalSamples=trainingReader.readDataImageOgr(trainingMap,fields,bstart_opt[0],bend_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
       if(input_opt.size()){
 	ImgReaderOgr inputReader(input_opt[0]);
-	totalTestSamples=inputReader.readDataImageOgr(testMap,fields,start_opt[0],end_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
+	totalTestSamples=inputReader.readDataImageOgr(testMap,fields,bstart_opt[0],bend_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
 	inputReader.close();
       }
     }
diff --git a/src/apps/pkinfo.cc b/src/apps/pkinfo.cc
index 75f1fb1..116456c 100644
--- a/src/apps/pkinfo.cc
+++ b/src/apps/pkinfo.cc
@@ -258,33 +258,39 @@ int main(int argc, char *argv[])
     double maxValue=0;
     double meanValue=0;
     double stdDev=0;
-    if(stat_opt[0]){
-      assert(band_opt[0]<imgReader.nrOfBand());
-      GDALProgressFunc pfnProgress;
-      void* pProgressData;
-      GDALRasterBand* rasterBand;
-      rasterBand=imgReader.getRasterBand(band_opt[0]);
-      rasterBand->ComputeStatistics(0,&minValue,&maxValue,&meanValue,&stdDev,pfnProgress,pProgressData);
-      std::cout << "-min " << minValue << " -max " << maxValue << " --mean " << meanValue << " --stdDev " << stdDev << " ";
-    }
-
-    if(minmax_opt[0]||min_opt[0]||max_opt[0]){
-      assert(band_opt[0]<imgReader.nrOfBand());
-      if((ulx_opt.size()||uly_opt.size()||lrx_opt.size()||lry_opt.size())&&(imgReader.covers(ulx_opt[0],uly_opt[0],lrx_opt[0],lry_opt[0]))){
-	double uli,ulj,lri,lrj;
-	imgReader.geo2image(ulx_opt[0],uly_opt[0],uli,ulj);
-	imgReader.geo2image(lrx_opt[0],lry_opt[0],lri,lrj);
-	imgReader.getMinMax(static_cast<int>(uli),static_cast<int>(lri),static_cast<int>(ulj),static_cast<int>(lrj),band_opt[0],minValue,maxValue);
+    int nband=band_opt.size();
+    if(band_opt[0]<0)
+      nband=imgReader.nrOfBand();
+    for(int iband=0;iband<nband;++iband){
+      unsigned short theBand=(band_opt[0]<0)? iband : band_opt[iband];
+      if(stat_opt[0]){
+	assert(theBand<imgReader.nrOfBand());
+	GDALProgressFunc pfnProgress;
+	void* pProgressData;
+	GDALRasterBand* rasterBand;
+	rasterBand=imgReader.getRasterBand(theBand);
+	rasterBand->ComputeStatistics(0,&minValue,&maxValue,&meanValue,&stdDev,pfnProgress,pProgressData);
+	std::cout << "-min " << minValue << " -max " << maxValue << " --mean " << meanValue << " --stdDev " << stdDev << " ";
       }
-      else
-	imgReader.getMinMax(minValue,maxValue,band_opt[0],true);
-      if(minmax_opt[0])
-	std::cout << "-min " << minValue << " -max " << maxValue << " ";
-      else{
-	if(min_opt[0])
-	  std::cout << "-min " << minValue << " ";
-	if(max_opt[0])
-	  std::cout << "-max " << maxValue << " ";
+
+      if(minmax_opt[0]||min_opt[0]||max_opt[0]){
+	assert(theBand<imgReader.nrOfBand());
+	if((ulx_opt.size()||uly_opt.size()||lrx_opt.size()||lry_opt.size())&&(imgReader.covers(ulx_opt[0],uly_opt[0],lrx_opt[0],lry_opt[0]))){
+	  double uli,ulj,lri,lrj;
+	  imgReader.geo2image(ulx_opt[0],uly_opt[0],uli,ulj);
+	  imgReader.geo2image(lrx_opt[0],lry_opt[0],lri,lrj);
+	  imgReader.getMinMax(static_cast<int>(uli),static_cast<int>(lri),static_cast<int>(ulj),static_cast<int>(lrj),theBand,minValue,maxValue);
+	}
+	else
+	  imgReader.getMinMax(minValue,maxValue,theBand,true);
+	if(minmax_opt[0])
+	  std::cout << "-min " << minValue << " -max " << maxValue << " ";
+	else{
+	  if(min_opt[0])
+	    std::cout << "-min " << minValue << " ";
+	  if(max_opt[0])
+	    std::cout << "-max " << maxValue << " ";
+	}
       }
     }
     if(relative_opt[0])
@@ -374,9 +380,9 @@ int main(int argc, char *argv[])
 //       }
     }
     if(read_opt[0]){
-      int nband=band_opt.size();
-      if(band_opt[0]<0)
-        nband=imgReader.nrOfBand();
+      // int nband=band_opt.size();
+      // if(band_opt[0]<0)
+      //   nband=imgReader.nrOfBand();
       std::cout.precision(12);
       for(int iband=0;iband<nband;++iband){
         unsigned short theBand=(band_opt[0]<0)? iband : band_opt[iband];
diff --git a/src/apps/pkkalman.cc b/src/apps/pkkalman.cc
index 860b90b..24dd44b 100644
--- a/src/apps/pkkalman.cc
+++ b/src/apps/pkkalman.cc
@@ -41,7 +41,6 @@ int main(int argc,char **argv) {
   Optionpk<string> outputfw_opt("ofw", "outputfw", "Output raster dataset for forward model");
   Optionpk<string> outputbw_opt("obw", "outputbw", "Output raster dataset for backward model");
   Optionpk<string> outputfb_opt("ofb", "outputfb", "Output raster dataset for smooth model");
-  Optionpk<float> threshold_opt("th", "threshold", "threshold for selecting samples (randomly). Provide probability in percentage (>0) or absolute (<0).", 0);
   Optionpk<double> modnodata_opt("modnodata", "modnodata", "invalid value for model input", 0);
   Optionpk<double> obsnodata_opt("obsnodata", "obsnodata", "invalid value for observation input", 0);
   Optionpk<double> modoffset_opt("modoffset", "modoffset", "offset used to read model input dataset (value=offset+scale*readValue", 0);
@@ -51,10 +50,16 @@ int main(int argc,char **argv) {
   Optionpk<double> eps_opt("eps", "eps", "epsilon for non zero division", 0.00001);
   Optionpk<double> uncertModel_opt("um", "uncertmodel", "Multiply this value with std dev of first model image to obtain uncertainty of model",2);
   Optionpk<double> uncertObs_opt("uo", "uncertobs", "Uncertainty of valid observations",0);
+  Optionpk<double> deltaObs_opt("dobs", "deltaobs", "Threshold for relative difference (in percentage) in observation and model pixel");
   Optionpk<double> uncertNodata_opt("unodata", "uncertnodata", "Uncertainty in case of no-data values in observation", 10000);
   // Optionpk<double> regTime_opt("rt", "regtime", "Relative Weight for regression in time series", 1.0);
   // Optionpk<double> regSensor_opt("rs", "regsensor", "Relative Weight for regression in sensor series", 1.0);
   Optionpk<int> down_opt("down", "down", "Downsampling factor for reading model data to calculate regression", 9);
+  Optionpk<float> threshold_opt("th", "threshold", "threshold for selecting samples (randomly). Provide probability in percentage (>0) or absolute (<0).", 0);
+  Optionpk<int> minreg_opt("minreg", "minreg", "Minimum number of pixels to take into account for regression", 5, 2);
+  // Optionpk<bool> regObs_opt("regobs", "regobs", "Perform regression between modeled and observed value",false);
+  // Optionpk<double> checkDiff_opt("diff", "diff", "Flag observation as invalid if difference with model is above uncertainty",false);
+  Optionpk<unsigned short> window_opt("win", "window", "window size for calculating regression (use 0 for global)", 0);
   Optionpk<string>  oformat_opt("of", "oformat", "Output image format (see also gdal_translate). Empty string: inherit from input image","GTiff",2);
   Optionpk<string> option_opt("co", "co", "Creation option for output file. Multiple options can be specified.");
   Optionpk<short> verbose_opt("v", "verbose", "verbose mode when positive", 0);
@@ -70,7 +75,6 @@ int main(int argc,char **argv) {
     outputfw_opt.retrieveOption(argc,argv);
     outputbw_opt.retrieveOption(argc,argv);
     outputfb_opt.retrieveOption(argc,argv);
-    threshold_opt.retrieveOption(argc,argv);
     modnodata_opt.retrieveOption(argc,argv);
     obsnodata_opt.retrieveOption(argc,argv);
     modoffset_opt.retrieveOption(argc,argv);
@@ -80,10 +84,16 @@ int main(int argc,char **argv) {
     eps_opt.retrieveOption(argc,argv);
     uncertModel_opt.retrieveOption(argc,argv);
     uncertObs_opt.retrieveOption(argc,argv);
+    deltaObs_opt.retrieveOption(argc,argv);
     uncertNodata_opt.retrieveOption(argc,argv);
     // regTime_opt.retrieveOption(argc,argv);
     // regSensor_opt.retrieveOption(argc,argv);
     down_opt.retrieveOption(argc,argv);
+    threshold_opt.retrieveOption(argc,argv);
+    minreg_opt.retrieveOption(argc,argv);
+    // regObs_opt.retrieveOption(argc,argv);
+    // checkDiff_opt.retrieveOption(argc,argv);
+    window_opt.retrieveOption(argc,argv);
     oformat_opt.retrieveOption(argc,argv);
     option_opt.retrieveOption(argc,argv);
     verbose_opt.retrieveOption(argc,argv);
@@ -156,6 +166,7 @@ int main(int argc,char **argv) {
   }
 
   statfactory::StatFactory stat;
+  stat.setNoDataValues(modnodata_opt);
   imgregression::ImgRegression imgreg;
   // vector<ImgReaderGdal> imgReaderModel(model_opt.size());
   // vector<ImgReaderGdal> imgReaderObs(observation_opt.size());
@@ -194,6 +205,11 @@ int main(int argc,char **argv) {
   imgreg.setDown(down_opt[0]);
   imgreg.setThreshold(threshold_opt[0]);
 
+  double c0modGlobal=0;//time regression coefficient c0 calculated on entire image 
+  double c1modGlobal=0;//time regression coefficient c1 calculated on entire image 
+  double c0mod=0;//time regression coefficient c0 calculated on local window
+  double c1mod=0;//time regression coefficient c1 calculated on local window
+
   double c0obs=0;
   double c1obs=0;
   double errObs=uncertNodata_opt[0];//start with high initial value in case we do not have first observation at time 0
@@ -281,10 +297,15 @@ int main(int argc,char **argv) {
 	try{
 	  imgReaderModel1.readData(estReadBuffer,GDT_Float64,modRow);
 	  //simple nearest neighbor
-	  stat.nearUp(estReadBuffer,estWriteBuffer);
-	  imgWriterEst.writeData(estWriteBuffer,GDT_Float64,irow,0);
-	  for(int icol=0;icol<ncol;++icol)
+	  //stat.nearUp(estReadBuffer,estWriteBuffer);
+
+	  for(int icol=0;icol<ncol;++icol){
+	    imgWriterEst.image2geo(icol,irow,x,y);
+	    imgReaderModel1.geo2image(x,y,modCol,modRow);
+	    estWriteBuffer[icol]=estReadBuffer[modCol];
 	    uncertWriteBuffer[icol]=uncertModel_opt[0]*stdDev;
+	  }
+	  imgWriterEst.writeData(estWriteBuffer,GDT_Float64,irow,0);
 	  imgWriterEst.writeData(uncertWriteBuffer,GDT_Float64,irow,1);
 	}
 	catch(string errorString){
@@ -398,13 +419,12 @@ int main(int argc,char **argv) {
       //to keep it general, we must redo it (overlap might have changed)
     
       pfnProgress(progress,pszMessage,pProgressArg);
-      double c0mod=0;
-      double c1mod=0;
 
       if(verbose_opt[0])
-	  cout << "Calculating regression for " << imgReaderModel1.getFileName() << " " << imgReaderModel2.getFileName() << endl;
-      double errMod=imgreg.getRMSE(imgReaderModel1,imgReaderModel2,c0mod,c1mod);
-      // double errMod=imgreg.getRMSE(imgReaderModel1,imgReaderModel2,c0mod,c1mod,verbose_opt[0]);
+	cout << "Calculating regression for " << imgReaderModel1.getFileName() << " " << imgReaderModel2.getFileName() << endl;
+      
+      double errMod=imgreg.getRMSE(imgReaderModel1,imgReaderModel2,c0modGlobal,c1modGlobal);
+      // double errMod=imgreg.getRMSE(imgReaderModel1,imgReaderModel2,c0modGlobal,c1modGlobal,verbose_opt[0]);
 
       bool update=false;
       if(obsindex<relobsindex.size()){
@@ -440,51 +460,146 @@ int main(int argc,char **argv) {
       imgReaderEst.setOffset(obsoffset_opt[0]);
       imgReaderEst.setScale(obsscale_opt[0]);
 
-      vector<double> obsBuffer;
-      vector<double> modelBuffer;
-      vector<double> uncertObsBuffer;
+      vector<double> obsLineBuffer;
+      vector<double> obsWindowBuffer;//buffer for observation to calculate average corresponding to model pixel
+      vector<double> model1LineBuffer;
+      vector<double> model2LineBuffer;
+      vector<double> model1buffer;//buffer for model 1 to calculate time regression based on window
+      vector<double> model2buffer;//buffer for model 2 to calculate time regression based on window
+      vector<double> uncertObsLineBuffer;
       vector<double> estReadBuffer;
+      // vector<double> estWindowBuffer;//buffer for estimate to calculate average corresponding to model pixel
       vector<double> uncertReadBuffer;
       vector<double> estWriteBuffer(ncol);
       vector<double> uncertWriteBuffer(ncol);
 
       for(int irow=0;irow<imgWriterEst.nrOfRow();++irow){
 	assert(irow<imgReaderEst.nrOfRow());
+	//not needed here, because we read entire window for each pixel...
 	imgReaderEst.readData(estReadBuffer,GDT_Float64,irow,0);
 	imgReaderEst.readData(uncertReadBuffer,GDT_Float64,irow,1);
 	//read model2 in case current estimate is nodata
 	imgReaderEst.image2geo(0,irow,x,y);
 	imgReaderModel2.geo2image(x,y,modCol,modRow);
 	assert(modRow>=0&&modRow<imgReaderModel2.nrOfRow());
-	imgReaderModel2.readData(modelBuffer,GDT_Float64,modRow,0);
+	imgReaderModel2.readData(model2LineBuffer,GDT_Float64,modRow,0);
+
+	imgReaderModel1.geo2image(x,y,modCol,modRow);
+	assert(modRow>=0&&modRow<imgReaderModel1.nrOfRow());
+	imgReaderModel1.readData(model1LineBuffer,GDT_Float64,modRow,0);
+
 	if(update){
-	  imgReaderObs.readData(obsBuffer,GDT_Float64,irow,0);
+	  imgReaderObs.readData(obsLineBuffer,GDT_Float64,irow,0);
 	  if(imgReaderObs.nrOfBand()>1)
-	    imgReaderObs.readData(uncertObsBuffer,GDT_Float64,irow,1);
+	    imgReaderObs.readData(uncertObsLineBuffer,GDT_Float64,irow,1);
 	}
 	for(int icol=0;icol<imgWriterEst.nrOfCol();++icol){
+	  int minCol=(icol>down_opt[0]/2) ? icol-down_opt[0]/2 : 0;
+	  int maxCol=(icol+down_opt[0]/2<imgReaderEst.nrOfCol()) ? icol+down_opt[0]/2 : imgReaderEst.nrOfCol()-1;
+	  int minRow=(irow>down_opt[0]/2) ? irow-down_opt[0]/2 : 0;
+	  int maxRow=(irow+down_opt[0]/2<imgReaderEst.nrOfRow()) ? irow+down_opt[0]/2 : imgReaderEst.nrOfRow()-1;
+	  if(update)
+	    imgReaderObs.readDataBlock(obsWindowBuffer,GDT_Float64,minCol,maxCol,minRow,maxRow,0);
+	  // imgReaderEst.readDataBlock(estWindowBuffer,GDT_Float64,minCol,maxCol,minRow,maxRow,0);
 	  double estValue=estReadBuffer[icol];
+	  // double estValue=estWindowBuffer[estWindowBuffer.size()/2];
+	  double estMeanValue=0;//stat.mean(estWindowBuffer);
+	  double nvalid=0;
 	  //time update
-	  if(imgReaderEst.isNoData(estValue)){
-	    //pk: in case we have not found any valid data yet, better here to take the current model value
-	    imgReaderEst.image2geo(icol,irow,x,y);
-	    imgReaderModel2.geo2image(x,y,modCol,modRow);
-	    assert(modRow>=0&&modRow<imgReaderModel2.nrOfRow());
-	    if(imgReaderModel2.isNoData(modelBuffer[modCol])){//if both estimate and model are no-data, set obs to nodata
+	  imgReaderEst.image2geo(icol,irow,x,y);
+	  imgReaderModel2.geo2image(x,y,modCol,modRow);
+	  assert(modRow>=0&&modRow<imgReaderModel2.nrOfRow());
+	  double modValue=model2LineBuffer[modCol];
+	  bool estNodata=imgReaderEst.isNoData(estValue);
+	  //todo: debug checkDiff_opt 
+	  // if(checkDiff_opt[0]){
+	  //   vector<double>::iterator itwin=estWindowBuffer.begin();
+	  //   while(itwin!=estWindowBuffer.end()){
+	  //     if(!imgReaderEst.isNoData(*itwin)){
+	  // 	estMeanValue+=*itwin;
+	  // 	++nvalid;
+	  //     }
+	  //     ++itwin;
+	  //   }
+	  //   estMeanValue/=nvalid;
+	  //   double difference=(estMeanValue-c0obs)/c1obs-model1LineBuffer[modCol];
+	  //   difference*=difference;
+	  //   estNodata=estNodata||(sqrt(difference)>uncertModel_opt[0]*stdDev);
+	  // }
+	  if(estNodata){
+	    //we have not found any valid data yet, better here to take the current model value if valid
+	    if(imgReaderModel2.isNoData(modValue)){//if both estimate and model are no-data, set obs to nodata
 	      estWriteBuffer[icol]=obsnodata_opt[0];
 	      uncertWriteBuffer[icol]=uncertNodata_opt[0];
 	    }
 	    else{
-	      estWriteBuffer[icol]=modelBuffer[modCol];
+	      estWriteBuffer[icol]=modValue;
 	      uncertWriteBuffer[icol]=uncertModel_opt[0]*stdDev;
 	    }
 	  }	  
 	  else{
+	    if(window_opt[0]>0){
+	      try{
+		// imgReaderModel2.geo2image(x,y,modCol,modRow);//did that already
+		minCol=(modCol>window_opt[0]/2) ? modCol-window_opt[0]/2 : 0;
+		maxCol=(modCol+window_opt[0]/2<imgReaderModel2.nrOfCol()) ? modCol+window_opt[0]/2 : imgReaderModel2.nrOfCol()-1;
+		minRow=(modRow>window_opt[0]/2) ? modRow-window_opt[0]/2 : 0;
+		maxRow=(modRow+window_opt[0]/2<imgReaderModel2.nrOfRow()) ? modRow+window_opt[0]/2 : imgReaderModel2.nrOfRow()-1;
+		imgReaderModel2.readDataBlock(model2buffer,GDT_Float64,minCol,maxCol,minRow,maxRow,0);
+
+		imgReaderModel1.geo2image(x,y,modCol,modRow);
+		assert(modRow>=0&&modRow<imgReaderModel1.nrOfRow());
+		minCol=(modCol>window_opt[0]/2) ? modCol-window_opt[0]/2 : 0;
+		maxCol=(modCol+window_opt[0]/2<imgReaderModel1.nrOfCol()) ? modCol+window_opt[0]/2 : imgReaderModel1.nrOfCol()-1;
+		minRow=(modRow>window_opt[0]/2) ? modRow-window_opt[0]/2 : 0;
+		maxRow=(modRow+window_opt[0]/2<imgReaderModel1.nrOfRow()) ? modRow+window_opt[0]/2 : imgReaderModel1.nrOfRow()-1;
+		imgReaderModel1.readDataBlock(model1buffer,GDT_Float64,minCol,maxCol,minRow,maxRow,0);
+		// imgReaderEst.image2geo(icol,irow,x,y);
+	      }
+	      catch(string errorString){
+		cerr << "Error reading data block for " << minCol << "-" << maxCol << ", " << minRow << "-" << maxRow << endl;
+	      }
+	      //erase no-data from buffer
+	      vector<double>::iterator it1=model1buffer.begin();
+	      vector<double>::iterator it2=model2buffer.begin();
+	      while(it1!=model1buffer.end()&&it2!=model2buffer.end()){
+		//erase nodata
+		bool modNodata=false;
+		modNodata=modNodata||imgReaderModel1.isNoData(*it1);
+		modNodata=modNodata||imgReaderModel2.isNoData(*it2);
+		//todo: debug checkDiff_opt 
+		// if(checkDiff_opt[0]){
+		//   double difference=(estMeanValue-c0obs)/c1obs-*it1;
+		//   difference*=difference;
+		//   modNodata=modNodata||(sqrt(difference)>uncertModel_opt[0]*stdDev);
+		// }
+		if(modNodata){
+		  model1buffer.erase(it1);
+		  model2buffer.erase(it2);
+		}
+		else{
+		  ++it1;
+		  ++it2;
+		}
+	      }
+	      if(model1buffer.size()>minreg_opt[0]&&model2buffer.size()>minreg_opt[0])
+		errMod=stat.linear_regression_err(model1buffer,model2buffer,c0mod,c1mod);
+	      else{//use global regression...
+		c0mod=c0modGlobal;
+		c1mod=c1modGlobal;
+	      }
+	    }
+	    else{
+	      c0mod=c0modGlobal;
+	      c1mod=c1modGlobal;
+	    }
 	    double certNorm=(errMod*errMod+errObs*errObs);
 	    double certMod=errObs*errObs/certNorm;
 	    double certObs=errMod*errMod/certNorm;
 	    double regTime=(c0mod+c1mod*estValue)*certMod;
-	    double regSensor=(c0obs+c1obs*estValue)*certObs;
+
+	    // double regSensor=(c0obs+c1obs*estValue)*certObs;
+	    double regSensor=(c0obs+c1obs*modValue)*certObs;
 	    estWriteBuffer[icol]=regTime+regSensor;
 	    double totalUncertainty=0;
 	    if(errMod<eps_opt[0])
@@ -498,16 +613,28 @@ int main(int argc,char **argv) {
 	    uncertWriteBuffer[icol]=totalUncertainty+uncertReadBuffer[icol];
 	  }
 	  //observation update
-	  if(update&&!imgReaderObs.isNoData(obsBuffer[icol])){
-	    double kalmanGain=1;
-	    double uncertObs=uncertObs_opt[0];
-	    if(uncertObsBuffer.size()>icol)
-	      uncertObs=uncertObsBuffer[icol];
-	    if((uncertWriteBuffer[icol]+uncertObs)>eps_opt[0])
-	      kalmanGain=uncertWriteBuffer[icol]/(uncertWriteBuffer[icol]+uncertObs);
-	    assert(kalmanGain<=1);
-	    estWriteBuffer[icol]+=kalmanGain*(obsBuffer[icol]-estWriteBuffer[icol]);
-	    uncertWriteBuffer[icol]*=(1-kalmanGain);
+	  if(update&&!imgReaderObs.isNoData(obsLineBuffer[icol])){
+	    bool doUpdate=true;
+	    if(deltaObs_opt.size()){
+	      statfactory::StatFactory statobs;
+	      statobs.setNoDataValues(obsnodata_opt);
+	      double obsMeanValue=statobs.mean(obsWindowBuffer);
+	      double difference=(obsMeanValue-c0obs)/c1obs-modValue;
+	      difference/=modValue;//make relative difference
+	      difference*=difference;
+	      doUpdate=(100*sqrt(difference)<deltaObs_opt[0]);
+	    }
+	    if(doUpdate){
+	      double kalmanGain=1;
+	      double uncertObs=uncertObs_opt[0];
+	      if(uncertObsLineBuffer.size()>icol)
+		uncertObs=uncertObsLineBuffer[icol];
+	      if((uncertWriteBuffer[icol]+uncertObs)>eps_opt[0])
+		kalmanGain=uncertWriteBuffer[icol]/(uncertWriteBuffer[icol]+uncertObs);
+	      assert(kalmanGain<=1);
+	      estWriteBuffer[icol]+=kalmanGain*(obsLineBuffer[icol]-estWriteBuffer[icol]);
+	      uncertWriteBuffer[icol]*=(1-kalmanGain);
+	    }
 	  }
 	}
 	imgWriterEst.writeData(estWriteBuffer,GDT_Float64,irow,0);
@@ -583,7 +710,6 @@ int main(int argc,char **argv) {
       //write last model as output
       if(verbose_opt[0])
 	cout << "write last model as output" << endl;
-      // for(int irow=0;irow<imgWriterEst.nrOfRow();++irow){
       for(int irow=0;irow<nrow;++irow){
 	vector<double> estReadBuffer;
 	vector<double> estWriteBuffer(ncol);
@@ -594,10 +720,15 @@ int main(int argc,char **argv) {
 	try{
 	  imgReaderModel1.readData(estReadBuffer,GDT_Float64,modRow);
 	  //simple nearest neighbor
-	  stat.nearUp(estReadBuffer,estWriteBuffer);
-	  imgWriterEst.writeData(estWriteBuffer,GDT_Float64,irow,0);
-	  for(int icol=0;icol<imgWriterEst.nrOfCol();++icol)
+	  //stat.nearUp(estReadBuffer,estWriteBuffer);
+
+	  for(int icol=0;icol<imgWriterEst.nrOfCol();++icol){
+	    imgWriterEst.image2geo(icol,irow,x,y);	    
+	    imgReaderModel1.geo2image(x,y,modCol,modRow);
+	    estWriteBuffer[icol]=estReadBuffer[modCol];
 	    uncertWriteBuffer[icol]=uncertModel_opt[0]*stdDev;
+	  }
+	  imgWriterEst.writeData(estWriteBuffer,GDT_Float64,irow,0);
 	  imgWriterEst.writeData(uncertWriteBuffer,GDT_Float64,irow,1);
 	}
 	catch(string errorString){
@@ -624,10 +755,10 @@ int main(int argc,char **argv) {
 	imgReaderModel1.readData(estReadBuffer,GDT_Float64,modRow);
 	vector<double> estWriteBuffer(ncol);
 	vector<double> uncertWriteBuffer(ncol);
-	vector<double> uncertObsBuffer;
+	vector<double> uncertObsLineBuffer;
 	imgReaderObs.readData(estWriteBuffer,GDT_Float64,irow,0);
 	if(imgReaderObs.nrOfBand()>1)
-	  imgReaderObs.readData(uncertObsBuffer,GDT_Float64,irow,1);
+	  imgReaderObs.readData(uncertObsLineBuffer,GDT_Float64,irow,1);
 	for(int icol=0;icol<imgWriterEst.nrOfCol();++icol){
 	  if(imgReaderObs.isNoData(estWriteBuffer[icol])){
 	    imgWriterEst.image2geo(icol,irow,x,y);
@@ -641,8 +772,8 @@ int main(int argc,char **argv) {
 	  }
 	  else{
 	    double uncertObs=uncertObs_opt[0];
-	    if(uncertObsBuffer.size()>icol)
-	      uncertObs=uncertObsBuffer[icol];
+	    if(uncertObsLineBuffer.size()>icol)
+	      uncertObs=uncertObsLineBuffer[icol];
 	    if(uncertModel_opt[0]*stdDev+uncertObs>eps_opt[0]){
 	      imgWriterEst.image2geo(icol,irow,x,y);
 	      imgReaderModel1.geo2image(x,y,modCol,modRow);
@@ -711,13 +842,12 @@ int main(int argc,char **argv) {
       //to keep it general, we must redo it (overlap might have changed)
     
       pfnProgress(progress,pszMessage,pProgressArg);
-      double c0mod=0;
-      double c1mod=0;
 
       if(verbose_opt[0])
 	cout << "Calculating regression for " << imgReaderModel1.getFileName() << " " << imgReaderModel2.getFileName() << endl;
-      double errMod=imgreg.getRMSE(imgReaderModel1,imgReaderModel2,c0mod,c1mod);
-      // double errMod=imgreg.getRMSE(imgReaderModel1,imgReaderModel2,c0mod,c1mod,verbose_opt[0]);
+
+      double errMod=imgreg.getRMSE(imgReaderModel1,imgReaderModel2,c0modGlobal,c1modGlobal);
+      // double errMod=imgreg.getRMSE(imgReaderModel1,imgReaderModel2,c0modGlobal,c1modGlobal,verbose_opt[0]);
 
       bool update=false;
       if(obsindex<relobsindex.size()){
@@ -736,6 +866,8 @@ int main(int argc,char **argv) {
 	if(verbose_opt[0])
 	  cout << "Calculating regression for " << imgReaderModel2.getFileName() << " " << imgReaderObs.getFileName() << endl;
 	errObs=imgreg.getRMSE(imgReaderModel2,imgReaderObs,c0obs,c1obs,verbose_opt[0]);
+	if(verbose_opt[0])
+	  cout << "c0obs, c1obs: " << c0obs << ", " << c1obs << endl;
       }
       //prediction (also to fill cloudy pixels in update mode)
       string input;
@@ -751,57 +883,152 @@ int main(int argc,char **argv) {
       imgReaderEst.setOffset(obsoffset_opt[0]);
       imgReaderEst.setScale(obsscale_opt[0]);
 
-      vector<double> obsBuffer;
-      vector<double> modelBuffer;
-      vector<double> uncertObsBuffer;
+      vector<double> obsLineBuffer;
+      vector<double> obsWindowBuffer;//buffer for observation to calculate average corresponding to model pixel
+      vector<double> model1LineBuffer;
+      vector<double> model2LineBuffer;
+      vector<double> model1buffer;//buffer for model 1 to calculate time regression based on window
+      vector<double> model2buffer;//buffer for model 2 to calculate time regression based on window
+      vector<double> uncertObsLineBuffer;
       vector<double> estReadBuffer;
+      // vector<double> estWindowBuffer;//buffer for estimate to calculate average corresponding to model pixel
       vector<double> uncertReadBuffer;
       vector<double> estWriteBuffer(ncol);
       vector<double> uncertWriteBuffer(ncol);
-	
+
       for(int irow=0;irow<imgWriterEst.nrOfRow();++irow){
 	assert(irow<imgReaderEst.nrOfRow());
+	//not needed here, because we read entire window for each pixel...
 	imgReaderEst.readData(estReadBuffer,GDT_Float64,irow,0);
 	imgReaderEst.readData(uncertReadBuffer,GDT_Float64,irow,1);
 	//read model2 in case current estimate is nodata
 	imgReaderEst.image2geo(0,irow,x,y);
 	imgReaderModel2.geo2image(x,y,modCol,modRow);
 	assert(modRow>=0&&modRow<imgReaderModel2.nrOfRow());
-	imgReaderModel2.readData(modelBuffer,GDT_Float64,modRow,0);
+	imgReaderModel2.readData(model2LineBuffer,GDT_Float64,modRow,0);
+
+	imgReaderModel1.geo2image(x,y,modCol,modRow);
+	assert(modRow>=0&&modRow<imgReaderModel1.nrOfRow());
+	imgReaderModel1.readData(model1LineBuffer,GDT_Float64,modRow,0);
+
 	if(update){
-	  imgReaderObs.readData(obsBuffer,GDT_Float64,irow,0);
+	  imgReaderObs.readData(obsLineBuffer,GDT_Float64,irow,0);
 	  if(imgReaderObs.nrOfBand()>1)
-	    imgReaderObs.readData(uncertObsBuffer,GDT_Float64,irow,1);
+	    imgReaderObs.readData(uncertObsLineBuffer,GDT_Float64,irow,1);
 	}
 	for(int icol=0;icol<imgWriterEst.nrOfCol();++icol){
+	  int minCol=(icol>down_opt[0]/2) ? icol-down_opt[0]/2 : 0;
+	  int maxCol=(icol+down_opt[0]/2<imgReaderEst.nrOfCol()) ? icol+down_opt[0]/2 : imgReaderEst.nrOfCol()-1;
+	  int minRow=(irow>down_opt[0]/2) ? irow-down_opt[0]/2 : 0;
+	  int maxRow=(irow+down_opt[0]/2<imgReaderEst.nrOfRow()) ? irow+down_opt[0]/2 : imgReaderEst.nrOfRow()-1;
+	  if(update)
+	    imgReaderObs.readDataBlock(obsWindowBuffer,GDT_Float64,minCol,maxCol,minRow,maxRow,0);
+	  // imgReaderEst.readDataBlock(estWindowBuffer,GDT_Float64,minCol,maxCol,minRow,maxRow,0);
 	  double estValue=estReadBuffer[icol];
+	  // double estValue=estWindowBuffer[estWindowBuffer.size()/2];
+	  double estMeanValue=0;//stat.mean(estWindowBuffer);
+	  double nvalid=0;
 	  //time update
-	  if(imgReaderEst.isNoData(estValue)){
-	    //pk: in case we have not found any valid data yet, better here to take the current model value
-	    imgReaderEst.image2geo(icol,irow,x,y);
-	    imgReaderModel2.geo2image(x,y,modCol,modRow);
-	    assert(modRow>=0&&modRow<imgReaderModel2.nrOfRow());
-	    if(imgReaderModel2.isNoData(modelBuffer[modCol])){//if both estimate and model are no-data, set obs to nodata
+	  imgReaderEst.image2geo(icol,irow,x,y);
+	  imgReaderModel2.geo2image(x,y,modCol,modRow);
+	  assert(modRow>=0&&modRow<imgReaderModel2.nrOfRow());
+	  double modValue=model2LineBuffer[modCol];
+	  bool estNodata=imgReaderEst.isNoData(estValue);
+	  //todo: debug checkDiff_opt 
+	  // if(checkDiff_opt[0]){
+	  //   vector<double>::iterator itwin=estWindowBuffer.begin();
+	  //   while(itwin!=estWindowBuffer.end()){
+	  //     if(!imgReaderEst.isNoData(*itwin)){
+	  // 	estMeanValue+=*itwin;
+	  // 	++nvalid;
+	  //     }
+	  //     ++itwin;
+	  //   }
+	  //   estMeanValue/=nvalid;
+	  //   double difference=(estMeanValue-c0obs)/c1obs-model1LineBuffer[modCol];
+	  //   difference*=difference;
+	  //   estNodata=estNodata||(sqrt(difference)>uncertModel_opt[0]*stdDev);
+	  // }
+	  if(estNodata){
+	    //we have not found any valid data yet, better here to take the current model value if valid
+	    if(imgReaderModel2.isNoData(modValue)){//if both estimate and model are no-data, set obs to nodata
 	      estWriteBuffer[icol]=obsnodata_opt[0];
 	      uncertWriteBuffer[icol]=uncertNodata_opt[0];
 	    }
 	    else{
-	      estWriteBuffer[icol]=modelBuffer[modCol];
+	      estWriteBuffer[icol]=modValue;
 	      uncertWriteBuffer[icol]=uncertModel_opt[0]*stdDev;
 	    }
 	  }	  
 	  else{
+	    if(window_opt[0]>0){
+	      try{
+		// imgReaderModel2.geo2image(x,y,modCol,modRow);//did that already
+		minCol=(modCol>window_opt[0]/2) ? modCol-window_opt[0]/2 : 0;
+		maxCol=(modCol+window_opt[0]/2<imgReaderModel2.nrOfCol()) ? modCol+window_opt[0]/2 : imgReaderModel2.nrOfCol()-1;
+		minRow=(modRow>window_opt[0]/2) ? modRow-window_opt[0]/2 : 0;
+		maxRow=(modRow+window_opt[0]/2<imgReaderModel2.nrOfRow()) ? modRow+window_opt[0]/2 : imgReaderModel2.nrOfRow()-1;
+		imgReaderModel2.readDataBlock(model2buffer,GDT_Float64,minCol,maxCol,minRow,maxRow,0);
+
+		imgReaderModel1.geo2image(x,y,modCol,modRow);
+		assert(modRow>=0&&modRow<imgReaderModel1.nrOfRow());
+		minCol=(modCol>window_opt[0]/2) ? modCol-window_opt[0]/2 : 0;
+		maxCol=(modCol+window_opt[0]/2<imgReaderModel1.nrOfCol()) ? modCol+window_opt[0]/2 : imgReaderModel1.nrOfCol()-1;
+		minRow=(modRow>window_opt[0]/2) ? modRow-window_opt[0]/2 : 0;
+		maxRow=(modRow+window_opt[0]/2<imgReaderModel1.nrOfRow()) ? modRow+window_opt[0]/2 : imgReaderModel1.nrOfRow()-1;
+		imgReaderModel1.readDataBlock(model1buffer,GDT_Float64,minCol,maxCol,minRow,maxRow,0);
+		// imgReaderEst.image2geo(icol,irow,x,y);
+	      }
+	      catch(string errorString){
+		cerr << "Error reading data block for " << minCol << "-" << maxCol << ", " << minRow << "-" << maxRow << endl;
+	      }
+	      //erase no-data from buffer
+	      vector<double>::iterator it1=model1buffer.begin();
+	      vector<double>::iterator it2=model2buffer.begin();
+	      while(it1!=model1buffer.end()&&it2!=model2buffer.end()){
+		//erase nodata
+		bool modNodata=false;
+		modNodata=modNodata||imgReaderModel1.isNoData(*it1);
+		modNodata=modNodata||imgReaderModel2.isNoData(*it2);
+		//todo: debug checkDiff_opt 
+		// if(checkDiff_opt[0]){
+		//   double difference=(estMeanValue-c0obs)/c1obs-*it1;
+		//   difference*=difference;
+		//   modNodata=modNodata||(sqrt(difference)>uncertModel_opt[0]*stdDev);
+		// }
+		if(modNodata){
+		  model1buffer.erase(it1);
+		  model2buffer.erase(it2);
+		}
+		else{
+		  ++it1;
+		  ++it2;
+		}
+	      }
+	      if(model1buffer.size()>minreg_opt[0]&&model2buffer.size()>minreg_opt[5])
+		errMod=stat.linear_regression_err(model1buffer,model2buffer,c0mod,c1mod);
+	      else{//use global regression...
+		c0mod=c0modGlobal;
+		c1mod=c1modGlobal;
+	      }
+	    }
+	    else{
+	      c0mod=c0modGlobal;
+	      c1mod=c1modGlobal;
+	    }
 	    double certNorm=(errMod*errMod+errObs*errObs);
 	    double certMod=errObs*errObs/certNorm;
 	    double certObs=errMod*errMod/certNorm;
 	    double regTime=(c0mod+c1mod*estValue)*certMod;
-	    double regSensor=(c0obs+c1obs*estValue)*certObs;
+
+	    // double regSensor=(c0obs+c1obs*estValue)*certObs;
+	    double regSensor=(c0obs+c1obs*modValue)*certObs;
 	    estWriteBuffer[icol]=regTime+regSensor;
 	    double totalUncertainty=0;
 	    if(errMod<eps_opt[0])
 	      totalUncertainty=errObs;
 	    else if(errObs<eps_opt[0])
-	      totalUncertainty=errObs;
+	      totalUncertainty=errMod;
 	    else{
 	      totalUncertainty=1.0/errMod/errMod+1/errObs/errObs;
 	      totalUncertainty=sqrt(1.0/totalUncertainty);
@@ -809,16 +1036,29 @@ int main(int argc,char **argv) {
 	    uncertWriteBuffer[icol]=totalUncertainty+uncertReadBuffer[icol];
 	  }
 	  //observation update
-	  if(update&&!imgReaderObs.isNoData(obsBuffer[icol])){
-	    double kalmanGain=1;
-	    double uncertObs=uncertObs_opt[0];
-	    if(uncertObsBuffer.size()>icol)
-	      uncertObs=uncertObsBuffer[icol];
-	    if((uncertWriteBuffer[icol]+uncertObs)>eps_opt[0])
-	      kalmanGain=uncertWriteBuffer[icol]/(uncertWriteBuffer[icol]+uncertObs);
-	    assert(kalmanGain<=1);
-	    estWriteBuffer[icol]+=kalmanGain*(obsBuffer[icol]-estWriteBuffer[icol]);
-	    uncertWriteBuffer[icol]*=(1-kalmanGain);
+	  if(update&&!imgReaderObs.isNoData(obsLineBuffer[icol])){
+	    bool doUpdate=true;
+	    if(deltaObs_opt.size()){
+	      statfactory::StatFactory statobs;
+	      statobs.setNoDataValues(obsnodata_opt);
+	      double obsMeanValue=statobs.mean(obsWindowBuffer);
+	      double difference=(obsMeanValue-c0obs)/c1obs-modValue;
+	      difference*=difference;
+	      difference/=modValue;//make relative difference
+	      difference*=difference;
+	      doUpdate=(100*sqrt(difference)<deltaObs_opt[0]);
+	    }
+	    if(doUpdate){
+	      double kalmanGain=1;
+	      double uncertObs=uncertObs_opt[0];
+	      if(uncertObsLineBuffer.size()>icol)
+		uncertObs=uncertObsLineBuffer[icol];
+	      if((uncertWriteBuffer[icol]+uncertObs)>eps_opt[0])
+		kalmanGain=uncertWriteBuffer[icol]/(uncertWriteBuffer[icol]+uncertObs);
+	      assert(kalmanGain<=1);
+	      estWriteBuffer[icol]+=kalmanGain*(obsLineBuffer[icol]-estWriteBuffer[icol]);
+	      uncertWriteBuffer[icol]*=(1-kalmanGain);
+	    }
 	  }
 	}
 	imgWriterEst.writeData(estWriteBuffer,GDT_Float64,irow,0);
@@ -896,7 +1136,7 @@ int main(int argc,char **argv) {
     
       vector<double> estForwardBuffer;
       vector<double> estBackwardBuffer;
-      vector<double> uncertObsBuffer;
+      vector<double> uncertObsLineBuffer;
       vector<double> uncertForwardBuffer;
       vector<double> uncertBackwardBuffer;
       vector<double> uncertReadBuffer;
@@ -932,7 +1172,7 @@ int main(int argc,char **argv) {
 	if(update){
 	  imgReaderObs.readData(estWriteBuffer,GDT_Float64,irow,0);
 	  if(imgReaderObs.nrOfBand()>1)
-	    imgReaderObs.readData(uncertObsBuffer,GDT_Float64,irow,1);
+	    imgReaderObs.readData(uncertObsLineBuffer,GDT_Float64,irow,1);
 	}
 
 	for(int icol=0;icol<imgWriterEst.nrOfCol();++icol){
@@ -945,8 +1185,8 @@ int main(int argc,char **argv) {
 	  // if(update){//check for nodata in observation
 	  //   if(imgReaderObs.isNoData(estWriteBuffer[icol]))
 	  //     uncertObs=uncertNodata_opt[0];
-	  //   else if(uncertObsBuffer.size()>icol)
-	  //     uncertObs=uncertObsBuffer[icol];
+	  //   else if(uncertObsLineBuffer.size()>icol)
+	  //     uncertObs=uncertObsLineBuffer[icol];
 	  // }
 
 	  double noemer=(C+D);
diff --git a/src/apps/pkoptsvm.cc b/src/apps/pkoptsvm.cc
index ffcc488..0452469 100644
--- a/src/apps/pkoptsvm.cc
+++ b/src/apps/pkoptsvm.cc
@@ -28,6 +28,7 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include "algorithms/ConfusionMatrix.h"
 #include "algorithms/FeatureSelector.h"
 #include "algorithms/OptFactory.h"
+#include "algorithms/CostFactorySVM.h"
 #include "algorithms/svm.h"
 #include "imageclasses/ImgReaderOgr.h"
 
@@ -35,11 +36,6 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
 #include <config.h>
 #endif
 
-namespace svm{
-  enum SVM_TYPE {C_SVC=0, nu_SVC=1,one_class=2, epsilon_SVR=3, nu_SVR=4};
-  enum KERNEL_TYPE {linear=0,polynomial=1,radial=2,sigmoid=3};
-}
-
 using namespace std;
 
 #define Malloc(type,n) (type *)malloc((n)*sizeof(type))
@@ -70,21 +66,6 @@ Optionpk<short> verbose_opt("v", "verbose", "use 1 to output intermediate result
 
 double objFunction(const std::vector<double> &x, std::vector<double> &grad, void *my_func_data){
 
-  std::map<std::string, svm::SVM_TYPE> svmMap;
-
-  svmMap["C_SVC"]=svm::C_SVC;
-  svmMap["nu_SVC"]=svm::nu_SVC;
-  svmMap["one_class"]=svm::one_class;
-  svmMap["epsilon_SVR"]=svm::epsilon_SVR;
-  svmMap["nu_SVR"]=svm::nu_SVR;
-
-  std::map<std::string, svm::KERNEL_TYPE> kernelMap;
-
-  kernelMap["linear"]=svm::linear;
-  kernelMap["polynomial"]=svm::polynomial;
-  kernelMap["radial"]=svm::radial;
-  kernelMap["sigmoid;"]=svm::sigmoid;
-
   assert(grad.empty());
   vector<Vector2d<float> > *tf=reinterpret_cast<vector<Vector2d<float> >*> (my_func_data);
   float ccost=x[0];
@@ -92,138 +73,185 @@ double objFunction(const std::vector<double> &x, std::vector<double> &grad, void
   double error=1.0/epsilon_tol_opt[0];
   double kappa=1.0;
   double oa=1.0;
-  //todo: calculate kappa using cross validation
-  unsigned short nclass=tf->size();
-  unsigned int ntraining=0;
-  unsigned int ntest=0;
-  for(int iclass=0;iclass<nclass;++iclass){
-    ntraining+=nctraining[iclass];
-    ntest+=nctest[iclass];
-  }
-  if(ntest)
-    cv_opt[0]=0;
-  if(!cv_opt[0])
-    assert(ntest);
-    // ntraining+=(*tf)[iclass].size();
-  unsigned short nFeatures=(*tf)[0][0].size();
-  struct svm_parameter param;
-  param.svm_type = svmMap[svm_type_opt[0]];
-  param.kernel_type = kernelMap[kernel_type_opt[0]];
-  param.degree = kernel_degree_opt[0];
-  param.gamma = gamma;
-  param.coef0 = coef0_opt[0];
-  param.nu = nu_opt[0];
-  param.cache_size = cache_opt[0];
-  param.C = ccost;
-  param.eps = epsilon_tol_opt[0];
-  param.p = epsilon_loss_opt[0];
-  param.shrinking = (shrinking_opt[0])? 1 : 0;
-  param.probability = (prob_est_opt[0])? 1 : 0;
-  param.nr_weight = 0;//not used: I use priors and balancing
-  param.weight_label = NULL;
-  param.weight = NULL;
-  param.verbose=(verbose_opt[0]>2)? true:false;
-  struct svm_model* svm;
-  struct svm_problem prob;
-  struct svm_node* x_space;
-  prob.l=ntraining;
-  prob.y = Malloc(double,prob.l);
-  prob.x = Malloc(struct svm_node *,prob.l);
-  x_space = Malloc(struct svm_node,(nFeatures+1)*ntraining);
-  unsigned long int spaceIndex=0;
-  int lIndex=0;
-  for(int iclass=0;iclass<nclass;++iclass){
-    // for(int isample=0;isample<(*tf)[iclass].size();++isample){
-    for(int isample=0;isample<nctraining[iclass];++isample){
-      prob.x[lIndex]=&(x_space[spaceIndex]);
-      for(int ifeature=0;ifeature<nFeatures;++ifeature){
-        x_space[spaceIndex].index=ifeature+1;
-        x_space[spaceIndex].value=(*tf)[iclass][isample][ifeature];
-        ++spaceIndex;
-      }
-      x_space[spaceIndex++].index=-1;
-      prob.y[lIndex]=iclass;
-      ++lIndex;
-    }
-  }
 
-  assert(lIndex==prob.l);
-  if(verbose_opt[0]>2)
-    std::cout << "checking parameters" << std::endl;
-  svm_check_parameter(&prob,&param);
-  if(verbose_opt[0]>2)
-    std::cout << "parameters ok, training" << std::endl;
-  svm=svm_train(&prob,&param);
-  if(verbose_opt[0]>2)
-    std::cout << "SVM is now trained" << std::endl;
-
-  ConfusionMatrix cm;
+  CostFactorySVM costfactory(svm_type_opt[0], kernel_type_opt[0], kernel_degree_opt[0], gamma, coef0_opt[0], ccost, nu_opt[0],  epsilon_loss_opt[0], cache_opt[0], epsilon_tol_opt[0], shrinking_opt[0], prob_est_opt[0], cv_opt[0], verbose_opt[0]);
+
+  assert(tf->size());
+  // if(nctest>0)
+  //   costfactory.setCv(0);
+
+  costfactory.setCv(cv_opt[0]);
+
+  if(classname_opt.size()){
+    assert(classname_opt.size()==classvalue_opt.size());
+    for(int iclass=0;iclass<classname_opt.size();++iclass)
+      costfactory.setClassValueMap(classname_opt[iclass],classvalue_opt[iclass]);
+  }
   //set names in confusion matrix using nameVector
+  costfactory.setNameVector(nameVector);
+  // vector<string> nameVector=costfactory.getNameVector();
   for(int iname=0;iname<nameVector.size();++iname){
-    if(classValueMap.empty())
-      cm.pushBackClassName(nameVector[iname]);
-    else if(cm.getClassIndex(type2string<short>(classValueMap[nameVector[iname]]))<0)
-      cm.pushBackClassName(type2string<short>(classValueMap[nameVector[iname]]));
-  }
-  if(cv_opt[0]>1){
-    double *target = Malloc(double,prob.l);
-    svm_cross_validation(&prob,&param,cv_opt[0],target);
-    assert(param.svm_type != EPSILON_SVR&&param.svm_type != NU_SVR);//only for regression
-    for(int i=0;i<prob.l;i++){
-      string refClassName=nameVector[prob.y[i]];
-      string className=nameVector[target[i]];
-      if(classValueMap.size())
-	cm.incrementResult(type2string<short>(classValueMap[refClassName]),type2string<short>(classValueMap[className]),1.0);
-      else
-	cm.incrementResult(cm.getClass(prob.y[i]),cm.getClass(target[i]),1.0);
-    }
-    free(target);
-  }
-  else{
-    struct svm_node *x_test;
-    x_test = Malloc(struct svm_node,(nFeatures+1));
-    for(int iclass=0;iclass<nclass;++iclass){
-      for(int isample=0;isample<nctest[iclass];++isample){
-	for(int ifeature=0;ifeature<nFeatures;++ifeature){
-	  x_test[ifeature].index=ifeature+1;
-	  x_test[ifeature].value=(*tf)[iclass][nctraining[iclass]+isample][ifeature];
-	}
-	x_test[nFeatures].index=-1;
-	double predict_label=0;
-	//todo: make distinction between svm_predict and svm_predict_probability?
-	predict_label = svm_predict(svm,x_test);
-	string refClassName=nameVector[iclass];
-	string className=nameVector[static_cast<short>(predict_label)];
-	if(classValueMap.size())
-	  cm.incrementResult(type2string<short>(classValueMap[refClassName]),type2string<short>(classValueMap[className]),1.0);
-	else
-	  cm.incrementResult(refClassName,className,1.0);
-      }
+    if(costfactory.getClassValueMap().empty()){
+      costfactory.pushBackClassName(nameVector[iname]);
+      // cm.pushBackClassName(nameVector[iname]);
     }
-    free(x_test);
-  }
-  if(verbose_opt[0]>1)
-    std::cout << cm << std::endl;
-  assert(cm.nReference());
-  free(prob.y);
-  free(prob.x);
-  free(x_space);
-  svm_free_and_destroy_model(&(svm));
-  if(verbose_opt[0]>2)
-    std::cout << cm << std::endl;
-  kappa=cm.kappa();
-  oa=cm.oa();
-  if(verbose_opt[0]>1){
-    std::cout << " --ccost " << x[0];
-    std::cout << " --gamma " << x[1];
-    std::cout << std::endl;
-    std::cout << "oa: " << oa << std::endl;
-    std::cout << "kappa: " << kappa << std::endl;
+    else if(costfactory.getClassIndex(type2string<short>((costfactory.getClassValueMap())[nameVector[iname]]))<0)
+      costfactory.pushBackClassName(type2string<short>((costfactory.getClassValueMap())[nameVector[iname]]));
   }
-  double cost=(costfunction_opt[0])? oa : kappa;
-  if(cost>0)
-    error=1.0/cost;
-  return(error);
+
+  costfactory.setNcTraining(nctraining);
+  costfactory.setNcTest(nctest);
+
+  kappa=costfactory.getCost(*tf);
+  return(kappa);
+
+  // std::map<std::string, svm::SVM_TYPE> svmMap;
+
+  // svmMap["C_SVC"]=svm::C_SVC;
+  // svmMap["nu_SVC"]=svm::nu_SVC;
+  // svmMap["one_class"]=svm::one_class;
+  // svmMap["epsilon_SVR"]=svm::epsilon_SVR;
+  // svmMap["nu_SVR"]=svm::nu_SVR;
+
+  // std::map<std::string, svm::KERNEL_TYPE> kernelMap;
+
+  // kernelMap["linear"]=svm::linear;
+  // kernelMap["polynomial"]=svm::polynomial;
+  // kernelMap["radial"]=svm::radial;
+  // kernelMap["sigmoid;"]=svm::sigmoid;
+
+  // unsigned short nclass=tf->size();
+  // unsigned int ntraining=0;
+  // unsigned int ntest=0;
+  // for(int iclass=0;iclass<nclass;++iclass){
+  //   ntraining+=nctraining[iclass];
+  //   ntest+=nctest[iclass];
+  // }
+  // if(ntest)
+  //   cv_opt[0]=0;
+  // if(!cv_opt[0])
+  //   assert(ntest);
+
+  // unsigned short nFeatures=(*tf)[0][0].size();
+  // struct svm_parameter param;
+  // param.svm_type = svmMap[svm_type_opt[0]];
+  // param.kernel_type = kernelMap[kernel_type_opt[0]];
+  // param.degree = kernel_degree_opt[0];
+  // param.gamma = gamma;
+  // param.coef0 = coef0_opt[0];
+  // param.nu = nu_opt[0];
+  // param.cache_size = cache_opt[0];
+  // param.C = ccost;
+  // param.eps = epsilon_tol_opt[0];
+  // param.p = epsilon_loss_opt[0];
+  // param.shrinking = (shrinking_opt[0])? 1 : 0;
+  // param.probability = (prob_est_opt[0])? 1 : 0;
+  // param.nr_weight = 0;//not used: I use priors and balancing
+  // param.weight_label = NULL;
+  // param.weight = NULL;
+  // param.verbose=(verbose_opt[0]>2)? true:false;
+  // struct svm_model* svm;
+  // struct svm_problem prob;
+  // struct svm_node* x_space;
+
+  // prob.l=ntraining;
+  // prob.y = Malloc(double,prob.l);
+  // prob.x = Malloc(struct svm_node *,prob.l);
+  // x_space = Malloc(struct svm_node,(nFeatures+1)*ntraining);
+  // unsigned long int spaceIndex=0;
+  // int lIndex=0;
+  // for(int iclass=0;iclass<nclass;++iclass){
+  //   // for(int isample=0;isample<(*tf)[iclass].size();++isample){
+  //   for(int isample=0;isample<nctraining[iclass];++isample){
+  //     prob.x[lIndex]=&(x_space[spaceIndex]);
+  //     for(int ifeature=0;ifeature<nFeatures;++ifeature){
+  //       x_space[spaceIndex].index=ifeature+1;
+  //       x_space[spaceIndex].value=(*tf)[iclass][isample][ifeature];
+  //       ++spaceIndex;
+  //     }
+  //     x_space[spaceIndex++].index=-1;
+  //     prob.y[lIndex]=iclass;
+  //     ++lIndex;
+  //   }
+  // }
+
+  // assert(lIndex==prob.l);
+  // if(verbose_opt[0]>2)
+  //   std::cout << "checking parameters" << std::endl;
+  // svm_check_parameter(&prob,&param);
+  // if(verbose_opt[0]>2)
+  //   std::cout << "parameters ok, training" << std::endl;
+  // svm=svm_train(&prob,&param);
+  // if(verbose_opt[0]>2)
+  //   std::cout << "SVM is now trained" << std::endl;
+
+  // ConfusionMatrix cm;
+  // //set names in confusion matrix using nameVector
+  // for(int iname=0;iname<nameVector.size();++iname){
+  //   if(classValueMap.empty())
+  //     cm.pushBackClassName(nameVector[iname]);
+  //   else if(cm.getClassIndex(type2string<short>(classValueMap[nameVector[iname]]))<0)
+  //     cm.pushBackClassName(type2string<short>(classValueMap[nameVector[iname]]));
+  // }
+  // if(cv_opt[0]>1){
+  //   double *target = Malloc(double,prob.l);
+  //   svm_cross_validation(&prob,&param,cv_opt[0],target);
+  //   assert(param.svm_type != EPSILON_SVR&&param.svm_type != NU_SVR);//only for regression
+  //   for(int i=0;i<prob.l;i++){
+  //     string refClassName=nameVector[prob.y[i]];
+  //     string className=nameVector[target[i]];
+  //     if(classValueMap.size())
+  // 	cm.incrementResult(type2string<short>(classValueMap[refClassName]),type2string<short>(classValueMap[className]),1.0);
+  //     else
+  // 	cm.incrementResult(cm.getClass(prob.y[i]),cm.getClass(target[i]),1.0);
+  //   }
+  //   free(target);
+  // }
+  // else{
+  //   struct svm_node *x_test;
+  //   x_test = Malloc(struct svm_node,(nFeatures+1));
+  //   for(int iclass=0;iclass<nclass;++iclass){
+  //     for(int isample=0;isample<nctest[iclass];++isample){
+  // 	for(int ifeature=0;ifeature<nFeatures;++ifeature){
+  // 	  x_test[ifeature].index=ifeature+1;
+  // 	  x_test[ifeature].value=(*tf)[iclass][nctraining[iclass]+isample][ifeature];
+  // 	}
+  // 	x_test[nFeatures].index=-1;
+  // 	double predict_label=0;
+  // 	//todo: make distinction between svm_predict and svm_predict_probability?
+  // 	predict_label = svm_predict(svm,x_test);
+  // 	string refClassName=nameVector[iclass];
+  // 	string className=nameVector[static_cast<short>(predict_label)];
+  // 	if(classValueMap.size())
+  // 	  cm.incrementResult(type2string<short>(classValueMap[refClassName]),type2string<short>(classValueMap[className]),1.0);
+  // 	else
+  // 	  cm.incrementResult(refClassName,className,1.0);
+  //     }
+  //   }
+  //   free(x_test);
+  // }
+  // if(verbose_opt[0]>1)
+  //   std::cout << cm << std::endl;
+  // assert(cm.nReference());
+  // free(prob.y);
+  // free(prob.x);
+  // free(x_space);
+  // svm_free_and_destroy_model(&(svm));
+  // if(verbose_opt[0]>2)
+  //   std::cout << cm << std::endl;
+  // kappa=cm.kappa();
+  // oa=cm.oa();
+  // if(verbose_opt[0]>1){
+  //   std::cout << " --ccost " << x[0];
+  //   std::cout << " --gamma " << x[1];
+  //   std::cout << std::endl;
+  //   std::cout << "oa: " << oa << std::endl;
+  //   std::cout << "kappa: " << kappa << std::endl;
+  // }
+  // double cost=(costfunction_opt[0])? oa : kappa;
+  // if(cost>0)
+  //   error=1.0/cost;
+  // return(error);
 }
 
 int main(int argc, char *argv[])
@@ -231,16 +259,16 @@ int main(int argc, char *argv[])
   map<short,int> reclassMap;
   vector<int> vreclass;
   Optionpk<string> training_opt("t", "training", "training vector file. A single vector file contains all training features (must be set as: b0, b1, b2,...) for all classes (class numbers identified by label option)."); 
-  Optionpk<string> input_opt("i", "input", "input test vectro file"); 
+  Optionpk<string> input_opt("i", "input", "input test vector file"); 
   Optionpk<string> tlayer_opt("tln", "tln", "training layer name(s)");
-  Optionpk<string> label_opt("\0", "label", "identifier for class label in training vector file.","label"); 
+  Optionpk<string> label_opt("label", "label", "identifier for class label in training vector file.","label"); 
   // Optionpk<unsigned short> reclass_opt("\0", "rc", "reclass code (e.g. --rc=12 --rc=23 to reclass first two classes to 12 and 23 resp.).", 0);
-  Optionpk<unsigned int> balance_opt("\0", "balance", "balance the input data to this number of samples for each class", 0);
+  Optionpk<unsigned int> balance_opt("bal", "balance", "balance the input data to this number of samples for each class", 0);
   Optionpk<bool> random_opt("random","random", "in case of balance, randomize input data", true);
-  Optionpk<int> minSize_opt("m", "min", "if number of training pixels is less then min, do not take this class into account", 0);
-  Optionpk<double> start_opt("s", "start", "start band sequence number",0); 
-  Optionpk<double> end_opt("e", "end", "end band sequence number (set to 0 to include all bands)", 0); 
+  Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account", 0);
   Optionpk<short> band_opt("b", "band", "band index (starting from 0, either use band option or use start to end)");
+  Optionpk<double> bstart_opt("bs", "bstart", "start band sequence number",0); 
+  Optionpk<double> bend_opt("be", "bend", "bend band sequence number (set to 0 to include all bands)", 0); 
   Optionpk<double> offset_opt("\0", "offset", "offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
   Optionpk<float> gamma_opt("g", "gamma", "min max boundaries for gamma in kernel function (optional: initial value)",0);
@@ -260,9 +288,9 @@ int main(int argc, char *argv[])
     balance_opt.retrieveOption(argc,argv);
     random_opt.retrieveOption(argc,argv);
     minSize_opt.retrieveOption(argc,argv);
-    start_opt.retrieveOption(argc,argv);
-    end_opt.retrieveOption(argc,argv);
     band_opt.retrieveOption(argc,argv);
+    bstart_opt.retrieveOption(argc,argv);
+    bend_opt.retrieveOption(argc,argv);
     offset_opt.retrieveOption(argc,argv);
     scale_opt.retrieveOption(argc,argv);
     svm_type_opt.retrieveOption(argc,argv);
@@ -365,15 +393,18 @@ int main(int argc, char *argv[])
       }
     }
     else{
-      totalSamples=trainingReader.readDataImageOgr(trainingMap,fields,start_opt[0],end_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
+      totalSamples=trainingReader.readDataImageOgr(trainingMap,fields,bstart_opt[0],bend_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
       if(input_opt.size()){
 	ImgReaderOgr inputReader(input_opt[0]);
-	totalTestSamples=inputReader.readDataImageOgr(testMap,fields,start_opt[0],end_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
+	totalTestSamples=inputReader.readDataImageOgr(testMap,fields,bstart_opt[0],bend_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
 	inputReader.close();
       }
       trainingReader.close();
     }
     if(trainingMap.size()<2){
+      // map<string,Vector2d<float> >::iterator mapit=trainingMap.begin();
+      // while(mapit!=trainingMap.end())
+      // 	cerr << mapit->first << " -> " << classValueMap[mapit->first] << std::endl;
       string errorstring="Error: could not read at least two classes from training input file";
       throw(errorstring);
     }
@@ -596,9 +627,12 @@ int main(int argc, char *argv[])
   if(algorithm_opt[0]=="GRID"){
     if(step_opt.size()<2)//[0] for cost, [1] for gamma
       step_opt.push_back(step_opt.back());
-    double minError=1000;
-    double minCost=0;
-    double minGamma=0;
+    // double minError=1000;
+    // double minCost=0;
+    // double minGamma=0;
+    double maxKappa=0;
+    double maxCost=0;
+    double maxGamma=0;
     const char* pszMessage;
     void* pProgressArg=NULL;
     GDALProgressFunc pfnProgress=GDALTermProgress;
@@ -612,15 +646,15 @@ int main(int argc, char *argv[])
 	x[0]=ccost;
 	x[1]=gamma;
 	std::vector<double> theGrad;
-	double error=0;
-	error=objFunction(x,theGrad,&trainingFeatures);
-	if(error<minError){
-	  minError=error;
-	  minCost=ccost;
-	  minGamma=gamma;
+	double kappa=0;
+	kappa=objFunction(x,theGrad,&trainingFeatures);
+	if(kappa>maxKappa){
+	  maxKappa=kappa;
+	  maxCost=ccost;
+	  maxGamma=gamma;
 	}
 	if(verbose_opt[0])
-	  std::cout << ccost << " " << gamma << " " << error<< std::endl;
+	  std::cout << ccost << " " << gamma << " " << kappa<< std::endl;
 	progress+=1.0/ncost/ngamma;
 	if(!verbose_opt[0])
 	  pfnProgress(progress,pszMessage,pProgressArg);
@@ -629,8 +663,8 @@ int main(int argc, char *argv[])
     progress=1.0;
     if(!verbose_opt[0])
       pfnProgress(progress,pszMessage,pProgressArg);
-    x[0]=minCost;
-    x[1]=minGamma;
+    x[0]=maxCost;
+    x[1]=maxGamma;
   }
   else{
     nlopt::opt optimizer=OptFactory::getOptimizer(algorithm_opt[0],2);
@@ -646,7 +680,8 @@ int main(int argc, char *argv[])
     init[1]=(gamma_opt[2]>0)? gamma_opt[1] : 1.0/trainingFeatures[0][0].size();
     ub[0]=ccost_opt[1];
     ub[1]=(gamma_opt[1]>0)? gamma_opt[1] : 1.0/trainingFeatures[0][0].size();
-    optimizer.set_min_objective(objFunction, &trainingFeatures);
+    // optimizer.set_min_objective(objFunction, &trainingFeatures);
+    optimizer.set_max_objective(objFunction, &trainingFeatures);
     optimizer.set_lower_bounds(lb);
     optimizer.set_upper_bounds(ub);
     if(verbose_opt[0]>1)
diff --git a/src/apps/pksvm.cc b/src/apps/pksvm.cc
index 12ce0e6..d5532f6 100644
--- a/src/apps/pksvm.cc
+++ b/src/apps/pksvm.cc
@@ -55,9 +55,9 @@ int main(int argc, char *argv[])
   Optionpk<unsigned int> balance_opt("bal", "balance", "Balance the input data to this number of samples for each class", 0);
   Optionpk<bool> random_opt("random", "random", "Randomize training data for balancing and bagging", true, 2);
   Optionpk<int> minSize_opt("min", "min", "If number of training pixels is less then min, do not take this class into account (0: consider all classes)", 0);
-  Optionpk<double> start_opt("s", "start", "Start band sequence number",0); 
-  Optionpk<double> end_opt("e", "end", "End band sequence number (set to 0 to include all bands)", 0); 
   Optionpk<short> band_opt("b", "band", "Band index (starting from 0, either use band option or use start to end)");
+  Optionpk<double> bstart_opt("bs", "bstart", "Start band sequence number",0); 
+  Optionpk<double> bend_opt("be", "bend", "End band sequence number (set to 0 to include all bands)", 0); 
   Optionpk<double> offset_opt("\0", "offset", "Offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "Scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
   Optionpk<double> priors_opt("p", "prior", "Prior probabilities for each class (e.g., -p 0.3 -p 0.3 -p 0.2 ). Used for input only (ignored for cross validation)", 0.0); 
@@ -117,8 +117,8 @@ int main(int argc, char *argv[])
     msknodata_opt.retrieveOption(argc,argv);
     nodata_opt.retrieveOption(argc,argv);
     band_opt.retrieveOption(argc,argv);
-    start_opt.retrieveOption(argc,argv);
-    end_opt.retrieveOption(argc,argv);
+    bstart_opt.retrieveOption(argc,argv);
+    bend_opt.retrieveOption(argc,argv);
     balance_opt.retrieveOption(argc,argv);
     minSize_opt.retrieveOption(argc,argv);
     bag_opt.retrieveOption(argc,argv);
@@ -265,7 +265,7 @@ int main(int argc, char *argv[])
         if(band_opt.size())
           totalSamples=trainingReaderBag.readDataImageOgr(trainingMap,fields,band_opt,label_opt[0],tlayer_opt,verbose_opt[0]);
         else
-          totalSamples=trainingReaderBag.readDataImageOgr(trainingMap,fields,start_opt[0],end_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
+          totalSamples=trainingReaderBag.readDataImageOgr(trainingMap,fields,bstart_opt[0],bend_opt[0],label_opt[0],tlayer_opt,verbose_opt[0]);
         if(trainingMap.size()<2){
           string errorstring="Error: could not read at least two classes from training file, did you provide class labels in training sample (see option label)?";
           throw(errorstring);
@@ -716,7 +716,7 @@ int main(int argc, char *argv[])
           }
         }
         else{
-          for(int iband=start_opt[0];iband<start_opt[0]+nband;++iband){
+          for(int iband=bstart_opt[0];iband<bstart_opt[0]+nband;++iband){
             if(verbose_opt[0]==2)
               std::cout << "reading band " << iband << std::endl;
             assert(iband>=0);
diff --git a/src/base/Makefile.in b/src/base/Makefile.in
index c716975..9be0026 100644
--- a/src/base/Makefile.in
+++ b/src/base/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -22,23 +21,51 @@
 
 
 VPATH = @srcdir@
-am__make_dryrun = \
-  { \
-    am__dry=no; \
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
     case $$MAKEFLAGS in \
       *\\[\ \	]*) \
-        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
-          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
-      *) \
-        for am__flg in $$MAKEFLAGS; do \
-          case $$am__flg in \
-            *=*|--*) ;; \
-            *n*) am__dry=yes; break;; \
-          esac; \
-        done;; \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
     esac; \
-    test $$am__dry = yes; \
-  }
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -59,8 +86,8 @@ build_triplet = @build@
 host_triplet = @host@
 noinst_PROGRAMS = pktestOption$(EXEEXT)
 subdir = src/base
-DIST_COMMON = $(libbase_la_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/depcomp $(libbase_la_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -105,35 +132,69 @@ libbase_la_LIBADD =
 am__objects_1 =
 am_libbase_la_OBJECTS = $(am__objects_1)
 libbase_la_OBJECTS = $(am_libbase_la_OBJECTS)
-libbase_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+AM_V_lt = $(am__v_lt_ at AM_V@)
+am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+libbase_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(libbase_la_LDFLAGS) $(LDFLAGS) -o $@
 PROGRAMS = $(noinst_PROGRAMS)
 am_pktestOption_OBJECTS = pktestOption.$(OBJEXT)
 pktestOption_OBJECTS = $(am_pktestOption_OBJECTS)
 pktestOption_LDADD = $(LDADD)
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 am__mv = mv -f
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_ at AM_V@)
+am__v_CXX_ = $(am__v_CXX_ at AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
 CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_ at AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_ at AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_ at AM_V@)
+am__v_CC_ = $(am__v_CC_ at AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
 CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
 SOURCES = $(libbase_la_SOURCES) $(pktestOption_SOURCES)
 DIST_SOURCES = $(libbase_la_SOURCES) $(pktestOption_SOURCES)
 am__can_run_installinfo = \
@@ -142,12 +203,30 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 HEADERS = $(libbase_la_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_CXXFLAGS = -I$(top_srcdir)/src $(GDAL_CFLAGS) @AM_CXXFLAGS@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 
 # additional include pathes necessary to compile the C++ library
 AM_LDFLAGS = $(GDAL_LDFLAGS) @AM_LDFLAGS@
@@ -343,6 +422,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
 	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
@@ -369,14 +449,17 @@ uninstall-libLTLIBRARIES:
 
 clean-libLTLIBRARIES:
 	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-	  test "$$dir" != "$$p" || dir=.; \
-	  echo "rm -f \"$${dir}/so_locations\""; \
-	  rm -f "$${dir}/so_locations"; \
-	done
+	@list='$(lib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
+
 libbase.la: $(libbase_la_OBJECTS) $(libbase_la_DEPENDENCIES) $(EXTRA_libbase_la_DEPENDENCIES) 
-	$(libbase_la_LINK) -rpath $(libdir) $(libbase_la_OBJECTS) $(libbase_la_LIBADD) $(LIBS)
+	$(AM_V_CCLD)$(libbase_la_LINK) -rpath $(libdir) $(libbase_la_OBJECTS) $(libbase_la_LIBADD) $(LIBS)
 
 clean-noinstPROGRAMS:
 	@list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
@@ -386,9 +469,10 @@ clean-noinstPROGRAMS:
 	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
 	echo " rm -f" $$list; \
 	rm -f $$list
+
 pktestOption$(EXEEXT): $(pktestOption_OBJECTS) $(pktestOption_DEPENDENCIES) $(EXTRA_pktestOption_DEPENDENCIES) 
 	@rm -f pktestOption$(EXEEXT)
-	$(CXXLINK) $(pktestOption_OBJECTS) $(pktestOption_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(pktestOption_OBJECTS) $(pktestOption_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -399,25 +483,25 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pktestOption.Po at am__quote@
 
 .cc.o:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ $<
 
 .cc.obj:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cc.lo:
- at am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -446,26 +530,15 @@ uninstall-libbase_laHEADERS:
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 	dir='$(DESTDIR)$(libbase_ladir)'; $(am__uninstall_files_from_dir)
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -477,15 +550,11 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -494,6 +563,21 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -638,20 +722,20 @@ uninstall-am: uninstall-libLTLIBRARIES uninstall-libbase_laHEADERS
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS ctags \
-	distclean distclean-compile distclean-generic \
-	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-info \
-	install-info-am install-libLTLIBRARIES \
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+	clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS \
+	cscopelist-am ctags ctags-am distclean distclean-compile \
+	distclean-generic 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-info install-info-am install-libLTLIBRARIES \
 	install-libbase_laHEADERS 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-libLTLIBRARIES \
+	tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
 	uninstall-libbase_laHEADERS
 
 
diff --git a/src/fileclasses/Makefile.in b/src/fileclasses/Makefile.in
index a8c1055..0c4b89c 100644
--- a/src/fileclasses/Makefile.in
+++ b/src/fileclasses/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,23 +16,51 @@
 
 
 VPATH = @srcdir@
-am__make_dryrun = \
-  { \
-    am__dry=no; \
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
     case $$MAKEFLAGS in \
       *\\[\ \	]*) \
-        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
-          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
-      *) \
-        for am__flg in $$MAKEFLAGS; do \
-          case $$am__flg in \
-            *=*|--*) ;; \
-            *n*) am__dry=yes; break;; \
-          esac; \
-        done;; \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
     esac; \
-    test $$am__dry = yes; \
-  }
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -53,8 +80,8 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = src/fileclasses
-DIST_COMMON = $(libfileClasses_la_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/depcomp $(libfileClasses_la_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -100,31 +127,66 @@ libfileClasses_la_LIBADD =
 am__objects_1 =
 am_libfileClasses_la_OBJECTS = $(am__objects_1) FileReaderAscii.lo
 libfileClasses_la_OBJECTS = $(am_libfileClasses_la_OBJECTS)
-libfileClasses_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-	$(CXXFLAGS) $(libfileClasses_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_lt = $(am__v_lt_ at AM_V@)
+am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+libfileClasses_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(AM_CXXFLAGS) $(CXXFLAGS) $(libfileClasses_la_LDFLAGS) \
+	$(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 am__mv = mv -f
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_ at AM_V@)
+am__v_CXX_ = $(am__v_CXX_ at AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
 CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_ at AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_ at AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_ at AM_V@)
+am__v_CC_ = $(am__v_CC_ at AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
 CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
 SOURCES = $(libfileClasses_la_SOURCES)
 DIST_SOURCES = $(libfileClasses_la_SOURCES)
 am__can_run_installinfo = \
@@ -133,12 +195,30 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 HEADERS = $(libfileClasses_la_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_CXXFLAGS = -I$(top_srcdir)/src $(GDAL_CFLAGS) @AM_CXXFLAGS@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AM_LDFLAGS = $(GDAL_LDFLAGS) @AM_LDFLAGS@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
@@ -327,6 +407,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
 	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
@@ -353,14 +434,17 @@ uninstall-libLTLIBRARIES:
 
 clean-libLTLIBRARIES:
 	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-	  test "$$dir" != "$$p" || dir=.; \
-	  echo "rm -f \"$${dir}/so_locations\""; \
-	  rm -f "$${dir}/so_locations"; \
-	done
+	@list='$(lib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
+
 libfileClasses.la: $(libfileClasses_la_OBJECTS) $(libfileClasses_la_DEPENDENCIES) $(EXTRA_libfileClasses_la_DEPENDENCIES) 
-	$(libfileClasses_la_LINK) -rpath $(libdir) $(libfileClasses_la_OBJECTS) $(libfileClasses_la_LIBADD) $(LIBS)
+	$(AM_V_CXXLD)$(libfileClasses_la_LINK) -rpath $(libdir) $(libfileClasses_la_OBJECTS) $(libfileClasses_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -371,25 +455,25 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FileReaderAscii.Plo at am__quote@
 
 .cc.o:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ $<
 
 .cc.obj:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cc.lo:
- at am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -418,26 +502,15 @@ uninstall-libfileClasses_laHEADERS:
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 	dir='$(DESTDIR)$(libfileClasses_ladir)'; $(am__uninstall_files_from_dir)
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -449,15 +522,11 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -466,6 +535,21 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -611,20 +695,20 @@ uninstall-am: uninstall-libLTLIBRARIES \
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libLTLIBRARIES clean-libtool ctags distclean \
-	distclean-compile distclean-generic 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-info install-info-am \
-	install-libLTLIBRARIES install-libfileClasses_laHEADERS \
-	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-libLTLIBRARIES \
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+	clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \
+	ctags-am distclean distclean-compile distclean-generic \
+	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-info \
+	install-info-am install-libLTLIBRARIES \
+	install-libfileClasses_laHEADERS 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 tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
 	uninstall-libfileClasses_laHEADERS
 
 
diff --git a/src/imageclasses/ImgReaderGdal.h b/src/imageclasses/ImgReaderGdal.h
index 5d4fceb..d287631 100644
--- a/src/imageclasses/ImgReaderGdal.h
+++ b/src/imageclasses/ImgReaderGdal.h
@@ -237,14 +237,25 @@ template<typename T> void ImgReaderGdal::readDataBlock(std::vector<T>& buffer, c
   GDALRasterBand  *poBand;
   assert(band<nrOfBand()+1);
   poBand = m_gds->GetRasterBand(band+1);//GDAL uses 1 based index
-  assert(minCol<nrOfCol());
-  assert(minCol>=0);
-  assert(maxCol<nrOfCol());
-  assert(minCol<=maxCol);
-  assert(minRow<nrOfRow());
-  assert(minRow>=0);
-  assert(maxRow<nrOfRow());
-  assert(minRow<=maxRow);
+  if(minCol>=nrOfCol() ||
+     (minCol<0) ||
+     (maxCol>=nrOfCol()) ||
+     (minCol>maxCol) ||
+     (minRow>=nrOfRow()) ||
+     (minRow<0) ||
+     (maxRow>=nrOfRow()) ||
+     (minRow>maxRow)){
+    std::string errorString="block not within image boundaries";
+    throw(errorString);
+  }
+  /* assert(minCol<nrOfCol()); */
+  /* assert(minCol>=0); */
+  /* assert(maxCol<nrOfCol()); */
+  /* assert(minCol<=maxCol); */
+  /* assert(minRow<nrOfRow()); */
+  /* assert(minRow>=0); */
+  /* assert(maxRow<nrOfRow()); */
+  /* assert(minRow<=maxRow); */
   if(buffer.size()!=(maxRow-minRow+1)*(maxCol-minCol+1))
     buffer.resize((maxRow-minRow+1)*(maxCol-minCol+1));
   poBand->RasterIO(GF_Read,minCol,minRow,maxCol-minCol+1,maxRow-minRow+1,&(buffer[0]),(maxCol-minCol+1),(maxRow-minRow+1),dataType,0,0);
diff --git a/src/imageclasses/ImgReaderOgr.cc b/src/imageclasses/ImgReaderOgr.cc
index db5d7cc..84028ce 100644
--- a/src/imageclasses/ImgReaderOgr.cc
+++ b/src/imageclasses/ImgReaderOgr.cc
@@ -229,7 +229,7 @@ unsigned int ImgReaderOgr::readDataImageOgr(std::map<std::string,Vector2d<float>
   int totalSamples=0;  
   int nband=0;
   if(verbose)
-    std::cout << "reading shape file " << m_filename  << std::endl;
+    std::cout << "reading OGR dataset " << m_filename  << std::endl;
   for(int ilayer=0;ilayer<getLayerCount();++ilayer){
     std::string currentLayername=getLayer(ilayer)->GetName();
     if(layers.size())
@@ -313,7 +313,7 @@ unsigned int ImgReaderOgr::readDataImageOgr(std::map<std::string,Vector2d<float>
   int totalSamples=0;  
   int nband=0;
   if(verbose)
-    std::cout << "reading shape file " << m_filename  << std::endl;
+    std::cout << "reading OGR dataset file " << m_filename  << std::endl;
   for(int ilayer=0;ilayer<getLayerCount();++ilayer){
     std::string currentLayername=getLayer(ilayer)->GetName();
     if(layers.size())
diff --git a/src/imageclasses/ImgReaderOgr.h b/src/imageclasses/ImgReaderOgr.h
index f15f905..408627b 100644
--- a/src/imageclasses/ImgReaderOgr.h
+++ b/src/imageclasses/ImgReaderOgr.h
@@ -63,7 +63,7 @@ public:
 				const std::vector<std::string>& layers,
 				int verbose=false);
 
-  void shape2ascii(std::ostream& theOstream, const std::string& pointname, int layer=0, bool verbose=false);
+  //  void shape2ascii(std::ostream& theOstream, const std::string& pointname, int layer=0, bool verbose=false);
   unsigned long int getFeatureCount(int layer=0) const;
   int getFieldCount(int layer=0) const;
   OGRLayer* getLayer(int layer=0){return m_datasource->GetLayer(layer);};
diff --git a/src/imageclasses/ImgWriterOgr.cc b/src/imageclasses/ImgWriterOgr.cc
index 4f040cf..4297190 100644
--- a/src/imageclasses/ImgWriterOgr.cc
+++ b/src/imageclasses/ImgWriterOgr.cc
@@ -132,15 +132,34 @@ void ImgWriterOgr::close(void)
 void ImgWriterOgr::setCodec(const std::string& imageType){
   //register the drivers
   OGRRegisterAll();
-  //fetch the shape file driver
+  //fetch the OGR file driver
   OGRSFDriver *poDriver;
   poDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(imageType.c_str());
   if( poDriver == NULL ){
     std::string errorString="FileOpenError";
     throw(errorString);
   }
-  //create the data source
-  m_datasource=poDriver->CreateDataSource(m_filename.c_str(),NULL);
+  m_datasource = OGRSFDriverRegistrar::Open( m_filename.c_str(), TRUE );
+  if( m_datasource == NULL ){
+    m_datasource = OGRSFDriverRegistrar::Open( m_filename.c_str(), FALSE );
+    if ( m_datasource != NULL){// we can only open in not update mode
+      std::string errorString="Update mode not supported, delete output dataset first";
+      throw(errorString);
+      OGRDataSource::DestroyDataSource(m_datasource);
+      m_datasource = NULL;
+    }
+    else //create the data source
+      m_datasource=poDriver->CreateDataSource(m_filename.c_str(),NULL);
+  }
+  else{//datasets exists, always overwrite all layers (no update append for now)
+    int nLayerCount = m_datasource->GetLayerCount();
+    for(int iLayer = 0; iLayer < nLayerCount; ++iLayer){
+      if(m_datasource->DeleteLayer(iLayer)!=OGRERR_NONE){
+	std::string errorstring="DeleteLayer() failed when overwrite requested";
+	throw(errorstring);
+      }
+    }
+  }
   if(m_datasource==NULL){
     std::string errorString="Creation of output file failed";
     throw(errorString);
@@ -153,8 +172,27 @@ void ImgWriterOgr::setCodec(OGRSFDriver *poDriver){
     std::string errorString="FileOpenError";
     throw(errorString);
   }
-  //create the data source
-  m_datasource=poDriver->CreateDataSource(m_filename.c_str(),NULL);
+  m_datasource = OGRSFDriverRegistrar::Open( m_filename.c_str(), TRUE );
+  if( m_datasource == NULL ){
+    m_datasource = OGRSFDriverRegistrar::Open( m_filename.c_str(), FALSE );
+    if ( m_datasource != NULL){// we can only open in not update mode
+      std::string errorString="Update mode not supported, delete output dataset first";
+      throw(errorString);
+      OGRDataSource::DestroyDataSource(m_datasource);
+      m_datasource = NULL;
+    }
+    else //create the data source
+      m_datasource=poDriver->CreateDataSource(m_filename.c_str(),NULL);
+  }
+  else{//datasets exists, always overwrite all layers (no update append for now)
+    int nLayerCount = m_datasource->GetLayerCount();
+    for(int iLayer = 0; iLayer < nLayerCount; ++iLayer){
+      if(m_datasource->DeleteLayer(iLayer)!=OGRERR_NONE){
+	std::string errorstring="DeleteLayer() failed when overwrite requested";
+	throw(errorstring);
+      }
+    }
+  }
   if(m_datasource==NULL){
     std::string errorString="Creation of output file failed";
     throw(errorString);
@@ -176,6 +214,7 @@ OGRLayer* ImgWriterOgr::createLayer(const std::string& layername, const std::str
   //if points: use wkbPoint
   //if no constraints on the types geometry to be written: use wkbUnknown 
   OGRLayer* poLayer;
+
   OGRSpatialReference oSRS;
 
   if(theProjection!=""){
@@ -291,7 +330,7 @@ void ImgWriterOgr::addPoint(double x, double y, const std::map<std::string,doubl
   pt.setY(y);
   poFeature->SetGeometry( &pt );
   if(createFeature(poFeature,layer)!=OGRERR_NONE){
-    std::string errorString="Failed to create feature in shapefile";
+    std::string errorString="Failed to create feature";
     throw(errorString);
   }
   OGRFeature::DestroyFeature( poFeature );
@@ -316,7 +355,7 @@ void ImgWriterOgr::addPoint(double x, double y, const std::map<std::string,doubl
   pt.setY(y);
   poFeature->SetGeometry( &pt );
   if(createFeature(poFeature,layer)!=OGRERR_NONE){
-    std::string errorString="Failed to create feature in shapefile";
+    std::string errorString="Failed to create feature";
     throw(errorString);
   }
   OGRFeature::DestroyFeature( poFeature );
@@ -337,7 +376,7 @@ void ImgWriterOgr::addLineString(std::vector<OGRPoint*>& points, const std::stri
     throw(errorString);
   }
   if(createFeature(poFeature,layer)!=OGRERR_NONE){
-    std::string errorString="Failed to create feature in shapefile";
+    std::string errorString="Failed to create feature";
     throw(errorString);
   }
   OGRFeature::DestroyFeature( poFeature );
@@ -361,7 +400,7 @@ void ImgWriterOgr::addRing(std::vector<OGRPoint*>& points, const std::string& fi
   // SetSpatialFilter(&thePolygon)
   poFeature->SetGeometry( &thePolygon );
   if(createFeature(poFeature,layer)!=OGRERR_NONE){
-    std::string errorString="Failed to create feature in shapefile";
+    std::string errorString="Failed to create feature";
     throw(errorString);
     OGRFeature::DestroyFeature( poFeature );
   }
@@ -386,7 +425,7 @@ void ImgWriterOgr::addLineString(std::vector<OGRPoint*>& points, const std::stri
     throw(errorString);
   }
   if(createFeature(poFeature,layer)!=OGRERR_NONE){
-    std::string errorString="Failed to create feature in shapefile";
+    std::string errorString="Failed to create feature";
     throw(errorString);
   }
   OGRFeature::DestroyFeature( poFeature );
@@ -493,7 +532,7 @@ int ImgWriterOgr::ascii2ogr(const std::string& filename, const std::string &laye
       if(eGType==wkbPoint){
         pointFeature->SetGeometry( &thePoint );
         if(createFeature(pointFeature)!=OGRERR_NONE){
-          std::string errorString="Failed to create feature in shapefile";
+          std::string errorString="Failed to create feature";
           throw(errorString);
           OGRFeature::DestroyFeature( pointFeature );
         }
@@ -557,7 +596,7 @@ int ImgWriterOgr::ascii2ogr(const std::string& filename, const std::string &laye
       if(eGType==wkbPoint){
         pointFeature->SetGeometry( &thePoint );
         if(createFeature(pointFeature)!=OGRERR_NONE){
-          std::string errorString="Failed to create feature in shapefile";
+          std::string errorString="Failed to create feature";
           throw(errorString);
           OGRFeature::DestroyFeature( pointFeature );
         }
@@ -576,7 +615,7 @@ int ImgWriterOgr::ascii2ogr(const std::string& filename, const std::string &laye
     // SetSpatialFilter(&thePolygon)
     polyFeature->SetGeometry( &thePolygon );
     if(createFeature(polyFeature)!=OGRERR_NONE){
-      std::string errorString="Failed to create feature in shapefile";
+      std::string errorString="Failed to create feature";
       throw(errorString);
       OGRFeature::DestroyFeature( polyFeature );
     }
diff --git a/src/imageclasses/Makefile.in b/src/imageclasses/Makefile.in
index 4fae88e..6e446c5 100644
--- a/src/imageclasses/Makefile.in
+++ b/src/imageclasses/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,23 +16,51 @@
 
 
 VPATH = @srcdir@
-am__make_dryrun = \
-  { \
-    am__dry=no; \
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
     case $$MAKEFLAGS in \
       *\\[\ \	]*) \
-        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
-          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
-      *) \
-        for am__flg in $$MAKEFLAGS; do \
-          case $$am__flg in \
-            *=*|--*) ;; \
-            *n*) am__dry=yes; break;; \
-          esac; \
-        done;; \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
     esac; \
-    test $$am__dry = yes; \
-  }
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -53,8 +80,8 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = src/imageclasses
-DIST_COMMON = $(libimageClasses_la_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/depcomp $(libimageClasses_la_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -101,31 +128,66 @@ am__objects_1 =
 am_libimageClasses_la_OBJECTS = $(am__objects_1) ImgReaderGdal.lo \
 	ImgReaderOgr.lo ImgWriterGdal.lo ImgWriterOgr.lo
 libimageClasses_la_OBJECTS = $(am_libimageClasses_la_OBJECTS)
-libimageClasses_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-	$(CXXFLAGS) $(libimageClasses_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_lt = $(am__v_lt_ at AM_V@)
+am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+libimageClasses_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(AM_CXXFLAGS) $(CXXFLAGS) $(libimageClasses_la_LDFLAGS) \
+	$(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 am__mv = mv -f
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_ at AM_V@)
+am__v_CXX_ = $(am__v_CXX_ at AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
 CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_ at AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_ at AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_ at AM_V@)
+am__v_CC_ = $(am__v_CC_ at AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
 CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
 SOURCES = $(libimageClasses_la_SOURCES)
 DIST_SOURCES = $(libimageClasses_la_SOURCES)
 am__can_run_installinfo = \
@@ -134,12 +196,30 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 HEADERS = $(libimageClasses_la_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_CXXFLAGS = -I$(top_srcdir)/src $(GSL_CFLAGS) $(GDAL_CFLAGS) @AM_CXXFLAGS@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AM_LDFLAGS = $(GSL_LDFLAGS) $(GDAL_LDFLAGS) @AM_LDFLAGS@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
@@ -329,6 +409,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
 	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
@@ -355,14 +436,17 @@ uninstall-libLTLIBRARIES:
 
 clean-libLTLIBRARIES:
 	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-	  test "$$dir" != "$$p" || dir=.; \
-	  echo "rm -f \"$${dir}/so_locations\""; \
-	  rm -f "$${dir}/so_locations"; \
-	done
+	@list='$(lib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
+
 libimageClasses.la: $(libimageClasses_la_OBJECTS) $(libimageClasses_la_DEPENDENCIES) $(EXTRA_libimageClasses_la_DEPENDENCIES) 
-	$(libimageClasses_la_LINK) -rpath $(libdir) $(libimageClasses_la_OBJECTS) $(libimageClasses_la_LIBADD) $(LIBS)
+	$(AM_V_CXXLD)$(libimageClasses_la_LINK) -rpath $(libdir) $(libimageClasses_la_OBJECTS) $(libimageClasses_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -376,25 +460,25 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImgWriterOgr.Plo at am__quote@
 
 .cc.o:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ $<
 
 .cc.obj:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cc.lo:
- at am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -423,26 +507,15 @@ uninstall-libimageClasses_laHEADERS:
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 	dir='$(DESTDIR)$(libimageClasses_ladir)'; $(am__uninstall_files_from_dir)
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -454,15 +527,11 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -471,6 +540,21 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -616,20 +700,20 @@ uninstall-am: uninstall-libLTLIBRARIES \
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libLTLIBRARIES clean-libtool ctags distclean \
-	distclean-compile distclean-generic 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-info install-info-am \
-	install-libLTLIBRARIES install-libimageClasses_laHEADERS \
-	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-libLTLIBRARIES \
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+	clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \
+	ctags-am distclean distclean-compile distclean-generic \
+	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-info \
+	install-info-am install-libLTLIBRARIES \
+	install-libimageClasses_laHEADERS 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 tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
 	uninstall-libimageClasses_laHEADERS
 
 ###############################################################################
diff --git a/src/lasclasses/Makefile.in b/src/lasclasses/Makefile.in
index 053edc8..fda566f 100644
--- a/src/lasclasses/Makefile.in
+++ b/src/lasclasses/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,23 +16,51 @@
 
 
 VPATH = @srcdir@
-am__make_dryrun = \
-  { \
-    am__dry=no; \
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
     case $$MAKEFLAGS in \
       *\\[\ \	]*) \
-        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
-          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
-      *) \
-        for am__flg in $$MAKEFLAGS; do \
-          case $$am__flg in \
-            *=*|--*) ;; \
-            *n*) am__dry=yes; break;; \
-          esac; \
-        done;; \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
     esac; \
-    test $$am__dry = yes; \
-  }
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -53,8 +80,8 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = src/lasclasses
-DIST_COMMON = $(liblasClasses_la_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/depcomp $(liblasClasses_la_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -100,31 +127,66 @@ liblasClasses_la_LIBADD =
 am__objects_1 =
 am_liblasClasses_la_OBJECTS = $(am__objects_1) FileReaderLas.lo
 liblasClasses_la_OBJECTS = $(am_liblasClasses_la_OBJECTS)
-liblasClasses_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-	$(CXXFLAGS) $(liblasClasses_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_lt = $(am__v_lt_ at AM_V@)
+am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+liblasClasses_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(AM_CXXFLAGS) $(CXXFLAGS) $(liblasClasses_la_LDFLAGS) \
+	$(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 am__mv = mv -f
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_ at AM_V@)
+am__v_CXX_ = $(am__v_CXX_ at AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
 CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_ at AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_ at AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_ at AM_V@)
+am__v_CC_ = $(am__v_CC_ at AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
 CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
 SOURCES = $(liblasClasses_la_SOURCES)
 DIST_SOURCES = $(liblasClasses_la_SOURCES)
 am__can_run_installinfo = \
@@ -133,12 +195,30 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 HEADERS = $(liblasClasses_la_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_CXXFLAGS = -I$(top_srcdir)/src $(GDAL_CFLAGS) @AM_CXXFLAGS@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AM_LDFLAGS = $(GDAL_LDFLAGS) @AM_LDFLAGS@ -llas
 AR = @AR@
 AUTOCONF = @AUTOCONF@
@@ -327,6 +407,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
 	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
@@ -353,14 +434,17 @@ uninstall-libLTLIBRARIES:
 
 clean-libLTLIBRARIES:
 	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-	  test "$$dir" != "$$p" || dir=.; \
-	  echo "rm -f \"$${dir}/so_locations\""; \
-	  rm -f "$${dir}/so_locations"; \
-	done
+	@list='$(lib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
+
 liblasClasses.la: $(liblasClasses_la_OBJECTS) $(liblasClasses_la_DEPENDENCIES) $(EXTRA_liblasClasses_la_DEPENDENCIES) 
-	$(liblasClasses_la_LINK) -rpath $(libdir) $(liblasClasses_la_OBJECTS) $(liblasClasses_la_LIBADD) $(LIBS)
+	$(AM_V_CXXLD)$(liblasClasses_la_LINK) -rpath $(libdir) $(liblasClasses_la_OBJECTS) $(liblasClasses_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -371,25 +455,25 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FileReaderLas.Plo at am__quote@
 
 .cc.o:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ $<
 
 .cc.obj:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cc.lo:
- at am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -418,26 +502,15 @@ uninstall-liblasClasses_laHEADERS:
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 	dir='$(DESTDIR)$(liblasClasses_ladir)'; $(am__uninstall_files_from_dir)
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -449,15 +522,11 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -466,6 +535,21 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -611,20 +695,20 @@ uninstall-am: uninstall-libLTLIBRARIES \
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libLTLIBRARIES clean-libtool ctags distclean \
-	distclean-compile distclean-generic 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-info install-info-am \
-	install-libLTLIBRARIES install-liblasClasses_laHEADERS \
-	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-libLTLIBRARIES \
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+	clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \
+	ctags-am distclean distclean-compile distclean-generic \
+	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-info \
+	install-info-am install-libLTLIBRARIES \
+	install-liblasClasses_laHEADERS 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 tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
 	uninstall-liblasClasses_laHEADERS
 
 

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



More information about the Pkg-grass-devel mailing list