[singular] 07/07: Import (zeroth) Debian patch 4.0.1p2+ds-1

Jerome Benoit calculus-guest at moszumanska.debian.org
Sun Feb 8 12:52:45 UTC 2015


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

calculus-guest pushed a commit to branch master
in repository singular.

commit 6b7feec859472db77ea575aa5fcbb37c7ade150b
Author: Jerome Benoit <calculus at rezozer.net>
Date:   Sun Feb 8 12:50:12 2015 +0100

    Import (zeroth) Debian patch 4.0.1p2+ds-1
---
 debian/.git-dpm                                    |    8 -
 debian/ESingular.1                                 |    1 -
 debian/Singular.1                                  |   92 -
 debian/TSingular.1                                 |    1 -
 debian/changelog                                   |   43 +-
 debian/clean                                       |    9 +
 debian/compat                                      |    2 +-
 debian/control                                     |  195 +-
 debian/copyright                                   |  421 +-
 debian/libsingular-3-1-6.install                   |    1 -
 debian/libsingular-3-1-6.lintian-overrides         |    5 -
 debian/libsingular-dev.install                     |    2 -
 debian/libsingular4-dbg.lintian-overrides          |    2 +
 debian/libsingular4-dev-common.install             |    1 +
 debian/libsingular4-dev-common.lintian-overrides   |    2 +
 debian/libsingular4-dev.install                    |   13 +
 debian/libsingular4-dev.lintian-overrides          |    2 +
 debian/libsingular4.install                        |    6 +
 debian/libsingular4.lintian-overrides              |   18 +
 debian/patches/0001-tag-gfan-using-examples.patch  |  513 --
 ...ESTDIR-as-a-pre-prefix-in-install-targets.patch |  348 -
 ...003-add-working-all-target-to-Makefile.in.patch |   58 -
 .../0004-miscellaneous-Makefile.in-patches.patch   |  289 -
 ...eeds-to-be-defined-after-include-assert.h.patch |   25 -
 debian/patches/0006-keep-mod2.h-in-Singular.patch  | 6983 --------------------
 .../0007-move-libreadline-to-main-binary.patch     |  219 -
 debian/patches/0008-default-path-settings.patch    |   60 -
 ...-disable-examples-for-divisors-and-gitfan.patch |   35 -
 ...x-warning-treated-as-error-in-pyobject.cc.patch |   23 -
 debian/patches/0011-also-install-sing_dbm.h.patch  |   23 -
 ...on-t-forget-LDFLAGS-in-module-compilation.patch |   23 -
 debian/patches/0013-fix-mmInit-weirdness.patch     |   81 -
 .../0014-sanitize-cf_gmp.h-generation.patch        |   46 -
 .../0015-use-bin-sed-not-sed-in-build-system.patch |   93 -
 .../0016-Use-full-path-for-a-few-coreutils.patch   |  251 -
 .../0017-make-interactive-docbuild-work.patch      |   30 -
 ...18-NTL6-compatibility-patch-from-sagemath.patch |   52 -
 debian/patches/debianization-4ti2.patch            |   37 +
 debian/patches/debianization-documentation.patch   |   52 +
 debian/patches/debianization-gather-headers.patch  |  356 +
 .../patches/debianization-rename-libraries.patch   |  480 ++
 .../debianization-rename-pkgconfig_files.patch     |  147 +
 debian/patches/debianization-resources.patch       |   52 +
 debian/patches/debianization.patch                 |  241 +
 debian/patches/series                              |   34 +-
 debian/patches/upstream-CC2help2man.patch          |   90 +
 debian/patches/upstream-autotools-doxygen.patch    |   18 +
 .../upstream-autotools-help2man-extra.patch        |   28 +
 debian/patches/upstream-autotools-help2man.patch   |  159 +
 .../upstream-autotools-pkgconfig-refine.patch      |   23 +
 .../patches/upstream-contrib-update-normaliz.patch | 3443 ++++++++++
 debian/patches/upstream-dump4help2man.patch        |   90 +
 ...upstream-fix-autotools-CPPFLAGS_overwrite.patch |   19 +
 debian/patches/upstream-source-typo.patch          |  334 +
 debian/repack                                      |  161 +
 debian/rules                                       |  285 +-
 debian/series                                      |    0
 debian/singular-bin/ESingular                      |   11 -
 debian/singular-bin/Singular                       |   11 -
 debian/singular-bin/TSingular                      |   11 -
 debian/singular-data.install                       |    3 +
 debian/singular-data.lintian-overrides             |    2 +
 debian/singular-dev-doc.doc-base                   |   13 +
 debian/singular-dev-doc.docs                       |    1 +
 debian/singular-dev-doc.lintian-overrides          |    2 +
 debian/singular-doc.lintian-overrides              |    9 +
 debian/singular-modules.install                    |    6 +
 debian/singular-modules.lintian-overrides          |    2 +
 debian/singular-ui-emacs.install                   |    3 +
 debian/singular-ui-emacs.lintian-overrides         |    2 +
 debian/singular-ui-emacs.manpages                  |    1 +
 debian/singular-ui-xterm.install                   |    1 +
 debian/singular-ui-xterm.lintian-overrides         |    2 +
 debian/singular-ui-xterm.manpages                  |    1 +
 debian/singular-ui.install                         |    1 +
 debian/singular-ui.lintian-overrides               |    2 +
 debian/singular-ui.manpages                        |    1 +
 debian/singular.dirs                               |    1 -
 debian/singular.install                            |    6 -
 debian/singular.lintian-overrides                  |    2 +
 debian/singular.manpages                           |    3 -
 debian/singular.menu                               |    2 -
 debian/source/lintian-overrides                    |    3 +
 debian/watch                                       |    8 +-
 84 files changed, 6310 insertions(+), 9825 deletions(-)

diff --git a/debian/.git-dpm b/debian/.git-dpm
deleted file mode 100644
index 3e83686..0000000
--- a/debian/.git-dpm
+++ /dev/null
@@ -1,8 +0,0 @@
-# see git-dpm(1) from git-dpm package
-97ec68c07998e9c3b38aa340ee47aa2b4f6a09fb
-97ec68c07998e9c3b38aa340ee47aa2b4f6a09fb
-b7a79f71f3462339b70b598a5756e06ee0d6639e
-b7a79f71f3462339b70b598a5756e06ee0d6639e
-singular_3-1-6+dfsg.orig.tar.gz
-a970d278087f954d6e3ff439027b1a4dd6e7eb22
-20108290
diff --git a/debian/ESingular.1 b/debian/ESingular.1
deleted file mode 100644
index 5ce7560..0000000
--- a/debian/ESingular.1
+++ /dev/null
@@ -1 +0,0 @@
-.so Singular.1
diff --git a/debian/Singular.1 b/debian/Singular.1
deleted file mode 100644
index 53e782f..0000000
--- a/debian/Singular.1
+++ /dev/null
@@ -1,92 +0,0 @@
-.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.36.
-.TH SINGULAR "1" "April 2008" "Singular" "User Commands"
-.SH NAME
-Singular \- A commutative algebra system for polynomial computations
-.SH DESCRIPTION
-.SS "Singular -- a CAS for polynomial computations."
-.SS "ESingular: starts-up Singular within emacs."
-.SS "TSingular: starts-up Singular within a new terminal"
-.IP
-.SH SYNTAX
-.B \&Singular [options] [file1 [file2 ...]]
-
-.B \&ESingular [options] [file1 [file2 ...]]
-
-.B \&TSingular [options] [file1 [file2 ...]]
-
-.SH OPTIONS
-.TP
-\fB\-b\fR \fB\-\-batch\fR
-Run in MP batch mode
-.TP
-\fB\-c\fR \fB\-\-execute\fR=\fISTRING\fR
-Execute STRING on start\-up
-.TP
-\fB\-d\fR \fB\-\-sdb\fR
-Enable source code debugger (experimental)
-.TP
-\fB\-e\fR \fB\-\-echo\fR[=\fIVAL\fR]
-Set value of variable `echo' to (integer) VAL
-.TP
-\fB\-h\fR \fB\-\-help\fR
-Print help message and exit
-.TP
-\fB\-q\fR \fB\-\-quiet\fR
-Do not print start\-up banner and lib load messages
-.TP
-\fB\-r\fR \fB\-\-random\fR=\fISEED\fR
-Seed random generator with integer (integer) SEED
-.TP
-\fB\-t\fR \fB\-\-no\-tty\fR
-Do not redefine the terminal characteristics
-.TP
-\fB\-u\fR \fB\-\-user\-option\fR=\fISTRING\fR
-Return STRING on `system("\-\-user\-option")'
-.TP
-\fB\-v\fR \fB\-\-version\fR
-Print extended version and configuration info
-.TP
-\fB\-\-allow\-net\fR
-Allow to fetch (html) help pages from the net
-.TP
-\fB\-\-browser\fR=\fIBROWSER\fR
-Display help in BROWSER ([x,tk]info, netscape)
-.TP
-\fB\-\-emacs\fR
-Set defaults for running within emacs
-.TP
-\fB\-\-no\-stdlib\fR
-Do not load `standard.lib' on start\-up
-.TP
-\fB\-\-no\-rc\fR
-Do not execute `.singularrc' file(s) on start\-up
-.TP
-\fB\-\-no\-warn\fR
-Do not display warning messages
-.TP
-\fB\-\-no\-out\fR
-Suppress all output
-.TP
-\fB\-\-min\-time\fR=\fISECS\fR
-Do not display times smaller than SECS (in seconds)
-.TP
-\fB\-\-MPport\fR=\fIPORT\fR
-Use PORT number for MP conections
-.TP
-\fB\-\-MPhost\fR=\fIHOST\fR
-Use HOST for MP connections
-.TP
-\fB\-\-MPrsh\fR=\fIRSH\fR
-Use RSH for MP connections
-.TP
-\fB\-\-ticks\-per\-sec\fR=\fITICKS\fR
-Sets unit of timer to TICKS per second
-.PP
-For more information, type `help;' from within Singular or visit
-http://www.singular.uni\-kl.de or consult the
-Singular manual (available as on\-line info or html manual).
-.PP
-.SH "SEE ALSO"
-The full documentation for
-.B Singular
-is maintained as a Texinfo manual.
diff --git a/debian/TSingular.1 b/debian/TSingular.1
deleted file mode 100644
index 5ce7560..0000000
--- a/debian/TSingular.1
+++ /dev/null
@@ -1 +0,0 @@
-.so Singular.1
diff --git a/debian/changelog b/debian/changelog
index 3d84135..bcc4deb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,14 +1,39 @@
-singular (3-1-6+dfsg-1) UNRELEASED; urgency=low
+singular (4.0.1p2+ds-1) experimental; urgency=medium
 
-  * new upstream release, 3-1-6
-  * removed cdbs, use plain debhelper 
-  * install to $(DESTDIR)
-  * minus-friendly debian/watch (thanks, Bernhard)
-  * library package name: libsingular-3-1-6
-  * removed architecture.patch from series. no longer needed
-  * the relavant patches from sage-singular-3-1-5-p4 are merged already
+  * New major release started from scratch (Closes: #764475).
+  * Debianization:
+    - debian/copyright in DEP-5 format;
+    - debian/control:
+      - debhelper build-dep to >= 9;
+      - Standards Version 3.9.6;
+      - Vcs-* headers;
+    - debian/source, format 3.0 (quilt);
+    - build-arch/build-indep scheme, implement;
+    - debian/patches/ patches:
+      - in DEP-3 format;
+      - prepend singular- to every Singular libraries for avoiding
+        possible conflicts;
+      - gather headers in a package include folder for the same reason;
+      - manual page generated via help2man;
+      - minor upstream fixes;
+      - minor Debian adaptations;
+    - debian/watch file;
+    - debian/repack, repack script to clean up and gain weight;
+    - debian/rules:
+      - autoreconf-iguration;
+      - full dh integration;
+      - get-orig-source uscan based target which downloads the currently
+        packaged upstream tarball and repacks it;
+      - default target which basically queries package status with uscan
+        -- output in DEHS format;
+    - gpg-signature check support, neutralize.
+  * Minor fixes, enhancements, request for a better source tarball were
+    submitted and have been integrated; thanks to the Singular Team.
+  * Upstream fixes and enhancemens, as well as request for integration of the
+    user documentation in the source tarball will be pulled for request to the
+    Singular Team.
 
- -- Felix Salfelder <felix at salfelder.org>  Wed, 20 Mar 2013 13:43:39 +0100
+ -- Jerome Benoit <calculus at rezozer.net>  Fri, 06 Feb 2015 20:18:24 +0000
 
 singular (3-0-4-3.dfsg-3.1) unstable; urgency=low
 
diff --git a/debian/clean b/debian/clean
new file mode 100644
index 0000000..7d4215c
--- /dev/null
+++ b/debian/clean
@@ -0,0 +1,9 @@
+resources/resourcesconfig.h
+libsingular-config.1
+libpolys/libpolys-config.1
+Singular/Singular.1
+Singular/ESingular.1
+Singular/TSingular.1
+dox/doxyfile.stamp
+dox/html_dox.log
+dox/tags
diff --git a/debian/compat b/debian/compat
index 7f8f011..ec63514 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-7
+9
diff --git a/debian/control b/debian/control
index c8feeee..a9ea97f 100644
--- a/debian/control
+++ b/debian/control
@@ -2,57 +2,178 @@ Source: singular
 Section: math
 Priority: optional
 Maintainer: Debian Science Maintainers <debian-science-maintainers at lists.alioth.debian.org>
-Uploaders: Felix Salfelder <felix at salfelder.org>
+Uploaders: Jerome Benoit <calculus at rezozer.net>
+Build-Depends:
+ debhelper (>= 9),
+ autotools-dev, autoconf-archive, dh-autoreconf, libtool, help2man,
+ libreadline6-dev,
+ libgmp-dev, libmpfr-dev, libglpk-dev, libcdd-dev, libflint-dev, libntl-dev,
+## graphviz, 4ti2, normaliz, surf-alggeo,
+ python-polybori (>= 0.8.3)
+Build-Depends-Indep:
+ doxygen,
+ rdfind, symlinks
+Standards-Version: 3.9.6
 Homepage: http://www.singular.uni-kl.de/
-Build-Depends: autotools-dev, debhelper (>= 7), patchutils (>= 0.2.25),
- libgmp3-dev, libntl-dev (>=5.2), libreadline-dev, libmpfr-dev,
- python-polybori (>=0.8.2),
- sed (>= 4.2.1),
- sharutils,
- texinfo
-Standards-Version: 3.9.4
+Vcs-Git: git://anonscm.debian.org/debian-science/packages/singular.git
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=debian-science/packages/singular.git
-Vcs-Git: git://anonscm.debian.org/debian-science/packages/singular
 
 Package: singular
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libsingular-3-1-6  (= ${binary:Version})
-Description: commutative algebra system
- SINGULAR is a Computer Algebra System for polynomial computations
- with special emphasis on the needs of commutative algebra,
- algebraic geometry, and singularity theory.
+Depends: singular-ui, singular-data, singular-modules, ${misc:Depends}
+Description: Computer Algebra System for Polynomial Computations
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
  .
- Main computational objects: ideals/modules over very general
- polynomial rings over various ground fields.
+ This dummy package provides the standard installation.
+
+Package: libsingular4
+Provides: libsingular
+Section: libs
+Architecture: any
+Pre-Depends: ${misc:Pre-Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Conflicts: libsingular
+Multi-Arch: same
+Description: Computer Algebra System for Polynomial Computations -- library package
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
  .
- This package contains the Singular CLI and some helper programs.
+ This package contains shared libraries.
 
-Package: libsingular-dev
+Package: libsingular4-dev
+Provides: libsingular-dev
 Section: libdevel
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libsingular-3-1-6  (= ${binary:Version})
-Description: library for commutative algebra, development files
- SINGULAR is a Computer Algebra System for polynomial computations
- with special emphasis on the needs of commutative algebra,
- algebraic geometry, and singularity theory.
+Depends: libsingular4 (= ${binary:Version}), libsingular4-dev-common (= ${source:Version}), ${misc:Depends}
+Conflicts: libsingular-dev
+Suggests: pkg-config, singular-dev-doc (= ${binary:Version})
+Multi-Arch: same
+Description: Computer Algebra System for Polynomial Computations -- development package
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
  .
- Main computational objects: ideals/modules over very general
- polynomial rings over various ground fields.
+ This package contains architecture dependent header files and static libraries.
+
+Package: libsingular4-dev-common
+Section: libdevel
+Architecture: all
+Depends: ${misc:Depends}
+Multi-Arch: foreign
+Description: Computer Algebra System for Polynomial Computations -- common dev package
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
  .
- This package contains header files and static libraries.
+ This package contains common header files.
 
-Package: libsingular-3-1-6
-Provides: libsingular
+Package: singular-modules
 Section: libs
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: library for commutative algebra, shared library
- SINGULAR is a Computer Algebra System for polynomial computations
- with special emphasis on the needs of commutative algebra,
- algebraic geometry, and singularity theory.
+Pre-Depends: ${misc:Pre-Depends}
+Depends: libsingular4 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Multi-Arch: same
+Description: Computer Algebra System for Polynomial Computations -- module package
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
+ .
+ This package contains the basic builtin modules.
+
+Package: singular-data
+Architecture: all
+Depends: ${misc:Depends}
+Recommends: singular-ui (= ${binary:Version}), graphviz, 4ti2, normaliz, python-polybori (>= 0.8.3)
+Suggests: graphicsmagick-imagemagick-compat | imagemagick
+Multi-Arch: foreign
+Description: Computer Algebra System for Polynomial Computations -- shared data
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
+ .
+ This package contains architecture independent material.
+
+Package: singular-ui
+Architecture: any
+Depends: libsingular4 (= ${binary:Version}), singular-data (= ${source:Version}), ${shlibs:Depends}, ${misc:Depends}
+Recommends: singular-modules (= ${binary:Version})
+Multi-Arch: foreign
+Description: Computer Algebra System for Polynomial Computations -- console user interface
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
+ .
+ This package contains the SINGULAR command-line interface.
+
+Package: singular-ui-emacs
+Architecture: any
+Depends: singular-ui (= ${binary:Version}), emacs, ${shlibs:Depends}, ${misc:Depends}
+Multi-Arch: foreign
+Description: Computer Algebra System for Polynomial Computations -- emacs user interface
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
+ .
+ This package contains the SINGULAR command-line interface within emacs.
+
+Package: singular-ui-xterm
+Architecture: any
+Depends: singular-ui (= ${binary:Version}), xterm, ${shlibs:Depends}, ${misc:Depends}
+Multi-Arch: foreign
+Description: Computer Algebra System for Polynomial Computations -- xterm user interface
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
  .
- Main computational objects: ideals/modules over very general
- polynomial rings over various ground fields.
+ This package contains the SINGULAR command-line interface within a (new)
+ terminal window.
+
+Package: libsingular4-dbg
+Provides: libsingular-dbg
+Section: debug
+Priority: extra
+Architecture: any
+Depends: libsingular4 (= ${binary:Version}), ${misc:Depends}
+Conflicts: libsingular-dbg
+Multi-Arch: same
+Description: Computer Algebra System for Polynomial Computations -- debug symbols package
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
+ .
+ This package provides the debugging symbols.
+
+Package: singular-doc
+Section: doc
+Architecture: all
+Depends: ${misc:Depends}
+Suggests:
+ singular (= ${binary:Version}),
+ pdf-viewer,
+ www-browser
+Multi-Arch: foreign
+Description: Computer Algebra System for Polynomial Computations -- user documentation
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
+ .
+ This package contains the user documentation in HTML and PDF formats.
+
+Package: singular-dev-doc
+Section: doc
+Architecture: all
+Depends: libjs-jquery, ${misc:Depends}
+Suggests:
+ singular (= ${binary:Version}),
+# pdf-viewer,
+ www-browser
+Multi-Arch: foreign
+Description: Computer Algebra System for Polynomial Computations -- developer documentation
+ SINGULAR is a Computer Algebra System (CAS) for polynomial computations with
+ emphasis on the special needs of commutative algebra, algebraic geometry,
+ and singularity theory.
  .
- This package contains the shared library, some Singular runtime libraries and
- lookup tables.
+ This package contains the developer documentation in HTML and PDF formats.
diff --git a/debian/copyright b/debian/copyright
index 742240e..d322013 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,190 +1,245 @@
-This package was downloaded from http://www.singular.uni-kl.de
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0
+Upstream-Name: singular
+Upstream-Contact: Singular Team <singular at mathematik.uni-kl.de>
+Source: http://www.singular.uni-kl.de/
+Comment:
+ The upstream source tarball is repacked to drop off the regenerated material
+ (mainly autotools related) and material provided by other packages (mainly
+ autoconf-archive m4 files) to gain weight.
 
-Files: debian/watch
-Copyright: Bernhard R. Link <brlink at debian.org>
-
-Files: debian/*
-Copyright: Tim Abbott <tabbott at mit.edu> 2008,
-         Felix Salfelder <felix at salfelder.org> 2012
-License: GPL-3+
- The Debian packaging is licensed under the GPL,
- version 3 or later.
+Files: *
+Copyright:
+ 1986-2014 Singular Team <singular at mathematik.uni-kl.de>
+   Wolfram Decker
+   Gert-Martin Greuel
+   Gerhard Pfister
+   Hans Schoeneman
+License: GPL-2 or GPL-3
+Comment:
+ For information on how to cite Singular see
+ `http://www.singular.uni-kl.de/index.php/how-to-cite-singular'.
 
 Files: factory/*
-Copyright: © 1991-2007 G.-M. Greuel, R. Stobbe, J. Schmidt, G. Pfister,
-             H. Schoenemann
+Copyright:
+ 1991-2014
+   Gert-Martin Greuel
+   Rudiger Stobbe
+   Jens Schmidt
+   Gerhard Pfister
+   Hans Schonemann
+License: GPL-2 or GPL-3
+Comment:
+ Code from libfac or derived from code from libfac is contained in
+ the following files:
+  factory/cfCharSets.cc
+  factory/cfCharSets.h
+  factory/cfCharSetsUtil.cc
+  factory/cfCharSetsUtil.h
+  factory/facAlgFunc.cc
+  factory/facAlgFunc.h
+  factory/facAlgFuncUtil.cc
+  factory/facAlgFuncUtil.h
+ libfac is a library for `Characteristic sets and
+ factorization over algebraic function fields' written by
+ Michael Messollen <mmessollen at web.de>, Copyright 1996-2010.
+ .
+ Slightly modified code from Number Theory Library (NTL) is implemented
+ in the following files:
+  factory/cfNTLzzpEXGCD.cc
+  factory/cfNTLzzpEXGCD.h
+ NTL is a library for `Doing Number Theory' written under a GPL-2+ license
+ by Victor Shoup <victor at shoup.net>, Copyright 1996-2009; NTL is available
+ at `http://www.shoup.net'.
 
 Files: omalloc/*
-Copyright: © 1999-2007 O. Bachmann 
-License: GPL2+
+Copyright:
+ 1999-2010 Olaf Bachmann
+License: GPL-2+
+
+Files:
+ kernel/*
+ libpolys/*
+ emacs/*
+ Singular/*
+Copyright:
+ 1986-2014
+   Gert-Martin Greuel
+   Gerhard Pfister
+   Hans Schoeneman
+License: GPL-2 or GPL-3
+
+Files:
+ factory/bin/folding.el
+Copyright:
+ 1992-1993 Jamie Lokier
+License: GPL-2+
+
+Files:
+ factory/aminclude.am
+Copyright:
+ 2004 Oren Ben-Kiki
+License: GPL-2+
+
+Files:
+ omalloc/omReturn.h
+Copyright:
+ 2000 Gray Watson
+License: other
+ This file is part of the dmalloc package.
+ .
+ Permission to use, copy, modify, and distribute this software for
+ any purpose and without fee is hereby granted, provided that the
+ above copyright notice and this permission notice appear in all
+ copies, and that the name of Gray Watson not be used in advertising
+ or publicity pertaining to distribution of the document or software
+ without specific, written prior permission.
+ .
+ Gray Watson makes no representations about the suitability of the
+ software described herein for any purpose.  It is provided "as is"
+ without express or implied warranty.
+ .
+ The author may be contacted via `http://dmalloc.com/'.
+
+Files:
+ Singular/links/ndbm.cc
+ Singular/links/ndbm.h
+Copyright:
+ 1983 Regents of the University of California
+License: BSD-3-clause
+
+Files:
+ Singular/fegetopt.c
+Copyright:
+ 1987-1994 Free Software Foundation, Inc.
+License: GPL-2+
+
+Files:
+ Singular/fegetopt.h
+Copyright:
+ 1989-1993 Free Software Foundation, Inc.
+License: GPL-2+
+
+Files:
+ m4/ax_prefix_config_h.m4
+Copyright:
+ 2008 Guido U. Draheim <guidod at gmx.de>
+ 2008 Marten Svantesson
+ 2008 Gerald Point <Gerald.Point at labri.fr>
+License: GPL-3+
 
-Files: libfac/*
-Copyright: © 1996-2007 Michael Messollen <mmessollen at web.de>
+Files:
+ m4/google-perftools.m4
+Copyright:
+ 2005-2006 Intel Corporation
+License: Apache-2.0
 
-Files: *
-Copyright: © 1986-2007 G.-M. Greuel, G. Pfister, H. Schoenemann
-           © 1996-2007 Agnes Eileen Heydtmann,
-             Alexander Dreyer,
-             Andrea Mindnich,
-             Anne Fruehbis-Krueger,
-             Bernd Martin,
-             Christian Gorzel,
-             Christine Theis,
-             Christoph Lossen,
-             Dietmar Hillebrand,
-             Gerhard Pfister,
-             Gert-Martin Greuel,
-             Hans Schoenemann,
-             I.Bermejo,
-             Ivor Saynisch,
-             Jorge Martin Morales,
-             Jose Ignacio Farran Martin,
-             Kai Krueger,
-             Markus Hochstetter,
-             Martin Lamm,
-             Maryna Viazovska,
-             Mathias Schulze,
-             Moritz Wenk,
-             Olaf Bachmann,
-             Ph.Gimenez,
-             Santiago Laplagne,
-             S. Endrass,
-             Simon King,
-             Thomas Bayer,
-             Thomas Keilen,
-             Tobias Hirsch,
-             Viktor Levandovskyy,
-             Wilfred Pohl,
-             Wolfram Decker (Singular/LIB)
-License: GPL2+
-   This package 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; version 2 or version 3 of the License.
-   .
-   This package 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 package; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
-
-On Debian systems, the complete text of the GNU General
-Public License can be found in `/usr/share/common-licenses/GPL'.
-
-Files: Singular/run.c
-Copyright: (C) 1998  Charles S. Wilson
-License: GPL2+
-
-Files: factory/bin/folding.el
-Copyright: (C) 1992, 1993, Jamie Lokier
-License: GPL2+
-
-Files: omalloc/gmalloc.c
-Copyright: 1990, 1991, 1992, 1993, 1995 Free Software Foundation, Inc.
-                  Written May 1989 by Mike Haertel.
-License: GPL2+
-
-Files: factory/readcf.cc
-Copyright: (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005,
-      2006 Free Software Foundation, Inc.
-License: GPL2+
-
-Files: kernel/fegetopt.{h,c}
-Copyright: (C) 1987-1994 Free Software Foundation, Inc.
-License: GPL2+
-
-Files: kernel/htmlhelp.h
-Copyright: Jacek Caban 2004
-License: LGPL
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-
-On Debian systems, the complete text of the GNU Lesser General Public
-License can be found in `/usr/share/common-licenses/LGPL'.
-
-Files: omalloc/omReturn.h
-Copyright: Gray Watson 2000
-License: other
- * This file is part of the dmalloc package.
- *
- * Permission to use, copy, modify, and distribute this software for
- * any purpose and without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies, and that the name of Gray Watson not be used in advertising
- * or publicity pertaining to distribution of the document or software
- * without specific, written prior permission.
- *
- * Gray Watson makes no representations about the suitability of the
- * software described herein for any purpose.  It is provided "as is"
- * without express or implied warranty.
- *
- * The author may be contacted via http://dmalloc.com/
-
-Files: Singular/ndbm.{cc,h}
-Copyright: (c) 1983 Regents of the University of California.
-License: BSD
-    Redistribution and use in source and binary forms, with or without
-    modification, are permitted under the terms of the BSD License.
-
-    THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-    ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-    OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-    OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-    SUCH DAMAGE.
-
-On Debian systems, the complete text of the BSD License can be 
-found in `/usr/share/common-licenses/BSD'.
-
-Files: omalloc/Misc/dlmalloc
-Copyright: (C) Wolfram Gloger 1995
-License: other
-    Permission to use, copy, modify, distribute, and sell this software
-    and its documentation for any purpose is hereby granted without fee,
-    provided that (i) the above copyright notices and this permission
-    notice appear in all copies of the software and related documentation,
-    and (ii) the name of Wolfram Gloger may not be used in any advertising
-    or publicity relating to the software.
-    .
-    THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
-    WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-    .
-    IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL,
-    INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
-    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-    WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY
-    OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-    PERFORMANCE OF THIS SOFTWARE.
-
-Files: MP/*
-    The directory MP/ was removed from the singular package because it had
-    non-DFSG free code (the license requires non-commercial use).
-
-Files: ntl/*
-    removed from the singular package as we
-    use the Debian ntl package from upstream sources.
-
-Files: Singular/LIB/surfex{.lib,}
-    removed from the singular package because it had unclear
-    copyright status, had no actual java sources for the class files, and
-    regardless should be packaged separately should it be included in
-    Debian.
+Files:
+ m4/p-procs.m4
+Copyright:
+ 2011 Bradford Hovinen <hovinen at gmail.com>
+License: public-domain
+ This file is public domain and comes with NO WARRANTY of any kind.
+
+Files: debian/*
+Copyright:
+ 2014-2015 Jerome Benoit <calculus at rezozer.net>
+ 2008-2009 Tim Abbott <tabbott at mit.edu>
+License: GPL-3+
+Comment:
+ This package was originally debianized by Tim Abbott <tabbott at mit.edu>.
+ Thanks also to both Bernhard R. Link <brlink at debian.org> and
+ Felix Salfelder <felix at salfelder.org> who had maintained the Debian
+ material as deposited at Alioth from 2012 to 2014 (UNRELEASED).
+
+License: GPL-2 or GPL-3
+ This package 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; version 2 or version 3 of the License.
+ .
+ This package 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 package. If not, see <http://www.gnu.org/licenses/>.
+ .
+ On Debian systems, the complete text of the GNU General Public License
+ version 2 can be found in `/usr/share/common-licenses/GPL-2', and the
+ complete text of the GNU General Public License version 3 can be found
+ in `/usr/share/common-licenses/GPL-3'.
+
+License: GPL-2+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ .
+ This package 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 package. If not, see <http://www.gnu.org/licenses/>.
+ .
+ On Debian systems, the complete text of the GNU General Public License
+ version 2 can be found in `/usr/share/common-licenses/GPL-2'.
+
+License: GPL-3+
+ This package 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 package 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 package. If not, see <http://www.gnu.org/licenses/>.
+ .
+ On Debian systems, the complete text of the GNU General Public License
+ version 3 can be found in `/usr/share/common-licenses/GPL-3'.
+
+License: BSD-3-clause
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+    may be used to endorse or promote products derived from this software
+    without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+License: Apache-2.0
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ .
+ http://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ .
+ On Debian systems, the complete text of the Apache version 2.0 license
+ can be found in `/usr/share/common-licenses/Apache-2.0'.
diff --git a/debian/libsingular-3-1-6.install b/debian/libsingular-3-1-6.install
deleted file mode 100644
index a506b64..0000000
--- a/debian/libsingular-3-1-6.install
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/singular-* usr/lib/
diff --git a/debian/libsingular-3-1-6.lintian-overrides b/debian/libsingular-3-1-6.lintian-overrides
deleted file mode 100644
index b2c7972..0000000
--- a/debian/libsingular-3-1-6.lintian-overrides
+++ /dev/null
@@ -1,5 +0,0 @@
-# doesn't seem to make sense to have finer-grained versions
-dev-pkg-without-shlib-symlink usr/lib/libsingular-3-1-6.so usr/lib/libsingular-3-1.so
-# currently, singular needs a non-symlinked instance of libsingular.so in the
-# wrong place, because it is abused to locate /usr/lib/singular-$(VERSION).
-package-contains-hardlink usr/lib/libsingular-3-1-6.so -> usr/lib/singular-3-1-6/libsingular.so
diff --git a/debian/libsingular-dev.install b/debian/libsingular-dev.install
deleted file mode 100644
index d7bbc66..0000000
--- a/debian/libsingular-dev.install
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/include/ usr/
-usr/lib/libsingular.so usr/lib/
diff --git a/debian/libsingular4-dbg.lintian-overrides b/debian/libsingular4-dbg.lintian-overrides
new file mode 100644
index 0000000..0e801a4
--- /dev/null
+++ b/debian/libsingular4-dbg.lintian-overrides
@@ -0,0 +1,2 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+libsingular4-dbg: no-upstream-changelog
diff --git a/debian/libsingular4-dev-common.install b/debian/libsingular4-dev-common.install
new file mode 100644
index 0000000..7620531
--- /dev/null
+++ b/debian/libsingular4-dev-common.install
@@ -0,0 +1 @@
+usr/include/singular/
diff --git a/debian/libsingular4-dev-common.lintian-overrides b/debian/libsingular4-dev-common.lintian-overrides
new file mode 100644
index 0000000..ae3b7ee
--- /dev/null
+++ b/debian/libsingular4-dev-common.lintian-overrides
@@ -0,0 +1,2 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+libsingular4-dev-common: no-upstream-changelog
diff --git a/debian/libsingular4-dev.install b/debian/libsingular4-dev.install
new file mode 100644
index 0000000..6042bfe
--- /dev/null
+++ b/debian/libsingular4-dev.install
@@ -0,0 +1,13 @@
+usr/include/*/singular/factory/*conf.h
+usr/include/*/singular/omalloc/*Config.h
+usr/include/*/singular/resources/*config.h
+usr/include/*/singular/singular/*config.h
+usr/lib/*/libsingular-*.a
+usr/lib/*/libsingular-factory.so
+usr/lib/*/libsingular-gfan.so
+usr/lib/*/libsingular-omalloc.so
+usr/lib/*/libsingular-polys.so
+usr/lib/*/libsingular-resources.so
+usr/lib/*/libsingular-Singular.so
+usr/lib/*/pkgconfig/singular-*.pc
+usr/lib/*/pkgconfig/Singular.pc
diff --git a/debian/libsingular4-dev.lintian-overrides b/debian/libsingular4-dev.lintian-overrides
new file mode 100644
index 0000000..90bf240
--- /dev/null
+++ b/debian/libsingular4-dev.lintian-overrides
@@ -0,0 +1,2 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+libsingular4-dev: no-upstream-changelog
diff --git a/debian/libsingular4.install b/debian/libsingular4.install
new file mode 100644
index 0000000..f2a104f
--- /dev/null
+++ b/debian/libsingular4.install
@@ -0,0 +1,6 @@
+usr/lib/*/libsingular-factory-*.so
+usr/lib/*/libsingular-gfan.so.*
+usr/lib/*/libsingular-omalloc-*.so
+usr/lib/*/libsingular-polys-*.so
+usr/lib/*/libsingular-resources-*.so
+usr/lib/*/libsingular-Singular-*.so
diff --git a/debian/libsingular4.lintian-overrides b/debian/libsingular4.lintian-overrides
new file mode 100644
index 0000000..751625a
--- /dev/null
+++ b/debian/libsingular4.lintian-overrides
@@ -0,0 +1,18 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+libsingular4: no-upstream-changelog
+
+# the upstream source contains C++ code, and has no clearly defined and versionned ABI
+libsingular4: package-name-doesnt-match-sonames
+
+# An isolated mathematically impossible computation in factory/NTLconvert.cc
+# is managed with exit(3); this sounds as a clumsy DEBUG policy rather than a
+# design issue, but still an issue that has to be fixed by the upstream team
+# itself.
+# Singular comes with its own memory library omalloc that hooks `out of memory'
+# events (OM_OUT_OF_MEMORY_HOOK in omalloc/omAllocSystem.c) before to implement
+# an unreachable exit(3); this looks as a clumsy emergency exit policy rather
+# than a design issue that may be revisited only to please lintian.
+libsingular4: shlib-calls-exit
+
+# the upstream source contains C++ code, and has no clearly defined and versionned ABI
+libsingular4: no-symbols-control-file
diff --git a/debian/patches/0001-tag-gfan-using-examples.patch b/debian/patches/0001-tag-gfan-using-examples.patch
deleted file mode 100644
index 5d1b71d..0000000
--- a/debian/patches/0001-tag-gfan-using-examples.patch
+++ /dev/null
@@ -1,513 +0,0 @@
-From 6bf72e4723ccf1164988280237cef5ea7f8e5705 Mon Sep 17 00:00:00 2001
-From: "Bernhard R. Link" <brlink at debian.org>
-Date: Sat, 3 Mar 2012 10:17:51 +0100
-Subject: tag gfan using examples
-
-Tag all examples in cones.doc, so that the manual can be built even if
-compiled without gfan support. if the tag is not given to doc2tex.pl,
-it skips the tagged examples
-
-Forwarded: not-needed
----
- doc/cones.doc | 110 +++++++++++++++++++++++++++++-----------------------------
- 1 file changed, 55 insertions(+), 55 deletions(-)
-
-diff --git a/doc/cones.doc b/doc/cones.doc
-index da2a600..d03c68a 100644
---- a/doc/cones.doc
-+++ b/doc/cones.doc
-@@ -56,7 +56,7 @@ vectors of L is the lineality space of the cone,
- if either bit is 0, then program computes the information itself.
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- // Let's define a cone in R^3 generated by the following half lines:
- intmat HL[5][3]= 
-  1,0, 0,
-@@ -121,7 +121,7 @@ if lower bit is 1, then program assumes the kernel of E is the span of the cone,
- if either bit is 0, then program computes the information itself. 
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- // Let's define a cone in R^3 given by the following inequalities:
- intmat IE[6][3]=  
- 1,3,5,
-@@ -217,7 +217,7 @@ int
- ambient dimension of the cone;
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,0,
- 0,1;
-@@ -245,7 +245,7 @@ cone
- canonicalized version of the cone, no more redundant inequalities and equations
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[11][3]=
- 0,-1,1,
- -1,1,0,
-@@ -280,7 +280,7 @@ int
- codimension of the cone;
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[1][2]=
- 1,0;
- cone c1=coneViaPoints(M1);
-@@ -306,7 +306,7 @@ cone
- local version of the given cone around the given point of the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[3][3]=
- 1,0,0,
- 0,1,0,
-@@ -337,7 +337,7 @@ int
- 1 iff c1 contains c2 as a face; 0 otherwise
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[2][2]=
- 1,0,
- 0,1;
-@@ -368,7 +368,7 @@ int
- 1 iff c1 entirely contains c2 resp. iff c contains the given point, possibly on one of its facets; 0 otherwise
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[2][2]=
- 1,0,
- 0,1;
-@@ -405,7 +405,7 @@ int
- 1 iff the cone contains a point with positive coordinates in its relative interior; 0 otherwise
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,1,
- 1,-1;
-@@ -433,7 +433,7 @@ int
- 1 iff the given cone contains the given point in its relative interior; 0 otherwise
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[2][2]=
- 1,0,
- 0,1;
-@@ -462,7 +462,7 @@ cone if both input arguments are cones, else polytope
- the hull of the two objects
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,0,
- 0,1;
-@@ -504,7 +504,7 @@ cone if both input arguments are cones, else polytope
- the intersection of the two objects
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,0,
- 0,1;
-@@ -545,7 +545,7 @@ int
- dimension of the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[1][2]=
- 1,0;
- cone c1=coneViaPoints(M1);
-@@ -571,7 +571,7 @@ cone
- the dual of the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,0,
- 0,1;
-@@ -604,7 +604,7 @@ bigintmat
- equations given by the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,0,
- 0,1;
-@@ -634,7 +634,7 @@ bigintmat
- inner normal vectors of the facets of the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,0,
- 0,1;
-@@ -664,7 +664,7 @@ bigintmat
- generating vectors of the lineality space of the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[5][3]=
- 1,0,0,
- 0,1,0,
-@@ -691,7 +691,7 @@ bigintmat
- generating vectors of the span of the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[3][5]=
- 1,0,0,0,0,
- 0,1,0,0,0,
-@@ -717,7 +717,7 @@ intvec
- linear forms of the cone (can be set by setLinearForms); returns empty intmat if not set
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[2][3]=
- -1,0,0,
- 0,-1,0;
-@@ -744,7 +744,7 @@ int
- getMultiplicity of the cone (can be set by setMultiplicity); returns 1 if not set
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[2][3]=
- -1,0,0,
- 0,-1,0;
-@@ -769,7 +769,7 @@ bigintmat
- inequalities given by the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,0,
- 0,1;
-@@ -798,7 +798,7 @@ int
- 1 iff the cone is the entire ambient space; 0 otherwise
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- cone c1;
- isFullSpace(c1);
- intmat M2[2][2]=
-@@ -830,7 +830,7 @@ int
- 1 iff the cone is just the origin of the ambient space; 0 otherwise
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- cone c1; // full cone in zero-dimensional ambient space
- isOrigin(c1);
- intmat M2[2][2]=
-@@ -863,7 +863,7 @@ int
- 1 iff the cone resp. fan is simplicial; 0 otherwise
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[3][3]=
- 1,0,0,
- 0,1,0,
-@@ -913,7 +913,7 @@ int
- dimension of the lineality space of the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[3][3]=
- 1,0,0,
- 0,1,0,
-@@ -944,7 +944,7 @@ cone
- the lineality space of the cone as a new cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[3][3]=
- 1,0,0,
- 0,1,0,
-@@ -977,7 +977,7 @@ cone
- the negated (or negative) of the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[2][2]=
- 1,0,
- 0,1;
-@@ -1002,7 +1002,7 @@ bigintmat
- quotient of Z^n intersected with the span of the cone with Z^n intersected with its lineality space
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[3][2]=
- 1,0,
- 0,1,
-@@ -1027,7 +1027,7 @@ bigintmat
- random point in the relative interior in c
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[3][2]=
- 1,0,
- 0,1,
-@@ -1052,7 +1052,7 @@ bigintmat
- rays of the cone outside the lineality space, rays inside the lineality space will be ignored
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,0,
- 0,1;
-@@ -1083,7 +1083,7 @@ intvec
- point in the relative interior of the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,0,
- 0,1;
-@@ -1111,7 +1111,7 @@ intvec
- if dimension(c)=linealityDimension(c)+1, then the quotient lattice of Z^n intersected with the span and Z^n intersected with the lineality space is Z^1 and the class of the cone is a semigroup. returns a generator of that semigroup. (like quotientLatticeBasis(cone c), but as intvec)
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[3][2]=
- 1,0,
- 0,1,
-@@ -1135,7 +1135,7 @@ semigroupGenerator(c);
- adds the information of a linear form to the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[2][3]=
- -1,0,0,
- 0,-1,0;
-@@ -1161,7 +1161,7 @@ getLinearForms(c);
- adds the information of a multiplicity to the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[2][3]=
- -1,0,0,
- 0,-1,0;
-@@ -1186,7 +1186,7 @@ bigintmat
- generating vectors of the orthogonal complement of the span of the cone
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[3][5]=
- 1,0,0,0,0,
- 0,1,0,0,0,
-@@ -1211,7 +1211,7 @@ intvec
- special-purpose interior point which supports recognition of symmetries among non-intersecting cones (used in implementation of fans)
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M1[2][2]=
- 1,0,
- 0,1;
-@@ -1305,7 +1305,7 @@ cone
- 1 iff c is contained in the collection of cones that is f; 0 otherwise
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- fan f=emptyFan(2);
- intmat M[2][2]=
- 1,0,
-@@ -1331,7 +1331,7 @@ fan
- empty fan in ambient dimension d
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- fan f=emptyFan(2);
- f;
- @c example
-@@ -1352,7 +1352,7 @@ fan
- fan generated by the cones supplied, either via a list or via single arguments
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[2][2]=1,0,0,1;
- cone c=coneViaPoints(M);
- intmat N[2][2]=1,0,0,-1;
-@@ -1379,7 +1379,7 @@ fan
- full fan in ambient dimension d
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- fan f=fullFan(2);
- f;
- @c example
-@@ -1399,7 +1399,7 @@ intvec
- F-Vector of the fan
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- fan f=emptyFan(2);
- fVector(f);
- intmat M[2][2]=1,0,0,1;
-@@ -1425,7 +1425,7 @@ cone
- cone (orbit=0) or orbit (orbit=1) of a certain index (ranges from 1 to numberOfConesOfDimension(f,*,*,*)) in a given dimension; if maximal=0, all cones and orbits are considered, if maximal=1, only maximal cones and orbits are considered; the default flags for orbit and maximal is 0.
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[3][3]=
- 1,0,0,
- 0,1,0,
-@@ -1454,7 +1454,7 @@ none
- inserts the cone into the fan; checks for compatibility beforehand unless check is passed and equal 0
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- fan f=emptyFan(3);
- f;
- intmat M[3][3]=
-@@ -1482,7 +1482,7 @@ int
- 1 iff cone is compatible with the fan; 0 otherwise
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- fan f=emptyFan(3);
- intmat M1[3][3]=
- 1,0,0,
-@@ -1520,7 +1520,7 @@ isCompatible(f,c3);
- @c 1 iff the fan is complete; 0 otherwise
- @c @item @strong{Example:}
- @c @smallexample
-- at c @c example
-+ at c @c example tag:gfan
- @c fan f=fullFan(2);
- @c isComplete(f);
- @c fan g=emptyFan(2);
-@@ -1560,7 +1560,7 @@ int
- 1 iff the fan is pure; 0 otherwise
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- fan f=fullFan(2);
- isPure(f);
- fan g=emptyFan(2);
-@@ -1592,7 +1592,7 @@ int
- number of maximal cones in f
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- fan f=emptyFan(3);
- nmaxcones(f);
- intmat M1[3][3]=
-@@ -1625,7 +1625,7 @@ int
- number of cones in f
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- fan f=emptyFan(3);
- ncones(f);
- intmat M1[3][3]=
-@@ -1658,7 +1658,7 @@ int
- number of cones (orbit=0) or orbits (orbit=1) of a given dimension; if maximal=0, then all cones are considered, if maximal=1, only maximal cones are considered
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- fan f=emptyFan(3);
- ncones(f);
- intmat M[3][3]=
-@@ -1693,7 +1693,7 @@ none
- removes the cone from the fan; checks for compatibility beforehand unless check is passed and equal 0
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[2][2]=1,0,0,1;
- intmat N[2][2]=1,0,1,-1;
- cone c=coneViaPoints(M);
-@@ -1744,7 +1744,7 @@ if flags is 1, then program assumes that each row vector of M generates a ray in
- if flags is 0, then program computes that information itself.
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- // This is a polytope in R^2 generated by (0,0), (1,0), (0,1), (0,0);
- intmat V[4][3]= 
- 1,0,0,
-@@ -1792,7 +1792,7 @@ if lower bit is 1, then program assumes the kernel of E is the span of the cone,
- if either bit is 0, then program computes the information itself. 
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat IE[2][3]=
- 1,0,0,
- 0,1,0;
-@@ -1839,7 +1839,7 @@ polytope
- Newton polytope of f 
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[4][2]=
- 0,0,
- 1,0,
-@@ -1864,7 +1864,7 @@ polytope
- Newton polytope of f 
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- ring r;
- poly f=x+y+z;
- polytope p=newtonPolytope(f);
-@@ -1886,7 +1886,7 @@ intmat
- vertices of p 
- @item @strong{Example:}
- @smallexample
-- at c example
-+ at c example tag:gfan
- intmat M[4][3]=
- 1,0,0,
- 1,2,0,
diff --git a/debian/patches/0002-use-DESTDIR-as-a-pre-prefix-in-install-targets.patch b/debian/patches/0002-use-DESTDIR-as-a-pre-prefix-in-install-targets.patch
deleted file mode 100644
index a02efd5..0000000
--- a/debian/patches/0002-use-DESTDIR-as-a-pre-prefix-in-install-targets.patch
+++ /dev/null
@@ -1,348 +0,0 @@
-From bd1bc12193ac989615a06c1371e0d2bdb77ec05d Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Thu, 16 Feb 2012 08:45:58 +0100
-Subject: use $DESTDIR as a pre-prefix, in install* targets
-
-Forwarded: not-needed
----
- IntegerProgramming/Makefile.in | 12 +++---
- Singular/Makefile.in           | 83 +++++++++++++++++++++---------------------
- factory/GNUmakefile.in         | 21 ++++++-----
- kernel/Makefile.in             | 20 +++++-----
- libfac/Makefile.in             | 14 +++----
- omalloc/Makefile.in            | 22 +++++------
- 6 files changed, 86 insertions(+), 86 deletions(-)
-
-diff --git a/IntegerProgramming/Makefile.in b/IntegerProgramming/Makefile.in
-index 50de520..05fccfe 100644
---- a/IntegerProgramming/Makefile.in
-+++ b/IntegerProgramming/Makefile.in
-@@ -63,12 +63,12 @@ install-nolns: install
- install_all: install
- 
- install install-libsingular: $(MAIN1) $(MAIN2) $(MAIN3) $(MAIN4) $(LLL)
--	${MKINSTALLDIRS} ${bindir}
--	${INSTALL_PROGRAM} $(MAIN1) ${bindir}
--	${INSTALL_PROGRAM} $(MAIN2) ${bindir}
--	${INSTALL_PROGRAM} $(MAIN3) ${bindir}
--	${INSTALL_PROGRAM} $(MAIN4) ${bindir}
--	${INSTALL_PROGRAM} $(LLL) ${bindir}
-+	${MKINSTALLDIRS} $(DESTDIR)${bindir}
-+	${INSTALL_PROGRAM} $(MAIN1) $(DESTDIR)${bindir}
-+	${INSTALL_PROGRAM} $(MAIN2) $(DESTDIR)${bindir}
-+	${INSTALL_PROGRAM} $(MAIN3) $(DESTDIR)${bindir}
-+	${INSTALL_PROGRAM} $(MAIN4) $(DESTDIR)${bindir}
-+	${INSTALL_PROGRAM} $(LLL) $(DESTDIR)${bindir}
- 
- install-bindist: $(MAIN1) $(MAIN2) $(MAIN3) $(MAIN4)
- 	${MKINSTALLDIRS} ${install_bindir}
-diff --git a/Singular/Makefile.in b/Singular/Makefile.in
-index 0a2b7e2..807d786 100644
---- a/Singular/Makefile.in
-+++ b/Singular/Makefile.in
-@@ -562,20 +562,20 @@ install_all: install
- install-nolns: all installbin-nolns installslib-nolns
- 
- installbin: ${SING_EXEC} libparse ESingular TSingular ${RUN_SINGULARS}
--	${MKINSTALLDIRS} ${bindir} ${bindir_mod}
--	${INSTALL_PROGRAM} ${SING_EXEC} ${SINGULAR}
-+	${MKINSTALLDIRS} $(DESTDIR)${bindir} $(DESTDIR)${bindir_mod}
-+	${INSTALL_PROGRAM} ${SING_EXEC} $(DESTDIR)${SINGULAR}
- 	-for file in *.so; do \
--	  ${INSTALL_PROGRAM} $$file ${bindir}; \
-+	  ${INSTALL_PROGRAM} $$file $(DESTDIR)${bindir}; \
- 	done
- 	-for file in MOD/*.so; do \
- 	  ${INSTALL_PROGRAM} $$file ${bindir}/MOD; \
- 	done
--	${INSTALL_PROGRAM} libparse ${RUN_SINGULARS} ${bindir}
--	${INSTALL_PROGRAM} ESingular TSingular ${bindir}
--	${INSTALL_PROGRAM} surfex ${bindir}
--	chmod a+x ${SINGULAR}
--	rm -f ${bindir}/${SING_EXEC}${EXEC_EXT}
--	cd ${bindir}; ${LN_S} ${SINGULAR} Singular${EXEC_EXT};
-+	${INSTALL_PROGRAM} libparse ${RUN_SINGULARS} $(DESTDIR)${bindir}
-+	${INSTALL_PROGRAM} ESingular TSingular $(DESTDIR)${bindir}
-+	${INSTALL_PROGRAM} surfex $(DESTDIR)${bindir}
-+	chmod a+x $(DESTDIR)${SINGULAR}
-+	rm -f $(DESTDIR)${bindir}/${SING_EXEC}${EXEC_EXT}
-+	cd $(DESTDIR)${bindir}; ${LN_S} ${SINGULAR} Singular${EXEC_EXT};
- 
- installbin-nolns: ${SING_EXEC} libparse ESingular TSingular ${RUN_SINGULARS}
- 	${MKINSTALLDIRS} ${bindir} ${bindir_mod}
-@@ -586,33 +586,33 @@ installbin-nolns: ${SING_EXEC} libparse ESingular TSingular ${RUN_SINGULARS}
- 	-for file in MOD/*.so; do \
- 	  ${INSTALL_PROGRAM} $$file ${bindir}/MOD; \
- 	done
--	${INSTALL_PROGRAM} libparse ${RUN_SINGULARS} ${bindir}
--	${INSTALL_PROGRAM} ESingular TSingular ${DL_LIBS} ${bindir}
--	chmod a+x ${SINGULAR}
--	rm -f ${bindir}/${SING_EXEC}${EXEC_EXT}
--	${INSTALL_PROGRAM} ${SINGULAR} ${bindir}/Singular${EXEC_EXT};
-+	${INSTALL_PROGRAM} libparse ${RUN_SINGULARS} $(DESTDIR)${bindir}
-+	${INSTALL_PROGRAM} ESingular TSingular ${DL_LIBS} $(DESTDIR)${bindir}
-+	chmod a+x $(DESTDIR)${SINGULAR}
-+	rm -f $(DESTDIR)${bindir}/${SING_EXEC}${EXEC_EXT}
-+	${INSTALL_PROGRAM} ${SINGULAR} $(DESTDIR)${bindir}/Singular${EXEC_EXT};
- 
- installslib: LIB
- 	test -r ${slibdir} || ${LN_S} `pwd`/LIB ${slibdir}
- 
- installslib-nolns: LIB
--	${MKINSTALLDIRS} ${slibdir}
-+	${MKINSTALLDIRS} $(DESTDIR)${slibdir}
- 	for file in `pwd`/LIB/*.lib; do \
--	  ${INSTALL_DATA}  $$file ${slibdir}; \
-+	  ${INSTALL_DATA}  $$file $(DESTDIR)${slibdir}; \
- 	done
--	${MKINSTALLDIRS} ${slibdir}/gftables
-+	${MKINSTALLDIRS} $(DESTDIR)${slibdir}/gftables
- 	for file in `pwd`/LIB/gftables/*; do \
--	  ${INSTALL_DATA}  $$file ${slibdir}/gftables/; \
-+	  ${INSTALL_DATA}  $$file $(DESTDIR)${slibdir}; \
- 	done
- 
--install-libsingular: libsingular installslib-nolns
--	${MKINSTALLDIRS} ${includedir}/singular
-+install-libsingular: libsingular
-+	${MKINSTALLDIRS} $(DESTDIR)${includedir}/singular
- 	for file in *.$(SO_SUFFIX); do \
--	  ${INSTALL_PROGRAM}  $$file ${libdir}; \
-+	  ${INSTALL_PROGRAM}  $$file $(DESTDIR)${libdir}; \
- 	done
--	${INSTALL_PROGRAM} libsingular.h ${includedir}
-+	${INSTALL_PROGRAM} libsingular.h $(DESTDIR)${includedir}
- 	for file in subexpr.h tok.h grammar.h ipid.h lists.h ipshell.h attrib.h silink.h table.h; do \
--	sed -e "s:<kernel/:<singular/:" < $$file |sed -e "s:<Singular/:<singular/:"|sed -e "s:<omalloc/:<:"|sed -e "s:<factory/:<:" >${includedir}/singular/$$file ;\
-+	sed -e "s:<kernel/:<singular/:" < $$file |sed -e "s:<Singular/:<singular/:"|sed -e "s:<omalloc/:<:"|sed -e "s:<factory/:<:" >$(DESTDIR)${includedir}/singular/$$file ;\
- 	done
- 
- uninstall: uninstallbin
-@@ -664,24 +664,23 @@ LIB/all.lib:	LIB/all.lib.tmpl
- 
- install-bindist: $(HEADERS) $(SOURCES) Makefile depend
- 	echo "#define MAKE_DISTRIBUTION	" > distrib.h
--	sleep 1
--	${MAKE} ${SING_EXEC} ESingular TSingular libparse ${RUN_SINGULARS}
--	${MKINSTALLDIRS} ${install_bindir} ${install_bindir_mod}
--	${INSTALL_PROGRAM} ${SING_EXEC} ${install_bindir}/Singular
--	-${INSTALL_PROGRAM} *.so ${install_bindir}
--	-${INSTALL_PROGRAM} MOD/*.so ${install_bindir}/MOD
--	${INSTALL_PROGRAM} -s  libparse ${RUN_SINGULARS} ESingular TSingular ${install_bindir}
--	${INSTALL_PROGRAM} surfex ${install_bindir}
-+	# sleep 1
-+	${MAKE} ${SING_EXEC} ESingular TSingular libparse $(DESTDIR)${RUN_SINGULARS}
-+	${MKINSTALLDIRS} $(DESTDIR)${install_bindir} $(DESTDIR)${install_bindir_mod}
-+	${INSTALL_PROGRAM} ${SING_EXEC} $(DESTDIR)${install_bindir}/Singular
-+	-${INSTALL_PROGRAM} *.so $(DESTDIR)${install_bindir}
-+	${INSTALL_PROGRAM} -s  libparse ${RUN_SINGULARS} ESingular TSingular $(DESTDIR)${install_bindir}
-+	${INSTALL_PROGRAM} surfex $(DESTDIR)${install_bindir}
- 	echo "#undef MAKE_DISTRIBUTION " > distrib.h
- 
- install-sharedist: ${SLIBS_FILES} LIB/gftables
--	${MKINSTALLDIRS} ${install_slibdir}
--	cp ${SLIBS_FILES} ${install_slibdir}
--	${MKINSTALLDIRS} ${install_slibdir}/gftables
--	cp ${GFTABLES} ${install_slibdir}/gftables
--	${MKINSTALLDIRS} ${install_slibdir}/surfex
--	cp LIB/surfex/surfex.jar ${install_slibdir}/surfex
--	chmod -R +rX ${install_slibdir}/*
-+	${MKINSTALLDIRS} $(DESTDIR)${install_slibdir}
-+	cp ${SLIBS_FILES} $(DESTDIR)${install_slibdir}
-+	${MKINSTALLDIRS} $(DESTDIR)${install_slibdir}/gftables
-+	cp ${GFTABLES} $(DESTDIR)${install_slibdir}/gftables
-+	${MKINSTALLDIRS} $(DESTDIR)${install_slibdir}/surfex
-+	cp LIB/surfex/surfex.jar $(DESTDIR)${install_slibdir}/surfex
-+	chmod -R +rX $(DESTDIR)${install_slibdir}/*
- 
- tar:
- 	tar cf Singular-${SINGULAR_VERSION}-src.tar ${DISTFILES}
-@@ -779,8 +778,8 @@ mpsr_Tok.og: iparith.inc mpsr_Tok.cc
- 	$(CXXG) ${CXXFLAGSG} ${CPPFLAGS} ${CXXTEMPLFLAGSG} ${DEFSG} -c mpsr_Tok.cc -o mpsr_Tok.og
- 
- installg: Singularg
--	${MKINSTALLDIRS} ${bindir}
--	${INSTALL_PROGRAM} Singularg ${bindir}	
-+	${MKINSTALLDIRS} $(DESTDIR)${bindir}
-+	${INSTALL_PROGRAM} Singularg $(DESTDIR)${bindir}
- 
- ESingularg: mod2.h feOpt.cc version.h emacs.cc \
-            feOptES.inc
-@@ -859,8 +858,8 @@ mpsr_Tok.op: iparith.inc mpsr_Tok.cc
- 	$(CXXP) ${CXXFLAGSP} ${CPPFLAGS} ${CXXTEMPLFLAGSP} ${DEFSP} -c mpsr_Tok.cc -o mpsr_Tok.op
- 
- installp: Singularp
--	${MKINSTALLDIRS} ${bindir}
--	${INSTALL_PROGRAM} Singularp ${bindir}	
-+	${MKINSTALLDIRS} $(DESTDIR)${bindir}
-+	${INSTALL_PROGRAM} Singularp $(DESTDIR)${bindir}
- 
- ##
- ## dependencies
-diff --git a/factory/GNUmakefile.in b/factory/GNUmakefile.in
-index d20b6a2..43f11e9 100644
---- a/factory/GNUmakefile.in
-+++ b/factory/GNUmakefile.in
-@@ -535,19 +535,20 @@ install_all:    install libsingcf_p.a
- install-nolns: install
- 
- installcf:	cf
--		$(MKINSTALLDIRS) $(libdir)
--		$(MKINSTALLDIRS) $(includedir)
--		$(INSTALL_DATA) $(libfactory) $(libdir)/$(libfactory)
--		-$(INSTALL_DATA) libsingcf_g.a $(libdir)/libsingcf_g.a
--		-$(INSTALL_DATA) libsingcf_p.a $(libdir)/libsingcf_p.a
--		$(INSTALL_DATA) factory.h $(includedir)/factory.h
--		$(INSTALL_DATA) cf_gmp.h $(includedir)/cf_gmp.h
--		$(INSTALL_DATA) factoryconf.h $(includedir)/factoryconf.h
-+		$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
-+		$(MKINSTALLDIRS) $(DESTDIR)$(includedir)
-+		$(MKINSTALLDIRS) $(DESTDIR)$(templatedir)
-+		$(INSTALL_DATA) $(libfactory) $(DESTDIR)$(libdir)/$(libfactory)
-+		-$(INSTALL_DATA) libsingcf_g.a $(DESTDIR)$(libdir)/libsingcf_g.a
-+		-$(INSTALL_DATA) libsingcf_p.a $(DESTDIR)$(libdir)/libsingcf_p.a
-+		$(INSTALL_DATA) factory.h $(DESTDIR)$(includedir)/factory.h
-+		$(INSTALL_DATA) cf_gmp.h $(DESTDIR)$(includedir)/cf_gmp.h
-+		$(INSTALL_DATA) factoryconf.h $(DESTDIR)$(includedir)/factoryconf.h
- 		for file in $(templateincl); do \
--		  $(INSTALL_DATA) $(srcdir)/templates/$$file $(templatedir)/$$file; \
-+		  $(INSTALL_DATA) $(srcdir)/templates/$$file $(DESTDIR)$(templatedir)/$$file; \
- 		done
- # we run `ranlib' another time for SUN machines
--		$(RANLIB) $(libdir)/$(libfactory)
-+		$(RANLIB) $(DESTDIR)$(libdir)/$(libfactory)
- 
- installmem:	mem
- 		$(MKINSTALLDIRS) $(libdir)
-diff --git a/kernel/Makefile.in b/kernel/Makefile.in
-index adc9cd9..6f58083 100644
---- a/kernel/Makefile.in
-+++ b/kernel/Makefile.in
-@@ -48,7 +48,7 @@ PIPE		= @PIPE@
- CFLAGS		= @CFLAGS@ ${PIPE} 
- CXXFLAGS	= @CXXFLAGS@ ${PIPE} 
- CXXTEMPLFLAGS	= @CXXTEMPLFLAGS@
--CPPFLAGS	= -I${srcdir} -I.. -I at prefix@  @CPPFLAGS@ 
-+CPPFLAGS	= -I${srcdir} -I.. -I at prefix@  @CPPFLAGS@
- DEFS		= -DNDEBUG -DOM_NDEBUG -D at SING_UNAME@ @DEFS@
- LDFLAGS		= @LDFLAGS@
- LD_DYN_FLAGS	= @LD_DYN_FLAGS@
-@@ -236,7 +236,7 @@ libkernel.a: ${OBJS}
- 	-rm -f libkernel.a
- 	ar cr $@ $^
- 
--p_Procs_Lib.o: p_Procs_Lib.inc
-+p_Procs_Lib.o: p_Procs_Dynamic.inc
- 
- # Hmm compiling with -fomit-frame-pointer resulted in access violation
- # under cygwin
-@@ -253,12 +253,12 @@ p_Procs_Dynamic.o p_Procs_Lib.o p_Procs_Dynamic.og p_Procs_Lib.og\
- p_Procs_Dynamic.inc p_Procs_Lib.inc: p_Procs_Dynamic.h
- 
- # here is how p_Procs_[Static|Dynamic].inc is generated
--p_Procs_Static.inc: p_Procs_Generate.cc p_Procs_Impl.h mod2.h
-+p_Procs_Static.inc: p_Procs_Generate.cc p_Procs_Impl.h |mod2.h
- 	$(CXX) $(CPPFLAGS) -g -Dp_Procs_Static p_Procs_Generate.cc -o p_Procs_Static
- 	./p_Procs_Static > p_Procs_Static.xx && mv p_Procs_Static.xx p_Procs_Static.inc
- 	-rm -f p_Procs_Static p_Procs_Static.exe
- 
--p_Procs_Dynamic.inc: p_Procs_Generate.cc p_Procs_Impl.h mod2.h
-+p_Procs_Dynamic.inc: p_Procs_Generate.cc p_Procs_Impl.h |mod2.h
- 	$(CXX) $(CPPFLAGS) -g -Dp_Procs_Dynamic p_Procs_Generate.cc -o p_Procs_Dynamic
- 	./p_Procs_Dynamic > p_Procs_Dynamic.xx && mv p_Procs_Dynamic.xx p_Procs_Dynamic.inc
- 	-rm -f p_Procs_Dynamic p_Procs_Dynamic.exe
-@@ -272,9 +272,9 @@ p_Procs_%.so: p_Procs_Lib_%.dl_o
- install-nolns: install
- 
- install-libsingular: install
--	-${MKINSTALLDIRS} ${includedir}
--	-${MKINSTALLDIRS} ${includedir}/singular
--	-for file in *.h kInline.cc; do sed -e "s:<kernel/:<singular/:"< $$file | sed -e "s:<Singular/:<singular/:"|sed -e "s:<omalloc/:<:"|sed -e "s:<factory/:<:" > ${includedir}/singular/$$file; done
-+	${MKINSTALLDIRS} $(DESTDIR)${includedir}
-+	${MKINSTALLDIRS} $(DESTDIR)${includedir}/singular
-+	for file in *.h kInline.cc; do sed -e "s:<kernel/:<singular/:"< $$file | sed -e "s:<Singular/:<singular/:"|sed -e "s:<omalloc/:<:"|sed -e "s:<factory/:<:" > $(DESTDIR)${includedir}/singular/$$file; done
- 
- install: all installbin
- 
-@@ -290,12 +290,12 @@ endif
- 
- 
- installbin: ${DL_LIBS} ${DL_LIBSG} libkernel.a libkernel_g.a
--	${MKINSTALLDIRS} ${bindir}
-+	${MKINSTALLDIRS} $(DESTDIR)${bindir}
- 	- ranlib libkernel.a
- 	- ranlib libkernel_g.a
- ifeq (,${DL_LIBS})
- else
--	-${INSTALL_PROGRAM} ${DL_LIBS} ${bindir}
-+	${INSTALL_PROGRAM} ${DL_LIBS} $(DESTDIR)${bindir}
- ifeq (,${DL_LIBSG})
- else
- 	-for file in ${DL_LIBS} ${DL_LIBSG}; do ${INSTALL_PROGRAM} $$file ../Singular; done
-@@ -307,7 +307,7 @@ install-bindist: ${DL_LIBS} libkernel.a
- 	${MKINSTALLDIRS} ${bindir}
- ifeq (,${DL_LIBS})
- else
--	-${INSTALL_PROGRAM} ${DL_LIBS} ${bindir}
-+	${INSTALL_PROGRAM} ${DL_LIBS} $(DESTDIR)${bindir}
- endif
- 
- ##
-diff --git a/libfac/Makefile.in b/libfac/Makefile.in
-index c2b38eb..1f2953f 100644
---- a/libfac/Makefile.in
-+++ b/libfac/Makefile.in
-@@ -146,13 +146,13 @@ libsingfac_p.a:	$(PROFOBJ)
- install-nolns: install
- 
- install install-libsingular:	all
--	${MKINSTALLDIRS} ${includedir}
--	${MKINSTALLDIRS} ${libdir}
--	${INSTALL_DATA} ${LIBFACINCLUDE} ${includedir}
--	${INSTALL_DATA} ${TARGETNAME}.a ${libdir}
--	-${INSTALL_DATA} libsingfac_g.a ${libdir}
--	$(RANLIB) ${libdir}/${TARGETNAME}.a
--	-$(RANLIB) ${libdir}/libsingfac_g.a
-+	${MKINSTALLDIRS} $(DESTDIR)${includedir}
-+	${MKINSTALLDIRS} $(DESTDIR)${libdir}
-+	${INSTALL_DATA} ${LIBFACINCLUDE} $(DESTDIR)${includedir}
-+	${INSTALL_DATA} ${TARGETNAME}.a $(DESTDIR)${libdir}
-+	-${INSTALL_DATA} libsingfac_g.a $(DESTDIR)${libdir}
-+	$(RANLIB) $(DESTDIR)${libdir}/${TARGETNAME}.a
-+	-$(RANLIB) $(DESTDIR)${libdir}/libsingfac_g.a
- 
- install_all: install libsingfac_p.a
- 	-${INSTALL_DATA} libsingfac_p.a ${libdir}
-diff --git a/omalloc/Makefile.in b/omalloc/Makefile.in
-index 98a7e95..8661ca2 100644
---- a/omalloc/Makefile.in
-+++ b/omalloc/Makefile.in
-@@ -185,17 +185,17 @@ install-libsingular:
- 	$(INSTALL) omalloc.h $(includedir)/singular
- 
- install install-libsingular: all
--	$(MKINSTALLDIRS) $(libdir)
--	$(MKINSTALLDIRS) $(includedir)
--	$(INSTALL_DATA) libomalloc.a $(libdir)
--	$(RANLIB) $(libdir)/libomalloc.a
--	$(INSTALL_DATA) libomalloc_ndebug.a $(libdir)
--	$(RANLIB) $(libdir)/libomalloc_ndebug.a
--	$(INSTALL_DATA) omalloc.o $(libdir)
--	$(INSTALL_DATA) omalloc_debug.o $(libdir)
--	$(INSTALL_DATA) omalloc.h $(includedir)
--	$(INSTALL_DATA) omlimits.h $(includedir)
--	$(INSTALL_DATA) mylimits.h $(includedir)
-+	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
-+	$(MKINSTALLDIRS) $(DESTDIR)$(includedir)
-+	$(INSTALL_DATA) libomalloc.a $(DESTDIR)$(libdir)
-+	$(RANLIB) $(DESTDIR)$(libdir)/libomalloc.a
-+	$(INSTALL_DATA) libomalloc_ndebug.a $(DESTDIR)$(libdir)
-+	$(RANLIB) $(DESTDIR)$(libdir)/libomalloc_ndebug.a
-+	$(INSTALL_DATA) omalloc.o $(DESTDIR)$(libdir)
-+	$(INSTALL_DATA) omalloc_debug.o $(DESTDIR)$(libdir)
-+	$(INSTALL_DATA) omalloc.h $(DESTDIR)$(includedir)
-+	$(INSTALL_DATA) omlimits.h $(DESTDIR)$(includedir)
-+	$(INSTALL_DATA) mylimits.h $(DESTDIR)$(includedir)
- 
- install_all: install libomalloc_p.a
- 	$(INSTALL_DATA) libomalloc_p.a $(libdir)
diff --git a/debian/patches/0003-add-working-all-target-to-Makefile.in.patch b/debian/patches/0003-add-working-all-target-to-Makefile.in.patch
deleted file mode 100644
index 6763c7b..0000000
--- a/debian/patches/0003-add-working-all-target-to-Makefile.in.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From 3fb0860f213ea61eb9e6853cabb16d93a6d7296a Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Thu, 16 Feb 2012 11:07:25 +0100
-Subject: add working 'all' target to Makefile.in
-
-now 'make\ {all,install}' works as usual and expected
-
-Forwarded: not-needed
----
- Makefile.in | 14 +++++++++-----
- 1 file changed, 9 insertions(+), 5 deletions(-)
-
-diff --git a/Makefile.in b/Makefile.in
-index 0d6db8f..f2eaa65 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -24,8 +24,12 @@ GUNZIP		= @GUNZIP@
- 
- ##############################################################
- # default target
--${SINGULAR}:
--	${MAKE} install
-+all:
-+	@ for SUBDIR in ${BUILD1_SUBDIRS}; \
-+	do \
-+	  echo ${MAKE} all in $${SUBDIR}; \
-+	  ${MAKE} -C $$SUBDIR || exit 1; \
-+	done
- 
- ##############################################################
- # general targets
-@@ -34,7 +38,7 @@ ${SINGULAR}:
- 
- TEXINFO_TEX_FILES = epsf.tex texinfo.tex txi-cs.tex txi-de.tex txi-no.tex
- TEXINFO_TEX_DIR = Texinfo/doc
--all:
-+original_all:
- 	echo For everybody who did not read the README: use make install
- 	exit 1
- 
-@@ -42,7 +46,7 @@ install install_all:
- 	@ for SUBDIR in ${BUILD1_SUBDIRS}; \
- 	do \
- 	  echo ${MAKE} $@ in $${SUBDIR}; \
--	  (cd $${SUBDIR} && ${MAKE} $@ ) || exit 1;\
-+	  ${MAKE} -C $$SUBDIR $@ || exit 1 ;\
- 	  (if test "$${SUBDIR}" = Texinfo && test -d doc; then \
- 		for FILE in ${TEXINFO_TEX_FILES}; \
- 		do \
-@@ -62,7 +66,7 @@ install-nolns:
- 	@ for SUBDIR in ${BUILD1_SUBDIRS}; \
- 	do \
- 	  echo ${MAKE} $@ in $${SUBDIR}; \
--	  (cd $${SUBDIR} && ${MAKE} $@ )  || exit 1;\
-+	  ${MAKE} -C $$SUBDIR $@ ;\
- 	  (if test "$${SUBDIR}" = Texinfo && test -d doc; then \
- 	    for FILE in ${TEXINFO_TEX_FILES}; \
- 	    do \
diff --git a/debian/patches/0004-miscellaneous-Makefile.in-patches.patch b/debian/patches/0004-miscellaneous-Makefile.in-patches.patch
deleted file mode 100644
index 652401f..0000000
--- a/debian/patches/0004-miscellaneous-Makefile.in-patches.patch
+++ /dev/null
@@ -1,289 +0,0 @@
-From d214a720c0d0bbc9f76cc34086f520a3c6434d6d Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Thu, 16 Feb 2012 12:37:00 +0100
-Subject: miscellaneous Makefile.in patches
-
-     - fix flags (mostly search paths)
-     - repair default and install targets
-     - remove dependency on mod2.h in kernel. "make depend" works fine
-
-Forwarded: not-needed
----
- Singular/Makefile.in   | 44 +++++++++++++++++++++++++-------------------
- emacs/Makefile.in      |  5 ++++-
- factory/GNUmakefile.in | 18 ++++++++++--------
- kernel/Makefile.in     | 10 +++++-----
- omalloc/Makefile.in    |  6 +++---
- 5 files changed, 47 insertions(+), 36 deletions(-)
-
-diff --git a/Singular/Makefile.in b/Singular/Makefile.in
-index 807d786..6b94ca2 100644
---- a/Singular/Makefile.in
-+++ b/Singular/Makefile.in
-@@ -93,7 +93,7 @@ endif
- DEFS		= -DNDEBUG -DOM_NDEBUG -D at SING_UNAME@ @DEFS@
- LDFLAGS2	= @LDFLAGS@
- ifneq ($(SINGUNAME),ix86-Win)
--LDFLAGS		= -L at prefix@/kernel -L../kernel -lkernel @LDFLAGS@ 
-+LDFLAGS		= -L at prefix@/kernel -L../kernel -L../omalloc -L../libfac -L../factory -lkernel @LDFLAGS@
- LDFLAGSG	= -L at prefix@/kernel -L../kernel -lkernel_g @LD_DYN_FLAGS1@ @LDFLAGS@ 
- LDFLAGSP	= -L at prefix@/kernel -L../kernel -lkernel_p @LD_DYN_FLAGS1@ @LDFLAGS@ 
- else
-@@ -363,9 +363,9 @@ GFTABLES = $(wildcard LIB/gftables/[1-9]*)
- 	fi
- 
- .cc.o:	
--	${CXX} ${CXXFLAGS} ${CXXTEMPLFLAGS} ${CPPFLAGS} ${DEFS} -c $<
-+	${CXX} -fPIC ${CXXFLAGS} ${CXXTEMPLFLAGS} ${CPPFLAGS} ${DEFS} -c $<
- .c.o:
--	${CC} ${CFLAGS} ${CPPFLAGS} ${DEFS} -c $<
-+	${CC} -fPIC ${CFLAGS} ${CPPFLAGS} ${DEFS} -c $<
- 
- %.dl_o : %.cc
- 	${CXX} ${CXXFLAGS} ${CXXTEMPLFLAGS} ${CPPFLAGS} ${DEFS} ${SFLAGS} -c $< -o $@
-@@ -387,11 +387,13 @@ Singular${S_EXT}: mod2.h Makefile version.h $(WIN_LIBS) scanner.cc  ${OBJS} \
- 	  tesths.cc iparith.o mpsr_Tok.o claptmpl.o\
- 	  ${OBJS} ${LDFLAGS} ${LIBS} ../kernel/mmalloc.o 
- 
--libsingular: mod2.h Makefile version.h $(WIN_LIBS) scanner.cc  ${OBJS} \
--         iparith.o libparse.cc claptmpl.o mpsr_Tok.o $(DL_LIBS) 
-+libsingular: libsingular.${SO_SUFFIX}
-+
-+libsingular.${SO_SUFFIX}: version.h $(WIN_LIBS) scanner.cc  ${OBJS} \
-+         iparith.o libparse.cc claptmpl.o mpsr_Tok.o $(DL_LIBS) tesths.o
- 	$(LIBSINGULAR_LD) ${SLDFLAGS} ${LIBSINGULAR_FLAGS} -o libsingular.${SO_SUFFIX} \
--	iparith.o mpsr_Tok.o claptmpl.o \
--	${OBJS} -lkernel -L../kernel -L../factory -L../libfac -L${libdir} ${LIBSINGULAR_LIBS}
-+ 	tesths.o iparith.o mpsr_Tok.o claptmpl.o \
-+ 	${OBJS} -lkernel -L../kernel -L../factory -L../libfac -L../omalloc -L${libdir} ${LIBSINGULAR_LIBS}
- 
- libsingular.a: mod2.h Makefile version.h $(WIN_LIBS) scanner.cc  ${OBJS} \
-          iparith.o libparse.cc claptmpl.o mpsr_Tok.o
-@@ -427,13 +429,16 @@ iparith.inc: gentable.cc grammar.h tok.h table.h mod2.h
- 	 ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${CXXTEMPLFLAGS} ${DEFS} gentable.cc \
- 	     -o gentable1
- 	./gentable1
--	/bin/rm -f gentable1 gentable1.exe
-+	# /bin/rm -f gentable1 gentable1.exe
- 
- mpsr_Tok.inc: gentable2.cc grammar.h tok.h table.h mod2.h
- 	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${CXXTEMPLFLAGS} ${DEFS} gentable2.cc \
- 	     -o gentable2
- 	./gentable2
--	/bin/rm -f gentable2 gentable2.exe
-+	# /bin/rm -f gentable2 gentable2.exe
-+	#
-+	# FIXME: the above doesnt work.
-+	touch $@
- 
- 
- version.h: ${SOURCES} ${HEADERS} Makefile.in mod2.h.in \
-@@ -473,17 +478,17 @@ TSingular: mod2.h feOpt.cc version.h emacs.cc \
- feOpt.o: feOpt.inc feOptES.inc feOptTS.inc
- extra.o: feOpt.inc
- 
--feOpt.inc: feOpt.cc mod2.h
-+feOpt.inc: feOpt.cc |mod2.h
- 	$(CXX) $(CXXFLAGS) -DGENERATE_OPTION_INDEX ${CPPFLAGS} feOpt.cc -o feOpt
- 	./feOpt
- 	/bin/rm -f feOpt feOpt.exe
- 
--feOptES.inc: feOpt.cc mod2.h
-+feOptES.inc: feOpt.cc |mod2.h
- 	$(CXX) $(CXXFLAGS) -DGENERATE_OPTION_INDEX  -DESINGULAR -I../kernel feOpt.cc -o feOptES
- 	./feOptES
- 	rm -f feOptES feOptES.exe
- 
--feOptTS.inc: feOpt.cc mod2.h
-+feOptTS.inc: feOpt.cc |mod2.h
- 	$(CXX) $(CXXFLAGS) -DGENERATE_OPTION_INDEX  -DTSINGULAR -I../kernel feOpt.cc -o feOptTS
- 	./feOptTS
- 	rm -f feOptTS feOptTS.exe
-@@ -555,11 +560,11 @@ endif
- ##
- ## install targets
- ##
--install: all installbin installslib
-+install: all installbin installslib install-libsingular
- 
- install_all: install
- 
--install-nolns: all installbin-nolns installslib-nolns
-+install-ln: all installbin installslib-ln
- 
- installbin: ${SING_EXEC} libparse ESingular TSingular ${RUN_SINGULARS}
- 	${MKINSTALLDIRS} $(DESTDIR)${bindir} $(DESTDIR)${bindir_mod}
-@@ -568,7 +573,7 @@ installbin: ${SING_EXEC} libparse ESingular TSingular ${RUN_SINGULARS}
- 	  ${INSTALL_PROGRAM} $$file $(DESTDIR)${bindir}; \
- 	done
- 	-for file in MOD/*.so; do \
--	  ${INSTALL_PROGRAM} $$file ${bindir}/MOD; \
-+	  ${INSTALL_PROGRAM} $$file $(DESTDIR)${bindir}/MOD; \
- 	done
- 	${INSTALL_PROGRAM} libparse ${RUN_SINGULARS} $(DESTDIR)${bindir}
- 	${INSTALL_PROGRAM} ESingular TSingular $(DESTDIR)${bindir}
-@@ -584,7 +589,7 @@ installbin-nolns: ${SING_EXEC} libparse ESingular TSingular ${RUN_SINGULARS}
- 	  ${INSTALL_PROGRAM} $$file ${bindir}; \
- 	done
- 	-for file in MOD/*.so; do \
--	  ${INSTALL_PROGRAM} $$file ${bindir}/MOD; \
-+	  ${INSTALL_PROGRAM} $$file $(DESTDIR)${bindir}/MOD; \
- 	done
- 	${INSTALL_PROGRAM} libparse ${RUN_SINGULARS} $(DESTDIR)${bindir}
- 	${INSTALL_PROGRAM} ESingular TSingular ${DL_LIBS} $(DESTDIR)${bindir}
-@@ -592,10 +597,10 @@ installbin-nolns: ${SING_EXEC} libparse ESingular TSingular ${RUN_SINGULARS}
- 	rm -f $(DESTDIR)${bindir}/${SING_EXEC}${EXEC_EXT}
- 	${INSTALL_PROGRAM} ${SINGULAR} $(DESTDIR)${bindir}/Singular${EXEC_EXT};
- 
--installslib: LIB
-+installslib-ln: LIB
- 	test -r ${slibdir} || ${LN_S} `pwd`/LIB ${slibdir}
- 
--installslib-nolns: LIB
-+installslib: LIB
- 	${MKINSTALLDIRS} $(DESTDIR)${slibdir}
- 	for file in `pwd`/LIB/*.lib; do \
- 	  ${INSTALL_DATA}  $$file $(DESTDIR)${slibdir}; \
-@@ -630,11 +635,12 @@ mostlyclean:
- 	-rm -f Singular Singular-static Singularg Singularp libparse feOpt*.inc
- 	-rm -f *.o *.og core *.op *.so* *.dl_o*
- 	-rm -rf MOD
--	-rm -f ESingular* TSingular*
-+	-rm -f ESingular* TSingular* libsingular
- 
- clean: mostlyclean
- 	-rm -f *.bak *.d *.dd depend 
- 	-rm -f ${slibdir}
-+	-rm -f gentable1 gentable2
- 
- distclean: clean
- 	-rm -f iparith.inc mpsr_Tok.inc stamp.h 
-diff --git a/emacs/Makefile.in b/emacs/Makefile.in
-index 86ba445..47c57e1 100644
---- a/emacs/Makefile.in
-+++ b/emacs/Makefile.in
-@@ -42,9 +42,12 @@ lib-cmpl.el: ${prefix}/Singular/Makefile lib.pl
- 	(cd ${prefix}/Singular;${MAKE} --no-print-directory -s -f Makefile echoLIBS) > lib-temp
- 	${PERL} lib.pl -s ${singulardir} `cat lib-temp` > lib-cmpl.el
- 
--clean mostlyclean distclean:
-+clean mostlyclean:
- 	rm -f cmd-cmpl.el hlp-cmpl.el lib-cmpl.el ex-cmpl.el
- 
-+distclean: mostlyclean
-+	rm -f Makefile
-+
- install-sharedist: all
- 	${MKINSTALLDIRS} ${emacsdir}
- 	${INSTALL_DATA} cmd-cmpl.el ${emacsdir}
-diff --git a/factory/GNUmakefile.in b/factory/GNUmakefile.in
-index 43f11e9..cb28207 100644
---- a/factory/GNUmakefile.in
-+++ b/factory/GNUmakefile.in
-@@ -386,24 +386,24 @@ distfiles :=	\
- #
- 
- # how to create library objects
--%.o: %.cc config.h factoryconf.h
-+%.o: %.cc config.h |factoryconf.h
- 	$(CXX) -c $< $(LIBCXXFLAGS) -o $@
- %.o: %.c config.h
- 	$(CC) -c $< $(LIBCFLAGS) -o $@
- # the debug version:
--%.og: %.cc config.h factoryconf.h
-+%.og: %.cc config.h |factoryconf.h
- 	$(CXX) -g -c $< $(LIBCGGFLAGS) -o $@
- # the profiling version:
--%.op: %.cc config.h factoryconf.h
-+%.op: %.cc config.h |factoryconf.h
- 	$(CXX) -O -pg -c $< $(LIBCGGFLAGS) -o $@
- 
- # how to create dependency files.  To avoid broken dependency files
- # (which in turn break this GNUmakefile) we first generate them in
- # a temporary file which we then move to the destination file.
--%.dtmp: %.cc factoryconf.h config.h
-+%.dtmp: %.cc |factoryconf.h config.h
- 	echo $*.d "\\" > $@
- 	$(CXX) -MM $< $(DEPCXXFLAGS) >> $@
--%.dtmp: %.c factoryconf.h config.h
-+%.dtmp: %.c |factoryconf.h config.h
- 	echo $*.d "\\" > $@
- 	$(CXX) -MM $< $(DEPCXXFLAGS) >> $@
- %.dtmp: %.template
-@@ -669,8 +669,10 @@ $(srcdir)/configure: configure.in
- # seems gmake needs at least a trivial command.  otherwise all
- # files which depend on config.h will be remade even if congig.h
- # did not change.
--config.h:	stamp-h
--		@:
-+#
-+# WTF?
-+#config.h:	stamp-h
-+#		@:
- 
- stamp-h:	config.h.in config.status
- 		CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status
-@@ -683,7 +685,7 @@ config.status:	configure
- 		./config.status --recheck
- 
- # create cf_gmp.h
--cf_gmp.h: GNUmakefile gen_cf_gmp.template
-+cf_gmp.h: gen_cf_gmp.template
- 	echo "#!/bin/sh" >gen_cf_gmp.sh 
- 	echo "GMP_H_T=\"`$(CXX) $(LIBCXXFLAGS) -M gen_cf_gmp.cc|grep gmp.h` \"" >>gen_cf_gmp.sh 
- 	cat gen_cf_gmp.template >>gen_cf_gmp.sh
-diff --git a/kernel/Makefile.in b/kernel/Makefile.in
-index 6f58083..78d2b07 100644
---- a/kernel/Makefile.in
-+++ b/kernel/Makefile.in
-@@ -253,12 +253,12 @@ p_Procs_Dynamic.o p_Procs_Lib.o p_Procs_Dynamic.og p_Procs_Lib.og\
- p_Procs_Dynamic.inc p_Procs_Lib.inc: p_Procs_Dynamic.h
- 
- # here is how p_Procs_[Static|Dynamic].inc is generated
--p_Procs_Static.inc: p_Procs_Generate.cc p_Procs_Impl.h |mod2.h
-+p_Procs_Static.inc: p_Procs_Generate.cc p_Procs_Impl.h
- 	$(CXX) $(CPPFLAGS) -g -Dp_Procs_Static p_Procs_Generate.cc -o p_Procs_Static
- 	./p_Procs_Static > p_Procs_Static.xx && mv p_Procs_Static.xx p_Procs_Static.inc
- 	-rm -f p_Procs_Static p_Procs_Static.exe
- 
--p_Procs_Dynamic.inc: p_Procs_Generate.cc p_Procs_Impl.h |mod2.h
-+p_Procs_Dynamic.inc: p_Procs_Generate.cc p_Procs_Impl.h
- 	$(CXX) $(CPPFLAGS) -g -Dp_Procs_Dynamic p_Procs_Generate.cc -o p_Procs_Dynamic
- 	./p_Procs_Dynamic > p_Procs_Dynamic.xx && mv p_Procs_Dynamic.xx p_Procs_Dynamic.inc
- 	-rm -f p_Procs_Dynamic p_Procs_Dynamic.exe
-@@ -439,15 +439,15 @@ libkernel_p.a: ${OBJP} ${DL_LIBSP} ${OBJSP2}
- ## dependencies
- ##
- 
--%.dd: %.cc mod2.h 
-+%.dd: %.cc
- 	echo $(@:.dd=.og) $(@:.dd=.op) $(@:.dd=.dl_o) $(@:.dd=.dl_og) $(@:.dd=.dl_op)" " \\ > $@
- 	$(CXXM) -DGENTABLE ${CPPFLAGS} ${DEFSG} $< >> $@
- 
--%.d: %.c mod2.h 
-+%.d: %.c
- 	echo $(@:.d=.og) $(@:.d=.op) " " \\ > $@
- 	$(CCM) ${CPPFLAGS} ${DEFSG} $< >> $@
- 
--depend:   $(CXXSOURCES:.cc=.dd) $(ESOURCES:.cc=.dd) $(CSOURCES:.c=.d) mod2.h
-+depend:   $(CXXSOURCES:.cc=.dd) $(ESOURCES:.cc=.dd) $(CSOURCES:.c=.d)
- 	cat *.d *.dd >depend
- 
- ifeq (depend,$(wildcard depend))
-diff --git a/omalloc/Makefile.in b/omalloc/Makefile.in
-index 8661ca2..1dd2e36 100644
---- a/omalloc/Makefile.in
-+++ b/omalloc/Makefile.in
-@@ -180,9 +180,9 @@ configure: configure.in
- ##
- install-nolns: install
- 
--install-libsingular:
--	$(MKINSTALLDIRS) $(includedir)/singular
--	$(INSTALL) omalloc.h $(includedir)/singular
-+#install-libsingular:
-+#	$(MKINSTALLDIRS) $(includedir)/singular
-+#	$(INSTALL) omalloc.h $(includedir)/singular
- 
- install install-libsingular: all
- 	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
diff --git a/debian/patches/0005-assert-needs-to-be-defined-after-include-assert.h.patch b/debian/patches/0005-assert-needs-to-be-defined-after-include-assert.h.patch
deleted file mode 100644
index d5a21fc..0000000
--- a/debian/patches/0005-assert-needs-to-be-defined-after-include-assert.h.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 0fd6fa905ac8a1e261a5075ca785666746ae2067 Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Thu, 16 Feb 2012 11:23:11 +0100
-Subject: =?UTF-8?q?assert=20needs=20to=20be=20defined=20after=20#include?=
- =?UTF-8?q?=20"assert.h",=0Aalso=20if=20-Ifactory=20is=20used.?=
-
-Forwarded: not-needed
----
- factory/assert.h | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/factory/assert.h b/factory/assert.h
-index 3dd036b..d2933a1 100644
---- a/factory/assert.h
-+++ b/factory/assert.h
-@@ -128,3 +128,9 @@ extern "C" {
- #define PVIRT_CHARCC(msg) = 0
- #endif /* NOASSERT */
- /* }}} */
-+
-+
-+//assert is expected to be available after '#include "assert.h"'
-+#ifndef assert
-+# define assert(a)
-+#endif
diff --git a/debian/patches/0006-keep-mod2.h-in-Singular.patch b/debian/patches/0006-keep-mod2.h-in-Singular.patch
deleted file mode 100644
index ca24646..0000000
--- a/debian/patches/0006-keep-mod2.h-in-Singular.patch
+++ /dev/null
@@ -1,6983 +0,0 @@
-From d4af17eb7020d07867906e431b348dca13c57c63 Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Wed, 22 Feb 2012 11:18:38 +0100
-Subject: keep mod2.h in Singular/
-
-don't copy mod2.h generated in Singular/ to kernel/
-to avoid time stamp issues
-
-Forwarded: not-needed
----
- Singular/Minor.cc            |    2 +-
- Singular/MinorInterface.cc   |    2 +-
- Singular/MinorProcessor.cc   |    2 +-
- Singular/attrib.cc           |    2 +-
- Singular/calcSVD.cc          |    2 +-
- Singular/claptmpl.cc         |    2 +-
- Singular/cntrlc.cc           |    2 +-
- Singular/configure           |    1 -
- Singular/configure.in        |    1 -
- Singular/eigenval_ip.cc      |    2 +-
- Singular/emacs.cc            |    2 +-
- Singular/extra.cc            |    2 +-
- Singular/feOpt.cc            |    2 +-
- Singular/fehelp.cc           |    2 +-
- Singular/fglm.cc             |    2 +-
- Singular/gms.cc              |    2 +-
- Singular/grammar.cc          |    2 +-
- Singular/grammar.y           |    2 +-
- Singular/interpolation.cc    |    2 +-
- Singular/iparith.cc          |    2 +-
- Singular/ipassign.cc         |    2 +-
- Singular/ipconv.cc           |    2 +-
- Singular/ipid.cc             |    2 +-
- Singular/iplib.cc            |    2 +-
- Singular/ipprint.cc          |    2 +-
- Singular/ipshell.cc          |    2 +-
- Singular/janet.cc            |    2 +-
- Singular/libparse.l          |    2 +-
- Singular/lists.cc            |    2 +-
- Singular/maps_ip.cc          |    2 +-
- Singular/minpoly.cc          |    2 +-
- Singular/misc_ip.cc          |    2 +-
- Singular/mpsr_Error.cc       |    2 +-
- Singular/mpsr_Get.cc         |    2 +-
- Singular/mpsr_GetMisc.cc     |    2 +-
- Singular/mpsr_GetPoly.cc     |    2 +-
- Singular/mpsr_Put.cc         |    2 +-
- Singular/mpsr_PutPoly.cc     |    2 +-
- Singular/mpsr_Tok.cc         |    2 +-
- Singular/mpsr_sl.cc          |    2 +-
- Singular/ndbm.cc             |    2 +-
- Singular/pcv.cc              |    2 +-
- Singular/pipeLink.cc         |    2 +-
- Singular/scanner.cc          |    2 +-
- Singular/scanner.l           |    2 +-
- Singular/sdb.cc              |    2 +-
- Singular/silink.cc           |    2 +-
- Singular/sing_dbm.cc         |    2 +-
- Singular/sing_win.cc         |    2 +-
- Singular/slInit_Dynamic.cc   |    2 +-
- Singular/slInit_Static.cc    |    2 +-
- Singular/ssiLink.cc          |    2 +-
- Singular/subexpr.cc          |    2 +-
- Singular/tesths.cc           |    2 +-
- Singular/walk.cc             |    2 +-
- Singular/walk_ip.cc          |    2 +-
- Singular/wrapper.cc          |    2 +-
- kernel/F4.cc                 |    2 +-
- kernel/F5cData.cc            |    2 +-
- kernel/F5cLists.cc           |    2 +-
- kernel/GMPrat.cc             |    2 +-
- kernel/Number.h              |    2 +-
- kernel/Poly.h                |    2 +-
- kernel/PowerSeries.h         |    2 +-
- kernel/clapconv.cc           |    2 +-
- kernel/clapsing.cc           |    2 +-
- kernel/dError.c              |    2 +-
- kernel/digitech.cc           |    2 +-
- kernel/digitech.h            |    2 +-
- kernel/eigenval.cc           |    2 +-
- kernel/f5c.cc                |    2 +-
- kernel/f5data.cc             |    2 +-
- kernel/f5gb.cc               |    2 +-
- kernel/f5lists.cc            |    2 +-
- kernel/fast_maps.cc          |    2 +-
- kernel/fast_mult.cc          |    2 +-
- kernel/fast_mult.h           |    2 +-
- kernel/feResource.cc         |    2 +-
- kernel/febase.cc             |    2 +-
- kernel/fegetopt.c            |    2 +-
- kernel/feread.cc             |    2 +-
- kernel/fereadl.c             |    2 +-
- kernel/ffields.cc            |    2 +-
- kernel/fglmcomb.cc           |    2 +-
- kernel/fglmgauss.cc          |    2 +-
- kernel/fglmhom.cc            |    2 +-
- kernel/fglmvec.cc            |    2 +-
- kernel/fglmzero.cc           |    2 +-
- kernel/gfan.cc               | 4512 ++++++++++++++++++++++++++++++++++++++++++
- kernel/gnumpc.cc             |    2 +-
- kernel/gnumpfl.cc            |    2 +-
- kernel/gr_kstd2.cc           |    2 +-
- kernel/gring.cc              |    2 +-
- kernel/hdegree.cc            |    2 +-
- kernel/hilb.cc               |    2 +-
- kernel/hutil.cc              |    2 +-
- kernel/ideals.cc             |    2 +-
- kernel/int64vec.cc           |    2 +-
- kernel/intvec.cc             |    2 +-
- kernel/kbuckets.cc           |    2 +-
- kernel/khstd.cc              |    2 +-
- kernel/kspoly.cc             |    2 +-
- kernel/kstd1.cc              |    2 +-
- kernel/kstd2.cc              |    2 +-
- kernel/kstdfac.cc            |    2 +-
- kernel/kutil.cc              |    2 +-
- kernel/linearAlgebra.cc      |    2 +-
- kernel/longalg.cc            |    2 +-
- kernel/longrat.cc            |    2 +-
- kernel/longrat0.cc           |    2 +-
- kernel/longtrans.cc          |    2 +-
- kernel/lplist.cc             |    2 +-
- kernel/maps.cc               |    2 +-
- kernel/matpol.cc             |    2 +-
- kernel/misc.cc               |    2 +-
- kernel/mmalloc.cc            |    2 +-
- kernel/mmstd.c               |    2 +-
- kernel/mod_raw.cc            |    2 +-
- kernel/modulop.cc            |    2 +-
- kernel/mpr_base.cc           |    2 +-
- kernel/mpr_complex.cc        |    2 +-
- kernel/mpr_inout.cc          |    2 +-
- kernel/mpr_numeric.cc        |    2 +-
- kernel/multicnt.cc           |    2 +-
- kernel/ncSACache.cc          |    2 +-
- kernel/ncSAFormula.cc        |    2 +-
- kernel/ncSAMult.cc           |    2 +-
- kernel/npolygon.cc           |    2 +-
- kernel/numbers.cc            |    2 +-
- kernel/pDebug.cc             |    2 +-
- kernel/pInline0.cc           |    2 +-
- kernel/pInline1.cc           |    2 +-
- kernel/pInline2.cc           |    2 +-
- kernel/pShallowCopyDelete.cc |    2 +-
- kernel/p_Mult_q.cc           |    2 +-
- kernel/p_Mult_q.h            |    2 +-
- kernel/p_Procs_Dynamic.cc    |    2 +-
- kernel/p_Procs_Generate.cc   |    2 +-
- kernel/p_Procs_Lib.cc        |    2 +-
- kernel/p_Procs_Static.cc     |    2 +-
- kernel/p_polys.cc            |    2 +-
- kernel/page.c                |    2 +-
- kernel/polys-impl.cc         |    2 +-
- kernel/polys.cc              |    2 +-
- kernel/polys0.cc             |    2 +-
- kernel/polys1.cc             |    2 +-
- kernel/prCopy.cc             |    2 +-
- kernel/ratgring.cc           |    2 +-
- kernel/ring.cc               |    2 +-
- kernel/ringgb.cc             |    2 +-
- kernel/ringgb.h              |    2 +-
- kernel/rintegers.cc          |    2 +-
- kernel/rmodulo2m.cc          |    2 +-
- kernel/rmodulon.cc           |    2 +-
- kernel/sbuckets.cc           |    2 +-
- kernel/sca.cc                |    2 +-
- kernel/semic.cc              |    2 +-
- kernel/shiftgb.cc            |    2 +-
- kernel/shortfl.cc            |    2 +-
- kernel/sparsmat.cc           |    2 +-
- kernel/spectrum.cc           |    2 +-
- kernel/splist.cc             |    2 +-
- kernel/summator.cc           |    2 +-
- kernel/syz.cc                |    2 +-
- kernel/syz0.cc               |    2 +-
- kernel/syz1.cc               |    2 +-
- kernel/syz2.cc               |    2 +-
- kernel/syz3.cc               |    2 +-
- kernel/tgb.cc                |    2 +-
- kernel/tgbgauss.cc           |    2 +-
- kernel/tgbgauss.h            |    2 +-
- kernel/timer.cc              |    2 +-
- kernel/tmult.cc              |    2 +-
- kernel/units.cc              |    2 +-
- kernel/walkMain.cc           |    2 +-
- kernel/walkProc.cc           |    2 +-
- kernel/walkSupport.cc        |    2 +-
- kernel/weight.cc             |    2 +-
- kernel/weight0.c             |    2 +-
- 179 files changed, 4688 insertions(+), 178 deletions(-)
- create mode 100644 kernel/gfan.cc
-
-diff --git a/Singular/Minor.cc b/Singular/Minor.cc
-index 402d7e6..4e358c5 100644
---- a/Singular/Minor.cc
-+++ b/Singular/Minor.cc
-@@ -1,4 +1,4 @@
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/polys.h>
- #include <Minor.h>
-diff --git a/Singular/MinorInterface.cc b/Singular/MinorInterface.cc
-index c79f694..508f979 100644
---- a/Singular/MinorInterface.cc
-+++ b/Singular/MinorInterface.cc
-@@ -1,4 +1,4 @@
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/polys.h>
- #include <kernel/ideals.h>
-diff --git a/Singular/MinorProcessor.cc b/Singular/MinorProcessor.cc
-index 1c08156..6ff81aa 100644
---- a/Singular/MinorProcessor.cc
-+++ b/Singular/MinorProcessor.cc
-@@ -1,4 +1,4 @@
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/polys.h>
- #include <MinorProcessor.h>
-diff --git a/Singular/attrib.cc b/Singular/attrib.cc
-index 1f016ef..bbef31e 100644
---- a/Singular/attrib.cc
-+++ b/Singular/attrib.cc
-@@ -12,7 +12,7 @@
- #include <ctype.h>
- #include <unistd.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/omalloc.h>
- #include <kernel/options.h>
- #include <Singular/tok.h>
-diff --git a/Singular/calcSVD.cc b/Singular/calcSVD.cc
-index bf80b3c..1e889dd 100644
---- a/Singular/calcSVD.cc
-+++ b/Singular/calcSVD.cc
-@@ -1,5 +1,5 @@
- #include <stdio.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_SVD
- 
-diff --git a/Singular/claptmpl.cc b/Singular/claptmpl.cc
-index 0fa6109..512b353 100644
---- a/Singular/claptmpl.cc
-+++ b/Singular/claptmpl.cc
-@@ -6,7 +6,7 @@
- * ABSTRACT - instantiation of all templates
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- //#include <vector>
- //using namespace std;
- #ifdef HAVE_FACTORY
-diff --git a/Singular/cntrlc.cc b/Singular/cntrlc.cc
-index 80552b5..4a37ef5 100644
---- a/Singular/cntrlc.cc
-+++ b/Singular/cntrlc.cc
-@@ -16,7 +16,7 @@
- #include <signal.h>
- #include <sys/types.h>
- #include <sys/wait.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/omalloc.h>
- #include <Singular/tok.h>
- #include <Singular/ipshell.h>
-diff --git a/Singular/configure b/Singular/configure
-index d72b6bd..7663e6c 100755
---- a/Singular/configure
-+++ b/Singular/configure
-@@ -10442,4 +10442,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
- $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
- fi
--
-diff --git a/Singular/configure.in b/Singular/configure.in
-index 9c62c22..418a334 100644
---- a/Singular/configure.in
-+++ b/Singular/configure.in
-@@ -1518,5 +1518,4 @@ if test "$ac_cv_singuname" = "ix86-Win"; then
- fi
- 
- AC_OUTPUT(${OUTPUT_MAKEFILES}, \
-- cp mod2.h ../kernel/mod2.h; \
-  if test "$CONFIG_HEADERS"; then echo timestamp > stamp-h; fi)
-diff --git a/Singular/eigenval_ip.cc b/Singular/eigenval_ip.cc
-index 5f53709..b9f6030 100644
---- a/Singular/eigenval_ip.cc
-+++ b/Singular/eigenval_ip.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: eigenvalues of constant square matrices
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_EIGENVAL
- 
-diff --git a/Singular/emacs.cc b/Singular/emacs.cc
-index 4c800d0..7ef7227 100644
---- a/Singular/emacs.cc
-+++ b/Singular/emacs.cc
-@@ -17,7 +17,7 @@
- #ifdef ix86_Win
- #include <windows.h>
- #endif
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/version.h>
- #include <omalloc/omalloc.h>
- 
-diff --git a/Singular/extra.cc b/Singular/extra.cc
-index 45ea3ba..139b9d2 100644
---- a/Singular/extra.cc
-+++ b/Singular/extra.cc
-@@ -12,7 +12,7 @@
- #include <string.h>
- #include <ctype.h>
- #include <signal.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <misc_ip.h>
- #include <blackbox.h>
- #include <newstruct.h>
-diff --git a/Singular/feOpt.cc b/Singular/feOpt.cc
-index 81fca1c..166eb2a 100644
---- a/Singular/feOpt.cc
-+++ b/Singular/feOpt.cc
-@@ -7,7 +7,7 @@
- 
- #include <string.h>
- #include <stdlib.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/feOpt.h>
- #if !defined(GENERATE_OPTION_INDEX) && !defined(ESINGULAR) && !defined(TSINGULAR)
- #include <kernel/options.h>
-diff --git a/Singular/fehelp.cc b/Singular/fehelp.cc
-index ef96b44..5d4a51c 100644
---- a/Singular/fehelp.cc
-+++ b/Singular/fehelp.cc
-@@ -12,7 +12,7 @@
- #include <stdlib.h>
- #include <time.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <Singular/tok.h>
- #include <omalloc/omalloc.h>
-diff --git a/Singular/fglm.cc b/Singular/fglm.cc
-index a4c397c..f4a3de3 100644
---- a/Singular/fglm.cc
-+++ b/Singular/fglm.cc
-@@ -15,7 +15,7 @@
- *   lying in a 0-dimensional ideal.
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_FACTORY
- #include <Singular/tok.h>
-diff --git a/Singular/gms.cc b/Singular/gms.cc
-index e204043..dc9060e 100644
---- a/Singular/gms.cc
-+++ b/Singular/gms.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: Gauss-Manin system normal form
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_GMS
- 
-diff --git a/Singular/grammar.cc b/Singular/grammar.cc
-index d3327ab..e81c78f 100644
---- a/Singular/grammar.cc
-+++ b/Singular/grammar.cc
-@@ -76,7 +76,7 @@
- #include <stdarg.h>
- #include <string.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <omalloc/omalloc.h>
- #include <Singular/tok.h>
-diff --git a/Singular/grammar.y b/Singular/grammar.y
-index 39e2150..fcb71e2 100644
---- a/Singular/grammar.y
-+++ b/Singular/grammar.y
-@@ -12,7 +12,7 @@
- #include <stdarg.h>
- #include <string.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <omalloc/omalloc.h>
- #include <Singular/tok.h>
-diff --git a/Singular/interpolation.cc b/Singular/interpolation.cc
-index 4d87ddf..1bf10a8 100644
---- a/Singular/interpolation.cc
-+++ b/Singular/interpolation.cc
-@@ -2,7 +2,7 @@
- *  Computer Algebra System SINGULAR     *
- ****************************************/
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <kernel/febase.h>
- #include <kernel/ideals.h>
-diff --git a/Singular/iparith.cc b/Singular/iparith.cc
-index 33a8c3d..52e2e75 100644
---- a/Singular/iparith.cc
-+++ b/Singular/iparith.cc
-@@ -12,7 +12,7 @@
- #include <time.h>
- #include <unistd.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <kernel/options.h>
- #include <Singular/ipid.h>
-diff --git a/Singular/ipassign.cc b/Singular/ipassign.cc
-index e6947e4..01b6ef0 100644
---- a/Singular/ipassign.cc
-+++ b/Singular/ipassign.cc
-@@ -11,7 +11,7 @@
- #include <string.h>
- #include <ctype.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <kernel/options.h>
- #include <Singular/ipid.h>
-diff --git a/Singular/ipconv.cc b/Singular/ipconv.cc
-index a9a7696..431141d 100644
---- a/Singular/ipconv.cc
-+++ b/Singular/ipconv.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: automatic type conversions
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <Singular/ipid.h>
- #include <kernel/bigintmat.h>
-diff --git a/Singular/ipid.cc b/Singular/ipid.cc
-index 872f6b6..36c8d7f 100644
---- a/Singular/ipid.cc
-+++ b/Singular/ipid.cc
-@@ -7,7 +7,7 @@
- 
- #include <string.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/static.h>
- #include <omalloc/omalloc.h>
- #include <Singular/tok.h>
-diff --git a/Singular/iplib.cc b/Singular/iplib.cc
-index a81bc6d..3142247 100644
---- a/Singular/iplib.cc
-+++ b/Singular/iplib.cc
-@@ -11,7 +11,7 @@
- #include <ctype.h>
- #include <sys/stat.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/static.h>
- #include <Singular/tok.h>
- #include <kernel/options.h>
-diff --git a/Singular/ipprint.cc b/Singular/ipprint.cc
-index ede2210..d8f3916 100644
---- a/Singular/ipprint.cc
-+++ b/Singular/ipprint.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: interpreter: printing
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <Singular/ipid.h>
- #include <omalloc/omalloc.h>
-diff --git a/Singular/ipshell.cc b/Singular/ipshell.cc
-index a32c523..32934e7 100644
---- a/Singular/ipshell.cc
-+++ b/Singular/ipshell.cc
-@@ -11,7 +11,7 @@
- #include <ctype.h>
- #include <math.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <kernel/options.h>
- #include <Singular/ipid.h>
-diff --git a/Singular/janet.cc b/Singular/janet.cc
-index 5633599..f5f7806 100755
---- a/Singular/janet.cc
-+++ b/Singular/janet.cc
-@@ -3,7 +3,7 @@
- #include <string.h>
- #include <time.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/omalloc.h>
- #include <kernel/polys.h>
- #include <kernel/numbers.h>
-diff --git a/Singular/libparse.l b/Singular/libparse.l
-index 87d7b4b..cfea410 100644
---- a/Singular/libparse.l
-+++ b/Singular/libparse.l
-@@ -6,7 +6,7 @@
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
--#include <kernel/mod2.h>
-+#include "mod2.h"
- #ifdef STANDALONE_PARSER
-   #include <Singular/utils.h>
-   #define HAVE_LIBPARSER
-diff --git a/Singular/lists.cc b/Singular/lists.cc
-index 1d851ed..c4875fc 100644
---- a/Singular/lists.cc
-+++ b/Singular/lists.cc
-@@ -7,7 +7,7 @@
- // to produce a non-inline version from lists.h
- #define LISTS_CC
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <kernel/febase.h>
- //#include "ipid.h"
-diff --git a/Singular/maps_ip.cc b/Singular/maps_ip.cc
-index 4756a1b..65ef0f4 100644
---- a/Singular/maps_ip.cc
-+++ b/Singular/maps_ip.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT - the mapping of polynomials to other rings
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <kernel/febase.h>
- #include <kernel/polys.h>
-diff --git a/Singular/minpoly.cc b/Singular/minpoly.cc
-index c319099..87bb58e 100644
---- a/Singular/minpoly.cc
-+++ b/Singular/minpoly.cc
-@@ -6,7 +6,7 @@
- 
- 
- #include<cmath>
--#include<Singular/mod2.h>
-+#include <Singular/mod2.h>
- //#include<iomanip>
- 
- #include "minpoly.h"
-diff --git a/Singular/misc_ip.cc b/Singular/misc_ip.cc
-index 47c592a..bd2c2b5 100644
---- a/Singular/misc_ip.cc
-+++ b/Singular/misc_ip.cc
-@@ -14,7 +14,7 @@
- /*****************************************************************************/
- 
- // include header files
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/lists.h>
- #include <kernel/longrat.h>
- #include <Singular/misc_ip.h>
-diff --git a/Singular/mpsr_Error.cc b/Singular/mpsr_Error.cc
-index c189743..44a0b28 100644
---- a/Singular/mpsr_Error.cc
-+++ b/Singular/mpsr_Error.cc
-@@ -11,7 +11,7 @@
-  * Change History (most recent first):
-  *
-  ***************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_MPSR
- 
-diff --git a/Singular/mpsr_Get.cc b/Singular/mpsr_Get.cc
-index c681b03..3fac95a 100644
---- a/Singular/mpsr_Get.cc
-+++ b/Singular/mpsr_Get.cc
-@@ -12,7 +12,7 @@
-  *
-  ***************************************************************/
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_MPSR
- 
-diff --git a/Singular/mpsr_GetMisc.cc b/Singular/mpsr_GetMisc.cc
-index 641b82f..58b536b 100644
---- a/Singular/mpsr_GetMisc.cc
-+++ b/Singular/mpsr_GetMisc.cc
-@@ -12,7 +12,7 @@
-  *
-  ***************************************************************/
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_MPSR
- 
-diff --git a/Singular/mpsr_GetPoly.cc b/Singular/mpsr_GetPoly.cc
-index 24bd201..88eef83 100644
---- a/Singular/mpsr_GetPoly.cc
-+++ b/Singular/mpsr_GetPoly.cc
-@@ -10,7 +10,7 @@
-  *
-  *
-  ***************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_MPSR
- #include "mylimits.h"
-diff --git a/Singular/mpsr_Put.cc b/Singular/mpsr_Put.cc
-index 539e408..449ff9e 100644
---- a/Singular/mpsr_Put.cc
-+++ b/Singular/mpsr_Put.cc
-@@ -13,7 +13,7 @@
-  *    Updated putting routines to MP and MPP v1.1
-  *
-  ***************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_MPSR
- 
-diff --git a/Singular/mpsr_PutPoly.cc b/Singular/mpsr_PutPoly.cc
-index bcd93f4..bf57ac8 100644
---- a/Singular/mpsr_PutPoly.cc
-+++ b/Singular/mpsr_PutPoly.cc
-@@ -13,7 +13,7 @@
-  *    Updated routines to MP and MPP v1.1
-  *
-  ***************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_MPSR
- 
-diff --git a/Singular/mpsr_Tok.cc b/Singular/mpsr_Tok.cc
-index a3801f5..a6818df 100644
---- a/Singular/mpsr_Tok.cc
-+++ b/Singular/mpsr_Tok.cc
-@@ -16,7 +16,7 @@
- #include <sys/types.h>
- #include <unistd.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_MPSR
- 
-diff --git a/Singular/mpsr_sl.cc b/Singular/mpsr_sl.cc
-index 1253e38..5e8f571 100644
---- a/Singular/mpsr_sl.cc
-+++ b/Singular/mpsr_sl.cc
-@@ -8,7 +8,7 @@
-  *  Created: 12/00
-  *******************************************************************/
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_MPSR
- 
-diff --git a/Singular/ndbm.cc b/Singular/ndbm.cc
-index c03cb68..2cb2986 100644
---- a/Singular/ndbm.cc
-+++ b/Singular/ndbm.cc
-@@ -10,7 +10,7 @@
- //
- //**************************************************************************/
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #ifdef HAVE_DBM
- #ifndef HPUX_9
- #include <strings.h>
-diff --git a/Singular/pcv.cc b/Singular/pcv.cc
-index 0f5091c..d9391f1 100644
---- a/Singular/pcv.cc
-+++ b/Singular/pcv.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: conversion between polys and coef vectors
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_PCV
- //#if !defined(HAVE_DYNAMIC_LOADING) || defined(BUILD_MODULE)
-diff --git a/Singular/pipeLink.cc b/Singular/pipeLink.cc
-index 913c88b..47e3b77 100644
---- a/Singular/pipeLink.cc
-+++ b/Singular/pipeLink.cc
-@@ -16,7 +16,7 @@
- #include <sys/socket.h>
- 
- 
--#include "mod2.h"
-+#include <Singular/mod2.h>
- 
- #include "tok.h"
- #include "ipid.h"
-diff --git a/Singular/scanner.cc b/Singular/scanner.cc
-index aa186ce..9847fa1 100644
---- a/Singular/scanner.cc
-+++ b/Singular/scanner.cc
-@@ -560,7 +560,7 @@ char *yytext;
- #include <stdlib.h>
- #include <ctype.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/omalloc.h>
- #include <Singular/tok.h>
- #include <Singular/stype.h>
-diff --git a/Singular/scanner.l b/Singular/scanner.l
-index 8298e71..b78f242 100644
---- a/Singular/scanner.l
-+++ b/Singular/scanner.l
-@@ -7,7 +7,7 @@
- #include <stdlib.h>
- #include <ctype.h>
- 
--#include <kernel/mod2.h>
-+#include "mod2.h"
- #include <omalloc/omalloc.h>
- #include <Singular/tok.h>
- #include <Singular/stype.h>
-diff --git a/Singular/sdb.cc b/Singular/sdb.cc
-index ea0011f..be15a91 100644
---- a/Singular/sdb.cc
-+++ b/Singular/sdb.cc
-@@ -7,7 +7,7 @@
- 
- #include <unistd.h>   // for unlink,fork,execlp,getpid
- #include <sys/wait.h> // for wait
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <kernel/options.h>
- #include <omalloc/omalloc.h>
-diff --git a/Singular/silink.cc b/Singular/silink.cc
-index b3af337..3d64a87 100644
---- a/Singular/silink.cc
-+++ b/Singular/silink.cc
-@@ -12,7 +12,7 @@
- #include <sys/stat.h>
- #include <unistd.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <kernel/options.h>
- #include <omalloc/omalloc.h>
-diff --git a/Singular/sing_dbm.cc b/Singular/sing_dbm.cc
-index bcbd993..fe8990d 100644
---- a/Singular/sing_dbm.cc
-+++ b/Singular/sing_dbm.cc
-@@ -12,7 +12,7 @@
- #  include <fcntl.h>
- #  include <errno.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_DBM
- 
-diff --git a/Singular/sing_win.cc b/Singular/sing_win.cc
-index 00a7062..30dc60f 100644
---- a/Singular/sing_win.cc
-+++ b/Singular/sing_win.cc
-@@ -6,7 +6,7 @@
- * ABSTRACT: Windows specific routines
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #ifdef ix86_Win
- #include <windows.h>
- #include <winuser.h>
-diff --git a/Singular/slInit_Dynamic.cc b/Singular/slInit_Dynamic.cc
-index 3830612..0fa703c 100644
---- a/Singular/slInit_Dynamic.cc
-+++ b/Singular/slInit_Dynamic.cc
-@@ -13,7 +13,7 @@
-  * MP link Extension inits
-  *
-  ***************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/silink.h>
- #include <Singular/slInit.h>
- #include <kernel/mod_raw.h>
-diff --git a/Singular/slInit_Static.cc b/Singular/slInit_Static.cc
-index a19a4f8..207dea0 100644
---- a/Singular/slInit_Static.cc
-+++ b/Singular/slInit_Static.cc
-@@ -13,7 +13,7 @@
-  * MP link Extension inits
-  *
-  ***************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/silink.h>
- #include <Singular/slInit.h>
- 
-diff --git a/Singular/ssiLink.cc b/Singular/ssiLink.cc
-index ff19a2a..938a60e 100644
---- a/Singular/ssiLink.cc
-+++ b/Singular/ssiLink.cc
-@@ -22,7 +22,7 @@
- 
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- // #include "mod2.h"
- 
- #include <Singular/tok.h>
-diff --git a/Singular/subexpr.cc b/Singular/subexpr.cc
-index 873c0a9..0415134 100644
---- a/Singular/subexpr.cc
-+++ b/Singular/subexpr.cc
-@@ -11,7 +11,7 @@
- #include <ctype.h>
- #include <unistd.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/intvec.h>
- #include <kernel/bigintmat.h>
- #include <Singular/tok.h>
-diff --git a/Singular/tesths.cc b/Singular/tesths.cc
-index 6ecb9b1..3957c83 100644
---- a/Singular/tesths.cc
-+++ b/Singular/tesths.cc
-@@ -12,7 +12,7 @@
- #include <stdlib.h>
- #include <time.h>
- #include <errno.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <kernel/options.h>
- #include <Singular/ipshell.h>
-diff --git a/Singular/walk.cc b/Singular/walk.cc
-index 49bd804..d5b61f2 100644
---- a/Singular/walk.cc
-+++ b/Singular/walk.cc
-@@ -45,7 +45,7 @@
- #include <sys/types.h>
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/intvec.h>
- #include <Singular/cntrlc.h>
- #include <kernel/options.h>
-diff --git a/Singular/walk_ip.cc b/Singular/walk_ip.cc
-index b1627f0..8afc077 100644
---- a/Singular/walk_ip.cc
-+++ b/Singular/walk_ip.cc
-@@ -11,7 +11,7 @@
- #include <ctype.h>
- #include <math.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/tok.h>
- #include <kernel/options.h>
- #include <Singular/ipid.h>
-diff --git a/Singular/wrapper.cc b/Singular/wrapper.cc
-index 07a2e2f..7884e9f 100755
---- a/Singular/wrapper.cc
-+++ b/Singular/wrapper.cc
-@@ -1,5 +1,5 @@
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/febase.h>
- #include <kernel/polys.h>
- #include <kernel/kstd1.h>
-diff --git a/kernel/F4.cc b/kernel/F4.cc
-index 93cfedb..d72939c 100644
---- a/kernel/F4.cc
-+++ b/kernel/F4.cc
-@@ -1,4 +1,4 @@
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/F4.h>
- #include <kernel/tgb_internal.h>
- #include <kernel/tgbgauss.h>
-diff --git a/kernel/F5cData.cc b/kernel/F5cData.cc
-index be2021a..384ebc9 100644
---- a/kernel/F5cData.cc
-+++ b/kernel/F5cData.cc
-@@ -9,7 +9,7 @@
-  * these data types is defined.
-  */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_F5C
- #include <kernel/kutil.h>
-diff --git a/kernel/F5cLists.cc b/kernel/F5cLists.cc
-index daab9db..8922036 100644
---- a/kernel/F5cLists.cc
-+++ b/kernel/F5cLists.cc
-@@ -1,4 +1,4 @@
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_F5C
- #include <kernel/kutil.h>
-diff --git a/kernel/GMPrat.cc b/kernel/GMPrat.cc
-index 8d73221..628d90d 100644
---- a/kernel/GMPrat.cc
-+++ b/kernel/GMPrat.cc
-@@ -8,7 +8,7 @@
- 
- #define  GMPRAT_CC
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_SPECTRUM
- 
-diff --git a/kernel/Number.h b/kernel/Number.h
-index 4428d15..05f52b7 100644
---- a/kernel/Number.h
-+++ b/kernel/Number.h
-@@ -1,7 +1,7 @@
- #ifndef NUMBERCPP_HEADER
- #define NUMBERCPP_HEADER
- #include <boost/intrusive_ptr.hpp>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/numbers.h>
- #include <kernel/febase.h>
- #include <kernel/ring.h>
-diff --git a/kernel/Poly.h b/kernel/Poly.h
-index d04b1cc..ab70d30 100644
---- a/kernel/Poly.h
-+++ b/kernel/Poly.h
-@@ -1,6 +1,6 @@
- #ifndef POLYCPP_HEADER
- #define POLYCPP_HEADER
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/IIntvec.h>
- #include <kernel/numbers.h>
- #include <kernel/Number.h>
-diff --git a/kernel/PowerSeries.h b/kernel/PowerSeries.h
-index 809d0b5..7c3f764 100644
---- a/kernel/PowerSeries.h
-+++ b/kernel/PowerSeries.h
-@@ -1,6 +1,6 @@
- #ifndef POWER_SERIES_HEADER
- #define POWER_SERIES_HEADER
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/Poly.h>
- template <class traits> class PowerSeriesInputIterator:
- public std::
-diff --git a/kernel/clapconv.cc b/kernel/clapconv.cc
-index b017e53..07f3c6f 100644
---- a/kernel/clapconv.cc
-+++ b/kernel/clapconv.cc
-@@ -7,7 +7,7 @@
- */
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #ifdef HAVE_FACTORY
- #include <omalloc/omalloc.h>
- #include <kernel/structs.h>
-diff --git a/kernel/clapsing.cc b/kernel/clapsing.cc
-index 606578b..0c327cf 100644
---- a/kernel/clapsing.cc
-+++ b/kernel/clapsing.cc
-@@ -7,7 +7,7 @@
- */
- 
- //#define FACTORIZE2_DEBUG
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/omalloc.h>
- #ifdef HAVE_FACTORY
- #define SI_DONT_HAVE_GLOBAL_VARS
-diff --git a/kernel/dError.c b/kernel/dError.c
-index 5ea1d19..6c229cb 100644
---- a/kernel/dError.c
-+++ b/kernel/dError.c
-@@ -11,7 +11,7 @@
- #define DERROR_C
- #include <stdarg.h>
- #include <stdio.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/distrib.h>
- #ifdef HAVE_CONFIG_H
- #include <omalloc/omalloc.h>
-diff --git a/kernel/digitech.cc b/kernel/digitech.cc
-index 25df89f..6039e43 100644
---- a/kernel/digitech.cc
-+++ b/kernel/digitech.cc
-@@ -1,7 +1,7 @@
- /****************************************
- *  Computer Algebra System SINGULAR     *
- ****************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/ring.h>
- 
- #include <kernel/digitech.h>
-diff --git a/kernel/digitech.h b/kernel/digitech.h
-index b8d0fd3..a1ceb37 100644
---- a/kernel/digitech.h
-+++ b/kernel/digitech.h
-@@ -1,6 +1,6 @@
- #ifndef DIGITECH_HEADER
- #define DIGITECH_HEADER
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/polys.h>
- void bit_reduce(poly & f,ring r);
- poly uni_subst_bits(poly outer_uni, poly inner_multi, ring r);
-diff --git a/kernel/eigenval.cc b/kernel/eigenval.cc
-index a0934a3..d2ce108 100644
---- a/kernel/eigenval.cc
-+++ b/kernel/eigenval.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: eigenvalues of constant square matrices
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_EIGENVAL
- 
-diff --git a/kernel/f5c.cc b/kernel/f5c.cc
-index c1e3b33..caebac9 100644
---- a/kernel/f5c.cc
-+++ b/kernel/f5c.cc
-@@ -1,4 +1,4 @@
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #ifdef HAVE_F5C
- #include <unistd.h>
- #include <kernel/structs.h>
-diff --git a/kernel/f5data.cc b/kernel/f5data.cc
-index d872f61..d606a4e 100644
---- a/kernel/f5data.cc
-+++ b/kernel/f5data.cc
-@@ -5,7 +5,7 @@
- /*
- * ABSTRACT: lpolynomial definition 
- */
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_F5
- #include <kernel/kutil.h>
-diff --git a/kernel/f5gb.cc b/kernel/f5gb.cc
-index d308517..72b20d0 100644
---- a/kernel/f5gb.cc
-+++ b/kernel/f5gb.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: f5gb interface
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #ifdef HAVE_F5
- #include <unistd.h>
- #include <omp.h>
-diff --git a/kernel/f5lists.cc b/kernel/f5lists.cc
-index ae0bcab..4546a17 100644
---- a/kernel/f5lists.cc
-+++ b/kernel/f5lists.cc
-@@ -1,4 +1,4 @@
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_F5
- #include <kernel/kutil.h>
-diff --git a/kernel/fast_maps.cc b/kernel/fast_maps.cc
-index 619c4fd..c38fd20 100644
---- a/kernel/fast_maps.cc
-+++ b/kernel/fast_maps.cc
-@@ -7,7 +7,7 @@
-  *  Author:  obachman (Olaf Bachmann)
-  *  Created: 02/01
-  *******************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/omalloc.h>
- #include <kernel/options.h>
- #include <kernel/p_polys.h>
-diff --git a/kernel/fast_mult.cc b/kernel/fast_mult.cc
-index 120a29a..ae42b3b 100644
---- a/kernel/fast_mult.cc
-+++ b/kernel/fast_mult.cc
-@@ -1,7 +1,7 @@
- /****************************************
- *  Computer Algebra System SINGULAR     *
- ****************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/ring.h>
- #include <kernel/fast_mult.h>
- #include <kernel/kbuckets.h>
-diff --git a/kernel/fast_mult.h b/kernel/fast_mult.h
-index 43a4344..41e97e4 100644
---- a/kernel/fast_mult.h
-+++ b/kernel/fast_mult.h
-@@ -1,6 +1,6 @@
- #ifndef fast_mult_header
- #define fast_mult_header
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/polys.h>
- poly unifastmult(poly f,poly g, ring r);
- poly multifastmult(poly f, poly g, ring r);
-diff --git a/kernel/feResource.cc b/kernel/feResource.cc
-index 30ace22..01bb816 100644
---- a/kernel/feResource.cc
-+++ b/kernel/feResource.cc
-@@ -9,7 +9,7 @@
- #include <unistd.h>
- #include <string.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #ifdef AIX_4
- #define HAVE_PUTENV 1
- #endif
-diff --git a/kernel/febase.cc b/kernel/febase.cc
-index 865c9d7..725eca2 100644
---- a/kernel/febase.cc
-+++ b/kernel/febase.cc
-@@ -7,7 +7,7 @@
- 
- /* I need myfread in standalone_parser */
- #ifndef STANDALONE_PARSER
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #include <stdlib.h>
- #include <stdio.h>
-diff --git a/kernel/fegetopt.c b/kernel/fegetopt.c
-index 47fd931..3cf3db8 100644
---- a/kernel/fegetopt.c
-+++ b/kernel/fegetopt.c
-@@ -31,7 +31,7 @@
- */
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifndef __STDC__
- #  ifndef const
-diff --git a/kernel/feread.cc b/kernel/feread.cc
-index d861fc6..8f67c5e 100644
---- a/kernel/feread.cc
-+++ b/kernel/feread.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: input from ttys, simulating fgets
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- // ----------------------------------------
- // system settings:
-diff --git a/kernel/fereadl.c b/kernel/fereadl.c
-index d2f6c1c..1c495be 100644
---- a/kernel/fereadl.c
-+++ b/kernel/fereadl.c
-@@ -6,7 +6,7 @@
- */
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/febase.h>
- #include <omalloc/omalloc.h>
- #include <kernel/structs.h>
-diff --git a/kernel/ffields.cc b/kernel/ffields.cc
-index be5aeb7..255e590 100644
---- a/kernel/ffields.cc
-+++ b/kernel/ffields.cc
-@@ -6,7 +6,7 @@
- */
- 
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <kernel/febase.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/fglmcomb.cc b/kernel/fglmcomb.cc
-index d8b42a2..4c11eab 100644
---- a/kernel/fglmcomb.cc
-+++ b/kernel/fglmcomb.cc
-@@ -7,7 +7,7 @@
- * ABSTRACT -
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_FACTORY
- #include <kernel/options.h>
-diff --git a/kernel/fglmgauss.cc b/kernel/fglmgauss.cc
-index 933e26c..b64613a 100644
---- a/kernel/fglmgauss.cc
-+++ b/kernel/fglmgauss.cc
-@@ -8,7 +8,7 @@
- *  to find linear dependecies of fglmVectors.
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef  HAVE_FACTORY
- #include <kernel/structs.h>
-diff --git a/kernel/fglmhom.cc b/kernel/fglmhom.cc
-index 16ead96..4636bea 100644
---- a/kernel/fglmhom.cc
-+++ b/kernel/fglmhom.cc
-@@ -9,7 +9,7 @@
- */
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #if 0
- #include <factoryconf.h>
- #ifndef NOSTREAMIO
-diff --git a/kernel/fglmvec.cc b/kernel/fglmvec.cc
-index a0a4300..75abda1 100644
---- a/kernel/fglmvec.cc
-+++ b/kernel/fglmvec.cc
-@@ -11,7 +11,7 @@
- *   specialized for this purpose.
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_FACTORY
- #include <omalloc/omalloc.h>
-diff --git a/kernel/fglmzero.cc b/kernel/fglmzero.cc
-index 5224374..4cac366 100644
---- a/kernel/fglmzero.cc
-+++ b/kernel/fglmzero.cc
-@@ -17,7 +17,7 @@
-  * o FindUnivariatePolys added
-  */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_FACTORY
- #include <kernel/options.h>
-diff --git a/kernel/gfan.cc b/kernel/gfan.cc
-new file mode 100644
-index 0000000..55c9431
---- /dev/null
-+++ b/kernel/gfan.cc
-@@ -0,0 +1,4512 @@
-+/*
-+Compute the Groebner fan of an ideal
-+$Author: monerjan $
-+$Date: 2009/11/03 06:57:32 $
-+$Header: /usr/local/Singular/cvsroot/kernel/gfan.cc,v 1.103 2009/11/03 06:57:32 monerjan Exp $
-+$Id: gfan.cc 14493 2012-01-16 11:00:07Z motsak $
-+*/
-+
-+#include <Singular/mod2.h>
-+
-+#ifdef HAVE_FANS
-+#include <kernel/options.h>
-+#include <kernel/kstd1.h>
-+#include <kernel/kutil.h>
-+#include <kernel/polys.h>
-+#include <kernel/ideals.h>
-+#include <kernel/kmatrix.h>
-+#include <kernel/GMPrat.h>
-+
-+#include "ring.h"	//apparently not needed
-+#include <Singular/lists.h>
-+#include <kernel/prCopy.h>
-+#include <kernel/stairc.h>
-+#include <fstream>	//read-write cones to files
-+#include <string>
-+#include <sstream>
-+#include <stdlib.h>
-+#include <assert.h>
-+#include <gfanlib/gfanlib.h>
-+
-+/*DO NOT REMOVE THIS*/
-+#ifndef GMPRATIONAL
-+#define GMPRATIONAL
-+#endif
-+
-+#include <setoper.h>
-+#include <cdd.h>
-+#include <cddmp.h>
-+
-+#ifndef gfan_DEBUG
-+// #define gfan_DEBUG
-+#ifndef gfan_DEBUGLEVEL
-+#define gfan_DEBUGLEVEL 1
-+#endif
-+#endif
-+
-+//NOTE Defining this will slow things down!
-+//Only good for very coarse profiling
-+// #define gfanp
-+#ifdef gfanp
-+  #include <sys/time.h>
-+  #include <iostream>
-+#endif
-+
-+//NOTE DO NOT REMOVE THIS
-+#ifndef SHALLOW
-+  #define SHALLOW
-+#endif
-+
-+#ifndef USE_ZFAN
-+  #define USE_ZFAN
-+#endif
-+
-+#include <gfan.h>
-+using namespace std;
-+
-+#define ivIsStrictlyPositive iv64isStrictlyPositive
-+
-+/**
-+*\brief Class facet
-+*	Implements the facet structure as a linked list
-+*
-+*/
-+		
-+/** \brief The default constructor for facets
-+*/
-+facet::facet()			
-+{
-+	// Pointer to next facet.  */
-+	/* Defaults to NULL. This way there is no need to check explicitly */
-+	this->fNormal=NULL;
-+	this->interiorPoint=NULL;		
-+	this->UCN=0;
-+	this->codim2Ptr=NULL;
-+	this->codim=1;		//default for (codim-1)-facets
-+	this->numCodim2Facets=0;
-+	this->numRays=0;
-+	this->flipGB=NULL;
-+	this->next=NULL;
-+	this->prev=NULL;		
-+	this->flipRing=NULL;	//the ring on the other side
-+	this->isFlippable=FALSE;
-+}
-+		
-+/** \brief Constructor for facets of codim == 2
-+* Note that as of now the code of the constructors is only for facets and codim2-faces. One
-+* could easily change that by renaming numCodim2Facets to numCodimNminusOneFacets or similar
-+*/
-+facet::facet(const int &n)
-+{
-+	this->fNormal=NULL;
-+	this->interiorPoint=NULL;			
-+	this->UCN=0;
-+	this->codim2Ptr=NULL;
-+	if(n==2)
-+	{
-+		this->codim=n;
-+	}//NOTE Handle exception here!			
-+	this->numCodim2Facets=0;
-+	this->numRays=0;
-+	this->flipGB=NULL;
-+	this->next=NULL;
-+	this->prev=NULL;
-+	this->flipRing=NULL;
-+	this->isFlippable=FALSE;
-+}
-+		
-+/** \brief The copy constructor
-+* By default only copies the fNormal, f2Normals and UCN
-+*/
-+facet::facet(const facet& f)
-+{
-+	this->fNormal=iv64Copy(f.fNormal);
-+	this->UCN=f.UCN;
-+	this->isFlippable=f.isFlippable;
-+	//Needed for flip2
-+	//NOTE ONLY REFERENCE
-+	this->interiorPoint=iv64Copy(f.interiorPoint);//only referencing is prolly not the best thing to do in a copy constructor
-+	facet* f2Copy;
-+	f2Copy=f.codim2Ptr;
-+	facet* f2Act;
-+	f2Act=this->codim2Ptr;
-+	while(f2Copy!=NULL)
-+	{
-+		if(f2Act==NULL
-+#ifndef NDEBUG
-+  #if SIZEOF_LONG==8
-+				 || f2Act==(facet*)0xfefefefefefefefe
-+  #elif SIZEOF_LONG==4
-+				 || f2Act==(facet*)0xfefefefe
-+  #endif
-+#endif
-+		  )
-+		{
-+			f2Act=new facet(2);
-+			this->codim2Ptr=f2Act;			
-+		}
-+		else
-+		{
-+			facet* marker;
-+			marker = f2Act;
-+			f2Act->next = new facet(2);
-+			f2Act = f2Act->next;
-+			f2Act->prev = marker;
-+		}
-+		int64vec *f2Normal;
-+		f2Normal = f2Copy->getFacetNormal();
-+// 		f2Act->setFacetNormal(f2Copy->getFacetNormal());
-+		f2Act->setFacetNormal(f2Normal);
-+		delete f2Normal;
-+		f2Act->setUCN(f2Copy->getUCN());
-+		f2Copy = f2Copy->next;
-+	}	
-+}
-+
-+/** \brief Shallow copy constructor for facets
-+* We only need the interior point for equality testing
-+*/
-+facet* facet::shallowCopy(const facet& f)
-+{
-+	facet *res = new facet();
-+	res->fNormal=(int64vec * const)f.fNormal;
-+	res->UCN=f.UCN;
-+	res->isFlippable=f.isFlippable;
-+	res->interiorPoint=(int64vec * const)f.interiorPoint;
-+	res->codim2Ptr=(facet * const)f.codim2Ptr;
-+	res->prev=NULL;
-+	res->next=NULL;
-+	res->flipGB=NULL;
-+	res->flipRing=NULL;
-+	return res;
-+}
-+
-+void facet::shallowDelete()
-+{
-+#ifndef NDEBUG
-+// 	printf("shallowdel at UCN %i\n", this->getUCN());
-+#endif
-+	this->fNormal=NULL;
-+// 	this->UCN=0;
-+	this->interiorPoint=NULL;
-+	this->codim2Ptr=NULL;
-+	this->prev=NULL;
-+	this->next=NULL;
-+	this->flipGB=NULL;
-+	this->flipRing=NULL;
-+	assert(this->fNormal==NULL);	
-+// 	delete(this);
-+}
-+		
-+/** The default destructor */
-+facet::~facet()
-+{
-+#ifndef NDEBUG
-+// 	printf("~facet at UCN %i\n",this->getUCN());
-+#endif
-+	if(this->fNormal!=NULL)
-+		delete this->fNormal;
-+	if(this->interiorPoint!=NULL)
-+		delete this->interiorPoint;
-+	/* Cleanup the codim2-structure */
-+// 	if(this->codim==2)
-+// 	{
-+// 		facet *codim2Ptr;
-+// 		codim2Ptr = this->codim2Ptr;
-+// 		while(codim2Ptr!=NULL)
-+// 		{
-+// 			if(codim2Ptr->fNormal!=NULL)
-+// 			{
-+// 				delete codim2Ptr->fNormal;//NOTE Do not want this anymore since the rays are now in gcone!
-+// 				codim2Ptr = codim2Ptr->next;
-+// 			}
-+// 		}
-+// 	}
-+	//The rays are stored in the cone!
-+	if(this->flipGB!=NULL)
-+		idDelete((ideal *)&this->flipGB);
-+// 	if(this->flipRing!=NULL && this->flipRing->idroot!=(idhdl)0xfbfbfbfbfbfbfbfb)
-+// 		rDelete(this->flipRing); //See vol II/134
-+// 	this->flipRing=NULL;
-+	this->prev=NULL;
-+	this->next=NULL;
-+}
-+		
-+inline const int64vec *facet::getRef2FacetNormal() const
-+{
-+	return(this->fNormal);
-+}	
-+
-+/** Equality check for facets based on unique interior points*/
-+static bool areEqual2(facet* f, facet *g)
-+{
-+#ifdef gfanp
-+	gcone::numberOfFacetChecks++;
-+	timeval start, end;
-+	gettimeofday(&start, 0);
-+#endif
-+	bool res = TRUE;
-+	const int64vec *fIntP = f->getRef2InteriorPoint();
-+	const int64vec *gIntP = g->getRef2InteriorPoint();
-+	for(int ii=0;ii<pVariables;ii++)
-+	{
-+		if( (*fIntP)[ii] != (*gIntP)[ii] )
-+		{
-+			res=FALSE;
-+			break;
-+		}
-+	}
-+// 	if( fIntP->compare(gIntP)!=0) res=FALSE;
-+#ifdef gfanp
-+	gettimeofday(&end, 0);
-+	gcone::t_areEqual += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-+#endif	
-+	return res;
-+}
-+
-+/** \brief Comparison of facets
-+ * called from enqueueNewFacets
-+* The facet normals are primitve vectors since we call gcone::normalize() on all cones.
-+* Hence it should suffice to check whether facet normal f equals minus facet normal s.
-+* If so we check the extremal rays
-+*
-+* BEWARE: It would be better to use const int64vec* but that will lead to call something like
-+* int foo=((int64vec*)f2Normal)->compare((int64vec*)s2Normal) resulting in much higher memory usage
-+*/
-+static bool areEqual(facet *f, facet *s)
-+{
-+#ifdef gfanp
-+	gcone::numberOfFacetChecks++;
-+	timeval start, end;
-+	gettimeofday(&start, 0);
-+#endif
-+	bool res = TRUE;
-+	int notParallelCtr=0;
-+	int ctr=0;
-+	const int64vec* fNormal; //No new since iv64Copy and therefore getFacetNormal return a new
-+	const int64vec* sNormal;
-+	fNormal = f->getRef2FacetNormal();
-+	sNormal = s->getRef2FacetNormal();
-+#include "intvec.h"
-+	//Do not need parallelity. Too time consuming
-+//  	if(!isParallel(*fNormal,*sNormal))
-+// 	if(fNormal->compare(ivNeg(sNormal))!=0)//This results in a Mandelbug
-+ // 		notParallelCtr++;
-+// 	else//parallelity, so we check the codim2-facets
-+	int64vec *fNRef=const_cast<int64vec*>(fNormal);
-+	int64vec *sNRef=const_cast<int64vec*>(sNormal);
-+	if(isParallel(*fNRef,*sNRef))
-+// 	if(fNormal->compare((sNormal))!=0)//Behold! Teh definitive Mandelbug
-+	{
-+		facet* f2Act;
-+		facet* s2Act;
-+		f2Act = f->codim2Ptr;		
-+		ctr=0;
-+		while(f2Act!=NULL)
-+		{
-+			const int64vec* f2Normal;
-+			f2Normal = f2Act->getRef2FacetNormal();
-+// 			int64vec *f2Ref=const_cast<int64vec*>(f2Normal);
-+			s2Act = s->codim2Ptr;
-+			while(s2Act!=NULL)
-+			{
-+				const int64vec* s2Normal;
-+				s2Normal = s2Act->getRef2FacetNormal();
-+// 				bool foo=areEqual(f2Normal,s2Normal);
-+// 				int64vec *s2Ref=const_cast<int64vec*>(s2Normal);
-+				int foo=f2Normal->compare(s2Normal);
-+				if(foo==0)
-+					ctr++;
-+				s2Act = s2Act->next;
-+			}
-+			f2Act = f2Act->next;
-+		}		
-+	}
-+	if(ctr==f->numCodim2Facets)
-+		res=TRUE;
-+	else
-+	{
-+#ifdef gfanp
-+		gcone::parallelButNotEqual++;
-+#endif
-+		res=FALSE;
-+	}
-+#ifdef gfanp
-+	gettimeofday(&end, 0);
-+	gcone::t_areEqual += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-+#endif
-+	return res;
-+}	
-+		
-+/** Stores the facet normal \param int64vec*/
-+inline void facet::setFacetNormal(int64vec *iv)
-+{
-+	if(this->fNormal!=NULL)
-+		delete this->fNormal;
-+	this->fNormal = iv64Copy(iv);			
-+}
-+		
-+/** Hopefully returns the facet normal 
-+* Mind: iv64Copy returns a new int64vec, so use this in the following way:
-+* int64vec *iv;
-+* iv = this->getFacetNormal();
-+* [...]
-+* delete(iv);
-+*/
-+inline int64vec *facet::getFacetNormal() const
-+{				
-+	return iv64Copy(this->fNormal);
-+}
-+
-+/** Method to print the facet normal*/
-+inline void facet::printNormal() const
-+{
-+	fNormal->show();
-+}
-+		
-+/** Store the flipped GB*/
-+inline void facet::setFlipGB(ideal I)
-+{
-+	this->flipGB=idCopy(I);
-+}
-+		
-+/** Returns a pointer to the flipped GB
-+Seems not be used
-+Anyhow idCopy would make sense here.
-+*/
-+inline ideal facet::getFlipGB()
-+{
-+	return this->flipGB;
-+}
-+		
-+/** Print the flipped GB*/
-+inline void facet::printFlipGB()
-+{
-+#ifndef NDEBUG
-+	idShow(this->flipGB);
-+#endif
-+}
-+		
-+/** Set the UCN */
-+inline void facet::setUCN(int n)
-+{
-+	this->UCN=n;
-+}
-+		
-+/** \brief Get the UCN 
-+* Returns the UCN iff this != NULL, else -1
-+*/
-+inline int facet::getUCN()
-+{
-+#ifndef NDEBUG
-+  #if SIZEOF_LONG==8
-+	if((this!=NULL && this!=(facet * const)0xfbfbfbfbfbfbfbfb))
-+  #elif SIZEOF_LONG==4
-+	if((this!=NULL && this!=(facet * const)0xfbfbfbfb))
-+  #endif
-+#endif
-+#ifdef NDEBUG
-+	if(this!=NULL)
-+#endif			
-+		return this->UCN;
-+	else
-+		return -1;
-+}
-+		
-+/** Store an interior point of the facet */
-+inline void facet::setInteriorPoint(int64vec *iv)
-+{
-+	if(this->interiorPoint!=NULL)
-+		delete this->interiorPoint;
-+	this->interiorPoint = iv64Copy(iv);
-+}
-+		
-+/** Returns a pointer to this->interiorPoint
-+* MIND: iv64Copy returns a new int64vec
-+* @see facet::getFacetNormal
-+*/
-+inline int64vec *facet::getInteriorPoint()
-+{
-+	return iv64Copy(this->interiorPoint);
-+}
-+
-+inline const int64vec *facet::getRef2InteriorPoint()
-+{
-+	return (this->interiorPoint);
-+}
-+		
-+/** \brief Debugging function
-+* prints the facet normal an all (codim-2)-facets that belong to it
-+*/
-+volatile void facet::fDebugPrint()
-+{
-+  #ifndef NDEBUG
-+	facet *codim2Act;			
-+	codim2Act = this->codim2Ptr;
-+	int64vec *fNormal;
-+	fNormal = this->getFacetNormal();	
-+	printf("=======================\n");
-+	printf("Facet normal = (");fNormal->show(1,1);printf(")\n");
-+	printf("-----------------------\n");
-+	printf("Codim2 facets:\n");
-+	while(codim2Act!=NULL)
-+	{
-+		int64vec *f2Normal;
-+		f2Normal = codim2Act->getFacetNormal();
-+		printf("(");f2Normal->show(1,0);printf(")\n");
-+		codim2Act = codim2Act->next;
-+		delete f2Normal;
-+	}
-+	printf("=======================\n");
-+ 	delete fNormal;
-+  #endif
-+}
-+
-+
-+/**
-+*\brief Implements the cone structure
-+*
-+* A cone is represented by a linked list of facet normals
-+* @see facet
-+*/
-+
-+
-+/** \brief Default constructor. 
-+ *
-+ * Initialises this->next=NULL and this->facetPtr=NULL
-+ */
-+gcone::gcone()
-+{
-+	this->next=NULL;
-+	this->prev=NULL;
-+	this->facetPtr=NULL;	//maybe this->facetPtr = new facet();			
-+	this->baseRing=currRing;
-+	this->counter++;
-+	this->UCN=this->counter;			
-+	this->numFacets=0;
-+	this->ivIntPt=NULL;
-+	this->gcRays=NULL;
-+}
-+		
-+/** \brief Constructor with ring and ideal
-+ *
-+ * This constructor takes the root ring and the root ideal as parameters and stores 
-+ * them in the private members gcone::rootRing and gcone::inputIdeal
-+ * This constructor is only called once in the computation of the Gröbner fan,
-+ * namely for the very first cone. Therefore pred is set to 1.
-+ * Might set it to this->UCN though...
-+ * Since knowledge of the root ring is only needed when using reverse search,
-+ * this constructor is not needed when using the "second" method
-+*/
-+gcone::gcone(ring r, ideal I)
-+{
-+	this->next=NULL;
-+	this->prev=NULL;
-+	this->facetPtr=NULL;			
-+	this->inputIdeal=I;
-+	this->baseRing=currRing;
-+	this->counter++;
-+	this->UCN=this->counter;
-+	this->pred=1;
-+	this->numFacets=0;
-+	this->ivIntPt=NULL;
-+	this->gcRays=NULL;
-+}
-+		
-+/** \brief Copy constructor 
-+ *
-+ * Copies a cone, sets this->gcBasis to the flipped GB
-+ * Call this only after a successful call to gcone::flip which sets facet::flipGB
-+*/		
-+gcone::gcone(const gcone& gc, const facet &f)
-+{
-+	this->next=NULL;
-+// 	this->prev=(gcone *)&gc; //comment in to get a tree
-+	this->prev=NULL;
-+	this->numVars=gc.numVars;
-+	this->counter++;
-+	this->UCN=this->counter;
-+	this->pred=gc.UCN;
-+	this->facetPtr=NULL;
-+   	this->gcBasis=idrCopyR(f.flipGB, f.flipRing);
-+//  	this->inputIdeal=idCopy(this->gcBasis);
-+	this->baseRing=rCopy(f.flipRing);
-+	this->numFacets=0;
-+	this->ivIntPt=NULL;
-+	this->gcRays=NULL;
-+}
-+		
-+/** \brief Default destructor 
-+*/
-+gcone::~gcone()
-+{
-+#ifndef NDEBUG
-+  #if SIZEOF_LONG==8
-+	if( ( this->gcBasis!=(ideal)(0xfbfbfbfbfbfbfbfb) ) && (this->gcBasis!=NULL) )
-+		idDelete((ideal*)&this->gcBasis);
-+  #elif SIZEOF_LONG!=8
-+	if(this->gcBasis!=(ideal)0xfbfbfbfb)
-+		idDelete((ideal *)&this->gcBasis);
-+  #endif
-+#else
-+	if(this->gcBasis!=NULL)
-+		idDelete((ideal *)&this->gcBasis);
-+#endif
-+// 	idDelete((ideal *)&this->gcBasis);
-+// 	if(this->inputIdeal!=NULL)
-+// 		idDelete((ideal *)&this->inputIdeal);
-+// 	if (this->rootRing!=NULL && this->rootRing!=(ip_sring *)0xfefefefefefefefe)
-+// 		rDelete(this->rootRing);
-+	if(this->UCN!=1 && this->baseRing!=NULL)
-+		rDelete(this->baseRing);
-+	facet *fAct;
-+	facet *fDel;
-+	/*Delete the facet structure*/
-+	fAct=this->facetPtr;
-+	fDel=fAct;
-+	while(fAct!=NULL)
-+	{
-+		fDel=fAct;
-+		fAct=fAct->next;
-+		delete fDel;
-+	}
-+	this->counter--;
-+	//should be deleted in noRevS
-+// 	dd_FreeMatrix(this->ddFacets);
-+	//dd_FreeMatrix(this->ddFacets);
-+	for(int ii=0;ii<this->numRays;ii++)
-+		delete(gcRays[ii]);
-+	omFree(gcRays);
-+}			
-+
-+/** Returns the number of cones existing at the time*/
-+inline int gcone::getCounter()
-+{
-+	return this->counter;
-+}
-+	
-+/** \brief Set the interior point of a cone */
-+inline void gcone::setIntPoint(int64vec *iv)
-+{
-+	if(this->ivIntPt!=NULL)
-+		delete this->ivIntPt;
-+	this->ivIntPt=iv64Copy(iv);
-+}
-+		
-+/** \brief Returns either a physical copy the interior point of a cone or just a reference to it.*/
-+inline int64vec *gcone::getIntPoint(bool shallow)
-+{
-+	if(shallow==TRUE)
-+		return this->ivIntPt;
-+	else
-+		return iv64Copy(this->ivIntPt);
-+}
-+		
-+/** \brief Print the interior point */
-+inline void gcone::showIntPoint()
-+{
-+	ivIntPt->show();
-+}
-+		
-+/** \brief Print facets
-+ * This is mainly for debugging purposes. Usually called from within gdb
-+ */
-+volatile void gcone::showFacets(const short codim)
-+{
-+  #ifndef NDEBUG
-+	facet *f=this->facetPtr;
-+	facet *f2=NULL;
-+	if(codim==2)
-+		f2=this->facetPtr->codim2Ptr;
-+	while(f!=NULL)
-+	{
-+		int64vec *iv;
-+		iv = f->getFacetNormal();
-+		printf("(");iv->show(1,0);
-+		if(f->isFlippable==FALSE)
-+			printf(")* ");
-+		else
-+			printf(") ");
-+		delete iv;
-+		if(codim==2)
-+		{
-+			f2=f->codim2Ptr;
-+			while(f2!=NULL)
-+			{
-+				printf("[");f2->getFacetNormal()->show(1,0);printf("]");
-+				f2 = f2->next;
-+			}
-+			printf("\n");
-+		}
-+		f=f->next;
-+	}
-+	printf("\n");
-+  #endif
-+}
-+		
-+/** For debugging purposes only */
-+static volatile void showSLA(facet &f)
-+{
-+  #ifndef NDEBUG
-+	facet *fAct;
-+	fAct = &f;
-+	if(fAct!=NULL)
-+	{
-+		facet *codim2Act;
-+		codim2Act = fAct->codim2Ptr;
-+		
-+		printf("\n");
-+		while(fAct!=NULL)
-+		{
-+			int64vec *fNormal;		
-+			fNormal=fAct->getFacetNormal();
-+			printf("(");fNormal->show(1,0);
-+			if(fAct->isFlippable==TRUE)
-+				printf(") ");
-+			else
-+				printf(")* ");
-+			delete fNormal;
-+			codim2Act = fAct->codim2Ptr;
-+			printf(" Codim2: ");
-+			while(codim2Act!=NULL)
-+			{
-+				int64vec *f2Normal;
-+				f2Normal = codim2Act->getFacetNormal();
-+				printf("(");f2Normal->show(1,0);printf(") ");
-+				delete f2Normal;
-+				codim2Act = codim2Act->next;
-+			}
-+			printf("UCN = %i\n",fAct->getUCN());
-+			fAct = fAct->next;
-+		}
-+	}
-+  #endif
-+}
-+		
-+static void idDebugPrint(const ideal &I)
-+{
-+  #ifndef NDEBUG
-+	int numElts=IDELEMS(I);
-+	printf("Ideal with %i generators\n", numElts);
-+	printf("Leading terms: ");
-+	for (int ii=0;ii<numElts;ii++)
-+	{
-+		pWrite0(pHead(I->m[ii]));
-+		printf(",");
-+	}
-+	printf("\n");
-+  #endif
-+}
-+
-+static void invPrint(const ideal &I)
-+{
-+// 	int numElts=IDELEMS(I);
-+// 	cout << "inv = ";
-+// 	for(int ii=0;ii<numElts;ii++);
-+// 	{
-+// 		pWrite0(pHead(I->m[ii]));
-+// 		cout << ",";
-+// 	}
-+// 	cout << endl;
-+}
-+
-+static bool isMonomial(const ideal &I)
-+{
-+	bool res = TRUE;
-+	for(int ii=0;ii<IDELEMS(I);ii++)
-+	{
-+		if(pLength((poly)I->m[ii])>1)
-+		{
-+			res = FALSE;
-+			break;
-+		}
-+	}
-+	return res;
-+}
-+		
-+/** \brief Set gcone::numFacets */
-+inline void gcone::setNumFacets()
-+{
-+}
-+		
-+/** \brief Get gcone::numFacets */
-+inline int gcone::getNumFacets()
-+{
-+	return this->numFacets;
-+}
-+		
-+inline int gcone::getUCN()
-+{
-+	if( this!=NULL)// && ( this!=(gcone * const)0xfbfbfbfbfbfbfbfb && this!=(gcone * const)0xfbfbfbfb ) )
-+		return this->UCN;
-+	else
-+		return -1;
-+}
-+
-+inline int gcone::getPredUCN()
-+{
-+	return this->pred;
-+}
-+/** Returns a copy of the this->baseRing */
-+inline ring gcone::getBaseRing()
-+{
-+	return rCopy(this->baseRing);
-+}
-+
-+inline void gcone::setBaseRing(ring r)
-+{
-+	this->baseRing=rCopy(r);
-+}
-+
-+inline ring gcone::getRef2BaseRing()
-+{
-+	return this->baseRing;
-+}
-+
-+/** \brief Compute the normals of the cone
-+ *
-+ * This method computes a representation of the cone in terms of facet normals. It takes an ideal
-+ * as its input. Redundancies are automatically removed using cddlib's dd_MatrixCanonicalize.
-+ * Other methods for redundancy checkings might be implemented later. See Anders' diss p.44.
-+ * Note that in order to use cddlib a 0-th column has to be added to the matrix since cddlib expects 
-+ * each row to represent an inequality of type const+x1+...+xn <= 0. While computing the normals we come across
-+ * the set \f$ \partial\mathcal{G} \f$ which we might store for later use. C.f p71 of journal
-+ * As a result of this procedure the pointer facetPtr points to the first facet of the cone.
-+ *
-+ * Optionally, if the parameter bool compIntPoint is set to TRUE the method will also compute
-+ * an interior point of the cone.
-+		 */
-+void gcone::getConeNormals(const ideal &I, bool compIntPoint)
-+{
-+#ifdef gfanp
-+	timeval start, end;
-+	gettimeofday(&start, 0);
-+#endif
-+	poly aktpoly;
-+	int rows; 			// will contain the dimensions of the ineq matrix - deprecated by
-+	dd_rowrange ddrows;
-+	dd_colrange ddcols;
-+	dd_rowset ddredrows;		// # of redundant rows in ddineq
-+	dd_rowset ddlinset;		// the opposite
-+	dd_rowindex ddnewpos=NULL;		  // all to make dd_Canonicalize happy
-+	dd_NumberType ddnumb=dd_Integer; //Number type
-+	dd_ErrorType dderr=dd_NoError;		
-+	//Compute the # inequalities i.e. rows of the matrix
-+	rows=0; //Initialization
-+	for (int ii=0;ii<IDELEMS(I);ii++)
-+	{
-+// 		aktpoly=(poly)I->m[ii];
-+// 		rows=rows+pLength(aktpoly)-1;
-+		rows=rows+pLength((poly)I->m[ii])-1;
-+	}
-+
-+	dd_rowrange aktmatrixrow=0;	// needed to store the diffs of the expvects in the rows of ddineq
-+	ddrows=rows;
-+	ddcols=this->numVars;
-+	dd_MatrixPtr ddineq; 		//Matrix to store the inequalities			
-+	ddineq=dd_CreateMatrix(ddrows,ddcols+1); //The first col has to be 0 since cddlib checks for additive consts there
-+		
-+	// We loop through each g\in GB and compute the resulting inequalities
-+	for (int i=0; i<IDELEMS(I); i++)
-+	{
-+		aktpoly=(poly)I->m[i];		//get aktpoly as i-th component of I
-+		//simpler version of storing expvect diffs
-+		int *leadexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));
-+		pGetExpV(aktpoly,leadexpv);
-+		poly pNextTerm=aktpoly;
-+		while(pNext(pNextTerm)/*pNext(aktpoly)*/!=NULL)
-+		{
-+			pNextTerm/*aktpoly*/=pNext(pNextTerm);
-+			int *tailexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));
-+			pGetExpV(pNextTerm,tailexpv);			
-+			for(int kk=1;kk<=this->numVars;kk++)
-+			{				
-+				dd_set_si(ddineq->matrix[(dd_rowrange)aktmatrixrow][kk],leadexpv[kk]-tailexpv[kk]);
-+			}
-+			aktmatrixrow += 1;
-+			omFree(tailexpv);
-+		}		
-+		omFree(leadexpv);	
-+	} //for
-+#if true
-+	/*Let's make the preprocessing here. This could already be done in the above for-loop,
-+	* but for a start it is more convenient here.
-+	* We check the necessary condition of FJT p.18
-+	* Quote: [...] every non-zero spoly should have at least one of its terms in inv(G)
-+	*/
-+// 	ideal initialForm=idInit(IDELEMS(I),1);
-+// 	int64vec *gamma=new int64vec(this->numVars);
-+	int falseGammaCounter=0;
-+	int *redRowsArray=NULL;
-+	int num_alloc=0;
-+	int num_elts=0;	
-+	for(int ii=0;ii<ddineq->rowsize;ii++)
-+	{
-+		ideal initialForm=idInit(IDELEMS(I),I->rank);
-+		//read row ii into gamma
-+// 		int64 tmp;
-+		int64vec *gamma=new int64vec(this->numVars);
-+		for(int jj=1;jj<=this->numVars;jj++)
-+		{
-+			int64 tmp;
-+			tmp=(int64)mpq_get_d(ddineq->matrix[ii][jj]);
-+			(*gamma)[jj-1]=(int64)tmp;
-+		}
-+		computeInv((ideal&)I,initialForm,*gamma);
-+		delete gamma;
-+		//Create leading ideal
-+		ideal L=idInit(IDELEMS(initialForm),1);
-+		for(int jj=0;jj<IDELEMS(initialForm);jj++)
-+		{
-+			poly p=pHead(initialForm->m[jj]);
-+			L->m[jj]=pCopy(/*pHead(initialForm->m[jj]))*/p);
-+			pDelete(&p);
-+		}		
-+		
-+		LObject *P = new sLObject();//TODO What's the difference between sLObject and LObject?
-+		memset(P,0,sizeof(LObject));
-+
-+		for(int jj=0;jj<=IDELEMS(initialForm)-2;jj++)
-+		{
-+			bool isMaybeFacet=FALSE;
-+			P->p1=initialForm->m[jj];	//build spolys of initialForm in_v
-+
-+			for(int kk=jj+1;kk<=IDELEMS(initialForm)-1;kk++)
-+			{
-+				P->p2=initialForm->m[kk];
-+				ksCreateSpoly(P);							
-+				if(P->p!=NULL)	//spoly non zero=?
-+				{	
-+					poly p;//NOTE Don't use pInit here. Evil memleak will follow
-+					poly q;
-+					poly pDel,qDel;
-+					p=pCopy(P->p);
-+					q=pHead(p);	//Monomial q
-+					pDelete(&q);
-+					pDel=p; qDel=q;
-+					isMaybeFacet=FALSE;
-+					//TODO: Suffices to check LTs here
-+					while(p!=NULL)
-+					{						
-+						q=pHead(p);
-+						for(int ll=0;ll<IDELEMS(L);ll++)
-+						{
-+							if(pLmEqual(L->m[ll],q) || pDivisibleBy(L->m[ll],q))
-+							{							
-+								isMaybeFacet=TRUE;
-+ 								break;//for
-+							}
-+						}
-+						pDelete(&q);
-+						if(isMaybeFacet==TRUE)
-+						{
-+							break;//while(p!=NULL)
-+						}
-+						p=pNext(p);
-+					}//while
-+// 					pDelete(&p);//NOTE Better to use pDel and qDel. Commenting in this line will not work!
-+					if(q!=NULL) pDelete(&q);
-+					pDelete(&pDel);
-+					pDelete(&qDel);
-+					if(isMaybeFacet==FALSE)
-+					{
-+						dd_set_si(ddineq->matrix[ii][0],1);						
-+// 						if(num_alloc==0)
-+// 							num_alloc += 1;
-+// 						else						
-+// 							num_alloc += 1;
-+						if(num_alloc==num_elts)	num_alloc==0 ? num_alloc=1 : num_alloc*=2;
-+						
-+						void *tmp = realloc(redRowsArray,(num_alloc*sizeof(int)));
-+						if(!tmp)
-+						{
-+							WerrorS("Woah dude! Couldn't realloc memory\n");
-+							exit(-1);
-+						}
-+						redRowsArray = (int*)tmp;
-+						redRowsArray[num_elts]=ii;
-+						num_elts++;
-+						//break;//for(int kk, since we have found one that is not in L	
-+						goto _start;	//mea culpa, mea culpa, mea maxima culpa
-+					}
-+				}//if(P->p!=NULL)
-+				pDelete(&(P->p));
-+			}//for k
-+		}//for jj
-+		_start:;
-+		idDelete(&L);
-+		delete P;
-+		idDelete(&initialForm);
-+	}//for(ii<ddineq-rowsize
-+// 	delete gamma;
-+	int offset=0;//needed for correction of redRowsArray[ii]
-+#ifndef NDEBUG
-+	printf("Removed %i of %i in preprocessing step\n",num_elts,ddineq->rowsize);
-+#endif
-+	for( int ii=0;ii<num_elts;ii++ )
-+	{
-+		dd_MatrixRowRemove(&ddineq,redRowsArray[ii]+1-offset);//cddlib sucks at enumeration
-+		offset++;
-+	}	
-+	free(redRowsArray);//NOTE May crash on some machines.
-+	/*And now for the strictly positive rows
-+	* Doesn't gain significant speedup
-+	*/
-+	/*int *posRowsArray=NULL;
-+	num_alloc=0;
-+	num_elts=0;
-+	for(int ii=0;ii<ddineq->rowsize;ii++)
-+	{
-+		int64vec *ivPos = new int64vec(this->numVars);
-+		for(int jj=0;jj<this->numVars;jj++)
-+			(*ivPos)[jj]=(int)mpq_get_d(ddineq->matrix[ii][jj+1]);
-+		bool isStrictlyPos=FALSE;
-+		int posCtr=0;		
-+		for(int jj=0;jj<this->numVars;jj++)
-+		{
-+			int64vec *ivCanonical = new int64vec(this->numVars);
-+			jj==0 ? (*ivCanonical)[ivPos->length()-1]=1 : (*ivCanonical)[jj-1]=1;
-+			if(dotProduct(*ivCanonical,*ivPos)!=0)
-+			{
-+				if ((*ivPos)[jj]>=0)
-+				{				
-+					posCtr++;				
-+				}
-+			}			
-+			delete ivCanonical;
-+		}
-+		if(posCtr==ivPos->length())
-+			isStrictlyPos=TRUE;
-+		if(isStrictlyPos==TRUE)
-+		{
-+			if(num_alloc==0)
-+				num_alloc += 1;
-+			else
-+				num_alloc += 1;
-+			void *tmp = realloc(posRowsArray,(num_alloc*sizeof(int)));
-+			if(!tmp)
-+			{
-+				WerrorS("Woah dude! Couldn't realloc memory\n");
-+				exit(-1);
-+			}
-+			posRowsArray = (int*)tmp;
-+			posRowsArray[num_elts]=ii;
-+			num_elts++;	
-+		}
-+		delete ivPos;
-+	}
-+	offset=0;
-+	for(int ii=0;ii<num_elts;ii++)
-+	{
-+		dd_MatrixRowRemove(&ddineq,posRowsArray[ii]+1-offset);
-+		offset++;
-+	}
-+	free(posRowsArray);*/
-+#endif
-+
-+	dd_MatrixCanonicalize(&ddineq, &ddlinset, &ddredrows, &ddnewpos, &dderr);	
-+	ddrows = ddineq->rowsize;	//Size of the matrix with redundancies removed
-+	ddcols = ddineq->colsize;
-+	
-+	this->ddFacets = dd_CopyMatrix(ddineq);
-+			
-+	/*Write the normals into class facet*/	
-+	facet *fAct; 	//pointer to active facet	
-+	int numNonFlip=0;
-+	for (int kk = 0; kk<ddrows; kk++)
-+	{
-+		int64 ggT=1;//NOTE Why does (int)mpq_get_d(ddineq->matrix[kk][1]) not work?
-+		int64vec *load = new int64vec(this->numVars);//int64vec to store a single facet normal that will then be stored via setFacetNormal
-+		for (int jj = 1; jj <ddcols; jj++)
-+		{
-+			int64 val;
-+			val = (int64)mpq_get_d(ddineq->matrix[kk][jj]);
-+			(*load)[jj-1] = val;	//store typecasted entry at pos jj-1 of load
-+			ggT = int64gcd(ggT,/*(int64&)foo*/val);
-+		}//for (int jj = 1; jj <ddcols; jj++)
-+		if(ggT>1)
-+		{
-+			for(int ll=0;ll<this->numVars;ll++)
-+				(*load)[ll] /= ggT;//make primitive vector
-+		}
-+		/*Quick'n'dirty hack for flippability. Executed only if gcone::hasHomInput==FALSE
-+		* Otherwise every facet intersects the positive orthant
-+		*/	
-+		if(gcone::hasHomInput==FALSE)
-+		{
-+			//TODO: No dP needed
-+			bool isFlip=FALSE;
-+			for(int jj = 0; jj<load->length(); jj++)
-+			{
-+// 				int64vec *ivCanonical = new int64vec(load->length());
-+// 				(*ivCanonical)[jj]=1;
-+// 				if (dotProduct(*load,*ivCanonical)<0)	
-+// 				{
-+// 					isFlip=TRUE;
-+// 					break;	//URGHS
-+// 				}
-+// 				delete ivCanonical;
-+				if((*load)[jj]<0)
-+				{
-+					isFlip=TRUE;
-+					break;
-+				}				
-+			}/*End of check for flippability*/
-+// 			if(iv64isStrictlyPositive(load))
-+// 				isFlip=TRUE;
-+			if(isFlip==FALSE)
-+			{
-+				this->numFacets++;
-+				numNonFlip++;
-+				if(this->numFacets==1)
-+				{
-+					facet *fRoot = new facet();
-+					this->facetPtr = fRoot;
-+					fAct = fRoot;							
-+				}
-+				else
-+				{
-+					fAct->next = new facet();
-+					fAct = fAct->next;
-+				}
-+				fAct->isFlippable=FALSE;
-+				fAct->setFacetNormal(load);
-+				fAct->setUCN(this->getUCN());
-+#ifndef NDEBUG
-+				printf("Marking facet (");load->show(1,0);printf(") as non flippable\n");		
-+#endif
-+			}
-+			else
-+			{
-+				this->numFacets++;
-+				if(this->numFacets==1)
-+				{
-+					facet *fRoot = new facet();
-+					this->facetPtr = fRoot;
-+					fAct = fRoot;
-+				}
-+				else
-+				{
-+					fAct->next = new facet();
-+					fAct = fAct->next;
-+				}
-+				fAct->isFlippable=TRUE;
-+				fAct->setFacetNormal(load);
-+				fAct->setUCN(this->getUCN());					
-+			}
-+		}//hasHomInput==FALSE
-+		else	//Every facet is flippable
-+		{	/*Now load should be full and we can call setFacetNormal*/					
-+			this->numFacets++;
-+			if(this->numFacets==1)
-+			{
-+				facet *fRoot = new facet();
-+				this->facetPtr = fRoot;
-+				fAct = fRoot;
-+			}
-+			else
-+			{
-+				fAct->next = new facet();
-+				fAct = fAct->next;
-+			}
-+			fAct->isFlippable=TRUE;
-+			fAct->setFacetNormal(load);
-+			fAct->setUCN(this->getUCN());					
-+		}//if (isFlippable==FALSE)
-+		delete load;				
-+	}//for (int kk = 0; kk<ddrows; kk++)
-+			
-+	//In cases like I=<x-1,y-1> there are only non-flippable facets...
-+	if(numNonFlip==this->numFacets)
-+	{
-+		WerrorS ("Only non-flippable facets. Terminating...\n");
-+// 		exit(-1);//Bit harsh maybe...
-+	}
-+			
-+	/*
-+	Now we should have a linked list containing the facet normals of those facets that are
-+	-irredundant
-+	-flipable
-+	Adressing is done via *facetPtr
-+	*/			
-+	if (compIntPoint==TRUE)
-+	{
-+		int64vec *iv = new int64vec(this->numVars);
-+		dd_MatrixPtr posRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
-+		int jj=1;
-+		for (int ii=0;ii<=this->numVars;ii++)
-+		{
-+			dd_set_si(posRestr->matrix[ii][jj],1);
-+			jj++;							
-+		}
-+		dd_MatrixAppendTo(&ddineq,posRestr);
-+		interiorPoint(ddineq, *iv);	//NOTE ddineq contains non-flippable facets
-+		this->setIntPoint(iv);	//stores the interior point in gcone::ivIntPt
-+		delete iv;
-+		dd_FreeMatrix(posRestr);
-+	}	
-+	//Clean up but don't delete the return value!	
-+	//dd_FreeMatrix(ddineq);	
-+	set_free(ddredrows);//check
-+	set_free(ddlinset);//check
-+	//free(ddnewpos);//<-- NOTE Here the crash occurs omAlloc issue?
-+#ifdef gfanp
-+	gettimeofday(&end, 0);
-+	time_getConeNormals += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-+#endif
-+
-+}//gcone::getConeNormals(ideal I)
-+		
-+/** \brief Compute the (codim-2)-facets of a given cone
-+ * This method is used during noRevS
-+ * Additionally we check whether the codim2-facet normal is strictly positive. Otherwise
-+ * the facet is marked as non-flippable.
-+ */
-+void gcone::getCodim2Normals(const gcone &gc)
-+{
-+#ifdef gfanp
-+	timeval start, end;
-+  	gettimeofday(&start, 0);
-+#endif
-+	//this->facetPtr->codim2Ptr = new facet(2);	//instantiate a (codim-2)-facet
-+	facet *fAct;
-+	fAct = this->facetPtr;		
-+	facet *codim2Act;
-+	//codim2Act = this->facetPtr->codim2Ptr;
-+	dd_MatrixPtr ddineq;//,P,ddakt;
-+	dd_ErrorType err;
-+	//ddineq = facets2Matrix(gc);	//get a matrix representation of the cone
-+	ddineq = dd_CopyMatrix(gc.ddFacets);
-+	/*Now set appropriate linearity*/
-+	for (int ii=0; ii<this->numFacets; ii++)			
-+	{	
-+		dd_rowset impl_linset, redset;
-+		dd_rowindex newpos;
-+		dd_MatrixPtr ddakt;
-+  		ddakt = dd_CopyMatrix(ddineq);
-+// 		ddakt->representation=dd_Inequality;	//Not using this makes it faster. But why does the quick check below still work?
-+// 		ddakt->representation=dd_Generator;
-+		set_addelem(ddakt->linset,ii+1);/*Now set appropriate linearity*/
-+#ifdef gfanp
-+		timeval t_ddMC_start, t_ddMC_end;
-+		gettimeofday(&t_ddMC_start,0);
-+#endif				
-+ 		//dd_MatrixCanonicalize(&ddakt, &impl_linset, &redset, &newpos, &err);
-+		dd_PolyhedraPtr ddpolyh;
-+		ddpolyh=dd_DDMatrix2Poly(ddakt, &err);
-+// 		ddpolyh=dd_DDMatrix2Poly2(ddakt, dd_MaxCutoff, &err);
-+		dd_MatrixPtr P;
-+		P=dd_CopyGenerators(ddpolyh);		
-+		dd_FreePolyhedra(ddpolyh);
-+		//TODO Call for one cone , normalize - check equalities - plus lineality -done
-+#ifdef gfanp
-+		gettimeofday(&t_ddMC_end,0);
-+		t_ddMC += (t_ddMC_end.tv_sec - t_ddMC_start.tv_sec + 1e-6*(t_ddMC_end.tv_usec - t_ddMC_start.tv_usec));
-+#endif	
-+		/* We loop through each row of P normalize it by making all
-+		* entries integer ones and add the resulting vector to the
-+		* int matrix facet::codim2Facets */
-+		for (int jj=1;jj<=/*ddakt*/P->rowsize;jj++)
-+		{					
-+			fAct->numCodim2Facets++;
-+			if(fAct->numCodim2Facets==1)					
-+			{						
-+				fAct->codim2Ptr = new facet(2);						
-+				codim2Act = fAct->codim2Ptr;
-+			}
-+			else
-+			{
-+				codim2Act->next = new facet(2);
-+				codim2Act = codim2Act->next;
-+			}
-+			int64vec *n = new int64vec(this->numVars);
-+#ifdef gfanp
-+			timeval t_mI_start, t_mI_end;
-+			gettimeofday(&t_mI_start,0);
-+#endif
-+			makeInt(P,jj,*n);
-+			/*for(int kk=0;kk<this->numVars;kk++)
-+			{
-+				int foo;
-+				foo = (int)mpq_get_d(ddakt->matrix[ii][kk+1]);
-+				(*n)[kk]=foo;
-+			}*/
-+#ifdef gfanp
-+			gettimeofday(&t_mI_end,0);
-+			t_mI += (t_mI_end.tv_sec - t_mI_start.tv_sec + 1e-6*(t_mI_end.tv_usec - t_mI_start.tv_usec));
-+#endif
-+			codim2Act->setFacetNormal(n);
-+			delete n;					
-+		}		
-+		/*We check whether the facet spanned by the codim-2 facets
-+		* intersects with the positive orthant. Otherwise we define this
-+		* facet to be non-flippable. Works since we set the appropriate 
-+		* linearity for ddakt above.
-+		*/
-+		//TODO It might be faster to compute jus the implied equations instead of a relative interior point
-+// 		int64vec *iv_intPoint = new int64vec(this->numVars);
-+// 		dd_MatrixPtr shiftMatrix;
-+// 		dd_MatrixPtr intPointMatrix;
-+// 		shiftMatrix = dd_CreateMatrix(this->numVars,this->numVars+1);
-+// 		for(int kk=0;kk<this->numVars;kk++)
-+// 		{
-+// 			dd_set_si(shiftMatrix->matrix[kk][0],1);
-+// 			dd_set_si(shiftMatrix->matrix[kk][kk+1],1);
-+// 		}
-+// 		intPointMatrix=dd_MatrixAppend(ddakt,shiftMatrix);
-+// #ifdef gfanp
-+// 		timeval t_iP_start, t_iP_end;
-+// 		gettimeofday(&t_iP_start, 0);
-+// #endif		
-+// 		interiorPoint(intPointMatrix,*iv_intPoint);
-+// // 		dd_rowset impl_linste,lbasis;
-+// // 		dd_LPSolutionPtr lps=NULL;
-+// // 		dd_ErrorType err;
-+// // 		dd_FindRelativeInterior(intPointMatrix, &impl_linset, &lbasis, &lps, &err);
-+// #ifdef gfanp
-+// 		gettimeofday(&t_iP_end, 0);
-+// 		t_iP += (t_iP_end.tv_sec - t_iP_start.tv_sec + 1e-6*(t_iP_end.tv_usec - t_iP_start.tv_usec));
-+// #endif
-+// 		for(int ll=0;ll<this->numVars;ll++)
-+// 		{
-+// 			if( (*iv_intPoint)[ll] < 0 )
-+// 			{
-+// 				fAct->isFlippable=FALSE;
-+// 				break;
-+// 			}
-+// 		}
-+		/*End of check*/
-+		/*This test should be way less time consuming*/
-+#ifdef gfanp
-+		timeval t_iP_start, t_iP_end;
-+		gettimeofday(&t_iP_start, 0);
-+#endif
-+		bool containsStrictlyPosRay=TRUE;
-+		for(int ii=0;ii<ddakt->rowsize;ii++)
-+		{
-+			containsStrictlyPosRay=TRUE;
-+			for(int jj=1;jj<this->numVars;jj++)
-+			{
-+				if(ddakt->matrix[ii][jj]<=0)
-+				{
-+					containsStrictlyPosRay=FALSE;
-+					break;
-+				}
-+			}
-+			if(containsStrictlyPosRay==TRUE)
-+				break;
-+		}
-+		if(containsStrictlyPosRay==FALSE)
-+		//TODO Not sufficient. Intersect with pos orthant for pos int
-+			fAct->isFlippable=FALSE;
-+#ifdef gfanp
-+		gettimeofday(&t_iP_end, 0);
-+		t_iP += (t_iP_end.tv_sec - t_iP_start.tv_sec + 1e-6*(t_iP_end.tv_usec - t_iP_start.tv_usec));
-+#endif
-+		/**/
-+		fAct = fAct->next;	
-+		dd_FreeMatrix(ddakt);
-+		dd_FreeMatrix(P);
-+	}//for 	
-+	dd_FreeMatrix(ddineq);
-+#ifdef gfanp
-+	gettimeofday(&end, 0);
-+	time_getCodim2Normals += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-+#endif
-+}
-+		
-+/** Really extremal rays this time ;)
-+* Extremal rays are unique modulo the homogeneity space.
-+* Therefore we dd_MatrixAppend gc->ddFacets and gcone::dd_LinealitySpace
-+* into ddineq. Next we compute the extremal rays of the so given subspace.
-+* Figuring out whether a ray belongs to a given facet(normal) is done by
-+* checking whether the inner product of the ray with the normal is zero.
-+* We use ivAdd here which returns a new int64vec. Therefore we need to avoid
-+* a memory leak which would be cause by the line 
-+* iv=ivAdd(iv,b)
-+* So we keep pointer tmp to iv and delete(tmp), so there should not occur a 
-+* memleak
-+* TODO normalization
-+*/
-+void gcone::getExtremalRays(const gcone &gc)
-+{
-+#ifdef gfanp
-+	timeval start, end;
-+	gettimeofday(&start, 0);
-+	timeval poly_start, poly_end;
-+	gettimeofday(&poly_start,0);
-+#endif
-+	//Add lineality space - dd_LinealitySpace
-+	dd_MatrixPtr ddineq;
-+	dd_ErrorType err;	
-+	ddineq = (dd_LinealitySpace->rowsize>0) ? dd_AppendMatrix(gc.ddFacets,gcone::dd_LinealitySpace) : dd_CopyMatrix(gc.ddFacets);
-+	/* In case the input is non-homogeneous we add constrains for the positive orthant.
-+	* This is justified by the fact that for non-homog ideals we only consider the 
-+	* restricted fan. This way we can be sure to find strictly positive interior points.
-+	* This in turn makes life easy when checking for flippability!
-+	* Drawback: Makes the LP larger so probably slows down computations a wee bit.
-+	*/
-+	dd_MatrixPtr ddPosRestr;
-+	if(hasHomInput==FALSE)
-+	{
-+		dd_MatrixPtr tmp;
-+		ddPosRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
-+		for(int ii=0;ii<this->numVars;ii++)
-+			dd_set_si(ddPosRestr->matrix[ii][ii+1],1);
-+		dd_MatrixAppendTo(&ddineq,ddPosRestr);
-+		assert(ddineq);
-+		dd_FreeMatrix(ddPosRestr);
-+	}	
-+	dd_PolyhedraPtr ddPolyh;
-+	ddPolyh = dd_DDMatrix2Poly(ddineq, &err);
-+	dd_MatrixPtr P;
-+	P=dd_CopyGenerators(ddPolyh);//Here we actually compute the rays!
-+	dd_FreePolyhedra(ddPolyh);
-+	dd_FreeMatrix(ddineq);
-+#ifdef gfanp
-+	gettimeofday(&poly_end,0);
-+	t_ddPolyh += (poly_end.tv_sec - poly_start.tv_sec + 1e-6*(poly_end.tv_usec - poly_start.tv_usec));
-+#endif
-+	/* Compute interior point on the fly*/
-+	int64vec *ivIntPointOfCone = new int64vec(this->numVars);
-+	int64vec *foo = new int64vec(this->numVars);
-+	for(int ii=0;ii<P->rowsize;ii++)
-+	{
-+		int64vec *tmp = ivIntPointOfCone;
-+		makeInt(P,ii+1,*foo);
-+		ivIntPointOfCone = iv64Add(ivIntPointOfCone,foo);
-+		delete tmp;
-+	}
-+	delete foo;
-+	int64 ggT=(*ivIntPointOfCone)[0];
-+	for (int ii=0;ii<(this->numVars);ii++)
-+	{
-+		if( (*ivIntPointOfCone)[ii]>INT_MAX ) 
-+			WarnS("Interior point exceeds INT_MAX!\n");
-+		//Compute intgcd
-+		ggT=int64gcd(ggT,(*ivIntPointOfCone)[ii]);
-+	}
-+	
-+	//Divide out a common gcd > 1
-+	if(ggT>1)
-+	{
-+		for(int ii=0;ii<this->numVars;ii++)
-+		{
-+			(*ivIntPointOfCone)[ii] /= ggT;
-+			if( (*ivIntPointOfCone)[ii]>INT_MAX ) WarnS("Interior point still exceeds INT_MAX after GCD!\n");
-+		}
-+	}
-+
-+	/*For homogeneous input (like Det3,3,5) the int points may be negative. So add a suitable multiple of (1,_,1)*/
-+	if(hasHomInput==TRUE && iv64isStrictlyPositive(ivIntPointOfCone)==FALSE)
-+	{
-+		int64vec *ivOne = new int64vec(this->numVars);
-+		int maxNegEntry=0;
-+		for(int ii=0;ii<this->numVars;ii++)
-+		{
-+// 			(*ivOne)[ii]=1;
-+			if ((*ivIntPointOfCone)[ii]<maxNegEntry) maxNegEntry=(*ivIntPointOfCone)[ii];
-+		}
-+		maxNegEntry *= -1;
-+		maxNegEntry++;//To be on the safe side
-+		for(int ii=0;ii<this->numVars;ii++)
-+			(*ivOne)[ii]=maxNegEntry;
-+		int64vec *tmp=ivIntPointOfCone;
-+		ivIntPointOfCone=iv64Add(ivIntPointOfCone,ivOne);
-+		delete(tmp);
-+// 		while( !iv64isStrictlyPositive(ivIntPointOfCone) )
-+// 		{
-+// 			int64vec *tmp = ivIntPointOfCone;
-+// 			for(int jj=0;jj<this->numVars;jj++)
-+// 				(*ivOne)[jj] = (*ivOne)[jj] << 1; //times 2
-+// 			ivIntPointOfCone = ivAdd(ivIntPointOfCone,ivOne);
-+// 			delete tmp;				
-+// 		}
-+		delete ivOne;
-+		int64 ggT=(*ivIntPointOfCone)[0];
-+		for(int ii=0;ii<this->numVars;ii++)
-+			ggT=int64gcd( ggT, (*ivIntPointOfCone)[ii]);
-+		if(ggT>1)
-+		{
-+			for(int jj=0;jj<this->numVars;jj++)
-+				(*ivIntPointOfCone)[jj] /= ggT;
-+		}
-+	}
-+// 	assert(iv64isStrictlyPositive(ivIntPointOfCone));
-+	
-+	this->setIntPoint(ivIntPointOfCone);
-+	delete(ivIntPointOfCone);
-+	/* end of interior point computation*/
-+	
-+	//Loop through the rows of P and check whether fNormal*row[i]=0 => row[i] belongs to fNormal
-+	int rows=P->rowsize;
-+	facet *fAct=gc.facetPtr;
-+	//Construct an array to hold the extremal rays of the cone
-+	this->gcRays = (int64vec**)omAlloc0(sizeof(int64vec*)*P->rowsize);	
-+	for(int ii=0;ii<P->rowsize;ii++)
-+	{
-+		int64vec *rowvec = new int64vec(this->numVars);
-+		makeInt(P,ii+1,*rowvec);//get an integer entry instead of rational, rowvec is primitve
-+		this->gcRays[ii] = iv64Copy(rowvec);
-+		delete rowvec;
-+	}	
-+	this->numRays=P->rowsize;
-+	//Check which rays belong to which facet
-+	while(fAct!=NULL)
-+	{
-+		const int64vec *fNormal;// = new int64vec(this->numVars);
-+		fNormal = fAct->getRef2FacetNormal();//->getFacetNormal();
-+		int64vec *ivIntPointOfFacet = new int64vec(this->numVars);
-+		for(int ii=0;ii<rows;ii++)
-+		{			
-+ 			if(dotProduct(*fNormal,this->gcRays[ii])==0)
-+			{
-+				int64vec *tmp = ivIntPointOfFacet;//Prevent memleak
-+				fAct->numCodim2Facets++;
-+				facet *codim2Act;
-+				if(fAct->numCodim2Facets==1)					
-+				{						
-+					fAct->codim2Ptr = new facet(2);						
-+					codim2Act = fAct->codim2Ptr;
-+				}
-+				else
-+				{
-+					codim2Act->next = new facet(2);
-+					codim2Act = codim2Act->next;
-+				}
-+				//codim2Act->setFacetNormal(rowvec);
-+				//Rather just let codim2Act point to the corresponding int64vec of gcRays
-+				codim2Act->fNormal=this->gcRays[ii];
-+				fAct->numRays++;				 
-+				//Memleak avoided via tmp
-+				ivIntPointOfFacet=iv64Add(ivIntPointOfFacet,this->gcRays[ii]);
-+				//Now tmp still points to the OLD address of ivIntPointOfFacet
-+				delete(tmp);
-+					
-+			}
-+		}//For non-homog input ivIntPointOfFacet should already be >0 here
-+// 		if(!hasHomInput) {assert(iv64isStrictlyPositive(ivIntPointOfFacet));}
-+		//if we have no strictly pos ray but the input is homogeneous
-+		//then add a suitable multiple of (1,...,1)
-+		if( !iv64isStrictlyPositive(ivIntPointOfFacet) && hasHomInput==TRUE)
-+		{
-+			int64vec *ivOne = new int64vec(this->numVars);
-+			for(int ii=0;ii<this->numVars;ii++)
-+				(*ivOne)[ii]=1;
-+			while( !iv64isStrictlyPositive(ivIntPointOfFacet) )
-+			{
-+				int64vec *tmp = ivIntPointOfFacet;
-+				for(int jj=0;jj<this->numVars;jj++)
-+				{
-+					(*ivOne)[jj] = (*ivOne)[jj] << 1; //times 2
-+				}
-+				ivIntPointOfFacet = iv64Add(ivIntPointOfFacet/*diff*/,ivOne);
-+				delete tmp;				
-+			}
-+			delete ivOne;
-+		}
-+		int64 ggT=(*ivIntPointOfFacet)[0];
-+		for(int ii=0;ii<this->numVars;ii++)
-+			ggT=int64gcd(ggT,(*ivIntPointOfFacet)[ii]);
-+		if(ggT>1)
-+		{
-+			for(int ii=0;ii<this->numVars;ii++)
-+				(*ivIntPointOfFacet)[ii] /= ggT;
-+		}			
-+		fAct->setInteriorPoint(ivIntPointOfFacet);
-+		
-+		delete(ivIntPointOfFacet);
-+		//Now (if we have at least 3 variables) do a bubblesort on the rays
-+		/*if(this->numVars>2)
-+		{
-+			facet *A[fAct->numRays-1];
-+			facet *f2Act=fAct->codim2Ptr;
-+			for(unsigned ii=0;ii<fAct->numRays;ii++)
-+			{
-+				A[ii]=f2Act;
-+				f2Act=f2Act->next;
-+			}
-+			bool exchanged=FALSE;
-+			unsigned n=fAct->numRays-1;
-+			do
-+			{
-+				exchanged=FALSE;//n=fAct->numRays-1;				
-+				for(unsigned ii=0;ii<=n-1;ii++)
-+				{					
-+					if((A[ii]->fNormal)->compare((A[ii+1]->fNormal))==1)
-+					{
-+						//Swap rays
-+						cout << "Swapping ";
-+						A[ii]->fNormal->show(1,0); cout << " with "; A[ii+1]->fNormal->show(1,0); cout << endl;
-+						A[ii]->next=A[ii+1]->next;
-+						if(ii>0)
-+							A[ii-1]->next=A[ii+1];
-+						A[ii+1]->next=A[ii];
-+						if(ii==0)
-+							fAct->codim2Ptr=A[ii+1];
-+						//end swap
-+						facet *tmp=A[ii];//swap in list
-+						A[ii+1]=A[ii];
-+						A[ii]=tmp;
-+// 						tmp=NULL;			
-+					}					
-+				}
-+				n--;			
-+			}while(exchanged==TRUE && n>=0);
-+		}*///if pVariables>2
-+// 		delete fNormal;		
-+		fAct = fAct->next;
-+	}//end of facet checking
-+	dd_FreeMatrix(P);
-+	//Now all extremal rays should be set w.r.t their respective fNormal
-+	//TODO Not sufficient -> vol2 II/125&127
-+	//NOTE Sufficient according to cddlibs doc. These ARE rays
-+	//What the hell... let's just take interior points
-+	if(gcone::hasHomInput==FALSE)
-+	{
-+		fAct=gc.facetPtr;
-+		while(fAct!=NULL)
-+		{
-+// 			bool containsStrictlyPosRay=FALSE;
-+// 			facet *codim2Act;
-+// 			codim2Act = fAct->codim2Ptr;
-+// 			while(codim2Act!=NULL)
-+// 			{
-+// 				int64vec *rayvec;
-+// 				rayvec = codim2Act->getFacetNormal();//Mind this is no normal but a ray!
-+// 				//int negCtr=0;
-+// 				if(iv64isStrictlyPositive(rayvec))
-+// 				{
-+// 					containsStrictlyPosRay=TRUE;
-+// 					delete(rayvec);
-+// 					break;
-+// 				}				
-+// 				delete(rayvec);
-+// 				codim2Act = codim2Act->next;
-+// 			}
-+// 			if(containsStrictlyPosRay==FALSE)
-+// 				fAct->isFlippable=FALSE;
-+			if(!iv64isStrictlyPositive(fAct->interiorPoint))
-+				fAct->isFlippable=FALSE;
-+			fAct = fAct->next;
-+		}
-+	}//hasHomInput?	
-+#ifdef gfanp
-+	gettimeofday(&end, 0);
-+	t_getExtremalRays += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-+#endif	
-+}
-+
-+/** Order the spanning rays in a lex way hopefully using qsort()*/
-+void gcone::orderRays()
-+{
-+//   qsort(gcRays,sizeof(int64vec),int64vec::compare);
-+}
-+	
-+inline bool gcone::iv64isStrictlyPositive(const int64vec * iv64)
-+{
-+	bool res=TRUE;
-+	for(int ii=0;ii<iv64->length();ii++)
-+	{
-+		if((*iv64)[ii]<=0)
-+		{
-+			res=FALSE;
-+			break;
-+		}		
-+	}
-+	return res;
-+}
-+
-+/** \brief Compute the Groebner Basis on the other side of a shared facet 
-+ *
-+ * Implements algorithm 4.3.2 from Anders' thesis.
-+ * As shown there it is not necessary to compute an interior point. The knowledge of the facet normal
-+ * suffices. A term \f$ x^\gamma \f$ of \f$ g \f$ is in \f$  in_\omega(g) \f$ iff \f$ \gamma - leadexp(g)\f$
-+ * is parallel to \f$ leadexp(g) \f$
-+ * Parallelity is checked using basic linear algebra. See gcone::isParallel.
-+ * Other possibilities include computing the rank of the matrix consisting of the vectors in question and
-+ * computing an interior point of the facet and taking all terms having the same weight with respect 
-+ * to this interior point.
-+ *\param ideal, facet
-+ * Input: a marked,reduced Groebner basis and a facet
-+ */
-+inline void gcone::flip(ideal gb, facet *f)		//Compute "the other side"
-+{	
-+#ifdef gfanp
-+	timeval start, end;
-+	gettimeofday(&start, 0);
-+#endif		
-+	int64vec *fNormal;// = new int64vec(this->numVars);	//facet normal, check for parallelity			
-+	fNormal = f->getFacetNormal();	//read this->fNormal;
-+#ifndef NDEBUG
-+// 	std::cout << "running gcone::flip" << std::endl;
-+	printf("flipping UCN %i over facet",this->getUCN());
-+	fNormal->show(1,0);
-+	printf(") with UCN %i\n",f->getUCN() );	
-+#endif
-+	if(this->getUCN() != f->getUCN())
-+	{
-+		WerrorS("Uh oh... Trying to flip over facet with incompatible UCN");
-+		exit(-1);
-+	}
-+	/*1st step: Compute the initial ideal*/
-+	/*poly initialFormElement[IDELEMS(gb)];*/	//array of #polys in GB to store initial form
-+	ideal initialForm=idInit(IDELEMS(gb),this->gcBasis->rank);
-+	
-+	computeInv(gb,initialForm,*fNormal);
-+
-+#ifndef NDEBUG
-+/*	cout << "Initial ideal is: " << endl;
-+	idShow(initialForm);
-+	//f->printFlipGB();*/
-+// 	cout << "===" << endl;
-+#endif			
-+	/*2nd step: lift initial ideal to a GB of the neighbouring cone using minus alpha as weight*/
-+	/*Substep 2.1
-+	compute $G_{-\alpha}(in_v(I)) 
-+	see journal p. 66
-+	NOTE Check for different rings. Prolly it will not always be necessary to add a weight, if the
-+	srcRing already has a weighted ordering
-+	*/
-+	ring srcRing=currRing;
-+	ring tmpRing;
-+			
-+	if( (srcRing->order[0]!=ringorder_a))
-+	{
-+		int64vec *iv;// = new int64vec(this->numVars);
-+		iv = ivNeg(fNormal);//ivNeg uses iv64Copy -> new
-+// 		tmpRing=rCopyAndAddWeight(srcRing,ivNeg(fNormal));
-+		tmpRing=rCopyAndAddWeight(srcRing,iv);
-+		delete iv;
-+	}
-+	else
-+	{
-+		tmpRing=rCopy0(srcRing);
-+		int length=fNormal->length();
-+		int *A=(int *)omAlloc0(length*sizeof(int));
-+		for(int jj=0;jj<length;jj++)
-+		{
-+			A[jj]=-(*fNormal)[jj];
-+		}
-+		omFree(tmpRing->wvhdl[0]);
-+		tmpRing->wvhdl[0]=(int*)A;
-+		tmpRing->block1[0]=length;
-+		rComplete(tmpRing);
-+		//omFree(A);
-+	}
-+  	delete fNormal; 
-+	rChangeCurrRing(tmpRing);	
-+			
-+	ideal ina;			
-+	ina=idrCopyR(initialForm,srcRing);
-+	idDelete(&initialForm);
-+	ideal H;
-+//  	H=kStd(ina,NULL,isHomog,NULL);	//we know it is homogeneous
-+#ifdef gfanp
-+	timeval t_kStd_start, t_kStd_end;
-+	gettimeofday(&t_kStd_start,0);
-+#endif
-+	if(gcone::hasHomInput==TRUE)
-+		H=kStd(ina,NULL,isHomog,NULL/*,gcone::hilbertFunction*/);
-+	else
-+		H=kStd(ina,NULL,isNotHomog,NULL);	//This is \mathcal(G)_{>_-\alpha}(in_v(I))
-+#ifdef gfanp
-+	gettimeofday(&t_kStd_end, 0);
-+	t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
-+#endif
-+	idSkipZeroes(H);
-+	idDelete(&ina);
-+
-+	/*Substep 2.2
-+	do the lifting and mark according to H
-+	*/
-+	rChangeCurrRing(srcRing);
-+	ideal srcRing_H;
-+	ideal srcRing_HH;			
-+	srcRing_H=idrCopyR(H,tmpRing);
-+	//H is needed further below, so don't idDelete here
-+ 	srcRing_HH=ffG(srcRing_H,this->gcBasis);
-+ 	idDelete(&srcRing_H);
-+		
-+	/*Substep 2.2.1
-+	 * Mark according to G_-\alpha
-+	 * Here we have a minimal basis srcRing_HH. In order to turn this basis into a reduced basis
-+	 * we have to compute an interior point of C(srcRing_HH). For this we need to know the cone
-+	 * represented by srcRing_HH MARKED ACCORDING TO G_{-\alpha}
-+	 * Thus we check whether the leading monomials of srcRing_HH and srcRing_H coincide. If not we 
-+	 * compute the difference accordingly
-+	*/
-+#ifdef gfanp
-+	timeval t_markings_start, t_markings_end;
-+	gettimeofday(&t_markings_start, 0);
-+#endif		
-+	bool markingsAreCorrect=FALSE;
-+	dd_MatrixPtr intPointMatrix;
-+	int iPMatrixRows=0;
-+	dd_rowrange aktrow=0;			
-+	for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
-+	{
-+		poly aktpoly=(poly)srcRing_HH->m[ii];//This is a pointer, so don't pDelete
-+		iPMatrixRows = iPMatrixRows+pLength(aktpoly);		
-+	}
-+	/* additionally one row for the standard-simplex and another for a row that becomes 0 during
-+	 * construction of the differences
-+	 */
-+	intPointMatrix = dd_CreateMatrix(iPMatrixRows+2,this->numVars+1); 
-+	intPointMatrix->numbtype=dd_Integer;	//NOTE: DO NOT REMOVE OR CHANGE TO dd_Rational
-+	
-+	for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
-+	{
-+		markingsAreCorrect=FALSE;	//crucial to initialise here
-+		poly aktpoly=srcRing_HH->m[ii]; //Only a pointer, so don't pDelete
-+		/*Comparison of leading monomials is done via exponent vectors*/
-+		for (int jj=0;jj<IDELEMS(H);jj++)
-+		{
-+			int *src_ExpV = (int *)omAlloc((this->numVars+1)*sizeof(int));
-+			int *dst_ExpV = (int *)omAlloc((this->numVars+1)*sizeof(int));
-+			pGetExpV(aktpoly,src_ExpV);
-+			rChangeCurrRing(tmpRing);	//this ring change is crucial!
-+			poly p=pCopy(H->m[ii]);
-+			pGetExpV(p/*pCopy(H->m[ii])*/,dst_ExpV);
-+			pDelete(&p);
-+			rChangeCurrRing(srcRing);
-+			bool expVAreEqual=TRUE;
-+			for (int kk=1;kk<=this->numVars;kk++)
-+			{
-+#ifndef NDEBUG
-+// 				cout << src_ExpV[kk] << "," << dst_ExpV[kk] << endl;
-+#endif
-+				if (src_ExpV[kk]!=dst_ExpV[kk])
-+				{
-+					expVAreEqual=FALSE;
-+				}
-+			}								
-+			if (expVAreEqual==TRUE)
-+			{
-+				markingsAreCorrect=TRUE; //everything is fine
-+#ifndef NDEBUG
-+// 				cout << "correct markings" << endl;
-+#endif
-+			}//if (pHead(aktpoly)==pHead(H->m[jj])
-+			omFree(src_ExpV);
-+			omFree(dst_ExpV);
-+		}//for (int jj=0;jj<IDELEMS(H);jj++)
-+		
-+		int *leadExpV=(int *)omAlloc((this->numVars+1)*sizeof(int));
-+		if (markingsAreCorrect==TRUE)
-+		{
-+			pGetExpV(aktpoly,leadExpV);
-+		}
-+		else
-+		{
-+			rChangeCurrRing(tmpRing);
-+			pGetExpV(pHead(H->m[ii]),leadExpV); //We use H->m[ii] as leading monomial
-+			rChangeCurrRing(srcRing);
-+		}
-+		/*compute differences of the expvects*/				
-+		while (pNext(aktpoly)!=NULL)
-+		{
-+			int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
-+			/*The following if-else-block makes sure the first term (i.e. the wrongly marked term) 
-+			is not omitted when computing the differences*/
-+			if(markingsAreCorrect==TRUE)
-+			{
-+				aktpoly=pNext(aktpoly);
-+				pGetExpV(aktpoly,v);
-+			}
-+			else
-+			{
-+				pGetExpV(pHead(aktpoly),v);
-+				markingsAreCorrect=TRUE;
-+			}
-+			int ctr=0;
-+			for (int jj=0;jj<this->numVars;jj++)
-+			{				
-+				/*Store into ddMatrix*/				
-+				if(leadExpV[jj+1]-v[jj+1])
-+					ctr++;
-+				dd_set_si(intPointMatrix->matrix[aktrow][jj+1],leadExpV[jj+1]-v[jj+1]);
-+			}
-+			/*It ought to be more sensible to avoid 0-rows in the first place*/
-+// 			if(ctr==this->numVars)//We have a 0-row
-+// 				dd_MatrixRowRemove(&intPointMatrix,aktrow);
-+// 			else
-+				aktrow +=1;
-+			omFree(v);
-+		}
-+		omFree(leadExpV);
-+	}//for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
-+#ifdef gfanp
-+	gettimeofday(&t_markings_end, 0);
-+	t_markings += (t_markings_end.tv_sec - t_markings_start.tv_sec + 1e-6*(t_markings_end.tv_usec - t_markings_start.tv_usec));
-+#endif
-+	/*Now it is safe to idDelete(H)*/
-+	idDelete(&H);
-+	/*Preprocessing goes here since otherwise we would delete the constraint
-+	* for the standard simplex.
-+	*/
-+	preprocessInequalities(intPointMatrix);
-+	/*Now we add the constraint for the standard simplex*/
-+// 	dd_set_si(intPointMatrix->matrix[aktrow][0],-1);
-+// 	for (int jj=1;jj<=this->numVars;jj++)
-+// 	{
-+// 		dd_set_si(intPointMatrix->matrix[aktrow][jj],1);
-+// 	}
-+	//Let's make sure we compute interior points from the positive orthant
-+// 	dd_MatrixPtr posRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
-+// 	
-+// 	int jj=1;
-+// 	for (int ii=0;ii<this->numVars;ii++)
-+// 	{
-+// 		dd_set_si(posRestr->matrix[ii][jj],1);
-+// 		jj++;							
-+// 	}
-+	/*We create a matrix containing the standard simplex
-+	* and constraints to assure a strictly positive point
-+	* is computed */
-+	dd_MatrixPtr posRestr = dd_CreateMatrix(this->numVars+1, this->numVars+1);
-+	for(int ii=0;ii<posRestr->rowsize;ii++)
-+	{
-+		if(ii==0)
-+		{
-+			dd_set_si(posRestr->matrix[ii][0],-1);
-+			for(int jj=1;jj<=this->numVars;jj++)			
-+				dd_set_si(posRestr->matrix[ii][jj],1);			
-+		}
-+		else
-+		{
-+			/** Set all variables to \geq 1/10. YMMV but this choice is pretty equal*/
-+			dd_set_si2(posRestr->matrix[ii][0],-1,2);
-+			dd_set_si(posRestr->matrix[ii][ii],1);
-+		}
-+	}
-+	dd_MatrixAppendTo(&intPointMatrix,posRestr);
-+	dd_FreeMatrix(posRestr);
-+
-+	int64vec *iv_weight = new int64vec(this->numVars);
-+#ifdef gfanp
-+	timeval t_dd_start, t_dd_end;
-+	gettimeofday(&t_dd_start, 0);
-+#endif
-+	dd_ErrorType err;
-+	dd_rowset implLin, redrows;
-+	dd_rowindex newpos;
-+
-+	//NOTE Here we should remove interiorPoint and instead
-+	// create and ordering like (a(omega),a(fNormal),dp)
-+// 	if(this->ivIntPt==NULL)
-+		interiorPoint(intPointMatrix, *iv_weight);	//iv_weight now contains the interior point
-+// 	else
-+// 		iv_weight=this->getIntPoint();
-+	dd_FreeMatrix(intPointMatrix);
-+	/*Crude attempt for interior point */
-+	/*dd_PolyhedraPtr ddpolyh;
-+	dd_ErrorType err;
-+	dd_rowset impl_linset,redset;
-+	dd_rowindex newpos;
-+	dd_MatrixCanonicalize(&intPointMatrix, &impl_linset, &redset, &newpos, &err);
-+	ddpolyh=dd_DDMatrix2Poly(intPointMatrix, &err);
-+	dd_MatrixPtr P;
-+	P=dd_CopyGenerators(ddpolyh);
-+	dd_FreePolyhedra(ddpolyh);
-+	for(int ii=0;ii<P->rowsize;ii++)
-+	{
-+ 		int64vec *iv_row=new int64vec(this->numVars);
-+		makeInt(P,ii+1,*iv_row);
-+		iv_weight =ivAdd(iv_weight, iv_row);
-+		delete iv_row;
-+	}
-+	dd_FreeMatrix(P);
-+	dd_FreeMatrix(intPointMatrix);*/
-+#ifdef gfanp
-+	gettimeofday(&t_dd_end, 0);
-+	t_dd += (t_dd_end.tv_sec - t_dd_start.tv_sec + 1e-6*(t_dd_end.tv_usec - t_dd_start.tv_usec));
-+#endif	
-+	
-+	/*Step 3
-+	* turn the minimal basis into a reduced one */			
-+	// NOTE May assume that at this point srcRing already has 3 blocks of orderins, starting with a
-+	// Thus: 
-+	//ring dstRing=rCopyAndChangeWeight(srcRing,iv_weight);	
-+	ring dstRing=rCopy0(tmpRing);
-+	int length=iv_weight->length();
-+	int *A=(int *)omAlloc0(length*sizeof(int));
-+	for(int jj=0;jj<length;jj++)
-+	{
-+		A[jj]=(*iv_weight)[jj];
-+	}
-+	dstRing->wvhdl[0]=(int*)A;
-+	rComplete(dstRing);
-+	rChangeCurrRing(dstRing);
-+ 	rDelete(tmpRing);
-+	delete iv_weight;
-+
-+	ideal dstRing_I;			
-+	dstRing_I=idrCopyR(srcRing_HH,srcRing);
-+	idDelete(&srcRing_HH); //Hmm.... causes trouble - no more
-+	//dstRing_I=idrCopyR(inputIdeal,srcRing);
-+	BITSET save=test;
-+	test|=Sy_bit(OPT_REDSB);
-+	test|=Sy_bit(OPT_REDTAIL);
-+#ifndef NDEBUG
-+// 	test|=Sy_bit(6);	//OPT_DEBUG
-+#endif
-+	ideal tmpI;
-+	//NOTE Any of the two variants of tmpI={idrCopy(),dstRing_I} does the trick
-+	//tmpI = idrCopyR(this->inputIdeal,this->baseRing);
-+	tmpI = dstRing_I;
-+#ifdef gfanp
-+	gettimeofday(&t_kStd_start,0);
-+#endif
-+	if(gcone::hasHomInput==TRUE)
-+		dstRing_I=kStd(tmpI,NULL,isHomog,NULL/*,gcone::hilbertFunction*/);
-+	else
-+		dstRing_I=kStd(tmpI,NULL,isNotHomog,NULL);
-+#ifdef gfanp
-+	gettimeofday(&t_kStd_end, 0);
-+	t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
-+#endif
-+	idDelete(&tmpI);
-+	idNorm(dstRing_I);			
-+// 	kInterRed(dstRing_I);
-+	idSkipZeroes(dstRing_I);
-+	test=save;
-+	/*End of step 3 - reduction*/
-+			
-+	f->setFlipGB(dstRing_I);//store the flipped GB
-+// 	idDelete(&dstRing_I);
-+	f->flipRing=rCopy(dstRing);	//store the ring on the other side
-+#ifndef NDEBUG
-+ 	printf("Flipped GB is UCN %i:\n",counter+1);
-+ 	idDebugPrint(dstRing_I);
-+	printf("\n");
-+#endif	
-+	idDelete(&dstRing_I);	
-+	rChangeCurrRing(srcRing);	//return to the ring we started the computation of flipGB in
-+ 	rDelete(dstRing);
-+#ifdef gfanp
-+	gettimeofday(&end, 0);
-+	time_flip += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-+#endif
-+}//void flip(ideal gb, facet *f)
-+
-+/** \brief A slightly different approach to flipping
-+* Here we use the fact that in_v(in_u(I))=in_(u+eps*v)(I). Therefore, we do no longer
-+* need to compute an interior point and run BBA on the minimal basis but we can rather
-+* use the ordering (a(omega),a(fNormal),dp)
-+* The second parameter facet *f must not be const since we need to store f->flipGB
-+* Problem: Assume we start in a cone with ordering (dp,C). Then \f$ in_\omega(I) \f$
-+* will be from a ring with (a(),dp,C) and our resulting cone from (a(),a(),dp,C). Hence a way
-+* must be found to circumvent the sequence of a()'s growing to a ridiculous size.
-+* Therefore: We use (a(),a(),dp,C) for the computation of the reduced basis. But then we 
-+* do have an interior point of the cone by adding the extremal rays. So we replace 
-+* the latter cone by a cone with (a(sum_of_rays),dp,C). 
-+* Con: It's incredibly ugly
-+* Pro: No messing around with readConeFromFile()
-+* Is there a way to construct a vector from \f$ \omega \f$ and the facet normal?
-+*/
-+inline void gcone::flip2(const ideal &gb, facet *f)
-+{
-+#ifdef gfanp
-+	timeval start, end;
-+	gettimeofday(&start, 0);
-+#endif
-+	const int64vec *fNormal;
-+	fNormal = f->getRef2FacetNormal();/*->getFacetNormal();*/	//read this->fNormal;
-+#ifndef NDEBUG
-+// 	printf("flipping UCN %i over facet(",this->getUCN());
-+// 	fNormal->show(1,0);
-+// 	printf(") with UCN %i\n",f->getUCN());	
-+#endif
-+	if(this->getUCN() != f->getUCN())
-+	{	printf("%i vs %i\n",this->getUCN(), f->getUCN() );
-+		WerrorS("Uh oh... Trying to flip over facet with incompatible UCN");
-+		exit(-1);
-+	}
-+	/*1st step: Compute the initial ideal*/
-+	ideal initialForm=idInit(IDELEMS(gb),this->gcBasis->rank);	
-+	computeInv( gb, initialForm, *fNormal );
-+	ring srcRing=currRing;
-+	ring tmpRing;
-+	
-+	const int64vec *intPointOfFacet;
-+	intPointOfFacet=f->getInteriorPoint();
-+	//Now we need two blocks of ringorder_a!
-+	//May assume the same situation as in flip() here			
-+	if( (srcRing->order[0]!=ringorder_a/*64*/) && (srcRing->order[1]!=ringorder_a/*64*/) )
-+	{
-+		int64vec *iv = new int64vec(this->numVars);//init with 1s, since we do not need a 2nd block here but later
-+// 		int64vec *iv_foo = new int64vec(this->numVars,1);//placeholder
-+		int64vec *ivw = ivNeg(const_cast<int64vec*>(fNormal));		
-+		tmpRing=rCopyAndAddWeight2(srcRing,ivw/*intPointOfFacet*/,iv);
-+		delete iv;delete ivw;
-+// 		delete iv_foo;
-+	}
-+	else 
-+	{
-+		int64vec *iv=new int64vec(this->numVars);
-+		int64vec *ivw=ivNeg(const_cast<int64vec*>(fNormal));
-+		tmpRing=rCopyAndAddWeight2(srcRing,ivw,iv);
-+		delete iv; delete ivw;
-+		/*tmpRing=rCopy0(srcRing);
-+		int length=fNormal->length();
-+		int *A1=(int *)omAlloc0(length*sizeof(int));
-+		int *A2=(int *)omAlloc0(length*sizeof(int));
-+		for(int jj=0;jj<length;jj++)
-+		{
-+			A1[jj] = -(*fNormal)[jj];
-+			A2[jj] = 1;//-(*fNormal)[jj];//NOTE Do we need this here? This is only the facet ideal
-+		}
-+		omFree(tmpRing->wvhdl[0]);
-+		if(tmpRing->wvhdl[1]!=NULL)
-+			omFree(tmpRing->wvhdl[1]);
-+		tmpRing->wvhdl[0]=(int*)A1;		
-+		tmpRing->block1[0]=length;
-+		tmpRing->wvhdl[1]=(int*)A2;		
-+		tmpRing->block1[1]=length;
-+		rComplete(tmpRing);*/
-+	}
-+// 	delete fNormal; //NOTE Do not delete when using getRef2FacetNormal();
-+	rChangeCurrRing(tmpRing);	
-+	//Now currRing should have (a(),a(),dp,C)		
-+	ideal ina;			
-+	ina=idrCopyR(initialForm,srcRing);
-+	idDelete(&initialForm);
-+	ideal H;
-+#ifdef gfanp
-+	timeval t_kStd_start, t_kStd_end;
-+	gettimeofday(&t_kStd_start,0);
-+#endif
-+	BITSET save=test;
-+	test|=Sy_bit(OPT_REDSB);
-+	test|=Sy_bit(OPT_REDTAIL);
-+// 	if(gcone::hasHomInput==TRUE)
-+		H=kStd(ina,NULL,testHomog/*isHomog*/,NULL/*,gcone::hilbertFunction*/);
-+// 	else
-+// 		H=kStd(ina,NULL,isNotHomog,NULL);	//This is \mathcal(G)_{>_-\alpha}(in_v(I))
-+	test=save;
-+#ifdef gfanp
-+	gettimeofday(&t_kStd_end, 0);
-+	t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
-+#endif
-+	idSkipZeroes(H);
-+	idDelete(&ina);
-+	
-+	rChangeCurrRing(srcRing);
-+	ideal srcRing_H;
-+	ideal srcRing_HH;			
-+	srcRing_H=idrCopyR(H,tmpRing);
-+	//H is needed further below, so don't idDelete here
-+	srcRing_HH=ffG(srcRing_H,this->gcBasis);
-+	idDelete(&srcRing_H);
-+	//Now BBA(srcRing_HH) with (a(),a(),dp)
-+	/* Evil modification of currRing */
-+	ring dstRing=rCopy0(tmpRing);
-+	int length=this->numVars;
-+	int *A1=(int *)omAlloc0(length*sizeof(int));
-+	int *A2=(int *)omAlloc0(length*sizeof(int));
-+	const int64vec *ivw=f->getRef2FacetNormal();
-+	for(int jj=0;jj<length;jj++)
-+	{
-+		A1[jj] = (*intPointOfFacet)[jj];
-+		A2[jj] = -(*ivw)[jj];//TODO Or minus (*ivw)[ii] ??? NOTE minus
-+	}
-+	omFree(dstRing->wvhdl[0]);
-+	if(dstRing->wvhdl[1]!=NULL)
-+		omFree(dstRing->wvhdl[1]);
-+	dstRing->wvhdl[0]=(int*)A1;		
-+	dstRing->block1[0]=length;
-+	dstRing->wvhdl[1]=(int*)A2;		
-+	dstRing->block1[1]=length;
-+	rComplete(dstRing);
-+	rChangeCurrRing(dstRing);
-+	ideal dstRing_I;			
-+	dstRing_I=idrCopyR(srcRing_HH,srcRing);
-+	idDelete(&srcRing_HH); //Hmm.... causes trouble - no more	
-+	save=test;
-+	test|=Sy_bit(OPT_REDSB);
-+	test|=Sy_bit(OPT_REDTAIL);
-+	ideal tmpI;
-+	tmpI = dstRing_I;
-+#ifdef gfanp
-+// 	timeval t_kStd_start, t_kStd_end;
-+	gettimeofday(&t_kStd_start,0);
-+#endif
-+// 	if(gcone::hasHomInput==TRUE)
-+// 		dstRing_I=kStd(tmpI,NULL,isHomog,NULL/*,gcone::hilbertFunction*/);
-+// 	else
-+		dstRing_I=kStd(tmpI,NULL,testHomog,NULL);
-+#ifdef gfanp
-+	gettimeofday(&t_kStd_end, 0);
-+	t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
-+#endif
-+	idDelete(&tmpI);
-+	idNorm(dstRing_I);			
-+	idSkipZeroes(dstRing_I);
-+	test=save;
-+	/*End of step 3 - reduction*/
-+	
-+	f->setFlipGB(dstRing_I);
-+	f->flipRing=rCopy(dstRing);
-+	rDelete(tmpRing);
-+	rDelete(dstRing);
-+	//Now we should have dstRing with (a(),a(),dp,C)
-+	//This must be replaced with (a(),dp,C) BEFORE gcTmp is actually added to the list
-+	//of cones in noRevS
-+	rChangeCurrRing(srcRing);
-+#ifdef gfanp
-+	gettimeofday(&end, 0);
-+	time_flip2 += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-+#endif
-+}//flip2
-+
-+/** \brief Compute initial ideal
-+ * Compute the initial ideal in_v(G) wrt a (possible) facet normal
-+ * used in gcone::getFacetNormal in order to preprocess possible facet normals
-+ * and in gcone::flip for obvious reasons.
-+*/
-+/*inline*/ void gcone::computeInv(const ideal &gb, ideal &initialForm, const int64vec &fNormal)
-+{
-+#ifdef gfanp
-+	timeval start, end;
-+	gettimeofday(&start, 0);
-+#endif
-+	for (int ii=0;ii<IDELEMS(gb);ii++)
-+	{
-+		poly initialFormElement;
-+		poly aktpoly = (poly)gb->m[ii];//Ptr, so don't pDelete(aktpoly)
-+		int *leadExpV=(int *)omAlloc((this->numVars+1)*sizeof(int));
-+		pGetExpV(aktpoly,leadExpV);	//find the leading exponent in leadExpV[1],...,leadExpV[n], use pNext(p)
-+		initialFormElement=pHead(aktpoly);
-+// 		int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
-+		while(pNext(aktpoly)!=NULL)	/*loop trough terms and check for parallelity*/
-+		{
-+			int64vec *check = new int64vec(this->numVars);
-+			aktpoly=pNext(aktpoly);	//next term
-+			int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
-+			pGetExpV(aktpoly,v);		
-+			/* Convert (int)v into (int64vec)check */
-+// 			bool notPar=FALSE;
-+			for (int jj=0;jj<this->numVars;jj++)
-+			{
-+				(*check)[jj]=v[jj+1]-leadExpV[jj+1];
-+// 				register int64 foo=(fNormal)[jj];
-+// 				if( ( (*check)[jj]  == /*fNormal[jj]*/foo ) 
-+// 				 || ( (/*fNormal[jj]*/foo!=0) && ( ( (*check)[jj] % /*fNormal[jj]*/foo ) !=0 ) ) ) 
-+// 				{
-+// 					notPar=TRUE;
-+// 					break;
-+// 				}
-+			}
-+			omFree(v);
-+			if (isParallel(*check,fNormal))//Found a parallel vector. Add it
-+//  			if(notPar==FALSE)
-+			{
-+				initialFormElement = pAdd((initialFormElement),(poly)pHead(aktpoly));//pAdd = p_Add_q destroys args
-+			}
-+			delete check;
-+		}//while
-+// 		omFree(v);
-+#ifndef NDEBUG
-+//  		cout << "Initial Form=";				
-+//  		pWrite(initialFormElement[ii]);
-+//  		cout << "---" << endl;
-+#endif
-+		/*Now initialFormElement must be added to (ideal)initialForm */
-+		initialForm->m[ii]=pCopy(initialFormElement);
-+		pDelete(&initialFormElement);
-+		omFree(leadExpV);
-+	}//for
-+#ifdef gfanp
-+	gettimeofday(&end, 0);
-+	time_computeInv += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-+#endif
-+}
-+
-+/** \brief Compute the remainder of a polynomial by a given ideal
-+ *
-+ * Compute \f$ f^{\mathcal{G}} \f$
-+ * Algorithm is taken from Cox, Little, O'Shea, IVA 2nd Ed. p 62
-+ * However, since we are only interested in the remainder, there is no need to
-+ * compute the factors \f$ a_i \f$
-+ */
-+//NOTE: Should be replaced by kNF or kNF2
-+//NOTE: Done
-+//NOTE: removed with r12286
-+		
-+/** \brief Compute \f$ f-f^{\mathcal{G}} \f$
-+*/
-+//NOTE: use kNF or kNF2 instead of restOfDivision
-+inline ideal gcone::ffG(const ideal &H, const ideal &G)
-+{
-+	int size=IDELEMS(H);
-+	ideal res=idInit(size,1);
-+	for (int ii=0;ii<size;ii++)
-+	{
-+// 		poly temp1;//=pInit();
-+// 		poly temp2;//=pInit();
-+		poly temp3;//=pInit();//polys to temporarily store values for pSub
-+// 		res->m[ii]=pCopy(kNF(G, NULL,H->m[ii],0,0));
-+//  		temp1=pCopy(H->m[ii]);//TRY
-+// 		temp2=pCopy(res->m[ii]);
-+		//NOTE if gfanHeuristic=0 (sic!) this results in dPolyErrors - mon from wrong ring
-+//  		temp2=pCopy(kNF(G, NULL,H->m[ii],0,0));//TRY
-+//  		temp3=pSub(temp1, temp2);//TRY
-+		temp3=pSub(pCopy(H->m[ii]),pCopy(kNF(G,NULL,H->m[ii],0,0)));//NOTRY
-+		res->m[ii]=pCopy(temp3);
-+		//res->m[ii]=pSub(temp1,temp2); //buggy		
-+		//cout << "res->m["<<ii<<"]=";pWrite(res->m[ii]);
-+// 		pDelete(&temp1);//TRY
-+// 		pDelete(&temp2);
-+		pDelete(&temp3);
-+	}
-+	return res;
-+}
-+	
-+/** \brief Preprocessing of inequlities
-+* Do some preprocessing on the matrix of inequalities
-+* 1) Replace several constraints on the pos. orthants by just one for each orthant
-+* 2) Remove duplicates of inequalities
-+* 3) Remove inequalities that arise as sums of other inequalities
-+*/
-+void gcone::preprocessInequalities(dd_MatrixPtr &ddineq)
-+{
-+/*	int *posRowsArray=NULL;
-+	int num_alloc=0;
-+	int num_elts=0;
-+ 	int offset=0;*/
-+	//Remove zeroes (and strictly pos rows?)
-+	for(int ii=0;ii<ddineq->rowsize;ii++)
-+	{
-+		int64vec *iv = new int64vec(this->numVars);
-+		int64vec *ivNull = new int64vec(this->numVars);//Needed for intvec64::compare(*int64vec)
-+		int posCtr=0;
-+		for(int jj=0;jj<this->numVars;jj++)
-+		{
-+			(*iv)[jj]=(int)mpq_get_d(ddineq->matrix[ii][jj+1]);
-+			if((*iv)[jj]>0)//check for strictly pos rows
-+				posCtr++;
-+			//Behold! This will delete the row for the standard simplex!
-+		}
-+// 		if( (iv->compare(0)==0) || (posCtr==iv->length()) )
-+		if( (posCtr==iv->length()) || (iv->compare(ivNull)==0) )		
-+		{
-+			dd_MatrixRowRemove(&ddineq,ii+1);
-+			ii--;//Yes. This is on purpose
-+		}
-+		delete iv;
-+		delete ivNull;
-+	}
-+	//Remove duplicates of rows
-+// 	posRowsArray=NULL;
-+// 	num_alloc=0;
-+// 	num_elts=0;
-+// 	offset=0;
-+// 	int num_newRows = ddineq->rowsize;
-+// 	for(int ii=0;ii<ddineq->rowsize-1;ii++)
-+// 	for(int ii=0;ii<num_newRows-1;ii++)
-+// 	{
-+// 		int64vec *iv = new int64vec(this->numVars);//1st vector to check against
-+// 		for(int jj=0;jj<this->numVars;jj++)
-+// 			(*iv)[jj]=(int)mpq_get_d(ddineq->matrix[ii][jj+1]);
-+// 		for(int jj=ii+1;jj</*ddineq->rowsize*/num_newRows;jj++)
-+// 		{
-+// 			int64vec *ivCheck = new int64vec(this->numVars);//Checked against iv
-+// 			for(int kk=0;kk<this->numVars;kk++)
-+// 				(*ivCheck)[kk]=(int)mpq_get_d(ddineq->matrix[jj][kk+1]);
-+// 			if (iv->compare(ivCheck)==0)
-+// 			{
-+// // 				cout << "=" << endl;
-+// // 				num_alloc++;
-+// // 				void *tmp=realloc(posRowsArray,(num_alloc*sizeof(int)));
-+// // 				if(!tmp)
-+// // 				{
-+// // 					WerrorS("Woah dude! Couldn't realloc memory\n");
-+// // 					exit(-1);
-+// // 				}
-+// // 				posRowsArray = (int*)tmp;
-+// // 				posRowsArray[num_elts]=jj;
-+// // 				num_elts++;
-+// 				dd_MatrixRowRemove(&ddineq,jj+1);
-+// 				num_newRows = ddineq->rowsize;
-+// 			}
-+// 			delete ivCheck;
-+// 		}
-+// 		delete iv;
-+// 	}
-+// 	for(int ii=0;ii<num_elts;ii++)
-+// 	{
-+// 		dd_MatrixRowRemove(&ddineq,posRowsArray[ii]+1-offset);
-+// 		offset++;
-+// 	}
-+// 	free(posRowsArray);
-+	//Apply Thm 2.1 of JOTA Vol 53 No 1 April 1987*/	
-+}//preprocessInequalities
-+	
-+/** \brief Compute a Groebner Basis
-+ *
-+ * Computes the Groebner basis and stores the result in gcone::gcBasis
-+ *\param ideal
-+ *\return void
-+ */
-+inline void gcone::getGB(const ideal &inputIdeal)		
-+{
-+	BITSET save=test;
-+	test|=Sy_bit(OPT_REDSB);
-+	test|=Sy_bit(OPT_REDTAIL);
-+	ideal gb;
-+	gb=kStd(inputIdeal,NULL,testHomog,NULL);
-+	idNorm(gb);
-+	idSkipZeroes(gb);
-+	this->gcBasis=gb;	//write the GB into gcBasis
-+	test=save;
-+}//void getGB
-+		
-+/** \brief Compute the negative of a given int64vec
-+	*/		
-+static int64vec* ivNeg(/*const*/int64vec *iv)
-+{	//Hm, switching to int64vec const int64vec does no longer work
-+	int64vec *res;// = new int64vec(iv->length());
-+	res=iv64Copy(iv);
-+	*res *= (int)-1;						
-+	return res;
-+}
-+
-+
-+/** \brief Compute the dot product of two intvecs
-+*
-+*/
-+static int dotProduct(const int64vec &iva, const int64vec &ivb)				
-+{			
-+	int res=0;	
-+	for (int i=0;i<pVariables;i++)
-+	{
-+// #ifndef NDEBUG
-+// 	(const_cast<int64vec*>(&iva))->show(1,0); (const_cast<int64vec*>(&ivb))->show(1,0);
-+// #endif
-+		res = res+(iva[i]*ivb[i]);
-+	}
-+	return res;
-+}
-+/** \brief Check whether two intvecs are parallel
-+ *
-+ * \f$ \alpha\parallel\beta\Leftrightarrow\langle\alpha,\beta\rangle^2=\langle\alpha,\alpha\rangle\langle\beta,\beta\rangle \f$
-+ */
-+static bool isParallel(const int64vec &a,const int64vec &b)
-+{	
-+	bool res;
-+	int lhs=dotProduct(a,b)*dotProduct(a,b);
-+	int rhs=dotProduct(a,a)*dotProduct(b,b);
-+	return res = (lhs==rhs)?TRUE:FALSE;
-+}
-+
-+/** \brief Compute an interior point of a given cone
-+ * Result will be written into int64vec iv. 
-+ * Any rational point is automatically converted into an integer.
-+ */
-+void gcone::interiorPoint( dd_MatrixPtr &M, int64vec &iv) //no const &M here since we want to remove redundant rows
-+{
-+	dd_LPPtr lp,lpInt;
-+	dd_ErrorType err=dd_NoError;
-+	dd_LPSolverType solver=dd_DualSimplex;
-+	dd_LPSolutionPtr lpSol=NULL;
-+// 	dd_rowset ddlinset,ddredrows;	//needed for dd_FindRelativeInterior
-+//  	dd_rowindex ddnewpos;
-+	dd_NumberType numb;	
-+	//M->representation=dd_Inequality;
-+			
-+	//NOTE: Make this n-dimensional!
-+	//dd_set_si(M->rowvec[0],1);dd_set_si(M->rowvec[1],1);dd_set_si(M->rowvec[2],1);
-+									
-+	/*NOTE: Leave the following line commented out!
-+	* Otherwise it will slow down computations a great deal
-+	* */
-+// 	dd_MatrixCanonicalizeLinearity(&M, &ddlinset, &ddnewpos, &err);
-+	//if (err!=dd_NoError){cout << "Error during dd_MatrixCanonicalize" << endl;}
-+	dd_MatrixPtr posRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
-+	int jj=1;
-+	for (int ii=0;ii<this->numVars;ii++)
-+	{
-+		dd_set_si(posRestr->matrix[ii][jj],1);
-+		jj++;							
-+	}
-+	dd_MatrixAppendTo(&M,posRestr);
-+	dd_FreeMatrix(posRestr);
-+	lp=dd_Matrix2LP(M, &err);
-+	if (err!=dd_NoError){WerrorS("Error during dd_Matrix2LP in gcone::interiorPoint");}
-+	if (lp==NULL){WerrorS("LP is NULL");}
-+#ifndef NDEBUG
-+//			dd_WriteLP(stdout,lp);
-+#endif	
-+					
-+	lpInt=dd_MakeLPforInteriorFinding(lp);
-+	if (err!=dd_NoError){WerrorS("Error during dd_MakeLPForInteriorFinding in gcone::interiorPoint");}
-+#ifndef NDEBUG
-+// 			dd_WriteLP(stdout,lpInt);
-+#endif			
-+// 	dd_FindRelativeInterior(M,&ddlinset,&ddredrows,&lpSol,&err);
-+	if (err!=dd_NoError)
-+	{
-+		WerrorS("Error during dd_FindRelativeInterior in gcone::interiorPoint");
-+		dd_WriteErrorMessages(stdout, err);
-+	}			
-+	dd_LPSolve(lpInt,solver,&err);	//This will not result in a point from the relative interior
-+// 	if (err!=dd_NoError){WerrorS("Error during dd_LPSolve");}									
-+	lpSol=dd_CopyLPSolution(lpInt);
-+// 	if (err!=dd_NoError){WerrorS("Error during dd_CopyLPSolution");}
-+#ifndef NDEBUG
-+	printf("Interior point: ");
-+	for (int ii=1; ii<(lpSol->d)-1;ii++)
-+	{
-+		dd_WriteNumber(stdout,lpSol->sol[ii]);
-+	}
-+	printf("\n");
-+#endif			
-+	//NOTE The following strongly resembles parts of makeInt. 
-+	//Maybe merge sometimes
-+	mpz_t kgV; mpz_init(kgV);
-+	mpz_set_str(kgV,"1",10);
-+	mpz_t den; mpz_init(den);
-+	mpz_t tmp; mpz_init(tmp);
-+	mpq_get_den(tmp,lpSol->sol[1]);
-+	for (int ii=1;ii<(lpSol->d)-1;ii++)
-+	{
-+		mpq_get_den(den,lpSol->sol[ii+1]);
-+		mpz_lcm(kgV,tmp,den);
-+		mpz_set(tmp, kgV);
-+	}
-+	mpq_t qkgV;
-+	mpq_init(qkgV);
-+	mpq_set_z(qkgV,kgV);
-+	for (int ii=1;ii<(lpSol->d)-1;ii++)
-+	{
-+		mpq_t product;
-+		mpq_init(product);
-+		mpq_mul(product,qkgV,lpSol->sol[ii]);
-+		iv[ii-1]=(int)mpz_get_d(mpq_numref(product));
-+		mpq_clear(product);
-+	}
-+#ifndef NDEBUG
-+// 			iv.show();
-+// 			cout << endl;
-+#endif
-+	mpq_clear(qkgV);
-+	mpz_clear(tmp);
-+	mpz_clear(den);
-+	mpz_clear(kgV);			
-+			
-+	dd_FreeLPSolution(lpSol);
-+	dd_FreeLPData(lpInt);
-+	dd_FreeLPData(lp);
-+// 	set_free(ddlinset);
-+// 	set_free(ddredrows); 	
-+			
-+}//void interiorPoint(dd_MatrixPtr const &M)
-+
-+/** Computes an interior point of a cone by taking two interior points a,b from two different facets
-+* and then computing b+(a-b)/2
-+* Of course this only works for flippable facets 
-+* Two cases may occur: 
-+* 1st: There are only two facets who share the only strictly positive ray
-+* 2nd: There are at least two facets which have a distinct positive ray
-+* In the former case we use linear algebra to determine an interior point,
-+* in the latter case we simply add up the two rays
-+*
-+* Way too bad! The case may occur that the cone is spanned by three rays, of which only two are strictly
-+* positive => these lie in a plane and thus their sum is not from relative interior.
-+* So let's just sum up all rays, find one strictly positive and shift the point along that ray
-+* 
-+* Used by noRevS
-+*NOTE no longer used nor maintained. MM Mar 9, 2010
-+*/
-+// void gcone::interiorPoint2()
-+// {//idPrint(this->gcBasis);
-+// #ifndef NDEBUG
-+// 	if(this->ivIntPt!=NULL)
-+// 		WarnS("Interior point already exists - ovrewriting!");
-+// #endif
-+// 	facet *f1 = this->facetPtr;
-+// 	facet *f2 = NULL;
-+// 	int64vec *intF1=NULL;
-+// 	while(f1!=NULL)
-+// 	{
-+// 		if(f1->isFlippable)
-+// 		{
-+// 			facet *f1Ray = f1->codim2Ptr;
-+// 			while(f1Ray!=NULL)
-+// 			{
-+// 				const int64vec *check=f1Ray->getRef2FacetNormal();
-+// 				if(iv64isStrictlyPositive(check))
-+// 				{
-+// 					intF1=iv64Copy(check);
-+// 					break;
-+// 				}				
-+// 				f1Ray=f1Ray->next;
-+// 			}
-+// 		}
-+// 		if(intF1!=NULL)
-+// 			break;
-+// 		f1=f1->next;
-+// 	}
-+// 	if(f1!=NULL && f1->next!=NULL)//Choose another facet, different from f1
-+// 		f2=f1->next;
-+// 	else
-+// 		f2=this->facetPtr;
-+// 	if(intF1==NULL && hasHomInput==TRUE)
-+// 	{
-+// 		intF1 = new int64vec(this->numVars);
-+// 		for(int ii=0;ii<this->numVars;ii++)
-+// 			(*intF1)[ii]=1;
-+// 	}
-+// 	assert(f1); assert(f2);
-+// 	int64vec *intF2=f2->getInteriorPoint();
-+// 	mpq_t *qPosRay = new mpq_t[this->numVars];//The positive ray from above
-+// 	mpq_t *qIntPt = new mpq_t[this->numVars];//starting vector a+((b-a)/2)
-+// 	mpq_t *qPosIntPt = new mpq_t[this->numVars];//This should be >0 eventually
-+// 	for(int ii=0;ii<this->numVars;ii++)
-+// 	{
-+// 		mpq_init(qPosRay[ii]);
-+// 		mpq_init(qIntPt[ii]);
-+// 		mpq_init(qPosIntPt[ii]);
-+// 	}	
-+// 	//Compute a+((b-a)/2) && Convert intF1 to mpq
-+// 	for(int ii=0;ii<this->numVars;ii++)
-+// 	{
-+// 		mpq_t a,b;
-+// 		mpq_init(a); mpq_init(b);
-+// 		mpq_set_si(a,(*intF1)[ii],1);
-+// 		mpq_set_si(b,(*intF2)[ii],1);
-+// 		mpq_t diff;
-+// 		mpq_init(diff);
-+// 		mpq_sub(diff,b,a);	//diff=b-a
-+// 		mpq_t quot;
-+// 		mpq_init(quot);
-+// 		mpq_div_2exp(quot,diff,1);	//quot=diff/2=(b-a)/2
-+// 		mpq_clear(diff);
-+// 		//Don't be clever and reuse diff here
-+// 		mpq_t sum; mpq_init(sum);
-+// 		mpq_add(sum,b,quot);	//sum=b+quot=a+(b-a)/2
-+// 		mpq_set(qIntPt[ii],sum);
-+// 		mpq_clear(sum);
-+// 		mpq_clear(quot);
-+// 		mpq_clear(a); mpq_clear(b);
-+// 		//Now for intF1
-+// 		mpq_set_si(qPosRay[ii],(*intF1)[ii],1);
-+// 	}
-+// 	//Now add: qPosIntPt=qPosRay+qIntPt until qPosIntPt >0
-+// 	while(TRUE)
-+// 	{	
-+// 		bool success=FALSE;
-+// 		int posCtr=0;	
-+// 		for(int ii=0;ii<this->numVars;ii++)
-+// 		{
-+// 			mpq_t sum; mpq_init(sum);
-+// 			mpq_add(sum,qPosRay[ii],qIntPt[ii]);
-+// 			mpq_set(qPosIntPt[ii],sum);
-+// 			mpq_clear(sum);
-+// 			if(mpq_sgn(qPosIntPt[ii])==1)
-+// 				posCtr++;
-+// 		}
-+// 		if(posCtr==this->numVars)//qPosIntPt > 0 
-+// 			break;
-+// 		else
-+// 		{
-+// 			mpq_t qTwo; mpq_init(qTwo);
-+// 			mpq_set_ui(qTwo,2,1);
-+// 			for(int jj=0;jj<this->numVars;jj++)
-+// 			{
-+// 				mpq_t tmp; mpq_init(tmp);
-+// 				mpq_mul(tmp,qPosRay[jj],qTwo);
-+// 				mpq_set( qPosRay[jj], tmp);
-+// 				mpq_clear(tmp);
-+// 			}
-+// 			mpq_clear(qTwo);
-+// 		}
-+// 	}//while
-+// 	//Now qPosIntPt ought to be >0, so convert back to int :D
-+// 	/*Compute lcm of the denominators*/
-+// 	mpz_t *denom = new mpz_t[this->numVars];
-+// 	mpz_t tmp,kgV;
-+// 	mpz_init(tmp); mpz_init(kgV);
-+// 	for (int ii=0;ii<this->numVars;ii++)
-+// 	{
-+// 		mpz_t z;
-+// 		mpz_init(z);
-+// 		mpq_get_den(z,qPosIntPt[ii]);
-+// 		mpz_init(denom[ii]);
-+// 		mpz_set( denom[ii], z);
-+// 		mpz_clear(z);				
-+// 	}
-+// 		
-+// 	mpz_set(tmp,denom[0]);
-+// 	for (int ii=0;ii<this->numVars;ii++)
-+// 	{
-+// 		mpz_lcm(kgV,tmp,denom[ii]);
-+// 		mpz_set(tmp,kgV);				
-+// 	}
-+// 	mpz_clear(tmp);	
-+// 	/*Multiply the nominators by kgV*/
-+// 	mpq_t qkgV,res;
-+// 	mpq_init(qkgV);
-+// 	mpq_canonicalize(qkgV);		
-+// 	mpq_init(res);
-+// 	mpq_canonicalize(res);
-+// 				
-+// 	mpq_set_num(qkgV,kgV);
-+// 	int64vec *n=new int64vec(this->numVars);
-+// 	for (int ii=0;ii<this->numVars;ii++)
-+// 	{
-+// 		mpq_canonicalize(qPosIntPt[ii]);
-+// 		mpq_mul(res,qkgV,qPosIntPt[ii]);
-+// 		(*n)[ii]=(int)mpz_get_d(mpq_numref(res));
-+// 	}
-+// 	this->setIntPoint(n);
-+// 	delete n;
-+// 	delete [] qPosIntPt;
-+// 	delete [] denom;
-+// 	delete [] qPosRay;
-+// 	delete [] qIntPt;
-+// 	mpz_clear(kgV);
-+// 	mpq_clear(qkgV); mpq_clear(res);
-+// }
-+	
-+/** \brief Copy a ring and add a weighted ordering in first place
-+ * 
-+ */
-+ring gcone::rCopyAndAddWeight(const ring &r, int64vec *ivw)				
-+{
-+	ring res=rCopy0(r);
-+	int jj;
-+			
-+	omFree(res->order);
-+	res->order =(int *)omAlloc0(4*sizeof(int/*64*/));
-+	omFree(res->block0);
-+	res->block0=(int *)omAlloc0(4*sizeof(int/*64*/));
-+	omFree(res->block1);
-+	res->block1=(int *)omAlloc0(4*sizeof(int/*64*/));
-+	omfree(res->wvhdl);
-+	res->wvhdl =(int **)omAlloc0(4*sizeof(int/*64*/**));
-+			
-+	res->order[0]=ringorder_a/*64*/;
-+	res->block0[0]=1;
-+	res->block1[0]=res->N;
-+	res->order[1]=ringorder_dp;	//basically useless, since that should never be used			
-+	res->block0[1]=1;
-+	res->block1[1]=res->N;
-+	res->order[2]=ringorder_C;
-+
-+	int length=ivw->length();
-+	int/*64*/ *A=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
-+	for (jj=0;jj<length;jj++)
-+	{				
-+		A[jj]=(*ivw)[jj];
-+		if((*ivw)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::rCopyAndAddWeight!\n");
-+	}			
-+	res->wvhdl[0]=(int *)A;
-+	res->block1[0]=length;
-+			
-+	rComplete(res);
-+	return res;
-+}//rCopyAndAdd
-+		
-+ring gcone::rCopyAndAddWeight2(const ring &r,const int64vec *ivw, const int64vec *fNormal)				
-+{
-+	ring res=rCopy0(r);
-+			
-+	omFree(res->order);
-+	res->order =(int *)omAlloc0(5*sizeof(int/*64*/));
-+	omFree(res->block0);
-+	res->block0=(int *)omAlloc0(5*sizeof(int/*64*/));
-+	omFree(res->block1);
-+	res->block1=(int *)omAlloc0(5*sizeof(int/*64*/));
-+	omfree(res->wvhdl);
-+	res->wvhdl =(int **)omAlloc0(5*sizeof(int/*64*/**));
-+			
-+	res->order[0]=ringorder_a/*64*/;
-+	res->block0[0]=1;
-+	res->block1[0]=res->N;
-+	res->order[1]=ringorder_a/*64*/;
-+	res->block0[1]=1;
-+	res->block1[1]=res->N;
-+	
-+	res->order[2]=ringorder_dp;
-+	res->block0[2]=1;
-+	res->block1[2]=res->N;
-+	
-+	res->order[3]=ringorder_C;
-+
-+	int length=ivw->length();
-+	int/*64*/ *A1=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
-+	int/*64*/ *A2=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
-+	for (int jj=0;jj<length;jj++)
-+	{				
-+		A1[jj]=(*ivw)[jj];
-+		A2[jj]=-(*fNormal)[jj];
-+		if((*ivw)[jj]>=INT_MAX || (*fNormal)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::rCopyAndAddWeight2!\n");
-+	}			
-+	res->wvhdl[0]=(int *)A1;
-+	res->block1[0]=length;
-+	res->wvhdl[1]=(int *)A2;
-+	res->block1[1]=length;
-+	rComplete(res);
-+	return res;
-+}
-+		
-+//NOTE not needed anywhere
-+// ring rCopyAndChangeWeight(ring const &r, int64vec *ivw)
-+// {
-+// 	ring res=rCopy0(currRing);
-+// 	rComplete(res);
-+// 	rSetWeightVec(res,(int64*)ivw);
-+// 	//rChangeCurrRing(rnew);
-+// 	return res;
-+// }
-+		
-+/** \brief Checks whether a given facet is a search facet
-+ * Determines whether a given facet of a cone is the search facet of a neighbouring cone
-+ * This is done in the following way:
-+ * We loop through all facets of the cone and find the "smallest" facet, i.e. the unique facet
-+ * that is first crossed during the generic walk.
-+ * We then check whether the fNormal of this facet is parallel to the fNormal of our testfacet.
-+ * If this is the case, then our facet is indeed a search facet and TRUE is retuned. 
-+*/
-+//removed with r12286
-+		
-+/** \brief Check for equality of two intvecs
-+ */
-+static bool ivAreEqual(const int64vec &a, const int64vec &b)
-+{
-+	bool res=TRUE;
-+	for(int ii=0;ii<pVariables;ii++)
-+	{
-+		if(a[ii]!=b[ii])
-+		{
-+			res=FALSE;
-+			break;
-+		}
-+	}
-+	return res;
-+}
-+		
-+/** \brief The reverse search algorithm
-+ */
-+//removed with r12286
-+/** \brief Compute the lineality/homogeneity space
-+* It is the kernel of the inequality matrix Ax=0
-+* As a result gcone::dd_LinealitySpace is set
-+*/
-+dd_MatrixPtr gcone::computeLinealitySpace()
-+{
-+	dd_MatrixPtr res;
-+	dd_MatrixPtr ddineq;
-+	ddineq=dd_CopyMatrix(this->ddFacets);	
-+	//Add a row of 0s in 0th place
-+	dd_MatrixPtr ddAppendRowOfZeroes=dd_CreateMatrix(1,this->numVars+1);
-+	dd_MatrixPtr ddFoo=dd_AppendMatrix(ddAppendRowOfZeroes,ddineq);
-+	dd_FreeMatrix(ddAppendRowOfZeroes);
-+	dd_FreeMatrix(ddineq);
-+	ddineq=dd_CopyMatrix(ddFoo);
-+	dd_FreeMatrix(ddFoo);
-+	//Cohen starts here
-+	int dimKer=0;//Cohen calls this r
-+	int m=ddineq->rowsize;//Rows
-+	int n=ddineq->colsize;//Cols
-+	int c[m+1];
-+	int d[n+1];
-+	for(int ii=0;ii<m;ii++)
-+		c[ii]=0;
-+	for(int ii=0;ii<n;ii++)
-+		d[ii]=0;	
-+	
-+	for(int k=1;k<n;k++)
-+	{
-+		//Let's find a j s.t. m[j][k]!=0 && c[j]=0		
-+		int condCtr=0;//Check each row for zeroness
-+		for(int j=1;j<m;j++)
-+		{
-+			if(mpq_sgn(ddineq->matrix[j][k])!=0 && c[j]==0)
-+			{
-+				mpq_t quot; mpq_init(quot);
-+				mpq_t one; mpq_init(one); mpq_set_str(one,"-1",10);
-+				mpq_t ratd; mpq_init(ratd);
-+				if((int)mpq_get_d(ddineq->matrix[j][k])!=0)
-+					mpq_div(quot,one,ddineq->matrix[j][k]);
-+				mpq_set(ratd,quot);
-+				mpq_canonicalize(ratd);
-+		
-+				mpq_set_str(ddineq->matrix[j][k],"-1",10);
-+				for(int ss=k+1;ss<n;ss++)
-+				{
-+					mpq_t prod; mpq_init(prod);
-+					mpq_mul(prod, ratd, ddineq->matrix[j][ss]);				
-+					mpq_set(ddineq->matrix[j][ss],prod);
-+					mpq_canonicalize(ddineq->matrix[j][ss]);
-+					mpq_clear(prod);
-+				}		
-+				for(int ii=1;ii<m;ii++)
-+				{
-+					if(ii!=j)
-+					{
-+						mpq_set(ratd,ddineq->matrix[ii][k]);
-+						mpq_set_str(ddineq->matrix[ii][k],"0",10);			
-+						for(int ss=k+1;ss<n;ss++)
-+						{
-+							mpq_t prod; mpq_init(prod);
-+							mpq_mul(prod, ratd, ddineq->matrix[j][ss]);
-+							mpq_t sum; mpq_init(sum);
-+							mpq_add(sum, ddineq->matrix[ii][ss], prod);
-+							mpq_set(ddineq->matrix[ii][ss],	sum);
-+							mpq_canonicalize(ddineq->matrix[ii][ss]);
-+							mpq_clear(prod);
-+							mpq_clear(sum);
-+						}
-+					}
-+				}
-+				c[j]=k;		
-+				d[k]=j;
-+				mpq_clear(quot); mpq_clear(ratd); mpq_clear(one);	
-+			}
-+			else
-+				condCtr++;
-+		}			
-+		if(condCtr==m-1)	//Why -1 ???
-+		{
-+			dimKer++;
-+			d[k]=0;
-+// 			break;//goto _4;
-+		}//else{
-+		/*Eliminate*/
-+	}//for(k
-+	/*Output kernel, i.e. set gcone::dd_LinealitySpace here*/	
-+// 	gcone::dd_LinealitySpace = dd_CreateMatrix(dimKer,this->numVars+1);
-+	res = dd_CreateMatrix(dimKer,this->numVars+1);
-+	int row=-1;
-+	for(int kk=1;kk<n;kk++)
-+	{
-+		if(d[kk]==0)
-+		{
-+			row++;
-+			for(int ii=1;ii<n;ii++)
-+			{
-+				if(d[ii]>0)
-+					mpq_set(res->matrix[row][ii],ddineq->matrix[d[ii]][kk]);
-+				else if(ii==kk)				
-+					mpq_set_str(res->matrix[row][ii],"1",10);
-+				mpq_canonicalize(res->matrix[row][ii]);
-+			}
-+		}
-+	}
-+	dd_FreeMatrix(ddineq);
-+	return(res);
-+	//Better safe than sorry:
-+	//NOTE dd_LinealitySpace contains RATIONAL ENTRIES
-+	//Therefore if you need integer ones: CALL gcone::makeInt(...) method
-+}	
-+
-+
-+/** \brief The new method of Markwig and Jensen
-+ * Compute gcBasis and facets for the arbitrary starting cone. Store \f$(codim-1)\f$-facets as normals.
-+ * In order to represent a facet uniquely compute also the \f$(codim-2)\f$-facets and norm by the gcd of the components.
-+ * Keep a list of facets as a linked list containing an int64vec and an integer matrix.
-+ * Since a \f$(codim-1)\f$-facet belongs to exactly two full dimensional cones, we remove a facet from the list as
-+ * soon as we compute this facet again. Comparison of facets is done by...
-+ */
-+void gcone::noRevS(gcone &gcRoot, bool usingIntPoint)
-+{	
-+	facet *SearchListRoot = new facet(); //The list containing ALL facets we come across
-+	facet *SearchListAct;
-+	SearchListAct = NULL;
-+	//SearchListAct = SearchListRoot;			
-+	gcone *gcAct;
-+	gcAct = &gcRoot;
-+	gcone *gcPtr;	//Pointer to end of linked list of cones
-+	gcPtr = &gcRoot;
-+	gcone *gcNext;	//Pointer to next cone to be visited
-+	gcNext = &gcRoot;
-+	gcone *gcHead;
-+	gcHead = &gcRoot;			
-+	facet *fAct;
-+	fAct = gcAct->facetPtr;				
-+	ring rAct;
-+	rAct = currRing;
-+	int UCNcounter=gcAct->getUCN();	
-+#ifndef NDEBUG
-+	printf("NoRevs\n");
-+	printf("Facets are:\n");
-+	gcAct->showFacets();
-+#endif			
-+	/*Compute lineality space here
-+	* Afterwards static dd_MatrixPtr gcone::dd_LinealitySpace is set*/
-+	if(dd_LinealitySpace==NULL)
-+		dd_LinealitySpace = gcAct->computeLinealitySpace();
-+	/*End of lineality space computation*/		
-+	//gcAct->getCodim2Normals(*gcAct);
-+	if(fAct->codim2Ptr==NULL)
-+		gcAct->getExtremalRays(*gcAct);		
-+	/* Make a copy of the facet list of first cone
-+	   Since the operations getCodim2Normals and normalize affect the facets
-+	   we must not memcpy them before these ops! */	
-+	/*facet *codim2Act; codim2Act = NULL;			
-+	facet *sl2Root;
-+	facet *sl2Act;*/			
-+	for(int ii=0;ii<this->numFacets;ii++)
-+	{
-+		//only copy flippable facets! NOTE: We do not need flipRing or any such information.
-+		if(fAct->isFlippable==TRUE)
-+		{
-+			/*Using shallow copy here*/
-+#ifdef SHALLOW
-+			if( ii==0 || (ii>0 && SearchListAct==NULL) ) //1st facet may be non-flippable
-+			{
-+				if(SearchListRoot!=NULL) delete(SearchListRoot);
-+				SearchListRoot = fAct->shallowCopy(*fAct);
-+				SearchListAct = SearchListRoot;	//SearchListRoot is already 'new'ed at beginning of method!
-+			}
-+			else
-+			{			
-+				SearchListAct->next = fAct->shallowCopy(*fAct);
-+				SearchListAct = SearchListAct->next;						
-+			}
-+			fAct=fAct->next;
-+#else
-+			/*End of shallow copy*/
-+			int64vec *fNormal;
-+			fNormal = fAct->getFacetNormal();
-+			if( ii==0 || (ii>0 && SearchListAct==NULL) ) //1st facet may be non-flippable
-+			{						
-+				SearchListAct = SearchListRoot;	//SearchListRoot is already 'new'ed at beginning of method!
-+			}
-+			else
-+			{			
-+				SearchListAct->next = new facet();
-+				SearchListAct = SearchListAct->next;						
-+			}
-+			SearchListAct->setFacetNormal(fNormal);
-+			SearchListAct->setUCN(this->getUCN());
-+			SearchListAct->numCodim2Facets=fAct->numCodim2Facets;
-+			SearchListAct->isFlippable=TRUE;
-+			//Copy int point as well
-+			int64vec *ivIntPt;
-+			ivIntPt = fAct->getInteriorPoint();
-+			SearchListAct->setInteriorPoint(ivIntPt);
-+			delete(ivIntPt);
-+			//Copy codim2-facets
-+			facet *codim2Act;
-+			codim2Act = NULL;			
-+			facet *sl2Root;
-+			facet *sl2Act;			
-+			codim2Act=fAct->codim2Ptr;
-+			SearchListAct->codim2Ptr = new facet(2);
-+			sl2Root = SearchListAct->codim2Ptr;
-+			sl2Act = sl2Root;			
-+			for(int jj=0;jj<fAct->numCodim2Facets;jj++)
-+// 			for(int jj=0;jj<fAct->numRays-1;jj++)
-+			{
-+				int64vec *f2Normal;
-+				f2Normal = codim2Act->getFacetNormal();
-+				if(jj==0)
-+				{						
-+					sl2Act = sl2Root;
-+					sl2Act->setFacetNormal(f2Normal);
-+				}
-+				else
-+				{
-+					sl2Act->next = new facet(2);
-+					sl2Act = sl2Act->next;
-+					sl2Act->setFacetNormal(f2Normal);
-+				}
-+				delete f2Normal;				
-+				codim2Act = codim2Act->next;
-+			}
-+			fAct = fAct->next;
-+			delete fNormal;
-+#endif
-+		}//if(fAct->isFlippable==TRUE)			
-+		else {fAct = fAct->next;}
-+	}//End of copying facets into SLA
-+	
-+	SearchListAct = SearchListRoot;	//Set to beginning of list
-+	/*Make SearchList doubly linked*/
-+#ifndef NDEBUG
-+  #if SIZEOF_LONG==8
-+	while(SearchListAct!=(facet*)0xfefefefefefefefe && SearchListAct!=NULL)
-+	{
-+		if(SearchListAct->next!=(facet*)0xfefefefefefefefe && SearchListAct->next!=NULL){
-+  #elif SIZEOF_LONG!=8
-+	while(SearchListAct!=(facet*)0xfefefefe)
-+	{
-+		if(SearchListAct->next!=(facet*)0xfefefefe){
-+  #endif
-+#else
-+	while(SearchListAct!=NULL)
-+	{
-+		if(SearchListAct->next!=NULL){
-+#endif
-+			SearchListAct->next->prev = SearchListAct;					
-+		}
-+		SearchListAct = SearchListAct->next;
-+	}
-+	SearchListAct = SearchListRoot;	//Set to beginning of List
-+	
-+// 	fAct = gcAct->facetPtr;//???
-+	gcAct->writeConeToFile(*gcAct);			
-+	/*End of initialisation*/
-+	
-+	fAct = SearchListAct;
-+	/*2nd step
-+	  Choose a facet from SearchList, flip it and forget the previous cone
-+	  We always choose the first facet from SearchList as facet to be flipped
-+	*/	
-+	while( (SearchListAct!=NULL))//&& counter<490)
-+	{//NOTE See to it that the cone is only changed after ALL facets have been flipped!				
-+		fAct = SearchListAct;		
-+ 		while(fAct!=NULL)
-+// 		while( (fAct->getUCN() == fAct->next->getUCN()) )		
-+		{	//Since SLA should only contain flippables there should be no need to check for that			
-+			gcAct->flip2(gcAct->gcBasis,fAct);
-+			//NOTE rCopy needed?
-+			ring rTmp=rCopy(fAct->flipRing);
-+			rComplete(rTmp);
-+			rChangeCurrRing(rTmp);
-+			gcone *gcTmp = new gcone(*gcAct,*fAct);//copy constructor!
-+			/* Now gcTmp->gcBasis and gcTmp->baseRing are set from fAct->flipGB and fAct->flipRing.
-+			 * Since we come at most once across a given facet from gcAct->facetPtr we can delete them.
-+			 * NOTE: Can this cause trouble with the destructor?
-+			 * Answer: Yes it bloody well does!
-+			 * However I'd like to delete this data here, since if we have a cone with many many facets it
-+			 * should pay to get rid of the flipGB as soon as possible.
-+			 * Destructor must be equipped with necessary checks.
-+			*/
-+ 			idDelete((ideal *)&fAct->flipGB);
-+			rDelete(fAct->flipRing);			
-+			gcTmp->getConeNormals(gcTmp->gcBasis/*, FALSE*/);
-+// 			gcTmp->getCodim2Normals(*gcTmp);
-+			gcTmp->getExtremalRays(*gcTmp);
-+			//NOTE Order rays lex here
-+			gcTmp->orderRays();			
-+// 			//NOTE If flip2 is used we need to get an interior point of gcTmp
-+// 			// and replace gcTmp->baseRing with an appropriate ring with only
-+// 			// one weight
-+// 			gcTmp->interiorPoint2();
-+			gcTmp->replaceDouble_ringorder_a_ByASingleOne();
-+			//gcTmp->ddFacets should not be needed anymore, so
-+			dd_FreeMatrix(gcTmp->ddFacets);
-+#ifndef NDEBUG
-+// 			gcTmp->showFacets(1);
-+#endif
-+			/*add facets to SLA here*/
-+#ifdef SHALLOW
-+  #ifndef NDEBUG
-+			printf("fActUCN before enq2: %i\n",fAct->getUCN());
-+  #endif
-+			facet *tmp;
-+			tmp=gcTmp->enqueue2(SearchListRoot);
-+  #ifndef NDEBUG
-+			printf("\nheadUCN=%i\n",tmp->getUCN());
-+			printf("fActUCN after enq2: %i\n",fAct->getUCN());
-+  #endif
-+			SearchListRoot=tmp;
-+			//SearchListRoot=gcTmp->enqueue2/*NewFacets*/(SearchListRoot);
-+#else 
-+			SearchListRoot=gcTmp->enqueueNewFacets(SearchListRoot);
-+#endif //ifdef SHALLOW
-+// 			gcTmp->writeConeToFile(*gcTmp);
-+ 			if(gfanHeuristic==1)
-+ 			{
-+				gcTmp->writeConeToFile(*gcTmp);
-+ 				idDelete((ideal*)&gcTmp->gcBasis);//Whonder why?
-+				rDelete(gcTmp->baseRing);
-+ 			}			
-+#ifndef NDEBUG
-+			if(SearchListRoot!=NULL)
-+				showSLA(*SearchListRoot);
-+#endif			
-+			rChangeCurrRing(gcAct->baseRing);
-+			rDelete(rTmp);
-+			//doubly linked for easier removal
-+			gcTmp->prev = gcPtr;
-+			gcPtr->next=gcTmp;
-+			gcPtr=gcPtr->next;
-+			//Cleverly disguised exit condition follows
-+			if(fAct->getUCN() == fAct->next->getUCN())
-+			{
-+				printf("Switching UCN from %i to %i\n",fAct->getUCN(),fAct->next->getUCN());
-+				fAct=fAct->next;				
-+			}
-+			else
-+			{
-+				//rDelete(gcAct->baseRing);
-+// 				printf("break\n");
-+				break;
-+			}
-+// 			fAct=fAct->next;
-+		}//while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) );		
-+		//Search for cone with smallest UCN
-+#ifndef NDEBUG
-+  #if SIZEOF_LONG==8	//64 bit
-+		while(gcNext!=(gcone * const)0xfbfbfbfbfbfbfbfb && SearchListRoot!=NULL)
-+  #elif SIZEOF_LONG == 4
-+		while(gcNext!=(gcone * const)0xfbfbfbfb && SearchListRoot!=NULL)
-+  #endif
-+#endif
-+#ifdef NDEBUG
-+		while(gcNext!=NULL && SearchListRoot!=NULL)	
-+#endif
-+		{			
-+			if( gcNext->getUCN() == SearchListRoot->getUCN() )
-+			{
-+				if(gfanHeuristic==0)
-+				{
-+					gcAct = gcNext;
-+					//Seems better to not to use rCopy here
-+// 					rAct=rCopy(gcAct->baseRing);
-+					rAct=gcAct->baseRing;
-+					rComplete(rAct);
-+					rChangeCurrRing(rAct);						
-+					break;
-+				}
-+				else if(gfanHeuristic==1)
-+				{
-+					gcone *gcDel;
-+					gcDel = gcAct;					
-+					gcAct = gcNext;
-+					//Read st00f from file &
-+					//implant the GB into gcAct
-+					readConeFromFile(gcAct->getUCN(), gcAct);
-+					//Kill the baseRing but ONLY if it is not the ring the computation started in!
-+// 					if(gcDel->getUCN()!=1)//WTF!? This causes the Mandelbug in gcone::areEqual(facet, facet)
-+// 						rDelete(gcDel->baseRing);
-+// 					rAct=rCopy(gcAct->baseRing);
-+					/*The ring change occurs in readConeFromFile, so as to 
-+					assure that gcAct->gcBasis belongs to the right ring*/
-+					rAct=gcAct->baseRing;
-+					rComplete(rAct);
-+					rChangeCurrRing(rAct);
-+					break;
-+				}				
-+			}
-+			else if(gcNext->getUCN() < SearchListRoot->getUCN() )
-+			{
-+				idDelete( (ideal*)&gcNext->gcBasis );				
-+// 				rDelete(gcNext->baseRing);//TODO Why does this crash?
-+			}
-+			/*else
-+			{
-+				if(gfanHeuristic==1)
-+				{
-+					gcone *gcDel;
-+					gcDel = gcNext;
-+					if(gcDel->getUCN()!=1)
-+						rDelete(gcDel->baseRing);
-+				}					
-+			}*/			
-+ 			gcNext = gcNext->next;
-+		}
-+		UCNcounter++;
-+		SearchListAct = SearchListRoot;		
-+	}
-+	printf("\nFound %i cones - terminating\n", counter);
-+}//void noRevS(gcone &gc)	
-+		
-+		
-+/** \brief Make a set of rational vectors into integers
-+ *
-+ * We compute the lcm of the denominators and multiply with this to get integer values.
-+ * If the gcd of the nominators > 1 we divide by the gcd => primitive vector.
-+ * Expects a new int64vec as 3rd parameter
-+ * \param dd_MatrixPtr,int64vec
-+ */
-+void gcone::makeInt(const dd_MatrixPtr &M, const int line, int64vec &n)
-+{			
-+	mpz_t *denom = new mpz_t[this->numVars];
-+	for(int ii=0;ii<this->numVars;ii++)
-+	{
-+		mpz_init_set_str(denom[ii],"0",10);
-+	}
-+		
-+	mpz_t kgV,tmp;
-+	mpz_init(kgV);
-+	mpz_init(tmp);
-+			
-+	for (int ii=0;ii<(M->colsize)-1;ii++)
-+	{
-+		mpz_t z;
-+		mpz_init(z);
-+		mpq_get_den(z,M->matrix[line-1][ii+1]);
-+		mpz_set( denom[ii], z);
-+		mpz_clear(z);				
-+	}
-+						
-+	/*Compute lcm of the denominators*/
-+	mpz_set(tmp,denom[0]);
-+	for (int ii=0;ii<(M->colsize)-1;ii++)
-+	{
-+		mpz_lcm(kgV,tmp,denom[ii]);
-+		mpz_set(tmp,kgV);				
-+	}
-+	mpz_clear(tmp);	
-+	/*Multiply the nominators by kgV*/
-+	mpq_t qkgV,res;
-+	mpq_init(qkgV);
-+	mpq_set_str(qkgV,"1",10);
-+	mpq_canonicalize(qkgV);
-+			
-+	mpq_init(res);
-+	mpq_set_str(res,"1",10);
-+	mpq_canonicalize(res);
-+			
-+	mpq_set_num(qkgV,kgV);
-+			
-+//	mpq_canonicalize(qkgV);
-+// 	int ggT=1;
-+	for (int ii=0;ii<(M->colsize)-1;ii++)
-+	{
-+		mpq_mul(res,qkgV,M->matrix[line-1][ii+1]);
-+		n[ii]=(int64)mpz_get_d(mpq_numref(res));
-+// 		ggT=int64gcd(ggT,n[ii]);
-+	}
-+	int64 ggT=n[0];
-+	for(int ii=0;ii<this->numVars;ii++)
-+		ggT=int64gcd(ggT,n[ii]);	
-+	//Normalisation
-+	if(ggT>1)
-+	{
-+		for(int ii=0;ii<this->numVars;ii++)
-+			n[ii] /= ggT;
-+	}
-+	delete [] denom;
-+	mpz_clear(kgV);
-+	mpq_clear(qkgV); mpq_clear(res);			
-+			
-+}
-+/**
-+ * For all codim-2-facets we compute the gcd of the components of the facet normal and 
-+ * divide it out. Thus we get a normalized representation of each
-+ * (codim-2)-facet normal, i.e. a primitive vector
-+ * Actually we now also normalize the facet normals.
-+ */
-+// void gcone::normalize()
-+// {
-+// 	int *ggT = new int;
-+// 		*ggT=1;
-+// 	facet *fAct;
-+// 	facet *codim2Act;
-+// 	fAct = this->facetPtr;
-+// 	codim2Act = fAct->codim2Ptr;
-+// 	while(fAct!=NULL)
-+// 	{
-+// 		int64vec *fNormal;
-+// 		fNormal = fAct->getFacetNormal();
-+// 		int *ggT = new int;
-+// 		*ggT=1;
-+// 		for(int ii=0;ii<this->numVars;ii++)
-+// 		{
-+// 			*ggT=intgcd((*ggT),(*fNormal)[ii]);
-+// 		}
-+// 		if(*ggT>1)//We only need to do this if the ggT is non-trivial
-+// 		{
-+// // 			int64vec *fCopy = fAct->getFacetNormal();
-+// 			for(int ii=0;ii<this->numVars;ii++)
-+// 				(*fNormal)[ii] = ((*fNormal)[ii])/(*ggT);
-+// 			fAct->setFacetNormal(fNormal);
-+// 		}		
-+// 		delete fNormal;
-+// 		delete ggT;
-+// 		/*And now for the codim2*/
-+// 		while(codim2Act!=NULL)
-+// 		{				
-+// 			int64vec *n;
-+// 			n=codim2Act->getFacetNormal();
-+// 			int *ggT=new int;
-+// 			*ggT=1;
-+// 			for(int ii=0;ii<this->numVars;ii++)
-+// 			{
-+// 				*ggT = intgcd((*ggT),(*n)[ii]);
-+// 			}
-+// 			if(*ggT>1)
-+// 			{
-+// 				for(int ii=0;ii<this->numVars;ii++)
-+// 				{
-+// 					(*n)[ii] = ((*n)[ii])/(*ggT);
-+// 				}
-+// 				codim2Act->setFacetNormal(n);
-+// 			}
-+// 			codim2Act = codim2Act->next;
-+// 			delete n;
-+// 			delete ggT;
-+// 		}
-+// 		fAct = fAct->next;
-+// 	}
-+// }
-+
-+/** \brief Enqueue new facets into the searchlist 
-+ * The searchlist (SLA for short) is implemented as a FIFO
-+ * Checks are done as follows:
-+ * 1) Check facet fAct against all facets in SLA for parallelity. If it is not parallel to any one add it.
-+ * 2) If it is parallel compare the codim2 facets. If they coincide the facets are equal and we delete the 
-+ *	facet from SLA and do not add fAct.
-+ * It may very well happen, that SLA=\f$ \emptyset \f$ but we do not have checked all fActs yet. In this case we
-+ * can be sure, that none of the facets that are still there already were in SLA once, so we just dump them into SLA.
-+ * Takes ptr to search list root
-+ * Returns a pointer to new first element of Searchlist
-+ */
-+facet * gcone::enqueueNewFacets(facet *f)
-+{
-+#ifdef gfanp
-+	timeval start, end;
-+	gettimeofday(&start, 0);
-+#endif
-+	facet *slHead;
-+	slHead = f;
-+	facet *slAct;	//called with f=SearchListRoot
-+	slAct = f;
-+	facet *slEnd;	//Pointer to end of SLA
-+	slEnd = f;
-+// 	facet *slEndStatic;	//marks the end before a new facet is added		
-+	facet *fAct;
-+	fAct = this->facetPtr;
-+	facet *codim2Act;
-+	codim2Act = this->facetPtr->codim2Ptr;
-+	facet *sl2Act;
-+	sl2Act = f->codim2Ptr;
-+	/** Pointer to a facet that will be deleted */
-+	volatile facet *deleteMarker;
-+	deleteMarker = NULL;
-+			
-+	/** \brief  Flag to mark a facet that might be added
-+	 * The following case may occur:
-+	 * A facet fAct is found to be parallel but not equal to the current facet slAct from SLA.
-+	 * This does however not mean that there does not exist a facet behind the current slAct that is actually equal
-+	 * to fAct. In this case we set the boolean flag maybe to TRUE. If we encounter an equality lateron, it is reset to
-+	 * FALSE and the according slAct is deleted. 
-+	 * If slAct->next==NULL AND maybe==TRUE we know, that fAct must be added
-+	 */
-+
-+	/**A facet was removed, lengthOfSearchlist-- thus we must not rely on 
-+	 * if(notParallelCtr==lengthOfSearchList) but rather
-+	 * if( (notParallelCtr==lengthOfSearchList && removalOccured==FALSE)
-+	 */
-+	volatile bool removalOccured=FALSE;
-+	while(slEnd->next!=NULL)
-+	{
-+		slEnd=slEnd->next;
-+	}
-+	/*1st step: compare facetNormals*/			
-+	while(fAct!=NULL)
-+	{						
-+		if(fAct->isFlippable==TRUE)
-+		{
-+			int64vec *fNormal=NULL;
-+			fNormal=fAct->getFacetNormal();			
-+			slAct = slHead;
-+			/*If slAct==NULL and fAct!=NULL 
-+			we just copy all remaining facets into SLA*/
-+			if(slAct==NULL)
-+			{
-+				facet *fCopy;
-+				fCopy = fAct;
-+				while(fCopy!=NULL)
-+				{
-+					if(fCopy->isFlippable==TRUE)//We must assure fCopy is also flippable
-+					{
-+						if(slAct==NULL)
-+						{
-+							slAct = new facet(*fCopy/*,TRUE*/);//copy constructor
-+							slHead = slAct;								
-+						}
-+						else
-+						{
-+							slAct->next = new facet(*fCopy/*,TRUE*/);
-+							slAct = slAct->next;
-+						}
-+					}
-+					fCopy = fCopy->next;
-+				}
-+				break;//Where does this lead to?
-+			}
-+			/*End of dumping into SLA*/
-+			while(slAct!=NULL)
-+			{
-+				int64vec *slNormal=NULL;
-+				removalOccured=FALSE;
-+				slNormal = slAct->getFacetNormal();
-+#ifndef NDEBUG
-+				printf("Checking facet (");fNormal->show(1,1);printf(") against (");slNormal->show(1,1);printf(")\n");
-+#endif				
-+// 				if( (areEqual(fAct,slAct) && (!areEqual2(fAct,slAct)) ))
-+// 					exit(-1);
-+ 				if(areEqual2(fAct,slAct))
-+				{					
-+					deleteMarker = slAct;
-+					if(slAct==slHead)
-+					{						
-+						slHead = slAct->next;						
-+						if(slHead!=NULL)
-+							slHead->prev = NULL;
-+					}
-+					else if (slAct==slEnd)
-+					{
-+						slEnd=slEnd->prev;
-+						slEnd->next = NULL;
-+					}								
-+					else
-+					{
-+						slAct->prev->next = slAct->next;
-+						slAct->next->prev = slAct->prev;
-+					}
-+					removalOccured=TRUE;
-+					gcone::lengthOfSearchList--;
-+					if(deleteMarker!=NULL)
-+					{
-+// 						delete deleteMarker;
-+// 						deleteMarker=NULL;
-+					}
-+#ifndef NDEBUG
-+					printf("Removing (");fNormal->show(1,1);printf(") from list\n");
-+#endif
-+					delete slNormal;
-+					break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct
-+				}
-+				slAct = slAct->next;
-+				/* NOTE The following lines must not be here but rather called inside the if-block above.
-+				Otherwise results get crappy. Unfortunately there are two slAct=slAct->next calls now,
-+				(not nice!) but since they are in seperate branches of the if-statement there should not
-+				be a way it gets called twice thus ommiting one facet:
-+				slAct = slAct->next;*/
-+				if(deleteMarker!=NULL)
-+				{						
-+//  					delete deleteMarker;
-+//  					deleteMarker=NULL;
-+				}
-+				delete slNormal;
-+						//if slAct was marked as to be deleted, delete it here!
-+			}//while(slAct!=NULL)
-+			if(removalOccured==FALSE)
-+			{
-+#ifndef NDEBUG
-+// 				cout << "Adding facet (";fNormal->show(1,0);cout << ") to SLA " << endl;
-+#endif
-+				//Add fAct to SLA
-+				facet *marker;
-+				marker = slEnd;
-+				facet *f2Act;
-+				f2Act = fAct->codim2Ptr;
-+
-+				slEnd->next = new facet();
-+				slEnd = slEnd->next;//Update slEnd
-+				facet *slEndCodim2Root;
-+				facet *slEndCodim2Act;
-+				slEndCodim2Root = slEnd->codim2Ptr;
-+				slEndCodim2Act = slEndCodim2Root;
-+								
-+				slEnd->setUCN(this->getUCN());
-+				slEnd->isFlippable = TRUE;
-+				slEnd->setFacetNormal(fNormal);
-+				//NOTE Add interior point here
-+				//This is ugly but needed for flip2
-+				//Better: have slEnd->interiorPoint point to fAct->interiorPoint
-+				//NOTE Only reference -> c.f. copy constructor
-+				//slEnd->setInteriorPoint(fAct->getInteriorPoint());
-+				slEnd->interiorPoint = fAct->interiorPoint;
-+				slEnd->prev = marker;
-+				//Copy codim2-facets
-+				//int64vec *f2Normal=new int64vec(this->numVars);
-+				while(f2Act!=NULL)
-+				{
-+					int64vec *f2Normal;
-+					f2Normal=f2Act->getFacetNormal();
-+					if(slEndCodim2Root==NULL)
-+					{
-+						slEndCodim2Root = new facet(2);
-+						slEnd->codim2Ptr = slEndCodim2Root;			
-+						slEndCodim2Root->setFacetNormal(f2Normal);
-+						slEndCodim2Act = slEndCodim2Root;
-+					}
-+					else					
-+					{
-+						slEndCodim2Act->next = new facet(2);
-+						slEndCodim2Act = slEndCodim2Act->next;
-+						slEndCodim2Act->setFacetNormal(f2Normal);
-+					}
-+					f2Act = f2Act->next;
-+					delete f2Normal;
-+				}
-+				gcone::lengthOfSearchList++;							
-+			}//if( (notParallelCtr==lengthOfSearchList && removalOccured==FALSE) ||
-+			fAct = fAct->next;
-+ 			delete fNormal;
-+//  			delete slNormal;
-+		}//if(fAct->isFlippable==TRUE)
-+		else
-+		{
-+			fAct = fAct->next;
-+		}
-+		if(gcone::maxSize<gcone::lengthOfSearchList)
-+			gcone::maxSize= gcone::lengthOfSearchList;
-+	}//while(fAct!=NULL)
-+#ifdef gfanp
-+	gettimeofday(&end, 0);
-+	time_enqueue += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-+#endif						
-+	return slHead;
-+}//addC2N
-+
-+/** Enqueuing using shallow copies*/
-+facet * gcone::enqueue2(facet *f)
-+{
-+	assert(f!=NULL);
-+#ifdef gfanp
-+	timeval start, end;
-+	gettimeofday(&start, 0);
-+#endif
-+	facet *slHead;
-+	slHead = f;
-+	facet *slAct;	//called with f=SearchListRoot
-+	slAct = f;
-+	static facet *slEnd;	//Pointer to end of SLA
-+	if(slEnd==NULL)
-+		slEnd = f;
-+	
-+	facet *fAct;
-+	fAct = this->facetPtr;//New facets to compare
-+	facet *codim2Act;
-+	codim2Act = this->facetPtr->codim2Ptr;
-+	volatile bool removalOccured=FALSE;
-+	while(slEnd->next!=NULL)
-+	{
-+		slEnd=slEnd->next;
-+	}	
-+	while(fAct!=NULL)
-+	{
-+		if(fAct->isFlippable)
-+		{
-+			facet *fDeleteMarker=NULL;
-+			slAct = slHead;
-+			if(slAct==NULL)
-+			{
-+				printf("Zero length SLA\n");
-+				facet *fCopy;
-+				fCopy = fAct;				
-+				while(fCopy!=NULL)
-+				{
-+					if(fCopy->isFlippable==TRUE)//We must assure fCopy is also flippable
-+					{
-+						if(slAct==NULL)
-+						{
-+							slAct = slAct->shallowCopy(*fCopy);//shallow copy constructor
-+							slHead = slAct;								
-+						}
-+						else
-+						{
-+							slAct->next = slAct->shallowCopy(*fCopy);
-+							slAct = slAct->next;
-+						}
-+					}
-+					fCopy = fCopy->next;
-+				}
-+				break;	//WTF?
-+			}
-+			/*Comparison starts here*/
-+			while(slAct!=NULL)
-+			{
-+				removalOccured=FALSE;
-+#ifndef NDEBUG
-+	printf("Checking facet (");fAct->fNormal->show(1,1);printf(") against (");slAct->fNormal->show(1,1);printf(")\n");
-+#endif	
-+				if(areEqual2(fAct,slAct))
-+				{
-+					fDeleteMarker=slAct;
-+					if(slAct==slHead)
-+					{
-+// 						fDeleteMarker=slHead;
-+// 						printf("headUCN at enq=%i\n",slHead->getUCN());
-+						slHead = slAct->next;						
-+// 						printf("headUCN at enq=%i\n",slHead->getUCN());
-+						if(slHead!=NULL)
-+						{
-+							slHead->prev = NULL;
-+						}
-+						fDeleteMarker->shallowDelete();
-+ 						//delete fDeleteMarker;//NOTE this messes up fAct in noRevS!
-+// 						printf("headUCN at enq=%i\n",slHead->getUCN());
-+					}
-+					else if (slAct==slEnd)
-+					{
-+						slEnd=slEnd->prev;
-+						slEnd->next = NULL;
-+						fDeleteMarker->shallowDelete();
-+						delete(fDeleteMarker);
-+					}								
-+					else
-+					{
-+						slAct->prev->next = slAct->next;
-+						slAct->next->prev = slAct->prev;
-+						fDeleteMarker->shallowDelete();
-+						delete(fDeleteMarker);
-+					}
-+					removalOccured=TRUE;
-+					gcone::lengthOfSearchList--;
-+#ifndef NDEBUG
-+printf("Removing (");fAct->fNormal->show(1,1);printf(") from list\n");
-+#endif
-+					break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct
-+				}
-+				slAct = slAct->next;				
-+			}//while(slAct!=NULL)
-+			if(removalOccured==FALSE)
-+			{
-+				facet *marker=slEnd;
-+				slEnd->next = fAct->shallowCopy(*fAct);
-+				slEnd = slEnd->next;
-+				slEnd->prev=marker;
-+				gcone::lengthOfSearchList++;
-+			}
-+			fAct = fAct->next;
-+// 			if(fDeleteMarker!=NULL)
-+// 			{
-+// 				fDeleteMarker->shallowDelete();
-+// 				delete(fDeleteMarker);
-+// 				fDeleteMarker=NULL;
-+// 			}
-+		}
-+		else
-+			fAct = fAct->next;
-+	}//while(fAct!=NULL)
-+	
-+#ifdef gfanp
-+	gettimeofday(&end, 0);
-+	time_enqueue += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-+#endif	
-+// 	printf("headUCN at enq=%i\n",slHead->getUCN());
-+	return slHead;
-+}
-+
-+/** 
-+* During flip2 every gc->baseRing gets two ringorder_a
-+* To avoid having an awful lot of those in the end we endow
-+* gc->baseRing by a suitable ring with (a,dp,C) and copy all
-+* necessary stuff over
-+* But first we will try to just do an inplace exchange and copying only the
-+* gc->gcBasis
-+*/
-+void gcone::replaceDouble_ringorder_a_ByASingleOne()
-+{
-+	ring srcRing=currRing;
-+	ring replacementRing=rCopy0((ring)this->baseRing);
-+	/*We assume we have (a(),a(),dp) here*/
-+	omFree(replacementRing->order);
-+	replacementRing->order =(int *)omAlloc0(4*sizeof(int/*64*/));
-+	omFree(replacementRing->block0);
-+	replacementRing->block0=(int *)omAlloc0(4*sizeof(int/*64*/));
-+	omFree(replacementRing->block1);
-+	replacementRing->block1=(int *)omAlloc0(4*sizeof(int/*64*/));
-+	omfree(replacementRing->wvhdl);
-+	replacementRing->wvhdl =(int **)omAlloc0(4*sizeof(int/*64*/**));
-+			
-+	replacementRing->order[0]=ringorder_a/*64*/;
-+	replacementRing->block0[0]=1;
-+	replacementRing->block1[0]=replacementRing->N;
-+		
-+	replacementRing->order[1]=ringorder_dp;
-+	replacementRing->block0[1]=1;
-+	replacementRing->block1[1]=replacementRing->N;
-+	
-+	replacementRing->order[2]=ringorder_C;
-+
-+	int64vec *ivw = this->getIntPoint(TRUE);//returns a reference
-+// 	assert(this->ivIntPt);	
-+	int length=ivw->length();	
-+	int/*64*/ *A=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
-+	for (int jj=0;jj<length;jj++)
-+	{
-+		A[jj]=(*ivw)[jj];
-+		if((*ivw)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::replaceDouble_ringorder_a_ByASingleOne!\n");
-+	}	
-+	//delete ivw; //Not needed if this->getIntPoint(TRUE)
-+	replacementRing->wvhdl[0]=(int *)A;
-+	replacementRing->block1[0]=length;
-+	/*Finish*/
-+	rComplete(replacementRing);
-+	rChangeCurrRing(replacementRing);
-+	ideal temporaryGroebnerBasis=idrCopyR(this->gcBasis,this->baseRing);
-+	rDelete(this->baseRing);
-+	this->baseRing=rCopy(replacementRing);
-+	this->gcBasis=idCopy(temporaryGroebnerBasis);	
-+	/*And back to where we came from*/
-+	rChangeCurrRing(srcRing);
-+	idDelete( (ideal*)&temporaryGroebnerBasis );
-+	rDelete(replacementRing);	
-+}
-+
-+/** \brief Compute the gcd of two ints
-+ */
-+static int64 int64gcd(const int64 &a, const int64 &b)
-+{
-+	int64 r, p=a, q=b;
-+	if(p < 0)
-+		p = -p;
-+	if(q < 0)
-+		q = -q;
-+	while(q != 0)
-+	{
-+		r = p % q;
-+		p = q;
-+		q = r;
-+	}
-+	return p;
-+}
-+	
-+static int intgcd(const int &a, const int &b)
-+{
-+	int r, p=a, q=b;
-+	if(p < 0)
-+		p = -p;
-+	if(q < 0)
-+		q = -q;
-+	while(q != 0)
-+	{
-+		r = p % q;
-+		p = q;
-+		q = r;
-+	}
-+	return p;
-+}
-+		
-+/** \brief Construct a dd_MatrixPtr from a cone's list of facets
-+ * NO LONGER USED
-+ */
-+// inline dd_MatrixPtr gcone::facets2Matrix(const gcone &gc)
-+// {
-+// 	facet *fAct;
-+// 	fAct = gc.facetPtr;
-+// 	
-+// 	dd_MatrixPtr M;
-+// 	dd_rowrange ddrows;
-+// 	dd_colrange ddcols;
-+// 	ddcols=(this->numVars)+1;
-+// 	ddrows=this->numFacets;
-+// 	dd_NumberType numb = dd_Integer;
-+// 	M=dd_CreateMatrix(ddrows,ddcols);			
-+// 			
-+// 	int jj=0;
-+// 	
-+// 	while(fAct!=NULL)
-+// 	{
-+// 		int64vec *comp;
-+// 		comp = fAct->getFacetNormal();
-+// 		for(int ii=0;ii<this->numVars;ii++)
-+// 		{
-+// 			dd_set_si(M->matrix[jj][ii+1],(*comp)[ii]);
-+// 		}
-+// 		jj++;
-+// 		delete comp;
-+// 		fAct=fAct->next;				
-+// 	}			
-+// 	return M;
-+// }
-+		
-+/** \brief Write information about a cone into a file on disk
-+ *
-+ * This methods writes the information needed for the "second" method into a file.
-+ * The file's is divided in sections containing information on
-+ * 1) the ring
-+ * 2) the cone's Groebner Basis
-+ * 3) the cone's facets
-+ * Each line contains exactly one date
-+ * Each section starts with its name in CAPITALS
-+ */
-+void gcone::writeConeToFile(const gcone &gc, bool usingIntPoints)
-+{
-+	int UCN=gc.UCN;
-+	stringstream ss;
-+	ss << UCN;
-+	string UCNstr = ss.str();		
-+			
-+ 	string prefix="/tmp/Singular/cone";
-+// 	string prefix="./";	//crude hack -> run tests in separate directories
-+	string suffix=".sg";
-+	string filename;
-+	filename.append(prefix);
-+	filename.append(UCNstr);
-+	filename.append(suffix);
-+		
-+// 	int thisPID = getpid();
-+// 	ss << thisPID;
-+// 	string strPID = ss.str();
-+// 	string prefix="./";
-+						
-+	ofstream gcOutputFile(filename.c_str());
-+	assert(gcOutputFile);
-+	facet *fAct;
-+	fAct = gc.facetPtr;			
-+	facet *f2Act;
-+	f2Act=fAct->codim2Ptr;
-+	
-+	char *ringString = rString(gc.baseRing);
-+			
-+	if (!gcOutputFile)
-+	{
-+		WerrorS("Error opening file for writing in writeConeToFile\n");
-+	}
-+	else
-+	{	
-+		gcOutputFile << "UCN" << endl;
-+		gcOutputFile << this->UCN << endl;
-+		gcOutputFile << "RING" << endl;	
-+		gcOutputFile << ringString << endl;
-+		gcOutputFile << "GCBASISLENGTH" << endl;
-+		gcOutputFile << IDELEMS(gc.gcBasis) << endl;			
-+		//Write this->gcBasis into file
-+		gcOutputFile << "GCBASIS" << endl;				
-+		for (int ii=0;ii<IDELEMS(gc.gcBasis);ii++)
-+		{					
-+			gcOutputFile << p_String((poly)gc.gcBasis->m[ii],gc.baseRing) << endl;
-+		}				
-+					
-+		gcOutputFile << "FACETS" << endl;								
-+		
-+		while(fAct!=NULL)
-+		{	
-+			const int64vec *iv=fAct->getRef2FacetNormal();
-+// 			iv=fAct->getRef2FacetNormal();//->getFacetNormal();
-+			f2Act=fAct->codim2Ptr;
-+			for (int ii=0;ii<iv->length();ii++)
-+			{
-+// 				if (ii<iv->length()-1)
-+// 					gcOutputFile << (*iv)[ii] << ",";
-+// 				else
-+// 					gcOutputFile << (*iv)[ii] << " ";
-+				gcOutputFile << (*iv)[ii];
-+				(ii<iv->length()-1) ? gcOutputFile << "," : gcOutputFile << " ";
-+			}
-+			//delete iv;
-+			while(f2Act!=NULL)
-+			{
-+				const int64vec *iv2;
-+				iv2=f2Act->getRef2FacetNormal();
-+				for(int jj=0;jj<iv2->length();jj++)
-+				{
-+// 					if (jj<iv2->length()-1)
-+// 						gcOutputFile << (*iv2)[jj] << ",";
-+// 					else
-+// 						gcOutputFile << (*iv2)[jj] << " ";
-+					gcOutputFile << (*iv2)[jj];
-+					(jj<iv2->length()-1) ? gcOutputFile << "," : gcOutputFile << " ";
-+				}
-+				f2Act = f2Act->next;
-+			}
-+			gcOutputFile << endl;
-+			fAct=fAct->next;
-+		}			
-+	gcOutputFile.close();
-+	}
-+	delete [] ringString;
-+			
-+}//writeConeToFile(gcone const &gc)
-+		
-+/** \brief Reads a cone from a file identified by its number
-+* ||depending on whether flip or flip2 is used, switch the flag flipFlag
-+* ||defaults to 0 => flip
-+* ||1 => flip2
-+*/
-+void gcone::readConeFromFile(int UCN, gcone *gc)
-+{
-+	//int UCN=gc.UCN;
-+	stringstream ss;
-+	ss << UCN;
-+	string UCNstr = ss.str();
-+	int gcBasisLength=0;
-+	size_t found;	//used for find_first_(not)_of
-+
-+	string prefix="/tmp/Singular/cone";
-+	string suffix=".sg";
-+	string filename;
-+	filename.append(prefix);
-+	filename.append(UCNstr);
-+	filename.append(suffix);
-+					
-+	ifstream gcInputFile(filename.c_str(), ifstream::in);
-+	
-+	ring saveRing=currRing;	
-+	//Comment the following if you uncomment the if(line=="RING") part below
-+//  	rChangeCurrRing(gc->baseRing);
-+	
-+	while( !gcInputFile.eof() )
-+	{
-+		string line;
-+		getline(gcInputFile,line);
-+		if(line=="RING")
-+		{
-+			getline(gcInputFile,line);
-+			found = line.find("a(");
-+			line.erase(0,found+2);
-+			string strweight;
-+			strweight=line.substr(0,line.find_first_of(")"));
-+						
-+			int64vec *iv=new int64vec(this->numVars);// 			
-+			for(int ii=0;ii<this->numVars;ii++)
-+			{
-+				string weight;
-+				weight=line.substr(0,line.find_first_of(",)"));
-+				char *w=new char[weight.size()+1];
-+				strcpy(w,weight.c_str());
-+				(*iv)[ii]=atol(w/*weight.c_str()*/);//Better to long. Weight bound in Singular:2147483647
-+				delete[] w;
-+				line.erase(0,line.find_first_of(",)")+1);
-+			}
-+			found = line.find("a(");
-+			
-+			ring newRing;
-+			if(currRing->order[0]!=ringorder_a/*64*/)
-+			{
-+					newRing=rCopyAndAddWeight(currRing,iv);
-+			}
-+			else
-+			{ 	
-+					newRing=rCopy0(currRing);
-+					int length=this->numVars;
-+					int *A=(int *)omAlloc0(length*sizeof(int));
-+					for(int jj=0;jj<length;jj++)
-+					{
-+						A[jj]=(*iv)[jj];
-+					}
-+					omFree(newRing->wvhdl[0]);
-+					newRing->wvhdl[0]=(int*)A;
-+					newRing->block1[0]=length;
-+			}
-+			delete iv;
-+ 			rComplete(newRing);
-+			gc->baseRing=rCopy(newRing);
-+			rDelete(newRing);
-+			rComplete(gc->baseRing);
-+			if(currRing!=gc->baseRing)
-+				rChangeCurrRing(gc->baseRing);
-+		}
-+		
-+		if(line=="GCBASISLENGTH")
-+		{
-+			string strGcBasisLength;
-+			getline(gcInputFile, line);
-+			strGcBasisLength = line;
-+			char *s=new char[strGcBasisLength.size()+1];
-+			strcpy(s,strGcBasisLength.c_str());
-+			int size=atoi(s/*strGcBasisLength.c_str()*/);
-+			delete[] s;
-+			gcBasisLength=size;		
-+			gc->gcBasis=idInit(size,1);
-+		}
-+		if(line=="GCBASIS")
-+		{
-+			for(int jj=0;jj<gcBasisLength;jj++)
-+			{
-+				getline(gcInputFile,line);
-+				//magically convert strings into polynomials
-+				//polys.cc:p_Read
-+				//check until first occurance of + or -
-+				//data or c_str	
-+// 				poly strPoly;//=pInit();//Ought to be inside the while loop, but that will eat your memory
-+				poly resPoly=pInit();	//The poly to be read in		
-+				while(!line.empty())
-+				{
-+					poly strPoly;//=pInit();
-+					
-+					string strMonom, strCoeff, strCoeffNom, strCoeffDenom;
-+					bool hasCoeffInQ = FALSE;	//does the polynomial have rational coeff?
-+					bool hasNegCoeff = FALSE;	//or a negative one?
-+					found = line.find_first_of("+-");	//get the first monomial
-+					string tmp;
-+					tmp=line[found];
-+// 					if(found!=0 && (tmp.compare("-")==0) )
-+// 						hasNegCoeff = TRUE;	//We have a coeff < 0
-+					if(found==0)
-+					{
-+						if(tmp.compare("-")==0)
-+							hasNegCoeff = TRUE;
-+						line.erase(0,1);	//remove leading + or -
-+						found = line.find_first_of("+-");	//adjust found
-+					}
-+					strMonom = line.substr(0,found);
-+					line.erase(0,found);
-+					number nCoeff=nInit(1);
-+					number nCoeffNom=nInit(1);
-+					number nCoeffDenom=nInit(1);
-+					found = strMonom.find_first_of("/");
-+					if(found!=string::npos)	//i.e. "/" exists in strMonom
-+					{
-+						hasCoeffInQ = TRUE;
-+						strCoeffNom=strMonom.substr(0,found);						
-+						strCoeffDenom=strMonom.substr(found+1,strMonom.find_first_not_of("1234567890",found+1));
-+						strMonom.erase(0,found);
-+						strMonom.erase(0,strMonom.find_first_not_of("1234567890/"));	
-+						char *Nom=new char[strCoeffNom.size()+1];
-+						char *Denom=new char[strCoeffDenom.size()+1];
-+						strcpy(Nom,strCoeffNom.c_str());
-+						strcpy(Denom,strCoeffDenom.c_str());		
-+						nRead(Nom/*strCoeffNom.c_str()*/, &nCoeffNom);
-+						nRead(Denom/*strCoeffDenom.c_str()*/, &nCoeffDenom);
-+						delete[] Nom;
-+						delete[] Denom;
-+					}
-+					else
-+					{
-+						found = strMonom.find_first_not_of("1234567890");
-+						strCoeff = strMonom.substr(0,found);						
-+						if(!strCoeff.empty())
-+						{
-+							char *coeff = new char[strCoeff.size()+1];
-+							strcpy(coeff, strCoeff.c_str());
-+ 							nRead(coeff/*strCoeff.c_str()*/,&nCoeff);
-+							delete[] coeff;
-+						}
-+					}
-+					char* monom = new char[strMonom.size()+1];
-+					strcpy(monom, strMonom.c_str());						
-+					p_Read(monom,strPoly,currRing);	//strPoly:=monom
-+					delete[] monom;	
-+					switch (hasCoeffInQ)
-+					{
-+						case TRUE:
-+							if(hasNegCoeff)
-+								nCoeffNom=nNeg(nCoeffNom);
-+							pSetCoeff(strPoly, nDiv(nCoeffNom, nCoeffDenom));
-+							break;
-+						case FALSE:
-+							if(hasNegCoeff)
-+								nCoeff=nNeg(nCoeff);							
-+							if(!nIsOne(nCoeff))
-+							{
-+								pSetCoeff(strPoly, nCoeff );
-+							}
-+							break;
-+					}
-+						//pSetCoeff(strPoly, (number) intCoeff);//Why is this set to zero instead of 1???
-+					if(pIsConstantComp(resPoly))
-+					{
-+						resPoly=pCopy(strPoly);
-+						pDelete(&strPoly);
-+					}
-+					else
-+					{
-+// 						poly tmp=pAdd(pCopy(resPoly),strPoly);//foo is destroyed
-+// 						pDelete(&resPoly);
-+// 						resPoly=tmp;
-+// 						pDelete(&tmp);
-+						resPoly=pAdd(resPoly,strPoly);//pAdd = p_Add_q, destroys args
-+					}
-+					/*if(nCoeff!=NULL)					
-+						nDelete(&nCoeff);*/ //NOTE This may cause a crash on certain examples...
-+					nDelete(&nCoeffNom);
-+					nDelete(&nCoeffDenom);
-+				}//while(!line.empty())			
-+				gc->gcBasis->m[jj]=pCopy(resPoly);
-+				pDelete(&resPoly);	//reset
-+			}
-+// 			break;
-+		}//if(line=="GCBASIS")	
-+		if(line=="FACETS")
-+		{
-+			facet *fAct=gc->facetPtr;
-+			while(fAct!=NULL)
-+			{
-+				getline(gcInputFile,line);
-+				found = line.find("\t");
-+				string normalString=line.substr(0,found);
-+				int64vec *fN = new int64vec(this->numVars);
-+				for(int ii=0;ii<this->numVars;ii++)
-+				{
-+					string component;
-+					found = normalString.find(",");
-+					component=normalString.substr(0,found);
-+					char *sComp = new char[component.size()+1];
-+					strcpy(sComp,component.c_str());
-+					(*fN)[ii]=atol(sComp/*component.c_str()*/);
-+					delete[] sComp;
-+					normalString.erase(0,found+1);
-+				}
-+				/*Only the following line needs to be commented out if you decide not to delete fNormals*/
-+// 				fAct->setFacetNormal(fN);
-+				delete(fN);
-+				fAct = fAct->next;	//Booh, this is ugly
-+			}			
-+			break; //NOTE Must always be in the last if-block!
-+		}
-+	}//while(!gcInputFile.eof())	
-+	gcInputFile.close();
-+	rChangeCurrRing(saveRing);
-+}
-+	
-+
-+/** \brief Sort the rays of a facet lexicographically
-+*/
-+// void gcone::sortRays(gcone *gc)
-+// {
-+// 	facet *fAct;
-+// 	fAct = this->facetPtr->codim2Ptr;
-+// 	while(fAct->next!=NULL)
-+// 	{
-+// 		if(fAct->fNormal->compare(fAct->fNormal->next)==-1
-+// 	}
-+// }
-+
-+/** \brief Gather the output
-+* List of lists
-+* If heuristic==1 readConeFromFile() is called once more on every cone. This may slow down the computation but it also
-+* allows us to rDelete(gcDel->baseRing) and the such in gcone::noRevS.
-+*\param *gc Pointer to gcone, preferably gcRoot ;-)
-+*\param n the number of cones as determined by gcRoot->getCounter()
-+*
-+*/
-+lists lprepareResult(gcone *gc, const int n)
-+{
-+	gcone *gcAct;
-+	gcAct = gc;	
-+	facet *fAct;
-+	fAct = gc->facetPtr;
-+	
-+	lists res=(lists)omAllocBin(slists_bin);
-+	res->Init(n);	//initialize to store n cones
-+	for(int ii=0;ii<n;ii++)
-+	{
-+		if(gfanHeuristic==1)// && gcAct->getUCN()>1)
-+		{
-+			gcAct->readConeFromFile(gcAct->getUCN(),gcAct);	
-+// 			rChangeCurrRing(gcAct->getBaseRing());//NOTE memleak?
-+		}
-+		rChangeCurrRing(gcAct->getRef2BaseRing());	
-+		res->m[ii].rtyp=LIST_CMD;
-+		lists l=(lists)omAllocBin(slists_bin);
-+		l->Init(6);
-+		l->m[0].rtyp=INT_CMD;
-+		l->m[0].data=(void*)gcAct->getUCN();
-+		l->m[1].rtyp=IDEAL_CMD;
-+		/*The following is necessary for leaves in the tree of cones
-+		* Since we don't use them in the computation and gcBasis is 
-+		* set to (poly)NULL in noRevS we need to get this back here.
-+		*/
-+// 		if(gcAct->gcBasis->m[0]==(poly)NULL)
-+// 		if(gfanHeuristic==1 && gcAct->getUCN()>1)
-+// 			gcAct->readConeFromFile(gcAct->getUCN(),gcAct);
-+// 		ring saveRing=currRing;
-+// 		ring tmpRing=gcAct->getBaseRing;
-+// 		rChangeCurrRing(tmpRing);
-+// 		l->m[1].data=(void*)idrCopyR_NoSort(gcAct->gcBasis,gcAct->getBaseRing());
-+// 		l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getBaseRing());//NOTE memleak?
-+		l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getRef2BaseRing());
-+// 		rChangeCurrRing(saveRing);
-+
-+		l->m[2].rtyp=INTVEC_CMD;
-+		int64vec iv=(gcAct->f2M(gcAct,gcAct->facetPtr));//NOTE memleak?
-+		l->m[2].data=(void*)iv64Copy(&iv);
-+		
-+		l->m[3].rtyp=LIST_CMD;
-+			lists lCodim2List = (lists)omAllocBin(slists_bin);
-+			lCodim2List->Init(gcAct->numFacets); 
-+			fAct = gcAct->facetPtr;//fAct->codim2Ptr;
-+			int jj=0;
-+			while(fAct!=NULL && jj<gcAct->numFacets)
-+			{
-+				lCodim2List->m[jj].rtyp=INTVEC_CMD;
-+				int64vec ivC2=(gcAct->f2M(gcAct,fAct,2));
-+				lCodim2List->m[jj].data=(void*)iv64Copy(&ivC2);
-+				jj++;
-+				fAct = fAct->next;
-+			} 		
-+		l->m[3].data=(void*)lCodim2List;		
-+		l->m[4].rtyp=INTVEC_CMD/*RING_CMD*/;
-+		l->m[4].data=(void*)(gcAct->getIntPoint/*BaseRing*/()); 		
-+		l->m[5].rtyp=INT_CMD;
-+		l->m[5].data=(void*)gcAct->getPredUCN();
-+		res->m[ii].data=(void*)l;
-+		gcAct = gcAct->next;
-+	}	
-+	return res;
-+}
-+
-+/** Convert gc->gcRays into an intvec in order to be used with bbcone stuff*/
-+intvec *gcRays2Intmat(gcone *gc)
-+{
-+  int r = gc->numRays;
-+  int c = gc->numVars;  //Spalten
-+  intvec *res = new intvec(r,c,(int)0);
-+  
-+  int offset=0;
-+  for(int ii=0;ii<gc->numRays;ii++)
-+  {
-+    int64vec *ivTmp=iv64Copy(gc->gcRays[ii]);
-+    for(int jj=0;jj<pVariables;jj++)
-+      (*res)[offset+jj]=(int)(*ivTmp)[jj];
-+    offset += pVariables;
-+    delete ivTmp;
-+  }
-+  return res;
-+}
-+
-+/** \brief Put stuff in gfanlib's datatype gfan::ZFan
-+*/
-+void prepareGfanLib(gcone *gc, gfan::ZFan *fan)
-+{
-+  using namespace gfan;
-+  int ambientDimension = gc->numVars;
-+  gcone *gcAct;
-+  gcAct = gc;
-+
-+  //Iterate over all cones and adjoin to PolyhedralFan
-+   while(gcAct!=NULL)
-+  {     
-+    intvec *rays=gcRays2Intmat(gcAct);
-+    ZMatrix zm = intmat2ZMatrix(rays);
-+    delete rays;
-+    ZCone *zc = new ZCone();
-+    *zc = ZCone::givenByRays(zm, gfan::ZMatrix(0, zm.getWidth()));
-+//     delete &zm;
-+    zc->canonicalize();//As per Anders' hint
-+    fan->insert(*zc);
-+//     delete zc;
-+    gcAct=gcAct->next;
-+  }
-+}
-+
-+/** \brief Write facets of a cone into a matrix
-+* Takes a pointer to a facet as 2nd arg 
-+* f should always point to gc->facetPtr
-+* param n is used to determine whether it operates in codim 1 or 2
-+* We have to cast the int64vecs to int64vec due to issues with list structure
-+*/
-+inline int64vec gcone::f2M(gcone *gc, facet *f, int n)
-+{
-+	facet *fAct;
-+	int64vec *res;//=new int64vec(this->numVars);	
-+// 	int codim=n;
-+// 	int bound;
-+// 	if(f==gc->facetPtr)
-+	if(n==1)
-+	{
-+		int64vec *m1Res=new int64vec(gc->numFacets,gc->numVars,0);
-+		res = iv64Copy(m1Res);
-+		fAct = gc->facetPtr;
-+		delete m1Res;
-+// 		bound = gc->numFacets*(this->numVars);		
-+	}
-+	else
-+	{
-+		fAct = f->codim2Ptr;
-+		int64vec *m2Res = new int64vec(f->numCodim2Facets,gc->numVars,0);
-+		res = iv64Copy(m2Res);
-+		delete m2Res;	
-+// 		bound = fAct->numCodim2Facets*(this->numVars);
-+
-+	}
-+	int ii=0;
-+	while(fAct!=NULL )//&& ii < bound )
-+	{
-+		const int64vec *fNormal;
-+		fNormal = fAct->getRef2FacetNormal();//->getFacetNormal();
-+		for(int jj=0;jj<this->numVars;jj++)
-+		{
-+			(*res)[ii]=(int)(*fNormal)[jj];//This is ugly and prone to overflow
-+			ii++;
-+		}
-+		fAct = fAct->next;
-+	}	
-+	return *res;
-+}
-+
-+int gcone::counter=0;
-+int gfanHeuristic;
-+int gcone::lengthOfSearchList;
-+int gcone::maxSize;
-+dd_MatrixPtr gcone::dd_LinealitySpace;
-+int64vec *gcone::hilbertFunction;
-+#ifdef gfanp
-+// int gcone::lengthOfSearchList=0;
-+float gcone::time_getConeNormals;
-+float gcone::time_getCodim2Normals;
-+float gcone::t_getExtremalRays;
-+float gcone::t_ddPolyh;
-+float gcone::time_flip;
-+float gcone::time_flip2;
-+float gcone::t_areEqual;
-+float gcone::t_markings;
-+float gcone::t_dd;
-+float gcone::t_kStd=0;
-+float gcone::time_enqueue;
-+float gcone::time_computeInv;
-+float gcone::t_ddMC;
-+float gcone::t_mI;
-+float gcone::t_iP;
-+float gcone::t_isParallel;
-+unsigned gcone::parallelButNotEqual=0;
-+unsigned gcone::numberOfFacetChecks=0;
-+#endif
-+int gcone::numVars;
-+bool gcone::hasHomInput=FALSE;
-+int64vec *gcone::ivZeroVector;
-+// ideal gfan(ideal inputIdeal, int h)
-+/** Main routine 
-+ * The first and second parameter are mandatory. The third (and maybe fourth) parameter is for Janko :)
-+ */
-+#ifndef USE_ZFAN
-+lists grfan(ideal inputIdeal, int h, bool singleCone=FALSE)
-+#else
-+gfan::ZFan* grfan(ideal inputIdeal, int h, bool singleCone=FALSE)
-+#endif
-+{
-+	lists lResList; //this is the object we return	
-+	gfan::ZFan *zResFan = new gfan::ZFan(pVariables);
-+	
-+	if(rHasGlobalOrdering(currRing))
-+	{	
-+// 		int numvar = pVariables; 
-+		gfanHeuristic = h;
-+		
-+		enum searchMethod {
-+			reverseSearch,
-+			noRevS
-+		};
-+	
-+		searchMethod method;
-+		method = noRevS;
-+	
-+		ring inputRing=currRing;	// The ring the user entered
-+// 		ring rootRing;			// The ring associated to the target ordering
-+
-+		dd_set_global_constants();
-+		if(method==noRevS)
-+		{
-+			gcone *gcRoot = new gcone(currRing,inputIdeal);
-+			gcone *gcAct;
-+			gcAct = gcRoot;
-+			gcone::numVars=pVariables;
-+			//gcAct->numVars=pVariables;//NOTE is now static
-+			gcAct->getGB(inputIdeal);
-+			/*Check whether input is homogeneous
-+			if TRUE each facet intersects the positive orthant, so we don't need the
-+			flippability test in getConeNormals & getExtremalRays
-+			*/
-+			if(idHomIdeal(gcAct->gcBasis,NULL))//disabled for tests
-+			{
-+				gcone::hasHomInput=TRUE;
-+// 				gcone::hilbertFunction=hHstdSeries(inputIdeal,NULL,NULL,NULL,currRing);
-+			}
-+			else
-+			{
-+				gcone::ivZeroVector = new int64vec(pVariables);
-+				for(int ii=0;ii<pVariables;ii++)
-+					(*gcone::ivZeroVector)[ii]=0;
-+			}
-+
-+			if(isMonomial(gcAct->gcBasis))
-+			{//FIXME
-+				WerrorS("Monomial input - terminating");
-+				dd_free_global_constants();
-+				//This is filthy
-+				goto pointOfNoReturn;				
-+			}			
-+			gcAct->getConeNormals(gcAct->gcBasis);
-+			gcone::dd_LinealitySpace = gcAct->computeLinealitySpace();
-+			gcAct->getExtremalRays(*gcAct);
-+			if(singleCone==FALSE)//Is Janko here?
-+			{//Compute the whole fan
-+			  gcAct->noRevS(*gcAct);	//Here we go!
-+			}			    
-+			//Switch back to the ring the computation was started in
-+			rChangeCurrRing(inputRing);
-+			//res=gcAct->gcBasis;
-+			//Below is a workaround, since gcAct->gcBasis gets deleted in noRevS
-+#ifndef USE_ZFAN
-+			lResList=lprepareResult(gcRoot,gcRoot->getCounter());
-+#else
-+			prepareGfanLib(gcRoot,zResFan);
-+#endif
-+			/*Cleanup*/
-+			gcone *gcDel;	
-+			gcDel = gcRoot;
-+			gcAct = gcRoot;
-+			while(gcAct!=NULL)
-+			{
-+				gcDel = gcAct;
-+				gcAct = gcAct->next;
-+// 				delete gcDel;
-+			}
-+		}//method==noRevS
-+		dd_FreeMatrix(gcone::dd_LinealitySpace);
-+		dd_free_global_constants();
-+	}//rHasGlobalOrdering
-+	else
-+	{
-+		//Simply return an empty list
-+		WerrorS("Ring has non-global ordering.\nThis function requires your current ring to be endowed with a global ordering.\n Now terminating!");
-+// 		gcone *gcRoot=new gcone();
-+// 		gcone *gcPtr = gcRoot;
-+// 		for(int ii=0;ii<10000;ii++)
-+// 		{
-+// 			gcPtr->setBaseRing(currRing);
-+// 			facet *fPtr=gcPtr->facetPtr=new facet();
-+// 			for(int jj=0;jj<5;jj++)
-+// 			{
-+// 				int64vec *iv=new int64vec(pVariables);
-+// 				fPtr->setFacetNormal(iv);				
-+// 				delete(iv);
-+// 				fPtr->next=new facet();
-+// 				fPtr=fPtr->next;
-+// 			}
-+// 			gcPtr->next=new gcone();
-+// 			gcPtr->next->prev=gcPtr;
-+// 			gcPtr=gcPtr->next;			
-+// 		}
-+// 		gcPtr=gcRoot;
-+// 		while(gcPtr!=NULL)
-+// 		{
-+// 			gcPtr=gcPtr->next;
-+// // 			delete(gcPtr->prev);
-+// 		}
-+		goto pointOfNoReturn;
-+	}
-+	/*Return result*/
-+#ifdef gfanp
-+	cout << endl << "t_getConeNormals:" << gcone::time_getConeNormals << endl;
-+	/*cout << "t_getCodim2Normals:" << gcone::time_getCodim2Normals << endl;
-+	cout << "  t_ddMC:" << gcone::t_ddMC << endl;
-+	cout << "  t_mI:" << gcone::t_mI << endl;
-+	cout << "  t_iP:" << gcone::t_iP << endl;*/
-+	cout << "t_getExtremalRays:" << gcone::t_getExtremalRays << endl;
-+	cout << "  t_ddPolyh:" << gcone::t_ddPolyh << endl;
-+	cout << "t_Flip:" << gcone::time_flip << endl;
-+	cout << "  t_markings:" << gcone::t_markings << endl;
-+	cout << "  t_dd:" << gcone::t_dd << endl;
-+	cout << "  t_kStd:" << gcone::t_kStd << endl;
-+	cout << "t_Flip2:" << gcone::time_flip2 << endl;
-+	cout << "  t_dd:" << gcone::t_dd << endl;
-+	cout << "  t_kStd:" << gcone::t_kStd << endl;
-+	cout << "t_computeInv:" << gcone::time_computeInv << endl;
-+	cout << "t_enqueue:" << gcone::time_enqueue << endl;
-+	cout << "  t_areEqual:" <<gcone::t_areEqual << endl;
-+	cout << "t_isParallel:" <<gcone::t_isParallel << endl;
-+	cout << endl;
-+	cout << "Checked " << gcone::numberOfFacetChecks << " Facets" << endl;
-+	cout << " out of which there were " << gcone::parallelButNotEqual << " parallel but not equal." << endl;
-+#endif
-+	printf("Maximum lenght of list of facets: %i", gcone::maxSize);
-+pointOfNoReturn:
-+#ifndef USE_ZFAN
-+	return lResList;
-+#else
-+	return zResFan;
-+#endif
-+}
-+
-+/** Compute a single Gröbner cone by specifying an ideal and a weight vector.
-+ * NOTE: We do NOT check whether the vector is from the relative interior of the cone.
-+ * That is upon the user to assure.
-+ */
-+// lists grcone_by_intvec(ideal inputIdeal)
-+// {
-+//   if( (rRingOrder_t)currRing->order[0] == ringorder_wp)
-+//   {
-+//     lists lResList;
-+//     lResList=grfan(inputIdeal, 0, TRUE);
-+//   }
-+//   else
-+//     WerrorS("Need wp ordering");
-+// }
-+#endif
-diff --git a/kernel/gnumpc.cc b/kernel/gnumpc.cc
-index 62ea1f0..e3a28a8 100644
---- a/kernel/gnumpc.cc
-+++ b/kernel/gnumpc.cc
-@@ -7,7 +7,7 @@
- * ngc == number gnu complex
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/gnumpfl.cc b/kernel/gnumpfl.cc
-index 8438dd5..eb7294b 100644
---- a/kernel/gnumpfl.cc
-+++ b/kernel/gnumpfl.cc
-@@ -7,7 +7,7 @@
- * ngf == number gnu floats
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/gr_kstd2.cc b/kernel/gr_kstd2.cc
-index 27e0152..c311b81 100644
---- a/kernel/gr_kstd2.cc
-+++ b/kernel/gr_kstd2.cc
-@@ -5,7 +5,7 @@
- *  ABSTRACT -  Kernel: noncomm. alg. of Buchberger
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_PLURAL
- 
-diff --git a/kernel/gring.cc b/kernel/gring.cc
-index ec02714..27e8a5a 100644
---- a/kernel/gring.cc
-+++ b/kernel/gring.cc
-@@ -16,7 +16,7 @@
- #define OM_TRACK 5
- #endif
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_PLURAL
- #define PLURAL_INTERNAL_DECLARATIONS
-diff --git a/kernel/hdegree.cc b/kernel/hdegree.cc
-index 2e3053e..6d4cecd 100644
---- a/kernel/hdegree.cc
-+++ b/kernel/hdegree.cc
-@@ -5,7 +5,7 @@
- *  ABSTRACT -  dimension, multiplicity, HC, kbase
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- 
- #include <kernel/structs.h>
-diff --git a/kernel/hilb.cc b/kernel/hilb.cc
-index e629397..f687164 100644
---- a/kernel/hilb.cc
-+++ b/kernel/hilb.cc
-@@ -5,7 +5,7 @@
- *  ABSTRACT -  Hilbert series
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/hutil.cc b/kernel/hutil.cc
-index 3521746..07214b3 100644
---- a/kernel/hutil.cc
-+++ b/kernel/hutil.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: Utilities for staircase operations
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/ideals.cc b/kernel/ideals.cc
-index d1701b9..5c63cc8 100644
---- a/kernel/ideals.cc
-+++ b/kernel/ideals.cc
-@@ -6,7 +6,7 @@
- */
- 
- /* includes */
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifndef NDEBUG
- # define MYTEST 0
-diff --git a/kernel/int64vec.cc b/kernel/int64vec.cc
-index ef39725..31a6323 100644
---- a/kernel/int64vec.cc
-+++ b/kernel/int64vec.cc
-@@ -4,7 +4,7 @@
- /*
- * ABSTRACT: class int64vec: lists/vectors of int64
- */
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
- #include <kernel/int64vec.h>
-diff --git a/kernel/intvec.cc b/kernel/intvec.cc
-index 075d1ea..7688255 100644
---- a/kernel/intvec.cc
-+++ b/kernel/intvec.cc
-@@ -6,7 +6,7 @@
- */
- #ifndef INTVEC_CC
- #define INTVEC_CC
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/febase.h>
- #include <kernel/options.h>
- #include <kernel/intvec.h>
-diff --git a/kernel/kbuckets.cc b/kernel/kbuckets.cc
-index fe6b32c..eb90b87 100644
---- a/kernel/kbuckets.cc
-+++ b/kernel/kbuckets.cc
-@@ -2,7 +2,7 @@
- *  Computer Algebra System SINGULAR     *
- ****************************************/
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <omalloc/omalloc.h>
- #include <kernel/p_polys.h>
-diff --git a/kernel/khstd.cc b/kernel/khstd.cc
-index 51039c4..23c863d 100644
---- a/kernel/khstd.cc
-+++ b/kernel/khstd.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT:utils for hilbert driven kStd
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/febase.h>
- #include <kernel/options.h>
- #include <kernel/polys.h>
-diff --git a/kernel/kspoly.cc b/kernel/kspoly.cc
-index 78b5c02..756a256 100644
---- a/kernel/kspoly.cc
-+++ b/kernel/kspoly.cc
-@@ -6,7 +6,7 @@
- */
- 
- // #define PDEBUG 2
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <kernel/kutil.h>
- #include <kernel/numbers.h>
-diff --git a/kernel/kstd1.cc b/kernel/kstd1.cc
-index 07175cb..4c9c978 100644
---- a/kernel/kstd1.cc
-+++ b/kernel/kstd1.cc
-@@ -13,7 +13,7 @@
- // define if buckets should be used
- #define MORA_USE_BUCKETS
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/omalloc.h>
- 
- #ifndef NDEBUG
-diff --git a/kernel/kstd2.cc b/kernel/kstd2.cc
-index e853df2..38ea53d 100644
---- a/kernel/kstd2.cc
-+++ b/kernel/kstd2.cc
-@@ -12,7 +12,7 @@
- // define to enable tailRings
- #define HAVE_TAIL_RING
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifndef NDEBUG
- # define MYTEST 0
-diff --git a/kernel/kstdfac.cc b/kernel/kstdfac.cc
-index 437a9d5..3c6b003 100644
---- a/kernel/kstdfac.cc
-+++ b/kernel/kstdfac.cc
-@@ -5,7 +5,7 @@
- *  ABSTRACT -  Kernel: factorizing alg. of Buchberger
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/omalloc.h>
- #include <kernel/options.h>
- #include <kernel/polys.h>
-diff --git a/kernel/kutil.cc b/kernel/kutil.cc
-index 0b2103b..68d2cf9 100644
---- a/kernel/kutil.cc
-+++ b/kernel/kutil.cc
-@@ -10,7 +10,7 @@
- #define KUTIL_CC
- #include <stdlib.h>
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifndef NDEBUG
- # define MYTEST 0
-diff --git a/kernel/linearAlgebra.cc b/kernel/linearAlgebra.cc
-index 74842dc..015cac2 100644
---- a/kernel/linearAlgebra.cc
-+++ b/kernel/linearAlgebra.cc
-@@ -14,7 +14,7 @@
- /*****************************************************************************/
- 
- // include header files
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/polys.h>
- #include <kernel/ideals.h>
-diff --git a/kernel/longalg.cc b/kernel/longalg.cc
-index 5b26264..b86431f 100644
---- a/kernel/longalg.cc
-+++ b/kernel/longalg.cc
-@@ -7,7 +7,7 @@
- 
- #include <stdio.h>
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <omalloc/omalloc.h>
- #include <kernel/febase.h>
-diff --git a/kernel/longrat.cc b/kernel/longrat.cc
-index 1938a45..c2cc177 100644
---- a/kernel/longrat.cc
-+++ b/kernel/longrat.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: computation with long rational numbers (Hubert Grassmann)
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/longrat.h>
- 
-diff --git a/kernel/longrat0.cc b/kernel/longrat0.cc
-index f4d1e32..7ecaabe 100644
---- a/kernel/longrat0.cc
-+++ b/kernel/longrat0.cc
-@@ -8,7 +8,7 @@
- 
- #include <stdio.h>
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <omalloc/omalloc.h>
- #include <kernel/febase.h>
-diff --git a/kernel/longtrans.cc b/kernel/longtrans.cc
-index cf2ebef..88d48ab 100644
---- a/kernel/longtrans.cc
-+++ b/kernel/longtrans.cc
-@@ -9,7 +9,7 @@
- #if 0
- #include <stdio.h>
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <omalloc/omalloc.h>
- #include <kernel/febase.h>
-diff --git a/kernel/lplist.cc b/kernel/lplist.cc
-index 0f5fdc3..35bacb9 100644
---- a/kernel/lplist.cc
-+++ b/kernel/lplist.cc
-@@ -4,7 +4,7 @@
- /*
- * ABSTRACT: list interface
- */
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_F5
- 
-diff --git a/kernel/maps.cc b/kernel/maps.cc
-index d323ca8..951c2c9 100644
---- a/kernel/maps.cc
-+++ b/kernel/maps.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT - the mapping of polynomials to other rings
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <kernel/febase.h>
- #include <kernel/polys.h>
-diff --git a/kernel/matpol.cc b/kernel/matpol.cc
-index 304c249..16b0ea7 100644
---- a/kernel/matpol.cc
-+++ b/kernel/matpol.cc
-@@ -9,7 +9,7 @@
- #include <stdio.h>
- #include <math.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <kernel/structs.h>
- #include <kernel/kstd1.h>
-diff --git a/kernel/misc.cc b/kernel/misc.cc
-index 4ba410c..21ecce5 100644
---- a/kernel/misc.cc
-+++ b/kernel/misc.cc
-@@ -12,7 +12,7 @@
- #include <stdlib.h>
- #include <time.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <omalloc/omalloc.h>
- #include <kernel/structs.h>
-diff --git a/kernel/mmalloc.cc b/kernel/mmalloc.cc
-index 2050e59..0a3b6d4 100644
---- a/kernel/mmalloc.cc
-+++ b/kernel/mmalloc.cc
-@@ -6,7 +6,7 @@
- */
- #include <stdlib.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #include <omalloc/omalloc.h>
- #include <new>
-diff --git a/kernel/mmstd.c b/kernel/mmstd.c
-index 6ccb824..f2fd277 100644
---- a/kernel/mmstd.c
-+++ b/kernel/mmstd.c
-@@ -6,7 +6,7 @@
- * i.e. (malloc/realloc/free)
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #include <omalloc/omalloc.h>
- #include <Singular/static.h>
-diff --git a/kernel/mod_raw.cc b/kernel/mod_raw.cc
-index 025bbb2..8cb85c7 100644
---- a/kernel/mod_raw.cc
-+++ b/kernel/mod_raw.cc
-@@ -17,7 +17,7 @@
- #include <sys/stat.h>
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <Singular/static.h>
- 
- #include <kernel/mod_raw.h>
-diff --git a/kernel/modulop.cc b/kernel/modulop.cc
-index 35e1c37..70ee176 100644
---- a/kernel/modulop.cc
-+++ b/kernel/modulop.cc
-@@ -6,7 +6,7 @@
- */
- 
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
-diff --git a/kernel/mpr_base.cc b/kernel/mpr_base.cc
-index a784bab..95947df 100644
---- a/kernel/mpr_base.cc
-+++ b/kernel/mpr_base.cc
-@@ -8,7 +8,7 @@
- 
- #include <math.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #include <omalloc/mylimits.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/mpr_complex.cc b/kernel/mpr_complex.cc
-index 9fb1056..255e14f 100644
---- a/kernel/mpr_complex.cc
-+++ b/kernel/mpr_complex.cc
-@@ -10,7 +10,7 @@
- 
- // WARNING! ALWAYS use omAlloc and FreeL when alloc. memory for some char* !!
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- //#ifdef HAVE_MPR
- #include <kernel/structs.h>
- #include <kernel/febase.h>
-diff --git a/kernel/mpr_inout.cc b/kernel/mpr_inout.cc
-index f8c9b7e..3e13e7e 100644
---- a/kernel/mpr_inout.cc
-+++ b/kernel/mpr_inout.cc
-@@ -6,7 +6,7 @@
- * ABSTRACT - multipolynomial resultant
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- //#ifdef HAVE_MPR
- 
- //-> includes
-diff --git a/kernel/mpr_numeric.cc b/kernel/mpr_numeric.cc
-index 79c741b..55bb031 100644
---- a/kernel/mpr_numeric.cc
-+++ b/kernel/mpr_numeric.cc
-@@ -8,7 +8,7 @@
- *            ( root finder, vandermonde system solver, simplex )
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- //#ifdef HAVE_MPR
- 
- //#define mprDEBUG_ALL
-diff --git a/kernel/multicnt.cc b/kernel/multicnt.cc
-index 9f11b1d..de21ed3 100644
---- a/kernel/multicnt.cc
-+++ b/kernel/multicnt.cc
-@@ -7,7 +7,7 @@
- 
- #define MULTICNT_CC
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_SPECTRUM
- 
-diff --git a/kernel/ncSACache.cc b/kernel/ncSACache.cc
-index 742ebba..86b86e5 100644
---- a/kernel/ncSACache.cc
-+++ b/kernel/ncSACache.cc
-@@ -17,7 +17,7 @@
- #endif
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifndef NDEBUG
- #define OUTPUT 1
-diff --git a/kernel/ncSAFormula.cc b/kernel/ncSAFormula.cc
-index b4fefe0..c985bda 100644
---- a/kernel/ncSAFormula.cc
-+++ b/kernel/ncSAFormula.cc
-@@ -17,7 +17,7 @@
- #endif
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_PLURAL
- 
-diff --git a/kernel/ncSAMult.cc b/kernel/ncSAMult.cc
-index fcf767a..ecdcaed 100644
---- a/kernel/ncSAMult.cc
-+++ b/kernel/ncSAMult.cc
-@@ -17,7 +17,7 @@
- #endif
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_PLURAL
- 
-diff --git a/kernel/npolygon.cc b/kernel/npolygon.cc
-index afb939b..b54d941 100644
---- a/kernel/npolygon.cc
-+++ b/kernel/npolygon.cc
-@@ -7,7 +7,7 @@
- 
- #define  NPOLYGON_CC
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_SPECTRUM
- 
-diff --git a/kernel/numbers.cc b/kernel/numbers.cc
-index 61b68a7..35c08b2 100644
---- a/kernel/numbers.cc
-+++ b/kernel/numbers.cc
-@@ -8,7 +8,7 @@
- 
- #include <string.h>
- #include <stdlib.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
- #include <kernel/kstd1.h>
-diff --git a/kernel/pDebug.cc b/kernel/pDebug.cc
-index b658d92..5b2e82a 100644
---- a/kernel/pDebug.cc
-+++ b/kernel/pDebug.cc
-@@ -14,7 +14,7 @@
- #include <stdio.h>
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #ifdef PDEBUG
- 
- // do the following to always enforce checking of pSetm
-diff --git a/kernel/pInline0.cc b/kernel/pInline0.cc
-index f851034..7eb90cb 100644
---- a/kernel/pInline0.cc
-+++ b/kernel/pInline0.cc
-@@ -9,7 +9,7 @@
-  *******************************************************************/
- #ifndef PINLINE0_CC
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #define PINLINE0_CC
- #undef DO_PINLINE0
-diff --git a/kernel/pInline1.cc b/kernel/pInline1.cc
-index 40563b6..e30321d 100644
---- a/kernel/pInline1.cc
-+++ b/kernel/pInline1.cc
-@@ -10,7 +10,7 @@
- #ifndef PINLINE1_CC
- #define PINLINE1_CC
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef PDEBUG
- 
-diff --git a/kernel/pInline2.cc b/kernel/pInline2.cc
-index 5b4ede8..b71b8ad 100644
---- a/kernel/pInline2.cc
-+++ b/kernel/pInline2.cc
-@@ -9,7 +9,7 @@
-  *******************************************************************/
- #ifndef PINLINE2_CC
- #define PINLINE2_CC
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef PDEBUG
- 
-diff --git a/kernel/pShallowCopyDelete.cc b/kernel/pShallowCopyDelete.cc
-index 25fe533..f5d6daa 100644
---- a/kernel/pShallowCopyDelete.cc
-+++ b/kernel/pShallowCopyDelete.cc
-@@ -7,7 +7,7 @@
-  *  Author:  obachman (Olaf Bachmann)
-  *  Created: 8/00
-  *******************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/p_polys.h>
- #include <kernel/ring.h>
- #include <kernel/pShallowCopyDelete.h>
-diff --git a/kernel/p_Mult_q.cc b/kernel/p_Mult_q.cc
-index bbb07ef..cbec90e 100644
---- a/kernel/p_Mult_q.cc
-+++ b/kernel/p_Mult_q.cc
-@@ -7,7 +7,7 @@
-  *  Author:  obachman (Olaf Bachmann)
-  *  Created: 8/00
-  *******************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- /***************************************************************
-  *
-diff --git a/kernel/p_Mult_q.h b/kernel/p_Mult_q.h
-index 4da031f..8ec326f 100644
---- a/kernel/p_Mult_q.h
-+++ b/kernel/p_Mult_q.h
-@@ -8,7 +8,7 @@
-  *  Author:  obachman (Olaf Bachmann)
-  *  Created: 8/00
-  *******************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- 
- // Use buckets if min(pLength(p), pLength(q)) >= MIN_LENGTH_BUCKET
-diff --git a/kernel/p_Procs_Dynamic.cc b/kernel/p_Procs_Dynamic.cc
-index 8f30e78..58f1249 100644
---- a/kernel/p_Procs_Dynamic.cc
-+++ b/kernel/p_Procs_Dynamic.cc
-@@ -7,7 +7,7 @@
-  *  Author:  obachman (Olaf Bachmann)
-  *  Created: 12/00
-  *******************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/p_polys.h>
- #include <kernel/ring.h>
-diff --git a/kernel/p_Procs_Generate.cc b/kernel/p_Procs_Generate.cc
-index af1003d..5ed8398 100644
---- a/kernel/p_Procs_Generate.cc
-+++ b/kernel/p_Procs_Generate.cc
-@@ -14,7 +14,7 @@
- #include <stdlib.h>
- #include <string.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/dError.c>
- 
- #ifdef p_Procs_Static
-diff --git a/kernel/p_Procs_Lib.cc b/kernel/p_Procs_Lib.cc
-index 5ff7c37..4014665 100644
---- a/kernel/p_Procs_Lib.cc
-+++ b/kernel/p_Procs_Lib.cc
-@@ -7,7 +7,7 @@
-  *  Author:  obachman (Olaf Bachmann)
-  *  Created: 12/00
-  *******************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/p_polys.h>
- #include <kernel/ring.h>
-diff --git a/kernel/p_Procs_Static.cc b/kernel/p_Procs_Static.cc
-index a3aa326..a93f493 100644
---- a/kernel/p_Procs_Static.cc
-+++ b/kernel/p_Procs_Static.cc
-@@ -7,7 +7,7 @@
-  *  Author:  obachman (Olaf Bachmann)
-  *  Created: 12/00
-  *******************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/p_polys.h>
- #include <kernel/ring.h>
-diff --git a/kernel/p_polys.cc b/kernel/p_polys.cc
-index 01c15c6..4e90501 100644
---- a/kernel/p_polys.cc
-+++ b/kernel/p_polys.cc
-@@ -9,7 +9,7 @@
-  *******************************************************************/
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #include <kernel/structs.h>
- #include <kernel/p_polys.h>
-diff --git a/kernel/page.c b/kernel/page.c
-index 19681d5..4011a14 100644
---- a/kernel/page.c
-+++ b/kernel/page.c
-@@ -1,4 +1,4 @@
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #ifdef PAGE_TEST
- #include <stdlib.h>
- #include <unistd.h>
-diff --git a/kernel/polys-impl.cc b/kernel/polys-impl.cc
-index d247b65..a1b751d 100644
---- a/kernel/polys-impl.cc
-+++ b/kernel/polys-impl.cc
-@@ -17,7 +17,7 @@
- 
- #include <stdio.h>
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #include <omalloc/omalloc.h>
- #ifdef PDEBUG
-diff --git a/kernel/polys.cc b/kernel/polys.cc
-index 53ba7b9..b89a9a0 100644
---- a/kernel/polys.cc
-+++ b/kernel/polys.cc
-@@ -10,7 +10,7 @@
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <omalloc/omalloc.h>
- #include <kernel/febase.h>
-diff --git a/kernel/polys0.cc b/kernel/polys0.cc
-index 87aea68..d5ec8fd 100644
---- a/kernel/polys0.cc
-+++ b/kernel/polys0.cc
-@@ -7,7 +7,7 @@
- */
- 
- /* includes */
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/numbers.h>
- #include <kernel/ring.h>
-diff --git a/kernel/polys1.cc b/kernel/polys1.cc
-index fa797fe..36d25d6 100644
---- a/kernel/polys1.cc
-+++ b/kernel/polys1.cc
-@@ -8,7 +8,7 @@
- 
- /* includes */
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <kernel/numbers.h>
- #include <kernel/ffields.h>
-diff --git a/kernel/prCopy.cc b/kernel/prCopy.cc
-index d335eda..7273cff 100644
---- a/kernel/prCopy.cc
-+++ b/kernel/prCopy.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT - implementation of functions for Copy/Move/Delete for Polys
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/omalloc.h>
- #include <kernel/p_polys.h>
- #include <kernel/numbers.h>
-diff --git a/kernel/ratgring.cc b/kernel/ratgring.cc
-index 48d7a6f..6dc7a5c 100644
---- a/kernel/ratgring.cc
-+++ b/kernel/ratgring.cc
-@@ -7,7 +7,7 @@
-  *  Author:  levandov (Viktor Levandovsky)
-  *  Created: 8/00 - 11/00
-  *******************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/ratgring.h>
- #ifdef HAVE_RATGRING
- #include <kernel/gring.h>
-diff --git a/kernel/ring.cc b/kernel/ring.cc
-index ac14c23..f2f9a6b 100644
---- a/kernel/ring.cc
-+++ b/kernel/ring.cc
-@@ -7,7 +7,7 @@
- 
- /* includes */
- #include <math.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #include <kernel/options.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/ringgb.cc b/kernel/ringgb.cc
-index c1d510f..60e33c9 100644
---- a/kernel/ringgb.cc
-+++ b/kernel/ringgb.cc
-@@ -7,7 +7,7 @@
- //#define HAVE_TAIL_RING
- #define NO_BUCKETS
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/kutil.h>
- #include <kernel/structs.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/ringgb.h b/kernel/ringgb.h
-index dd05f96..10f15c8 100644
---- a/kernel/ringgb.h
-+++ b/kernel/ringgb.h
-@@ -6,7 +6,7 @@
- */
- #ifndef RINGGB_HEADER
- #define RINGGB_HEADER
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_RINGS
- #include <kernel/polys.h>
-diff --git a/kernel/rintegers.cc b/kernel/rintegers.cc
-index 199315a..5b3af34 100644
---- a/kernel/rintegers.cc
-+++ b/kernel/rintegers.cc
-@@ -6,7 +6,7 @@
- */
- 
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
-diff --git a/kernel/rmodulo2m.cc b/kernel/rmodulo2m.cc
-index 23e8635..13efb52 100644
---- a/kernel/rmodulo2m.cc
-+++ b/kernel/rmodulo2m.cc
-@@ -6,7 +6,7 @@
- */
- 
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_RINGS
- #include <omalloc/mylimits.h>
-diff --git a/kernel/rmodulon.cc b/kernel/rmodulon.cc
-index e90aab7..17b2720 100644
---- a/kernel/rmodulon.cc
-+++ b/kernel/rmodulon.cc
-@@ -6,7 +6,7 @@
- */
- 
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
-diff --git a/kernel/sbuckets.cc b/kernel/sbuckets.cc
-index a99f0c5..2293b27 100644
---- a/kernel/sbuckets.cc
-+++ b/kernel/sbuckets.cc
-@@ -8,7 +8,7 @@
-  *  Author:  obachman (Olaf Bachmann)
-  *  Created: 9/00
-  *******************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #include <kernel/sbuckets.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/sca.cc b/kernel/sca.cc
-index 41bda73..a4aeea7 100644
---- a/kernel/sca.cc
-+++ b/kernel/sca.cc
-@@ -18,7 +18,7 @@
- #endif
- 
- // #define PDEBUG 2
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_PLURAL
- // for
-diff --git a/kernel/semic.cc b/kernel/semic.cc
-index fed3484..dced520 100644
---- a/kernel/semic.cc
-+++ b/kernel/semic.cc
-@@ -7,7 +7,7 @@
- 
- #define SEMIC_CC
- 
--#include"mod2.h"
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_SPECTRUM
- 
-diff --git a/kernel/shiftgb.cc b/kernel/shiftgb.cc
-index 04a73f6..fc09395 100644
---- a/kernel/shiftgb.cc
-+++ b/kernel/shiftgb.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: kernel: utils for shift GB and free GB
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_SHIFTBBA
- #include <kernel/febase.h>
-diff --git a/kernel/shortfl.cc b/kernel/shortfl.cc
-index fa1646a..31c3f66 100644
---- a/kernel/shortfl.cc
-+++ b/kernel/shortfl.cc
-@@ -7,7 +7,7 @@
- */
- 
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
-diff --git a/kernel/sparsmat.cc b/kernel/sparsmat.cc
-index d3d1bed..ad245a6 100644
---- a/kernel/sparsmat.cc
-+++ b/kernel/sparsmat.cc
-@@ -6,7 +6,7 @@
- * ABSTRACT: operations with sparse matrices (bareiss, ...)
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <kernel/febase.h>
- #include <kernel/intvec.h>
-diff --git a/kernel/spectrum.cc b/kernel/spectrum.cc
-index 1671a6e..98a8f4f 100644
---- a/kernel/spectrum.cc
-+++ b/kernel/spectrum.cc
-@@ -7,7 +7,7 @@
- 
- #define SPECTRUM_CC
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_SPECTRUM
- 
-diff --git a/kernel/splist.cc b/kernel/splist.cc
-index c1db0ae..7a4b65a 100644
---- a/kernel/splist.cc
-+++ b/kernel/splist.cc
-@@ -7,7 +7,7 @@
- 
- #define SPLIST_CC
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- #ifdef HAVE_SPECTRUM
- 
-diff --git a/kernel/summator.cc b/kernel/summator.cc
-index 5351586..ce70f0b 100644
---- a/kernel/summator.cc
-+++ b/kernel/summator.cc
-@@ -17,7 +17,7 @@
- #define OM_TRACK 5
- #endif
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #ifdef HAVE_PLURAL
- #include <kernel/summator.h>
- #include <kernel/options.h>
-diff --git a/kernel/syz.cc b/kernel/syz.cc
-index 2283bf0..bcca57f 100644
---- a/kernel/syz.cc
-+++ b/kernel/syz.cc
-@@ -7,7 +7,7 @@
- */
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <omalloc/omalloc.h>
- #include <kernel/polys.h>
-diff --git a/kernel/syz0.cc b/kernel/syz0.cc
-index e5e4d2b..2d92449 100644
---- a/kernel/syz0.cc
-+++ b/kernel/syz0.cc
-@@ -6,7 +6,7 @@
- */
- 
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <omalloc/omalloc.h>
- #include <kernel/polys.h>
-diff --git a/kernel/syz1.cc b/kernel/syz1.cc
-index c8537c4..f815067 100644
---- a/kernel/syz1.cc
-+++ b/kernel/syz1.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: resolutions
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <kernel/options.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/syz2.cc b/kernel/syz2.cc
-index 83acf72..5014240 100644
---- a/kernel/syz2.cc
-+++ b/kernel/syz2.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: resolutions
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <kernel/options.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/syz3.cc b/kernel/syz3.cc
-index b4edc9b..175258f 100644
---- a/kernel/syz3.cc
-+++ b/kernel/syz3.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: resolutions
- */
-  
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/mylimits.h>
- #include <kernel/options.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/tgb.cc b/kernel/tgb.cc
-index 3ee6393..f4c1a0f 100644
---- a/kernel/tgb.cc
-+++ b/kernel/tgb.cc
-@@ -13,7 +13,7 @@
- ///@TODO: delay nur auf Sugarvergr?erung
- ///@TODO: grade aus ecartS, setze dazu strat->honey; und nutze p.ecart
- ///@TODO: no tail reductions in syz comp
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <kernel/tgb.h>
- #include <kernel/tgb_internal.h>
-diff --git a/kernel/tgbgauss.cc b/kernel/tgbgauss.cc
-index 7d6db60..a99a0ad 100644
---- a/kernel/tgbgauss.cc
-+++ b/kernel/tgbgauss.cc
-@@ -4,7 +4,7 @@
- /*
- * ABSTRACT: gauss implementation for F4
- */
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <kernel/tgbgauss.h>
- #include <omalloc/omalloc.h>
-diff --git a/kernel/tgbgauss.h b/kernel/tgbgauss.h
-index 994a208..8ab56fc 100644
---- a/kernel/tgbgauss.h
-+++ b/kernel/tgbgauss.h
-@@ -6,7 +6,7 @@
- /*
- * ABSTRACT: gauss implementation for F4 header
- */
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/numbers.h>
- //#include "tgb_internal.h"
- 
-diff --git a/kernel/timer.cc b/kernel/timer.cc
-index 4a382bf..7623fa8 100644
---- a/kernel/timer.cc
-+++ b/kernel/timer.cc
-@@ -8,7 +8,7 @@
- #include <sys/resource.h>
- #include <unistd.h>
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- 
- int        timerv = 0;
- static double timer_resolution = TIMER_RESOLUTION;
-diff --git a/kernel/tmult.cc b/kernel/tmult.cc
-index c26c61e..647e6e3 100644
---- a/kernel/tmult.cc
-+++ b/kernel/tmult.cc
-@@ -4,7 +4,7 @@
-  *  tmult.cc: p_Mult_nn with pthreads - experimental
-  *
-  *******************************************************************/
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/numbers.h>
- #include <kernel/polys.h>
-diff --git a/kernel/units.cc b/kernel/units.cc
-index 37f7416..3c40728 100644
---- a/kernel/units.cc
-+++ b/kernel/units.cc
-@@ -5,7 +5,7 @@
- * ABSTRACT: procedures to compute with units
- */
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/febase.h>
- #include <kernel/numbers.h>
-diff --git a/kernel/walkMain.cc b/kernel/walkMain.cc
-index c0ac32a..1f5b530 100644
---- a/kernel/walkMain.cc
-+++ b/kernel/walkMain.cc
-@@ -6,7 +6,7 @@
-  *
- */
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <kernel/intvec.h>
- #include <kernel/int64vec.h>
-diff --git a/kernel/walkProc.cc b/kernel/walkProc.cc
-index 18945b7..8e39c5a 100644
---- a/kernel/walkProc.cc
-+++ b/kernel/walkProc.cc
-@@ -2,7 +2,7 @@
- *  Computer Algebra System SINGULAR     *
- ****************************************/
- 
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/structs.h>
- #include <kernel/structs.h>
- #include <kernel/polys.h>
-diff --git a/kernel/walkSupport.cc b/kernel/walkSupport.cc
-index ea9c1fa..ada42f7 100644
---- a/kernel/walkSupport.cc
-+++ b/kernel/walkSupport.cc
-@@ -1,5 +1,5 @@
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/intvec.h>
- #include <kernel/int64vec.h>
- #include <kernel/polys.h>
-diff --git a/kernel/weight.cc b/kernel/weight.cc
-index 23a8779..936187b 100644
---- a/kernel/weight.cc
-+++ b/kernel/weight.cc
-@@ -7,7 +7,7 @@
- */
- 
- #include <math.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <kernel/options.h>
- #include <omalloc/omalloc.h>
- #include <kernel/polys.h>
-diff --git a/kernel/weight0.c b/kernel/weight0.c
-index 80454d9..04746d5 100644
---- a/kernel/weight0.c
-+++ b/kernel/weight0.c
-@@ -8,7 +8,7 @@
- 
- #include <math.h>
- #include <string.h>
--#include <kernel/mod2.h>
-+#include <Singular/mod2.h>
- #include <omalloc/omalloc.h>
- #include <kernel/structs.h>
- 
diff --git a/debian/patches/0007-move-libreadline-to-main-binary.patch b/debian/patches/0007-move-libreadline-to-main-binary.patch
deleted file mode 100644
index a8b6d96..0000000
--- a/debian/patches/0007-move-libreadline-to-main-binary.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-From 846b23172d3c400611e0736b87009c9e2c4f7568 Mon Sep 17 00:00:00 2001
-From: "Bernhard R. Link" <brlink at debian.org>
-Date: Sun, 26 Feb 2012 13:38:14 +0100
-Subject: move libreadline to main binary
-
-and link Singular binary against libsingular instead of carrying a copy
-of everything.
-
-Forwarded: not-needed
----
- Singular/Makefile.in |  8 +++++---
- kernel/Makefile.in   | 17 +++++++++--------
- kernel/febase.cc     | 41 +++++++++++++++++++++++++++++++++++++++++
- kernel/feread.cc     | 27 +--------------------------
- 4 files changed, 56 insertions(+), 37 deletions(-)
-
-diff --git a/Singular/Makefile.in b/Singular/Makefile.in
-index 6b94ca2..61bc6f7 100644
---- a/Singular/Makefile.in
-+++ b/Singular/Makefile.in
-@@ -137,7 +137,7 @@ HAVE_MPSR       = @HAVE_MPSR@
- #
- # Handle libSINGULAR stuff
- #
--LIBSINGULAR_LIBS =-lsingfac -lsingcf -lntl -lreadline -lgmp -lomalloc
-+LIBSINGULAR_LIBS =-lsingfac -lsingcf -lntl -lgmp -lomalloc -ldl
- 
- SO_SUFFIX = so
- 
-@@ -380,12 +380,14 @@ Singular-static: version.h
- 	${MAKE} LD_STATIC=1 S_EXT="-static" Singular-static
- 	echo "#undef HAVE_STATIC" > static.h
- 
-+SINGULAR_DYNAMIC = libsingular.$(SO_SUFFIX) ../kernel/feread.o ../kernel/fereadl.o
-+
- Singular${S_EXT}: mod2.h Makefile version.h $(WIN_LIBS) scanner.cc  ${OBJS} \
--          iparith.o tesths.cc libparse.cc claptmpl.o mpsr_Tok.o $(DL_LIBS) 
-+          iparith.o tesths.cc libparse.cc claptmpl.o mpsr_Tok.o $(DL_LIBS) $(SINGULAR_DYNAMIC)
- 	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${CXXTEMPLFLAGS} ${DEFS} \
- 	  -o Singular${S_EXT} \
- 	  tesths.cc iparith.o mpsr_Tok.o claptmpl.o\
--	  ${OBJS} ${LDFLAGS} ${LIBS} ../kernel/mmalloc.o 
-+	  ${OBJS} $(SINGULAR_DYNAMIC) ${LDFLAGS} ${LIBS} ../kernel/mmalloc.o
- 
- libsingular: libsingular.${SO_SUFFIX}
- 
-diff --git a/kernel/Makefile.in b/kernel/Makefile.in
-index 78d2b07..727364e 100644
---- a/kernel/Makefile.in
-+++ b/kernel/Makefile.in
-@@ -91,7 +91,7 @@ endif
- # normal C++ source files
- CXXSOURCES=bigintmat.cc clapconv.cc \
-     clapsing.cc \
--    febase.cc feread.cc feResource.cc \
-+    febase.cc feResource.cc \
-     ffields.cc hdegree.cc hilb.cc hutil.cc \
-     sca.cc gring.cc gr_kstd2.cc summator.cc ncSAMult.cc ncSAFormula.cc \
-     ideals.cc intvec.cc int64vec.cc \
-@@ -119,7 +119,7 @@ CXXSOURCES=bigintmat.cc clapconv.cc \
- CXXSOURCES2	= SingularBuilder.cpp
- 
- # normal C source files
--CSOURCES=weight0.c fegetopt.c fereadl.c dError.c mmstd.c
-+CSOURCES=weight0.c fegetopt.c dError.c mmstd.c
- 
- # C++ sources which are used if part of the kernel are dynamically linked
- ifeq ($(DL_KERNEL),1)
-@@ -137,7 +137,8 @@ STATIC_SOURCES=p_Procs_Static.cc
- 
- # special C++ source files (need extra compiling and/or linking), for which
- # dependencies should be generated
--ESOURCES=mmalloc.cc $(DL_KERNEL_SOURCES) $(DL_LIB_SOURCES) $(STATIC_SOURCES)
-+ESOURCES=mmalloc.cc $(DL_KERNEL_SOURCES) $(DL_LIB_SOURCES) $(STATIC_SOURCES) feread.cc
-+ECSOURCES=fereadl.c
- 
- SOURCES=${CSOURCES} ${CXXSOURCES} \
- 	prCopyTemplate.cc \
-@@ -177,13 +178,13 @@ HEADERS=bigintmat.h hutil.h idrec.h stairc.h ideals.h \
- 	p_Procs_Dynamic.h p_Procs_Impl.h p_Procs_Set.h \
- 	p_Procs.h p_Procs_Static.h p_Mult_q.h
- 
--DISTFILES=${SOURCES} ${HEADERS} ${ESOURCES} \
-+DISTFILES=${SOURCES} ${HEADERS} ${ESOURCES} ${ECSOURCES} \
-         Makefile.in \
- 	mkinstalldirs \
- 	prCopy.pl
- 
- OBJS := $(CXXSOURCES:.cc=.o) $(CSOURCES:.c=.o) #$(CXXSOURCES2:.cpp=.o)
--OBJS2 := $(ESOURCES:.cc=.o)
-+OBJS2 := $(ESOURCES:.cc=.o) $(ECSOURCES:.c=.o)
- OBJSG2 := $(ESOURCES:.cc=.og)
- OBJSP2 := $(ESOURCES:.cc=.op)
- 
-@@ -338,8 +339,8 @@ maintainer-clean: distclean srcclean
- ## miscellanous targets
- ##
- 
--TAGS:   ${SOURCES} ${ESOURCES} ${HEADERS} 
--	etags ${SOURCES} ${ESOURCES} ${HEADERS}
-+TAGS:   ${SOURCES} ${ESOURCES} ${ECSOURCES} ${HEADERS} 
-+	etags ${SOURCES} ${ESOURCES} ${ECSOURCES} ${HEADERS}
- 
- tags:   
- 	ctags *.c *.h *.cc *.inc
-@@ -447,7 +448,7 @@ libkernel_p.a: ${OBJP} ${DL_LIBSP} ${OBJSP2}
- 	echo $(@:.d=.og) $(@:.d=.op) " " \\ > $@
- 	$(CCM) ${CPPFLAGS} ${DEFSG} $< >> $@
- 
--depend:   $(CXXSOURCES:.cc=.dd) $(ESOURCES:.cc=.dd) $(CSOURCES:.c=.d)
-+depend:   $(CXXSOURCES:.cc=.dd) $(ESOURCES:.cc=.dd) $(ECSOURCES:.c=.d) $(CSOURCES:.c=.d)
- 	cat *.d *.dd >depend
- 
- ifeq (depend,$(wildcard depend))
-diff --git a/kernel/febase.cc b/kernel/febase.cc
-index 725eca2..971f7fd 100644
---- a/kernel/febase.cc
-+++ b/kernel/febase.cc
-@@ -26,6 +26,47 @@
- #include <kernel/dError.h>
- #include <kernel/options.h>
- 
-+/* some stuff move here from feread.cc: */
-+
-+/* ===================================================================*/
-+/* =                      batch mode                                = */
-+/* ===================================================================*/
-+/* dummy (for batch mode): */
-+char * fe_fgets_dummy(const char *pr,char *s, int size)
-+{
-+  return NULL;
-+}
-+
-+/* ===================================================================*/
-+/* =                        fgets                                   = */
-+/* ===================================================================*/
-+char * fe_fgets(const char *pr,char *s, int size)
-+{
-+  if (BVERBOSE(V_PROMPT))
-+  {
-+    fprintf(stdout,"%s",pr);
-+  }
-+  mflush();
-+  return fgets(s,size,stdin);
-+}
-+
-+char * fe_fgets_stdin_init(const char *pr,char *s, int size) __attribute__((weak));
-+char * fe_fgets_stdin_init(const char *pr,char *s, int size) {
-+	Werror("No method to read from stdin loaded!\n");
-+	return NULL;
-+}
-+extern "C" {
-+void fe_reset_input_mode (void) __attribute__((weak));
-+void fe_reset_input_mode (void)
-+{
-+}
-+}
-+
-+char * (*fe_fgets_stdin)(const char *pr,char *s, int size)
-+ = fe_fgets_stdin_init;
-+
-+/* end of some stuff move here from feread.cc */
-+
- #define fePutChar(c) fputc((unsigned char)(c),stdout)
- /*0 implementation */
- 
-diff --git a/kernel/feread.cc b/kernel/feread.cc
-index 8f67c5e..522ed9c 100644
---- a/kernel/feread.cc
-+++ b/kernel/feread.cc
-@@ -30,10 +30,6 @@
- #include <unistd.h>
- #endif
- 
--static char * fe_fgets_stdin_init(const char *pr,char *s, int size);
--char * (*fe_fgets_stdin)(const char *pr,char *s, int size)
-- = fe_fgets_stdin_init;
--
- extern char *iiArithGetCmd(int);
- 
- /* ===================================================================*/
-@@ -289,23 +285,11 @@ char * fe_fgets_stdin_drl(const char *pr,char *s, int size)
- }
- #endif
- 
--/* ===================================================================*/
--/* =                        fgets                                   = */
--/* ===================================================================*/
--char * fe_fgets(const char *pr,char *s, int size)
--{
--  if (BVERBOSE(V_PROMPT))
--  {
--    fprintf(stdout,"%s",pr);
--  }
--  mflush();
--  return fgets(s,size,stdin);
--}
- 
- /* ===================================================================*/
- /* =       init for static rl, dyn. rl, emu. rl                     = */
- /* ===================================================================*/
--static char * fe_fgets_stdin_init(const char *pr,char *s, int size)
-+char * fe_fgets_stdin_init(const char *pr,char *s, int size)
- {
- #if (defined(HAVE_READLINE) || defined(HAVE_LIBREADLINE)) && !defined(HAVE_DYN_RL) && !defined(HAVE_FEREAD)
-   /* Allow conditional parsing of the ~/.inputrc file. */
-@@ -393,12 +377,3 @@ static char * fe_fgets_stdin_init(const char *pr,char *s, int size)
- #endif
- }
- 
--/* ===================================================================*/
--/* =                      batch mode                                = */
--/* ===================================================================*/
--/* dummy (for batch mode): */
--char * fe_fgets_dummy(const char *pr,char *s, int size)
--{
--  return NULL;
--}
--
diff --git a/debian/patches/0008-default-path-settings.patch b/debian/patches/0008-default-path-settings.patch
deleted file mode 100644
index 14fcc73..0000000
--- a/debian/patches/0008-default-path-settings.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-From 9498be97aa05974cb61cb293a273d381c69f6c62 Mon Sep 17 00:00:00 2001
-From: "Bernhard R. Link" <brlink at debian.org>
-Date: Sat, 25 Feb 2012 13:47:46 +0100
-Subject: default path settings
-
-- Hardcode "Singular" pathname, so we can install the library to a
-  different location than the binaries.
-- as S_BIN_DIR and S_ROOT_DIR are the same in the Debian package,
-  don't default ROOT_DIR to BIN_DIR/..
-- xterm set as x-terminal-emulator alternative.
-- emacs binary located in /usr/bin
-- remove %b/.. and %r/.. from default search path in order to
-  not look into /usr/lib/LIB for libraries.
-
-Forwarded: not-needed
----
- kernel/feResource.cc | 14 ++++++--------
- 1 file changed, 6 insertions(+), 8 deletions(-)
-
-diff --git a/kernel/feResource.cc b/kernel/feResource.cc
-index 01bb816..950929a 100644
---- a/kernel/feResource.cc
-+++ b/kernel/feResource.cc
-@@ -75,13 +75,11 @@ static feResourceConfig_s feResourceConfigs[] =
-    "%b/LIB;"
-    "%b/MOD;"
-    "%r/LIB;"
--   "%r/../LIB;"
-    "%d/LIB;"
--   "%d/../LIB"
-    ""},
--  {"Singular",  'S',    feResBinary,"SINGULAR_EXECUTABLE",  "%d/"S_UNAME"/Singular",(char *)""},
--  {"BinDir",    'b',    feResDir,   "SINGULAR_BIN_DIR",     "%d/"S_UNAME,           (char *)""},
--  {"RootDir",   'r',    feResDir,   "SINGULAR_ROOT_DIR",    "%b/..",                (char *)""},
-+  {"Singular",  'S',    feResBinary,"SINGULAR_EXECUTABLE",  "%b/Singular",(char *)S_ROOT_DIR "/Singular"},
-+  {"BinDir",    'b',    feResDir,   "SINGULAR_BIN_DIR",     "%r",               (char *)""},
-+  {"RootDir",   'r',    feResDir,   "SINGULAR_ROOT_DIR",     S_ROOT_DIR,  (char *)""},
-   {"DefaultDir",'d',    feResDir,   "SINGULAR_DEFAULT_DIR",  SINGULAR_DEFAULT_DIR,  (char *)""},
-   {"InfoFile",  'i',    feResFile,  "SINGULAR_INFO_FILE",   "%r/info/singular.hlp", (char *)""},
-   {"IdxFile",   'x',    feResFile,  "SINGULAR_IDX_FILE",    "%r/doc/singular.idx",  (char *)""},
-@@ -94,8 +92,8 @@ static feResourceConfig_s feResourceConfigs[] =
-   {"Path",      'p',    feResPath,  NULL,                   "%b;$PATH",             (char *)""},
- 
- #ifdef ESINGULAR
--  {"emacs",     'E',    feResBinary,"ESINGULAR_EMACS",      "%b/emacs",             (char *)""},
--  {"xemacs",    'A',    feResBinary,"ESINGULAR_EMACS",      "%b/xemacs",            (char *)""},
-+  {"emacs",     'E',    feResBinary,"ESINGULAR_EMACS",      "/usr/bin/emacs",       (char *)""},
-+  {"xemacs",    'A',    feResBinary,"ESINGULAR_EMACS",      "/usr/bin/xemacs",      (char *)""},
-   {"SingularEmacs",'M', feResBinary,"ESINGULAR_SINGULAR",   "%b/Singular",          (char *)""},
-   {"EmacsLoad", 'l',    feResFile,  "ESINGULAR_EMACS_LOAD", "%e/.emacs-singular",   (char *)""},
-   {"EmacsDir",  'e',    feResDir,   "ESINGULAR_EMACS_DIR",  "%r/emacs",             (char *)""},
-@@ -104,7 +102,7 @@ static feResourceConfig_s feResourceConfigs[] =
- #ifdef ix86_Win
-   {"rxvt",      'X',    feResBinary,"RXVT",                 "%b/rxvt",              (char *)""},
- #else
--  {"xterm",     'X',    feResBinary,"XTERM",                "%b/xterm",             (char *)""},
-+  {"xterm",     'X',    feResBinary,"XTERM",                "/usr/bin/x-terminal-emulator",             (char *)""},
- #endif
- #else
-   {"EmacsDir",  'e',    feResDir,   "SINGULAR_EMACS_DIR",   "%r/emacs",             (char *)""},
diff --git a/debian/patches/0009-disable-examples-for-divisors-and-gitfan.patch b/debian/patches/0009-disable-examples-for-divisors-and-gitfan.patch
deleted file mode 100644
index 2ec8ef8..0000000
--- a/debian/patches/0009-disable-examples-for-divisors-and-gitfan.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From e941222fa54ee5e161e6786c6ead0483bfd391ca Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Tue, 19 Mar 2013 17:30:10 +0100
-Subject: disable examples for divisors and gitfan
-
-this is too much. there are only 3 examples in divisors that need to be
-disabled...
-
-Forwarded: not-needed
----
- doc/singular.doc | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/doc/singular.doc b/doc/singular.doc
-index 602ab1c..c7dad7e 100644
---- a/doc/singular.doc
-+++ b/doc/singular.doc
-@@ -960,7 +960,7 @@ Comments should be send to the author of the library directly.
- @node divisors_lib,ffsolve_lib,classifyceq_lib, Experimental libraries
- @subsection divisors_lib
- 
-- at c lib divisors.lib
-+ at c lib divisors.lib no_ex
- @c ----------------------------------------------------------
- @node ffsolve_lib, findifs_lib, divisors_lib, Experimental libraries
- @subsection ffsolve_lib
-@@ -992,7 +992,7 @@ Issues:
- @node gitfan_lib,lll_lib, finitediff_lib, Experimental libraries
- @subsection gitfan_lib
- 
-- at c lib gitfan.lib
-+ at c lib gitfan.lib no_ex
- 
- @c ----------------------------------------------------------
- @node lll_lib, locnormal_lib, gitfan_lib, Experimental libraries
diff --git a/debian/patches/0010-fix-warning-treated-as-error-in-pyobject.cc.patch b/debian/patches/0010-fix-warning-treated-as-error-in-pyobject.cc.patch
deleted file mode 100644
index 788b775..0000000
--- a/debian/patches/0010-fix-warning-treated-as-error-in-pyobject.cc.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From 38b6d0f27fa31f7878d3b2ba546bc8e4f44dde75 Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Tue, 19 Mar 2013 08:27:10 +0100
-Subject: fix warning treated as error in pyobject.cc
-
-Forwarded: not-needed
----
- Singular/pyobject.cc | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/Singular/pyobject.cc b/Singular/pyobject.cc
-index 354b5b6..51a8882 100644
---- a/Singular/pyobject.cc
-+++ b/Singular/pyobject.cc
-@@ -240,7 +240,7 @@ protected:
-     PyErr_Fetch(&pType, &pMessage, &pTraceback);
-     
-     Werror("pyobject error occured");
--    Werror(PyString_AsString(pMessage));
-+    Werror("%s", PyString_AsString(pMessage));
-     
-     Py_XDECREF(pType);
-     Py_XDECREF(pMessage);
diff --git a/debian/patches/0011-also-install-sing_dbm.h.patch b/debian/patches/0011-also-install-sing_dbm.h.patch
deleted file mode 100644
index 385c753..0000000
--- a/debian/patches/0011-also-install-sing_dbm.h.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From 9a818c9c4186e3c84a6bbcbde26b331dbaf9739b Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Wed, 20 Mar 2013 22:07:13 +0100
-Subject: also install sing_dbm.h
-
-Forwarded: not-needed
----
- Singular/Makefile.in | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/Singular/Makefile.in b/Singular/Makefile.in
-index 61bc6f7..960dcc0 100644
---- a/Singular/Makefile.in
-+++ b/Singular/Makefile.in
-@@ -618,7 +618,7 @@ install-libsingular: libsingular
- 	  ${INSTALL_PROGRAM}  $$file $(DESTDIR)${libdir}; \
- 	done
- 	${INSTALL_PROGRAM} libsingular.h $(DESTDIR)${includedir}
--	for file in subexpr.h tok.h grammar.h ipid.h lists.h ipshell.h attrib.h silink.h table.h; do \
-+	for file in subexpr.h tok.h grammar.h ipid.h lists.h ipshell.h attrib.h silink.h table.h sing_dbm.h; do \
- 	sed -e "s:<kernel/:<singular/:" < $$file |sed -e "s:<Singular/:<singular/:"|sed -e "s:<omalloc/:<:"|sed -e "s:<factory/:<:" >$(DESTDIR)${includedir}/singular/$$file ;\
- 	done
- 
diff --git a/debian/patches/0012-don-t-forget-LDFLAGS-in-module-compilation.patch b/debian/patches/0012-don-t-forget-LDFLAGS-in-module-compilation.patch
deleted file mode 100644
index 1c88cfe..0000000
--- a/debian/patches/0012-don-t-forget-LDFLAGS-in-module-compilation.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From 96d569ae2c6f5dc66bbce1ef513d379c19bb7ea8 Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Mon, 25 Mar 2013 10:32:45 +0100
-Subject: don't forget LDFLAGS in module compilation
-
-Forwarded: not-needed
----
- Singular/Makefile.in | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/Singular/Makefile.in b/Singular/Makefile.in
-index 960dcc0..c1e69bd 100644
---- a/Singular/Makefile.in
-+++ b/Singular/Makefile.in
-@@ -505,7 +505,7 @@ dbmsr.so: $(DBMSR_SOURCES:.cc=.dl_o)
- MOD/pyobject.${MODULE_SUFFIX}: pyobject.dl_o
- 	@echo "build dynamic module pyobject..."
- 	$(MKINSTALLDIRS) $(srcdir)/MOD 
--	$(CXX) $^ ${PYTHON_MODULE_LDFLAGS} ${SLDFLAGS} ${PYTHON_MODULE_LIBS} ${LD_LIBC} -o $@
-+	$(CXX) $^ ${PYTHON_MODULE_LDFLAGS} $(LDFLAGS) ${SLDFLAGS} ${PYTHON_MODULE_LIBS} ${LD_LIBC} -o $@
- 
- src: scanner.cc grammar.h grammar.cc libparse.cc
- 
diff --git a/debian/patches/0013-fix-mmInit-weirdness.patch b/debian/patches/0013-fix-mmInit-weirdness.patch
deleted file mode 100644
index e357283..0000000
--- a/debian/patches/0013-fix-mmInit-weirdness.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From 0d086256d04a861ca04d99d8c7a467efdf84bbd4 Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Sat, 14 Sep 2013 18:11:32 +0200
-Subject: fix mmInit weirdness.
-
-Forwarded: not-needed
----
- Singular/Makefile.in | 12 ++++++++----
- Singular/misc_ip.cc  |  7 -------
- Singular/mmInit.cc   |  8 ++++++++
- 3 files changed, 16 insertions(+), 11 deletions(-)
- create mode 100644 Singular/mmInit.cc
-
-diff --git a/Singular/Makefile.in b/Singular/Makefile.in
-index c1e69bd..23beba4 100644
---- a/Singular/Makefile.in
-+++ b/Singular/Makefile.in
-@@ -216,7 +216,7 @@ endif
- CXXSOURCES=grammar.cc scanner.cc attrib.cc \
-     blackbox.cc eigenval_ip.cc\
-     extra.cc fehelp.cc feOpt.cc \
--    ipassign.cc ipconv.cc ipid.cc iplib.cc \
-+    ipassign.cc ipconv.cc ipid.cc \
-     ipprint.cc ipshell.cc \
-     newstruct.cc lists.cc \
-     sdb.cc \
-@@ -364,6 +364,10 @@ GFTABLES = $(wildcard LIB/gftables/[1-9]*)
- 
- .cc.o:	
- 	${CXX} -fPIC ${CXXFLAGS} ${CXXTEMPLFLAGS} ${CPPFLAGS} ${DEFS} -c $<
-+
-+iplib_lib.o: iplib.cc
-+	${CXX} ${CXXFLAGS} ${CXXTEMPLFLAGS} -DLIBSINGULAR ${CPPFLAGS} ${DEFS} -c $< -o $@
-+
- .c.o:
- 	${CC} -fPIC ${CFLAGS} ${CPPFLAGS} ${DEFS} -c $<
- 
-@@ -392,10 +396,10 @@ Singular${S_EXT}: mod2.h Makefile version.h $(WIN_LIBS) scanner.cc  ${OBJS} \
- libsingular: libsingular.${SO_SUFFIX}
- 
- libsingular.${SO_SUFFIX}: version.h $(WIN_LIBS) scanner.cc  ${OBJS} \
--         iparith.o libparse.cc claptmpl.o mpsr_Tok.o $(DL_LIBS) tesths.o
-+         iparith.o libparse.cc claptmpl.o mpsr_Tok.o $(DL_LIBS) mmInit.o iplib_lib.o
- 	$(LIBSINGULAR_LD) ${SLDFLAGS} ${LIBSINGULAR_FLAGS} -o libsingular.${SO_SUFFIX} \
-- 	tesths.o iparith.o mpsr_Tok.o claptmpl.o \
-- 	${OBJS} -lkernel -L../kernel -L../factory -L../libfac -L../omalloc -L${libdir} ${LIBSINGULAR_LIBS}
-+	iparith.o mpsr_Tok.o claptmpl.o mmInit.o iplib_lib.o \
-+	    ${OBJS} -lkernel -L../kernel -L../factory -L../libfac -L../omalloc -L${libdir} ${LIBSINGULAR_LIBS}
- 
- libsingular.a: mod2.h Makefile version.h $(WIN_LIBS) scanner.cc  ${OBJS} \
-          iparith.o libparse.cc claptmpl.o mpsr_Tok.o
-diff --git a/Singular/misc_ip.cc b/Singular/misc_ip.cc
-index bd2c2b5..a00659d 100644
---- a/Singular/misc_ip.cc
-+++ b/Singular/misc_ip.cc
-@@ -1220,11 +1220,4 @@ void siInit(char *name)
- }
- 
- #ifdef LIBSINGULAR
--#ifdef HAVE_FACTORY
--// the init routines of factory need mmInit
--int mmInit( void )
--{
--  return 1;
--}
--#endif
- #endif
-diff --git a/Singular/mmInit.cc b/Singular/mmInit.cc
-new file mode 100644
-index 0000000..aa49bae
---- /dev/null
-+++ b/Singular/mmInit.cc
-@@ -0,0 +1,8 @@
-+#include <kernel/mod2.h>
-+#ifdef HAVE_FACTORY
-+// the init routines of factory need mmInit
-+int mmInit( void )
-+{
-+  return 1;
-+}
-+#endif
diff --git a/debian/patches/0014-sanitize-cf_gmp.h-generation.patch b/debian/patches/0014-sanitize-cf_gmp.h-generation.patch
deleted file mode 100644
index ea49004..0000000
--- a/debian/patches/0014-sanitize-cf_gmp.h-generation.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 481d2189dc80cb08d4e3b34205afdb7f3ee01074 Mon Sep 17 00:00:00 2001
-From: Felix Salfelder <felix at salfelder.org>
-Date: Tue, 20 Aug 2013 13:52:48 +0200
-Subject: sanitize cf_gmp.h generation
-
-this is similar to
-http://trac.sagemath.org/attachment/ticket/14737/sanitize_gmp_header_hack.patch
-
-Forwarded: not-needed
----
- factory/GNUmakefile.in      | 14 ++++++++------
- factory/gen_cf_gmp.template |  3 ---
- 2 files changed, 8 insertions(+), 9 deletions(-)
- delete mode 100644 factory/gen_cf_gmp.template
-
-diff --git a/factory/GNUmakefile.in b/factory/GNUmakefile.in
-index cb28207..45836f9 100644
---- a/factory/GNUmakefile.in
-+++ b/factory/GNUmakefile.in
-@@ -684,9 +684,11 @@ GNUmakefile:	GNUmakefile.in config.status
- config.status:	configure
- 		./config.status --recheck
- 
--# create cf_gmp.h
--cf_gmp.h: gen_cf_gmp.template
--	echo "#!/bin/sh" >gen_cf_gmp.sh 
--	echo "GMP_H_T=\"`$(CXX) $(LIBCXXFLAGS) -M gen_cf_gmp.cc|grep gmp.h` \"" >>gen_cf_gmp.sh 
--	cat gen_cf_gmp.template >>gen_cf_gmp.sh
--	$(SHELL) gen_cf_gmp.sh
-+GMP_H_ = $(shell echo '\#include <gmp.h>' | $(CXX) $(LIBCXXFLAGS) -E - -M -MP | grep 'gmp\.h:$$' )
-+GMP_H__ = $(GMP_H_:.h:=.h)
-+
-+cf_gmp.h: GNUmakefile $(GMP_H__)
-+	@echo "Generating $@ from $(GMP_H__)...";
-+	test -f "$(GMP_H__)"
-+	grep -v '__GMP_DECLSPEC_XX|std::FILE' $(GMP_H__) > $@T
-+	diff $@T $@ >/dev/null 2>/dev/null && rm $@T || mv $@T $@
-diff --git a/factory/gen_cf_gmp.template b/factory/gen_cf_gmp.template
-deleted file mode 100644
-index 90389ac..0000000
---- a/factory/gen_cf_gmp.template
-+++ /dev/null
-@@ -1,3 +0,0 @@
--GMP_H=`echo $GMP_H_T| sed -e 's/^.*gmp.cc//' -e 's/ .$//'`
--echo generating cf_gmp.h from $GMP_H
--cat $GMP_H | grep -v __GMP_DECLSPEC_XX |grep -v std::FILE > cf_gmp.h
diff --git a/debian/patches/0015-use-bin-sed-not-sed-in-build-system.patch b/debian/patches/0015-use-bin-sed-not-sed-in-build-system.patch
deleted file mode 100644
index b5d6896..0000000
--- a/debian/patches/0015-use-bin-sed-not-sed-in-build-system.patch
+++ /dev/null
@@ -1,93 +0,0 @@
-From 9979b15239cbbd95b0858fff7254c9eda80783d9 Mon Sep 17 00:00:00 2001
-From: Julien Puydt <julien.puydt at laposte.net>
-Date: Sun, 25 May 2014 13:02:55 +0200
-Subject: use /bin/sed, not sed, in build system
-
-Forwarded: not-needed
----
- Singular/Makefile.in | 3 ++-
- doc/Makefile.in      | 5 +++--
- kernel/Makefile.in   | 3 ++-
- mkinstalldirs        | 2 +-
- 4 files changed, 8 insertions(+), 5 deletions(-)
-
-diff --git a/Singular/Makefile.in b/Singular/Makefile.in
-index 23beba4..52de247 100644
---- a/Singular/Makefile.in
-+++ b/Singular/Makefile.in
-@@ -67,6 +67,7 @@ CC		= @CC@
- LD              = @LD@
- CXX		= @CXX@
- LEX		= sh flexer.sh
-+SED		= /bin/sed
- 
- PERL		= @PERL@
- BISON		= bison
-@@ -623,7 +624,7 @@ install-libsingular: libsingular
- 	done
- 	${INSTALL_PROGRAM} libsingular.h $(DESTDIR)${includedir}
- 	for file in subexpr.h tok.h grammar.h ipid.h lists.h ipshell.h attrib.h silink.h table.h sing_dbm.h; do \
--	sed -e "s:<kernel/:<singular/:" < $$file |sed -e "s:<Singular/:<singular/:"|sed -e "s:<omalloc/:<:"|sed -e "s:<factory/:<:" >$(DESTDIR)${includedir}/singular/$$file ;\
-+	$(SED) -e "s:<kernel/:<singular/:" < $$file |$(SED) -e "s:<Singular/:<singular/:"|$(SED) -e "s:<omalloc/:<:"|$(SED) -e "s:<factory/:<:" >$(DESTDIR)${includedir}/singular/$$file ;\
- 	done
- 
- uninstall: uninstallbin
-diff --git a/doc/Makefile.in b/doc/Makefile.in
-index f3ea4cf..2da78d0 100644
---- a/doc/Makefile.in
-+++ b/doc/Makefile.in
-@@ -45,6 +45,7 @@ GZIP            = @MYGZIP@
- UUDECODE        = @UUDECODE@
- 
- PERL            = @PERL@
-+SED             = /bin/sed
- TEX             = tex
- MAKEINFO        = @MAKEINFO@ --force
- TEXI2PDF        = @TEXI2PDF@
-@@ -168,10 +169,10 @@ usercard.dvi: usercard.tex singcard.tex
- 	${TEX} $<
- 
- s-plural.tex: plural.tex
--	sed -e "s/BR_PLURAL_BR/(plural)/g" <plural.tex >s-plural.tex
-+	$(SED) -e "s/BR_PLURAL_BR/(plural)/g" <plural.tex >s-plural.tex
- 
- s-plulibs.tex: plulibs.tex
--	sed -e "s/BR_PLURAL_BR/(plural)/g" <plulibs.tex >s-plulibs.tex
-+	$(SED) -e "s/BR_PLURAL_BR/(plural)/g" <plulibs.tex >s-plulibs.tex
- 
- # postscript stuff
- ps: dvi manual.ps usercard.ps
-diff --git a/kernel/Makefile.in b/kernel/Makefile.in
-index 727364e..4540b31 100644
---- a/kernel/Makefile.in
-+++ b/kernel/Makefile.in
-@@ -40,6 +40,7 @@ INSTALL_PROGRAM	= @INSTALL_PROGRAM@
- INSTALL_DATA	= @INSTALL_DATA@
- MKINSTALLDIRS   = ./mkinstalldirs
- LN_S		= @LN_S@
-+SED		= /bin/sed
- 
- ##
- ## compiler and linker options
-@@ -275,7 +276,7 @@ install-nolns: install
- install-libsingular: install
- 	${MKINSTALLDIRS} $(DESTDIR)${includedir}
- 	${MKINSTALLDIRS} $(DESTDIR)${includedir}/singular
--	for file in *.h kInline.cc; do sed -e "s:<kernel/:<singular/:"< $$file | sed -e "s:<Singular/:<singular/:"|sed -e "s:<omalloc/:<:"|sed -e "s:<factory/:<:" > $(DESTDIR)${includedir}/singular/$$file; done
-+	for file in *.h kInline.cc; do $(SED) -e "s:<kernel/:<singular/:"< $$file | $(SED) -e "s:<Singular/:<singular/:"|$(SED) -e "s:<omalloc/:<:"|$(SED) -e "s:<factory/:<:" > $(DESTDIR)${includedir}/singular/$$file; done
- 
- install: all installbin
- 
-diff --git a/mkinstalldirs b/mkinstalldirs
-index 91f6d04..80780d0 100755
---- a/mkinstalldirs
-+++ b/mkinstalldirs
-@@ -8,7 +8,7 @@
- errstatus=0
- 
- for file in ${1+"$@"} ; do 
--   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
-+   set fnord `echo ":$file" | /bin/sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
-    shift
- 
-    pathcomp=
diff --git a/debian/patches/0016-Use-full-path-for-a-few-coreutils.patch b/debian/patches/0016-Use-full-path-for-a-few-coreutils.patch
deleted file mode 100644
index 21cc2e4..0000000
--- a/debian/patches/0016-Use-full-path-for-a-few-coreutils.patch
+++ /dev/null
@@ -1,251 +0,0 @@
-From f399e8337d7cc7fb0c248bdab8b3a36023516a37 Mon Sep 17 00:00:00 2001
-From: Julien Puydt <julien.puydt at laposte.net>
-Date: Mon, 26 May 2014 09:43:52 +0200
-Subject: Use full path for a few coreutils
-
-For some reason quite a few places need /bin/something...
-
-Forwarded: not-needed
----
- Makefile.in     | 15 +++++++--------
- doc/Makefile.in | 48 +++++++++++++++++++++++++-----------------------
- install-sh      | 12 ++++++------
- mkinstalldirs   |  2 +-
- 4 files changed, 39 insertions(+), 38 deletions(-)
-
-diff --git a/Makefile.in b/Makefile.in
-index f2eaa65..bd1718d 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -21,6 +21,7 @@ PERL		= @PERL@
- TMP_DIR		= @TMP_DIR@
- MYGZIP		= @MYGZIP@ -9
- GUNZIP		= @GUNZIP@
-+CHMOD		= /bin/chmod
- 
- ##############################################################
- # default target
-@@ -53,8 +54,6 @@ install install_all:
- 		  if test "$@" = uninstall; then\
- 		    echo rm -f doc/$${FILE};\
- 	            rm -f doc/$${FILE}; \
--	          else \
--		    echo cp ${TEXINFO_TEX_DIR}/$${FILE} doc; \
- 		    cp ${TEXINFO_TEX_DIR}/$${FILE} doc; \
- 	          fi; \
- 	        done;\
-@@ -258,7 +257,7 @@ dist: ${SHAREDIST_NAME}.tar.gz  ${BINDIST_NAME}.tar.gz
- sharedist ${SHAREDIST_NAME}.tar.gz:
- 	if test -d ${SI_TMPDIR}; then rm -rf ${SI_TMPDIR}; fi
- 	${MAKE} install-sharedist localdir=${SI_TMPDIR}
--	chmod -R a+rX ${SI_TMPDIR}
-+	$(CHMOD) -R a+rX ${SI_TMPDIR}
- 	cd ${SI_TMPDIR}; tar cf - Singular| ${MYGZIP} > ${SHAREDIST_NAME}.tar.gz
- 	mv ${SI_TMPDIR}/${SHAREDIST_NAME}.tar.gz .
- 	rm -rf ${SI_TMPDIR}
-@@ -266,7 +265,7 @@ sharedist ${SHAREDIST_NAME}.tar.gz:
- bindist ${BINDIST_NAME}.tar.gz:
- 	if test -d ${SI_TMPDIR}; then rm -fr ${SI_TMPDIR}; fi
- 	${MAKE} install-bindist localdir=${SI_TMPDIR}
--	chmod -R a+rX ${SI_TMPDIR}
-+	$(CHMOD) -R a+rX ${SI_TMPDIR}
- 	cd ${SI_TMPDIR}; tar cf - Singular| ${MYGZIP} > ${BINDIST_NAME}.tar.gz
- 	mv ${SI_TMPDIR}/${BINDIST_NAME}.tar.gz .
- 	rm -rf ${SI_TMPDIR}
-@@ -274,7 +273,7 @@ bindist ${BINDIST_NAME}.tar.gz:
- static-bindist ${BINDIST_NAME}-static.tar.gz:
- 	if test -d ${SI_TMPDIR}; then rm -fr ${SI_TMPDIR}; fi
- 	${MAKE} install-bindist localdir=${SI_TMPDIR} LD_STATIC=1
--	chmod -R a+rX ${SI_TMPDIR}
-+	$(CHMOD) -R a+rX ${SI_TMPDIR}
- 	-rm -f ${SI_TMPDIR}/Singular/*/*/*.so
- 	-rm -f ${SI_TMPDIR}/Singular/*/*/modgen*
- 	cd ${SI_TMPDIR}; tar cf - Singular| ${MYGZIP} > ${BINDIST_NAME}-static.tar.gz
-@@ -651,7 +650,7 @@ _static-bindist: ${SINGULAR}
- 	-strip ${SI_TMPDIR}/${BINDIR_NAME}/*
- 	cat INSTALL.unix | sed -e "s/<x-y-z>/${S_VERSION}/g" > \
-                       ${SI_TMPDIR}/Singular/INSTALL
--	cd ${SI_TMPDIR}; chmod -R a+rX *;\
-+	cd ${SI_TMPDIR}; $(CHMOD) -R a+rX *;\
-            tar cf - Singular | ${MYGZIP} > ${BINDIST_NAME}-static.tar.gz
- 	mv ${SI_TMPDIR}/${BINDIST_NAME}-static.tar.gz .
- 	rm -rf ${SI_TMPDIR}
-@@ -682,7 +681,7 @@ windist: ${SINGULAR}
- 	${INSTALL} ${CYGWIN_DLL} ${SI_TMPDIR}/${BINDIR_NAME}
- 	cat INSTALL.win	| sed -e "s/<x-y-z>/${S_VERSION}/g" > \
-                          ${SI_TMPDIR}/Singular/INSTALL
--	cd ${SI_TMPDIR}; chmod -R a+rX *;\
-+	cd ${SI_TMPDIR}; $(CHMOD) -R a+rX *;\
-            ${ZIP} -r sing Singular
- 	mv ${SI_TMPDIR}/sing.zip Singular-${S_VERSION}-${SINGUNAME}.zip
- 	rm -rf ${SI_TMPDIR}
-@@ -695,7 +694,7 @@ srcdist:
- 	touch  grammar.cc;\
- 	touch  scanner.cc;\
- 	cd ../..;\
--	chmod -R a+rX .;\
-+	$(CHMOD) -R a+rX .;\
- 	tar cf - Singular-${S_VERSION}| ${MYGZIP} > Singular-${S_VERSION}.tar.gz
- 	mv ${SI_TMPDIR}/Singular-${S_VERSION}.tar.gz .
- 	rm -rf ${SI_TMPDIR}
-diff --git a/doc/Makefile.in b/doc/Makefile.in
-index 2da78d0..4598a5e 100644
---- a/doc/Makefile.in
-+++ b/doc/Makefile.in
-@@ -44,6 +44,8 @@ MKINSTALLDIRS   = ../mkinstalldirs
- GZIP            = @MYGZIP@
- UUDECODE        = @UUDECODE@
- 
-+CP              = /bin/cp
-+CHMOD           = /bin/chmod
- PERL            = @PERL@
- SED             = /bin/sed
- TEX             = tex
-@@ -243,7 +245,7 @@ endif
- 	${PERL} ${TEXI2HTML} -init_file t2h_standalone.init -split none -out_file $@ $<
- 
- % : %.txt
--	cp $< $@
-+	$(CP) $< $@
- 
- standalone: standalone-txt standalone-html ${STANDALONE_FILES}
- 
-@@ -254,15 +256,15 @@ WWW_DIR	= /singular/www/2-0/
- FTP_DIR = /ftp/pub/Math/Singular/Development
- 
- install-standalone: standalone
--	cp INSTALL_unix.html COPYING.html INSTALL_win.html ${WWW_DIR}
--	cp COPYING COPYING.html ${FTP_DIR}
--	cp INSTALL_unix INSTALL_unix.html ${FTP_DIR}
--	cp INSTALL_win INSTALL_win.html ${FTP_DIR}
--	cp README_ftp.html ${FTP_DIR}/README.html
--	cp README_ftp ${FTP_DIR}/README
--	cp NEWS.html NEWS ${FTP_DIR}
--	cp NEWS.html ${WWW_DIR}
--	- chmod g+w ${FTP_DIR}/*
-+	$(CP) INSTALL_unix.html COPYING.html INSTALL_win.html ${WWW_DIR}
-+	$(CP) COPYING COPYING.html ${FTP_DIR}
-+	$(CP) INSTALL_unix INSTALL_unix.html ${FTP_DIR}
-+	$(CP) INSTALL_win INSTALL_win.html ${FTP_DIR}
-+	$(CP) README_ftp.html ${FTP_DIR}/README.html
-+	$(CP) README_ftp ${FTP_DIR}/README
-+	$(CP) NEWS.html NEWS ${FTP_DIR}
-+	$(CP) NEWS.html ${WWW_DIR}
-+	- $(CHMOD) g+w ${FTP_DIR}/*
- 
- 
- 
-@@ -297,7 +299,7 @@ images/%.xbm : images/%.xbm.uu
- 
- ${IMAGES_HTML} : ${IMAGES_SRC}
- 	test -d ${HTML_SUBDIR} || mkdir ${HTML_SUBDIR}
--	cp ${IMAGES_SRC} ${HTML_SUBDIR}
-+	$(CP) ${IMAGES_SRC} ${HTML_SUBDIR}
- 
- ###########################################################
- # misc targets
-@@ -320,13 +322,13 @@ install-sharedist: singular.hlp html singular.idx \
- 	${MKINSTALLDIRS} ${install_prefix}
- 	${MKINSTALLDIRS} ${install_infodir}
- 	${INSTALL_DATA} singular.hlp ${install_infodir}
--	chmod -R +rX ${install_infodir}
-+	$(CHMOD) -R +rX ${install_infodir}
- 	${MKINSTALLDIRS} ${install_htmldir}
--	cp ${HTML_SUBDIR}/*.htm ${install_htmldir}
--	cp ${HTML_SUBDIR}/*.gif ${install_htmldir}
--	-cp ${HTML_SUBDIR}/*.png ${install_htmldir}
--	cp ${HTML_SUBDIR}/*.jpg ${install_htmldir}
--	chmod -R +rX ${install_htmldir}
-+	$(CP) ${HTML_SUBDIR}/*.htm ${install_htmldir}
-+	$(CP) ${HTML_SUBDIR}/*.gif ${install_htmldir}
-+	-$(CP) ${HTML_SUBDIR}/*.png ${install_htmldir}
-+	$(CP) ${HTML_SUBDIR}/*.jpg ${install_htmldir}
-+	$(CHMOD) -R +rX ${install_htmldir}
- 	${MKINSTALLDIRS} ${install_docdir}
- 	${INSTALL_DATA} singular.idx ${install_docdir}
- 	${INSTALL_DATA} ../GPL2 ${install_prefix}/GPL2
-@@ -337,15 +339,15 @@ install-sharedist: singular.hlp html singular.idx \
- 	${INSTALL_DATA} NEWS.html ${install_prefix}
- 	${INSTALL_DATA} README_distribution.txt ${install_prefix}/README
- 	${INSTALL_DATA} README_distribution.html ${install_prefix}/README.html
--	chmod -R +rX ${install_docdir}
--	chmod -R +rX ${install_prefix}
-+	$(CHMOD) -R +rX ${install_docdir}
-+	$(CHMOD) -R +rX ${install_prefix}
- 	${MKINSTALLDIRS} ${install_exdir}
--	cp -R examples ${install_prefix}
-+	$(CP) -R examples ${install_prefix}
- 	/bin/rm -f ${install_prefix}/examples/[A-Z]*.res
- 	/bin/rm -f ${install_prefix}/examples/*.res
- 	/bin/rm -f ${install_prefix}/examples/[A-Z]*.inc
- 	/bin/rm -f ${install_prefix}/examples/*.inc
--	chmod -R +rX ${install_prefix}/
-+	$(CHMOD) -R +rX ${install_prefix}/
- 
- # use 'make INSTALL_unix.olaf.txt INSTALL_unix.olaf.html SINGUNAME=olaf'
- # to generate these files for uname 'olaf'
-@@ -369,9 +371,9 @@ texi2html = $(TEXI2HTML:%.pl=%)
- lib2doc.tar.gz:
- 	rm -rf lib2doc lib2doc.tar.gz
- 	mkdir lib2doc
--	cp Makefile.lib2doc lib2doc/Makefile
-+	$(CP) Makefile.lib2doc lib2doc/Makefile
- 	${MAKEINFO} --no-header --paragraph-indent none -o lib2doc/README lib2doc.texi
--	cp pl2doc.pl doc2tex.pl ${texi2html} lib2doc
-+	$(CP) pl2doc.pl doc2tex.pl ${texi2html} lib2doc
- 	tar cf lib2doc.tar lib2doc
- 	${GZIP} lib2doc.tar
- 
-diff --git a/install-sh b/install-sh
-index 6781b98..9d00788 100755
---- a/install-sh
-+++ b/install-sh
-@@ -59,13 +59,13 @@ fi
- # or use environment vars.
- 
- chgrpprog=${CHGRPPROG-chgrp}
--chmodprog=${CHMODPROG-chmod}
-+chmodprog=${CHMODPROG-/bin/chmod}
- chownprog=${CHOWNPROG-chown}
- cmpprog=${CMPPROG-cmp}
--cpprog=${CPPROG-cp}
-+cpprog=${CPPROG-/bin/cp}
- mkdirprog=${MKDIRPROG-mkdir}
--mvprog=${MVPROG-mv}
--rmprog=${RMPROG-rm}
-+mvprog=${MVPROG-/bin/mv}
-+rmprog=${RMPROG-/bin/rm}
- stripprog=${STRIPPROG-strip}
- 
- posix_glob='?'
-@@ -447,7 +447,7 @@ do
-     rmtmp=$dstdir/_rm.$$_
- 
-     # Trap to clean up those temp files at exit.
--    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-+    trap 'ret=$?; $(rmprog) -f "$dsttmp" "$rmtmp" && exit $ret' 0
- 
-     # Copy the file name to the temp name.
-     (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
-@@ -477,7 +477,7 @@ do
-        test "$old" = "$new" &&
-        $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
-     then
--      rm -f "$dsttmp"
-+      $(rmprog) -f "$dsttmp"
-     else
-       # Rename the file to the real destination.
-       $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
-diff --git a/mkinstalldirs b/mkinstalldirs
-index 80780d0..bd690e1 100755
---- a/mkinstalldirs
-+++ b/mkinstalldirs
-@@ -20,7 +20,7 @@ for file in ${1+"$@"} ; do
- 
-      if test ! -d "$pathcomp"; then
-         echo "mkdir $pathcomp" 1>&2
--        mkdir "$pathcomp" || errstatus=$?
-+        /bin/mkdir "$pathcomp" || errstatus=$?
-      fi
- 
-      pathcomp="$pathcomp/"
diff --git a/debian/patches/0017-make-interactive-docbuild-work.patch b/debian/patches/0017-make-interactive-docbuild-work.patch
deleted file mode 100644
index c7a7b2b..0000000
--- a/debian/patches/0017-make-interactive-docbuild-work.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fbb53c6000d119fba6816a9d81655f494eb2982f Mon Sep 17 00:00:00 2001
-From: Julien Puydt <julien.puydt at laposte.net>
-Date: Mon, 26 May 2014 09:45:31 +0200
-Subject: make interactive docbuild work.
-
-Makes non-interactive build work The build is failing in non-interactive
-mode because it tries to launch singular, which does things which work
-only in a tty.
-
-extracted from
-http://pkg.fedoraproject.org/cgit/Singular.git/tree/Singular-doc.patch
-
-Forwarded: not-needed
----
- doc/Makefile.in | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/doc/Makefile.in b/doc/Makefile.in
-index 4598a5e..a92a7d7 100644
---- a/doc/Makefile.in
-+++ b/doc/Makefile.in
-@@ -71,7 +71,7 @@ EX_SUBDIR       = ./examples
- CHKSUM_DB       = ${DOC_SUBDIR}/chksum
- DOC2TEX_EXAMPLE_EXCLUSIONS = @DOC2TEX_EXAMPLE_EXCLUSIONS@
- DOC2TEX         = ${PERL} ./doc2tex.pl -docdir ${DOC_SUBDIR} \
--                  -Singular ${SINGULAR} -verbose ${VERBOSE} -make ${MAKE} \
-+                  -Singular /bin/true -verbose ${VERBOSE} -make ${MAKE} \
- 		  -exdir ${EX_SUBDIR} ${DOC2TEX_EXAMPLE_EXCLUSIONS}
- TAG		=
- PL2DOC		= ${PERL} ./pl2doc.pl ${TAG} -db ${CHKSUM_DB}
diff --git a/debian/patches/0018-NTL6-compatibility-patch-from-sagemath.patch b/debian/patches/0018-NTL6-compatibility-patch-from-sagemath.patch
deleted file mode 100644
index ae7ce3c..0000000
--- a/debian/patches/0018-NTL6-compatibility-patch-from-sagemath.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From 97ec68c07998e9c3b38aa340ee47aa2b4f6a09fb Mon Sep 17 00:00:00 2001
-From: Julien Puydt <julien.puydt at laposte.net>
-Date: Fri, 15 Aug 2014 09:16:12 +0200
-Subject: NTL6 compatibility patch (from sagemath)
-
----
- Singular/claptmpl.cc | 35 +++++++++++++++++++++++++++++++++++
- 1 file changed, 35 insertions(+)
-
-diff --git a/Singular/claptmpl.cc b/Singular/claptmpl.cc
-index 512b353..ec34e00 100644
---- a/Singular/claptmpl.cc
-+++ b/Singular/claptmpl.cc
-@@ -123,3 +123,38 @@ template class std::list<PolyMinorValue>;
- template class Cache<MinorKey, IntMinorValue>;
- template class Cache<MinorKey, PolyMinorValue>;
- 
-+#ifdef HAVE_NTL
-+#include<NTL/version.h>
-+#if NTL_MAJOR_VERSION == 6
-+
-+#include<NTL/tools.h>
-+#include<NTL/lzz_pE.h>
-+#include<NTL/lzz_pEX.h>
-+#include<NTL/lzz_pX.h>
-+#include<NTL/lzz_p.h>
-+#include<NTL/vector.h>
-+#include<NTL/pair.h>
-+#include<NTL/GF2X.h>
-+#include<NTL/GF2EX.h>
-+#include<NTL/ZZ.h>
-+#include<NTL/ZZX.h>
-+#include<NTL/ZZ_pX.h>
-+#ifdef NTL_CLIENT               // in <NTL/tools.h>: using of name space NTL
-+NTL_CLIENT
-+#endif
-+template class Vec<zz_p>;
-+template class Vec<zz_pE>;
-+template class Mat<zz_p>;
-+template class Mat<zz_pE>;
-+template class Mat<ZZ>;
-+template class Vec<Pair<zz_pX, long> >;
-+template class Vec<Pair<zz_pEX, long> >;
-+template class Vec<Pair<GF2EX, long> >;
-+template class Vec<Pair<ZZX, long> >;
-+template class Vec<Pair<ZZ_pX, long> >;
-+template class Vec<Pair<GF2X, long> >;
-+template void swap<zz_pE>(Vec<zz_pE>&, Vec<zz_pE>&);
-+template long operator==<zz_p>(Vec<zz_p> const&, Vec<zz_p> const&);
-+#endif
-+
-+#endif
diff --git a/debian/patches/debianization-4ti2.patch b/debian/patches/debianization-4ti2.patch
new file mode 100644
index 0000000..32f6923
--- /dev/null
+++ b/debian/patches/debianization-4ti2.patch
@@ -0,0 +1,37 @@
+Description: debianization: 4ti2
+ Address the Debian specific naming scheme set up for the 4ti2 suite tools
+ in the 4ti2 Debian package.
+Origin: debian
+Forwarded: not-needed
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-28
+
+--- a/Singular/LIB/sing4ti2.lib
++++ b/Singular/LIB/sing4ti2.lib
+@@ -89,7 +89,7 @@
+ // Singular's string is too clumsy for this, hence we first prepare
+ // using standard unix commands
+ //----------------------------------------------------------------------
+-   j=system("sh","markov sing4ti2 >/dev/null 2>&1");
++   j=system("sh","4ti2-markov sing4ti2 >/dev/null 2>&1");
+    j=system("sh","awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.mar | sed s/[\\\ \\\t\\\v\\\f]/,/g | sed s/,+/,/g|sed s/,,/,/g|sed s/,,/,/g > sing4ti2.converted");
+    if(!defined(keepfiles))
+    {
+@@ -211,7 +211,7 @@
+ // Singular's string is too clumsy for this, hence we first prepare
+ // using standard unix commands
+ //----------------------------------------------------------------------
+-   j=system("sh","graver sing4ti2 >/dev/null 2>&1");
++   j=system("sh","4ti2-graver sing4ti2 >/dev/null 2>&1");
+    j=system("sh","awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.gra | sed s/[\\\ \\\t\\\v\\\f]/,/g | sed s/,+/,/g |sed s/,,/,/g|sed s/,,/,/g > sing4ti2.converted");
+    if(!defined(keepfiles))
+    {
+@@ -331,7 +331,7 @@
+ // Singular's string is too clumsy for this, hence we first prepare
+ // using standard unix commands
+ //----------------------------------------------------------------------
+-   j=system("sh","hilbert sing4ti2 >/dev/null 2>&1");
++   j=system("sh","4ti2-hilbert sing4ti2 >/dev/null 2>&1");
+    j=system("sh","awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil | sed s/[\\\ \\\t\\\v\\\f]/,/g | sed s/,+/,/g |sed s/,,/,/g|sed s/,,/,/g > sing4ti2.converted");
+    if(!defined(keepfiles))
+    {
diff --git a/debian/patches/debianization-documentation.patch b/debian/patches/debianization-documentation.patch
new file mode 100644
index 0000000..86dd8ae
--- /dev/null
+++ b/debian/patches/debianization-documentation.patch
@@ -0,0 +1,52 @@
+Description: debianization -- documentation
+ Address Debian Policy requirements for documentation.
+Origin: debian
+Forwarded: not-needed
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-20
+
+--- a/dox/Makefile.am
++++ b/dox/Makefile.am
+@@ -1,3 +1,5 @@
++htmldir = $(docdir)/html
++
+ GIT_VERSION := $(shell $(top_srcdir)/git-version-gen $(top_srcdir)/.tarball-git-version)
+ 
+ doxyrun:
+@@ -22,20 +24,30 @@
+ 
+ if HAVE_DOXYGEN
+ 
+-## doxyfile.stamp:
+-html:
++doxyfile.stamp:
+ 	$(MAKE) doxyrun abs_top_srcdir="$(abs_top_srcdir)" abs_top_builddir="$(abs_top_builddir)" \
+ 	DOXYGEN_CONFIG="$(abs_srcdir)/Doxyfile.in" DOXYGEN="$(DOXYGEN)"
+-##	echo Timestamp > doxyfile.stamp
++	echo Timestamp > doxyfile.stamp
+ 
+-## CLEANFILES = doxyfile.stamp
++##CLEANFILES = doxyfile.stamp
+ 
+ # all-local: doxyfile.stamp
+ 
+-## html: doxyfile.stamp
++html: doxyfile.stamp
++
++install-html-local: html
++	$(MKDIR_P) $(DESTDIR)$(htmldir)
++	cp -rp -t $(DESTDIR)$(htmldir) html/search
++	cp -p -t $(DESTDIR)$(htmldir) html/*.html html/*.png
++	cp -p -t $(DESTDIR)$(htmldir) html/doxygen.css html/stylesheet.css html/tabs.css
++	cp -p -t $(DESTDIR)$(htmldir) html/dynsections.js html/svgpan.js
++	rdfind -outputname /dev/null -removeidentinode false -makesymlinks true $(DESTDIR)$(htmldir)
++	symlinks -r -c -s -v $(DESTDIR)$(htmldir)
++	rdfind -outputname /dev/null -removeidentinode false -makesymlinks true $(DESTDIR)$(htmldir)/search
++	symlinks -r -c -s -v $(DESTDIR)$(htmldir)/search
+ 
+ clean-local:
+-	rm -f html_dox.log tags
++	rm -f html_dox.log tags doxyfile.stamp
+ 	rm -rf html
+ endif
+ 
diff --git a/debian/patches/debianization-gather-headers.patch b/debian/patches/debianization-gather-headers.patch
new file mode 100644
index 0000000..a473500
--- /dev/null
+++ b/debian/patches/debianization-gather-headers.patch
@@ -0,0 +1,356 @@
+Description: debianization - gather headers
+ Gather Singular headers in a package include folder mainly for avoiding
+ possible collision, given that some of them have rather generic names.
+Origin: debian
+Forwarded: not-needed
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-28
+
+--- a/factory/Makefile.am
++++ b/factory/Makefile.am
+@@ -169,8 +169,8 @@
+ 
+ noinst_HEADERS = $(factory_headers)
+ 
+-configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/factory
+-libsingular_factory_includedir = ${includedir}/factory
++configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/singular/factory
++libsingular_factory_includedir = ${includedir}/singular/factory
+ 
+ nodist_configheader_HEADERS = factoryconf.h
+ nodist_libsingular_factory_include_HEADERS = cplusplus.h factory.h
+--- a/omalloc/Makefile.am
++++ b/omalloc/Makefile.am
+@@ -2,8 +2,8 @@
+ 
+ lib_LTLIBRARIES=libsingular-omalloc.la
+ 
+-configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/omalloc
+-libsingular_omalloc_includedir=$(includedir)/omalloc
++configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/singular/omalloc
++libsingular_omalloc_includedir=$(includedir)/singular/omalloc
+ 
+ libsingular_omalloc_include_HEADERS = \
+ omalloc.h		omDerivedConfig.h	\
+--- a/resources/Makefile.am
++++ b/resources/Makefile.am
+@@ -13,12 +13,12 @@
+ 
+ libsingular_resources_la_LDFLAGS   = -release ${PACKAGE_VERSION}
+ 
+-configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/resources
+-libsingular_resources_includedir  =$(includedir)/resources
++configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/singular/resources
++libsingular_resources_includedir  =$(includedir)/singular/resources
+ 
+ libsingular_resources_include_HEADERS = omFindExec.h feResource.h feFopen.h
+ 
+-nodist_libsingular_resources_include_HEADERS = resourcesconfig.h
++nodist_configheader_HEADERS = resourcesconfig.h
+ DISTCLEANFILES = $(nodist_libsingular_resources_include_HEADERS)
+ 
+ pkgconfigdir = $(libdir)/pkgconfig
+--- a/gfanlib/Makefile.am
++++ b/gfanlib/Makefile.am
+@@ -11,7 +11,7 @@
+ SOURCES  = gfanlib_zcone.cpp gfanlib_symmetry.cpp gfanlib_symmetriccomplex.cpp gfanlib_polyhedralfan.cpp gfanlib_zfan.cpp gfanlib_polymakefile.cpp
+ libsingular_gfan_la_SOURCES   = $(SOURCES)
+ 
+-libsingular_gfan_includedir  =$(includedir)/gfanlib
++libsingular_gfan_includedir  =$(includedir)/singular/gfanlib
+ 
+ libsingular_gfan_include_HEADERS = gfanlib_z.h gfanlib_q.h gfanlib_vector.h gfanlib_matrix.h gfanlib_zcone.h gfanlib.h gfanlib_polyhedralfan.h gfanlib_polymakefile.h gfanlib_symmetriccomplex.h gfanlib_symmetry.h gfanlib_zfan.h
+ 
+--- a/factory/include/factory/Makefile.am
++++ b/factory/include/factory/Makefile.am
+@@ -6,7 +6,7 @@
+ 		templates/ftmpl_list.h \
+ 		templates/ftmpl_matrix.h
+ 
+-libfactory_includedir = ${includedir}/factory
++libfactory_includedir = ${includedir}/singular/factory
+ 
+ nobase_libfactory_include_HEADERS = \
+               cf_gmp.h ${templateincl}
+--- a/libpolys/polys/Makefile.am
++++ b/libpolys/polys/Makefile.am
+@@ -86,7 +86,7 @@
+   module_LTLIBRARIES=p_Procs_FieldGeneral.la p_Procs_FieldIndep.la p_Procs_FieldQ.la p_Procs_FieldZp.la
+ endif
+ 
+-libsingular_polys_includedir=$(includedir)/singular/polys
++libsingular_polys_includedir=$(includedir)/singular/singular/polys
+ 
+ nobase_libsingular_polys_include_HEADERS = $(LIBPOLYSHEADERS)
+ 
+--- a/Singular/Makefile.am
++++ b/Singular/Makefile.am
+@@ -127,7 +127,7 @@
+ libsingular_Singular_la_LDFLAGS    =${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} -release ${PACKAGE_VERSION} ${PTHREAD_LDFLAGS}
+ libsingular_Singular_la_LIBADD     =${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${BUILTIN_FLAGS} ${top_builddir}/kernel/libkernel.la ${PTHREAD_LIBS}
+ 
+-libsingular_Singular_includedir = ${includedir}/singular/Singular
++libsingular_Singular_includedir = ${includedir}/singular/singular/Singular
+ nobase_libsingular_Singular_include_HEADERS = $(SingularHEADERS)
+ 
+ #########################################################
+--- a/libpolys/reporter/Makefile.am
++++ b/libpolys/reporter/Makefile.am
+@@ -9,7 +9,7 @@
+ ## libreporter_la_LDFLAGS  = -release ${PACKAGE_VERSION}
+ ## libreporter_la_LIBADD   = ${top_builddir}/misc/libmisc.la
+ 
+-libreporter_la_includedir  =$(includedir)/singular/reporter
++libreporter_la_includedir  =$(includedir)/singular/singular/reporter
+ libreporter_la_include_HEADERS   = reporter.h s_buff.h si_signals.h
+ 
+ 
+--- a/libpolys/coeffs/Makefile.am
++++ b/libpolys/coeffs/Makefile.am
+@@ -20,7 +20,7 @@
+ 
+ libcoeffs_la_SOURCES   = $(SOURCES)
+ 
+-libcoeffs_la_includedir  =$(includedir)/singular/coeffs
++libcoeffs_la_includedir  =$(includedir)/singular/singular/coeffs
+ libcoeffs_la_include_HEADERS = \
+   coeffs.h numbers.h si_gmp.h gnumpc.h gnumpfl.h longrat.h modulop.h ffields.h rintegers.h rmodulo2m.h rmodulon.h \
+   shortfl.h mpr_complex.h mpr_global.h numstats.h \
+--- a/libpolys/misc/Makefile.am
++++ b/libpolys/misc/Makefile.am
+@@ -11,7 +11,7 @@
+ 
+ libmisc_la_SOURCES   = int64vec.cc options.c sirandom.c
+ 
+-libmisc_la_includedir = $(includedir)/singular/misc
++libmisc_la_includedir = $(includedir)/singular/singular/misc
+ libmisc_la_include_HEADERS = mylimits.h options.h intvec.h int64vec.h sirandom.h
+ 
+ nodist_libmisc_la_include_HEADERS = auxiliary.h
+--- a/kernel/Makefile.am
++++ b/kernel/Makefile.am
+@@ -23,7 +23,7 @@
+ 
+ libkernel_la_SOURCES=$(KERNELHEADERS)
+ 
+-libkernel_la_includedir=${includedir}/singular/kernel
++libkernel_la_includedir=${includedir}/singular/singular/kernel
+ libkernel_la_include_HEADERS=$(KERNELHEADERS)
+ 
+ SUBDIRS=numeric fglm groebner_walk combinatorics spectrum linear_algebra maps GBEngine oswrapper
+--- a/kernel/combinatorics/Makefile.am
++++ b/kernel/combinatorics/Makefile.am
+@@ -6,7 +6,7 @@
+ noinst_LTLIBRARIES=libcombinatorics.la
+ libcombinatorics_la_SOURCES=hdegree.cc hilb.cc hutil.cc
+ 
+-libcombinatorics_la_includedir=$(includedir)/singular/kernel/combinatorics
++libcombinatorics_la_includedir=$(includedir)/singular/singular/kernel/combinatorics
+ libcombinatorics_la_include_HEADERS=hutil.h stairc.h hilb.h
+ 
+ 
+--- a/kernel/fglm/Makefile.am
++++ b/kernel/fglm/Makefile.am
+@@ -6,7 +6,7 @@
+ noinst_LTLIBRARIES=libfglm.la
+ libfglm_la_SOURCES=fglmzero.cc fglmvec.cc fglmgauss.cc fglmhom.cc fglmcomb.cc
+ 
+-libfglm_la_includedir=$(includedir)/singular/kernel/fglm
++libfglm_la_includedir=$(includedir)/singular/singular/kernel/fglm
+ libfglm_la_include_HEADERS=fglm.h fglmgauss.h fglmvec.h
+ 
+ 
+--- a/kernel/GBEngine/Makefile.am
++++ b/kernel/GBEngine/Makefile.am
+@@ -6,7 +6,7 @@
+ noinst_LTLIBRARIES=libGBEngine.la
+ libGBEngine_la_SOURCES=khstd.cc kstdfac.cc kstd1.cc kstd2.cc kutil.cc nc.cc sca.cc gr_kstd2.cc kspoly.cc kpolys.cc syz.cc syz0.cc syz1.cc syz2.cc syz3.cc units.cc tgb.cc tgbgauss.cc f5data.cc f5lists.cc f5gb.cc f5c.cc ratgring.cc shiftgb.cc ringgb.cc janet.cc
+ 
+-libGBEngine_la_includedir=$(includedir)/singular/kernel/GBEngine
++libGBEngine_la_includedir=$(includedir)/singular/singular/kernel/GBEngine
+ libGBEngine_la_include_HEADERS=syz.h kstdfac.h kutil.h khstd.h kstd1.h units.h ratgring.h shiftgb.h nc.h kInline.h tgb.h ringgb.h tgbgauss.h tgb_internal.h f5c.h f5data.h f5gb.h f5lists.h janet.h
+ 
+ 
+--- a/kernel/groebner_walk/Makefile.am
++++ b/kernel/groebner_walk/Makefile.am
+@@ -6,7 +6,7 @@
+ noinst_LTLIBRARIES=libgroebner_walk.la
+ libgroebner_walk_la_SOURCES=walkProc.cc walkMain.cc walkSupport.cc
+ 
+-libgroebner_walk_la_includedir=$(includedir)/singular/kernel/groebner_walk
++libgroebner_walk_la_includedir=$(includedir)/singular/singular/kernel/groebner_walk
+ libgroebner_walk_la_include_HEADERS=walkProc.h walkMain.h walkSupport.h
+ 
+ 
+--- a/kernel/linear_algebra/Makefile.am
++++ b/kernel/linear_algebra/Makefile.am
+@@ -9,7 +9,7 @@
+ linearAlgebra.cc eigenval.cc interpolation.cc minpoly.cc
+ 
+ 
+-liblinear_algebra_la_includedir=$(includedir)/singular/kernel/linear_algebra
++liblinear_algebra_la_includedir=$(includedir)/singular/singular/kernel/linear_algebra
+ liblinear_algebra_la_include_HEADERS= \
+   Minor.h MinorInterface.h MinorProcessor.h \
+   linearAlgebra.h eigenval.h interpolation.h minpoly.h \
+--- a/kernel/maps/Makefile.am
++++ b/kernel/maps/Makefile.am
+@@ -6,7 +6,7 @@
+ noinst_LTLIBRARIES=libmaps.la
+ libmaps_la_SOURCES=fast_maps.cc
+ 
+-libmaps_la_includedir=$(includedir)/singular/kernel/maps
++libmaps_la_includedir=$(includedir)/singular/singular/kernel/maps
+ libmaps_la_include_HEADERS=fast_maps.h
+ 
+ 
+--- a/kernel/numeric/Makefile.am
++++ b/kernel/numeric/Makefile.am
+@@ -7,7 +7,7 @@
+ noinst_LTLIBRARIES=libnumeric.la
+ libnumeric_la_SOURCES=mpr_base.cc mpr_inout.cc mpr_numeric.cc
+ 
+-libnumeric_la_includedir=$(includedir)/singular/kernel/numeric
++libnumeric_la_includedir=$(includedir)/singular/singular/kernel/numeric
+ libnumeric_la_include_HEADERS=mpr_base.h mpr_inout.h mpr_numeric.h
+ 
+ 
+--- a/kernel/oswrapper/Makefile.am
++++ b/kernel/oswrapper/Makefile.am
+@@ -6,7 +6,7 @@
+ noinst_LTLIBRARIES=liboswrapper.la
+ liboswrapper_la_SOURCES=feread.cc fereadl.c timer.cc rlimit.c
+ 
+-liboswrapper_la_includedir=$(includedir)/singular/kernel/oswrapper
++liboswrapper_la_includedir=$(includedir)/singular/singular/kernel/oswrapper
+ liboswrapper_la_include_HEADERS=feread.h timer.h rlimit.h
+ 
+ 
+--- a/kernel/spectrum/Makefile.am
++++ b/kernel/spectrum/Makefile.am
+@@ -6,7 +6,7 @@
+ noinst_LTLIBRARIES=libspectrum.la
+ libspectrum_la_SOURCES=GMPrat.cc multicnt.cc npolygon.cc semic.cc spectrum.cc splist.cc
+ 
+-libspectrum_la_includedir=$(includedir)/singular/kernel/spectrum
++libspectrum_la_includedir=$(includedir)/singular/singular/kernel/spectrum
+ libspectrum_la_include_HEADERS=GMPrat.h multicnt.h npolygon.h semic.h spectrum.h splist.h kmatrix.h
+ 
+ 
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -28,7 +28,7 @@
+ 	$(srcdir)/git-version-gen $(srcdir)/.tarball-git-version > $(distdir)/.tarball-git-version
+ 
+ 
+-configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/singular
++configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/singular/singular
+ nodist_configheader_HEADERS = singularconfig.h
+ DISTCLEANFILES = $(nodist_configheader_HEADERS)
+ 
+--- a/libpolys/Makefile.am
++++ b/libpolys/Makefile.am
+@@ -15,7 +15,7 @@
+ 
+ SUBDIRS=misc reporter coeffs polys tests
+ 
+-configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/singular
++configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/singular/singular
+ nodist_configheader_HEADERS = libpolysconfig.h
+ DISTCLEANFILES = $(nodist_configheader_HEADERS)
+ 
+--- a/libpolys/libpolys.pc.in
++++ b/libpolys/libpolys.pc.in
+@@ -2,6 +2,7 @@
+ exec_prefix=@exec_prefix@
+ libdir=@libdir@
+ includedir=@includedir@
++multiarchincludedir=@includedir@/@DEB_HOST_MULTIARCH@
+ 
+ Name: @PACKAGE@
+ Description: The Singular polynomial/coefficient arithmetic and related supporting functionality
+@@ -11,7 +12,7 @@
+ Requires: @PKG_REQUIRE@ factory
+ Conflicts:
+ 
+-Cflags: -I${includedir} -I${includedir}/singular @SINGULAR_CFLAGS@ @FLINT_CFLAGS@ @NTL_CFLAGS@ @GMP_CFLAGS@
++Cflags: -I${multiarchincludedir}/singular -I${multiarchincludedir}/singular/singular -I${includedir}/singular -I${includedir}/singular/singular @SINGULAR_CFLAGS@ @FLINT_CFLAGS@ @NTL_CFLAGS@ @GMP_CFLAGS@
+ Libs: -L${libdir} -lsingular-polys @FLINT_LIBS@ @NTL_LIBS@ @GMP_LIBS@ @USEPPROCSDYNAMICLD@
+ Libs.private:
+ 
+--- a/Singular.pc.in
++++ b/Singular.pc.in
+@@ -2,6 +2,7 @@
+ exec_prefix=@exec_prefix@
+ libdir=@libdir@
+ includedir=@includedir@
++multiarchincludedir=@includedir@/@DEB_HOST_MULTIARCH@
+ 
+ Name: libSingular
+ Description: The Singular high level functionality
+@@ -11,7 +12,7 @@
+ Requires: @PKG_REQUIRE@ libpolys
+ Conflicts:
+ 
+-Cflags: -I${includedir} -I${includedir}/singular @SINGULAR_CFLAGS@
++Cflags: -I${multiarchincludedir}/singular -I${multiarchincludedir}/singular/singular -I${includedir}/singular -I${includedir}/singular/singular @SINGULAR_CFLAGS@
+ Libs: -L${libdir} -lsingular-Singular @USEPPROCSDYNAMICLD@
+ Libs.private:
+ 
+--- a/resources/resources.pc.in
++++ b/resources/resources.pc.in
+@@ -2,6 +2,7 @@
+ exec_prefix=@exec_prefix@
+ libdir=@libdir@
+ includedir=@includedir@
++multiarchincludedir=@includedir@/@DEB_HOST_MULTIARCH@
+ 
+ Name: @PACKAGE@
+ Description: The Singular resources manager
+@@ -11,7 +12,7 @@
+ # Requires:
+ # Conflicts:
+ 
+-Cflags: -I${includedir} @SINGULAR_CFLAGS@
++Cflags: -I${multiarchincludedir}/singular -I${includedir}/singular @SINGULAR_CFLAGS@
+ Libs: -L${libdir} -lsingular-resources
+ # Libs.private:
+ 
+--- a/factory/factory.pc.in
++++ b/factory/factory.pc.in
+@@ -2,6 +2,7 @@
+ exec_prefix=@exec_prefix@
+ libdir=@libdir@
+ includedir=@includedir@
++multiarchincludedir=@includedir@/@DEB_HOST_MULTIARCH@
+ 
+ Name: @PACKAGE@
+ Description: The Singular factorization library
+@@ -11,7 +12,7 @@
+ Requires: @PKG_REQUIRE@
+ Conflicts:
+ 
+-Cflags: -I${includedir} @SINGULAR_CFLAGS@ @FLINT_CFLAGS@ @NTL_CFLAGS@ @GMP_CFLAGS@
++Cflags: -I${multiarchincludedir}/singular -I${includedir}/singular @SINGULAR_CFLAGS@ @FLINT_CFLAGS@ @NTL_CFLAGS@ @GMP_CFLAGS@
+ Libs: -L${libdir} -lsingular-factory @FLINT_LIBS@ @NTL_LIBS@ @GMP_LIBS@
+ Libs.private:
+ 
+--- a/omalloc/omalloc.pc.in
++++ b/omalloc/omalloc.pc.in
+@@ -2,6 +2,7 @@
+ exec_prefix=@exec_prefix@
+ libdir=@libdir@
+ includedir=@includedir@
++multiarchincludedir=@includedir@/@DEB_HOST_MULTIARCH@
+ 
+ Name: @PACKAGE@
+ Description: The Singular memory manager
+@@ -11,7 +12,7 @@
+ # Requires:
+ # Conflicts:
+ 
+-Cflags: -I${includedir} -DOM_NDEBUG
++Cflags: -I${multiarchincludedir}/singular -I${includedir}/singular -DOM_NDEBUG
+ Libs: -L${libdir} -lsingular-omalloc
+ # Libs.private:
+ 
diff --git a/debian/patches/debianization-rename-libraries.patch b/debian/patches/debianization-rename-libraries.patch
new file mode 100644
index 0000000..b0aa011
--- /dev/null
+++ b/debian/patches/debianization-rename-libraries.patch
@@ -0,0 +1,480 @@
+Description: debianization - rename libraries
+ Append suffix `singular-' to every Singular libraries for avoiding possible
+ collision and for consistency, given that their name are rather generic apart
+ for the Singular library itself.
+Origin: debian
+Forwarded: not-needed
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-28
+
+--- a/omalloc/Makefile.am
++++ b/omalloc/Makefile.am
+@@ -1,11 +1,11 @@
+ ACLOCAL_AMFLAGS = -I ../m4
+ 
+-lib_LTLIBRARIES=libomalloc.la
++lib_LTLIBRARIES=libsingular-omalloc.la
+ 
+ configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/omalloc
+-libomalloc_includedir=$(includedir)/omalloc
++libsingular_omalloc_includedir=$(includedir)/omalloc
+ 
+-libomalloc_include_HEADERS = \
++libsingular_omalloc_include_HEADERS = \
+ omalloc.h		omDerivedConfig.h	\
+ omError.h		omStructs.h		omAllocDecl.h		\
+ omInlineDecl.h		omBin.h			omMemOps.h		\
+@@ -29,20 +29,20 @@
+ 
+ AM_CPPFLAGS =-I${top_srcdir}/.. -I${top_builddir}/..
+ 
+-libomalloc_la_SOURCES=$(SOURCES) $(noinst_HEADERS)
++libsingular_omalloc_la_SOURCES=$(SOURCES) $(noinst_HEADERS)
+ 
+-libomalloc_la_LDFLAGS    = -release ${PACKAGE_VERSION}
++libsingular_omalloc_la_LDFLAGS    = -release ${PACKAGE_VERSION}
+ if WANT_DEBUG
+-libomalloc_la_CFLAGS    = -g
++libsingular_omalloc_la_CFLAGS    = -g
+ else !WANT_DEBUG
+-libomalloc_la_CFLAGS    = -O2
++libsingular_omalloc_la_CFLAGS    = -O2
+ endif
+ 
+-nodist_libomalloc_la_SOURCES = omTables.inc omTables.h mylimits.h
++nodist_libsingular_omalloc_la_SOURCES = omTables.inc omTables.h mylimits.h
+ nodist_configheader_HEADERS = omConfig.h
+-nodist_libomalloc_include_HEADERS = mylimits.h omTables.h
++nodist_libsingular_omalloc_include_HEADERS = mylimits.h omTables.h
+ 
+-libomalloc_la_CPPFLAGS  = ${AM_CPPFLAGS} -DOM_ALLOC_INTERNAL
++libsingular_omalloc_la_CPPFLAGS  = ${AM_CPPFLAGS} -DOM_ALLOC_INTERNAL
+ 
+ BUILT_SOURCES = omTables.inc omTables.h
+ 
+@@ -72,10 +72,10 @@
+ 
+ omtTest_m_CPPFLAGS = ${AM_CPPFLAGS} -DOM_TEST_MALLOC
+ omtTest_m_SOURCES  = $(OMTTESTSSOURCES)
+-omtTest_m_LDADD    = libomalloc.la
++omtTest_m_LDADD    = libsingular-omalloc.la
+ 
+ omtTest_r_SOURCES  = $(OMTTESTSSOURCES)
+-omtTest_r_LDADD    = libomalloc.la
++omtTest_r_LDADD    = libsingular-omalloc.la
+ 
+ pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = omalloc.pc
+--- a/Singular/Makefile.am
++++ b/Singular/Makefile.am
+@@ -13,10 +13,10 @@
+ 
+ ########################### libSingular* #########################
+ 
+-libSingular_LTLIBRARIES = libSingular.la
+-libSingulardir = $(libdir)
++libsingular_Singular_LTLIBRARIES = libsingular-Singular.la
++libsingular_Singulardir = $(libdir)
+ 
+-libSingular_la_CPPFLAGS = ${AM_CPPFLAGS} -DLIBSINGULAR ${PTHREAD_CFLAGS}
++libsingular_Singular_la_CPPFLAGS = ${AM_CPPFLAGS} -DLIBSINGULAR ${PTHREAD_CFLAGS}
+ 
+ SOURCES = \
+    links/asciiLink.cc\
+@@ -69,7 +69,7 @@
+ 
+ #   links/slInit_Dynamic.cc
+ 
+-libSingular_la_SOURCES   = $(SOURCES)
++libsingular_Singular_la_SOURCES   = $(SOURCES)
+ 
+ SingularHEADERS = \
+    attrib.h \
+@@ -122,13 +122,13 @@
+ # -DMAKE_DISTRIBUTION
+ 
+ # plural_cmd.inc
+-nodist_libSingular_la_SOURCES = feOpt.inc iparith.inc
++nodist_libsingular_Singular_la_SOURCES = feOpt.inc iparith.inc
+ 
+-libSingular_la_LDFLAGS    =${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} -release ${PACKAGE_VERSION} ${PTHREAD_LDFLAGS}
+-libSingular_la_LIBADD     =${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${BUILTIN_FLAGS} ${top_builddir}/kernel/libkernel.la ${PTHREAD_LIBS}
++libsingular_Singular_la_LDFLAGS    =${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} -release ${PACKAGE_VERSION} ${PTHREAD_LDFLAGS}
++libsingular_Singular_la_LIBADD     =${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${BUILTIN_FLAGS} ${top_builddir}/kernel/libkernel.la ${PTHREAD_LIBS}
+ 
+-libSingular_includedir = ${includedir}/singular/Singular
+-nobase_libSingular_include_HEADERS = $(SingularHEADERS)
++libsingular_Singular_includedir = ${includedir}/singular/Singular
++nobase_libsingular_Singular_include_HEADERS = $(SingularHEADERS)
+ 
+ #########################################################
+ # handle all the generated *.inc
+@@ -176,13 +176,13 @@
+ 
+ Singular_SOURCES = tesths.cc mmalloc.cc fegetopt.c fegetopt.h utils.cc  utils.h
+ 
+-Singular_LDADD = libSingular.la ${BUILTIN_FLAGS}
++Singular_LDADD = libsingular-Singular.la ${BUILTIN_FLAGS}
+ 
+ Singular_LDFLAGS = ${AM_LDFLAGS} ${BUILTIN_FLAGS}
+ 
+ Singulard_SOURCES = tesths.cc mmalloc.cc fegetopt.c fegetopt.h utils.cc  utils.h
+ 
+-Singulard_LDADD = libSingular.la ${BUILTIN_FLAGS}
++Singulard_LDADD = libsingular-Singular.la ${BUILTIN_FLAGS}
+ 
+ Singulard_LDFLAGS = -shared ${AM_LDFLAGS} ${BUILTIN_FLAGS}
+ 
+@@ -193,8 +193,8 @@
+ ESingular_CPPFLAGS = ${AM_CPPFLAGS} -DESINGULAR -DPROTO
+ # ESingular_LDFLAGS = ${AM_LDFLAGS}
+ ESingular_LDADD =  ${top_builddir}/libpolys/reporter/libreporter.la \
+-${top_builddir}/libpolys/misc/libmisc.la ${top_builddir}/omalloc/libomalloc.la \
+-${top_builddir}/resources/libresources.la
++${top_builddir}/libpolys/misc/libmisc.la ${top_builddir}/omalloc/libsingular-omalloc.la \
++${top_builddir}/resources/libsingular-resources.la
+ 
+ 
+ ESingular_SOURCES = emacs.cc fegetopt.c fegetopt.h feOptES.inc feOpt.cc
+@@ -203,8 +203,8 @@
+ TSingular_CPPFLAGS = ${AM_CPPFLAGS} -DTSINGULAR -DPROTO
+ # TSingular_LDFLAGS = ${AM_LDFLAGS}
+ TSingular_LDADD = ${top_builddir}/libpolys/reporter/libreporter.la \
+-${top_builddir}/libpolys/misc/libmisc.la ${top_builddir}/omalloc/libomalloc.la \
+-${top_builddir}/resources/libresources.la
++${top_builddir}/libpolys/misc/libmisc.la ${top_builddir}/omalloc/libsingular-omalloc.la \
++${top_builddir}/resources/libsingular-resources.la
+ 
+ TSingular_SOURCES = emacs.cc fegetopt.c fegetopt.h feOptTS.inc feOpt.cc
+ # utils.cc utils.h
+@@ -215,7 +215,7 @@
+ 
+ libparse_SOURCES = libparse.cc fegetopt.c fegetopt.h utils.cc  utils.h
+ 
+-libparse_LDADD = ${top_builddir}/omalloc/libomalloc.la
++libparse_LDADD = ${top_builddir}/omalloc/libsingular-omalloc.la
+ libparse_LDFLAGS = ${AM_LDFLAGS}
+ 
+ %.1: %
+@@ -254,7 +254,7 @@
+ check_PROGRAMS=$(TESTS)
+ 
+ test_SOURCES = test.cc
+-test_LDADD = libSingular.la
++test_LDADD = libsingular-Singular.la
+ 
+ #########################################################
+ ### plural_cmd.inc
+--- a/xalloc/Makefile.am
++++ b/xalloc/Makefile.am
+@@ -1,8 +1,8 @@
+ ACLOCAL_AMFLAGS = -I ../m4
+ 
+-noinst_LTLIBRARIES=libomalloc.la
++noinst_LTLIBRARIES=libsingular-omalloc.la
+ 
+-# lib_LTLIBRARIES=libomalloc.la
++# lib_LTLIBRARIES=libsingular-omalloc.la
+ # lib_LIBRARIES=libomalloc.a
+ 
+ # libomallocdir = $(libdir)/
+@@ -12,8 +12,8 @@
+ 
+ SOURCES = dummy.c omalloc.h
+ 
+-libomalloc_la_SOURCES  =$(SOURCES)
++libsingular_omalloc_la_SOURCES  =$(SOURCES)
+ 
+-libomalloc_la_LDFLAGS  = -release ${PACKAGE_VERSION}
++libsingular_omalloc_la_LDFLAGS  = -release ${PACKAGE_VERSION}
+ 
+ 
+--- a/m4/options.m4
++++ b/m4/options.m4
+@@ -130,7 +130,7 @@
+     OMALLOC_INCLUDES="$OMALLOC_INCLUDES -I$ac_abs_top_builddir"
+   fi
+ 
+-  OMALLOC_LIBS="$ac_abs_top_builddir/omalloc/libomalloc.la"
++  OMALLOC_LIBS="$ac_abs_top_builddir/omalloc/libsingular-omalloc.la"
+ 
+   AC_SUBST(OMALLOC_INCLUDES)
+   AC_SUBST(OMALLOC_LIBS)
+@@ -162,7 +162,7 @@
+   AC_MSG_RESULT(yes)
+   RESOURCES_INCLUDES="-I$ac_abs_top_srcdir "
+ 
+-  RESOURCES_LIBS="$ac_abs_top_builddir/resources/libresources.la"
++  RESOURCES_LIBS="$ac_abs_top_builddir/resources/libsingular-resources.la"
+ 
+   AC_SUBST(RESOURCES_INCLUDES)
+   AC_SUBST(RESOURCES_LIBS)
+@@ -199,7 +199,7 @@
+     FACTORY_INCLUDES="$FACTORY_INCLUDES -I$ac_abs_top_builddir -I$ac_abs_top_builddir/factory/include"
+   fi
+ 
+-  FACTORY_LIBS="$ac_abs_top_builddir/factory/libfactory.la"
++  FACTORY_LIBS="$ac_abs_top_builddir/factory/libsingular-factory.la"
+ 
+   AC_SUBST(FACTORY_INCLUDES)
+   AC_SUBST(FACTORY_LIBS)
+--- a/factory/Makefile.am
++++ b/factory/Makefile.am
+@@ -6,12 +6,12 @@
+ $(OMALLOC_INCLUDES) $(RESOURCES_INCLUDES) \
+ $(FLINT_CFLAGS) $(NTL_CFLAGS) $(GMP_CFLAGS)
+ 
+-lib_LTLIBRARIES = libfactory.la
++lib_LTLIBRARIES = libsingular-factory.la
+ 
+-libfactory_la_LIBADD     =$(RESOURCES_LIBS) $(OMALLOC_LIBS) \
++libsingular_factory_la_LIBADD     =$(RESOURCES_LIBS) $(OMALLOC_LIBS) \
+ $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS)
+ 
+-libfactory_la_LDFLAGS    = -release ${PACKAGE_VERSION}
++libsingular_factory_la_LDFLAGS    = -release ${PACKAGE_VERSION}
+ 
+ # factory source files
+ SOURCES = \
+@@ -93,9 +93,9 @@
+     SOURCES +=  readcf.yy
+ endif
+ 
+-libfactory_la_SOURCES = $(SOURCES)
++libsingular_factory_la_SOURCES = $(SOURCES)
+ 
+-nodist_libfactory_la_SOURCES = cplusplus.h factory.h factoryconf.h
++nodist_libsingular_factory_la_SOURCES = cplusplus.h factory.h factoryconf.h
+ 
+ # factory header files
+ factory_headers = \
+@@ -170,10 +170,10 @@
+ noinst_HEADERS = $(factory_headers)
+ 
+ configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/factory
+-libfactory_includedir = ${includedir}/factory
++libsingular_factory_includedir = ${includedir}/factory
+ 
+ nodist_configheader_HEADERS = factoryconf.h
+-nodist_libfactory_include_HEADERS = cplusplus.h factory.h
++nodist_libsingular_factory_include_HEADERS = cplusplus.h factory.h
+ 
+ 
+ ####################################################
+@@ -210,13 +210,13 @@
+ ####################################################
+ # Support for building GF(q)-tables
+ #
+-# gengftables needs libfactory.la and factory.h AND is needed for
++# gengftables needs libsingular-factory.la and factory.h AND is needed for
+ # generating gftable but the tables are not necessarily needed to
+ # compile and use libfactory (though it will be a lot slower).
+ 
+ EXTRA_PROGRAMS = gengftables
+ gengftables_SOURCES = gengftables-conway.cc
+-gengftables_LDADD = libfactory.la $(FLINT_LIBS) $(GMP_LIBS) $(NTL_LIBS)
++gengftables_LDADD = libsingular-factory.la $(FLINT_LIBS) $(GMP_LIBS) $(NTL_LIBS)
+ 
+ 
+ ####################################################
+@@ -284,7 +284,7 @@
+ check_PROGRAMS = $(TESTS)
+ 
+ test_SOURCES = test.cc
+-test_LDADD   = libfactory.la $(libfactory_la_LIBADD)
++test_LDADD   = libsingular-factory.la $(libsingular_factory_la_LIBADD)
+ 
+ ####################################################
+ ## PKG config
+--- a/resources/Makefile.am
++++ b/resources/Makefile.am
+@@ -1,25 +1,25 @@
+ ACLOCAL_AMFLAGS = -I ../m4
+ 
+-libresources_LTLIBRARIES = libresources.la
++libsingular_resources_LTLIBRARIES = libsingular-resources.la
+ 
+-libresourcesdir = $(libdir)
++libsingular_resourcesdir = $(libdir)
+ 
+ 
+ AM_CPPFLAGS = -I${top_srcdir} -I${top_builddir}
+ 
+ 
+ SOURCES  = omFindExec.c feResource.cc feFopen.cc
+-libresources_la_SOURCES   = $(SOURCES)
++libsingular_resources_la_SOURCES   = $(SOURCES)
+ 
+-libresources_la_LDFLAGS   = -release ${PACKAGE_VERSION}
++libsingular_resources_la_LDFLAGS   = -release ${PACKAGE_VERSION}
+ 
+ configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/resources
+-libresources_includedir  =$(includedir)/resources
++libsingular_resources_includedir  =$(includedir)/resources
+ 
+-libresources_include_HEADERS = omFindExec.h feResource.h feFopen.h
++libsingular_resources_include_HEADERS = omFindExec.h feResource.h feFopen.h
+ 
+-nodist_libresources_include_HEADERS = resourcesconfig.h
+-DISTCLEANFILES = $(nodist_libresources_include_HEADERS)
++nodist_libsingular_resources_include_HEADERS = resourcesconfig.h
++DISTCLEANFILES = $(nodist_libsingular_resources_include_HEADERS)
+ 
+ pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = resources.pc
+--- a/kernel/Makefile.am
++++ b/kernel/Makefile.am
+@@ -14,7 +14,7 @@
+ 
+ libkernelCommon_la_SOURCES  = $(SOURCES)
+ libkernelCommon_la_LIBADD   = ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} \
+-${abs_top_builddir}/libpolys/polys/libpolys.la
++${abs_top_builddir}/libpolys/polys/libsingular-polys.la
+ 
+ ###### libkerneldir = $(libdir)/singular
+ 
+--- a/libpolys/polys/Makefile.am
++++ b/libpolys/polys/Makefile.am
+@@ -22,8 +22,8 @@
+ endif
+ 
+ 
+-libpolys_LTLIBRARIES = libpolys.la
+-libpolysdir = $(libdir)
++libsingular_polys_LTLIBRARIES = libsingular-polys.la
++libsingular_polysdir = $(libdir)
+ 
+ SOURCES = \
+ 	monomials/monomials.cc monomials/p_polys.cc monomials/ring.cc monomials/maps.cc \
+@@ -86,16 +86,16 @@
+   module_LTLIBRARIES=p_Procs_FieldGeneral.la p_Procs_FieldIndep.la p_Procs_FieldQ.la p_Procs_FieldZp.la
+ endif
+ 
+-libpolys_includedir=$(includedir)/singular/polys
++libsingular_polys_includedir=$(includedir)/singular/polys
+ 
+-nobase_libpolys_include_HEADERS = $(LIBPOLYSHEADERS)
++nobase_libsingular_polys_include_HEADERS = $(LIBPOLYSHEADERS)
+ 
+-libpolys_la_SOURCES = ${SOURCES}
++libsingular_polys_la_SOURCES = ${SOURCES}
+ 
+-EXTRA_libpolys_la_SOURCES = templates/p_Procs_Static.cc templates/p_Procs_Dynamic.cc
++EXTRA_libsingular_polys_la_SOURCES = templates/p_Procs_Static.cc templates/p_Procs_Dynamic.cc
+ 
+-libpolys_la_LDFLAGS= ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} -release ${PACKAGE_VERSION}
+-libpolys_la_LIBADD = ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${top_builddir}/coeffs/libcoeffs.la
++libsingular_polys_la_LDFLAGS= ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} -release ${PACKAGE_VERSION}
++libsingular_polys_la_LIBADD = ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${top_builddir}/coeffs/libcoeffs.la
+ 
+ 
+ #################################################
+@@ -122,7 +122,7 @@
+ TESTS = test
+ check_PROGRAMS = $(TESTS)
+ 
+-test_LDADD=libpolys.la \
++test_LDADD=libsingular-polys.la \
+ ${top_builddir}/reporter/libreporter.la ${top_builddir}/misc/libmisc.la \
+ $(FACTORY_LIBS) $(RESOURCES_LIBS) $(OMALLOC_LIBS) \
+ $(FLINT_LIBS) $(GMP_LIBS) $(NTL_LIBS)
+--- a/gfanlib/Makefile.am
++++ b/gfanlib/Makefile.am
+@@ -1,19 +1,19 @@
+ ACLOCAL_AMFLAGS = -I ../m4
+ 
+ if HAVE_GFANLIB
+-  libgfan_LTLIBRARIES=libgfan.la
++  libsingular_gfan_LTLIBRARIES=libsingular-gfan.la
+ endif
+ 
+-libgfandir = $(libdir)
++libsingular_gfandir = $(libdir)
+ 
+ AM_CPPFLAGS = -I${top_srcdir} -I${top_builddir} -DGMPRATIONAL
+ 
+ SOURCES  = gfanlib_zcone.cpp gfanlib_symmetry.cpp gfanlib_symmetriccomplex.cpp gfanlib_polyhedralfan.cpp gfanlib_zfan.cpp gfanlib_polymakefile.cpp
+-libgfan_la_SOURCES   = $(SOURCES)
++libsingular_gfan_la_SOURCES   = $(SOURCES)
+ 
+-libgfan_includedir  =$(includedir)/gfanlib
++libsingular_gfan_includedir  =$(includedir)/gfanlib
+ 
+-libgfan_include_HEADERS = gfanlib_z.h gfanlib_q.h gfanlib_vector.h gfanlib_matrix.h gfanlib_zcone.h gfanlib.h gfanlib_polyhedralfan.h gfanlib_polymakefile.h gfanlib_symmetriccomplex.h gfanlib_symmetry.h gfanlib_zfan.h
++libsingular_gfan_include_HEADERS = gfanlib_z.h gfanlib_q.h gfanlib_vector.h gfanlib_matrix.h gfanlib_zcone.h gfanlib.h gfanlib_polyhedralfan.h gfanlib_polymakefile.h gfanlib_symmetriccomplex.h gfanlib_symmetry.h gfanlib_zfan.h
+ 
+ DISTCLEANFILES =  config.h
+ 
+--- a/Singular/dyn_modules/gfanlib/Makefile.am
++++ b/Singular/dyn_modules/gfanlib/Makefile.am
+@@ -26,7 +26,7 @@
+ gfanlib_la_LDFLAGS  = ${P_PROCS_MODULE_LDFLAGS}
+ 
+ if HAVE_GFANLIB
+- gfanlib_la_LIBADD   = ${abs_top_builddir}/gfanlib/libgfan.la ${CDDGMPLDFLAGS}
++ gfanlib_la_LIBADD   = ${abs_top_builddir}/gfanlib/libsingular-gfan.la ${CDDGMPLDFLAGS}
+ endif
+ 
+ #AM_COLOR_TESTS=always
+--- a/libpolys/tests/Makefile.am
++++ b/libpolys/tests/Makefile.am
+@@ -22,7 +22,7 @@
+ $(FACTORY_LIBS) $(RESOURCES_LIBS) $(OMALLOC_LIBS) \
+ $(FLINT_LIBS) $(GMP_LIBS) $(NTL_LIBS)
+ 
+-polys_test_LDADD = ${top_builddir}/polys/libpolys.la $(coeffs_test_LDADD)
++polys_test_LDADD = ${top_builddir}/polys/libsingular-polys.la $(coeffs_test_LDADD)
+ rings_test_LDADD = $(polys_test_LDADD)
+ 
+ BUILT_SOURCES = gftables MOD \
+--- a/Singular.pc.in
++++ b/Singular.pc.in
+@@ -12,6 +12,6 @@
+ Conflicts:
+ 
+ Cflags: -I${includedir} -I${includedir}/singular @SINGULAR_CFLAGS@
+-Libs: -L${libdir} -lSingular @USEPPROCSDYNAMICLD@
++Libs: -L${libdir} -lsingular-Singular @USEPPROCSDYNAMICLD@
+ Libs.private:
+ 
+--- a/omalloc/omalloc.pc.in
++++ b/omalloc/omalloc.pc.in
+@@ -12,6 +12,7 @@
+ # Conflicts:
+ 
+ Cflags: -I${includedir} -DOM_NDEBUG
+-Libs: -L${libdir} -l at PACKAGE@
++Libs: -L${libdir} -lsingular-omalloc
+ # Libs.private:
+ 
++
+--- a/resources/resources.pc.in
++++ b/resources/resources.pc.in
+@@ -12,6 +12,6 @@
+ # Conflicts:
+ 
+ Cflags: -I${includedir} @SINGULAR_CFLAGS@
+-Libs: -L${libdir} -l at PACKAGE@
++Libs: -L${libdir} -lsingular-resources
+ # Libs.private:
+ 
+--- a/factory/factory.pc.in
++++ b/factory/factory.pc.in
+@@ -12,6 +12,6 @@
+ Conflicts:
+ 
+ Cflags: -I${includedir} @SINGULAR_CFLAGS@ @FLINT_CFLAGS@ @NTL_CFLAGS@ @GMP_CFLAGS@
+-Libs: -L${libdir} -l at PACKAGE@ @FLINT_LIBS@ @NTL_LIBS@ @GMP_LIBS@
++Libs: -L${libdir} -lsingular-factory @FLINT_LIBS@ @NTL_LIBS@ @GMP_LIBS@
+ Libs.private:
+ 
+--- a/libpolys/libpolys.pc.in
++++ b/libpolys/libpolys.pc.in
+@@ -12,6 +12,6 @@
+ Conflicts:
+ 
+ Cflags: -I${includedir} -I${includedir}/singular @SINGULAR_CFLAGS@ @FLINT_CFLAGS@ @NTL_CFLAGS@ @GMP_CFLAGS@
+-Libs: -L${libdir} -lpolys @FLINT_LIBS@ @NTL_LIBS@ @GMP_LIBS@ @USEPPROCSDYNAMICLD@
++Libs: -L${libdir} -lsingular-polys @FLINT_LIBS@ @NTL_LIBS@ @GMP_LIBS@ @USEPPROCSDYNAMICLD@
+ Libs.private:
+ 
diff --git a/debian/patches/debianization-rename-pkgconfig_files.patch b/debian/patches/debianization-rename-pkgconfig_files.patch
new file mode 100644
index 0000000..3eb520e
--- /dev/null
+++ b/debian/patches/debianization-rename-pkgconfig_files.patch
@@ -0,0 +1,147 @@
+Description: debianization - rename pkpconfig (pc) files
+ Append suffix `singular-' to each Singular pkgconfig(1) file for avoiding
+ possible collision apart for the Singular pkgconfig file itself, while
+ previous renaming changes are implemented.
+Origin: debian
+Forwarded: not-needed
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-28
+
+--- a/Singular.pc.in
++++ b/Singular.pc.in
+@@ -9,7 +9,7 @@
+ Version: @PACKAGE_VERSION@
+ URL: https://github.com/Singular/Sources/
+ 
+-Requires: @PKG_REQUIRE@ libpolys
++Requires: @PKG_REQUIRE@ singular-libpolys
+ Conflicts:
+ 
+ Cflags: -I${multiarchincludedir}/singular -I${multiarchincludedir}/singular/singular -I${includedir}/singular -I${includedir}/singular/singular @SINGULAR_CFLAGS@
+--- a/libpolys/libpolys.pc.in
++++ b/libpolys/libpolys.pc.in
+@@ -4,12 +4,12 @@
+ includedir=@includedir@
+ multiarchincludedir=@includedir@/@DEB_HOST_MULTIARCH@
+ 
+-Name: @PACKAGE@
++Name: Singular @PACKAGE@
+ Description: The Singular polynomial/coefficient arithmetic and related supporting functionality
+ Version: @PACKAGE_VERSION@
+ URL: https://github.com/Singular/Sources/tree/spielwiese/@PACKAGE@
+ 
+-Requires: @PKG_REQUIRE@ factory
++Requires: @PKG_REQUIRE@ singular-factory
+ Conflicts:
+ 
+ Cflags: -I${multiarchincludedir}/singular -I${multiarchincludedir}/singular/singular -I${includedir}/singular -I${includedir}/singular/singular @SINGULAR_CFLAGS@ @FLINT_CFLAGS@ @NTL_CFLAGS@ @GMP_CFLAGS@
+--- a/resources/resources.pc.in
++++ b/resources/resources.pc.in
+@@ -4,7 +4,7 @@
+ includedir=@includedir@
+ multiarchincludedir=@includedir@/@DEB_HOST_MULTIARCH@
+ 
+-Name: @PACKAGE@
++Name: Singular @PACKAGE@
+ Description: The Singular resources manager
+ Version: @PACKAGE_VERSION@
+ URL: https://github.com/Singular/Sources/tree/spielwiese/@PACKAGE@
+--- a/factory/factory.pc.in
++++ b/factory/factory.pc.in
+@@ -4,7 +4,7 @@
+ includedir=@includedir@
+ multiarchincludedir=@includedir@/@DEB_HOST_MULTIARCH@
+ 
+-Name: @PACKAGE@
++Name: Singular @PACKAGE@
+ Description: The Singular factorization library
+ Version: @PACKAGE_VERSION@
+ URL: https://github.com/Singular/Sources/tree/spielwiese/@PACKAGE@
+--- a/omalloc/omalloc.pc.in
++++ b/omalloc/omalloc.pc.in
+@@ -4,7 +4,7 @@
+ includedir=@includedir@
+ multiarchincludedir=@includedir@/@DEB_HOST_MULTIARCH@
+ 
+-Name: @PACKAGE@
++Name: Singular @PACKAGE@
+ Description: The Singular memory manager
+ Version: @PACKAGE_VERSION@
+ URL: https://github.com/Singular/Sources/tree/spielwiese/@PACKAGE@
+--- a/libpolys/configure.ac
++++ b/libpolys/configure.ac
+@@ -151,7 +151,7 @@
+ AC_CONFIG_FILES([coeffs/Makefile])
+ AC_CONFIG_FILES([polys/Makefile])
+ AC_CONFIG_FILES([tests/Makefile])
+-AC_CONFIG_FILES([libpolys.pc])
++AC_CONFIG_FILES([singular-libpolys.pc:libpolys.pc.in])
+ AC_CONFIG_FILES([misc/auxiliary.h])
+ AC_CONFIG_FILES([libpolys-config], [chmod a+x libpolys-config])
+ AC_OUTPUT
+--- a/resources/configure.ac
++++ b/resources/configure.ac
+@@ -72,5 +72,5 @@
+ AX_NORMALIZE_PATH([config_datadir],['/'])
+ AC_DEFINE_UNQUOTED([DATA_DIR],"$config_datadir",[datadir])
+ 
+-AC_CONFIG_FILES([resources.pc Makefile])
++AC_CONFIG_FILES([singular-resources.pc:resources.pc.in Makefile])
+ AC_OUTPUT
+--- a/factory/configure.ac
++++ b/factory/configure.ac
+@@ -400,6 +400,6 @@
+ 
+ 
+ 
+-AC_CONFIG_FILES([Makefile include/factory/Makefile factory.pc]) #  ftest/GNUmakefile
++AC_CONFIG_FILES([Makefile include/factory/Makefile singular-factory.pc:factory.pc.in]) #  ftest/GNUmakefile
+ AC_OUTPUT
+ 
+--- a/omalloc/configure.ac
++++ b/omalloc/configure.ac
+@@ -621,6 +621,6 @@
+ dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
+ dnl wrap it up
+ dnl
+-AC_CONFIG_FILES([Makefile omalloc.pc])
++AC_CONFIG_FILES([Makefile singular-omalloc.pc:omalloc.pc.in])
+ AC_OUTPUT
+ 
+--- a/libpolys/Makefile.am
++++ b/libpolys/Makefile.am
+@@ -20,7 +20,7 @@
+ DISTCLEANFILES = $(nodist_configheader_HEADERS)
+ 
+ pkgconfigdir = $(libdir)/pkgconfig
+-pkgconfig_DATA = libpolys.pc
++pkgconfig_DATA = singular-libpolys.pc
+ 
+ %.1: %
+ 	$(HELP2MAN) \
+--- a/resources/Makefile.am
++++ b/resources/Makefile.am
+@@ -22,4 +22,4 @@
+ DISTCLEANFILES = $(nodist_libsingular_resources_include_HEADERS)
+ 
+ pkgconfigdir = $(libdir)/pkgconfig
+-pkgconfig_DATA = resources.pc
++pkgconfig_DATA = singular-resources.pc
+--- a/factory/Makefile.am
++++ b/factory/Makefile.am
+@@ -291,5 +291,5 @@
+ ##
+ 
+ pkgconfigdir = $(libdir)/pkgconfig
+-pkgconfig_DATA = factory.pc
++pkgconfig_DATA = singular-factory.pc
+ 
+--- a/omalloc/Makefile.am
++++ b/omalloc/Makefile.am
+@@ -78,5 +78,5 @@
+ omtTest_r_LDADD    = libsingular-omalloc.la
+ 
+ pkgconfigdir = $(libdir)/pkgconfig
+-pkgconfig_DATA = omalloc.pc
++pkgconfig_DATA = singular-omalloc.pc
+ 
diff --git a/debian/patches/debianization-resources.patch b/debian/patches/debianization-resources.patch
new file mode 100644
index 0000000..6f48097
--- /dev/null
+++ b/debian/patches/debianization-resources.patch
@@ -0,0 +1,52 @@
+Description: debianization - resources
+ Address Debian Policy requirements for Singular resources.
+Origin: debian
+Forwarded: not-needed
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-24
+
+--- a/factory/Makefile.am
++++ b/factory/Makefile.am
+@@ -183,7 +183,7 @@
+ ####################################################
+ # the precomputed GF(q)-tables
+ 
+-gftablesdir=$(datadir)/factory/gftables
++gftablesdir=$(datadir)/singular/factory/gftables
+ dist_gftables_DATA = gftables/10201 gftables/1024 gftables/10609 gftables/11449 \
+ gftables/11881 gftables/121 gftables/12167 gftables/125 gftables/12769 \
+ gftables/128 gftables/1331 gftables/1369 gftables/14641 \
+--- a/resources/feResource.cc
++++ b/resources/feResource.cc
+@@ -59,14 +59,14 @@
+    "%r/share/singular/LIB;"
+    "%b/../share/singular/LIB;"
+    // gftables:
+-   "%D/factory;"
+-   "%r/share/factory;"
+-   "%b/LIB;"
+-   "%b/../factory;"
++   "%D/singular/factory;"
++   "%r/share/singular/factory;"
++   ////"%b/LIB;"
++   "%b/../share/singular/factory;"
+    // path for dynamic modules, should match ProcDir:
+-   "%b/MOD;"
++   ////"%b/MOD;"
+    "%r/lib/singular/MOD;"
+-   "%r/libexec/singular/MOD;"
++   ////"%r/libexec/singular/MOD;"
+    LIB_DIR "/singular/MOD;"
+    LIBEXEC_DIR "/singular/MOD;"
+    "%b",
+@@ -77,8 +77,8 @@
+   {"ProcDir",   'P',    feResPath,  "SINGULAR_PROCS_DIR",
+      "%b/MOD;"
+      "%r/lib/singular/MOD;"
+-     "%r/libexec/singular/MOD;"
+-     LIB_DIR "/singular/MOD;"   /*debian: -> /usr/lib/singular/MOD */
++     ////"%r/libexec/singular/MOD;"
++     LIB_DIR "/singular/MOD;"
+      LIBEXEC_DIR "/singular/MOD" ,                  (char *)""},
+   {"RootDir",   'r',    feResDir,   "SINGULAR_ROOT_DIR",    "%b/..",                (char *)""},
+   {"DataDir",   'D',    feResDir,   "SINGULAR_DATA_DIR",    "%b/../share/",          (char *)""},
diff --git a/debian/patches/debianization.patch b/debian/patches/debianization.patch
new file mode 100644
index 0000000..9884371
--- /dev/null
+++ b/debian/patches/debianization.patch
@@ -0,0 +1,241 @@
+Description: debianization
+ Meant to maintain a minimal debian/rules, to fix warnings,
+ to address Debian specific stuff in general.
+Origin: debian
+Forwarded: not-needed
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-28
+
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -28,7 +28,7 @@
+ 	$(srcdir)/git-version-gen $(srcdir)/.tarball-git-version > $(distdir)/.tarball-git-version
+ 
+ 
+-configheaderdir = ${includedir}/singular
++configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/singular
+ nodist_configheader_HEADERS = singularconfig.h
+ DISTCLEANFILES = $(nodist_configheader_HEADERS)
+ 
+--- a/libpolys/Makefile.am
++++ b/libpolys/Makefile.am
+@@ -15,7 +15,7 @@
+ 
+ SUBDIRS=misc reporter coeffs polys tests
+ 
+-configheaderdir = ${includedir}/singular
++configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/singular
+ nodist_configheader_HEADERS = libpolysconfig.h
+ DISTCLEANFILES = $(nodist_configheader_HEADERS)
+ 
+--- a/factory/Makefile.am
++++ b/factory/Makefile.am
+@@ -169,9 +169,11 @@
+ 
+ noinst_HEADERS = $(factory_headers)
+ 
++configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/factory
+ libfactory_includedir = ${includedir}/factory
+ 
+-nodist_libfactory_include_HEADERS = cplusplus.h factory.h factoryconf.h
++nodist_configheader_HEADERS = factoryconf.h
++nodist_libfactory_include_HEADERS = cplusplus.h factory.h
+ 
+ 
+ ####################################################
+--- a/omalloc/Makefile.am
++++ b/omalloc/Makefile.am
+@@ -2,6 +2,7 @@
+ 
+ lib_LTLIBRARIES=libomalloc.la
+ 
++configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/omalloc
+ libomalloc_includedir=$(includedir)/omalloc
+ 
+ libomalloc_include_HEADERS = \
+@@ -38,7 +39,8 @@
+ endif
+ 
+ nodist_libomalloc_la_SOURCES = omTables.inc omTables.h mylimits.h
+-nodist_libomalloc_include_HEADERS = omConfig.h mylimits.h omTables.h
++nodist_configheader_HEADERS = omConfig.h
++nodist_libomalloc_include_HEADERS = mylimits.h omTables.h
+ 
+ libomalloc_la_CPPFLAGS  = ${AM_CPPFLAGS} -DOM_ALLOC_INTERNAL
+ 
+--- a/resources/Makefile.am
++++ b/resources/Makefile.am
+@@ -13,6 +13,7 @@
+ 
+ libresources_la_LDFLAGS   = -release ${PACKAGE_VERSION}
+ 
++configheaderdir = ${includedir}/$(DEB_HOST_MULTIARCH)/resources
+ libresources_includedir  =$(includedir)/resources
+ 
+ libresources_include_HEADERS = omFindExec.h feResource.h feFopen.h
+--- a/configure.ac
++++ b/configure.ac
+@@ -18,7 +18,7 @@
+ AM_MAINTAINER_MODE([enable])
+ AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) # -Wno-extra-portability -Werror silent-rules
+ 
+-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
++m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
+ 
+ dnl Check if build env is sane
+ AM_SANITY_CHECK
+@@ -115,6 +115,8 @@
+   *cygwin* ) AX_APPEND_LINK_FLAGS([-Wl,-Bdynamic]);;
+ esac
+ 
++AC_SUBST(DEB_HOST_MULTIARCH)
++
+ PKG_REQUIRE="$PKG_REQUIRE"
+ AC_SUBST(PKG_REQUIRE)
+ 
+--- a/libpolys/configure.ac
++++ b/libpolys/configure.ac
+@@ -8,7 +8,7 @@
+ AM_MAINTAINER_MODE([enable])
+ 
+ AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) # -Wno-extra-portability -Werror silent-rules
+-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
++m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
+ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+ 
+ dnl Check if build env is sane
+@@ -89,6 +89,8 @@
+ dnl esac
+ dnl AC_SUBST(INCLUDES)
+ 
++AC_SUBST(DEB_HOST_MULTIARCH)
++
+ SING_CHECK_OMALLOC()
+ 
+ ENABLE_RESOURCES="yes"
+--- a/resources/configure.ac
++++ b/resources/configure.ac
+@@ -7,7 +7,7 @@
+ 
+ AM_MAINTAINER_MODE([enable])
+ AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) # -Wno-extra-portability -Werror silent-rules
+-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
++m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
+ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+ 
+ dnl Check if build env is sane
+@@ -42,6 +42,8 @@
+ # ([shared])
+ # LT_INIT(dlopen disable-static) # doesn't work on PowerPC!
+ 
++AC_SUBST(DEB_HOST_MULTIARCH)
++
+ # SING_CHECK_PIPE
+ 
+ ##### SEE http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
+--- a/factory/configure.ac
++++ b/factory/configure.ac
+@@ -19,7 +19,7 @@
+ AC_CONFIG_HEADER([_config.h])
+ 
+ AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) # -Wno-extra-portability -Werror silent-rules
+-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
++m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
+ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+ 
+ AM_MAINTAINER_MODE([enable])
+@@ -95,6 +95,8 @@
+   ,
+   [with_Singular=yes])
+ 
++AC_SUBST(DEB_HOST_MULTIARCH)
++
+ PKG_REQUIRE="$PKG_REQUIRE"
+ AC_SUBST(PKG_REQUIRE)
+ 
+--- a/omalloc/configure.ac
++++ b/omalloc/configure.ac
+@@ -16,11 +16,13 @@
+ 
+ AM_MAINTAINER_MODE([enable])
+ AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) # -Wno-extra-portability -Werror silent-rules
+-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
++m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
+ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+ 
+ AM_SANITY_CHECK
+ 
++AC_SUBST(DEB_HOST_MULTIARCH)
++
+ # Add pre'prefixed config
+ AX_PREFIX_CONFIG_H([omConfig.h],[],[_config.h])
+ 
+--- a/gfanlib/configure.ac
++++ b/gfanlib/configure.ac
+@@ -9,7 +9,7 @@
+ AC_CONFIG_HEADER([_config.h])
+ 
+ AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) # -Wno-extra-portability -Werror silent-rules
+-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
++m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
+ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+ 
+ # Add pre'prefixed config
+--- a/Singular/Makefile.am
++++ b/Singular/Makefile.am
+@@ -4,6 +4,8 @@
+ 
+ AM_CPPFLAGS = -I${top_srcdir} -I${top_builddir} -I${top_srcdir}/kernel -I${top_builddir}/kernel -I${top_srcdir}/libpolys -I${top_builddir}/libpolys $(FACTORY_INCLUDES)  $(GMP_CFLAGS) $(NTL_CFLAGS) $(FLINT_CFLAGS) -DGIT_VERSION='"$(GIT_VERSION)"'
+ 
++AM_CPPFLAGS += -DDEB_PKG_VERSION=\"$(DEB_PKG_VERSION)\"
++
+ SUBDIRS = dyn_modules
+ 
+ ########################### Possible builtin modules... #########################
+@@ -176,7 +178,7 @@
+ 
+ Singular_LDADD = libSingular.la ${BUILTIN_FLAGS}
+ 
+-Singular_LDFLAGS = -static ${AM_LDFLAGS} ${BUILTIN_FLAGS}
++Singular_LDFLAGS = ${AM_LDFLAGS} ${BUILTIN_FLAGS}
+ 
+ Singulard_SOURCES = tesths.cc mmalloc.cc fegetopt.c fegetopt.h utils.cc  utils.h
+ 
+@@ -189,7 +191,7 @@
+ 
+ #### ESingular
+ ESingular_CPPFLAGS = ${AM_CPPFLAGS} -DESINGULAR -DPROTO
+-# ESingular_LDFLAGS = -static ${AM_LDFLAGS}
++# ESingular_LDFLAGS = ${AM_LDFLAGS}
+ ESingular_LDADD =  ${top_builddir}/libpolys/reporter/libreporter.la \
+ ${top_builddir}/libpolys/misc/libmisc.la ${top_builddir}/omalloc/libomalloc.la \
+ ${top_builddir}/resources/libresources.la
+@@ -199,7 +201,7 @@
+ 
+ #### same for TSingular
+ TSingular_CPPFLAGS = ${AM_CPPFLAGS} -DTSINGULAR -DPROTO
+-# TSingular_LDFLAGS = -static ${AM_LDFLAGS}
++# TSingular_LDFLAGS = ${AM_LDFLAGS}
+ TSingular_LDADD = ${top_builddir}/libpolys/reporter/libreporter.la \
+ ${top_builddir}/libpolys/misc/libmisc.la ${top_builddir}/omalloc/libomalloc.la \
+ ${top_builddir}/resources/libresources.la
+@@ -214,7 +216,7 @@
+ libparse_SOURCES = libparse.cc fegetopt.c fegetopt.h utils.cc  utils.h
+ 
+ libparse_LDADD = ${top_builddir}/omalloc/libomalloc.la
+-libparse_LDFLAGS = -static ${AM_LDFLAGS}
++libparse_LDFLAGS = ${AM_LDFLAGS}
+ 
+ %.1: %
+ 	$(HELP2MAN) \
+--- a/Singular/tesths.cc
++++ b/Singular/tesths.cc
+@@ -137,7 +137,7 @@
+ " A Computer Algebra System for Polynomial Computations       /   version %s\n"
+ "                                                           0<\n"
+ " by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \\   %s\n"
+-"FB Mathematik der Universitaet, D-67653 Kaiserslautern        \\\n"
++"FB Mathematik der Universitaet, D-67653 Kaiserslautern        \\  Debian " DEB_PKG_VERSION "\n"
+ , VERSION, VERSION_DATE);
+   if (feOptValue(FE_OPT_NO_SHELL)) Warn("running in restricted mode:"
+     " shell invocation and links are disallowed");
diff --git a/debian/patches/series b/debian/patches/series
index d1dca91..b20b5a9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,18 +1,16 @@
-0001-tag-gfan-using-examples.patch
-0002-use-DESTDIR-as-a-pre-prefix-in-install-targets.patch
-0003-add-working-all-target-to-Makefile.in.patch
-0004-miscellaneous-Makefile.in-patches.patch
-0005-assert-needs-to-be-defined-after-include-assert.h.patch
-0006-keep-mod2.h-in-Singular.patch
-0007-move-libreadline-to-main-binary.patch
-0008-default-path-settings.patch
-0009-disable-examples-for-divisors-and-gitfan.patch
-0010-fix-warning-treated-as-error-in-pyobject.cc.patch
-0011-also-install-sing_dbm.h.patch
-0012-don-t-forget-LDFLAGS-in-module-compilation.patch
-0013-fix-mmInit-weirdness.patch
-0014-sanitize-cf_gmp.h-generation.patch
-0015-use-bin-sed-not-sed-in-build-system.patch
-0016-Use-full-path-for-a-few-coreutils.patch
-0017-make-interactive-docbuild-work.patch
-0018-NTL6-compatibility-patch-from-sagemath.patch
+upstream-contrib-update-normaliz.patch
+upstream-source-typo.patch
+upstream-fix-autotools-CPPFLAGS_overwrite.patch
+upstream-autotools-pkgconfig-refine.patch
+upstream-autotools-doxygen.patch
+upstream-CC2help2man.patch
+upstream-dump4help2man.patch
+upstream-autotools-help2man.patch
+upstream-autotools-help2man-extra.patch
+debianization.patch
+debianization-resources.patch
+debianization-rename-libraries.patch
+debianization-gather-headers.patch
+debianization-rename-pkgconfig_files.patch
+debianization-documentation.patch
+debianization-4ti2.patch
diff --git a/debian/patches/upstream-CC2help2man.patch b/debian/patches/upstream-CC2help2man.patch
new file mode 100644
index 0000000..9bff51c
--- /dev/null
+++ b/debian/patches/upstream-CC2help2man.patch
@@ -0,0 +1,90 @@
+Description: format usages and helps
+ Attempt to format and harmonize the help message of Singular front-end
+ programs wrt UN*X customs in view to employ help2man to generate manpages;
+ meant to be submitted to the upstream maintainer.
+Origin: debian
+Forwarded: yes (in progress)
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-23
+
+--- a/Singular/feOpt.cc
++++ b/Singular/feOpt.cc
+@@ -237,11 +237,11 @@
+ 
+       case FE_OPT_VERSION:
+         {
+-	char *s=versionString();
++        char *s=versionString();
+         printf("%s",s);
+-	omFree(s);
++        omFree(s);
+         return NULL;
+-	}
++        }
+ 
+       case FE_OPT_ECHO:
+         si_echo = (int) ((long)(feOptSpec[FE_OPT_ECHO].value));
+@@ -347,11 +347,13 @@
+ {
+   int i = 0;
+   char tmp[20];
+-#ifdef ESINGULAR
+-  printf("ESingular: A Program that starts-up Singular within emacs, for\n");
++#if defined(ESINGULAR)
++  printf("ESingular starts up Singular within emacs;\n");
++#elif defined(TSINGULAR)
++  printf("TSingular starts up Singular within a terminal window;\n");
+ #endif
+-  printf("Singular version %s -- a CAS for polynomial computations. Usage:\n", VERSION);
+-  printf("   %s [options] [file1 [file2 ...]]\n", name);
++  printf("Singular is a Computer Algebra System (CAS) for Polynomial Computations.\n");
++  printf("Usage: %s [options] [file1 [file2 ...]]\n", name);
+   printf("Options:\n");
+ 
+   while (feOptSpec[i].name != 0)
+@@ -369,17 +371,17 @@
+         else
+           sprintf(tmp, "%s=%s", feOptSpec[i].name, feOptSpec[i].arg_name);
+ 
+-        printf(" %c%c --%-19s %s\n",
+-               (feOptSpec[i].val != 0 ? '-' : ' '),
+-               (feOptSpec[i].val != 0 ? feOptSpec[i].val : ' '),
++        printf(" %c%c --%-20s %s\n",
++               (feOptSpec[i].val != LONG_OPTION_RETURN ? '-' : ' '),
++               (feOptSpec[i].val != LONG_OPTION_RETURN ? feOptSpec[i].val : ' '),
+                tmp,
+                feOptSpec[i].help);
+       }
+       else
+       {
+-        printf(" %c%c --%-19s %s\n",
+-               (feOptSpec[i].val != 0 ? '-' : ' '),
+-               (feOptSpec[i].val != 0 ? feOptSpec[i].val : ' '),
++        printf(" %c%c --%-20s %s\n",
++               (feOptSpec[i].val != LONG_OPTION_RETURN ? '-' : ' '),
++               (feOptSpec[i].val != LONG_OPTION_RETURN ? feOptSpec[i].val : ' '),
+                feOptSpec[i].name,
+                feOptSpec[i].help);
+       }
+--- a/Singular/emacs.cc
++++ b/Singular/emacs.cc
+@@ -134,14 +134,14 @@
+ 
+           feOptHelp(feArgv0);
+           exit(0);
+-
+-        case '?':
+-        case ':':
+-        case '\0':
++          break;
++      case '?':
++      case ':':
++      case '\0':
+           mainUsage();
+           exit(1);
+ 
+-        case  LONG_OPTION_RETURN:
++      case  LONG_OPTION_RETURN:
+         {
+           switch(option_index)
+           {
diff --git a/debian/patches/upstream-autotools-doxygen.patch b/debian/patches/upstream-autotools-doxygen.patch
new file mode 100644
index 0000000..1f0b19c
--- /dev/null
+++ b/debian/patches/upstream-autotools-doxygen.patch
@@ -0,0 +1,18 @@
+Description: autotools: dox[ygen]
+ Mainly hardden the generated dox/Makefile clean target;
+ meant to be submitted to the upstream maintainer.
+Origin: debian
+Forwarded: yes (in progress)
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-21
+
+--- a/dox/Makefile.am
++++ b/dox/Makefile.am
+@@ -35,6 +35,7 @@
+ ## html: doxyfile.stamp
+ 
+ clean-local:
++	rm -f html_dox.log tags
+ 	rm -rf html
+ endif
+ 
diff --git a/debian/patches/upstream-autotools-help2man-extra.patch b/debian/patches/upstream-autotools-help2man-extra.patch
new file mode 100644
index 0000000..ab2c861
--- /dev/null
+++ b/debian/patches/upstream-autotools-help2man-extra.patch
@@ -0,0 +1,28 @@
+Description: autotools: help2man - extra
+ Implement extra material added during the generation of the manpages for
+ the front-end programs; meant to be submitted to the upstream maintainer.
+Origin: debian
+Forwarded: yes (in progress)
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-23
+
+--- /dev/null
++++ b/Singular/man/Singular.h2m
+@@ -0,0 +1,3 @@
++[SEE ALSO]
++.BR TSingular (1),
++.BR ESingular (1).
+--- /dev/null
++++ b/Singular/man/ESingular.h2m
+@@ -0,0 +1,4 @@
++[SEE ALSO]
++.BR emacs (1),
++.BR Singular (1),
++.BR TSingular (1).
+--- /dev/null
++++ b/Singular/man/TSingular.h2m
+@@ -0,0 +1,4 @@
++[SEE ALSO]
++.BR xterm (1),
++.BR Singular (1),
++.BR ESingular (1).
diff --git a/debian/patches/upstream-autotools-help2man.patch b/debian/patches/upstream-autotools-help2man.patch
new file mode 100644
index 0000000..bb193fd
--- /dev/null
+++ b/debian/patches/upstream-autotools-help2man.patch
@@ -0,0 +1,159 @@
+Description: autotools: help2man
+ Implement the generation of the manpages for the front-end
+ programs and development tools with help2man(1);
+ meant to be submitted to the upstream maintainer.
+Origin: debian
+Forwarded: yes (in progress)
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-23
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -43,6 +43,7 @@
+ 
+ AC_CHECK_FUNCS(readlink getcwd getwd setenv putenv qsort_r)
+ 
++AC_PATH_PROG([HELP2MAN],[help2man])
+ AC_CHECK_PROGS([DOXYGEN], [doxygen])
+ if test -z "$DOXYGEN";
+    then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
+@@ -258,7 +259,8 @@
+ 
+ AC_CONFIG_FILES([IntegerProgramming/Makefile])
+ 
+-AC_CONFIG_FILES([libsingular-config Singular.pc])
++AC_CONFIG_FILES([Singular.pc])
++AC_CONFIG_FILES([libsingular-config], [chmod a+x libsingular-config])
+ 
+ AC_CONFIG_FILES([emacs/Makefile])
+ 
+--- a/Singular/Makefile.am
++++ b/Singular/Makefile.am
+@@ -155,6 +155,20 @@
+ 
+ bin_PROGRAMS = Singular ESingular TSingular $(optional_Singular_programs)
+ 
++man_MANS = Singular.1 ESingular.1 TSingular.1
++
++AM_H2MFLAGS = \
++	--manual="CAS Singular" \
++	--version-option="--dump-versiontuple" \
++	--source="Singular" \
++	--libtool \
++	--no-info
++
++## short descriptions for manpages
++Singular_DESCRIPTION =  "Computer Algebra System for Polynomial Computations -- command-line interface"
++ESingular_DESCRIPTION = "Computer Algebra System for Polynomial Computations -- command-line interface within emacs"
++TSingular_DESCRIPTION = "Computer Algebra System for Polynomial Computations -- command-line interface within a new terminal"
++
+ # the following dependency leads to Singular relinking upon a library update!
+ Singular ESingular TSingular $(optional_Singular_programs): ${abs_builddir}/LIB
+ 
+@@ -202,6 +216,15 @@
+ libparse_LDADD = ${top_builddir}/omalloc/libomalloc.la
+ libparse_LDFLAGS = -static ${AM_LDFLAGS}
+ 
++%.1: %
++	$(HELP2MAN) \
++			-s 1 \
++			$(AM_H2MFLAGS) \
++			-I $(top_srcdir)/Singular/man/$*.h2m \
++			-n $(if $($(subst -,_,$*)_DESCRIPTION), $($(subst -,_,$*)_DESCRIPTION), "manual page for $*") \
++			-o $@ \
++		$(abs_top_builddir)/Singular/$<
++
+ #########################################################
+ # the Singular library (*.lib files)
+ 
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -13,6 +13,17 @@
+ 
+ bin_SCRIPTS = libsingular-config
+ 
++man_MANS = libsingular-config.1
++
++AM_H2MFLAGS = \
++	--manual="CAS Singular" \
++	--source="Singular" \
++	--libtool \
++	--no-info
++
++## short descriptions for manpages
++libsingular_config_DESCRIPTION = "get information about installed Singular library"
++
+ dist-hook:
+ 	$(srcdir)/git-version-gen $(srcdir)/.tarball-git-version > $(distdir)/.tarball-git-version
+ 
+@@ -21,7 +32,14 @@
+ nodist_configheader_HEADERS = singularconfig.h
+ DISTCLEANFILES = $(nodist_configheader_HEADERS)
+ 
+-dist_man1_MANS = doc/Singular.man doc/ESingular.man doc/TSingular.man
+-
+ pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = Singular.pc
++
++%.1: %
++	$(HELP2MAN) \
++			-s 1 \
++			$(AM_H2MFLAGS) \
++			-I $(top_srcdir)/man/$*.h2m \
++			-n $(if $($(subst -,_,$*)_DESCRIPTION), $($(subst -,_,$*)_DESCRIPTION), "manual page for $*") \
++			-o $@ \
++		$(abs_top_builddir)/$<
+--- a/libpolys/configure.ac
++++ b/libpolys/configure.ac
+@@ -33,6 +33,9 @@
+ # ([shared])
+ # LT_INIT(dlopen disable-static) # doesn't work on PowerPC!
+ 
++# Checks for programs.
++AC_PATH_PROG([HELP2MAN],[help2man])
++
+ # Checks for libraries.
+ LB_CHECK_GMP(3.1.1,,AC_MSG_ERROR([Unable to find GMP on your machine: please use --with-gmp=PATH_TO_DIR_CONTAINING_LIB_AND_INCLUDE (see also ./configure --help if you do not understand what we are talking about)]))
+ LB_CHECK_NTL(5.0,,AC_MSG_WARN([Unable to find NTL (which is strongly recommended) on your machine: please use --with-ntl=PATH_TO_DIR_CONTAINING_LIB_AND_INCLUDE (see also ./configure --help if you do not understand what we are talking about)]))
+@@ -146,5 +149,7 @@
+ AC_CONFIG_FILES([coeffs/Makefile])
+ AC_CONFIG_FILES([polys/Makefile])
+ AC_CONFIG_FILES([tests/Makefile])
+-AC_CONFIG_FILES([libpolys-config libpolys.pc  misc/auxiliary.h])
++AC_CONFIG_FILES([libpolys.pc])
++AC_CONFIG_FILES([misc/auxiliary.h])
++AC_CONFIG_FILES([libpolys-config], [chmod a+x libpolys-config])
+ AC_OUTPUT
+--- a/libpolys/Makefile.am
++++ b/libpolys/Makefile.am
+@@ -2,6 +2,17 @@
+ 
+ bin_SCRIPTS = libpolys-config
+ 
++man_MANS = libpolys-config.1
++
++AM_H2MFLAGS = \
++	--manual="CAS Singular" \
++	--source="Singular" \
++	--libtool \
++	--no-info
++
++## short descriptions for manpages
++libpolys_config_DESCRIPTION = "get information about installed Singular polynomial library"
++
+ SUBDIRS=misc reporter coeffs polys tests
+ 
+ configheaderdir = ${includedir}/singular
+@@ -10,3 +21,12 @@
+ 
+ pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = libpolys.pc
++
++%.1: %
++	$(HELP2MAN) \
++			-s 1 \
++			$(AM_H2MFLAGS) \
++			-I $(top_srcdir)/man/$*.h2m \
++			-n $(if $($(subst -,_,$*)_DESCRIPTION), $($(subst -,_,$*)_DESCRIPTION), "manual page for $*") \
++			-o $@ \
++		$(abs_top_builddir)/$<
diff --git a/debian/patches/upstream-autotools-pkgconfig-refine.patch b/debian/patches/upstream-autotools-pkgconfig-refine.patch
new file mode 100644
index 0000000..5038cb1
--- /dev/null
+++ b/debian/patches/upstream-autotools-pkgconfig-refine.patch
@@ -0,0 +1,23 @@
+Description: autotools: pkgconfig: refine
+ Attempt to refine the generated pkgconfig configuration file;
+ meant to be submitted to the upstream maintainer.
+Origin: debian
+Forwarded: yes (in progress)
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-28
+
+--- a/libpolys/libpolys.pc.in
++++ b/libpolys/libpolys.pc.in
+@@ -8,10 +8,10 @@
+ Version: @PACKAGE_VERSION@
+ URL: https://github.com/Singular/Sources/tree/spielwiese/@PACKAGE@
+ 
+-Requires: @PKG_REQUIRE@
++Requires: @PKG_REQUIRE@ factory
+ Conflicts:
+ 
+ Cflags: -I${includedir} -I${includedir}/singular @SINGULAR_CFLAGS@ @FLINT_CFLAGS@ @NTL_CFLAGS@ @GMP_CFLAGS@
+-Libs: -L${libdir} -lpolys -lfactory @FLINT_LIBS@ @NTL_LIBS@ @GMP_LIBS@ @USEPPROCSDYNAMICLD@
++Libs: -L${libdir} -lpolys @FLINT_LIBS@ @NTL_LIBS@ @GMP_LIBS@ @USEPPROCSDYNAMICLD@
+ Libs.private:
+ 
diff --git a/debian/patches/upstream-contrib-update-normaliz.patch b/debian/patches/upstream-contrib-update-normaliz.patch
new file mode 100644
index 0000000..cc0e90b
--- /dev/null
+++ b/debian/patches/upstream-contrib-update-normaliz.patch
@@ -0,0 +1,3443 @@
+Description: contribution update: normaliz
+ Update the Singular lib[rary] as provided by the latest normaliz release,
+ http://www.home.uni-osnabrueck.de/wbruns/normaliz/;
+ the Singular library was extracted by hand.
+ This patch is meant to be submitted to the upstream maintainer.
+Origin: debian
+Forwarded: not-needed
+Applied-Upstream:
+ pulled to Singular github by the `normaliz' upstream maintainer (after contact).
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2015-01-07
+
+--- a/Singular/LIB/normaliz.lib
++++ b/Singular/LIB/normaliz.lib
+@@ -1,1684 +1,1744 @@
+-//// Singular library normaliz.lib
+-
+-version="version normaliz.lib 4.0.0.0 Jun_2013 "; // $Id: 834af90f9535c61eaa27f93a6aaa915ac1b155b2 $
+-category="Commutative Algebra";
+-info="
+-LIBRARY: normaliz.lib  Provides an interface for the use of Normaliz 2.7
+-         within SINGULAR.
+-AUTHORS:  Winfried Bruns, Winfried.Bruns at Uni-Osnabrueck.de
+-          Christof Soeger, Christof.Soeger at Uni-Osnabrueck.de
+-
+-OVERVIEW:
+-The library normaliz.lib provides an interface for the use of Normaliz 2.7
+-within SINGULAR. The exchange of data is via files.
+-In addition to the top level
+-functions that aim at objects of type ideal or ring, several other auxiliary
+-functions allow the user to apply Normaliz to data of type intmat. Therefore
+-SINGULAR can be used as a comfortable environment for the work with Normaliz.
+-@* Please see the @code{Normaliz2.7Documentation.pdf} (included in the Normaliz
+-distribution) for a more extensive documentation of Normaliz.
+- at code{nmz_sing.pdf} describes this library version 2.2, but most points are
+-still valid.
+-
+-@*Singular and Normaliz exchange data via files. These files are automatically
+-created and erased behind the scenes. As long as one wants to use only the
+-ring-theoretic functions there is no need for file management.
+-
+-@*Note that the numerical invariants computed by Normaliz can be
+-accessed in this \"automatic file mode\".
+-
+-@*However, if Singular is used as a frontend for Normaliz or the user
+-wants to inspect data not automatically returned to Singular, then
+-an explicit filename and a path can be specified for the exchange of
+-data. Moreover, the library provides functions for access to these files.
+-Deletion of the files is left to the user.
+-
+-@* Use of this library requires the program Normaliz to be installed.
+-You can download it from
+- at uref{http://www.mathematik.uni-osnabrueck.de/normaliz/}. Please make sure
+-that the executables are in the search path or use setNmzExecPath
+-(@ref{setNmzExecPath}).
+-
+-KEYWORDS: integral closure; normalization
+-
+-PROCEDURES:
+- intclToricRing(ideal I)      computes the integral closure of the toric ring
+-                              generated by the leading monomials of the
+-                              elements of I in the basering
+- normalToricRing(ideal I)     computes the normalization of the toric ring
+-                              generated by the leading monomials of the
+-                              elements of I
+- normalToricRingFromBinomials(ideal I)  computes the normalization of the
+-                              polynomial ring modulo the unique minimal prime
+-                              ideal of the binomial ideal I
+- ehrhartRing(ideal I)         computes the monomials representing the lattice
+-                              points of the polytop generated leading monomials
+-                              of the elements of I
+- intclMonIdeal(ideal I)       the exponent vectors of the leading monomials of
+-                              the elements of I are considered as generators of
+-                              a monomial ideal whose Rees algebra is computed
+-
+- torusInvariants(intmat T)    computes the ring of invariants of a torus action
+- finiteDiagInvariants(intmat C)  computes the ring of invariants of a finite
+-                                 abelian group acting diagonally on a polynomial
+-                                 ring
+- diagInvariants(intmat C)     computes the ring of invariants of a
+-                              diagonalizable group
+- intersectionValRings(intmat V)   computes the intersection of the polynomial
+-                                  ring with the valuation rings of monomial
+-                                  valuations
+- intersectionValRingIdeals(intmat V)       computes ideals of monomial valuations
+-
+- showNuminvs()                prints the numerical invariants
+- exportNuminvs()              exports the numerical invariants
+-
+- setNmzOption(string s, int onoff) sets the option s to onoff
+- showNmzOptions()             prints the enabled options to the standard output
+-
+- normaliz(intmat sgr,int nmz_mode) applies Normaliz
+- setNmzExecPath(string nmz_exec_path_name) sets the path to the Normaliz
+-                                           executable
+-
+- writeNmzData(intmat sgr, int n_mode) creates an input file for Normaliz
+- readNmzData(string nmz_suffix) reads the Normaliz output file with the
+-                                specified suffix
+-
+- setNmzFilename(string nmz_filename_name) sets the filename for the exchange
+-                                          of data
+- setNmzDataPath(string nmz_data_path_name) sets the directory for the exchange
+-                                           of data
+- writeNmzPaths()              writes the path names into two files
+- startNmz()                   retrieves the path names written by writeNmzPaths
+- rmNmzFiles()                 removes the files created for and by Normaliz
+-
+- mons2intmat(ideal I)         returns the intmat whose rows represent the
+-                              leading exponents of the elements of I
+- intmat2mons(intmat expo_vecs) returns the ideal generated by the monomials
+-                               which have the rows of expo_vecs as
+-                               exponent vector
+- binomials2intmat(ideal I)    returns the intmat whose rows represent the
+-                              exponents of the elements of the binomial ideal I
+-";
+-
+-
+-// helpers
+-
+-static proc desInt(string intname, int value)
+-// define, export and set an integer
+-{
+-    int exists;
+-    if(defined(`intname`)){exists=1;}
+-    if(!exists)
+-    {
+-        int `intname`=value;export(`intname`);
+-    }
+-    `intname`=value;
+-}
+-
+-static proc desString(string stringname, string value)
+-// define, export and set a string
+-{
+-    int exists;
+-    if(defined(`stringname`)){exists=1;}
+-    if(!exists)
+-    {
+-        string `stringname`=value;export(`stringname`);
+-    }
+-    `stringname`=value;
+-}
+-
+-static proc queryInt(string intname)
+-// if intname is defined, return(intname), else return(0)
+-{
+-    int exists,value;
+-    if(defined(`intname`)){exists=1;}
+-    if(!exists)
+-    {
+-        return(0);
+-    }
+-    return(`intname`);
+-}
+-
+-static proc queryString(string stringname)
+-// if stringname is defined, return(stringname), else return("")
+-{
+-    int exists;
+-    string value;
+-    if(defined(`stringname`)){exists=1;}
+-    if(!exists)
+-    {
+-        return("");
+-    }
+-    return(`stringname`);
+-}
+-
+-static proc fileExists(string f)
+-{
+-    return(status (f,"exists")=="yes");
+-}
+-
+-static proc appendSlash(string s)
+-// if nonempty and / is not the terminating char
+-{
+-    if(size(s)>0)
+-    {
+-        if(s[size(s)]!="/")
+-        {
+-            s=s+"/";
+-            return(s);
+-        }
+-    }
+-    return(s);
+-}
+-
+-// filenames and paths
+-
+-proc setNmzExecPath(string nmz_exec_path_name)
+-"USAGE:   setNmzExecPath(string s);   @code{s} path to the Normaliz executable
+-CREATE:   @code{Normaliz::nmz_exec_path} to save the given path @code{s}
+-NOTE:     It is not necessary to use this function if the Normaliz executable
+-          is in the search path of the system.
+-SEE ALSO: setNmzOption
+-EXAMPLE:  example setNmzExecPath; shows an example"
+-{
+-    desString("nmz_exec_path",nmz_exec_path_name);
+-    nmz_exec_path=appendSlash(nmz_exec_path);
+-}
+-example
+-{ "EXAMPLE:";echo = 2;
+-  setNmzExecPath("../Normaliz/");
+-}
+-
+-proc setNmzFilename(string nmz_filename_name)
+-"USAGE:   setNmzFilename(string s);
+-CREATE:   @code{Normaliz::nmz_filename} to save the given filename @code{s}
+-NOTE:     The function sets the filename for the exchange of data. Unless a
+-          path is set by setNmzDataPath, files will be created in the current
+-          directory.
+-          @* If a non-empty filename is set, the files created for and by
+-             Normaliz are kept. This is mandatory for the data access functions
+-             (see @ref{writeNmzData} and @ref{readNmzData}).
+-          @* Resetting the filename by setNmzFilename(\"\") forces the library
+-             to return to deletion of temporary files, but the files created
+-             while the filename had been set will not be erased.
+-SEE ALSO: writeNmzData, readNmzData, setNmzDataPath, rmNmzFiles
+-EXAMPLE:  example setNmzFilename; shows an example"
+-{
+-    desString("nmz_filename",nmz_filename_name);
+-    if(nmz_filename_name!="")
+-    {
+-        desInt("nmz_files_keep_switch",1);
+-    }
+-    else
+-    {
+-        desInt("nmz_files_keep_switch",0);
+-    }
+-}
+-example
+-{ "EXAMPLE:";echo = 2;
+-  setNmzDataPath("examples/");
+-  setNmzFilename("example1");
+-  //now the files for the exchange with Normaliz are examples/example1.SUFFIX
+-}
+-
+-proc setNmzDataPath(string nmz_data_path_name)
+-"USAGE:   setNmzDataPath(string s);
+-CREATE:   @code{Normaliz::nmz_data_path} to save the given path @code{s}
+-NOTE:     The function sets the path for the exchange of data. By default the
+-          files will be created in the current directory.
+-          @* It seems that Singular cannot use filenames starting with @code{~}
+-             or @code{$HOME} in its input/output functions.
+-          @* You must also avoid path names starting with @code{/} if you work
+-             under Cygwin, since Singular and Normaliz interpret them in
+-             different ways.
+-SEE ALSO: writeNmzData, readNmzData, rmNmzFiles, setNmzFilename
+-EXAMPLE:  example setNmzDataPath; shows an example"
+-{
+-    desString("nmz_data_path",nmz_data_path_name);
+-    nmz_data_path=appendSlash(nmz_data_path);
+-}example
+-{ "EXAMPLE:";echo = 2;
+-  setNmzDataPath("examples/");
+-  setNmzFilename("example1");
+-  //now the files for the exchange with Normalize are examples/example1.SUFFIX
+-}
+-
+-proc writeNmzPaths();
+-"USAGE:   writeNmzPaths();
+-CREATE:   the file nmz_sing_exec.path where the path to the Normaliz executable
+-          is saved
+-          @* the file nmz_sing_data.path where the directory for the exchange
+-          of data is saved
+-NOTE:     Both files are saved in the current directory. If one of the names
+-          has not been defined, the corresponding file is created, but
+-          contains nothing.
+-SEE ALSO: setNmzDataPath, setNmzExecPath, startNmz
+-EXAMPLE:  example writeNmzPaths; shows an example
+-"{
+-    link outf=":w nmz_sing_exec.path";
+-    write(outf, queryString("nmz_exec_path"));
+-    close(outf);
+-
+-    outf=":w nmz_sing_data.path";
+-    write(outf, queryString("nmz_data_path"));
+-    close(outf);
+-}
+-example
+-{ "EXAMPLE:";echo = 2;
+-  setNmzExecPath("../Normaliz/");
+-  writeNmzPaths();
+-  int dummy=system("sh","cat nmz_sing_exec.path");
+-  dummy=system("sh","cat nmz_sing_data.path");
+-}
+-
+-proc startNmz()
+-"USAGE:   startNmz();
+-PURPOSE:  This function reads the files written by @code{writeNmzPaths()},
+-          retrieves the path names, and types them on the standard output
+-          (as far as they have been set). Thus, once the path names have been
+-          stored, a Normaliz session can simply be opened by this function.
+-SEE ALSO: setNmzDataPath, setNmzExecPath, writeNmzPaths
+-EXAMPLE:  example startNmz; shows an example
+-"
+-{
+-    link inf=":r nmz_sing_exec.path";
+-    string s=read(inf);
+-    int i,p;
+-    p=findWord("/",s,1);
+-    if(p!=-1)
+-    {
+-        for(i=size(s);i>=1;i--)
+-        {
+-            if(s[i]=="/")
+-            {
+-                s=s[1..i];
+-                break;
+-            }
+-        }
+-        desString("nmz_exec_path",s);
+-        "nmz_exec_path is",nmz_exec_path;
+-    }
+-    else
+-    {
+-        "nmz_exec_path not set";
+-    }
+-
+-    inf=":r nmz_sing_data.path";
+-    s=read(inf);
+-    p=findWord("/",s,1);
+-    if(p!=-1)
+-    {
+-        for(i=size(s);i>=1;i--)
+-        {
+-            if(s[i]=="/")
+-            {
+-                s=s[1..i];
+-                break;
+-            }
+-        }
+-        desString("nmz_data_path",s);
+-        "nmz_data_path is",nmz_data_path;
+-    }
+-    else
+-    {
+-        "nmz_data_path not set";
+-    }
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  startNmz();
+-}
+-
+-static proc getNmzFile()
+-{
+-    if(queryInt("nmz_files_keep_switch"))
+-    {
+-        return(queryString("nmz_data_path")+queryString("nmz_filename"));
+-    }
+-    else
+-    {
+-        return(queryString("nmz_filename"));
+-    }
+-}
+-
+-static proc makeTempNmzDataPath()
+-{
+-    string testdir, testdir1;
+-    int i,dummy;
+-
+-    testdir1="/tmp/nmz_sing_"+string(system("pid"));
+-    testdir=testdir1;
+-    while(fileExists(testdir))
+-    {
+-        i++;
+-        testdir=testdir1+string(i);
+-    }
+-    dummy=system("sh","mkdir "+ testdir);
+-    desString("nmz_filename",testdir+"/nmz"); //files are nmz+suffix in testdir
+-}
+-
+-static proc eraseTempNmzDataPath();
+-{
+-    int dummy;
+-
+-    string tmpdir=getNmzFile();
+-    tmpdir=tmpdir[1..size(tmpdir)-4]; // remove "/nmz"
+-    dummy=system("sh","rm -r "+tmpdir);
+-    setNmzFilename("");
+-}
+-
+-static proc setNmzExec()
+-{
+-    return(queryString("nmz_exec_path")+"normaliz");
+-}
+-
+-proc rmNmzFiles()
+-"USAGE:  rmNmzFiles();
+-PURPOSE: This function removes the files created for and by Normaliz, using
+-         the last filename specified.
+-         It needs an explicit filename set (see @ref{setNmzFilename}).
+-SEE ALSO: writeNmzData, readNmzData, setNmzFilename, setNmzDataPath
+-EXAMPLE:  example rmNmzFiles; shows an example
+-"{
+-
+-    if(!queryInt("nmz_files_keep_switch"))
+-    {
+-        ERROR("rmNmzFiles: no filename specified");
+-    }
+-
+-    list suffixes="in","gen","out","cst","typ","egn","esp","inv","tri","ht1",
+-                  "ext";
+-    int i,dummy;
+-    string f;
+-
+-    for(i=1;i<=size(suffixes);i++)
+-    {
+-        f=getNmzFile()+"."+suffixes[i];
+-        if (fileExists(f)) { dummy=system("sh","rm "+f+ "&> /dev/null"); }
+-    }
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  setNmzFilename("VeryInteresting");
+-  rmNmzFiles();
+-}
+-
+-
+-
+-// parsing normaliz output
+-
+-static proc digit(string s)
+-{
+-    if(s==" ") // skip blanks quickly
+-    {
+-        return(0);
+-    }
+-
+-    if((s[1]>="0" && s[1]<="9")||s[1]=="-")
+-    {
+-        return(1);
+-    }
+-    return(0);
+-}
+-
+-static proc nextWord(string s, int p)
+-{
+-    int j,sw,ew;
+-
+-    for(;p<=size(s);p++) // must start with a letter
+-    {
+-
+-        if((s[p]>="a" && s[p]<="z")||
+-             (s[p]>="A" && s[p]<="Z"))
+-        {
+-            sw=p; break;
+-        }
+-    }
+-    if(p>size(s))
+-    {
+-        return(-1,-1); // no word found
+-    }
+-
+-    for(;p<=size(s);p++) // now numerals and -_ allowed
+-    {
+-        if(!((s[p]>="a" && s[p]<="z")||
+-             (s[p]>="A" && s[p]<="Z")||
+-             (s[p]>="0" && s[p]<="9")||
+-              s[p]=="_"||s[p]=="-"))
+-        {
+-            break;
+-        }
+-    }
+-    return(sw,p);
+-}
+-
+-static proc getInt(string s, int p)
+-{
+-    string nst;
+-    int i,j,en,sn;
+-
+-    for(;p<=size(s);p++)
+-    {
+-
+-        if(digit(s[p]))
+-        {
+-            sn=p; break;
+-        }
+-    }
+-    if(not(sn))
+-    {
+-        return(0,-1); // -1 indicates: no number found
+-    }
+-    p++;
+-    for(;p<=size(s);p++)
+-    {
+-        if(!digit(s[p]))
+-        {
+-            en=p-1; break;
+-        }
+-    }
+-    if(p>size(s))
+-    {
+-        en=size(s);
+-    }
+-    nst="i="+s[sn,en-sn+1];
+-    execute(nst);
+-    return(i,p);
+-}
+-
+-
+-static proc getRational(string s, int p)
+-{
+-    string nst;
+-    int i,j,en,sn;
+-
+-    for(;p<=size(s);p++)
+-    {
+-        if(digit(s[p]))
+-        {
+-            sn=p; break;
+-        }
+-    }
+-    if(not(sn))
+-    {
+-        return(0,-1); // -1 indicates: no number found
+-    }
+-    p++;
+-    int slash_at;
+-    for(;p<=size(s);p++)
+-    {
+-        if(s[p]=="/")
+-        {
+-            slash_at=p;
+-            p++;
+-            continue;
+-        }
+-        if(!digit(s[p]))
+-        {
+-            en=p-1; break;
+-        }
+-    }
+-    if(p>size(s))
+-    {
+-        en=size(s);
+-    }
+-    if(slash_at)
+-    {
+-        nst="i="+s[sn,slash_at-sn];
+-        execute(nst);
+-        nst="j="+s[slash_at+1,en-slash_at];
+-        execute(nst);
+-        return(i,p,j);
+-    }
+-    nst="i="+s[sn,en-sn+1];
+-    execute(nst);
+-    return(i,p);
+-}
+-
+-
+-static proc findWord(string s, string t, int p)
+-{
+-    for(;p<=size(t)-size(s)+1;p++)
+-    {
+-        if(t[p]==s[1])
+-        {
+-            if(t[p,size(s)]==s)
+-            {
+-                 return(p+size(s));
+-            }
+-        }
+-    }
+-    return(-1);
+-}
+-
+-
+-static proc skipEqualsign(string s,int p)
+-{
+-    for(;p<=size(s);p++)
+-    {
+-        if(s[p]=="=")
+-        {
+-            break;
+-        }
+-    }
+-    return(p+1);
+-}
+-
+-
+-// input and output to/from normaliz
+-
+-//list must have pairs of intmat, nmz_mode
+-static proc doWriteNmzData(list #)
+-{
+-    string s;
+-    int i,j;
+-    link outf=":w "+ getNmzFile() +".in";  // also sets the filename
+-
+-    intmat sgr;
+-    int num_rows, num_cols, n_mode;
+-
+-    for (int k=1; k+1<=size(#); k=k+2) {
+-    //get data from the parameter list
+-      sgr   = #[k];
+-      num_rows = nrows(sgr);
+-      num_cols = ncols(sgr);
+-                n_mode   = #[k+1];
+-
+-      write(outf,num_rows);
+-      write(outf,num_cols);
+-
+-      for(i=1;i<=nrows(sgr);i++)
+-      {
+-        s="";
+-        for(j=1;j<=num_cols;j++)
+-        {
+-           s=s+string(sgr[i,j])+" ";
+-        }
+-        write(outf,s);
+-      }
+-      write(outf,n_mode);
+-      write(outf,"");
+-    }
+-    close(outf);
+-}
+-
+-
+-proc writeNmzData(intmat sgr, int n_mode, list #)
+-"USAGE:   writeNmzData(intmat M, int mode);
+-          writeNmzData(intmat M, int mode, intmat M2, int mode2, ...);
+-CREATE:   Creates an input file for Normaliz from the matrix M. The second
+-          parameter sets the mode. How the matrix is interpreted depends on the
+-          mode. See the Normaliz documentation for more information.
+-
+-                         It is also possible to give more than one pair of matrix and mode. In
+-                         this case all matrices and modes are written. This can be used to
+-                         combine modes 4,5,6.
+-NOTE:     Needs an explicit filename set. The filename is created from the
+-          current filename.
+-   @*     Note that all functions in normaliz.lib write and read their data
+-          automatically to and from the hard disk so that writeNmzData will
+-          hardly ever be used explicitly.
+-SEE ALSO: readNmzData, rmNmzFiles, setNmzFilename, setNmzDataPath
+-EXAMPLE:  example writeNmzData; shows an example"
+-{
+-    if(queryString("nmz_filename")=="")
+-    {
+-        ERROR("writeNmzData: no filename specified");
+-    }
+-    doWriteNmzData(list(sgr, n_mode) + #);
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  setNmzFilename("VeryInteresting");
+-  intmat sgr[3][3]=1,2,3,4,5,6,7,8,10;
+-  writeNmzData(sgr,1);
+-  int dummy=system("sh","cat VeryInteresting.in");
+-
+-  intmat Hyperplanes[2][3] = 2,-1,0, // 2x-y >= 0
+-                             1, 1,0; //  x+y >= 0
+-  intmat Equation[1][3] = 0,1,-1;    // y = z
+-  intmat Congruence[1][4] = 1,0,0,3;  // x = 0 (3)
+-  writeNmzData(Hyperplanes,4,Equation,5,Congruence,6);
+-  dummy=system("sh","cat VeryInteresting.in");
+-}
+-
+-
+-proc readNmzData(string nmz_suffix)
+-"USAGE:  readNmzData(string suffix);
+-RETURN:  Reads an output file of Normaliz containing an integer matrix and
+-         returns it as an intmat. For example, this function is useful if one
+-         wants to inspect the support hyperplanes. The filename is created
+-         from the current  filename and the suffix given to the function.
+-NOTE:    Needs an explicit filename set by setNmzFilename.
+-   @*    Note that all functions in normaliz.lib write and read their data
+-         automatically so that readNmzData will usually not be used explicitly.
+-   @*    This function reads only the first matrix in a file!
+-SEE ALSO: writeNmzData, rmNmzFiles, setNmzFilename, setNmzDataPath
+-EXAMPLE:  example readNmzData; shows an example"
+-{
+-    if(queryString("nmz_filename")=="")
+-    {
+-        ERROR("readNmzData: no filename specified");
+-    }
+-
+-    string s;
+-    int n_rows,n_cols;            //number of rows/columns
+-    int p;                     //position
+-    int i,j;
+-    int returnvalue;
+-
+-    string filename = getNmzFile() + "."+ nmz_suffix;
+-    link in_f=":r "+ filename;
+-    s=read(in_f);
+-    close(in_f);
+-
+-    p=1;
+-    (n_rows,p)=getInt(s,p);
+-    (n_cols,p)=getInt(s,p);
+-    if (n_rows <= 0 || n_cols <= 0) {
+-             intmat empty;
+-             return(empty);
+-    }
+-         intmat nmz_gen[n_rows][n_cols];
+-    for(i=1;i<=n_rows;i++)
+-    {
+-        for(j=1;j<=n_cols;j++)
+-        {
+-            (nmz_gen[i,j],p) = getInt(s,p);
+-        }
+-    }
+-    return(nmz_gen);
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  setNmzFilename("VeryInteresting");
+-  intmat sgr[3][3]=1,2,3,4,5,6,7,8,10;
+-  intmat sgrnormal=normaliz(sgr,0);
+-  readNmzData("cst");
+-  readNmzData("typ");
+-}
+-
+-
+-// running normaliz (with options)
+-
+-// component 1 is name of option
+-// 2 is default value
+-// 3 is command line option to be passed to Normaliz
+-// 4 indictes whether file "gen" is generated
+-// value 2 of 4 indicates "no influence"
+-
+-static proc defNmzOptions()
+-{
+-    if(!defined(nmz_options)) // can be defined only once
+-    {
+-        list nmz_options=
+-        list("supp",0,"-s",0),
+-        list("triang",0,"-v",0),
+-        list("volume",0,"-V",0),
+-        list("hvect",0,"-p",0),
+-        list("hvect_l",0,"-P",0),
+-        list("height1",0,"-1",0),
+-        list("normal",0,"-n",1),
+-        list("normal_l",0,"-N",1),
+-        list("hilb",0,"-h",1),
+-        list("hilb_l",0,"-H",1),
+-        list("dual",0,"-d",1),
+-        list("control",0,"-c",2),
+-        list("allf",0,"-a",2),
+-        list("errorcheck",0,"-e",2),
+-        list("bigint",0,"-B",2),
+-        list("threads",0,"-x=",2);
+-        export(nmz_options);
+-    }
+-}
+-
+-proc setNmzOption(string s, int onoff)
+-"USAGE:   setNmzOption(string s, int onoff);
+-PURPOSE:  If @code{onoff=1} the option @code{s} is activated, and
+-          if @code{onoff=0} it is deactivated.
+-The Normaliz options are accessible via the following names:
+-@* @code{-s:  supp}
+-@* @code{-v:  triang}
+-@* @code{-V:  volume}
+-@* @code{-p:  hvect}
+-@* @code{-P:  hvect_l}
+-@* @code{-1:  height1}
+-@* @code{-n:  normal}
+-@* @code{-N:  normal_l}
+-@* @code{-h:  hilb}
+-@* @code{-H:  hilb_l}
+-@* @code{-d:  dual}
+-@* @code{-a:  allf}
+-@* @code{-c:  control}
+-@* @code{-e:  errorcheck}
+-@* @code{-B:  bigint} Use GMP for arbitrary precision integers
+-@* @code{-x=N:  threads} In this case the int parameter is used to set the
+-                         number of threads N, 0 means no explicit limiting.
+-
+-SEE ALSO: showNmzOptions
+-EXAMPLE:  example setNmzOption; shows an example
+-"
+-{
+-    defNmzOptions();
+-    for(int i=1;i<=size(nmz_options);i++)
+-    {
+-        if(s==nmz_options[i][1])
+-        {
+-            nmz_options[i][2]=onoff;
+-            return(1);
+-        }
+-    }
+-    "Invalid option ", s;
+-    return(0);
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  setNmzOption("hilb",1);
+-  showNmzOptions();
+-}
+-
+-static proc collectNmzOptions()
+-{
+-    defNmzOptions();
+-    string run_options=" -f ";
+-    desInt("GenGen",1); // indicates whether "gen" is generated
+-    for(int i=1;i<=size(nmz_options);i++)
+-    {
+-        if(nmz_options[i][2])
+-        {
+-            run_options=run_options+nmz_options[i][3];
+-                                if (nmz_options[i][1]=="threads") {
+-                                        run_options=run_options+string(nmz_options[i][2]);
+-                                }
+-                                run_options=run_options+" ";
+-            if(nmz_options[i][4]!=2)
+-            {
+-                GenGen=nmz_options[i][4];
+-            }
+-        }
+-    }
+-    return(run_options+" ");
+-}
+-
+-proc showNmzOptions()
+-"USAGE:   showNmzOptions();
+-RETURN:   Returns the string of activated options.
+-NOTE:     This string is used as parameter when calling Normaliz.
+-SEE ALSO: setNmzOption
+-EXAMPLE:  example showNmzOption; shows an example
+-"
+-{
+-    return(collectNmzOptions());
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  setNmzOption("hilb",1);
+-  showNmzOptions();
+-}
+-
+-
+-static proc runNormaliz(intmat sgr,def nmz_mode, list #)
+-{
+-    if(!queryInt("nmz_files_keep_switch"))
+-    {
+-        makeTempNmzDataPath();
+-    }
+-
+-    doWriteNmzData(list(sgr, nmz_mode) + #);
+-
+-    if(queryInt("nmz_files_keep_switch"))
+-    {
+-       int dummy=system("sh",setNmzExec()+ collectNmzOptions() + getNmzFile());
+-    }
+-    else
+-    {
+-        string gotodir="/tmp";
+-        string fname=getNmzFile();
+-        fname=fname[6..size(fname)];
+-        string exec="cd "+gotodir+" ; ";
+-        exec=exec+setNmzExec()+ collectNmzOptions()+" ";
+-        exec=exec+fname+" ;";
+-        int dummy=system("sh",exec);
+-    }
+-
+-    if(!GenGen) // return input matrix if "gen" has not been generated
+-    {
+-        if(!queryInt("nmz_files_keep_switch"))
+-        {
+-            eraseTempNmzDataPath();
+-        }
+-        return(sgr);
+-    }
+-    intmat Gen=readNmzData("gen");
+-
+-    if(!defined(Num_Invs))
+-    {
+-        list Num_Invs;
+-        export Num_Invs;
+-    }
+-    Num_Invs=getNuminvs();
+-
+-    if(!queryInt("nmz_files_keep_switch"))
+-    {
+-        eraseTempNmzDataPath();
+-    }
+-
+-    return(Gen);
+-
+-}
+-
+-proc normaliz(intmat sgr,int nmz_mode, list #)
+-"USAGE:   normaliz(intmat sgr,int nmz_mode);
+-          normaliz(intmat sgr, int nmz_mode, intmat sgr2, int nmz_mode2, ...);
+-RETURN:   The function applies Normaliz to the parameter sgr in the mode set
+-          by nmz_mode. The function returns the intmat defined by the file
+-          with suffix gen.
+-
+-          It is also possible to give more than one pair of matrix and mode. In
+-                         this case all matrices and modes are used. This can be used to
+-                         combine modes 4,5,6.
+-NOTE:     You will find procedures for many applications of Normaliz in this
+-          library, so the explicit call of this procedure may not be necessary.
+-SEE ALSO: intclToricRing, normalToricRing, ehrhartRing, intclMonIdeal,
+-          torusInvariants, diagInvariants, finiteDiagInvariants, intersectionValRings,
+-                         intersectionValRingIdeals
+-EXAMPLE:  example normaliz; shows an example
+-"
+-{
+-    return(runNormaliz(sgr,nmz_mode,#));
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R=0,(x,y,z),dp;
+-  intmat M[3][2]=3,1,
+-                 3,2,
+-                 1,3;
+-  normaliz(M,1);
+-
+-  intmat Hyperplanes[2][3] = 2,-1,0, // 2x-y >= 0
+-                             1, 1,0; //  x+y >= 0
+-  intmat Equation[1][3] = 0,1,-1;    // y = z
+-  intmat Congruence[1][4] = 1,0,0,3;  // x = 0 (3)
+-  normaliz(Hyperplanes,4,Equation,5,Congruence,6);
+-}
+-
+-
+-// retrieving normaliz numerical invariants
+-
+-static proc getNuminvs()
+-{
+-    string s;
+-    list num_invs;
+-    int p,sw,v_length,i,dummy_int;
+-    intvec dummy_vec;
+-    string type_inv,name_inv,dummy_bool;
+-
+-    link in_f=":r "+ getNmzFile() + "."+"inv";
+-    s=read(in_f);
+-
+-    p=1;
+-    while(p<size(s))
+-    {
+-        (sw,p)=nextWord(s,p);
+-        if(sw==-1)
+-        {
+-            break;
+-        }
+-        type_inv=s[sw..p-1];
+-        if(type_inv=="vector")
+-        {
+-            (v_length,p)=getInt(s,p);
+-            (sw,p)=nextWord(s,p);
+-            name_inv=s[sw..p-1];
+-            if(name_inv=="h-vector")
+-            {
+-                name_inv="h_vector";
+-            }
+-            if(name_inv!="hilbert_polynomial")
+-            {
+-                for(i=1;i<=v_length;i++)
+-                {
+-                    if(i==1)
+-                    {
+-                        (dummy_int,p)=getInt(s,p);
+-                        dummy_vec=dummy_int;
+-                    }
+-                    else
+-                    {
+-                        (dummy_int,p)=getInt(s,p);
+-                        dummy_vec=dummy_vec,dummy_int;
+-                    }
+-                }
+-                num_invs=num_invs+list(list(name_inv,dummy_vec,"intvec"));
+-            }
+-            else
+-            {
+-                p=skipEqualsign(s,p);
+-            }
+-        }
+-        if(type_inv=="integer")
+-        {
+-            (sw,p)=nextWord(s,p);
+-            name_inv=s[sw..p-1];
+-            (dummy_int,p)=getInt(s,p);
+-            num_invs=num_invs+list(list(name_inv,dummy_int,"int"));
+-        }
+-        if(type_inv=="boolean")
+-        {
+-            (sw,p)=nextWord(s,p);
+-            name_inv=s[sw..p-1];
+-            p=skipEqualsign(s,p);
+-            (sw,p)=nextWord(s,p);
+-            dummy_bool=s[sw..p-1];
+-            dummy_int=0;
+-            if(dummy_bool=="true")
+-            {
+-                dummy_int=1;
+-            }
+-            num_invs=num_invs+list(list(name_inv,dummy_int,"int"));
+-        }
+-    }
+-    return(num_invs);
+-}
+-
+-proc showNuminvs()
+-"USAGE:   showNuminvs();
+-PURPOSE:  prints the numerical invariants
+-SEE ALSO: exportNuminvs
+-EXAMPLE:  example showNuminvs(); shows an example
+-"
+-{
+-    list dummy;
+-    int i;
+-    for(i=1;i<=size(Num_Invs);i++)
+-    {
+-        dummy=Num_Invs[i];
+-        dummy[1],":", dummy[2];
+-    }
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R=0,(x,y,z,t),dp;
+-  ideal I=x^2,y^2,z^3;
+-  list l=intclMonIdeal(I);
+-  showNuminvs();
+-}
+-
+-
+-proc exportNuminvs()
+-"USAGE:   exportNuminvs();
+-CREATE:   Creates top-level variables which contain the numerical invariants.
+-          Depending on the options of normaliz different invariants are
+-          calculated. Use showNuminvs (@ref{showNuminvs}) to see which
+-          invariants are available.
+-SEE ALSO: showNuminvs
+-EXAMPLE:  example exportNuminvs; shows an example
+-"
+-{
+-    list dummy;
+-    int i;
+-    string s;
+-    for(i=1;i<=size(Num_Invs);i++)
+-    {
+-        dummy=Num_Invs[i];
+-        s=dummy[3]+" nmz_" + dummy[1] + "=dummy[2]; exportto(Top," + "nmz_" + dummy[1] + ");";
+-        execute(s);
+-    }
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R=0,(x,y,z,t),dp;
+-  ideal I=x^2,y^2,z^3;
+-  list l=intclMonIdeal(I);
+-  exportNuminvs();
+-  // now the following variables are set:
+-  nmz_hilbert_basis_elements;
+-  nmz_number_extreme_rays;
+-  nmz_rank;
+-  nmz_index;
+-  nmz_number_support_hyperplanes;
+-  nmz_homogeneous;
+-  nmz_primary;
+-  nmz_ideal_multiplicity;
+-}
+-
+-
+-// intmats to/from monomials
+-
+-proc mons2intmat(ideal I)
+-"USAGE:   mons2intmat(ideal I);
+-RETURN:   Returns the intmat whose rows represent the leading exponents of the
+-          (non-zero) elements of I. The length of each row is nvars(basering).
+-SEE ALSO: intmat2mons
+-EXAMPLE:  example mons2intmat; shows an example"
+-{
+-    int i,j,k;
+-    intmat expo_vecs[size(I)][nvars(basering)];
+-    intvec expo_v;
+-
+-    k=0;
+-    for(i=1;i<=ncols(I);i++)
+-    {
+-        if(I[i]!=0)
+-        {
+-            k++;
+-            expo_v=leadexp(I[i]);
+-            for(j=1;j<=nvars(basering);j++)
+-            {
+-                expo_vecs[k,j]=expo_v[j];
+-            }
+-        }
+-    }
+-    return(expo_vecs);
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R=0,(x,y,z),dp;
+-  ideal I=x2,y2,x2yz3;
+-  mons2intmat(I);
+-}
+-
+-proc intmat2mons(intmat expo_vecs)
+-"USAGE:   intmat2mons(intmat M);
+-RETURN:   an ideal generated by the monomials which correspond to the exponent
+-          vectors given by the rows of @code{M}
+-NOTE:     The number of variables in the basering @code{nvars(basering)} has to
+-          be at least the number of columns @code{ncols(M)}, otherwise the
+-          function exits with an error.
+-          is thrown (see @ref{ERROR}).
+-SEE ALSO: mons2intmat
+-EXAMPLE:  example intmat2mons; shows an example
+-"
+-{
+-    int i,j;
+-    poly m;
+-    ideal mons;
+-
+-    if(nvars(basering)<ncols(expo_vecs))
+-    {
+-        ERROR("intmat2mons: not enough variables in ring");
+-    }
+-
+-    for(i=1;i<=nrows(expo_vecs);i++)
+-    {
+-        m=1;
+-        for(j=1;j<=ncols(expo_vecs);j++)
+-        {
+-            m=m*var(j)^expo_vecs[i,j];
+-        }
+-        mons=mons,m;
+-    }
+-     mons=simplify(mons,2);    // get rid of starting 0
+-     return(mons);
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R=0,(x,y,z),dp;
+-  intmat expo_vecs[3][3] =
+-  2,0,0,
+-  0,2,0,
+-  2,1,3;
+-  intmat2mons(expo_vecs);
+-}
+-
+-static proc intmat2monsSel(intmat expo_vecs, int d)
+-{
+-    int i,j;
+-    poly m;
+-    ideal mons;
+-
+-    if(nvars(basering)<ncols(expo_vecs)-1)
+-    {
+-        ERROR("intmat2monsSel: not enough variables in ring");
+-    }
+-
+-    for(i=1;i<=nrows(expo_vecs);i++)
+-    {
+-        if(expo_vecs[i,ncols(expo_vecs)]==d)
+-        {
+-
+-            m=1;
+-            for(j=1;j<=ncols(expo_vecs)-1;j++)
+-            {
+-                m=m*var(j)^expo_vecs[i,j];
+-            }
+-            mons=mons,m;
+-        }
+-    }
+-     mons=simplify(mons,2);    // get rid of starting 0
+-     return(mons);
+-}
+-
+-
+-proc binomials2intmat(ideal I)
+-"USAGE:   binomials2intmat(ideal I);
+-RETURN:   Returns the intmat whose rows represent the exponents of the
+-          (non-zero) elements of I which have to be binomials.
+-                         The length of each row is nvars(basering).
+-SEE ALSO: mons2intmat, intmat2mons
+-EXAMPLE:  example binomials2intmat; shows an example"
+-{
+-  int i,j,k;
+-  intmat expo_vecs[size(I)][nvars(basering)];
+-  intvec expo_v;
+-
+-  k=0;
+-  poly f;
+-
+-  for(i=1; i<=ncols(I); i++)
+-  {
+-    if( I[i] != 0 )
+-    {
+-      k++;
+-      f = I[i];
+-      if (leadcoef(f) != 1) {f = -f};  //works in all characteristics
+-      if (size(f)!=2 || leadcoef(f)!=1 || leadcoef(f[2])!=-1)
+-      {
+-        ERROR(string("normalToricRing: binomial ideal expected: generator ",i,": ",I[i]));
+-      }
+-      expo_v = leadexp(f)-leadexp(f[2]);
+-      for(j=1;j<=nvars(basering);j++)
+-      {
+-        expo_vecs[k,j]=expo_v[j];
+-      }
+-    }
+-  }
+-  return(expo_vecs);
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring S = 37,(u,v,w,x,y,z),dp;
+-  ideal I = u2v-xyz, ux2-vyz, uvw-y2z;
+-  binomials2intmat(I);
+-}
+-
+-
+-// integral closure of rings and ideals
+-
+-static proc runIntclToricRing(ideal I, int nmz_mode)
+-{
+-    intmat expo_vecs=mons2intmat(I);
+-
+-    string dummy=collectNmzOptions(); // only to set GenGen
+-
+-    return( intmat2mons( runNormaliz(expo_vecs,nmz_mode) ) );
+-}
+-
+-proc intclToricRing(ideal I)
+-"USAGE:   intclToricRing(ideal I);
+-RETURN:   The toric ring S is the subalgebra of the basering generated by the
+-          leading monomials of the elements of I. The function computes the
+-          integral closure T of S in the basering and returns an ideal listing
+-          the algebra generators of T over the coefficient field.
+-@*        The function returns the input ideal I if one of the options
+-          @code{supp}, @code{triang}, or @code{hvect} has been activated.
+-          However, in this case some numerical invariants are computed, and
+-          some other data may be contained in files that you can read into
+-          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
+-NOTE:     A mathematical remark: the toric ring depends on the list of
+-          monomials given, and not only on the ideal they generate!
+-SEE ALSO:  normalToricRing, ehrhartRing, intclMonIdeal
+-EXAMPLE:   example intclToricRing; shows an example
+-"
+-{
+-    return(runIntclToricRing(I,0));
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R=37,(x,y,t),dp;
+-  ideal I=x3,x2y,y3;
+-  intclToricRing(I);
+-}
+-
+-proc normalToricRing(ideal I)
+-"USAGE:   normalToricRing(ideal I);
+-RETURN:   The toric ring S is the subalgebra of the basering generated by the
+-          leading monomials of the elements of I. The function computes the
+-          normalisation T of S and returns an ideal listing the algebra
+-          generators of T over the coefficient field.
+-@*        The function returns the input ideal I if one of the options
+-          @code{supp}, @code{triang}, or @code{hvect} has been activated.
+-          However, in this case some numerical invariants are computed, and
+-          some other data may be contained in files that you can read into
+-          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
+-NOTE:     A mathematical remark: the toric ring depends on the list of
+-          monomials given, and not only on the ideal they generate!
+-SEE ALSO: intclToricRing, ehrhartRing, intclMonIdeal, normalToricRingFromBinomials
+-EXAMPLE:  example normalToricRing; shows an example
+-"
+-{
+-    return(runIntclToricRing(I,1));
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring  R = 37,(x,y,t),dp;
+-  ideal I = x3,x2y,y3;
+-  normalToricRing(I);
+-}
+-
+-
+-proc normalToricRingFromBinomials(ideal I)
+-"USAGE:   normalToricRingFromBinomials(ideal I);
+-RETURN:
+- at tex
+-The ideal $I$ is generated by binomials of type $X^a-X^b$ (multiindex notation)
+-in the surrounding polynomial ring $K[X]=K[X_1,...,X_n]$. The binomials
+-represent a congruence on the monoid ${Z}^n$ with residue monoid $M$.
+-Let $N$ be the image of $M$ in gp($M$)/torsion. Then $N$ is universal in the
+-sense that every homomorphism from $M$ to an affine monoid factors through $N$.
+-If $I$ is a prime ideal, then $K[N]= K[X]/I$. In general, $K[N]=K[X]/P$ where
+-$P$ is the unique minimal prime ideal of $I$ generated by binomials of type
+-$X^a-X^b$.
+-
+-The function computes the normalization of $K[N]$ and returns a newly created
+-polynomial ring of the same Krull dimension, whose variables are
+-$x(1),...,x(n-r)$, where $r$ is the rank of the matrix with rows $a-b$.
+-(In general there is no canonical choice for such an embedding.)
+-Inside this polynomial ring there is an ideal $I$ which lists the algebra
+-generators of the normalization of $K[N]$.
+- at end tex
+-@*        The function returns the input ideal I if one of the options
+-          @code{supp}, @code{triang}, or @code{hvect} has been activated.
+-          However, in this case some numerical invariants are computed, and
+-          some other data may be contained in files that you can read into
+-          Singular.
+-SEE ALSO: intclToricRing, normalToricRing, ehrhartRing, intclMonIdeal
+-EXAMPLE:  example normalToricRing; shows an example
+-"
+-{
+-        intmat expo_vecs = binomials2intmat(I);
+-        string dummy=collectNmzOptions(); // only to set GenGen
+-        intmat result = runNormaliz(expo_vecs,10);
+-
+-        list baseringlist = ringlist(basering);
+-        ring S = (baseringlist[1]),(x(1..ncols(result))),dp;
+-        ideal I = intmat2mons(result);
+-        export(I);
+-        return (S);
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R = 37,(u,v,w,x,y,z),dp;
+-  ideal I = u2v-xyz, ux2-wyz, uvw-y2z;
+-  def S = normalToricRingFromBinomials(I);
+-  setring S;
+-  I;
+-}
+-
+-static proc runIntclMonIdeal(ideal I, int nmz_mode)
+-{
+-    intmat expo_vecs=mons2intmat(I);
+-    int i,last_comp;
+-
+-    // we test if there is room for the Rees algebra
+-
+-    for(i=1;i<=nrows(expo_vecs);i++)
+-    {
+-        if(expo_vecs[i,ncols(expo_vecs)]!=0)
+-        {
+-            last_comp=1;  break; // no
+-        }
+-    }
+-
+-    string dummy=collectNmzOptions(); // only to set GenGen
+-
+-    //adjust size of input matrix
+-         if (!last_comp) { // remove last component
+-             intmat tmp[nrows(expo_vecs)][ncols(expo_vecs)-1] = expo_vecs[1..nrows(expo_vecs),1..(ncols(expo_vecs)-1)];
+-                  expo_vecs = tmp;
+-         }
+-    intmat nmz_data=runNormaliz(expo_vecs,nmz_mode);
+-
+-    if(last_comp)
+-    {
+-        ideal I1=intmat2monsSel(nmz_data,1);
+-        return(list(I1));
+-    }
+-    else
+-    {
+-        ideal I1=intmat2monsSel(nmz_data,1);
+-        ideal I2=intmat2mons(nmz_data);
+-        return(list(I1,I2));
+-    }
+-}
+-
+-proc ehrhartRing(ideal I)
+-"USAGE:    ehrhartRing(ideal I);
+-RETURN:    The exponent vectors of the leading monomials of the elements of I
+-           are considered as vertices of a lattice polytope P.
+-           The Ehrhart ring of a (lattice) polytope P is the monoid algebra
+-           defined by the monoid of lattice points in the cone over the
+-           polytope P; see Bruns and Gubeladze, Polytopes, Rings, and K-theory,
+-           Springer 2009, pp. 228, 229.
+-           The function returns a list of ideals:
+-@*         (i) If the last ring variable is not used by the monomials, it is
+-               treated as the auxiliary variable of the Ehrhart ring. The
+-               function returns two ideals, the first containing the monomials
+-               representing the lattice points of the polytope, the second
+-               containing the algebra generators of the Ehrhart ring over the
+-                    coefficient field.
+-@*         (ii) If the last ring variable is used by the monomials, the list
+-                returned contains only one ideal, namely the monomials
+-                representing the lattice points of the polytope.
+-@*
+-@*        The function returns the a list containing the input ideal I if one
+-          of the options @code{supp}, @code{triang}, or @code{hvect} has been
+-                         activated.
+-          However, in this case some numerical invariants are computed, and
+-          some other data may be contained in files that you can read into
+-          Singular.
+-NOTE:      A mathematical remark: the Ehrhart ring depends on the list of
+-           monomials given, and not only on the ideal they generate!
+-SEE ALSO: intclToricRing, normalToricRing, intclMonIdeal
+-EXAMPLE:  example ehrhartRing; shows an example
+-"
+-{
+-    return(runIntclMonIdeal(I,2));
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R=37,(x,y,t),dp;
+-  ideal J=x3,x2y,y3,xy2t7;
+-  ehrhartRing(J);
+-}
+-
+-proc intclMonIdeal(ideal I)
+-"USAGE:   intclMonIdeal(ideal I);
+-RETURN:   The exponent vectors of the leading monomials of the elements of I
+-          are considered as generators of a monomial ideal for which the
+-          normalization of its Rees algebra is computed. For a Definiton of the
+-          Rees algebra (or Rees ring) see Bruns and Herzog, Cohen-Macaulay
+-          rings, Cambridge University Press 1998, p. 182.
+-          The function returns a list of ideals:
+-@* (i) If the last ring variable is not used by the monomials, it is treated
+-       as the auxiliary variable of the Rees algebra. The function returns two
+-       ideals, the first containing the monomials generating the integral
+-       closure of the monomial ideal, the second containing the algebra
+-         generators of the normalization of the Rees algebra.
+-@* (ii) If the last ring variable is used by the monomials, the list returned
+-        contains only one ideal, namely the monomials generating the integral
+-        closure of the ideal.
+-@*        The function returns the a list containing the input ideal I if one
+-          of the options @code{supp}, @code{triang}, or @code{hvect} has been
+-                         activated.
+-          However, in this case some numerical invariants are computed, and
+-          some other data may be contained in files that you can read into
+-          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
+-SEE ALSO: intclToricRing, normalToricRing, ehrhartRing
+-EXAMPLE:  example intclMonIdeal; shows an example
+-"
+-{
+-    return(runIntclMonIdeal(I,3));
+-}
+-example
+-{ "EXAMPLE"; echo=2;
+-    ring R=0,(x,y,z,t),dp;
+-    ideal I=x^2,y^2,z^3;
+-    list l=intclMonIdeal(I);
+-    l[1]; // integral closure of I
+-    l[2];  // monomials generating the integral closure of the Rees algebra
+-}
+-
+-// torus invariants and valuation rings and ideals
+-
+-proc torusInvariants(intmat E)
+-"USAGE:   torusInvariants(intmat A);
+-RETURN:
+-Returns an ideal representing the list of monomials generating the ring of
+-invariants as an algebra over the coefficient field.
+- at tex
+-$R^T$.
+- at end tex
+-@*The function returns the ideal given by the input matrix A if one of
+-the options @code{supp}, @code{triang}, or @code{hvect} has been
+-activated.
+-However, in this case some numerical invariants are computed, and
+-some other data may be contained in files that you can read into
+-Singular.
+-BACKGROUND:
+- at tex
+- Let $T = (K^*)^r$ be the $r$-dimensional torus acting on the polynomial ring
+- $R = K[X_1 ,\ldots,X_n]$ diagonally. Such an action can be described as
+- follows: there are integers $a_{i,j}$, $i=1,\ldots,r$, $j=1,\ldots,n$, such
+- that $(\lambda_1,\ldots,\lambda_r)\in T$ acts by the substitution
+-$$ X_j \mapsto \lambda_1^{a_{1,j}} \cdots \lambda_r^{a_{r,j}}X_j,
+-   \quad j=1,\ldots,n.$$
+-In order to compute the ring of invariants $R^T$ one must specify the matrix
+-$A=(a_{i,j})$.
+- at end tex
+-SEE ALSO: diagInvariants, finiteDiagInvariants, intersectionValRings,
+-          intersectionValRingIdeals
+-EXAMPLE:  example torusInvariants; shows an example
+-"
+-{
+-    if(nvars(basering)!=ncols(E))
+-    {
+-        ERROR("torusInvariants: wrong number of columns in matrix");
+-    }
+-
+-    string dummy=collectNmzOptions();  // only to set GenGen
+-
+-    return( intmat2mons( runNormaliz(E,5) ) );
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R=0,(x,y,z,w),dp;
+-  intmat E[2][4] = -1,-1,2,0, 1,1,-2,-1;
+-  torusInvariants(E);
+-}
+-
+-proc finiteDiagInvariants(intmat C)
+-"USAGE:   finiteDiagInvariants(intmat U);
+-RETURN:
+- at tex
+-This function computes the ring of invariants of a finite abelian group $G$
+-acting diagonally on the surrounding polynomial ring $K[X_1,...,X_n]$. The
+-group is the direct product of cyclic groups generated by finitely many
+-elements $g_1,...,g_w$. The element $g_i$ acts on the indeterminate $X_j$ by
+-$g_i(X_j)=\lambda_i^{u_{ij}}X_j$ where $\lambda_i$ is a primitive root of
+-unity of order equal to $ord(g_i)$. The ring of invariants is generated by all
+-monomials satisfying the system
+-$u_{i1}a_1+\ldots+u_{in} a_n \equiv 0$ mod ord$(g_i)$, $i=1,\ldots,w$.
+-The input to the function is the $w\times(n+1)$ matrix $U$ with rows
+-$u_{i1}\ldots u_{in}$ ord$(gi)$, $i=1,\ldots,w$. The output is a monomial ideal
+-listing the algebra generators of the subalgebra of invariants
+-{$R^G=\{f\in R : g_i f = f$ for all $i=1,\ldots,w\}$}.
+- at end tex
+-@*The function returns the ideal given by the input matrix C if one of
+-the options @code{supp}, @code{triang}, or @code{hvect} has been
+-activated.
+-However, in this case some numerical invariants are computed, and
+-some other data may be contained in files that you can read into
+-Singular.
+-NOTE:
+-SEE ALSO: torusInvariants, diagInvariants, intersectionValRings,
+-          intersectionValRingIdeals,showNuminvs,exportNuminvs
+-EXAMPLE:  example finiteDiagInvariants; shows an example
+-"
+-{
+-    if(nvars(basering)!=ncols(C)-1)
+-    {
+-        ERROR("finiteDiagInvariants: wrong number of columns in matrix");
+-    }
+-
+-    string dummy=collectNmzOptions();  // only to set GenGen
+-
+-    return( intmat2mons( runNormaliz(C,6) ) );
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R = 0,(x,y,z,w),dp;
+-  intmat C[2][5] = 1,1,1,1,5, 1,0,2,0,7;
+-  finiteDiagInvariants(C);
+-}
+-
+-proc diagInvariants(intmat E, intmat C)
+-"USAGE:   diagInvariants(intmat A, intmat U);
+-RETURN:
+- at tex
+-This function computes the ring of invariants of a diagonalizable group
+-$D = T\times G$ where $T$ is a torus and $G$ is a finite abelian group, both
+-acting diagonally on the polynomial ring $K[X_1,\ldots,X_n]$. The group
+-actions are specified by the input matrices A and U. The first matrix specifies
+-the torus action, the second the action of the finite group. See
+-torusInvariants and finiteDiagInvariants for more detail. The output is a
+-monomial ideal listing the algebra generators of the subalgebra of invariants.
+- at end tex
+-@*The function returns the ideal given by the input matrix A if one of
+-the options @code{supp}, @code{triang}, or @code{hvect} has been
+-activated.
+-However, in this case some numerical invariants are computed, and
+-some other data may be contained in files that you can read into
+-Singular.
+-SEE ALSO: torusInvariants, finiteDiagInvariants, intersectionValRings, intersectionValRingIdeals,showNuminvs,exportNuminvs
+-EXAMPLE:  example diagInvariants; shows an example
+-"
+-{
+-    if(nvars(basering)!=ncols(E) || nvars(basering)!=ncols(C)-1)
+-    {
+-        ERROR("diagInvariants: wrong number of columns in matrix");
+-    }
+-
+-    string dummy=collectNmzOptions();  // only to set GenGen
+-
+-    return( intmat2mons( runNormaliz(E,5,C,6) ) );
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R=0,(x,y,z,w),dp;
+-  intmat E[2][4] = -1,-1,2,0, 1,1,-2,-1;
+-  intmat C[2][5] = 1,1,1,1,5, 1,0,2,0,7;
+-  diagInvariants(E,C);
+-}
+-
+-proc intersectionValRings(intmat V)
+-"USAGE:   intersectionValRings(intmat V);
+-RETURN:   The function returns a monomial ideal, to be considered as the list
+-          of monomials generating @math{S} as an algebra over the coefficient
+-          field.
+-BACKGROUND:
+- at tex
+-A discrete monomial valuation $v$ on $R = K[X_1 ,\ldots,X_n]$ is determined by
+-the values $v(X_j)$ of the indeterminates. This function computes the
+-subalgebra $S = \{ f \in R : v_i ( f ) \geq 0,\ i = 1,\ldots,r\}$ for several
+-such valuations $v_i$, $i=1,\ldots,r$. It needs the matrix $V = (v_i(X_j))$ as
+-its input.
+- at end tex
+-@*The function returns the ideal given by the input matrix V if one of
+-the options @code{supp}, @code{triang}, or @code{hvect} has been
+-activated.
+-However, in this case some numerical invariants are computed, and
+-some other data may be contained in files that you can read into
+-Singular.
+-SEE ALSO: torusInvariants, diagInvariants, finiteDiagInvariants, intersectionValRingIdeals,showNuminvs,exportNuminvs
+-EXAMPLE:  example intersectionValRings; shows an example
+-"
+-{
+-
+-    if(nvars(basering)!=ncols(V))
+-    {
+-        ERROR("intersectionValRings: wrong number of columns in matrix");
+-    }
+-
+-    intmat V1[nrows(V)+ncols(V)][ncols(V)];
+-    int i,j;
+-
+-    for(i=1;i<=ncols(V);i++)
+-    {
+-        V1[i,i]=1;
+-    }
+-    for(i=1;i<=nrows(V);i++)
+-    {
+-        for(j=1;j<=ncols(V);j++)
+-        {
+-            V1[i+ncols(V),j]=V[i,j];
+-        }
+-    }
+-
+-
+-    string dummy=collectNmzOptions();  // only to set GenGen
+-
+-/*    if(!GenGen) // return V
+-    {
+-        runNormaliz(V1,4);
+-        return(V);
+-    }
+-*/
+-    return(intmat2mons(runNormaliz(V1,4)));
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+-  ring R=0,(x,y,z,w),dp;
+-  intmat V0[2][4]=0,1,2,3, -1,1,2,1;
+-  intersectionValRings(V0);
+-}
+-
+-proc intersectionValRingIdeals(intmat V)
+-"USAGE:   intersectionValRingIdeals(intmat V);
+-RETURN:   The function returns two ideals, both to be considered as lists of
+-          monomials which generate an algebra over the coefficient field. The
+-          first is the system of monomial generators of @math{S}, the second
+-          the system of generators of @math{M}.
+-@*        The function returns a list consisting of the ideal given by the
+-          input matrix T if one of the options @code{supp}, @code{triang}, or
+-          @code{hvect} has been activated.
+-          However, in this case some numerical invariants are computed, and
+-          some other data may be contained in files that you can read into
+-          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
+-BACKGROUND:
+- at tex
+-A discrete monomial valuation $v$ on $R = K[X_1 ,\ldots,X_n]$ is determined by
+-the values $v(X_j)$ of the indeterminates. This function computes the
+-subalgebra $S = \{ f \in R : v_i ( f ) \geq 0,\ i = 1,\ldots,r\}$ for several
+-such valuations $v_i$, $i=1,\ldots,r$. It needs the matrix $V = (v_i(X_j))$ as
+-its input.
+-
+-This function simultaneously determines the $S$-submodule
+-$M = \{ f \in R : v_i(f) \geq w_i ,\ i = 1,\ldots,r\}$ for integers
+-$w_1,\ldots\,w_r$. (If $w_i \geq 0$ for all $i$, $M$ is an ideal of $S$.)
+-The numbers $w_i$ form the $(n+1)$th column of the input matrix.
+- at end tex
+-NOTE:   The function also gives an error message if the matrix V has the
+-        wrong number of columns.
+-SEE ALSO: torusInvariants, diagInvariants, finiteDiagInvariants, intersectionValRings
+-EXAMPLE:  example intersectionValRingIdeals; shows an example
+-"
+-{
+-    if(nvars(basering)!=ncols(V)-1)
+-    {
+-        ERROR("intersectionValRingIdeals: wrong number of columns in matrix");
+-    }
+-
+-    intmat V1[nrows(V)+ncols(V)][ncols(V)];
+-    int i,j;
+-
+-    for(i=1;i<=ncols(V);i++)
+-    {
+-        V1[i,i]=1;
+-    }
+-    for(i=1;i<=nrows(V);i++)
+-    {
+-        for(j=1;j<=ncols(V);j++)
+-        {
+-            V1[i+ncols(V),j]=V[i,j];
+-        }
+-    }
+-    for(i=1;i<=nrows(V);i++)
+-    {
+-        V1[i+ncols(V),ncols(V)]=-V1[i+ncols(V),ncols(V)];
+-    }
+-
+-    string dummy=collectNmzOptions();  // only to set GenGen
+-
+-    intmat nmz_data=runNormaliz(V1,4);
+-
+-    ideal I1=intmat2monsSel(nmz_data,0);
+-    ideal I2=intmat2monsSel(nmz_data,1);
+-    return(list(I1,I2));
+-}
+-example
+-{ "EXAMPLE:"; echo=2;
+- ring R=0,(x,y,z,w),dp;
+- intmat V[2][5]=0,1,2,3,4, -1,1,2,1,3;
+- intersectionValRingIdeals(V);
+-}
++// Singular library normaliz.lib
++
++version="$Id$"
++category="Commutative algebra"
++info="
++LIBRARY: normaliz.lib  Provides an interface for the use of Normaliz 2.8 or 2.9
++         within SINGULAR.
++AUTHORS: Winfried Bruns, Winfried.Bruns at Uni-Osnabrueck.de
++         Christof Soeger, Christof.Soeger at Uni-Osnabrueck.de
++
++OVERVIEW:
++ at texinfo
++The library normaliz.lib provides an interface for the use of Normaliz 2.8 or
++2.9 within SINGULAR. The exchange of data is via files.
++In addition to the top level
++functions that aim at objects of type ideal or ring, several other auxiliary
++functions allow the user to apply Normaliz to data of type intmat. Therefore
++SINGULAR can be used as a comfortable environment for the work with Normaliz.
++@* Please see the @code{Normaliz2.9Documentation.pdf} (included in the Normaliz
++distribution) for a more extensive documentation of Normaliz.
++
++@* Normaliz allows the use of a grading. In the Singular functions that access
++Normaliz the parameter grading is an intvec that assigns a (not necessarily
++positive) degree to every variable of the ambient polynomial ring.
++But it must give positive degrees to the generators given to function.
++
++@*
++@*Singular and Normaliz exchange data via files. These files are automatically
++created and erased behind the scenes. As long as one wants to use only the
++ring-theoretic functions there is no need for file management.
++@*
++@*Note that the numerical invariants computed by Normaliz can be
++accessed in this \"automatic file mode\".
++@*
++@*However, if Singular is used as a frontend for Normaliz or the user
++wants to inspect data not automatically returned to Singular, then
++an explicit filename and a path can be specified for the exchange of
++data. Moreover, the library provides functions for access to these files.
++Deletion of the files is left to the user.
++@*
++@* Use of this library requires the program Normaliz to be installed.
++You can download it from
++ at uref{http://www.mathematik.uni-osnabrueck.de/normaliz/}. Please make sure
++that the executables are in the search path or use setNmzExecPath
++(@ref{setNmzExecPath}).
++ at end texinfo
++
++
++KEYWORDS: integral closure; normalization; toric ring
++
++PROCEDURES:
++ intclToricRing(ideal I)      computes the integral closure of the toric ring
++                              generated by the leading monomials of the
++                              elements of I in the basering
++ normalToricRing(ideal I)     computes the normalization of the toric ring
++                              generated by the leading monomials of the
++                              elements of I
++ normalToricRingFromBinomials(ideal I)  computes the normalization of the
++                              polynomial ring modulo the unique minimal binomial
++                              prime ideal of the binomial ideal I
++ ehrhartRing(ideal I)         considers the exponent vectors of the elements of I
++                              as points of a lattice polytope and computes the
++                              integral cloure of the polytopal algebra
++ intclMonIdeal(ideal I)       Computes the integral closure of the Rees algebra
++                              of the ideal generated by the leading monomials of
++                              the elements of I
++ torusInvariants(intmat T)    computes the ring of invariants of a torus action
++ finiteDiagInvariants(intmat C)  computes the ring of invariants of a finite
++                                 abelian group acting diagonally on a polynomial
++                                 ring
++ diagInvariants(intmat C)     computes the ring of invariants of a
++                              diagonalizable group
++ intersectionValRings(intmat V)   computes the intersection of the polynomial
++                                  ring with the valuation rings of monomial
++                                  valuations
++ intersectionValRingIdeals(intmat V)       computes ideals of monomial valuations
++
++ showNuminvs()                prints the numerical invariants found by Normaliz
++ exportNuminvs()              exports the numerical invariants found by Normaliz
++
++ setNmzOption(string s, int onoff) sets the option s to onoff
++ showNmzOptions()             prints the enabled options to the standard output
++
++ normaliz(intmat sgr,int nmz_mode) applies Normaliz
++ setNmzExecPath(string nmz_exec_path_name) sets the path to the Normaliz
++                                           executable
++
++ writeNmzData(intmat sgr, int n_mode) creates an input file for Normaliz
++ readNmzData(string nmz_suffix) reads the Normaliz output file with the
++                                specified suffix
++
++ setNmzFilename(string nmz_filename_name) sets the filename for the exchange
++                                          of data
++ setNmzDataPath(string nmz_data_path_name) sets the directory for the exchange
++                                           of data
++ writeNmzPaths()              writes the path names into two files
++ startNmz()                   retrieves the path names written by writeNmzPaths
++ rmNmzFiles()                 removes the files created for and by Normaliz
++
++ mons2intmat(ideal I)         returns the intmat whose rows represent the
++                              leading exponents of the elements of I
++ intmat2mons(intmat expo_vecs) returns the ideal generated by the monomials
++                               which have the rows of expo_vecs as
++                               exponent vector
++ binomials2intmat(ideal I)    returns the intmat whose rows represent the
++                              exponents of the elements of the binomial ideal I
++";
++
++
++// helpers
++
++static proc desInt(string intname, int value)
++// define, export and set an integer
++{
++    int exists;
++    if(defined(`intname`)){exists=1;}
++    if(!exists)
++    {
++        int `intname`=value;export(`intname`);
++    }
++    `intname`=value;
++}
++
++static proc desString(string stringname, string value)
++// define, export and set a string
++{
++    int exists;
++    if(defined(`stringname`)){exists=1;}
++    if(!exists)
++    {
++        string `stringname`=value;export(`stringname`);
++    }
++    `stringname`=value;
++}
++
++static proc queryInt(string intname)
++// if intname is defined, return(intname), else return(0)
++{
++    int exists,value;
++    if(defined(`intname`)){exists=1;}
++    if(!exists)
++    {
++        return(0);
++    }
++    return(`intname`);
++}
++
++static proc queryString(string stringname)
++// if stringname is defined, return(stringname), else return("")
++{
++    int exists;
++    string value;
++    if(defined(`stringname`)){exists=1;}
++    if(!exists)
++    {
++        return("");
++    }
++    return(`stringname`);
++}
++
++static proc fileExists(string f)
++{
++    return(status (f,"exists")=="yes");
++}
++
++static proc appendSlash(string s)
++// if nonempty and / is not the terminating char
++{
++    if(size(s)>0)
++    {
++        if(s[size(s)]!="/")
++        {
++            s=s+"/";
++            return(s);
++        }
++    }
++    return(s);
++}
++
++// filenames and paths
++
++proc setNmzExecPath(string nmz_exec_path_name)
++"USAGE:   setNmzExecPath(string s);   @code{s} path to the Normaliz executable
++CREATE:   @code{Normaliz::nmz_exec_path} to save the given path @code{s}
++NOTE:     It is not necessary to use this function if the Normaliz executable
++          is in the search path of the system.
++SEE ALSO: setNmzOption
++EXAMPLE:  example setNmzExecPath; shows an example"
++{
++    desString("nmz_exec_path",nmz_exec_path_name);
++    nmz_exec_path=appendSlash(nmz_exec_path);
++}
++example
++{ "EXAMPLE:";echo = 2;
++  setNmzExecPath("../Normaliz/");
++}
++
++proc setNmzFilename(string nmz_filename_name)
++"USAGE:   setNmzFilename(string s);
++CREATE:   @code{Normaliz::nmz_filename} to save the given filename @code{s}
++NOTE:     The function sets the filename for the exchange of data. Unless a
++          path is set by setNmzDataPath, files will be created in the current
++          directory.
++          @* If a non-empty filename is set, the files created for and by
++             Normaliz are kept. This is mandatory for the data access functions
++             (see @ref{writeNmzData} and @ref{readNmzData}).
++          @* Resetting the filename by setNmzFilename(\"\") forces the library
++             to return to deletion of temporary files, but the files created
++             while the filename had been set will not be erased.
++SEE ALSO: writeNmzData, readNmzData, setNmzDataPath, rmNmzFiles
++EXAMPLE:  example setNmzFilename; shows an example"
++{
++    desString("nmz_filename",nmz_filename_name);
++    if(nmz_filename_name!="")
++    {
++        desInt("nmz_files_keep_switch",1);
++    }
++    else
++    {
++        desInt("nmz_files_keep_switch",0);
++    }
++}
++example
++{ "EXAMPLE:";echo = 2;
++  setNmzDataPath("examples/");
++  setNmzFilename("example1");
++  //now the files for the exchange with Normaliz are examples/example1.SUFFIX
++}
++
++proc setNmzDataPath(string nmz_data_path_name)
++"USAGE:   setNmzDataPath(string s);
++CREATE:   @code{Normaliz::nmz_data_path} to save the given path @code{s}
++NOTE:     The function sets the path for the exchange of data. By default the
++          files will be created in the current directory.
++          @* It seems that Singular cannot use filenames starting with @code{~}
++             or @code{$HOME} in its input/output functions.
++          @* You must also avoid path names starting with @code{/} if you work
++             under Cygwin, since Singular and Normaliz interpret them in
++             different ways.
++SEE ALSO: writeNmzData, readNmzData, rmNmzFiles, setNmzFilename
++EXAMPLE:  example setNmzDataPath; shows an example"
++{
++    desString("nmz_data_path",nmz_data_path_name);
++    nmz_data_path=appendSlash(nmz_data_path);
++}
++example
++{ "EXAMPLE:";echo = 2;
++  setNmzDataPath("examples/");
++  setNmzFilename("example1");
++  //now the files for the exchange with Normalize are examples/example1.SUFFIX
++}
++
++proc writeNmzPaths();
++"USAGE:   writeNmzPaths();
++CREATE:   the file nmz_sing_exec.path where the path to the Normaliz executable
++          is saved
++          @* the file nmz_sing_data.path where the directory for the exchange
++          of data is saved
++NOTE:     Both files are saved in the current directory. If one of the names
++          has not been defined, the corresponding file is created, but
++          contains nothing.
++SEE ALSO: setNmzDataPath, setNmzExecPath, startNmz
++EXAMPLE:  example writeNmzPaths; shows an example
++"{
++    link outf=":w nmz_sing_exec.path";
++    write(outf, queryString("nmz_exec_path"));
++    close(outf);
++
++    outf=":w nmz_sing_data.path";
++    write(outf, queryString("nmz_data_path"));
++    close(outf);
++}
++example
++{ "EXAMPLE:";echo = 2;
++  setNmzExecPath("../Normaliz/");
++  writeNmzPaths();
++  int dummy=system("sh","cat nmz_sing_exec.path");
++  dummy=system("sh","cat nmz_sing_data.path");
++}
++
++proc startNmz()
++"USAGE:   startNmz();
++PURPOSE:  This function reads the files written by @code{writeNmzPaths()},
++          retrieves the path names, and types them on the standard output
++          (as far as they have been set). Thus, once the path names have been
++          stored, a Normaliz session can simply be opened by this function.
++SEE ALSO: setNmzDataPath, setNmzExecPath, writeNmzPaths
++EXAMPLE:  example startNmz; shows an example
++"
++{
++    link inf=":r nmz_sing_exec.path";
++    string s=read(inf);
++    int i,p;
++    p=findWord("/",s,1);
++    if(p!=-1)
++    {
++        for(i=size(s);i>=1;i--)
++        {
++            if(s[i]=="/")
++            {
++                s=s[1..i];
++                break;
++            }
++        }
++        desString("nmz_exec_path",s);
++        "nmz_exec_path is",nmz_exec_path;
++    }
++    else
++    {
++        "nmz_exec_path not set";
++    }
++
++    inf=":r nmz_sing_data.path";
++    s=read(inf);
++    p=findWord("/",s,1);
++    if(p!=-1)
++    {
++        for(i=size(s);i>=1;i--)
++        {
++            if(s[i]=="/")
++            {
++                s=s[1..i];
++                break;
++            }
++        }
++        desString("nmz_data_path",s);
++        "nmz_data_path is",nmz_data_path;
++    }
++    else
++    {
++        "nmz_data_path not set";
++    }
++}
++example
++{ "EXAMPLE:"; echo=2;
++  startNmz();
++}
++
++static proc getNmzFile()
++{
++    if(queryInt("nmz_files_keep_switch"))
++    {
++        return(queryString("nmz_data_path")+queryString("nmz_filename"));
++    }
++    else
++    {
++        return(queryString("nmz_filename"));
++    }
++}
++
++static proc makeTempNmzDataPath()
++{
++    string testdir, testdir1;
++    int i,dummy;
++
++    testdir1="/tmp/nmz_sing_"+string(system("pid"));
++    testdir=testdir1;
++    while(fileExists(testdir))
++    {
++        i++;
++        testdir=testdir1+string(i);
++    }
++    dummy=system("sh","mkdir "+ testdir);
++    desString("nmz_filename",testdir+"/nmz"); //files are nmz+suffix in testdir
++}
++
++static proc eraseTempNmzDataPath();
++{
++    int dummy;
++
++    string tmpdir=getNmzFile();
++    tmpdir=tmpdir[1..size(tmpdir)-4]; // remove "/nmz"
++    dummy=system("sh","rm -r "+tmpdir);
++    setNmzFilename("");
++}
++
++static proc setNmzExec()
++{
++    return(queryString("nmz_exec_path")+"normaliz");
++}
++
++proc rmNmzFiles()
++"USAGE:  rmNmzFiles();
++PURPOSE: This function removes the files created for and by Normaliz, using
++         the last filename specified.
++         It needs an explicit filename set (see @ref{setNmzFilename}).
++SEE ALSO: writeNmzData, readNmzData, setNmzFilename, setNmzDataPath
++EXAMPLE:  example rmNmzFiles; shows an example
++"{
++
++    if(!queryInt("nmz_files_keep_switch"))
++    {
++        ERROR("rmNmzFiles: no filename specified");
++    }
++
++    list suffixes="in","gen","out","cst","typ","egn","esp","inv","tri","ht1",
++                  "ext";
++    int i,dummy;
++    string f;
++
++    for(i=1;i<=size(suffixes);i++)
++    {
++        f=getNmzFile()+"."+suffixes[i];
++        if (fileExists(f)) {
++              dummy=system("sh","rm "+f+ "&> /dev/null");
++        }
++    }
++}
++example
++{ "EXAMPLE:"; echo=2;
++  setNmzFilename("VeryInteresting");
++  rmNmzFiles();
++}
++
++
++
++// parsing normaliz output
++
++static proc digit(string s)
++{
++    if(s==" ") // skip blanks quickly
++    {
++        return(0);
++    }
++
++    if((s[1]>="0" && s[1]<="9")||s[1]=="-")
++    {
++        return(1);
++    }
++    return(0);
++}
++
++static proc nextWord(string s, int p)
++{
++    int j,sw,ew;
++
++    for(;p<=size(s);p++) // must start with a letter
++    {
++
++        if((s[p]>="a" && s[p]<="z")||
++             (s[p]>="A" && s[p]<="Z"))
++        {
++            sw=p; break;
++        }
++    }
++    if(p>size(s))
++    {
++        return(-1,-1); // no word found
++    }
++
++    for(;p<=size(s);p++) // now numerals and -_ allowed
++    {
++        if(!((s[p]>="a" && s[p]<="z")||
++             (s[p]>="A" && s[p]<="Z")||
++             (s[p]>="0" && s[p]<="9")||
++              s[p]=="_"||s[p]=="-"))
++        {
++            break;
++        }
++    }
++    return(sw,p);
++}
++
++static proc getInt(string s, int p)
++{
++    string nst;
++    int i,j,en,sn;
++
++    for(;p<=size(s);p++)
++    {
++
++        if(digit(s[p]))
++        {
++            sn=p; break;
++        }
++    }
++    if(not(sn))
++    {
++        return(0,-1); // -1 indicates: no number found
++    }
++    p++;
++    for(;p<=size(s);p++)
++    {
++        if(!digit(s[p]))
++        {
++            en=p-1; break;
++        }
++    }
++    if(p>size(s))
++    {
++        en=size(s);
++    }
++    nst="i="+s[sn,en-sn+1];
++    execute(nst);
++    return(i,p);
++}
++
++
++static proc getRational(string s, int p)
++{
++    string nst;
++    int i,j,en,sn;
++
++    for(;p<=size(s);p++)
++    {
++        if(digit(s[p]))
++        {
++            sn=p; break;
++        }
++    }
++    if(not(sn))
++    {
++        return(0,-1); // -1 indicates: no number found
++    }
++    p++;
++    int slash_at;
++    for(;p<=size(s);p++)
++    {
++        if(s[p]=="/")
++        {
++            slash_at=p;
++            p++;
++            continue;
++        }
++        if(!digit(s[p]))
++        {
++            en=p-1; break;
++        }
++    }
++    if(p>size(s))
++    {
++        en=size(s);
++    }
++    if(slash_at)
++    {
++        nst="i="+s[sn,slash_at-sn];
++        execute(nst);
++        nst="j="+s[slash_at+1,en-slash_at];
++        execute(nst);
++        return(i,p,j);
++    }
++    nst="i="+s[sn,en-sn+1];
++    execute(nst);
++    return(i,p);
++}
++
++
++static proc findWord(string s, string t, int p)
++{
++    for(;p<=size(t)-size(s)+1;p++)
++    {
++        if(t[p]==s[1])
++        {
++            if(t[p,size(s)]==s)
++            {
++                 return(p+size(s));
++            }
++        }
++    }
++    return(-1);
++}
++
++
++static proc skipEqualsign(string s,int p)
++{
++    for(;p<=size(s);p++)
++    {
++        if(s[p]=="=")
++        {
++            break;
++        }
++    }
++    return(p+1);
++}
++
++
++// input and output to/from normaliz
++
++//list must have pairs of intmat, nmz_mode
++static proc doWriteNmzData(list #)
++{
++    string s;
++    int i,j;
++    link outf=":w "+ getNmzFile() +".in";  // also sets the filename
++
++    intmat sgr;
++    int num_rows, num_cols, n_mode;
++
++    for (int k=1; k+1<=size(#); k=k+2) {
++      //get data from the parameter list
++      n_mode   = #[k+1];
++      if (n_mode != -1) { //skip -1 mode
++        sgr   = #[k];
++        num_rows = nrows(sgr);
++        num_cols = ncols(sgr);
++
++        write(outf,num_rows);
++        write(outf,num_cols);
++
++        for(i=1;i<=nrows(sgr);i++)
++        {
++          s="";
++          for(j=1;j<=num_cols;j++)
++          {
++             s=s+string(sgr[i,j])+" ";
++          }
++          write(outf,s);
++        }
++        if (n_mode == 20) {
++          write(outf,"grading");
++        } else {
++          write(outf,n_mode);
++        }
++        write(outf,"");
++      }
++    }
++    close(outf);
++}
++
++
++static proc prepareGrading(list #)
++{
++    if (size(#)==0) {
++        return(0,-1); // mode -1 specifies discard the matrix
++    }
++    if (size(#)>1) {
++        print(#);
++        ERROR("To many parameters!");
++    }
++    intmat g = intmat(#[1],1,size(#[1]));
++    return (g,20);
++}
++
++
++proc writeNmzData(intmat sgr, int n_mode, list #)
++"USAGE:   writeNmzData(intmat M, int mode);
++          writeNmzData(intmat M, int mode, intmat M2, int mode2, ...);
++CREATE:   Creates an input file for Normaliz from the matrix M. The second
++          parameter sets the mode. How the matrix is interpreted depends on the
++          mode. See the Normaliz documentation for more information.
++
++          It is also possible to give more than one pair of matrix and mode. In
++          this case all matrices and modes are written. This can be used to
++          combine modes 4,5,6.
++          Use mode=20 to specify a grading.
++NOTE:     Needs an explicit filename set. The filename is created from the
++          current filename.
++   @*     Note that all functions in normaliz.lib write and read their data
++          automatically to and from the hard disk so that writeNmzData will
++          hardly ever be used explicitly.
++SEE ALSO: readNmzData, rmNmzFiles, setNmzFilename, setNmzDataPath
++EXAMPLE:  example writeNmzData; shows an example"
++{
++    if(queryString("nmz_filename")=="")
++    {
++        ERROR("writeNmzData: no filename specified");
++    }
++    doWriteNmzData(list(sgr, n_mode) + #);
++}
++example
++{ "EXAMPLE:"; echo=2;
++  setNmzFilename("VeryInteresting");
++  intmat sgr[3][3]=1,2,3,4,5,6,7,8,10;
++  writeNmzData(sgr,1);
++  int dummy=system("sh","cat VeryInteresting.in");
++
++  intmat Hyperplanes[2][3] = 2,-1,0, // 2x-y >= 0
++                             1, 1,0; //  x+y >= 0
++  intmat Equation[1][3] = 0,1,-1;    // y = z
++  intmat Congruence[1][4] = 1,0,0,3;  // x = 0 (3)
++  writeNmzData(Hyperplanes,4,Equation,5,Congruence,6);
++  dummy=system("sh","cat VeryInteresting.in");
++}
++
++
++proc readNmzData(string nmz_suffix)
++"USAGE:  readNmzData(string suffix);
++RETURN:  Reads an output file of Normaliz containing an integer matrix and
++         returns it as an intmat. For example, this function is useful if one
++         wants to inspect the support hyperplanes. The filename is created
++         from the current  filename and the suffix given to the function.
++NOTE:    Needs an explicit filename set by setNmzFilename.
++   @*    Note that all functions in normaliz.lib write and read their data
++         automatically so that readNmzData will usually not be used explicitly.
++   @*    This function reads only the first matrix in a file!
++SEE ALSO: writeNmzData, rmNmzFiles, setNmzFilename, setNmzDataPath
++EXAMPLE:  example readNmzData; shows an example"
++{
++    if(queryString("nmz_filename")=="")
++    {
++        ERROR("readNmzData: no filename specified");
++    }
++
++    string s;
++    int n_rows,n_cols;            //number of rows/columns
++    int p;                     //position
++    int i,j;
++    int returnvalue;
++
++    string filename = getNmzFile() + "."+ nmz_suffix;
++    link in_f=":r "+ filename;
++    s=read(in_f);
++    close(in_f);
++
++    p=1;
++    (n_rows,p)=getInt(s,p);
++    (n_cols,p)=getInt(s,p);
++    if (n_rows <= 0 || n_cols <= 0) {
++         intmat empty;
++         return(empty);
++    }
++    intmat nmz_gen[n_rows][n_cols];
++    for(i=1;i<=n_rows;i++)
++    {
++        for(j=1;j<=n_cols;j++)
++        {
++            (nmz_gen[i,j],p) = getInt(s,p);
++        }
++    }
++    return(nmz_gen);
++}
++example
++{ "EXAMPLE:"; echo=2;
++  setNmzFilename("VeryInteresting");
++  intmat sgr[3][3]=1,2,3,4,5,6,7,8,10;
++  intmat sgrnormal=normaliz(sgr,0);
++  readNmzData("cst");
++}
++
++
++// running normaliz (with options)
++
++// component 1 is name of option
++// 2 is default value
++// 3 is command line option to be passed to Normaliz
++// 4 indictes whether file "gen" is generated
++// value 2 of 4 indicates "no influence"
++
++static proc defNmzOptions()
++{
++    if(!defined(nmz_options)) // can be defined only once
++    {
++        list nmz_options=
++        list("supp",0,"-s",0),
++        list("triang",0,"-tT",0),
++        list("volume",0,"-v",0),
++        list("hvect",0,"-p",0),
++        list("height1",0,"-1",0),
++        list("normal",0,"-n",1),
++        list("normal_l",0,"-N",1),
++        list("hilb",0,"-h",1),
++        list("dual",0,"-d",1),
++        list("control",0,"-c",2),
++        list("allf",0,"-a",2),
++        list("errorcheck",0,"-e",2),
++        list("bigint",0,"-B",2),
++        list("threads",0,"-x=",2);
++        export(nmz_options);
++    }
++}
++
++proc setNmzOption(string s, int onoff)
++"USAGE:   setNmzOption(string s, int onoff);
++PURPOSE:  If @code{onoff=1} the option @code{s} is activated, and
++          if @code{onoff=0} it is deactivated.
++The Normaliz options are accessible via the following names:
++@* @code{-s:  supp}
++@* @code{-t:  triang}
++@* @code{-v:  volume}
++@* @code{-p:  hvect}
++@* @code{-1:  height1}
++@* @code{-n:  normal}
++@* @code{-N:  normal_l}
++@* @code{-h:  hilb}
++@* @code{-d:  dual}
++@* @code{-a:  allf}
++@* @code{-c:  control}
++@* @code{-e:  errorcheck}
++@* @code{-B:  bigint} Use GMP for arbitrary precision integers
++@* @code{-x=N:  threads} In this case the int parameter is used to set the
++                         number of threads N, 0 means no explicit limiting.
++
++SEE ALSO: showNmzOptions
++EXAMPLE:  example setNmzOption; shows an example
++"
++{
++    defNmzOptions();
++    for(int i=1;i<=size(nmz_options);i++)
++    {
++        if(s==nmz_options[i][1])
++        {
++            nmz_options[i][2]=onoff;
++            return(1);
++        }
++    }
++    "Invalid option ", s;
++    return(0);
++}
++example
++{ "EXAMPLE:"; echo=2;
++  setNmzOption("hilb",1);
++  showNmzOptions();
++}
++
++static proc collectNmzOptions()
++{
++    defNmzOptions();
++    string run_options=" -f ";
++    desInt("GenGen",1); // indicates whether "gen" is generated
++    for(int i=1;i<=size(nmz_options);i++)
++    {
++        if(nmz_options[i][2])
++        {
++            run_options=run_options+nmz_options[i][3];
++                if (nmz_options[i][1]=="threads") {
++                    run_options=run_options+string(nmz_options[i][2]);
++                }
++                run_options=run_options+" ";
++            if(nmz_options[i][4]!=2)
++            {
++                GenGen=nmz_options[i][4];
++            }
++        }
++    }
++    return(run_options+" ");
++}
++
++proc showNmzOptions()
++"USAGE:   showNmzOptions();
++RETURN:   Returns the string of activated options.
++NOTE:     This string is used as parameter when calling Normaliz.
++SEE ALSO: setNmzOption
++EXAMPLE:  example showNmzOption; shows an example
++"
++{
++    return(collectNmzOptions());
++}
++example
++{ "EXAMPLE:"; echo=2;
++  setNmzOption("hilb",1);
++  showNmzOptions();
++}
++
++
++static proc runNormaliz(intmat sgr, int nmz_mode, list #)
++{
++    if(!queryInt("nmz_files_keep_switch"))
++    {
++        makeTempNmzDataPath();
++    }
++
++    doWriteNmzData(list(sgr, nmz_mode) + #);
++
++    if(queryInt("nmz_files_keep_switch"))
++    {
++       int dummy=system("sh",setNmzExec()+ collectNmzOptions() + getNmzFile());
++    }
++    else
++    {
++        string gotodir="/tmp";
++        string fname=getNmzFile();
++        fname=fname[6..size(fname)];
++        string exec="cd "+gotodir+" ; ";
++        exec=exec+setNmzExec()+ collectNmzOptions()+" ";
++        exec=exec+fname+" ;";
++        int dummy=system("sh",exec);
++    }
++
++    if(!GenGen) // return input matrix if "gen" has not been generated
++    {
++        if(!queryInt("nmz_files_keep_switch"))
++        {
++            eraseTempNmzDataPath();
++        }
++        return(sgr);
++    }
++    intmat Gen=readNmzData("gen");
++
++    if(!defined(Num_Invs))
++    {
++        list Num_Invs;
++        export Num_Invs;
++    }
++    Num_Invs=getNuminvs();
++
++    if(!queryInt("nmz_files_keep_switch"))
++    {
++        eraseTempNmzDataPath();
++    }
++
++    return(Gen);
++
++}
++
++proc normaliz(intmat sgr,int nmz_mode, list #)
++"USAGE:   normaliz(intmat sgr,int nmz_mode);
++          normaliz(intmat sgr, int nmz_mode, intmat sgr2, int nmz_mode2, ...);
++RETURN:   The function applies Normaliz to the parameter sgr in the mode set
++          by nmz_mode. The function returns the intmat defined by the file
++          with suffix gen.
++
++          It is also possible to give more than one pair of matrix and mode. In
++          this case all matrices and modes are used. This can be used to
++          combine modes 4,5,6.
++          Use nmz_mode=20 to specify a grading.
++NOTE:     You will find procedures for many applications of Normaliz in this
++          library, so the explicit call of this procedure may not be necessary.
++SEE ALSO: intclToricRing, normalToricRing, ehrhartRing, intclMonIdeal,
++          torusInvariants, diagInvariants, finiteDiagInvariants, intersectionValRings,
++             intersectionValRingIdeals
++EXAMPLE:  example normaliz; shows an example
++"
++{
++    return(runNormaliz(sgr,nmz_mode,#));
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R=0,(x,y,z),dp;
++  intmat M[3][2]=3,1,
++                 3,2,
++                 1,3;
++  normaliz(M,1);
++
++  intmat Hyperplanes[2][3] = 2,-1,0, // 2x-y >= 0
++                             1, 1,0; //  x+y >= 0
++  intmat Equation[1][3] = 0,1,-1;    // y = z
++  intmat Congruence[1][4] = 1,0,0,3;  // x = 0 (3)
++  normaliz(Hyperplanes,4,Equation,5,Congruence,6);
++}
++
++
++// retrieving normaliz numerical invariants
++
++static proc getNuminvs()
++{
++    string s;
++    list num_invs;
++    int p,sw,v_length,i,dummy_int;
++    intvec dummy_vec;
++    string type_inv,name_inv,dummy_bool;
++
++    link in_f=":r "+ getNmzFile() + "."+"inv";
++    s=read(in_f);
++
++    p=1;
++    while(p<size(s))
++    {
++        (sw,p)=nextWord(s,p);
++        if(sw==-1)
++        {
++            break;
++        }
++        type_inv=s[sw..p-1];
++        if(type_inv=="vector")
++        {
++            (v_length,p)=getInt(s,p);
++            (sw,p)=nextWord(s,p);
++            name_inv=s[sw..p-1];
++            if(name_inv=="h-vector")
++            {
++                name_inv="h_vector";
++            }
++            if(name_inv!="hilbert_polynomial"
++              && name_inv!="hilbert_quasipolynomial")
++            {
++                for(i=1;i<=v_length;i++)
++                {
++                    if(i==1)
++                    {
++                        (dummy_int,p)=getInt(s,p);
++                        dummy_vec=dummy_int;
++                    }
++                    else
++                    {
++                        (dummy_int,p)=getInt(s,p);
++                        dummy_vec=dummy_vec,dummy_int;
++                    }
++                }
++                num_invs=num_invs+list(list(name_inv,dummy_vec,"intvec"));
++            }
++            else
++            {
++                p=skipEqualsign(s,p);
++            }
++        }
++        if(type_inv=="integer")
++        {
++            (sw,p)=nextWord(s,p);
++            name_inv=s[sw..p-1];
++            if (name_inv!="hilbert_quasipolynomial_denom") {
++              (dummy_int,p)=getInt(s,p);
++              num_invs=num_invs+list(list(name_inv,dummy_int,"int"));
++            }
++        }
++        if(type_inv=="boolean")
++        {
++            (sw,p)=nextWord(s,p);
++            name_inv=s[sw..p-1];
++            p=skipEqualsign(s,p);
++            (sw,p)=nextWord(s,p);
++            dummy_bool=s[sw..p-1];
++            dummy_int=0;
++            if(dummy_bool=="true")
++            {
++                dummy_int=1;
++            }
++            num_invs=num_invs+list(list(name_inv,dummy_int,"int"));
++        }
++    }
++    return(num_invs);
++}
++
++proc showNuminvs()
++"USAGE:   showNuminvs();
++PURPOSE:  prints the numerical invariants
++SEE ALSO: exportNuminvs
++EXAMPLE:  example showNuminvs(); shows an example
++"
++{
++    list dummy;
++    int i;
++    for(i=1;i<=size(Num_Invs);i++)
++    {
++        dummy=Num_Invs[i];
++        dummy[1],":", dummy[2];
++    }
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R=0,(x,y,z,t),dp;
++  ideal I=x3,x2y,y3;
++  list l=intclMonIdeal(I);
++  showNuminvs();
++}
++
++
++proc exportNuminvs()
++"USAGE:   exportNuminvs();
++CREATE:   Creates top-level variables which contain the numerical invariants.
++          Depending on the options of normaliz different invariants are
++          calculated. Use showNuminvs (@ref{showNuminvs}) to see which
++          invariants are available.
++SEE ALSO: showNuminvs
++EXAMPLE:  example exportNuminvs; shows an example
++"
++{
++    list dummy;
++    int i;
++    string s;
++    for(i=1;i<=size(Num_Invs);i++)
++    {
++        dummy=Num_Invs[i];
++        s=dummy[3]+" nmz_" + dummy[1] + "=dummy[2]; exportto(Top," + "nmz_" + dummy[1] + ");";
++        execute(s);
++    }
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R=0,(x,y,z,t),dp;
++  ideal I=x3,x2y,y3;
++  list l=intclMonIdeal(I);
++  exportNuminvs();
++  // now the following variables are set:
++  nmz_hilbert_basis_elements;
++  nmz_number_extreme_rays;
++  nmz_rank;
++  nmz_index;
++  nmz_number_support_hyperplanes;
++  nmz_size_triangulation;
++  nmz_sum_dets;
++  nmz_graded;
++  nmz_degree_1_elements;
++  nmz_grading;
++  nmz_grading_denom;
++  nmz_multiplicity;
++  nmz_multiplicity_denom;
++  nmz_hilbert_series_num;
++  nmz_hilbert_series_denom;
++  nmz_primary;
++}
++
++
++// intmats to/from monomials
++
++proc mons2intmat(ideal I)
++"USAGE:   mons2intmat(ideal I);
++RETURN:   Returns the intmat whose rows represent the leading exponents of the
++          (non-zero) elements of I. The length of each row is nvars(basering).
++SEE ALSO: intmat2mons
++EXAMPLE:  example mons2intmat; shows an example"
++{
++    int i,j,k;
++    intmat expo_vecs[size(I)][nvars(basering)];
++    intvec expo_v;
++
++    k=0;
++    for(i=1;i<=ncols(I);i++)
++    {
++        if(I[i]!=0)
++        {
++            k++;
++            expo_v=leadexp(I[i]);
++            for(j=1;j<=nvars(basering);j++)
++            {
++                expo_vecs[k,j]=expo_v[j];
++            }
++        }
++    }
++    return(expo_vecs);
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R=0,(x,y,z),dp;
++  ideal I=x2,y2,x2yz3;
++  mons2intmat(I);
++}
++
++proc intmat2mons(intmat expo_vecs)
++"USAGE:   intmat2mons(intmat M);
++RETURN:   an ideal generated by the monomials which correspond to the exponent
++          vectors given by the rows of @code{M}
++NOTE:     The number of variables in the basering @code{nvars(basering)} has to
++          be at least the number of columns @code{ncols(M)}, otherwise the
++          function exits with an error.
++          is thrown (see @ref{ERROR}).
++SEE ALSO: mons2intmat
++EXAMPLE:  example intmat2mons; shows an example
++"
++{
++    int i,j;
++    poly m;
++    ideal mons;
++
++    if(nvars(basering)<ncols(expo_vecs))
++    {
++        ERROR("intmat2mons: not enough variables in ring");
++    }
++
++    for(i=1;i<=nrows(expo_vecs);i++)
++    {
++        m=1;
++        for(j=1;j<=ncols(expo_vecs);j++)
++        {
++            m=m*var(j)^expo_vecs[i,j];
++        }
++        mons=mons,m;
++    }
++     mons=simplify(mons,2);    // get rid of starting 0
++     return(mons);
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R=0,(x,y,z),dp;
++  intmat expo_vecs[3][3] =
++  2,0,0,
++  0,2,0,
++  2,1,3;
++  intmat2mons(expo_vecs);
++}
++
++static proc intmat2monsSel(intmat expo_vecs, int d)
++{
++    int i,j;
++    poly m;
++    ideal mons;
++
++    if(nvars(basering)<ncols(expo_vecs)-1)
++    {
++        ERROR("intmat2monsSel: not enough variables in ring");
++    }
++
++    for(i=1;i<=nrows(expo_vecs);i++)
++    {
++        if(expo_vecs[i,ncols(expo_vecs)]==d)
++        {
++
++            m=1;
++            for(j=1;j<=ncols(expo_vecs)-1;j++)
++            {
++                m=m*var(j)^expo_vecs[i,j];
++            }
++            mons=mons,m;
++        }
++    }
++     mons=simplify(mons,2);    // get rid of starting 0
++     return(mons);
++}
++
++
++proc binomials2intmat(ideal I)
++"USAGE:   binomials2intmat(ideal I);
++RETURN:   Returns the intmat whose rows represent the exponents of the
++          (non-zero) elements of I which have to be binomials.
++          The length of each row is nvars(basering).
++SEE ALSO: mons2intmat, intmat2mons
++EXAMPLE:  example binomials2intmat; shows an example"
++{
++    int i,j,k;
++    intmat expo_vecs[size(I)][nvars(basering)];
++    intvec expo_v;
++
++    k=0;
++    poly f;
++
++    for(i=1; i<=ncols(I); i++)     {
++        if( I[i] != 0 ) {
++            k++;
++            f = I[i];
++            if (leadcoef(f) != 1) {f = -f};  //works in all characteristics
++            if (size(f)!=2 || leadcoef(f)!=1 || leadcoef(f[2])!=-1) {
++                ERROR(string("normalToricRing: binomial ideal expected: generator ",i,": ",I[i]));
++            }
++
++            expo_v = leadexp(f)-leadexp(f[2]);
++            for(j=1;j<=nvars(basering);j++) {
++                expo_vecs[k,j]=expo_v[j];
++            }
++        }
++    }
++    return(expo_vecs);
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring S = 37,(u,v,w,x,y,z),dp;
++  ideal I = u2v-xyz, ux2-vyz, uvw-y2z;
++  binomials2intmat(I);
++}
++
++
++// integral closure of rings and ideals
++
++static proc runIntclToricRing(ideal I, int nmz_mode, list #)
++{
++    intmat expo_vecs=mons2intmat(I);
++
++    string dummy=collectNmzOptions(); // only to set GenGen
++    return( intmat2mons( runNormaliz(expo_vecs,nmz_mode, prepareGrading(#)) ) );
++}
++
++proc intclToricRing(ideal I, list #)
++"USAGE:   intclToricRing(ideal I);
++          intclToricRing(ideal I, intvec grading);
++RETURN:   The toric ring S is the subalgebra of the basering generated by
++          the leading monomials of the elements of I (considered as a list
++          of polynomials). The function computes the integral
++          closure T of S in the basering and returns an ideal listing
++          the algebra generators of T over the coefficient field.
++@*        The function returns the input ideal I if one of the options
++          @code{supp}, @code{triang}, @code{volume}, or @code{hseries}
++          has been activated.
++          However, in this case some numerical invariants are computed, and
++          some other data may be contained in files that you can read into
++          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
++NOTE:     A mathematical remark: the toric ring depends on the list of
++          monomials given, and not only on the ideal they generate!
++SEE ALSO:  normalToricRing, ehrhartRing, intclMonIdeal
++EXAMPLE:   example intclToricRing; shows an example
++"
++{
++    return(runIntclToricRing(I,0,#));
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R=37,(x,y,t),dp;
++  ideal I=x3,x2y,y3;
++  intclToricRing(I);
++  showNuminvs();
++  //now the same example with another grading
++  intvec grading = 2,3,1;
++  intclToricRing(I,grading);
++  showNuminvs();
++
++}
++
++proc normalToricRing(ideal I, list #)
++"USAGE:   normalToricRing(ideal I);
++          normalToricRing(ideal I, intvec grading);
++RETURN:   The toric ring S is the subalgebra of the basering generated by the
++          leading monomials of the elements of I (considered as a list of
++          polynomials). The function computes the
++          normalisation T of S and returns an ideal listing the algebra
++          generators of T over the coefficient field.
++@*        The function returns the input ideal I if one of the options
++          @code{supp}, @code{triang}, @code{volume}, or @code{hseries}
++          has been activated.
++          However, in this case some numerical invariants are computed, and
++          some other data may be contained in files that you can read into
++          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
++NOTE:     A mathematical remark: the toric ring depends on the list of
++          monomials given, and not only on the ideal they generate!
++SEE ALSO: intclToricRing, ehrhartRing, intclMonIdeal, normalToricRingFromBinomials
++EXAMPLE:  example normalToricRing; shows an example
++"
++{
++    return(runIntclToricRing(I,1,#));
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring  R = 37,(x,y,t),dp;
++  ideal I = x3,x2y,y3;
++  normalToricRing(I);
++}
++
++
++proc normalToricRingFromBinomials(ideal I, list #)
++"USAGE:   normalToricRingFromBinomials(ideal I);
++          normalToricRingFromBinomials(ideal I, intvec grading);
++RETURN:   @texinfo
++ at tex
++The ideal $I$ is generated by binomials of type $X^a-X^b$ (multiindex notation)
++in the surrounding polynomial ring $K[X]=K[X_1,...,X_n]$. The binomials
++represent a congruence on the monoid ${Z}^n$ with residue monoid $M$.
++Let $N$ be the image of $M$ in gp($M$)/torsion. Then $N$ is universal in the
++sense that every homomorphism from $M$ to an affine monoid factors through $N$.
++If $I$ is a prime ideal, then $K[N]= K[X]/I$. In general, $K[N]=K[X]/P$ where
++$P$ is the unique minimal prime ideal of $I$ generated by binomials of type
++$X^a-X^b$.
++
++The function computes the normalization of $K[N]$ and returns a newly created
++polynomial ring of the same Krull dimension, whose variables are
++$x(1),...,x(n-r)$, where $r$ is the rank of the matrix with rows $a-b$.
++(In general there is no canonical choice for such an embedding.)
++Inside this polynomial ring there is an ideal $I$ which lists the algebra
++generators of the normalization of $K[N]$.
++ at end tex
++ at end texinfo
++@*        The function returns the input ideal I if one of the options
++          @code{supp}, @code{triang}, @code{volume}, or @code{hseries}
++          has been activated.
++          However, in this case some numerical invariants are computed, and
++          some other data may be contained in files that you can read into
++          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
++SEE ALSO: intclToricRing, normalToricRing, ehrhartRing, intclMonIdeal
++EXAMPLE:  example normalToricRing; shows an example
++"
++{
++    intmat expo_vecs = binomials2intmat(I);
++    string dummy=collectNmzOptions(); // only to set GenGen
++    intmat result = runNormaliz(expo_vecs,10,prepareGrading(#));
++
++    list baseringlist = ringlist(basering);
++    ring S = (baseringlist[1]),(x(1..ncols(result))),dp;
++    ideal I = intmat2mons(result);
++    export(I);
++    return (S);
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R = 37,(u,v,w,x,y,z),dp;
++  ideal I = u2v-xyz, ux2-wyz, uvw-y2z;
++  def S = normalToricRingFromBinomials(I);
++  setring S;
++  I;
++}
++
++static proc runIntclMonIdeal(ideal I, int nmz_mode, list #)
++{
++    intmat expo_vecs=mons2intmat(I);
++    int i,last_comp;
++
++    // we test if there is room for the Rees algebra
++
++    for(i=1;i<=nrows(expo_vecs);i++)
++    {
++        if(expo_vecs[i,ncols(expo_vecs)]!=0)
++        {
++            last_comp=1;  break; // no
++        }
++    }
++
++    string dummy=collectNmzOptions(); // only to set GenGen
++
++    //adjust size of input matrix
++    if (!last_comp) { // remove last component
++        intmat tmp[nrows(expo_vecs)][ncols(expo_vecs)-1]
++               = expo_vecs[1..nrows(expo_vecs),1..(ncols(expo_vecs)-1)];
++        expo_vecs = tmp;
++    }
++    intmat nmz_data=runNormaliz(expo_vecs,nmz_mode,prepareGrading(#));
++
++    if(last_comp)
++    {
++        ideal I1=intmat2monsSel(nmz_data,1);
++        return(list(I1));
++    }
++    else
++    {
++        ideal I1=intmat2monsSel(nmz_data,1);
++        ideal I2=intmat2mons(nmz_data);
++        return(list(I1,I2));
++    }
++}
++
++proc ehrhartRing(ideal I)
++"USAGE:    ehrhartRing(ideal I);
++RETURN:    The exponent vectors of the leading monomials of the elements of I
++           are considered as points of a lattice polytope P.
++           The Ehrhart ring of a (lattice) polytope P is the monoid algebra
++           defined by the monoid of lattice points in the cone over the
++           polytope P; see Bruns and Gubeladze, Polytopes, Rings, and K-theory,
++           Springer 2009, pp. 228, 229.
++           The function returns a list of ideals:
++@*         (i) If the last ring variable is not used by the monomials, it is
++               treated as the auxiliary variable of the Ehrhart ring. The
++               function returns two ideals, the first containing the monomials
++               representing all the lattice points of the polytope, the second
++               containing the algebra generators of the Ehrhart ring over the
++               coefficient field.
++@*         (ii) If the last ring variable is used by the monomials, the list
++                returned contains only one ideal, namely the monomials
++                representing the lattice points of the polytope.
++@*
++@*        The function returns the a list containing the input ideal I if one
++          of the options @code{supp}, @code{triang}, @code{volume}, or
++          @code{hseries} has been activated.
++          However, in this case some numerical invariants are computed, and
++          some other data may be contained in files that you can read into
++          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
++NOTE:      A mathematical remark: the Ehrhart ring depends on the list of
++           monomials given, and not only on the ideal they generate!
++SEE ALSO: intclToricRing, normalToricRing, intclMonIdeal
++EXAMPLE:  example ehrhartRing; shows an example
++"
++{
++    return(runIntclMonIdeal(I,2));
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R=37,(x,y,t),dp;
++  ideal J=x3,x2y,y3,xy2t7;
++  ehrhartRing(J);
++}
++
++proc intclMonIdeal(ideal I, list #)
++"USAGE:   intclMonIdeal(ideal I);
++          intclMonIdeal(ideal I, intvec grading);
++RETURN:   The exponent vectors of the leading monomials of the elements of I
++          are considered as generators of a monomial ideal for which the
++          normalization of its Rees algebra is computed. For a Definiton of the
++          Rees algebra (or Rees ring) see Bruns and Herzog, Cohen-Macaulay
++          rings, Cambridge University Press 1998, p. 182.
++          The function returns a list of ideals:
++@* (i) If the last ring variable is not used by the monomials, it is treated
++       as the auxiliary variable of the Rees algebra. The function returns two
++       ideals, the first containing the monomials generating the integral
++       closure of the monomial ideal, the second containing the algebra
++         generators of the normalization of the Rees algebra.
++@* (ii) If the last ring variable is used by the monomials, the list returned
++        contains only one ideal, namely the monomials generating the integral
++        closure of the ideal.
++@*        The function returns the a list containing the input ideal I if one
++          of the options @code{supp}, @code{triang}, @code{volume}, or
++          @code{hseries} has been activated.
++          However, in this case some numerical invariants are computed, and
++          some other data may be contained in files that you can read into
++          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
++SEE ALSO: intclToricRing, normalToricRing, ehrhartRing
++EXAMPLE:  example intclMonIdeal; shows an example
++"
++{
++    return(runIntclMonIdeal(I,3,#));
++}
++example
++{ "EXAMPLE"; echo=2;
++    ring R=0,(x,y,z,t),dp;
++    ideal I=x^2,y^2,z^3;
++    list l=intclMonIdeal(I);
++    l[1]; // integral closure of I
++    l[2];  // monomials generating the integral closure of the Rees algebra
++}
++
++// torus invariants and valuation rings and ideals
++
++proc torusInvariants(intmat E, list #)
++"USAGE:   torusInvariants(intmat A);
++          torusInvariants(intmat A, intvec grading);
++RETURN:   @texinfo
++Returns an ideal representing the list of monomials generating the ring of
++invariants as an algebra over the coefficient field.
++ at tex
++$R^T$.
++ at end tex
++@*        The function returns the ideal given by the input matrix A if one of
++          the options @code{supp}, @code{triang}, @code{volume}, or
++          @code{hseries} has been activated.
++          However, in this case some numerical invariants are computed, and
++          some other data may be contained in files that you can read into
++          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
++ at end texinfo
++BACKGROUND: @texinfo
++ at tex
++ Let $T = (K^*)^r$ be the $r$-dimensional torus acting on the polynomial ring
++ $R = K[X_1 ,\ldots,X_n]$ diagonally. Such an action can be described as
++ follows: there are integers $a_{i,j}$, $i=1,\ldots,r$, $j=1,\ldots,n$, such
++ that $(\lambda_1,\ldots,\lambda_r)\in T$ acts by the substitution
++$$ X_j \mapsto \lambda_1^{a_{1,j}} \cdots \lambda_r^{a_{r,j}}X_j,
++   \quad j=1,\ldots,n.$$
++In order to compute the ring of invariants $R^T$ one must specify the matrix
++$A=(a_{i,j})$.
++ at end tex
++ at end texinfo
++SEE ALSO: diagInvariants, finiteDiagInvariants, intersectionValRings,
++          intersectionValRingIdeals
++EXAMPLE:  example torusInvariants; shows an example
++"
++{
++    if(nvars(basering)!=ncols(E))
++    {
++        ERROR("torusInvariants: wrong number of columns in matrix");
++    }
++
++    string dummy=collectNmzOptions();  // only to set GenGen
++
++    return( intmat2mons( runNormaliz(E,5,prepareGrading(#)) ) );
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R=0,(x,y,z,w),dp;
++  intmat E[2][4] = -1,-1,2,0, 1,1,-2,-1;
++  torusInvariants(E);
++}
++
++proc finiteDiagInvariants(intmat C, list #)
++"USAGE:   finiteDiagInvariants(intmat U);
++          finiteDiagInvariants(intmat U, intvec grading);
++RETURN:   @texinfo
++ at tex
++This function computes the ring of invariants of a finite abelian group $G$
++acting diagonally on the surrounding polynomial ring $K[X_1,...,X_n]$. The
++group is the direct product of cyclic groups generated by finitely many
++elements $g_1,...,g_w$. The element $g_i$ acts on the indeterminate $X_j$ by
++$g_i(X_j)=\lambda_i^{u_{ij}}X_j$ where $\lambda_i$ is a primitive root of
++unity of order equal to $ord(g_i)$. The ring of invariants is generated by all
++monomials satisfying the system
++$u_{i1}a_1+\ldots+u_{in} a_n \equiv 0$ mod ord$(g_i)$, $i=1,\ldots,w$.
++The input to the function is the $w\times(n+1)$ matrix $U$ with rows
++$u_{i1}\ldots u_{in}$ ord$(gi)$, $i=1,\ldots,w$. The output is a monomial ideal
++listing the algebra generators of the subalgebra of invariants
++{$R^G=\{f\in R : g_i f = f$ for all $i=1,\ldots,w\}$}.
++ at end tex
++ at end texinfo
++@*        The function returns the ideal given by the input matrix C if one of
++          the options @code{supp}, @code{triang}, @code{volume}, or
++          @code{hseries} has been activated.
++          However, in this case some numerical invariants are computed, and
++          some other data may be contained in files that you can read into
++          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
++NOTE:
++SEE ALSO: torusInvariants, diagInvariants, intersectionValRings,
++          intersectionValRingIdeals
++EXAMPLE:  example finiteDiagInvariants; shows an example
++"
++{
++    if(nvars(basering)!=ncols(C)-1)
++    {
++        ERROR("finiteDiagInvariants: wrong number of columns in matrix");
++    }
++
++    string dummy=collectNmzOptions();  // only to set GenGen
++
++    return( intmat2mons( runNormaliz(C,6,prepareGrading(#)) ) );
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R = 0,(x,y,z,w),dp;
++  intmat C[2][5] = 1,1,1,1,5, 1,0,2,0,7;
++  finiteDiagInvariants(C);
++}
++
++proc diagInvariants(intmat E, intmat C, list #)
++"USAGE:   diagInvariants(intmat A, intmat U);
++          diagInvariants(intmat A, intmat U, intvec grading);
++RETURN:   @texinfo
++ at tex
++This function computes the ring of invariants of a diagonalizable group
++$D = T\times G$ where $T$ is a torus and $G$ is a finite abelian group, both
++acting diagonally on the polynomial ring $K[X_1,\ldots,X_n]$. The group
++actions are specified by the input matrices A and U. The first matrix specifies
++the torus action, the second the action of the finite group. See
++torusInvariants and finiteDiagInvariants for more detail. The output is a
++monomial ideal listing the algebra generators of the subalgebra of invariants.
++ at end tex
++ at end texinfo
++@*        The function returns the ideal given by the input matrix A if one of
++          the options @code{supp}, @code{triang}, @code{volume}, or
++          @code{hseries} has been activated.
++          However, in this case some numerical invariants are computed, and
++          some other data may be contained in files that you can read into
++          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
++SEE ALSO: torusInvariants, finiteDiagInvariants, intersectionValRings, intersectionValRingIdeals
++EXAMPLE:  example diagInvariants; shows an example
++"
++{
++    if(nvars(basering)!=ncols(E) || nvars(basering)!=ncols(C)-1)
++    {
++        ERROR("diagInvariants: wrong number of columns in matrix");
++    }
++
++    string dummy=collectNmzOptions();  // only to set GenGen
++
++    return( intmat2mons( runNormaliz(E,5,C,6,prepareGrading(#)) ) );
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R=0,(x,y,z,w),dp;
++  intmat E[2][4] = -1,-1,2,0, 1,1,-2,-1;
++  intmat C[2][5] = 1,1,1,1,5, 1,0,2,0,7;
++  diagInvariants(E,C);
++}
++
++proc intersectionValRings(intmat V, list #)
++"USAGE:   intersectionValRings(intmat V, intvec grading);
++RETURN:   The function returns a monomial ideal, to be considered as the list
++          of monomials generating @math{S} as an algebra over the coefficient
++          field.
++BACKGROUND: @texinfo
++ at tex
++A discrete monomial valuation $v$ on $R = K[X_1 ,\ldots,X_n]$ is determined by
++the values $v(X_j)$ of the indeterminates. This function computes the
++subalgebra $S = \{ f \in R : v_i ( f ) \geq 0,\ i = 1,\ldots,r\}$ for several
++such valuations $v_i$, $i=1,\ldots,r$. It needs the matrix $V = (v_i(X_j))$ as
++its input.
++ at end tex
++ at end texinfo
++@*        The function returns the ideal given by the input matrix V if one of
++          the options @code{supp}, @code{triang}, @code{volume}, or
++          @code{hseries} has been activated.
++          However, in this case some numerical invariants are computed, and
++          some other data may be contained in files that you can read into
++          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
++SEE ALSO: torusInvariants, diagInvariants, finiteDiagInvariants, intersectionValRingIdeals
++EXAMPLE:  example intersectionValRings; shows an example
++"
++{
++
++    if(nvars(basering)!=ncols(V))
++    {
++        ERROR("intersectionValRings: wrong number of columns in matrix");
++    }
++
++    intmat V1[nrows(V)+ncols(V)][ncols(V)];
++    int i,j;
++
++    for(i=1;i<=ncols(V);i++)
++    {
++        V1[i,i]=1;
++    }
++    for(i=1;i<=nrows(V);i++)
++    {
++        for(j=1;j<=ncols(V);j++)
++        {
++            V1[i+ncols(V),j]=V[i,j];
++        }
++    }
++
++
++    string dummy=collectNmzOptions();  // only to set GenGen
++
++/*    if(!GenGen) // return V
++    {
++        runNormaliz(V1,4,prepareGrading(#));
++        return(V);
++    }
++*/
++    return(intmat2mons(runNormaliz(V1,4,prepareGrading(#))));
++}
++example
++{ "EXAMPLE:"; echo=2;
++  ring R=0,(x,y,z,w),dp;
++  intmat V0[2][4]=0,1,2,3, -1,1,2,1;
++  intersectionValRings(V0);
++}
++
++proc intersectionValRingIdeals(intmat V, list #)
++"USAGE:   intersectionValRingIdeals(intmat V);
++          intersectionValRingIdeals(intmat V, intvec grading);
++RETURN:   The function returns two ideals, both to be considered as lists of
++          monomials. The
++          first is the system of monomial generators of @math{S}, the second
++          the system of generators of @math{M}.
++@*        The function returns a list consisting of the ideal given by the
++          input matrix T if one of the options @code{supp}, @code{triang}, or
++          @code{hvect} has been activated.
++          However, in this case some numerical invariants are computed, and
++          some other data may be contained in files that you can read into
++          Singular (see @ref{showNuminvs}, @ref{exportNuminvs}).
++BACKGROUND: @texinfo
++ at tex
++A discrete monomial valuation $v$ on $R = K[X_1 ,\ldots,X_n]$ is determined by
++the values $v(X_j)$ of the indeterminates. This function computes the
++subalgebra $S = \{ f \in R : v_i ( f ) \geq 0,\ i = 1,\ldots,r\}$ for several
++such valuations $v_i$, $i=1,\ldots,r$. It needs the matrix $V = (v_i(X_j))$ as
++its input.
++
++This function simultaneously determines the $S$-submodule
++$M = \{ f \in R : v_i(f) \geq w_i ,\ i = 1,\ldots,r\}$ for integers
++$w_1,\ldots\,w_r$. (If $w_i \geq 0$ for all $i$, $M$ is an ideal of $S$.)
++The numbers $w_i$ form the $(n+1)$th column of the input matrix.
++ at end tex
++ at end texinfo
++NOTE:   The function also gives an error message if the matrix V has the
++        wrong number of columns.
++SEE ALSO: torusInvariants, diagInvariants, finiteDiagInvariants, intersectionValRings
++EXAMPLE:  example intersectionValRingIdeals; shows an example
++"
++{
++    if(nvars(basering)!=ncols(V)-1)
++    {
++        ERROR("intersectionValRingIdeals: wrong number of columns in matrix");
++    }
++
++    intmat V1[nrows(V)+ncols(V)][ncols(V)];
++    int i,j;
++
++    for(i=1;i<=ncols(V);i++)
++    {
++        V1[i,i]=1;
++    }
++    for(i=1;i<=nrows(V);i++)
++    {
++        for(j=1;j<=ncols(V);j++)
++        {
++            V1[i+ncols(V),j]=V[i,j];
++        }
++    }
++    for(i=1;i<=nrows(V);i++)
++    {
++        V1[i+ncols(V),ncols(V)]=-V1[i+ncols(V),ncols(V)];
++    }
++
++    string dummy=collectNmzOptions();  // only to set GenGen
++
++    intmat nmz_data=runNormaliz(V1,4,prepareGrading(#));
++
++    ideal I1=intmat2monsSel(nmz_data,0);
++    ideal I2=intmat2monsSel(nmz_data,1);
++    return(list(I1,I2));
++}
++example
++{ "EXAMPLE:"; echo=2;
++ ring R=0,(x,y,z,w),dp;
++ intmat V[2][5]=0,1,2,3,4, -1,1,2,1,3;
++ intersectionValRingIdeals(V);
++}
diff --git a/debian/patches/upstream-dump4help2man.patch b/debian/patches/upstream-dump4help2man.patch
new file mode 100644
index 0000000..cc1dff8
--- /dev/null
+++ b/debian/patches/upstream-dump4help2man.patch
@@ -0,0 +1,90 @@
+Description: version tuple dump option
+ Add a --dump-versiontuple long hidden option (that literaly dump
+ Singular version) to Singular front-end programs in view to employ
+ help2man to generate manpages; meant to be submitted to the upstream
+ maintainer.
+Origin: debian
+Forwarded: yes (in progress)
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-23
+
+--- a/Singular/feOptTab.h
++++ b/Singular/feOptTab.h
+@@ -149,7 +149,10 @@
+    "LINK",     "Use LINK for connections",                             feOptString,    0,   0},
+ 
+   {"ticks-per-sec",     required_argument,  LONG_OPTION_RETURN,
+-   "TICKS",     "Sets unit of timer to TICKS per second",               feOptInt,    (void*)1,      0},
++   "TICKS",    "Sets unit of timer to TICKS per second",               feOptInt,    (void*)1,      0},
++
++  {"dump-versiontuple",       no_argument,  LONG_OPTION_RETURN,
++   0,          "//Display the version-tuple and exit",  feOptUntyped,    0,      0},
+ 
+ // terminator -- do NOT remove
+   { 0, 0, 0, 0, 0, feOptInt, 0, 0}
+--- a/Singular/feOpt.cc
++++ b/Singular/feOpt.cc
+@@ -302,6 +302,12 @@
+         return NULL;
+       }
+ 
++      case FE_OPT_DUMP_VERSIONTUPLE:
++      {
++        feOptDumpVersionTuple();
++        return NULL;
++      }
++
+       default:
+         return NULL;
+   }
+@@ -394,6 +400,9 @@
+   printf("Singular manual (available as on-line info or html manual).\n");
+ }
+ 
+-
++void feOptDumpVersionTuple(void)
++{
++  printf("%s\n",VERSION);
++}
+ 
+ #endif // GENERATE_OPTION_INDEX
+--- a/Singular/feOpt.h
++++ b/Singular/feOpt.h
+@@ -33,6 +33,7 @@
+ 
+ 
+ void feOptHelp(const char* name);
++void feOptDumpVersionTuple(void);
+ 
+ #ifdef __cplusplus
+ 
+--- a/Singular/tesths.cc
++++ b/Singular/tesths.cc
+@@ -115,6 +115,13 @@
+       exit(1);
+     }
+     if (optc == 'h') exit(0);
++    switch(option_index)
++    {
++      case FE_OPT_DUMP_VERSIONTUPLE:
++        exit(0);
++        break;
++      default: ;
++    }
+   }
+ 
+   /* say hello */
+--- a/Singular/emacs.cc
++++ b/Singular/emacs.cc
+@@ -170,6 +170,11 @@
+                 no_emacs_call = 1;
+                 break;
+ 
++              case FE_OPT_DUMP_VERSIONTUPLE:
++                feOptDumpVersionTuple();
++                exit(0);
++                break;
++
+               default:
+                 goto NEXT;
+           }
diff --git a/debian/patches/upstream-fix-autotools-CPPFLAGS_overwrite.patch b/debian/patches/upstream-fix-autotools-CPPFLAGS_overwrite.patch
new file mode 100644
index 0000000..b6e1ac3
--- /dev/null
+++ b/debian/patches/upstream-fix-autotools-CPPFLAGS_overwrite.patch
@@ -0,0 +1,19 @@
+Description: autotools: fix CPPFLAGS overwrite
+ Fix CPPFLAGS overwrite issue observed in omalloc package.
+ This patch is meant to be submitted to the upstream maintainer.
+Origin: debian
+Forwarded: yes (in progress)
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2015-01-02
+
+--- a/omalloc/configure.ac
++++ b/omalloc/configure.ac
+@@ -98,7 +98,7 @@
+ dnl  ac_cflags_set=no
+ dnl fi
+ 
+-CPPFLAGS="-I.. -I."
++CPPFLAGS="-I.. -I. $CPPFLAGS"
+ AC_PROG_MAKE_SET
+ AC_PROG_CC
+ AC_PROG_CPP
diff --git a/debian/patches/upstream-source-typo.patch b/debian/patches/upstream-source-typo.patch
new file mode 100644
index 0000000..883aa13
--- /dev/null
+++ b/debian/patches/upstream-source-typo.patch
@@ -0,0 +1,334 @@
+Description: source typo
+ Correct spelling error as reported by lintian in some binraries;
+ meant to silence lintian and eventually to be submitted to the
+ upstream maintainer.
+Origin: debian
+Forwarded: yes (in progress)
+Author: Jerome Benoit <calculus at rezozer.net>
+Last-Update: 2014-12-20
+
+Comment: spelling-error-in-binary
+
+--- a/Singular/fevoices.cc
++++ b/Singular/fevoices.cc
+@@ -87,7 +87,7 @@
+ }
+ 
+ /*2
+-* init a new voice similiar to the current
++* init a new voice similar to the current
+ */
+ void Voice::Next()
+ {
+--- a/Singular/ipassign.cc
++++ b/Singular/ipassign.cc
+@@ -1688,7 +1688,7 @@
+       }
+       if(like_lists)
+       {
+-        if (traceit&TRACE_ASSIGN) PrintS("assign list[..]=...or similiar\n");
++        if (traceit&TRACE_ASSIGN) PrintS("assign list[..]=...or similar\n");
+         if (like_lists==1)
+         {
+           // check blackbox/newtype type:
+@@ -1724,7 +1724,7 @@
+ #endif
+       return (bb==NULL) || bb->blackbox_Assign(l,r);
+     }
+-    // end of handling elems of list and similiar
++    // end of handling elems of list and similar
+     rl=r->listLength();
+     if (rl==1)
+     {
+--- a/libpolys/polys/templates/p_Procs_Impl.h
++++ b/libpolys/polys/templates/p_Procs_Impl.h
+@@ -30,8 +30,8 @@
+  the p_*_Templates.cc and header files which provide the respective
+  macros.
+ 
+- At run-time, a fast proc is set/choosen if found/generated, else
+- a general proc is set/choosen.
++ At run-time, a fast proc is set/chosen if found/generated, else
++ a general proc is set/chosen.
+  *******************************************************************/
+ 
+ // Define HAVE_FAST_P_PROCS to:
+@@ -395,7 +395,7 @@
+ /***************************************************************
+  *
+  * Filters which are applied to field/length/ord, before a proc is
+- * choosen
++ * chosen
+  *
+  *******************************************************************/
+ #ifdef p_Procs_Static
+--- a/Singular/LIB/normal.lib
++++ b/Singular/LIB/normal.lib
+@@ -185,7 +185,7 @@
+   {
+     if ( typeof(#[i]) == "string" )
+     {
+-//--------------------------- choosen methods -----------------------
++//--------------------------- chosen methods -----------------------
+       if ( (#[i]=="isprim") or (#[i]=="isPrim") )
+       {decomp = 0;}
+ 
+@@ -5722,7 +5722,7 @@
+      }
+    }
+ 
+-   //--------------------------- choosen methods -----------------------
++   //--------------------------- chosen methods -----------------------
+    // "withGens": computes algebra generators for each irreducible component
+    // ### the extra code for withGens should be incorporated in the general case
+ 
+--- a/Singular/LIB/grobcov.lib
++++ b/Singular/LIB/grobcov.lib
+@@ -2890,7 +2890,7 @@
+ // Output: S=(w_1,..,w_j)
+ //    where the w_l=(n_l1,..,n_ls) are intvec of length size(L), where
+ //    n_lt fixes which element of (v_t1,..,v_tk_t) is to be
+-//    choosen to form the tth (Q,P) for the lth element of the sheaf
++//    chosen to form the tth (Q,P) for the lth element of the sheaf
+ //    representing the I-regular function.
+ // The selection is done to obtian the minimal number of elements
+ //    of the sheaf that specializes to non-null everywhere.
+--- a/kernel/GBEngine/kstd1.cc
++++ b/kernel/GBEngine/kstd1.cc
+@@ -2896,7 +2896,7 @@
+         message(strat->P.pFDeg(),
+                 &olddeg,&reduc,strat, red_result);
+ 
+-      /* reduction of the element choosen from L */
++      /* reduction of the element chosen from L */
+       red_result = strat->red(&strat->P,strat);
+     }
+ 
+--- a/kernel/GBEngine/kstd2.cc
++++ b/kernel/GBEngine/kstd2.cc
+@@ -1472,7 +1472,7 @@
+         message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
+                 &olddeg,&reduc,strat, red_result);
+ 
+-      /* reduction of the element choosen from L */
++      /* reduction of the element chosen from L */
+       red_result = strat->red(&strat->P,strat);
+       if (errorreported)  break;
+     }
+@@ -1835,7 +1835,7 @@
+     /* picks the last element from the lazyset L */
+     strat->P = strat->L[strat->Ll];
+     strat->Ll--;
+-    /* reduction of the element choosen from L */
++    /* reduction of the element chosen from L */
+ 
+     if (!strat->rewCrit2(strat->P.sig, ~strat->P.sevSig, strat->P.GetLmCurrRing(), strat, strat->P.checked+1)) {
+       //#if 1
+@@ -2676,7 +2676,7 @@
+       Print("Poly before red: ");
+       pWrite(strat->P.p);
+ #endif
+-      /* complete reduction of the element choosen from L */
++      /* complete reduction of the element chosen from L */
+       red_result = strat->red2(&strat->P,strat);
+       if (errorreported)  break;
+     }
+@@ -3011,7 +3011,7 @@
+         message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
+                 &olddeg,&reduc,strat, red_result);
+ 
+-      /* reduction of the element choosen from L */
++      /* reduction of the element chosen from L */
+       red_result = strat->red(&strat->P,strat);
+     }
+ 
+--- a/kernel/GBEngine/kstdfac.cc
++++ b/kernel/GBEngine/kstdfac.cc
+@@ -588,7 +588,7 @@
+       if (TEST_OPT_PROT)
+         message(currRing->pFDeg(strat->P.p,currRing),&olddeg,&reduc,strat, red_result);
+     }
+-    /* reduction of the element choosen from L */
++    /* reduction of the element chosen from L */
+     kTest_TS(strat);
+     red_result = strat->red(&strat->P,strat);
+     if (strat->P.p != NULL)
+--- a/kernel/GBEngine/sca.cc
++++ b/kernel/GBEngine/sca.cc
+@@ -614,7 +614,7 @@
+       message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
+               &olddeg,&reduc,strat, red_result);
+ 
+-    // reduction of the element choosen from L
++    // reduction of the element chosen from L
+     red_result = strat->red(&strat->P,strat);
+ 
+ 
+@@ -742,7 +742,7 @@
+ 
+         h.PrepareRed(strat->use_buckets);
+ 
+-        // reduction of the element choosen from L(?)
++        // reduction of the element chosen from L(?)
+         red_result = strat->red(&h,strat);
+ 
+         // reduction to non-zero new poly
+--- a/kernel/numeric/mpr_base.cc
++++ b/kernel/numeric/mpr_base.cc
+@@ -1457,7 +1457,7 @@
+       if ( epos == 0 )
+       {
+         // this can happen, if the shift vektor or the lift funktions
+-        // are not generically choosen.
++        // are not generically chosen.
+         Werror("resMatrixSparse::createMatrix: Found exponent not in E, id %d, set [%d, %d]!",
+                i,(*E)[i]->rc.set,(*E)[i]->rc.pnt);
+         return i;
+@@ -2703,7 +2703,7 @@
+     resMat= new resMatrixDense( gls );
+     break;
+   default:
+-    WerrorS("uResultant::uResultant: Unknown resultant matrix type choosen!");
++    WerrorS("uResultant::uResultant: Unknown chosen resultant matrix type!");
+   }
+ }
+ 
+@@ -2734,7 +2734,7 @@
+     }
+     break;
+   default:
+-    WerrorS("uResultant::extendIdeal: Unknown resultant matrix type choosen!");
++    WerrorS("uResultant::extendIdeal: Unknown chosen resultant matrix type!");
+   }
+ 
+   return( newGls );
+--- a/Singular/fglm.cc
++++ b/Singular/fglm.cc
+@@ -171,7 +171,7 @@
+     for ( k= npar-1; (k >= 0) && (state == FglmOk); k-- )
+         if ( pperm[k] >= 0 )
+         {
+-            WerrorS( "paramater names do not agree" );
++            WerrorS( "parameter names do not agree" );
+             state= FglmIncompatibleRings;
+         }
+     if (pperm != NULL) // OB: ????
+--- a/kernel/numeric/mpr_inout.cc
++++ b/kernel/numeric/mpr_inout.cc
+@@ -62,7 +62,7 @@
+   switch (state)
+   {
+   case mprWrongRType:
+-    WerrorS("Unknown resultant matrix type choosen!");
++    WerrorS("Unknown chosen resultant matrix type!");
+     break;
+   case mprHasOne:
+     Werror("One element of the ideal %s is constant!",name);
+--- a/kernel/groebner_walk/walkProc.cc
++++ b/kernel/groebner_walk/walkProc.cc
+@@ -117,7 +117,7 @@
+     for ( k= npar-1; (k >= 0) && (state == WalkOk); k-- )
+         if ( pperm[k] >= 0 )
+         {
+-            WerrorS( "paramater names do not agree" );
++            WerrorS( "parameter names do not agree" );
+             state= WalkIncompatibleRings;
+         }
+ 
+--- a/libpolys/coeffs/longrat.cc
++++ b/libpolys/coeffs/longrat.cc
+@@ -3102,7 +3102,7 @@
+ BOOLEAN nlCoeffIsEqual(const coeffs r, n_coeffType n, void *p)
+ {
+   /* test, if r is an instance of nInitCoeffs(n,parameter) */
+-  /* if paramater is not needed */
++  /* if parameter is not needed */
+   if (n==r->type)
+   {
+     if ((p==NULL)&&(r->cfDiv==nlDiv)) return TRUE;
+--- a/libpolys/coeffs/numbers.cc
++++ b/libpolys/coeffs/numbers.cc
+@@ -276,7 +276,7 @@
+ static BOOLEAN ndCoeffIsEqual(const coeffs r, n_coeffType n, void *)
+ {
+   /* test, if r is an instance of nInitCoeffs(n,parameter) */
+-  /* if paramater is not needed */
++  /* if parameter is not needed */
+   return (n==r->type);
+ }
+ 
+--- a/kernel/fast_mult.cc
++++ b/kernel/fast_mult.cc
+@@ -591,7 +591,7 @@
+   if (n<=1)
+     Werror("not implemented for so small n, recursion fails");//should be length(f)
+    if (pLength(f)<=1)
+-    Werror("not implemented for so small lenght of f, recursion fails");
++    Werror("not implemented for so small length of f, recursion fails");
+   //  number null_number=n_Init(0,r);
+   number* facult=(number*) omAlloc((n+1)*sizeof(number));
+   facult[0]=n_Init(1,r->cf);
+--- a/libpolys/coeffs/Enumerator.h
++++ b/libpolys/coeffs/Enumerator.h
+@@ -57,7 +57,7 @@
+     virtual bool IsValid() const = 0;
+ 
+   private:
+-    /// disable copy constructor and assigment operator
++    /// disable copy constructor and assignment operator
+     IBaseEnumerator(const IBaseEnumerator&);
+     void operator=(const IBaseEnumerator&);
+ 
+@@ -168,7 +168,7 @@
+ 
+ /** @class AIterator
+  *
+- * An abstract iterator with virtualized assigment operator and
++ * An abstract iterator with virtualized assignment operator and
+  * constructors.
+  *
+  * Abstract API for iterators that should work with STL and BOOST.
+--- a/IntegerProgramming/binomial.cc
++++ b/IntegerProgramming/binomial.cc
+@@ -300,7 +300,7 @@
+     if(_number_of_variables<=0)
+     {
+       cerr<<"\nWARNING: binomial& binomial::operator=(const binomial&):\n"
+-        "assigment from corrupt binomial"<<endl;
++        "assignment from corrupt binomial"<<endl;
+       exponent_vector=NULL;
+       return (*this);
+     }
+--- a/IntegerProgramming/binomial.h
++++ b/IntegerProgramming/binomial.h
+@@ -114,7 +114,7 @@
+ 
+ 
+ 
+-// assigment and access operators
++// assignment and access operators
+ 
+   binomial& operator=(const binomial&);
+   // assignment operator with memory control
+--- a/IntegerProgramming/list.cc
++++ b/IntegerProgramming/list.cc
+@@ -962,7 +962,7 @@
+ 
+ 
+ 
+-////////////////////////// assigment ///////////////////////////////////////
++////////////////////////// assignment ///////////////////////////////////////
+ 
+ 
+ 
+--- a/Singular/LIB/surf.lib
++++ b/Singular/LIB/surf.lib
+@@ -176,7 +176,7 @@
+   {
+     surf_call = "singularsurf ";
+     surf_call = surf_call + l + " >/dev/null 2>&1";
+-    "Close window to exit from `singularurf`.";
++    "Close window to exit from `singularsurf`.";
+ 
+     i = system("sh", surf_call);
+     if (i != 0)
diff --git a/debian/repack b/debian/repack
new file mode 100755
index 0000000..d78df8a
--- /dev/null
+++ b/debian/repack
@@ -0,0 +1,161 @@
+#!/bin/sh
+
+PACKAGE_NAME=singular
+
+set -e
+set -u
+
+usage() {
+	echo "Usage: repack --upstream-version <ver> <downloaded file>"
+	exit 1
+	}
+
+if [ "$#" != "3" ]; then
+	usage
+fi
+if [ "$1" != "--upstream-version" ]; then
+	usage
+fi
+if [ ! -f "$3" ]; then
+	if [ -n "$3" ]; then
+		echo "$3 doesn't exist"
+	fi
+	usage
+fi
+UPSTREAM_VERSION="$2"
+UPSTREAM_TARBALLZZ="$3"
+
+DEBIAN_SUFFIX="+ds"
+####DEBIAN_ENCAPSULATEDFOLDERNAME="${PACKAGE_NAME}-usrc"
+
+DEBIAN_UVERSION=${UPSTREAM_VERSION}${DEBIAN_SUFFIX}
+DEBIAN_ROOTFOLDERNAME="${PACKAGE_NAME}-${DEBIAN_UVERSION}.orig"
+DEBIAN_TARBALLXZ="$(dirname $UPSTREAM_TARBALLZZ)/${PACKAGE_NAME}_${DEBIAN_UVERSION}.orig.tar.xz"
+
+REPACK_TMPDIR=`mktemp -d ./repackXXXXXX`
+REPACK_TMPDIR=$(readlink -f "$REPACK_TMPDIR")
+trap "/bin/rm -rf \"$REPACK_TMPDIR\"" QUIT INT EXIT
+
+message() {
+	echo
+	echo "-- -- $1"
+	echo
+	}
+
+message "Repackaging $UPSTREAM_TARBALLZZ"
+
+UPSTREAM_ROOTFOLDER="${REPACK_TMPDIR}/unpacked"
+mkdir "${UPSTREAM_ROOTFOLDER}"
+tar -C "${UPSTREAM_ROOTFOLDER}" -xf "${UPSTREAM_TARBALLZZ}" || unzip -d "${UPSTREAM_ROOTFOLDER}" "${UPSTREAM_TARBALLZZ}"
+if [ `ls -1 "${UPSTREAM_ROOTFOLDER}" | wc -l` -eq 1 ]; then
+	UPSTREAM_ROOTFOLDER="${UPSTREAM_ROOTFOLDER}/`ls -1 "${UPSTREAM_ROOTFOLDER}"`"
+fi
+
+DEBIAN_ROOTFOLDER="${REPACK_TMPDIR}/${DEBIAN_ROOTFOLDERNAME}"
+## repack
+####set -f
+REPACK_WORKING_FOLDER=$(pwd)
+cd "${UPSTREAM_ROOTFOLDER}"
+
+####. "${REPACK_WORKING_FOLDER}/debian/repack.local"
+## wipe out
+rm --verbose --force -- README.md
+rm --verbose --force -- m4/lt~obsolete.m4
+rm --verbose --force -- m4/ltoptions.m4
+rm --verbose --force -- m4/ltsugar.m4
+rm --verbose --force -- m4/ltversion.m4
+rm --verbose --force -- m4/libtool.m4
+rm --verbose --force -- build-aux/ylwrap
+rm --verbose --force -- build-aux/depcomp
+rm --verbose --force -- build-aux/compile
+rm --verbose --force -- build-aux/ar-lib
+rm --verbose --force -- build-aux/install-sh
+rm --verbose --force -- build-aux/ltmain.sh
+rm --verbose --force -- build-aux/missing
+rm --verbose --force -- build-aux/config.sub
+rm --verbose --force -- build-aux/config.guess
+rm --verbose --force -- build-aux/test-driver
+rmdir --verbose --ignore-fail-on-non-empty -- build-aux
+##
+find . -name 'aclocal.m4' | xargs --no-run-if-empty rm --verbose --force
+find . -name 'Makefile.in' | xargs --no-run-if-empty rm --verbose --force
+rm --verbose --force -- gfanlib/_config.h.in
+rm --verbose --force -- gfanlib/configure
+rm --verbose --force -- libpolys/_config.h.in
+rm --verbose --force -- libpolys/configure
+rm --verbose --force -- factory/acinclude.m4
+####rm --verbose --force -- factory/aminclude.am
+rm --verbose --force -- factory/_config.h.in
+rm --verbose --force -- factory/configure
+rm --verbose --force -- omalloc/_config.h.in
+rm --verbose --force -- omalloc/configure
+rm --verbose --force -- resources/_config.h.in
+rm --verbose --force -- resources/configure
+rm --verbose --force -- _config.h.in
+rm --verbose --force -- configure
+##
+rm --verbose --force -- factory/readcf.cc
+rm --verbose --force -- Singular/feOptES.inc
+rm --verbose --force -- Singular/feOptTS.inc
+rm --verbose --force -- Singular/all.lib
+##
+rm --verbose --force -- doc/Singular.man
+rm --verbose --force -- doc/TSingular.man
+rm --verbose --force -- doc/ESingular.man
+rmdir --verbose --ignore-fail-on-non-empty -- doc
+## remove executable bit for source files
+chmod --changes a-x m4/flint-check.m4
+chmod --changes a-x gfanlib/configure.ac
+## discard autoconf-archive material
+rm --verbose --force -- m4/ax_append_compile_flags.m4
+rm --verbose --force -- m4/ax_append_flag.m4
+rm --verbose --force -- m4/ax_append_link_flags.m4
+rm --verbose --force -- m4/ax_check_compile_flag.m4
+rm --verbose --force -- m4/ax_check_link_flag.m4
+rm --verbose --force -- m4/ax_compute_relative_paths.m4
+rm --verbose --force -- m4/ax_cxx_gcc_abi_demangle.m4
+rm --verbose --force -- m4/ax_normalize_path.m4
+####rm --verbose --force -- m4/ax_prefix_config_h.m4
+###### comment:
+######  at the time of writting, the latest ax_prefix_config_h.m4
+######  as distributed within the autoconf-archive is not compatible
+######  with this version (serial 11); more precisely, not providing
+######  a prefix is an error in the lastest version (serial 15).
+rm --verbose --force -- m4/ax_pthread.m4
+rm --verbose --force -- m4/ax_python_embed.m4
+####rm --verbose --force -- m4/ax_python_with_version.m4
+###### comment:
+######  ax_python_with_version.m4 does not belong to autoconf-archive.
+#:
+
+cd ${REPACK_WORKING_FOLDER}
+set +f
+## end
+####if [ -n "${DEBIAN_ENCAPSULATEDFOLDERNAME}" ]; then
+####	mkdir "${DEBIAN_ROOTFOLDER}"
+####	mv "${UPSTREAM_ROOTFOLDER}" "${DEBIAN_ROOTFOLDER}/${DEBIAN_ENCAPSULATEDFOLDERNAME}"
+####else
+	mv "${UPSTREAM_ROOTFOLDER}" "${DEBIAN_ROOTFOLDER}"
+####fi
+
+REPACK_TARBALL="${REPACK_TMPDIR}/repacked.tar"
+REPACK_TARBALLXZ="${REPACK_TARBALL}.xz"
+( cd "${REPACK_TMPDIR}" && \
+	find -L "${DEBIAN_ROOTFOLDERNAME}" -xdev -type f -print | sort | \
+	tar -T-  --owner=root --group=root --mode=a+rX --create --file "${REPACK_TARBALL}" \
+	)
+xz -9e < "${REPACK_TARBALL}" > "${REPACK_TARBALLXZ}"
+mv "${REPACK_TARBALLXZ}" "${DEBIAN_TARBALLXZ}"
+
+message "Testing ${DEBIAN_TARBALLXZ}"
+
+xz --verbose --test "${DEBIAN_TARBALLXZ}"
+
+message "Printing information about ${DEBIAN_TARBALLXZ}"
+
+xz --verbose --list "${DEBIAN_TARBALLXZ}"
+
+message "Quitting"
+
+##
+## eos
diff --git a/debian/rules b/debian/rules
index cbd6324..22861fb 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,276 +1,31 @@
 #!/usr/bin/make -f
 
-# DH_VERBOSE=1
+DEB_PKG_DIR = $(abspath $(dir $(filter %rules, $(MAKEFILE_LIST))))
+export DEB_PKG_VERSION = $(shell dpkg-parsechangelog -l$(DEB_PKG_DIR)/changelog | sed -n -e '/^Version:/s/Version: //p')
 
-# soname-suffix of the library and part of directory name.
-# make sure to change the libsingular-* package name when changing this:
-VERSION=3-1-6
+export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
 
-CFLAGS := $(shell dpkg-buildflags --get CFLAGS)
-CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
-CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS)
-LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
+default:
+	@uscan --no-conf --dehs --report || true
 
-DOC_TRUE=
-DOC_FALSE=
-ifneq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
-	DOC_TRUE=\#
-else
-	ENABLE_DOC=--enable-doc
-	DOCDIR=doc
-	DOC_FALSE=\#
-endif
+%:
+	dh $@ --with autoreconf --parallel
 
-WITH_PYTHON = --with-python
+override_dh_auto_build-indep:
+	make -C dox html
 
-CFLAGS += -Wall
-CXXFLAGS += -Wall
+override_dh_auto_test-indep:
 
-DEB_CONFIGURE_EXTRA_FLAGS += --prefix=/usr/lib/singular-$(VERSION) \
-                             --exec-prefix=/usr/lib/singular-$(VERSION) \
-                             --libdir=/usr/lib \
-                             --includedir=/usr/include \
-                             --with-apint=gmp \
-                             --with-factory=$(CURDIR)/factory \
-                             --with-gmp=/usr/lib \
-                             --with-libfac=$(CURDIR)/libfac \
-                             --with-malloc=system \
-                             --with-NTL \
-                             $(WITH_PYTHON) \
-                             --without-bison \
-                             --without-Boost \
-                             --without-flint \
-                             --without-lex \
-                             --without-MP \
-                             $(ENABLE_DOC) \
-                             --enable-factory \
-                             --enable-gmp=/usr/lib \
-                             --enable-IntegerProgramming \
-                             --enable-libfac \
-                             --enable-Singular
+DEB_AUTO_INSTALL_MAKEFLAGS = TOPSRCDIR=$(CURDIR) DESTDIR=$(CURDIR)/debian/tmp
+override_dh_auto_install-indep:
+	make -C dox install-html $(DEB_AUTO_INSTALL_MAKEFLAGS)
 
-# BUG (see singular/spkg-install)
-# singular apparently doesnt work without debug
-DEB_CONFIGURE_EXTRA_FLAGS += --with-debug
+override_dh_link-arch:
+	dh_link -p libsingular4-dev \
+		/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/Singular.pc /usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/singular.pc
 
-clean:
-	if [ -f doc/Makefile ] ; then $(MAKE) -C doc clean ; fi
-	if [ -f Makefile ] ; then $(MAKE) distclean ; fi
-	rm -f *-stamp
-	dh_clean
-	rm -f VERSION
+override_dh_strip-arch:
+	dh_strip -a --dbg-package=libsingular4-dbg
 
-	find Singular -name "p_*.so" -delete
-	find doc \( -name "T*.txt" -o -name "*.dot" -o -name "*.ssi" \
-		-o -name "temp_*" -o -name "exmpl.tex" \
-		-o -name "*.jpg" -o -name "*.gif" -o -name "*.xbm" \
-		-o -name "QEPCAD*" -o -name "qepcadfilter.pl" \
-		-o -name "s-plulibs.tex" \) -delete
-	#sanity checks
-	find . \( -name "*.o" -o -name "*.dl_o" -o -name "*.og" \
-		  -o -name "*.so" -o -name "*.sog" -o -name "*.a" \
-		  -o -name "*.o_ndebug" -o -name "*.sog" -o -name "*.op" \) \
-		-printf 'clean failed: %p\n' -delete
-	# remove some leftovers:
-	rm -f Singular/libparse.cc.lmp doc/uname.texi doc/version.texi kernel/prCopy.inc
-	find . \( -name "config.guess" -o -name "config.sub" \
-		  -o -name "config.log" -o -name "config.status" \
-		  -o -name "stamp-h" -o -name "config.h" \
-		  -o -name "Makefile" -a -not -wholename "./calldummy/Makefile" \) \
-		-delete
-	rm -f factory/gen_cf_gmp.sh
-	rm -f libfac/factor/version.h
-	rm -f Singular/conftest.s1
-	rm -f Singular/conftest.subs
-	rm -f Singular/mpsr_Tok.xx
-	rm -f ntl/src/cfileout
-	rm -f ntl/src/makefile
-	rm -f ntl/src/mfileout
-	rm -f emacs/lib-temp
-
-binary: binary-arch binary-indep
-binary-indep:
-build-indep:
-
-binary-arch: install
-	dh_testdir
-	dh_testroot
-	dh_installdirs
-	dh_install
-	rm debian/libsingular-$(VERSION)/usr/lib/singular-$(VERSION)/*Singular*
-	ln -sf ../lib/singular-$(VERSION)/Singular debian/singular/usr/bin/
-	ln -sf ../lib/singular-$(VERSION)/TSingular debian/singular/usr/bin/
-	ln -sf ../lib/singular-$(VERSION)/ESingular debian/singular/usr/bin/
-	for dir in info html $(DOCDIR) examples emacs ; do \
-		mkdir -p debian/libsingular-$(VERSION)/usr/share/singular-$(VERSION)/$$dir ; \
-		ln -sf /usr/share/singular-$(VERSION)/$$dir \
-			debian/libsingular-$(VERSION)/usr/lib/singular-$(VERSION)/$$dir ; \
-	done
-	dh_installchangelogs
-	dh_installexamples
-	dh_installdocs
-	dh_installman
-	dh_installmenu
-	dh_link
-	dh_strip
-	# add a hardlink to place found by ld.so:
-	ln debian/libsingular-$(VERSION)/usr/lib/singular-$(VERSION)/libsingular.so \
-		debian/libsingular-$(VERSION)/usr/lib/libsingular-$(VERSION).so
-	# development symlink
-	ln -sf libsingular-$(VERSION).so debian/libsingular-dev/usr/lib/libsingular.so
-	dh_makeshlibs
-	dh_shlibdeps
-	dh_compress
-	dh_fixperms
-	dh_installdeb
-	dh_gencontrol
-	dh_md5sums
-	dh_builddeb
-
-ENABLE_DEBUGOUTPUT=--disable-debugoutput
-WITH_DEBUG=--without-debug
-
-configure-stamp:
-	cp -f /usr/share/misc/config.guess config.guess
-	cp -f /usr/share/misc/config.sub config.sub
-	export CFLAGS="$(CFLAGS) -fPIC" \
-	CXXFLAGS="$(CXXFLAGS) -fPIC" \
-	CPPFLAGS="$(CPPFLAGS) -DMAKE_DISTRIBUTION -I../omalloc -I$(CURDIR)/factory" \
-	LDFLAGS="$(LDFLAGS) -L$(CURDIR)/factory -L$(CURDIR)/libfac -L$(CURDIR)/omalloc"; \
-	./configure $(DEB_CONFIGURE_EXTRA_FLAGS); \
-	cd factory; ./configure \
-	            --prefix=/usr \
-	            --includedir=/usr/include/factory \
-	            --with-Singular=yes \
-	            --with-NTL=/usr \
-	            --without-flint \
-	            --with-gmp=/usr \
-	            --exec-prefix=/usr \
-	            --bindir=/usr/bin \
-	            --libdir=/usr/lib \
-	            --enable-gmp \
-	            --enable-NTL \
-	            $(ENABLE_DEBUGOUTPUT); \
-	cd $(CURDIR)/libfac; ./configure \
-	            --prefix=/usr \
-	            --exec-prefix=/usr \
-	            --bindir=/usr/bin \
-	            --libdir=/usr/lib \
-	            $(WITH_DEBUG)
-
-	# don't look in system directories first:
-	sed -e 's#-I/usr/lib/singular-[0-9.-]*\>#-I'"$(CURDIR)"'#g' \
-	    -e 's#-I/usr/\(local/\)\?include\( \|$$\)##g' \
-	    -e 's#-I$${prefix}\( \|$$\)#-I'"$(CURDIR)"' #g' \
-	    -e 's#-L/usr/local/lib\( \|$$\)##g' \
-	    -e 's#-L/usr/lib\( \|$$\)##g' \
-	    -e 's#-L$${libdir}\( \|$$\)##g' \
-	    -i Makefile omalloc/Makefile kernel/Makefile Singular/Makefile \
-	       libfac/Makefile factory/GNUmakefile IntegerProgramming/Makefile
-	sed -e 's#-I$$(includedir) ##' -i factory/GNUmakefile
-	# ncurses or termcap is only needed for the internal readline not available with glibc:
-	sed	-e 's# *-lncurses##' -e 's# *-ltermcap##' \
-		-i Singular/Makefile
-	# only called by the library, no need to link binaries against
-	sed	-e '/^LIBS\>/s# *-lnsl##' \
-		-e '/^LIBS\>/s# *-ldl##' \
-		-i Singular/Makefile
-	# disable building some things twice:
-	sed -e '/^all:/s# *libsingfac_g.a##' -i libfac/Makefile
-	sed -e '/^cf:/s# *libsingcf_g.a##' -i factory/GNUmakefile
-	sed -e '/^\(all\|installbin\):/s# *libkernel_g.a##' -i kernel/Makefile
-	sed -e 's#SINGULAR *=.*$$#SINGULAR=../Singular/Singular#' -i doc/Makefile
-	sed -e 's#LIBPARSE *=.*$$#LIBPARSE=../Singular/libparse#' -i doc/Makefile
-	sed -e 's#^Makefile:#Makefile.orig:#' -i doc/Makefile
-	touch $@
-
-build build-arch: build-stamp
-
-EXAMPLE_EXCLUDE=-exclude MP -exclude gfan -exclude normaliz -exclude sing4ti2 -exclude memory -exclude dynlib
-PYTHON_INCLUDE=-I/usr/include/python2.7
-
-build-stamp: configure-stamp
-	$(MAKE) LD='$(CXX) $(CXXFLAGS) -fPIC $(LDFLAGS)' \
-	           LIBSINGULAR_FLAGS='-shared -Wl,-soname,libsingular-$(VERSION).so $(CXXFLAGS) -fPIC $(LDFLAGS) -L../omalloc' \
-	           LD_DYN_FLAGS2='' DL_LIBSG='' GLIBC_DYN_FIX="-lc"
-	# the above command failed to build libsingular.so. let's try again
-	$(MAKE) -C Singular LD='$(CXX) $(CXXFLAGS) -fPIC $(LDFLAGS)' \
-	           LIBSINGULAR_FLAGS='-shared -Wl,-soname,libsingular-$(VERSION).so $(CXXFLAGS) -fPIC $(LDFLAGS) -L../omalloc' \
-	           LD_DYN_FLAGS2='' DL_LIBSG='' GLIBC_DYN_FIX="-lc" libsingular.so
-	# libparse is needed for doc-building ESingular and TSingular not built by "all".
-	# and the makefile here uses the wrong flags (only CPPFLAGS, not CXXFLAGS)
-	$(MAKE) -C Singular CPPFLAGS='-I. -I.. $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(PYTHON_INCLUDE)' libparse ESingular TSingular Singular
-	touch $@
-
-emacs-stamp: doc-stamp
-	cd Singular && ln -sf ../kernel/p_*.so .
-	mkdir -p debian/lddir && ln -sf ../../Singular/libsingular.so debian/lddir/libsingular-$(VERSION).so
-	SINGULAR_BIN_DIR=$(CURDIR)/Singular \
-	 LD_LIBRARY_PATH='$(CURDIR)/debian/lddir'"$${LD_LIBRARY_PATH:+:$${LD_LIBRARY_PATH}}" \
-	 $(MAKE) \
-		prefix="$(CURDIR)" \
-		examplesdir="$(CURDIR)/doc/examples" \
-		SINGULAR='$(CURDIR)/Singular/Singular' \
-		-C emacs \
-		all
-	rm -r debian/lddir
-	touch $@
-
-doc-stamp: build-stamp
-	[ -x Singular/libparse ]
-	touch Singular/libparse
-	mkdir -p debian/doclddir && ln -sf ../../Singular/libsingular.so debian/doclddir/libsingular-$(VERSION).so
-	$(DOC_TRUE)cd Singular && ln -sf ../kernel/p_*.so .
-	$(DOC_TRUE)cd debian/doclddir; ln -sf ../../kernel/p_*.so .
-	$(DOC_TRUE)export SINGULAR_BIN_DIR=$(CURDIR)/Singular \
-	$(DOC_TRUE)       SINGULAR_ROOT_DIR=$(CURDIR)/Singular \
-	$(DOC_TRUE)       LD_LIBRARY_PATH='$(CURDIR)/debian/doclddir'"$${LD_LIBRARY_PATH:+:$${LD_LIBRARY_PATH}}" \
-	$(DOC_TRUE)       PATH="$(CURDIR)/Singular:$(CURDIR)/kernel:$(CURDIR)/IntegerProgramming:$$PATH" \
-	$(DOC_TRUE)       PBORI_NOSAGE=YES; \
-	$(DOC_TRUE)$(MAKE) \
-	$(DOC_TRUE)	DOC2TEX_EXAMPLE_EXCLUSIONS="$(EXAMPLE_EXCLUDE)" \
-	$(DOC_TRUE)	bindir="$(CURDIR)/Singular" \
-	$(DOC_TRUE)	SINGULAR='$(CURDIR)/Singular/Singular' \
-	$(DOC_TRUE)	-C doc \
-	$(DOC_TRUE)	standalone-txt standalone-html html singular.idx singular.hlp
-	$(DOC_TRUE)rm -r debian/doclddir
-	$(DOC_FALSE)touch doc/singular.hlp
-	$(DOC_FALSE)-mkdir doc/examples
-	touch $@
-
-install: build-stamp doc-stamp emacs-stamp
-	dh_testdir
-	dh_testroot
-	dh_prep
-	$(MAKE) DESTDIR=$(CURDIR)/debian/tmp/ DL_LIBSG='' install-libsingular
-	$(MAKE) -C Singular DESTDIR=$(CURDIR)/debian/tmp/ DL_LIBSG='' install
-	$(DOC_TRUE)$(MAKE) -C doc \
-	$(DOC_TRUE)	bindir="$(CURDIR)/Singular" \
-	$(DOC_TRUE)	SINGULAR='$(CURDIR)/Singular/Singular' \
-	$(DOC_TRUE)	install_prefix=$(CURDIR)/debian/tmp/usr/share/singular-$(VERSION) \
-	$(DOC_TRUE)	install-sharedist
-	$(DOC_FALSE)mkdir -p $(CURDIR)/debian/tmp/usr/share/singular-$(VERSION)/info
-	$(DOC_FALSE)mkdir -p $(CURDIR)/debian/tmp/usr/share/singular-$(VERSION)/examples
-	$(DOC_FALSE)mkdir -p $(CURDIR)/debian/tmp/usr/share/singular-$(VERSION)/html
-	$(DOC_FALSE)mkdir -p $(CURDIR)/debian/tmp/usr/share/singular-$(VERSION)/doc
-	$(DOC_FALSE)mkdir -p $(CURDIR)/debian/tmp/usr/share/singular-$(VERSION)/emacs
-	$(DOC_TRUE)$(MAKE) -C emacs \
-	$(DOC_TRUE)	prefix="$(CURDIR)" \
-	$(DOC_TRUE)	examplesdir="$(CURDIR)/doc/examples" \
-	$(DOC_TRUE)	SINGULAR='$(CURDIR)/Singular/Singular' \
-	$(DOC_TRUE)	install_prefix=$(CURDIR)/debian/tmp/usr/share/singular-$(VERSION) \
-	$(DOC_TRUE)	install-sharedist
-	# surfex is not included due to missing sources, so do not install wrappers, either:
-	rm -f debian/tmp/usr/lib/singular-$(VERSION)/LIB/surfex.lib
-	rm -f debian/tmp/usr/lib/singular-$(VERSION)/surfex
-	# move as installed to libdir but searched in bindir:
-	install debian/tmp/usr/lib/dbmsr.so debian/tmp/usr/lib/singular-$(VERSION)/
-	# get rid of AIX specific headers
-	rm -f debian/tmp/usr/include/*limits.h
-	#don't use them
-	sed -e 's#mylimits\.h#limits.h#' -i debian/tmp/usr/include/singular/*.h
-	# remove executeable bits from .gif files:
-	find debian/tmp -name "*.gif" -exec chmod a-x {} \;
-	dh_lintian
-
-.PHONY: build-arch build-indep build install binary-arch binary-indep binary clean
+get-orig-source:
+	uscan --no-conf --download-current-version --verbose
diff --git a/debian/series b/debian/series
deleted file mode 100644
index e69de29..0000000
diff --git a/debian/singular-bin/ESingular b/debian/singular-bin/ESingular
deleted file mode 100644
index 6908897..0000000
--- a/debian/singular-bin/ESingular
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-export SINGULARPATH=/usr/lib/singular
-export SINGULAR_BIN_DIR=/usr/lib/singular
-export SINGULAR_ROOT_DIR=/usr/share/singular
-export SINGULAR_INFO_FILE=/usr/share/doc/singular/info/singular.hlp
-export SINGULAR_IDX_FILE=/usr/share/doc/singular/doc/singular.idx
-export SINGULAR_HTML_DIR=/usr/share/doc/singular/html
-export SINGULAR_EXAMPLES_DIR=/usr/share/doc/singular/examples
-export SINGULAR_EXECUTABLE=/usr/lib/singular/Singular
-export PATH=/usr/lib/singular:/usr/bin:$PATH
-exec /usr/lib/singular/ESingular "$@"
diff --git a/debian/singular-bin/Singular b/debian/singular-bin/Singular
deleted file mode 100644
index 8fbe763..0000000
--- a/debian/singular-bin/Singular
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-export SINGULARPATH=/usr/lib/singular
-export SINGULAR_BIN_DIR=/usr/lib/singular
-export SINGULAR_ROOT_DIR=/usr/share/singular
-export SINGULAR_INFO_FILE=/usr/share/doc/singular/info/singular.hlp
-export SINGULAR_IDX_FILE=/usr/share/doc/singular/doc/singular.idx
-export SINGULAR_HTML_DIR=/usr/share/doc/singular/html
-export SINGULAR_EXAMPLES_DIR=/usr/share/doc/singular/examples
-export SINGULAR_EXECUTABLE=/usr/lib/singular/Singular
-export PATH=/usr/lib/singular:/usr/bin:$PATH
-exec /usr/lib/singular/Singular "$@"
diff --git a/debian/singular-bin/TSingular b/debian/singular-bin/TSingular
deleted file mode 100644
index 37ae5c8..0000000
--- a/debian/singular-bin/TSingular
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-export SINGULARPATH=/usr/lib/singular
-export SINGULAR_BIN_DIR=/usr/lib/singular
-export SINGULAR_ROOT_DIR=/usr/share/singular
-export SINGULAR_INFO_FILE=/usr/share/doc/singular/info/singular.hlp
-export SINGULAR_IDX_FILE=/usr/share/doc/singular/doc/singular.idx
-export SINGULAR_HTML_DIR=/usr/share/doc/singular/html
-export SINGULAR_EXAMPLES_DIR=/usr/share/doc/singular/examples
-export SINGULAR_EXECUTABLE=/usr/lib/singular/Singular
-export PATH=/usr/lib/singular:/usr/bin:$PATH
-exec /usr/lib/singular/TSingular "$@"
diff --git a/debian/singular-data.install b/debian/singular-data.install
new file mode 100644
index 0000000..a099707
--- /dev/null
+++ b/debian/singular-data.install
@@ -0,0 +1,3 @@
+usr/share/singular/factory/gftables/
+usr/share/singular/LIB/
+usr/share/icons/Singular.png
diff --git a/debian/singular-data.lintian-overrides b/debian/singular-data.lintian-overrides
new file mode 100644
index 0000000..13df19a
--- /dev/null
+++ b/debian/singular-data.lintian-overrides
@@ -0,0 +1,2 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+singular-data: no-upstream-changelog
diff --git a/debian/singular-dev-doc.doc-base b/debian/singular-dev-doc.doc-base
new file mode 100644
index 0000000..14cc6af
--- /dev/null
+++ b/debian/singular-dev-doc.doc-base
@@ -0,0 +1,13 @@
+Document: singular
+Title: Singular Manual for developers
+Author: Singular Team
+Abstract:
+ Singular is a computer algebra system for polynomial computations,
+ with special emphasis on commutative and non-commutative algebra,
+ algebraic geometry, and singularity theory.
+ It is free and open-source under the GNU General Public Licence (GPL).
+Section: Science/Mathematics
+
+Format: HTML
+Index: /usr/share/doc/singular-dev-doc/html/index.html
+Files: /usr/share/doc/singular-dev-doc/html/*.html
diff --git a/debian/singular-dev-doc.docs b/debian/singular-dev-doc.docs
new file mode 100644
index 0000000..238dffb
--- /dev/null
+++ b/debian/singular-dev-doc.docs
@@ -0,0 +1 @@
+debian/tmp/usr/share/doc/singular/html/
diff --git a/debian/singular-dev-doc.lintian-overrides b/debian/singular-dev-doc.lintian-overrides
new file mode 100644
index 0000000..fb3a327
--- /dev/null
+++ b/debian/singular-dev-doc.lintian-overrides
@@ -0,0 +1,2 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+singular-dev-doc: no-upstream-changelog
diff --git a/debian/singular-doc.lintian-overrides b/debian/singular-doc.lintian-overrides
new file mode 100644
index 0000000..2ae3c54
--- /dev/null
+++ b/debian/singular-doc.lintian-overrides
@@ -0,0 +1,9 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+singular-doc: no-upstream-changelog
+
+# at the time of packaging, the upstream source ball comes without
+# user documentation material: a pull request will be asked to get a
+# more suitable upstream source ball; previous pull requests in this
+# sens were kindly accepted before to ease packaging -- Jerome Benoit
+# <calculus at rezozer.net>
+singular-doc: empty-binary-package
diff --git a/debian/singular-modules.install b/debian/singular-modules.install
new file mode 100644
index 0000000..99463e1
--- /dev/null
+++ b/debian/singular-modules.install
@@ -0,0 +1,6 @@
+usr/lib/*/singular/MOD/*.so
+usr/lib/*/singular/MOD/change_cost
+usr/lib/*/singular/MOD/gen_test
+usr/lib/*/singular/MOD/singularsurf
+usr/lib/*/singular/MOD/solve_IP
+usr/lib/*/singular/MOD/toric_ideal
diff --git a/debian/singular-modules.lintian-overrides b/debian/singular-modules.lintian-overrides
new file mode 100644
index 0000000..6741aea
--- /dev/null
+++ b/debian/singular-modules.lintian-overrides
@@ -0,0 +1,2 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+singular-modules: no-upstream-changelog
diff --git a/debian/singular-ui-emacs.install b/debian/singular-ui-emacs.install
new file mode 100644
index 0000000..b593b88
--- /dev/null
+++ b/debian/singular-ui-emacs.install
@@ -0,0 +1,3 @@
+usr/bin/ESingular
+usr/share/singular/emacs/*.el
+usr/share/singular/emacs/*.xpm
diff --git a/debian/singular-ui-emacs.lintian-overrides b/debian/singular-ui-emacs.lintian-overrides
new file mode 100644
index 0000000..75e1b93
--- /dev/null
+++ b/debian/singular-ui-emacs.lintian-overrides
@@ -0,0 +1,2 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+singular-ui-emacs: no-upstream-changelog
diff --git a/debian/singular-ui-emacs.manpages b/debian/singular-ui-emacs.manpages
new file mode 100644
index 0000000..1bf6080
--- /dev/null
+++ b/debian/singular-ui-emacs.manpages
@@ -0,0 +1 @@
+debian/tmp/usr/share/man/man1/ESingular.1
diff --git a/debian/singular-ui-xterm.install b/debian/singular-ui-xterm.install
new file mode 100644
index 0000000..c0de9e5
--- /dev/null
+++ b/debian/singular-ui-xterm.install
@@ -0,0 +1 @@
+usr/bin/TSingular
diff --git a/debian/singular-ui-xterm.lintian-overrides b/debian/singular-ui-xterm.lintian-overrides
new file mode 100644
index 0000000..ca330dc
--- /dev/null
+++ b/debian/singular-ui-xterm.lintian-overrides
@@ -0,0 +1,2 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+singular-ui-xterm: no-upstream-changelog
diff --git a/debian/singular-ui-xterm.manpages b/debian/singular-ui-xterm.manpages
new file mode 100644
index 0000000..cf58ffe
--- /dev/null
+++ b/debian/singular-ui-xterm.manpages
@@ -0,0 +1 @@
+debian/tmp/usr/share/man/man1/TSingular.1
diff --git a/debian/singular-ui.install b/debian/singular-ui.install
new file mode 100644
index 0000000..335b746
--- /dev/null
+++ b/debian/singular-ui.install
@@ -0,0 +1 @@
+usr/bin/Singular
diff --git a/debian/singular-ui.lintian-overrides b/debian/singular-ui.lintian-overrides
new file mode 100644
index 0000000..9cfc418
--- /dev/null
+++ b/debian/singular-ui.lintian-overrides
@@ -0,0 +1,2 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+singular-ui: no-upstream-changelog
diff --git a/debian/singular-ui.manpages b/debian/singular-ui.manpages
new file mode 100644
index 0000000..cec12c4
--- /dev/null
+++ b/debian/singular-ui.manpages
@@ -0,0 +1 @@
+debian/tmp/usr/share/man/man1/Singular.1
diff --git a/debian/singular.dirs b/debian/singular.dirs
deleted file mode 100644
index 415f082..0000000
--- a/debian/singular.dirs
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin
diff --git a/debian/singular.install b/debian/singular.install
deleted file mode 100644
index 37856ca..0000000
--- a/debian/singular.install
+++ /dev/null
@@ -1,6 +0,0 @@
-/usr/lib/singular-*/*Singular*
-/usr/share/singular-*/info
-/usr/share/singular-*/examples
-/usr/share/singular-*/html
-/usr/share/singular-*/doc
-/usr/share/singular-*/emacs
diff --git a/debian/singular.lintian-overrides b/debian/singular.lintian-overrides
new file mode 100644
index 0000000..ab8ae52
--- /dev/null
+++ b/debian/singular.lintian-overrides
@@ -0,0 +1,2 @@
+# the upstream source ball contains only EMPTY ChangeLog files
+singular: no-upstream-changelog
diff --git a/debian/singular.manpages b/debian/singular.manpages
deleted file mode 100644
index 88526f8..0000000
--- a/debian/singular.manpages
+++ /dev/null
@@ -1,3 +0,0 @@
-debian/Singular.1
-debian/ESingular.1
-debian/TSingular.1
diff --git a/debian/singular.menu b/debian/singular.menu
deleted file mode 100644
index a8d3b2e..0000000
--- a/debian/singular.menu
+++ /dev/null
@@ -1,2 +0,0 @@
-?package(singular):needs="text" section="Applications/Science/Mathematics" \
-	title="Singular" command="/usr/bin/Singular"
diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides
new file mode 100644
index 0000000..73225ec
--- /dev/null
+++ b/debian/source/lintian-overrides
@@ -0,0 +1,3 @@
+# Upstream source tarball is not (yet) signed: request to the Singular Team
+# was sent -- Jerome Benoit <calculus at rrezozer.net>
+debian-watch-may-check-gpg-signature
diff --git a/debian/watch b/debian/watch
index 5ffb66e..cb8a5c3 100644
--- a/debian/watch
+++ b/debian/watch
@@ -1,6 +1,4 @@
-# watch file for uscan(1)
-# note that this needs http://bugs.debian.org/658999 fixed to work properly
 version=3
-opts=dversionmangle=s/\.dfsg(\.\d+)?$// \
-        http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/([\d-]+)/ \
-                Singular-([\d-]+)\.tar\.gz
+opts=dversionmangle=s/\+ds// \
+http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/([\d-]+)/ singular-([\d\.]+|[\d\.]+p\d+)\.tar\.gz \
+debian sh debian/repack

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



More information about the debian-science-commits mailing list