Hi,

the test suite uses the --whole-archive and --no-whole-archive
flags hard coded in the automake makefiles. The reason seems to
be to properly link the static convencience libraries
from the various sub directories into the executable, since
the main program does not reference any symbols from the libraries
and without those flags the linker would decide to drop the objects
(the libraries register the test cases in the cppunit framework
through global variables). However, whole-archive flags
are system dependant and non-portable (one reason why building
the test suite on solaris currently fails).

I did not find any possibility to tell libtool to add the
--whole-archive flags when creating executables; this only
seems to be supported with shared libraries. My proposed
solution is to create a shared library libtestsuite.so which
contains all test cases; the main testsuite executable only
contains main.cpp and links against libtestsuite.so (see
attached patch). This allows to get rid of the hard coded
linker flags because libtool adds them when creating the
shared library.

If noone has a better idea or tells me that I am completely
wrong, I will commit these patches :-)

Thanks,

        Andreas
--- tests/src/Makefile.am       2005-12-02 19:22:33.000000000 +0100
+++ tests/src/Makefile.am       2005-12-11 15:32:42.000000000 +0100
@@ -7,9 +7,22 @@
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
-noinst_PROGRAMS = testsuite shortsocketserver
+# Testsuite library, including the convenience libraries
+lib_LTLIBRARIES = libtestsuite.la
 
-testsuite_SOURCES = \
+libtestsuite_la_LIBADD = \
+        customlogger/libcustomlogger.la\
+        defaultinit/libdefaultinit.la\
+        helpers/libhelpers.la\
+        net/libnet.la\
+        pattern/libpattern.la\
+        util/libutil.la\
+        varia/libvaria.la\
+        xml/libxml.la\
+        db/libdb.la\
+        nt/libnt.la
+
+libtestsuite_la_SOURCES =
         asyncappendertestcase.cpp\
         encodingtest.cpp\
         filetestcase.cpp \
@@ -17,7 +30,6 @@
         l7dtestcase.cpp\
         leveltestcase.cpp \
         loggertestcase.cpp\
-        main.cpp\
         minimumtestcase.cpp\
         patternlayouttest.cpp\
         vectorappender.cpp\
@@ -29,52 +41,40 @@
         writerappendertestcase.cpp \
         ndctestcase.cpp
 
+# The testsuite executable
+noinst_PROGRAMS = testsuite shortsocketserver
 
-testsuite_LDADD = \
-        $(top_builddir)/src/liblog4cxx.la
+testsuite_SOURCES = \
+        main.cpp
 
-testsuite_LDFLAGS = \
-        -Wl,--whole-archive,customlogger/libcustomlogger.a,--no-whole-archive\
-        -Wl,--whole-archive,defaultinit/libdefaultinit.a,--no-whole-archive\
-        -Wl,--whole-archive,helpers/libhelpers.a,--no-whole-archive\
-        -Wl,--whole-archive,net/libnet.a,--no-whole-archive\
-        -Wl,--whole-archive,pattern/libpattern.a,--no-whole-archive\
-        -Wl,--whole-archive,util/libutil.a,--no-whole-archive\
-        -Wl,--whole-archive,varia/libvaria.a,--no-whole-archive\
-        -Wl,--whole-archive,xml/libxml.a,--no-whole-archive\
-        -Wl,--whole-archive,db/libdb.a,--no-whole-archive\
-        -Wl,--whole-archive,nt/libnt.a,--no-whole-archive\
+testsuite_LDADD = \
+        $(top_builddir)/src/liblog4cxx.la \
+       libtestsuite.la \
         @LIBS_CPPUNIT@
 
 AM_CPPFLAGS = @CPPFLAGS_CPPUNIT@
 
 testsuite_DEPENDENCIES = \
-        customlogger/libcustomlogger.a\
-        defaultinit/libdefaultinit.a\
-        helpers/libhelpers.a\
-        net/libnet.a\
-        pattern/libpattern.a\
-        util/libutil.a\
-        varia/libvaria.a\
-        xml/libxml.a\
-        db/libdb.a\
-        nt/libnt.a\
+        customlogger/libcustomlogger.la\
+        defaultinit/libdefaultinit.la\
+        helpers/libhelpers.la\
+        net/libnet.la\
+        pattern/libpattern.la\
+        util/libutil.la\
+        varia/libvaria.la\
+        xml/libxml.la\
+        db/libdb.la\
+        nt/libnt.la\
         $(top_builddir)/src/liblog4cxx.la
 
+# shortsocketserver executable
 shortsocketserver_SOURCES = \
         shortsocketserver.cpp
 
 shortsocketserver_LDADD = \
         $(top_builddir)/src/liblog4cxx.la
 
-shortsocketserver_LDFLAGS = \
-        -Wl,--whole-archive,util/libutil.a,--no-whole-archive\
-        -Wl,--whole-archive,xml/libxml.a,--no-whole-archive\
-        @LIBS_CPPUNIT@
-
 shortsocketserver_DEPENDENCIES = \
-        util/libutil.a\
-        xml/libxml.a\
         $(top_builddir)/src/liblog4cxx.la
 
 check: testsuite shortsocketserver
--- tests/src/customlogger/Makefile.am  2005-12-02 19:22:32.000000000 +0100
+++ tests/src/customlogger/Makefile.am  2005-12-07 21:28:05.000000000 +0100
@@ -3,14 +3,14 @@
 
 if TESTS
 
-noinst_LIBRARIES = libcustomlogger.a
+noinst_LTLIBRARIES = libcustomlogger.la
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
-libcustomlogger_a_SOURCES = \
+libcustomlogger_la_SOURCES = \
        xlogger.cpp\
        xloggertestcase.cpp
        
-check: libcustomlogger.a
+check: libcustomlogger.la
 
 endif
--- tests/src/db/Makefile.am    2005-12-02 19:22:31.000000000 +0100
+++ tests/src/db/Makefile.am    2005-12-11 14:37:31.000000000 +0100
@@ -2,14 +2,14 @@
 
 if TESTS
 
-noinst_LIBRARIES = libdb.a
+noinst_LTLIBRARIES = libdb.la
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
 
-libdb_a_SOURCES = \
+libdb_la_SOURCES = \
        odbcappendertestcase.cpp
 
-check: libdb.a
+check: libdb.la
 
 endif
 
--- tests/src/defaultinit/Makefile.am   2005-12-02 19:22:31.000000000 +0100
+++ tests/src/defaultinit/Makefile.am   2005-12-11 14:35:54.000000000 +0100
@@ -2,16 +2,16 @@
 
 if TESTS
 
-noinst_LIBRARIES = libdefaultinit.a
+noinst_LTLIBRARIES = libdefaultinit.la
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
-libdefaultinit_a_SOURCES = \
+libdefaultinit_la_SOURCES = \
        testcase1.cpp\
        testcase2.cpp\
        testcase3.cpp\
        testcase4.cpp
        
-check: libdefaultinit.a
+check: libdefaultinit.la
 
 endif
--- tests/src/helpers/Makefile.am       2005-12-02 19:22:31.000000000 +0100
+++ tests/src/helpers/Makefile.am       2005-12-11 14:36:30.000000000 +0100
@@ -2,11 +2,11 @@
 
 if TESTS
 
-noinst_LIBRARIES = libhelpers.a
+noinst_LTLIBRARIES = libhelpers.la
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
-libhelpers_a_SOURCES = \
+libhelpers_la_SOURCES = \
         absolutetimedateformattestcase.cpp \
         cacheddateformattestcase.cpp \
         charsetdecodertestcase.cpp \
@@ -24,6 +24,6 @@
         transcodertestcase.cpp \
         unicodehelpertestcase.cpp 
 
-check: libhelpers.a
+check: libhelpers.la
 
 endif
--- tests/src/net/Makefile.am   2005-12-02 19:22:32.000000000 +0100
+++ tests/src/net/Makefile.am   2005-12-11 14:36:40.000000000 +0100
@@ -3,10 +3,10 @@
 
 if TESTS
 
-noinst_LIBRARIES = libnet.a
+noinst_LTLIBRARIES = libnet.la
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
-libnet_a_SOURCES = \
+libnet_la_SOURCES = \
        smtpappendertestcase.cpp \
        socketappendertestcase.cpp \
        sockethubappendertestcase.cpp \
@@ -15,7 +15,7 @@
        telnetappendertestcase.cpp \
        xmlsocketappendertestcase.cpp
 
-check: libnet.a 
+check: libnet.la 
 
 endif
 
--- tests/src/nt/Makefile.am    2005-12-02 19:22:31.000000000 +0100
+++ tests/src/nt/Makefile.am    2005-12-11 14:37:49.000000000 +0100
@@ -2,13 +2,13 @@
 
 if TESTS
 
-noinst_LIBRARIES = libnt.a
+noinst_LTLIBRARIES = libnt.la
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
-libnt_a_SOURCES = \
+libnt_la_SOURCES = \
        nteventlogappendertestcase.cpp
 
-check: libnt.a
+check: libnt.la
 
 endif
 
--- tests/src/pattern/Makefile.am       2005-12-02 19:22:31.000000000 +0100
+++ tests/src/pattern/Makefile.am       2005-12-11 14:36:54.000000000 +0100
@@ -3,15 +3,15 @@
 
 if TESTS
 
-noinst_LIBRARIES = libpattern.a
+noinst_LTLIBRARIES = libpattern.la
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
-libpattern_a_SOURCES = \
+libpattern_la_SOURCES = \
        num343patternconverter.cpp \
        patternparsertestcase.cpp
        
-check: libpattern.a
+check: libpattern.la
 
 endif
 
--- tests/src/rolling/Makefile.am       2005-12-02 19:22:31.000000000 +0100
+++ tests/src/rolling/Makefile.am       2005-12-11 14:37:06.000000000 +0100
@@ -2,11 +2,11 @@
 
 if TESTS
 
-noinst_LIBRARIES = librolling.a
+noinst_LTLIBRARIES = librolling.la
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
-librolling_a_SOURCES = \
+librolling_la_SOURCES = \
         filenamepatterntestcase.cpp \
         filterbasedrollingtest.cpp \
         manualrollingtest.cpp \
@@ -15,7 +15,7 @@
         sizebasedrollingtest.cpp \
         timebasedrollingtest.cpp
 
-check: librolling.a
+check: librolling.la
 
 endif
 
--- tests/src/util/Makefile.am  2005-12-02 19:22:33.000000000 +0100
+++ tests/src/util/Makefile.am  2005-12-11 14:37:14.000000000 +0100
@@ -3,11 +3,11 @@
 
 if TESTS
 
-noinst_LIBRARIES = libutil.a
+noinst_LTLIBRARIES = libutil.la
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
-libutil_a_SOURCES = \
+libutil_la_SOURCES = \
        absolutetimefilter.cpp\
        absolutedateandtimefilter.cpp\
        binarycompare.cpp\
@@ -25,7 +25,7 @@
        xmltimestampfilter.cpp \
        xmlthreadfilter.cpp
        
-check: libutil.a
+check: libutil.la
 
 endif
 
--- tests/src/varia/Makefile.am 2005-12-02 19:22:31.000000000 +0100
+++ tests/src/varia/Makefile.am 2005-12-11 14:37:23.000000000 +0100
@@ -2,17 +2,17 @@
 
 if TESTS
 
-noinst_LIBRARIES = libvaria.a
+noinst_LTLIBRARIES = libvaria.la
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
 
-libvaria_a_SOURCES = \
+libvaria_la_SOURCES = \
        errorhandlertestcase.cpp \
        levelmatchfiltertestcase.cpp \
        levelrangefiltertestcase.cpp
        
-check: libvaria.a
+check: libvaria.la
 
 endif
 
--- tests/src/xml/Makefile.am   2005-12-02 19:22:32.000000000 +0100
+++ tests/src/xml/Makefile.am   2005-12-11 14:37:40.000000000 +0100
@@ -3,17 +3,17 @@
 
 if TESTS
 
-noinst_LIBRARIES = libxml.a
+noinst_LTLIBRARIES = libxml.la
 
 INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
 
 
-libxml_a_SOURCES = \
+libxml_la_SOURCES = \
        customleveltestcase.cpp \
        domtestcase.cpp \
        xlevel.cpp \
        xmllayouttestcase.cpp
        
-check: libxml.a
+check: libxml.la
 
 endif

Reply via email to