Index: Singular/Makefile.am
===================================================================
--- Singular/Makefile.am	(revision ea5f3f6ec425ba64388b5f649fd56fcc93a4cd8d)
+++ Singular/Makefile.am	(revision 99b54a02eca0fe05e0d8b5bd6b722ba3946a46ea)
@@ -17,5 +17,50 @@
 # 
 
-AM_CPPFLAGS = -I${top_srcdir} -I${top_builddir} -I${top_srcdir}/numeric -I${top_builddir}/numeric -I${top_srcdir}/kernel -I${top_builddir}/kernel -I${top_srcdir}/libpolys -I${top_builddir}/libpolys $(GMP_CFLAGS) -I${top_srcdir}/factory/include -I${top_builddir}/factory/include $(FACTORY_CFLAGS) $(NTL_CFLAGS) $(FLINT_CFLAGS) ${EMBED_PYOBJECT_CFLAGS} -DHAVE_CONFIG_H 
+
+if ENABLE_FACTORY
+  USE_FACTORY = -L${top_builddir}/factory
+else
+  USE_FACTORY =
+endif
+
+AM_CPPFLAGS = -I${top_srcdir} -I${top_builddir} -I${top_srcdir}/numeric -I${top_builddir}/numeric -I${top_srcdir}/kernel -I${top_builddir}/kernel -I${top_srcdir}/libpolys -I${top_builddir}/libpolys $(GMP_CFLAGS) -I${top_srcdir}/factory/include -I${top_builddir}/factory/include $(FACTORY_CFLAGS) $(NTL_CFLAGS) $(FLINT_CFLAGS) -DHAVE_CONFIG_H
+AMLDFLAGS = -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/misc $(USE_FACTORY) -L${top_builddir}/omalloc -L${top_builddir}/resources
+
+########################### Dynamic Modules... #########################
+if ENABLE_P_PROCS_DYNAMIC
+  moduledir = $(libexecdir)/singular/MOD
+else !ENABLE_P_PROCS_DYNAMIC
+  moduledir = $(libdir)/singular
+endif !ENABLE_P_PROCS_DYNAMIC
+
+if PYTHON_USE
+  PY=pyobject.la
+else !PYTHON_USE
+  PY=
+endif !PYTHON_USE
+
+if SI_EMBED_PYTHON
+  EMBED_PYOBJECT = ${PY} ${top_builddir}/dyn_modules/syzextra/syzextra.la 
+else !SI_EMBED_PYTHON
+  EMBED_PYOBJECT = 
+endif !SI_EMBED_PYTHON
+
+##########################################################################
+module_LTLIBRARIES = pyobject.la
+
+pyobject_la_SOURCES = pyobject.cc
+
+# pyobject_la_CPPFLAGS   = ${AM_CPPFLAGS} ${NODEBUGDEFS}
+# pyobject_g_la_CPPFLAGS = ${AM_CPPFLAGS}
+
+pyobject_la_CXXFLAGS = @PYTHON_CSPEC@
+pyobject_la_CFLAGS   = @PYTHON_CSPEC@ 
+
+# ${NODEBUGCXXFLAGS} 
+# pyobject_g_la_CXXFLAGS = ${DEBUGCXXFLAGS} @PYTHON_CSPEC@
+
+pyobject_la_LDFLAGS = ${AMLDFLAGS} @PYTHON_LSPEC@ -module -export-dynamic -avoid-version -flat_namespace -weak_reference_mismatches weak -undefined dynamic_lookup
+###  -export-dynamic -shared -module -avoid-version (add to all DMs?)
+
 
 ########################### libSingular* #########################
@@ -101,6 +146,6 @@
 #   links/slInit_Dynamic.cc
 
-libSingular_la_SOURCES   = $(SOURCES) feOpt.inc
-# libSingular_g_la_SOURCES = $(SOURCES) feOpt.inc
+libSingular_la_SOURCES   = $(SOURCES)
+# libSingular_g_la_SOURCES = $(SOURCES)
 
 SingularHEADERS =    Cache.h \
@@ -164,17 +209,21 @@
 
 # plural_cmd.inc
-nodist_libSingular_la_SOURCES = iparith.inc
+nodist_libSingular_la_SOURCES = feOpt.inc iparith.inc ${EMBED_PYOBJECT}
 # nodist_libSingular_g_la_SOURCES = iparith.inc
 
-libSingular_la_LDFLAGS    = -release ${PACKAGE_VERSION}
+libSingular_la_LDFLAGS    =  -release ${PACKAGE_VERSION} ${AMLDFLAGS} ${EMBED_PYOBJECT} \
+-lnumeric -lkernel -lpolys -lcoeffs -lreporter -lmisc \
+$(FACTORY_LIBS) -lomalloc -lresources $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD}
+
+libSingular_la_LIBADD      = ${EMBED_PYOBJECT} \
+-lnumeric -lkernel -lpolys -lcoeffs -lreporter -lmisc \
+$(FACTORY_LIBS) -lomalloc -lresources $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD}
+
+# ${top_builddir}/numeric/libnumeric.la ${top_builddir}/kernel/libkernel.la ${top_builddir}/libpolys/polys/libpolys.la 
+
+
 
 libSingular_includedir = ${includedir}/singular/Singular/
 nobase_libSingular_include_HEADERS = $(SingularHEADERS)
-
-if ENABLE_FACTORY
-  USE_FACTORY = -L${top_builddir}/factory
-else
-  USE_FACTORY =
-endif
 
 #########################################################
@@ -220,6 +269,4 @@
 Singular ESingular TSingular $(optional_Singular_programs): ${abs_builddir}/LIB
 
-AMLDFLAGS = -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/misc $(USE_FACTORY) -L${top_builddir}/omalloc -L${top_builddir}/resources
-
 # Singular_CFLAGS = -O3 -fomit-frame-pointer ${PIPE}
 # Singularg_CFLAGS = -g ${PIPE}
@@ -234,5 +281,6 @@
 # Singularg_SOURCES = tesths.cc fegetopt.c fegetopt.h utils.cc  utils.h
 
-Singular_LDADD = libSingular.la ${top_builddir}/numeric/libnumeric.la ${top_builddir}/kernel/libkernel.la ${top_builddir}/libpolys/polys/libpolys.la -lcoeffs -lreporter -lmisc $(FACTORY_LIBS) -lomalloc -lresources $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${EMBED_PYOBJECT_LDFLAGS}
+Singular_LDADD = libSingular.la
+
 # Singularg_LDADD = libSingular_g.la ${top_builddir}/numeric/libnumeric_g.la ${top_builddir}/kernel/libkernel_g.la ${top_builddir}/libpolys/polys/libpolys_g.la -lcoeffs_g -lreporter_g -lmisc_g $(FACTORY_LIBS) -lomalloc_g -lresources_g $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS}  ${USEPPROCSDYNAMICLD} ${EMBED_PYOBJECT_LDFLAGS}
 
@@ -257,5 +305,7 @@
 # nodist_Singulardg_SOURCES =  libSingular_g.la
 
-Singulard_LDADD = libSingular.la -lnumeric -lkernel -lpolys -lcoeffs -lreporter -lmisc $(FACTORY_LIBS) -lomalloc -lresources $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${EMBED_PYOBJECT_LDFLAGS}
+#  ${EMBED_PYOBJECT_LDFLAGS}  ${EMBED_PYOBJECT_LDFLAGS}
+Singulard_LDADD = libSingular.la
+
 # Singulardg_LDADD = libSingular_g.la -lnumeric_g -lkernel_g -lpolys_g -lcoeffs_g -lreporter_g -lmisc_g $(FACTORY_LIBS) -lomalloc_g -lresources_g $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS}  ${USEPPROCSDYNAMICLD} ${EMBED_PYOBJECT_LDFLAGS}
 
@@ -351,7 +401,19 @@
 test_s_r_SOURCES = test.cc
 #test_s_g_SOURCES = test.cc
-
-test_s_r_LDADD = libSingular.la -lnumeric -lkernel -lpolys -lcoeffs -lreporter -lmisc $(FACTORY_LIBS) -lomalloc -lresources $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${EMBED_PYOBJECT_LDFLAGS}
-#test_s_g_LDADD = libSingular_g.la -lnumeric_g -lkernel_g -lpolys_g -lcoeffs_g -lreporter_g -lmisc_g $(FACTORY_LIBS) -lomalloc_g -lresources_g $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS}  ${USEPPROCSDYNAMICLD} ${EMBED_PYOBJECT_LDFLAGS}
+# ${EMBED_PYOBJECT_LDFLAGS}
+test_s_r_LDADD = libSingular.la 
+
+#-lnumeric -lkernel -lpolys -lcoeffs \
+#-lreporter -lmisc $(FACTORY_LIBS) -lomalloc -lresources $(FLINT_LIBS) \
+#$(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} \
+#${EMBED_PYOBJECT}
+
+#test_s_g_LDADD = libSingular_g.la 
+#-lnumeric_g -lkernel_g -lpolys_g \
+#-lcoeffs_g -lreporter_g -lmisc_g $(FACTORY_LIBS) -lomalloc_g \
+#-lresources_g $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) \
+#${USEPPROCSDYNAMICLDFLAGS}  ${USEPPROCSDYNAMICLD} \
+#${EMBED_PYOBJECT}
+
 
 # test_s_r_CPPFLAGS = ${AM_CPPFLAGS} -DHAVE_CONFIG_H
@@ -373,6 +435,7 @@
 test_d_r_SOURCES = test.cc
 # test_d_g_SOURCES = test.cc
-
-test_d_r_LDADD = libSingular.la -lnumeric -lkernel -lpolys -lcoeffs -lreporter -lmisc $(FACTORY_LIBS) -lomalloc -lresources $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${EMBED_PYOBJECT_LDFLAGS}
+#  ${EMBED_PYOBJECT_LDFLAGS}
+test_d_r_LDADD = libSingular.la 
+# -lnumeric -lkernel -lpolys -lcoeffs -lreporter -lmisc $(FACTORY_LIBS) -lomalloc -lresources $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD}
 # test_d_g_LDADD = libSingular_g.la -lnumeric_g -lkernel_g -lpolys_g -lcoeffs_g -lreporter_g -lmisc_g $(FACTORY_LIBS) -lomalloc_g -lresources_g $(FLINT_LIBS) $(NTL_LIBS) $(GMP_LIBS) ${USEPPROCSDYNAMICLDFLAGS}  ${USEPPROCSDYNAMICLD} ${EMBED_PYOBJECT_LDFLAGS}
 
@@ -381,5 +444,5 @@
 # test_d_g_CPPFLAGS = ${AM_CPPFLAGS} -DHAVE_CONFIG_H
 
-test_d_r_LDFLAGS = ${AMLDFLAGS}
+#test_d_r_LDFLAGS = ${AMLDFLAGS}
 # test_d_g_LDFLAGS = ${AMLDFLAGS}
 
@@ -424,22 +487,2 @@
 	ln -snf ${top_builddir}/libpolys/polys/.libs/ ${builddir}/MOD
 
-moduledir = $(libexecdir)/singular/MOD
-
-module_LTLIBRARIES =
-
-if ENABLE_P_PROCS_DYNAMIC
-if PYTHON_MODULE
-module_LTLIBRARIES += pyobject.la
-endif
-endif
-
-pyobject_la_SOURCES = pyobject.cc
-# pyobject_la_CPPFLAGS   = ${AM_CPPFLAGS} ${NODEBUGDEFS}
-# pyobject_g_la_CPPFLAGS = ${AM_CPPFLAGS}
-
-pyobject_la_CXXFLAGS   = @PYTHON_CSPEC@ 
-# ${NODEBUGCXXFLAGS} 
-# pyobject_g_la_CXXFLAGS = ${DEBUGCXXFLAGS} @PYTHON_CSPEC@
-
-pyobject_la_LDFLAGS = -export-dynamic -shared -module -avoid-version ${AMLDFLAGS} @PYTHON_LSPEC@
-###  -export-dynamic -shared -module -avoid-version (add to all DMs?)
Index: configure.ac
===================================================================
--- configure.ac	(revision ea5f3f6ec425ba64388b5f649fd56fcc93a4cd8d)
+++ configure.ac	(revision 99b54a02eca0fe05e0d8b5bd6b722ba3946a46ea)
@@ -163,17 +163,21 @@
 AC_CONFIG_FILES([kernel/Makefile])
 AC_CONFIG_FILES([numeric/Makefile])
-AC_CONFIG_FILES([Singular/Makefile])
+
+AC_CONFIG_SUBDIRS([gfanlib])
+
 AC_CONFIG_FILES([dyn_modules/Makefile])
 AC_CONFIG_FILES([dyn_modules/bigintm/Makefile])
 AC_CONFIG_FILES([dyn_modules/syzextra/Makefile])
 AC_CONFIG_FILES([dyn_modules/callgfanlib/Makefile])
+
+AC_CONFIG_FILES([Singular/Makefile])
+
 AC_CONFIG_FILES([IntegerProgramming/Makefile])
-AC_CONFIG_FILES([libsingular-config])
-
-AC_CONFIG_SUBDIRS([gfanlib])
 
 AC_CONFIG_FILES([redhat/singular.spec])
 # AC_CONFIG_FILES([desktop/Singular.desktop])
 # AC_CONFIG_FILES([desktop/Singular-manual.desktop])
+
+AC_CONFIG_FILES([libsingular-config])
 
 AC_CONFIG_FILES([redhat/Makefile])
Index: dyn_modules/bigintm/Makefile.am
===================================================================
--- dyn_modules/bigintm/Makefile.am	(revision ea5f3f6ec425ba64388b5f649fd56fcc93a4cd8d)
+++ dyn_modules/bigintm/Makefile.am	(revision 99b54a02eca0fe05e0d8b5bd6b722ba3946a46ea)
@@ -60,12 +60,10 @@
 
 if ENABLE_P_PROCS_DYNAMIC
-  P_PROCS_MODULE_LDFLAGS = ${AMLDFLAGS} -shared -module
-#   P_PROCS_MODULE_LDFLAGSG = ${AMLDFLAGS} -shared -module
+  P_PROCS_MODULE_LDFLAGS = ${AMLDFLAGS} -shared -module -dynamic -flat_namespace -weak_reference_mismatches weak -undefined dynamic_lookup
 else
   P_PROCS_MODULE_LDFLAGS = ${AMLDFLAGS}
-#   P_PROCS_MODULE_LDFLAGSG = ${AMLDFLAGS}
 endif
 
-# Add under Mac OS X: -twolevel_namespace -weak_reference_mismatches weak -undefined dynamic_lookup
+# Add under Mac OS X: -flat_namespace -weak_reference_mismatches weak -undefined dynamic_lookup
 
 bigintm_la_LDFLAGS = ${P_PROCS_MODULE_LDFLAGS}
Index: dyn_modules/callgfanlib/Makefile.am
===================================================================
--- dyn_modules/callgfanlib/Makefile.am	(revision ea5f3f6ec425ba64388b5f649fd56fcc93a4cd8d)
+++ dyn_modules/callgfanlib/Makefile.am	(revision 99b54a02eca0fe05e0d8b5bd6b722ba3946a46ea)
@@ -56,12 +56,10 @@
 
 if ENABLE_P_PROCS_DYNAMIC
-  P_PROCS_MODULE_LDFLAGS = ${AMLDFLAGS} -shared -module
-#  P_PROCS_MODULE_LDFLAGSG = ${AMLDFLAGS} -shared -module
+  P_PROCS_MODULE_LDFLAGS = ${AMLDFLAGS} -shared -module -dynamic -flat_namespace -weak_reference_mismatches weak -undefined dynamic_lookup
 else
   P_PROCS_MODULE_LDFLAGS = ${AMLDFLAGS}
-#  P_PROCS_MODULE_LDFLAGSG = ${AMLDFLAGS}
 endif
 
-# Add under Mac OS X: -twolevel_namespace -weak_reference_mismatches weak -undefined dynamic_lookup
+# Add under Mac OS X: -flat_namespace -weak_reference_mismatches weak -undefined dynamic_lookup
 
 gfanlib_la_LDFLAGS = ${P_PROCS_MODULE_LDFLAGS}
Index: dyn_modules/syzextra/Makefile.am
===================================================================
--- dyn_modules/syzextra/Makefile.am	(revision ea5f3f6ec425ba64388b5f649fd56fcc93a4cd8d)
+++ dyn_modules/syzextra/Makefile.am	(revision 99b54a02eca0fe05e0d8b5bd6b722ba3946a46ea)
@@ -1,14 +1,18 @@
 ACLOCAL_AMFLAGS = -I ../../m4
 
-moduledir = $(libexecdir)/singular/MOD
+if ENABLE_P_PROCS_DYNAMIC
+  moduledir = $(libexecdir)/singular/MOD
+else
+  moduledir = $(libdir)/singular
+endif
 
-if ENABLE_P_PROCS_DYNAMIC
+
 module_LTLIBRARIES=syzextra.la 
 
+#if ENABLE_P_PROCS_DYNAMIC
 # if WANT_DEBUG
 # module_LTLIBRARIES+=syzextra_g.la
 # endif
-  
-endif
+#endif
 
 if ENABLE_FACTORY
@@ -53,14 +57,12 @@
 # syzextra_g_la_CPPFLAGS = ${MYINCLUDES} ${P_PROCS_CPPFLAGS_COMMON}
 
-#syzextra_la_CXXFLAGS   = ${NODEBUGCXXFLAGS}
+syzextra_la_CXXFLAGS   = 
+# ${NODEBUGCXXFLAGS}
 #syzextra_g_la_CXXFLAGS = ${DEBUGCXXFLAGS}
 
-P_PROCS_MODULE_LDFLAGS = -shared -module ${AMLDFLAGS}
-# P_PROCS_MODULE_LDFLAGSG = -shared -module ${AMLDFLAGS}
-
-# Add under Mac OS X: -twolevel_namespace -weak_reference_mismatches weak -undefined dynamic_lookup
+P_PROCS_MODULE_LDFLAGS = ${AMLDFLAGS} -module -flat_namespace -weak_reference_mismatches weak -undefined dynamic_lookup
+# Add under Mac OS X: -flat_namespace -weak_reference_mismatches weak -undefined dynamic_lookup
 
 syzextra_la_LDFLAGS = ${P_PROCS_MODULE_LDFLAGS}
-# syzextra_g_la_LDFLAGS = ${P_PROCS_MODULE_LDFLAGSG}
 
 AM_COLOR_TESTS=always
Index: libpolys/polys/Makefile.am
===================================================================
--- libpolys/polys/Makefile.am	(revision ea5f3f6ec425ba64388b5f649fd56fcc93a4cd8d)
+++ libpolys/polys/Makefile.am	(revision 99b54a02eca0fe05e0d8b5bd6b722ba3946a46ea)
@@ -102,6 +102,5 @@
 # p_Procs_FieldZp_g_la_CXXFLAGS = ${DEBUGCXXFLAGS}
 
-P_PROCS_MODULE_LDFLAGS = -shared -module
-P_PROCS_MODULE_LDFLAGSG = -shared -module
+P_PROCS_MODULE_LDFLAGS = -shared -module -dynamic -export-dynamic -avoid-version -weak_reference_mismatches weak -undefined dynamic_lookup -Wl,-undefined -Wl,dynamic_lookup -flat_namespace
 
 p_Procs_FieldGeneral_la_LDFLAGS = ${P_PROCS_MODULE_LDFLAGS}
Index: m4/ax_python_with_version.m4
===================================================================
--- m4/ax_python_with_version.m4	(revision ea5f3f6ec425ba64388b5f649fd56fcc93a4cd8d)
+++ m4/ax_python_with_version.m4	(revision 99b54a02eca0fe05e0d8b5bd6b722ba3946a46ea)
@@ -112,6 +112,6 @@
         then 
           AC_DEFINE(EMBED_PYTHON,1,integrate python)
-          AC_SUBST(EMBED_PYOBJECT_CFLAGS,"\${PYTHON_CSPEC}")
-          AC_SUBST(EMBED_PYOBJECT_LDFLAGS,"\${PYTHON_LSPEC}")
+#          AC_SUBST(EMBED_PYOBJECT_CFLAGS,"\${PYTHON_CSPEC}")
+#          AC_SUBST(EMBED_PYOBJECT_LDFLAGS,"\${PYTHON_LSPEC}")
         fi
 	if test x"$ax_python_use" = x"true" 
Index: m4/flags.m4
===================================================================
--- m4/flags.m4	(revision ea5f3f6ec425ba64388b5f649fd56fcc93a4cd8d)
+++ m4/flags.m4	(revision 99b54a02eca0fe05e0d8b5bd6b722ba3946a46ea)
@@ -103,6 +103,6 @@
  fi
  
- if test "x${ENABLE_OPTIMIZATION}" != xno; then
-  OPTFLAGS="-DOM_NDEBUG -DNDEBUG -O2 -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -fomit-frame-pointer -fwrapv"
+ if test "x${ENABLE_OPTIMIZATION}" != xno; then 
+  OPTFLAGS="-DOM_NDEBUG -DNDEBUG -O2 -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -fomit-frame-pointer -fwrapv -fpermissive -fvisibility=default"
   #  -O3 - crashes gcc???!!!  
   AC_LANG_PUSH([C])
@@ -117,5 +117,6 @@
   AX_APPEND_LINK_FLAGS([-fno-exceptions -fno-rtti -fpermissive])
 #  AX_APPEND_LINK_FLAGS([-fno-implicit-templates]) # see above :(
-#  AX_APPEND_LINK_FLAGS([-rdynamic]) 
+  AX_APPEND_LINK_FLAGS([-rdynamic]) 
+  AX_APPEND_LINK_FLAGS([-flat_namespace -Wl,-bind_at_load -Wl,-undefined,dynamic_lookup  -fpermissive -fvisibility=default]) 
  fi
 
