Index: Makefile.am
===================================================================
--- Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -14,2 +14,5 @@
 
 TESTDIRS=$(ALLOC) $(USE_FACTORY) libpolys kernel Singular
+
+# libfac doesn't use automake, just include it all in tarball
+EXTRA_DIST = libfac
Index: Singular/Makefile.am
===================================================================
--- Singular/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ Singular/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -1,3 +1,2 @@
-# ACLOCAL_AMFLAGS = -I m4
 # PIPE = -pipe
 # ???
@@ -19,5 +18,6 @@
 ########################### libSingular* #########################
 
-lib_LIBRARIES = libSingular.a libSingular_g.a
+libSingular_LIBRARIES = libSingular.a libSingular_g.a
+libSingulardir = $(libdir)/singular
 
 libSingular_a_CFLAGS   = -O3 -fomit-frame-pointer -Wextra -Wall -Wno-long-long ${PIPE}
@@ -97,7 +97,4 @@
 libSingular_g_a_SOURCES = $(SOURCES)
 
-libSingular_a_includedir  =${includedir}/Singular/
-libSingular_g_a_includedir=${includedir}/Singular/
-
 SingularHEADERS =    Cache.h \
    CacheImplementation.h \
@@ -113,9 +110,10 @@
    distrib.h \
    eigenval_ip.h \
-   feOpt.h \
+   feOpt.h feOptTab.h fehelp.h \
    fglm.h \
    gms.h \
    grammar.h \
    interpolation.h \
+   idrec.h \
    ipconv.h \
    ipid.h \
@@ -125,4 +123,5 @@
    libparse.h \
    libsingular.h \
+   linearAlgebra_ip.h\
    lists.h \
    locals.h \
@@ -156,11 +155,11 @@
    tok.h \
    utils.h \
+   version.h \
    walk.h \
    feOpt.h feOpt.inc \
    mpsr_Tok.inc iparith.inc feOptTS.inc feOptES.inc
 
-
-libSingular_a_include_HEADERS   = $(SingularHEADERS)
-libSingular_g_a_include_HEADERS = $(SingularHEADERS)
+libSingular_includedir = ${includedir}/singular/Singular/
+libSingular_include_HEADERS = $(SingularHEADERS)
 
 if ENABLE_FACTORY
@@ -179,5 +178,5 @@
 AM_LDFLAGS = -L${top_builddir}/Singular -L${top_builddir}/numeric -L${top_builddir}/kernel -L${top_builddir}/libpolys/polys -L${top_builddir}/libpolys/coeffs -L${top_builddir}/libpolys/reporter -L${top_builddir}/libpolys/resources -L${top_builddir}/libpolys/misc $(USE_FACTORY) -L${top_builddir}/omalloc
 
-EXTRA_PROGRAMS = gentable2 gentable1 feOpt feOptES feOptTS
+noinst_PROGRAMS = gentable2 gentable1 feOpt feOptES feOptTS
 
 gentable2_SOURCES = gentable2.cc grammar.h tok.h table.h
@@ -194,6 +193,4 @@
 gentable1_CPPFLAGS = -DNDEBUG -DOM_NDEBUG
 
-# plural_cmd.inc: iparith.inc			       
-
 feOpt_SOURCES = feOptGen.cc feOptGen.h
 feOpt_CXXFLAGS = -O3 -fomit-frame-pointer --no-rtti -Wextra -Wall -Wno-long-long ${PIPE} $(CXXTEMPLFLAGS)
@@ -252,8 +249,8 @@
 #########################################################
 
-BUILT_SOURCES = feOpt.inc mpsr_Tok.inc iparith.inc feOptTS.inc feOptES.inc  # files are built first
-# plural_cmd.inc
-
-CLEANFILES = $(TESTS) $(EXTRA_PROGRAMS) $(BUILT_SOURCES)
+# These files are built first
+BUILT_SOURCES = feOpt.inc mpsr_Tok.inc iparith.inc plural_cmd.inc feOptTS.inc feOptES.inc
+
+CLEANFILES = $(BUILT_SOURCES)
 
 feOpt.inc: feOpt
@@ -266,6 +263,9 @@
 	./feOptTS
 
-iparith.inc: gentable1
+plural_cmd.inc iparith.inc: gentable1
 	./gentable1
+
+# fake rule to fix parallel make http://www.gnu.org/s/hello/manual/automake/Multiple-Outputs.html
+plural_cmd.inc: iparith.inc
 
 mpsr_Tok.inc: gentable2
Index: configure.ac
===================================================================
--- configure.ac	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ configure.ac	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -1,3 +1,3 @@
-AC_INIT([singular], [3.1.2.sw])
+AC_INIT([singular], [3.1.3.sw])
 
 AC_CONFIG_MACRO_DIR([m4])
Index: factory/Makefile.am
===================================================================
--- factory/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ factory/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -5,9 +5,6 @@
 lib_LIBRARIES = libfactory.a libfactory_g.a
 
-libfactory_a_includedir=$(includedir)/factory
-libfactory_g_a_includedir=$(includedir)/factory
-
-libfactory_a_libdir=$(libdir)/factory
-libfactory_g_a_libdir=$(libdir)/factory
+libfactory_a_libdir = $(libdir)
+libfactory_g_a_libdir = $(libdir)
 
 libfactory_a_CXXFLAGS   = -O3 -fomit-frame-pointer --no-rtti ${CXXTEMPLFLAGS}
@@ -90,11 +87,9 @@
 		singext.cc \
 		parseutil.cc \
-		ftmpl_inst.cc \
-		factory.h factoryconf.h
+		ftmpl_inst.cc
 
 if WITH_PARSER_FOR_CANONICAL_FORM
     SOURCES +=  readcf.yy
 endif
-
 
 libfactory_a_SOURCES = $(SOURCES)
@@ -106,4 +101,5 @@
 		canonicalform.h \
 		cf_algorithm.h \
+		cf_cyclo.h \
 		cf_binom.h \
 		cf_defs.h \
@@ -113,8 +109,10 @@
 		cf_globals.h \
 		cf_gcd_smallp.h \
+		cf_gmp.h \
 		cf_hnf.h \
 		cf_irred.h \
 		cf_iter.h \
 		cf_map.h \
+		cf_map_ext.h \
 		cfNewtonPolygon.h \
 		cfModResultant.h \
@@ -168,7 +166,12 @@
 		lgs.h \
 		algext.h \
-		singext.h
+		singext.h \
+		parseutil.h
 
 noinst_HEADERS = $(factory_headers)
+
+libfactory_includedir=$(includedir)/factory
+libfactory_include_HEADERS = cplusplus.h factory.h factoryconf.h
+
 
 # Documentation
@@ -185,32 +188,8 @@
 		rm -rf doxygen
 
-# Support for building GF(q)-tables
-
-templatesrc =	\
-		ftmpl_array.cc \
-		ftmpl_factor.cc \
-		ftmpl_functions.h \
-		ftmpl_list.cc \
-		ftmpl_matrix.cc
-templateincl =	\
-		ftmpl_array.h \
-		ftmpl_factor.h \
-		ftmpl_list.h \
-		ftmpl_matrix.h
-
-# TODO:
-# gengftables needs libfactory.a and factory.h AND is needed for generating gftable...
-# somehow the current deps. seem to be broken... 
-# moreover factory.h needs a lot more generated headers, which wouldn't be installed yet
-
-EXTRA_PROGRAMS = gengftables cplusplus
-
-
-gengftables_SOURCES = gengftables-conway.cc
-
-gengftables_LDADD = -L${builddir} -lfactory $(GMP_LIBS) $(NTL_LIBS)
+# the precomputed GF(q)-tables
 
 gftablesdir=$(datadir)/gftables
-gftables_DATA = gftables/10201 gftables/1024 gftables/10609 gftables/11449 \
+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 \
@@ -235,85 +214,82 @@
 
 
-gftables: gengftables
-		@if test -x ${srcdir}/gftables; then \
-			if test ! -x ${builddir}/gftables; then \
-			  ln -snf ${srcdir}/gftables ${builddir}; \
-			fi; \
-		else \
-			echo "This command will take quite a long time to execute;"; \
-			echo "maybe you want to get the tables directly via ftp (see"; \
-			echo "the INSTALL file)."; \
-			${builddir}/gengftables; \
-		fi
-
-.template.h:
-	${srcdir}/bin/makeheader $< $@
-
-BUILT_SOURCES = cplusplus.h factory.h factoryconf.h readcf.cc
-
-
-libfactory_a_include_HEADERS=$(BUILT_SOURCES)
-libfactory_g_a_include_HEADERS=$(BUILT_SOURCES)
+# Support for building GF(q)-tables
+#
+# gengftables needs libfactory.a 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 = -L${builddir} -lfactory $(GMP_LIBS) $(NTL_LIBS)
+
 
 # These files listed below are not used anywhere but are included in
 # the distribution. So they will be tacked on to EXTRA_DIST.
 
+templatesrc =	templates/ftmpl_array.cc \
+		templates/ftmpl_factor.cc \
+		templates/ftmpl_functions.h \
+		templates/ftmpl_list.cc \
+		templates/ftmpl_matrix.cc
+
+templateincl =	templates/ftmpl_array.h \
+		templates/ftmpl_factor.h \
+		templates/ftmpl_list.h \
+		templates/ftmpl_matrix.h
+
 # header templates
-hdrtemplsrc = \
-		factoryconf.template \
+hdrtemplsrc = 	factoryconf.template \
 		factory.template
 
 # FTE source files
-ftestsrc =	\
-		ftest_io.cc \
-		ftest_util.cc \
-		ntl_util.cc
+ftestsrc =	ftest/ftest_io.cc \
+		ftest/ftest_util.cc \
+		ftest/ntl_util.cc
 
 # FTE header files
-ftestincl =	\
-		ftest_io.h \
-		ftest_util.h \
-		ntl_util.h
-
-# FTE m4 source files (exported for `GNUmakefile' in `ftest/').
-# The variable `$(ftestm4develsrc)' may be already initialized
-# from the development `GNUmakefile'.
-ftestm4src =	$(ftestm4develsrc) \
-		commonden.m4 \
-		degree.m4 \
-		deriv.m4 \
-		divides.m4 \
-		divrem.m4 \
-		extgcd.m4 \
-		factorize.m4 \
-		fbinops.m4 \
-		feval.m4 \
-		gcd.m4 \
-		gcd.ntl.m4 \
-		insert.m4 \
-		norm.m4 \
-		resultant.m4 \
-		revert.m4 \
-		sqrfree.m4 \
-		size.m4 \
-		totaldegree.m4
-
-# other files from the FTE
+ftestincl =	ftest/ftest_io.h \
+		ftest/ftest_util.h \
+		ftest/ntl_util.h
+
+ftestm4src =	ftest/commonden.m4 \
+		ftest/degree.m4 \
+		ftest/deriv.m4 \
+		ftest/divides.m4 \
+		ftest/divrem.m4 \
+		ftest/extgcd.m4 \
+		ftest/factorize.m4 \
+		ftest/fbinops.m4 \
+		ftest/feval.m4 \
+		ftest/gcd.m4 \
+		ftest/gcd.ntl.m4 \
+		ftest/insert.m4 \
+		ftest/norm.m4 \
+		ftest/resultant.m4 \
+		ftest/revert.m4 \
+		ftest/sqrfree.m4 \
+		ftest/size.m4 \
+		ftest/totaldegree.m4
+
 ftestdistfiles = \
-		ftest_util.m4
-
-# gengftables.cc gengftables-conway.cc 
+		ftest/ftest_util.m4
+
 EXTRA_DIST =	test_install.cc \
 		$(templatesrc) $(templateincl) $(hdrtemplsrc) \
 		$(ftestsrc) $(ftestincl) $(ftestm4src) $(ftestdistfiles) \
-		doxygen.cfg factory.cfg gen_cf_gmp.template \
+		doxygen.cfg factory.cfg \
 		examples/application.cc \
 		examples/factorize.cc examples/gcd.cc \
 		bin/folding.el bin/fold-docu.el \
-		bin/makeheader bin/gen-readcf $(gftables_DATA)
-
-CLEANFILES = factory.h factoryconf.h cplusplus.h readcf.cc
-
-
+		bin/makeheader bin/gen-readcf 
+
+##################################################
+# autogenerated sources
+
+noinst_PROGRAMS = cplusplus
+
+BUILT_SOURCES = cplusplus.h factory.h factoryconf.h readcf.cc 
+
+CLEANFILES = $(BUILT_SOURCES)
 
 cplusplus_SOURCES = cplusplus.cc
@@ -322,8 +298,13 @@
 	${builddir}/cplusplus > ${builddir}/cplusplus.h
 
-#ftmpl_inst.o:	ftmpl_inst.cc factoryconf.h factory.h \
-#		$(addprefix templates/,$(templatesrc)) \
-#		$(addprefix templates/,$(templateincl))
-#		$(CXX) -c $< $(libfactory_a_CXXFLAGS)  $(INCLUDES) -o $@
+.template.h:
+	${srcdir}/bin/makeheader $< $@
+
+# factory/gfops.cc has the gftables path hardcoded in, so we create a
+# symlink. Remove this rule once gfopts.cc has been fixed. Note that
+# check-local would run in parallel with check, so we can't use it
+# here!
+all-local:
+	[ -d ${builddir}/gftables ] || ln -s ${srcdir}/gftables ${builddir}
 
 ####################################################
@@ -335,13 +316,10 @@
 TESTSSOURCES = test.cc 
 
-test_g: libfactory_g.a
-
 test_g_SOURCES = $(TESTSSOURCES)
 test_g_CFLAGS = -g -Wextra -Wall -pedantic -Wno-long-long -fomit-frame-pointer --no-rtti #ftmpl_inst.o
 test_g_LDADD = -L${builddir} -lfactory_g $(GMP_LIBS) $(NTL_LIBS)
 
-test_r: libfactory.a
-
 test_r_SOURCES = $(TESTSSOURCES)
 test_r_CFLAGS = -O3 -fomit-frame-pointer --no-rtti #ftmpl_inst.o
 test_r_LDADD = -L${builddir} -lfactory $(GMP_LIBS) $(NTL_LIBS)
+
Index: factory/configure.ac
===================================================================
--- factory/configure.ac	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ factory/configure.ac	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -422,4 +422,5 @@
     [test x$with_Singular != xyes && test x$enable_streamio != xno])
 
-AC_OUTPUT(Makefile ftest/GNUmakefile)
-
+AC_CONFIG_FILES([Makefile ftest/GNUmakefile])
+AC_OUTPUT
+
Index: kernel/Makefile.am
===================================================================
--- kernel/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ kernel/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -10,10 +10,8 @@
 
 
-
 CXXTEMPLFLAGS = --no-exceptions ## -fno-implicit-templates
 
-
-lib_LIBRARIES = libkernel.a libkernel_g.a
-
+libkernel_LIBRARIES = libkernel.a libkernel_g.a
+libkerneldir = $(libdir)/singular
 
 libkernel_a_CFLAGS   = -O3 -fomit-frame-pointer -Wextra -Wall -Wno-long-long ${PIPE}
@@ -50,11 +48,8 @@
     f5c.cc ratgring.cc shiftgb.cc gfan.cc \
     linearAlgebra.cc nc.cc preimage.cc \
-    fegetopt.c kInline.h
+    fegetopt.c
 
 libkernel_a_SOURCES   = $(SOURCES)
 libkernel_g_a_SOURCES = $(SOURCES)
-
-libkernel_a_includedir  =${includedir}/kernel/
-libkernel_g_a_includedir=${includedir}/kernel/
 
 KERNELHEADERS = polys.h hutil.h stairc.h ideals.h \
@@ -72,9 +67,10 @@
 	fegetopt.h \
 	ratgring.h shiftgb.h nc.h \
-	gfan.h preimage.h
+	gfan.h preimage.h mod2.h longrat.h timer.h kInline.h modulop.h fast_mult.h \
+	digitech.h tgb.h ringgb.h tgbgauss.h tgb_internal.h \
+	linearAlgebra.h page.h
 
-libkernel_a_include_HEADERS   = $(KERNELHEADERS)
-libkernel_g_a_include_HEADERS = $(KERNELHEADERS)
-
+libkernel_includedir  =${includedir}/singular/kernel/
+libkernel_include_HEADERS   = $(KERNELHEADERS)
 
 if ENABLE_FACTORY
@@ -99,6 +95,7 @@
 testg_CXXFLAGS = -g -Wextra -Wall -Wno-long-long -pedantic ${PIPE} $(CXXTEMPLFLAGS)
 
-testr_SOURCES = test.cc
-testg_SOURCES = test.cc
+testsources = test.cc f5c.h f5data.h f5gb.h f5lists.h
+testr_SOURCES = $(testsources)
+testg_SOURCES = $(testsources)
 
 testr_LDADD = -lkernel -lpolys -lcoeffs -lresources -lreporter -lmisc $(FACTORY_LIBS) -lomalloc $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD}
@@ -112,4 +109,2 @@
 
 
-# noinst_HEADERS =
-
Index: libpolys/Makefile.am
===================================================================
--- libpolys/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ libpolys/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -2,8 +2,4 @@
 
 bin_SCRIPTS = libpolys-config
-
-libpoly_libincludedir = $(libdir)/libpolys/include
-nodist_libpoly_libinclude_HEADERS = config.h
-
 
 PACKAGES=misc reporter resources coeffs polys tests
Index: libpolys/coeffs/Makefile.am
===================================================================
--- libpolys/coeffs/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ libpolys/coeffs/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -1,3 +1,5 @@
-lib_LIBRARIES = libcoeffs.a libcoeffs_g.a
+libcoeffs_LIBRARIES = libcoeffs.a libcoeffs_g.a
+libcoeffsdir = $(libdir)/singular
+
 CXXTEMPLFLAGS =  --no-exceptions 
 ## -fno-implicit-templates
@@ -29,13 +31,6 @@
 libcoeffs_g_a_SOURCES = $(SOURCES)
 
-## include_HEADERS = coeffs.h numbers.h
-
-libcoeffs_a_includedir  =$(includedir)/libpolys/coeffs
-libcoeffs_g_a_includedir=$(includedir)/libpolys/coeffs
-
-COEFFSHEADERS  = coeffs.h numbers.h si_gmp.h
-libcoeffs_a_include_HEADERS   = $(COEFFSHEADERS)
-libcoeffs_g_a_include_HEADERS = $(COEFFSHEADERS)
-
+libcoeffs_includedir  =$(includedir)/singular/coeffs
+libcoeffs_include_HEADERS = coeffs.h numbers.h si_gmp.h
 
 if ENABLE_FACTORY
Index: libpolys/misc/Makefile.am
===================================================================
--- libpolys/misc/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ libpolys/misc/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -1,3 +1,4 @@
-lib_LIBRARIES=libmisc.a libmisc_g.a
+libmisc_LIBRARIES = libmisc.a libmisc_g.a
+libmiscdir = $(libdir)/singular
 
 CXXTEMPLFLAGS      =  --no-exceptions ## -fno-implicit-templates
@@ -19,15 +20,8 @@
 libmisc_g_a_SOURCES = $(SOURCES)
 
-libmisc_a_includedir  =$(includedir)/libpolys/misc
-libmisc_g_a_includedir=$(includedir)/libpolys/misc
-
-###????
-#libmisc_a_libdir  =${libdir}/libpolys
-#libmisc_g_a_libdir=${libdir}/libpolys
-
-MISCHEADERS  = auxiliary.h mylimits.h options.h intvec.h int64vec.h
-libmisc_a_include_HEADERS   = $(MISCHEADERS)
-libmisc_g_a_include_HEADERS = $(MISCHEADERS)
+libmisc_includedir = $(includedir)/singular/misc
+libmisc_include_HEADERS = auxiliary.h mylimits.h options.h intvec.h int64vec.h
 
 
 
+
Index: libpolys/polys/Makefile.am
===================================================================
--- libpolys/polys/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ libpolys/polys/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -1,4 +1,3 @@
 CXXTEMPLFLAGS	=  --no-exceptions ## -fno-implicit-templates
-
 
 DEBUGCXXFLAGS = -g -Wextra -Wall -pedantic -Wno-long-long
@@ -28,45 +27,40 @@
 endif
 
-prCopy.inc: prCopy.pl
-	perl ${srcdir}/prCopy.pl >  prCopy.inc
-
-lib_LIBRARIES=libpolys.a libpolys_g.a
-
-libpolys_a_includedir=$(includedir)/libpolys/polys
-libpolys_g_a_includedir=$(includedir)/libpolys/polys
+libpolys_LIBRARIES = libpolys.a libpolys_g.a
+libpolysdir = $(libdir)/singular
 
 SOURCES = \
 	monomials/monomials.cc monomials/p_polys.cc monomials/ring.cc monomials/maps.cc \
-	operations/pShallowCopyDelete.cc operations/p_Mult_q.cc operations/p_Mult_q.h \
-	templates/p_Procs_Lib.cc templates/p_MemCmp.h templates/p_MemCopy.h templates/p_Numbers.h \
-	templates/p_Procs_Set.h templates/p_Procs_Static.h templates/p_Procs_Dynamic.h \
-	templates/p_Procs_Impl.h \
+	operations/pShallowCopyDelete.cc operations/p_Mult_q.cc \
 	nc/sca.cc nc/summator.cc nc/ncSAFormula.cc nc/ncSACache.cc nc/ncSAMult.cc \
 	pDebug.cc polys0.cc prCopy.cc prCopyMacros.h \
 	kbuckets.cc sbuckets.cc weight.cc weight0.c simpleideals.cc matpol.cc \
 	sparsmat.cc \
-        ${USE_P_PROCS_STATIC_CC} ${USE_P_PROCS_DYNAMIC_CC}  mod_raw.cc \
-        ext_fields/algext.cc ext_fields/algext.h \
-	ext_fields/transext.cc clapsing.cc clapconv.cc \
+        ${USE_P_PROCS_STATIC_CC} ${USE_P_PROCS_DYNAMIC_CC} mod_raw.cc \
+        ext_fields/algext.cc ext_fields/transext.cc \
+	clapsing.cc clapconv.cc \
 	nc/old.gring.cc
-
-#	OLD?: 
-
-BUILT_SOURCES = prCopy.inc templates/p_Procs.inc
-
-noinst_HEADERS =
 
 LIBPOLYSHEADERS = monomials/ring.h monomials/monomials.h \
 	nc/nc.h nc/sca.h nc/summator.h nc/ncSAFormula.h nc/ncSACache.h nc/ncSAMult.h \
-	operations/pShallowCopyDelete.h \
-	templates/p_MemAdd.h \
+	operations/pShallowCopyDelete.h operations/p_Mult_q.h \
 	templates/p_Procs.h mod_raw.h \
 	monomials/p_polys.h monomials/maps.h prCopy.h \
 	kbuckets.h sbuckets.h simpleideals.h weight.h matpol.h \
-	sparsmat.h clapsing.h clapconv.h
+	sparsmat.h clapsing.h clapconv.h coeffrings.h \
+	ext_fields/algext.h ext_fields/transext.h 
 
-### nobase_include_HEADERS = $(LIBPOLYSHEADERS)
-
-
+EXTRA_DIST = \
+	prCopy.pl prCopyTemplate.cc \
+	templates/p_Procs_Lib.cc templates/p_MemCmp.h templates/p_MemCopy.h templates/p_Numbers.h \
+	templates/p_Procs_Set.h templates/p_Procs_Static.h templates/p_Procs_Dynamic.h \
+	templates/p_Procs_Impl.h templates/p_Delete__T.cc templates/p_Copy__T.cc \
+	templates/p_ShallowCopyDelete__T.cc templates/p_MemAdd.h templates/p_Mult_nn__T.cc \
+	templates/pp_Mult_nn__T.cc templates/pp_Mult_mm__T.cc templates/p_Mult_mm__T.cc \
+	templates/pp_Mult_Coeff_mm_DivSelect__T.cc templates/pp_Mult_nn__T.cc \
+	templates/pp_Mult_Coeff_mm_DivSelectMult__T.cc \
+	templates/pp_Mult_mm_Noether__T.cc \
+	templates/p_kBucketSetLm__T.cc templates/p_Minus_mm_Mult_qq__T.cc \
+	templates/p_Merge_q__T.cc templates/p_Add_q__T.cc templates/p_Neg__T.cc
 
 P_PROCS_CPPFLAGS_COMMON = -DDYNAMIC_VERSION 
@@ -121,5 +115,5 @@
 
 
-moduledir = $(libdir)/libpolys/MOD/
+moduledir = $(libdir)/singular/MOD/
 
 if ENABLE_P_PROCS_DYNAMIC
@@ -128,23 +122,24 @@
 endif
 
+libpolys_includedir=$(includedir)/singular/polys
 
-nobase_libpolys_a_include_HEADERS = $(LIBPOLYSHEADERS)
-nobase_libpolys_g_a_include_HEADERS = $(LIBPOLYSHEADERS)
-
+libpolys_include_HEADERS = $(LIBPOLYSHEADERS)
 
 libpolys_a_SOURCES = ${SOURCES}
 libpolys_g_a_SOURCES = ${SOURCES}
 
-## libpolys_adir = $(libdir)/libpolys
-## libpolys_g_adir = $(libdir)/libpolys
-
 EXTRA_libpolys_a_SOURCES = templates/p_Procs_Static.cc templates/p_Procs_Dynamic.cc
 
-EXTRA_PROGRAMS = templates/p_Procs_Generate
-templates_p_Procs_Generate_SOURCES = templates/p_Procs_Generate.cc
+libpolys_g_a_CXXFLAGS = ${DEBUGCXXFLAGS}
+libpolys_a_CPPFLAGS = ${NODEBUGDEFS}
 
 
-###test_LDADD   = libcoeffs.a -lresources -lreporter -lgmp -lomalloc
+#################################################
+# autogenerated sources
 
+BUILT_SOURCES = prCopy.inc templates/p_Procs.inc
+
+noinst_PROGRAMS = templates/p_Procs_Generate
+templates_p_Procs_Generate_SOURCES = templates/p_Procs_Generate.cc
 templates_p_Procs_Generate_CFLAGS   = ${NODEBUGCFLAGS}
 templates_p_Procs_Generate_CXXFLAGS = ${NODEBUGCXXFLAGS}
@@ -156,9 +151,7 @@
 	${builddir}/templates/p_Procs_Generate > ${builddir}/templates/p_Procs.inc
 
-libpolys_g_a_CXXFLAGS = ${DEBUGCXXFLAGS}
-libpolys_a_CPPFLAGS = ${NODEBUGDEFS}
+prCopy.inc: prCopy.pl
+	perl ${srcdir}/prCopy.pl >  prCopy.inc
 
-#  -fdiagnostics-show-option
+CLEANFILES = $(BUILT_SOURCES)
 
-dynamic_modules: ${module_LTLIBRARIES}
-
Index: libpolys/reporter/Makefile.am
===================================================================
--- libpolys/reporter/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ libpolys/reporter/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -1,3 +1,4 @@
-lib_LIBRARIES=libreporter.a libreporter_g.a
+libreporter_LIBRARIES=libreporter.a libreporter_g.a
+libreporterdir = $(libdir)/singular
 
 CXXTEMPLFLAGS =  --no-exceptions ## -fno-implicit-templates
@@ -19,10 +20,7 @@
 libreporter_g_a_SOURCES = $(SOURCES)
 
-libreporter_a_includedir  =$(includedir)/libpolys/reporter
-libreporter_g_a_includedir=$(includedir)/libpolys/reporter
+libreporter_includedir  =$(includedir)/singular/reporter
 
-REPORTERHEADERS = reporter.h 
-libreporter_a_include_HEADERS   = $(REPORTERHEADERS)
-libreporter_g_a_include_HEADERS = $(REPORTERHEADERS)
+libreporter_include_HEADERS   = reporter.h 
 
 
Index: libpolys/resources/Makefile.am
===================================================================
--- libpolys/resources/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ libpolys/resources/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -1,3 +1,4 @@
-lib_LIBRARIES=libresources.a libresources_g.a
+libresources_LIBRARIES=libresources.a libresources_g.a
+libresourcesdir = $(libdir)/singular
 
 CXXTEMPLFLAGS      =  --no-exceptions ## -fno-implicit-templates
@@ -19,10 +20,7 @@
 libresources_g_a_SOURCES = $(SOURCES)
 
-libresources_a_includedir  =$(includedir)/libpolys/resources
-libresources_g_a_includedir=$(includedir)/libpolys/resources
+libresources_includedir  =$(includedir)/singular/resources
 
-RESOURCESHEADERS  = feFopen.h feResource.h
-libresources_a_include_HEADERS   = $(RESOURCESHEADERS)
-libresources_g_a_include_HEADERS = $(RESOURCESHEADERS)
+libresources_include_HEADERS   = feFopen.h feResource.h
 
 
Index: libpolys/tests/Makefile.am
===================================================================
--- libpolys/tests/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ libpolys/tests/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -23,9 +23,7 @@
 
 simple_test_SOURCES = simple_test_runner.cpp
-coeffs_test_SOURCES = coeffs_test_runner.cpp gftables
-polys_test_SOURCES = polys_test_runner.cpp gftables MOD
-rings_test_SOURCES = rings_test_runner.cpp gftables MOD
-
-
+coeffs_test_SOURCES = coeffs_test_runner.cpp
+polys_test_SOURCES = polys_test_runner.cpp
+rings_test_SOURCES = rings_test_runner.cpp
 
 polys_test_LDFLAGS = ${AM_LDFLAGS} ${USEPPROCSDYNAMICLDFLAGS}
@@ -37,5 +35,6 @@
 
 
-BUILT_SOURCES = $(simple_test_SOURCES) $(coeffs_test_SOURCES) $(rings_test_SOURCES) $(polys_test_SOURCES)
+BUILT_SOURCES = gftables MOD \
+	$(simple_test_SOURCES) $(coeffs_test_SOURCES) $(rings_test_SOURCES) $(polys_test_SOURCES)
 
 gftables: ${top_srcdir}/../factory/gftables
@@ -59,2 +58,16 @@
 
 CLEANFILES = $(BUILT_SOURCES)
+
+EXTRA_DIST = simple_test.h coeffs_test.h polys_test.h rings_test.h common.h 		\
+    cxxtest/Descriptions.h       cxxtest/ParenPrinter.h      cxxtest/TestListener.h	\
+    cxxtest/DummyDescriptions.h  cxxtest/QtGui.h             cxxtest/TestRunner.h	\
+    cxxtest/ErrorFormatter.h     cxxtest/RealDescriptions.h  cxxtest/TestSuite.h	\
+    cxxtest/ErrorPrinter.h       cxxtest/SelfTest.h          cxxtest/TestTracker.h	\
+    cxxtest/Flags.h              cxxtest/StdHeaders.h        cxxtest/ValueTraits.h	\
+    cxxtest/GlobalFixture.h      cxxtest/StdioFilePrinter.h  cxxtest/Win32Gui.h		\
+    cxxtest/Gui.h                cxxtest/StdioPrinter.h      cxxtest/X11Gui.h		\
+    cxxtest/LinkedList.h         cxxtest/StdValueTraits.h    cxxtest/YesNoRunner.h	\
+    cxxtest/Mock.h               cxxtest/TeeListener.h					\
+    cxxtest/Descriptions.cpp     cxxtest/LinkedList.cpp      cxxtest/TestSuite.cpp	\
+    cxxtest/DummyDescriptions.cpp cxxtest/RealDescriptions.cpp  cxxtest/TestTracker.cpp \
+    cxxtest/GlobalFixture.cpp    cxxtest/Root.cpp            cxxtest/ValueTraits.cpp
Index: numeric/Makefile.am
===================================================================
--- numeric/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ numeric/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -1,3 +1,4 @@
-lib_LIBRARIES=libnumeric.a libnumeric_g.a
+libnumeric_LIBRARIES = libnumeric.a libnumeric_g.a
+libnumericdir = $(libdir)/singular
 
 CXXTEMPLFLAGS =  --no-exceptions ## -fno-implicit-templates
@@ -19,11 +20,7 @@
 libnumeric_g_a_SOURCES = $(SOURCES)
 
-libnumeric_a_includedir  =$(includedir)/numeric/
-libnumeric_g_a_includedir=$(includedir)/numeric/
+libnumeric_includedir  =$(includedir)/singular/numeric/
 
-NUMERICHEADERS = mpr_base.h mpr_inout.h mpr_numeric.h
-
-libnumeric_a_include_HEADERS   = $(NUMERICHEADERS)
-libnumeric_g_a_include_HEADERS = $(NUMERICHEADERS)
+libnumeric_include_HEADERS = mpr_base.h mpr_inout.h mpr_numeric.h
 
 
Index: omalloc/Makefile.am
===================================================================
--- omalloc/Makefile.am	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ omalloc/Makefile.am	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -1,9 +1,10 @@
+ACLOCAL_AMFLAGS = -I ../m4
 AM_LDFLAGS = -L${top_builddir}/omalloc -L${top_builddir}/../omalloc
 
 lib_LIBRARIES=libomalloc.a libomalloc_g.a
 
-libomalloc_a_includedir=$(includedir)/omalloc
+libomalloc_includedir=$(includedir)/omalloc
 
-libomalloc_a_include_HEADERS=\
+libomalloc_include_HEADERS = \
 omalloc.h		omConfig.h		omDerivedConfig.h	\
 omError.h		omStructs.h		omAllocDecl.h		\
@@ -15,7 +16,6 @@
 omAllocFunc.h 		omlimits.h 		mylimits.h
 
-
-
-noinst_HEADERS= omPage.h omDefaultConfig.h omReturn.h
+noinst_HEADERS= omPage.h omDefaultConfig.h omReturn.h omGetPageSize.h \
+  omMalloc.h omMallocSystem.h
 
 SOURCES=\
@@ -23,6 +23,8 @@
 om_Alloc.c        omDebugCheck.c   omOpts.c         omGetBackTrace.c \
 omAllocSystem.c   omError.c        omStats.c	    omRet2Info.c     \
-omBin.c           omFindExec.c     omDebugTrack.c                    \
+omBin.c           omFindExec.c     omDebugTrack.c   		     \
 omalloc_provide.c omAllocFunc.c
+
+EXTRA_DIST = omalloc.c omtTestAlloc.c omtTest.h
 
 INCLUDES=-I${top_srcdir}/.. -I${top_builddir}/..
@@ -31,6 +33,6 @@
 libomalloc_g_a_SOURCES=$(SOURCES) $(noinst_HEADERS)
 
-nodist_libomalloc_a_SOURCES = omConfig.h omlimits.h mylimits.h omTables.h omalloc.h omTables.inc
-nodist_libomalloc_g_a_SOURCES = omConfig.h omlimits.h omTables.h omalloc.h omTables.inc
+nodist_libomalloc_a_SOURCES = omConfig.h omlimits.h mylimits.h omalloc.h omTables.inc
+nodist_libomalloc_g_a_SOURCES = omConfig.h omlimits.h omalloc.h omTables.inc
 
 libomalloc_a_CPPFLAGS= -DOM_NDEBUG
@@ -48,4 +50,6 @@
 omTables_CPPFLAGS = -DOM_GENERATE_INC
 
+CLEANFILES = $(BUILT_SOURCES)
+
 ####################################################
 ## Test program
@@ -54,5 +58,5 @@
 check_PROGRAMS = $(TESTS)
 
-OMTTESTSSOURCES = omtTestReal.c omtTestDebug.c omtTestKeep.c omtTestError.c omtTest.c 
+OMTTESTSSOURCES = omtTestReal.c omtTestDebug.c omtTestKeep.c omtTestError.c omtTest.c
 
 omtTest_g: libomalloc_g.a
Index: omalloc/configure.ac
===================================================================
--- omalloc/configure.ac	(revision 83db8d3000b4078b3fa1965f387d1f5099e5426e)
+++ omalloc/configure.ac	(revision c2eb2eb7f57eba4dc2374322d7b08a25f89e4529)
@@ -1,4 +1,4 @@
 dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
-dnl File: configure.in
+dnl File: configure.ac
 dnl Purpose: Process this file with autoconf to produce configure
 dnl Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
@@ -516,5 +516,5 @@
 
 AC_MSG_CHECKING(whether to track return addresses)
-if test "$with_track_return" = no || test "$ac_cv_get_return_addr_works" = no || test "$ac_cv_prog_addr2line_works" != yes; then
+if test "$with_track_return" = no || test "$ac_cv_get_return_addr_works" = no || test "$ac_cv_prog_addr2line_works "!= yes; then
   with_track_return=no
 else
@@ -582,7 +582,5 @@
 dnl
 AC_CONFIG_HEADER(config.h omConfig.h omlimits.h)
-
-AC_OUTPUT(Makefile, \
- if test "$CONFIG_HEADERS"; then echo timestamp > stamp-h; fi)
-
-
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+
