commit 3cbead845f607628a44d78583534e6c0a74e9af1
Author: orbea <orbea@riseup.net>
Date:   Mon May 10 09:38:47 2021 -0700

    Fix the build with -no-undefined.
    
    This adds correct usage of LDFLAGS and LIBADD.
    
    Signed-off-by: orbea <orbea@riseup.net>

diff --git a/builder/builder.h b/builder/builder.h
index e92b410..fa0055a 100644
--- a/builder/builder.h
+++ b/builder/builder.h
@@ -51,10 +51,6 @@ typedef struct __builder_module {
   "MAINTAINERCLEANFILES = %s*.h %s*.c %s*~\n\n"                                      \
   "CLEANFILES       = \n"                                                            \
   "\n"                                                                               \
-  "if NEED_FERITE_LIB\n"                                                             \
-  "libferite = -L${top_builddir}/src -lferite\n"                                     \
-  "endif\n\n"                                                                        \
-  "LDFLAGS          = $(libferite) -L${libdir} @%s_LIBS@\n"                          \
   "INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @%s_CFLAGS@\n" \
   "DEFS             = @thread_defs@\n"                                               \
   "\nscripts_DATA   = %s\nscriptsdir       = @FE_XPLAT_LIBRARY_PATH@\n\n"            \
@@ -65,7 +61,7 @@ typedef struct __builder_module {
   "\n"                                                                               \
   "%s_la_SOURCES    = %s %s\n"                                                       \
   "%s_la_LDFLAGS    = -no-undefined -module -avoid-version\n"                        \
-  "%s_la_LIBADD     =\n"                                                             \
+  "%s_la_LIBADD     = ${top_builddir}/src/libferite.la\n"                            \
   "\n"                                                                               \
   "%s_core.c: %s\n"                                                                  \
   "\t%s -m %s %s/%s/%s\n\n%s"    
diff --git a/configure.ac b/configure.ac
index 5b2f644..d5e713d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,8 +78,6 @@ AC_DEFINE_UNQUOTED([PLATFORM], "$platform", [The Platform on which we exist])
 CFLAGS="-DHAVE_CONFIG_HEADER -L$prefix/lib $CFLAGS"
 CCFLAGS="-DHAVE_CONFIG_HEADER  -L$prefix/lib $CCFLAGS"
 
-AM_CONDITIONAL(NEED_FERITE_LIB, test "$system" = "Darwin" -o "$system" = "CYGWIN" -o "$system" = "SunOS" -o "$system" = "MINGW")
-
 AC_PROG_INSTALL
 AC_PROG_MAKE_SET
 
diff --git a/libs/aphex/src/Makefile.am b/libs/aphex/src/Makefile.am
index 2b14cb7..57a8311 100644
--- a/libs/aphex/src/Makefile.am
+++ b/libs/aphex/src/Makefile.am
@@ -6,8 +6,6 @@ AUTOMAKE_OPTIONS     = no-dependencies foreign
 
 MAINTAINERCLEANFILES = Makefile.in
 
-LDFLAGS		         = -L${prefix}/lib
-
 INCLUDES	         = -I${top_srcdir}/libs/aphex/include -I${top_srcdir}/include -I${prefix}/include -I$(includedir) @aphex_INCS@
                        
 			
@@ -18,7 +16,7 @@ noinst_LTLIBRARIES   = libaphex.la
 include_HEADERS      =
 
 libaphex_la_DEPENDENCIES = $(top_builddir)/config.h
-libaphex_la_LDFLAGS      = -no-undefined $(LDFLAGS) -m @aphex_LDFLAGS@
+libaphex_la_LDFLAGS      = -no-undefined -m @aphex_LDFLAGS@
 libaphex_la_LIBADD       = @thread_libs@ @gc_libs@
 
 libaphex_la_SOURCES  = aphex_file.c aphex_directory.c aphex_config.c aphex_match.c aphex_thread.c aphex_notify.c poll.c poll.h
diff --git a/libs/triton/src/Makefile.am b/libs/triton/src/Makefile.am
index 0572996..0b25ba3 100644
--- a/libs/triton/src/Makefile.am
+++ b/libs/triton/src/Makefile.am
@@ -6,8 +6,6 @@ AUTOMAKE_OPTIONS     = no-dependencies foreign
 
 MAINTAINERCLEANFILES = Makefile.in
 
-LDFLAGS		         = -L/usr/local/lib
-
 INCLUDES	         = -I${top_srcdir} -I${top_srcdir}/libs/triton/include -I${top_srcdir}/include -I${prefix}/include -I$(includedir) @TRITON_INCS@
 
 DEFS                 = @debugdefs@
@@ -23,6 +21,6 @@ CLEANFILES = libltdl.la libltdlc.la
 include_HEADERS      =
 
 libtriton_la_DEPENDENCIES = $(top_builddir)/config.h
-libtriton_la_LDFLAGS      = -no-undefined $(LDFLAGS) -m @TRITON_LDFLAGS@
+libtriton_la_LDFLAGS      = -no-undefined -m @TRITON_LDFLAGS@
 
 libtriton_la_SOURCES = triton_core.c  triton_loader_dlfcn.c triton_loader_ltdl.c triton_loader_darwin.c triton_loader_win32.c
diff --git a/modules/array/Makefile.am b/modules/array/Makefile.am
index 9f0475d..8bef2b8 100644
--- a/modules/array/Makefile.am
+++ b/modules/array/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = array*.h array*.c array*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @array_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @array_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = array.la
 
 array_la_SOURCES    = array_core.c array_misc.c array_Array.c array_header.h  util.c util.h 
 array_la_LDFLAGS    = -no-undefined -module -avoid-version
-array_la_LIBADD     =
+array_la_LIBADD     = ${top_builddir}/src/libferite.la
 
 array_core.c: @MODULE_SRC_PREFIX@/array/array.fec 
 	@BUILDER@ -m array @MODULE_SRC_PREFIX@/array/array.fec
diff --git a/modules/date/Makefile.am b/modules/date/Makefile.am
index ab646b4..976baa0 100644
--- a/modules/date/Makefile.am
+++ b/modules/date/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = date*.h date*.c date*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite -L${top_builddir}/modules/stream -lferitestream
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @date_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @date_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = date.la
 
 date_la_SOURCES    = date_core.c date_header.h date_misc.c date_Alarm.c date_Date.c util_date.c util_date.h strptime.c
 date_la_LDFLAGS    = -no-undefined -module -avoid-version
-date_la_LIBADD     =
+date_la_LIBADD     = ${top_builddir}/modules/stream/libferitestream.la
 
 date_core.c: @MODULE_SRC_PREFIX@/date/date.fec
 	@BUILDER@ -m date @MODULE_SRC_PREFIX@/date/date.fec
diff --git a/modules/filesystem/Makefile.am b/modules/filesystem/Makefile.am
index ac5b5e9..227a5ab 100644
--- a/modules/filesystem/Makefile.am
+++ b/modules/filesystem/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = filesystem*.h filesystem*.c filesystem*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite  -L${top_builddir}/modules/stream -lferitestream
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @filesystem_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @filesystem_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = filesystem.la
 
 filesystem_la_SOURCES    = filesystem_core.c filesystem_misc.c filesystem_FileSystem.c filesystem_Directory.c filesystem_File.c filesystem_header.h  
 filesystem_la_LDFLAGS    = -no-undefined -module -avoid-version
-filesystem_la_LIBADD     =
+filesystem_la_LIBADD     = ${top_builddir}/modules/stream/libferitestream.la
 
 filesystem_core.c: @MODULE_SRC_PREFIX@/filesystem/filesystem.fec
 	@BUILDER@ -m filesystem @MODULE_SRC_PREFIX@/filesystem/filesystem.fec
diff --git a/modules/ipc/Makefile.am b/modules/ipc/Makefile.am
index 3367aa2..18f9593 100644
--- a/modules/ipc/Makefile.am
+++ b/modules/ipc/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = ipc*.h ipc*.c ipc*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @ipc_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @ipc_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = ipc.la
 
 ipc_la_SOURCES    = ipc_core.c ipc_misc.c ipc_IPCObject.c ipc_header.h  
 ipc_la_LDFLAGS    = -no-undefined -module -avoid-version
-ipc_la_LIBADD     =
+ipc_la_LIBADD     = ${top_builddir}/src/libferite.la
 
 ipc_core.c: @MODULE_SRC_PREFIX@/ipc/ipc.fec 
 	@BUILDER@ -m ipc @MODULE_SRC_PREFIX@/ipc/ipc.fec
diff --git a/modules/math/Makefile.am b/modules/math/Makefile.am
index 21a2ebc..f3a7f09 100644
--- a/modules/math/Makefile.am
+++ b/modules/math/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = math*.h math*.c math*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @math_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @math_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = math.la
 
 math_la_SOURCES    = math_core.c math_misc.c math_Math.c math_Math_Complex.c math_header.h  
 math_la_LDFLAGS    = -no-undefined -module -avoid-version
-math_la_LIBADD     =
+math_la_LIBADD     = ${top_builddir}/src/libferite.la
 
 math_core.c: @MODULE_SRC_PREFIX@/math/complex.fec @MODULE_SRC_PREFIX@/math/math.fec 
 	@BUILDER@ -m math @MODULE_SRC_PREFIX@/math/math.fec
diff --git a/modules/network/Makefile.am b/modules/network/Makefile.am
index 91aff1a..d753ed7 100644
--- a/modules/network/Makefile.am
+++ b/modules/network/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = network*.h network*.c network*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite -L${top_builddir}/modules/stream -lferitestream
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @network_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @network_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = network.la
 
 network_la_SOURCES    = network_core.c network_misc.c network_Network.c network_Network_TCP.c network_Network_TCP_Stream.c  network_Network_Host.c network_Network_UDP.c network_Network_UDP_Stream.c network_Network_Service.c network_header.h  util_network.c util_network.h 
 network_la_LDFLAGS    = -no-undefined -module -avoid-version
-network_la_LIBADD     =
+network_la_LIBADD     = ${top_builddir}/modules/stream/libferitestream.la
 
 network_core.c: @MODULE_SRC_PREFIX@/network/network.fec 
 	@BUILDER@ -m network @MODULE_SRC_PREFIX@/network/network.fec
diff --git a/modules/number/Makefile.am b/modules/number/Makefile.am
index 6a39962..1203c68 100644
--- a/modules/number/Makefile.am
+++ b/modules/number/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = number*.h number*.c number*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @number_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @number_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = number.la
 
 number_la_SOURCES    = number_core.c number_misc.c number_Number.c number_header.h  
 number_la_LDFLAGS    = -no-undefined -module -avoid-version
-number_la_LIBADD     =
+number_la_LIBADD     = ${top_builddir}/src/libferite.la
 
 number_core.c: @MODULE_SRC_PREFIX@/number/number.fec 
 	@BUILDER@ -m number @MODULE_SRC_PREFIX@/number/number.fec
diff --git a/modules/posix/Makefile.am b/modules/posix/Makefile.am
index 8c5d8e9..bfd96fa 100644
--- a/modules/posix/Makefile.am
+++ b/modules/posix/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = posix*.h posix*.c posix*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite -L${top_builddir}/modules/stream -lferitestream
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @posix_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @posix_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = posix.la
 
 posix_la_SOURCES    = posix_core.c posix_misc.c posix_Posix.c posix_Posix_Uname.c posix_Posix_Rlimit.c posix_Posix_User.c posix_Posix_Pipe.c posix_Posix_Rusage.c posix_Posix_ProcessStream.c posix_Posix_Stat.c posix_Posix_SelectResult.c posix_Posix_Group.c posix_header.h  util_posix.c util_posix.h util_user.c util_user.h util_signal.c util_signal.h
 posix_la_LDFLAGS    = -no-undefined -module -avoid-version
-posix_la_LIBADD     =
+posix_la_LIBADD     = ${top_builddir}/modules/stream/libferitestream.la
 
 posix_core.c: @MODULE_SRC_PREFIX@/posix/posix.fec @MODULE_SRC_PREFIX@/posix/posix_consts.fec
 	@BUILDER@ -m posix @MODULE_SRC_PREFIX@/posix/posix.fec
diff --git a/modules/reflection/Makefile.am b/modules/reflection/Makefile.am
index 8d02b47..0509819 100644
--- a/modules/reflection/Makefile.am
+++ b/modules/reflection/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = reflection*.h reflection*.c reflection*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @reflection_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @reflection_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = reflection.la
 
 reflection_la_SOURCES    = reflection_core.c reflection_misc.c reflection_Reflection.c reflection_Namespace.c reflection_Function.c reflection_Class.c reflection_Variable.c reflection_Object.c reflection_header.h  utility.c 
 reflection_la_LDFLAGS    = -no-undefined -module -avoid-version
-reflection_la_LIBADD     =
+reflection_la_LIBADD     = ${top_builddir}/src/libferite.la
 
 reflection_core.c: @MODULE_SRC_PREFIX@/reflection/reflection.fec 
 	@BUILDER@ -m reflection @MODULE_SRC_PREFIX@/reflection/reflection.fec
diff --git a/modules/regexp/Makefile.am b/modules/regexp/Makefile.am
index 9bf9df6..4bf74be 100644
--- a/modules/regexp/Makefile.am
+++ b/modules/regexp/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = regexp*.h regexp*.c regexp*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @regexp_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @regexp_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = regexp.la
 
 regexp_la_SOURCES    = regexp_core.c regexp_misc.c regexp_MatchObject.c regexp_Regexp.c regexp_header.h  
 regexp_la_LDFLAGS    = -no-undefined -module -avoid-version
-regexp_la_LIBADD     =
+regexp_la_LIBADD     = ${top_builddir}/src/libferite.la
 
 regexp_core.c: @MODULE_SRC_PREFIX@/regexp/regexp.fec  
 	@BUILDER@ -m regexp @MODULE_SRC_PREFIX@/regexp/regexp.fec
diff --git a/modules/serialize/Makefile.am b/modules/serialize/Makefile.am
index 0d40c38..ac58c8a 100644
--- a/modules/serialize/Makefile.am
+++ b/modules/serialize/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = serialize*.h serialize*.c serialize*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @serialize_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @serialize_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = serialize.la
 
 serialize_la_SOURCES    = serialize_core.c serialize_misc.c serialize_Serialize.c serialize_header.h  utility.c utility.h 
 serialize_la_LDFLAGS    = -no-undefined -module -avoid-version
-serialize_la_LIBADD     =
+serialize_la_LIBADD     = ${top_builddir}/src/libferite.la
 
 serialize_core.c: @MODULE_SRC_PREFIX@/serialize/serialize.fec 
 	@BUILDER@ -m serialize @MODULE_SRC_PREFIX@/serialize/serialize.fec
diff --git a/modules/stream/Makefile.am b/modules/stream/Makefile.am
index 5f6adf1..1ed7e61 100644
--- a/modules/stream/Makefile.am
+++ b/modules/stream/Makefile.am
@@ -7,18 +7,12 @@ MAINTAINERCLEANFILES = stream*.h stream*.c stream*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @stream_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @stream_CFLAGS@
 DEFS             = @thread_defs@
 
 lib_LTLIBRARIES  = libferitestream.la
 libferitestream_la_SOURCES = util_stream.c
-libferitestream_la_LIBADD       = $(LDFLAGS)	 
-libferitestream_la_DEPENDENCIES = 
+libferitestream_la_LIBADD       = ${top_builddir}/src/libferite.la
 libferitestream_la_LDFLAGS      = -version-info 1:0:0 -export-dynamic -no-undefined
 
 fsl_DATA         = util_stream.h
@@ -36,7 +30,7 @@ pkg_LTLIBRARIES  = stream.la
 
 stream_la_SOURCES    = stream_core.c stream_misc.c stream_Stream.c stream_Stream_Stream.c stream_Stream_StdioStream.c stream_Stream_StringStream.c stream_Stream_PointerObject.c stream_header.h  util_stream.c util_stream.h 
 stream_la_LDFLAGS    = -no-undefined -module -avoid-version  -L. -lferitestream
-stream_la_LIBADD     =
+stream_la_LIBADD     = libferitestream.la
 
 stream_core.c: @MODULE_SRC_PREFIX@/stream/stream.fec
 	@BUILDER@ -m stream @MODULE_SRC_PREFIX@/stream/stream.fec
diff --git a/modules/string/Makefile.am b/modules/string/Makefile.am
index 851d2ff..ff83887 100644
--- a/modules/string/Makefile.am
+++ b/modules/string/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = string*.h string*.c string*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @string_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @string_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = string.la
 
 string_la_SOURCES    = string_core.c string_misc.c string_String.c string_header.h  
 string_la_LDFLAGS    = -no-undefined -module -avoid-version
-string_la_LIBADD     =
+string_la_LIBADD     = ${top_builddir}/src/libferite.la
 
 string_core.c: @MODULE_SRC_PREFIX@/string/string.fec 
 	@BUILDER@ -m string @MODULE_SRC_PREFIX@/string/string.fec
diff --git a/modules/sys/Makefile.am b/modules/sys/Makefile.am
index ac60b56..01c7e8f 100644
--- a/modules/sys/Makefile.am
+++ b/modules/sys/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = sys*.h sys*.c sys*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite -L${top_builddir}/modules/stream -lferitestream
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @sys_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @sys_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = sys.la
 
 sys_la_SOURCES    = sys_core.c sys_misc.c sys_Sys.c sys_Sys_env.c sys_header.h   
 sys_la_LDFLAGS    = -no-undefined -module -avoid-version
-sys_la_LIBADD     =
+sys_la_LIBADD     = ${top_builddir}/modules/stream/libferitestream.la
 
 sys_core.c: @MODULE_SRC_PREFIX@/sys/env.fec @MODULE_SRC_PREFIX@/sys/std.fec @MODULE_SRC_PREFIX@/sys/sys.fec
 	@BUILDER@ -m sys @MODULE_SRC_PREFIX@/sys/sys.fec
diff --git a/modules/test/Makefile.am b/modules/test/Makefile.am
index aeb7940..b99b0de 100644
--- a/modules/test/Makefile.am
+++ b/modules/test/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = test*.h test*.c test*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @test_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @test_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = test.la
 
 test_la_SOURCES    = test_core.c test_misc.c test_Test.c test_header.h  utility.c utility.h 
 test_la_LDFLAGS    = -no-undefined -module -avoid-version
-test_la_LIBADD     =
+test_la_LIBADD     = ${top_builddir}/src/libferite.la
 
 test_core.c: @MODULE_SRC_PREFIX@/test/test.fec 
 	@BUILDER@ -m test @MODULE_SRC_PREFIX@/test/test.fec
diff --git a/modules/thread/Makefile.am b/modules/thread/Makefile.am
index 3d6cfb2..c5438e4 100644
--- a/modules/thread/Makefile.am
+++ b/modules/thread/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = thread*.h thread*.c thread*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @thread_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @thread_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = thread.la
 
 thread_la_SOURCES    = thread_core.c thread_misc.c thread_Thread.c thread_Mutex.c thread_Event.c thread_header.h  utility.c 
 thread_la_LDFLAGS    = -no-undefined -module -avoid-version
-thread_la_LIBADD     =
+thread_la_LIBADD     = ${top_builddir}/src/libferite.la
 
 thread_core.c: @MODULE_SRC_PREFIX@/thread/thread.fec 
 	@BUILDER@ -m thread @MODULE_SRC_PREFIX@/thread/thread.fec
diff --git a/modules/unix/Makefile.am b/modules/unix/Makefile.am
index 7999784..8fea3e7 100644
--- a/modules/unix/Makefile.am
+++ b/modules/unix/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = unix*.h unix*.c unix*~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite -L${top_builddir}/modules/stream -lferitestream
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @unix_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @unix_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = unix.la
 
 unix_la_SOURCES    = unix_core.c unix_misc.c unix_Unix.c unix_Unix_SyslogStream.c unix_Network.c unix_Network_Unix.c unix_Network_Unix_Stream.c unix_header.h  
 unix_la_LDFLAGS    = -no-undefined -module -avoid-version
-unix_la_LIBADD     =
+unix_la_LIBADD     = ${top_builddir}/modules/stream/libferitestream.la
 
 unix_core.c: @MODULE_SRC_PREFIX@/unix/unix.fec @MODULE_SRC_PREFIX@/unix/syslog.fec @MODULE_SRC_PREFIX@/unix/unixsocket.fec
 	@BUILDER@ -m unix @MODULE_SRC_PREFIX@/unix/unix.fec
diff --git a/modules/xml/Makefile.am b/modules/xml/Makefile.am
index 71a88a9..26c7cbb 100644
--- a/modules/xml/Makefile.am
+++ b/modules/xml/Makefile.am
@@ -7,11 +7,6 @@ MAINTAINERCLEANFILES = xml*.h xml*.c xml*~~
 
 CLEANFILES       = 
 
-if NEED_FERITE_LIB
-libferite = -L${top_builddir}/src -lferite
-endif
-
-LDFLAGS          = $(libferite) -L${libdir} @xml_LIBS@
 INCLUDES         = -I$(top_srcdir)/include -I$(prefix)/include -I. @xml_CFLAGS@
 DEFS             = @thread_defs@
 
@@ -27,7 +22,7 @@ pkg_LTLIBRARIES  = xml.la
 
 xml_la_SOURCES    = xml_core.c xml_misc.c xml_XML.c xml_XML_SAXParser.c xml_XML_TreeParser.c xml_header.h  sax_handlers.c sax_handlers.h tree_handlers.c tree_handlers.h xpath_handlers.c xpath_handlers.h xml_XML_Element.c
 xml_la_LDFLAGS    = -no-undefined -module -avoid-version
-xml_la_LIBADD     =
+xml_la_LIBADD     = ${top_builddir}/src/libferite.la @xml_LIBS@
 
 xml_core.c: @MODULE_SRC_PREFIX@/xml/xml.fec 
 	@BUILDER@ -m xml @MODULE_SRC_PREFIX@/xml/xml.fec
diff --git a/src/Makefile.am b/src/Makefile.am
index 01c8649..fa2e41e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,8 +8,6 @@ MAINTAINERCLEANFILES = Makefile.in
 
 CLEANFILES       = *~
 
-LDFLAGS		     = -L${prefix}/lib -lm
-
 INCLUDES	     = -I$(top_srcdir) -I$(top_srcdir)/libs/aphex/include -I$(top_srcdir)/libs/triton/include -I${top_srcdir}/include -I${prefix}/include -I$(includedir) -I${top_srcdir}/include/ferite/ @pcre_cflags@
 
 DEFS                 = @debugdefs@ @thread_defs@ @gc_defs@
@@ -69,6 +67,6 @@ EXTRA_DIST = ferite_parser.y ferite_scanner.l
 
 libferite_la_LIBADD       = $(top_builddir)/libs/triton/src/libtriton.la \
                             $(top_builddir)/libs/aphex/src/libaphex.la \
-							-lm @pcre_libs@ @thread_libs@ @gc_libs@ $(LDFLAGS)	 
+                            -lm @pcre_libs@ @thread_libs@ @gc_libs@
 libferite_la_DEPENDENCIES = $(top_builddir)/config.h $(top_builddir)/libs/triton/src/libtriton.la $(top_builddir)/libs/aphex/src/libaphex.la
 libferite_la_LDFLAGS      = -version-info 1:1:0 -export-dynamic -no-undefined
