Hi all,

This patch makes the shared/ subdirectory build a convenience library.
This means that on builds, each object file is only built once, then
compiled into a static, partially linked object file.  This has obvious
advantages for the build time, as you only build these files once.  It
also has advantages for the maintenance of various Makefile.am's, since
you just include the .la file and let libtool do the rest.

Including inline since I think the list strips attachments.

diff --git a/Makefile.am b/Makefile.am
index 8787f48..4093551 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,8 +18,8 @@
 
 ACLOCAL_AMFLAGS=-I m4
 
-SUBDIRS = libltdl libclamav clamscan clamd clamdscan freshclam sigtool 
clamconf database docs etc clamav-milter test unit_tests clamdtop clambc
-EXTRA_DIST = FAQ examples BUGS shared libclamav.pc.in 
libclamunrar_iface/Makefile.am libclamunrar_iface/Makefile.in UPGRADE 
COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.file COPYING.zlib 
COPYING.getopt COPYING.regex COPYING.sha256
+SUBDIRS = libltdl libclamav shared clamscan clamd clamdscan freshclam sigtool 
clamconf database docs etc clamav-milter test unit_tests clamdtop clambc
+EXTRA_DIST = FAQ examples BUGS libclamav.pc.in libclamunrar_iface/Makefile.am 
libclamunrar_iface/Makefile.in UPGRADE COPYING.bzip2 COPYING.lzma COPYING.unrar 
COPYING.LGPL COPYING.file COPYING.zlib COPYING.getopt COPYING.regex 
COPYING.sha256
 
 bin_SCRIPTS=clamav-config
 
diff --git a/clamav-milter/Makefile.am b/clamav-milter/Makefile.am
index 5613e53..19e00a2 100644
--- a/clamav-milter/Makefile.am
+++ b/clamav-milter/Makefile.am
@@ -22,14 +22,6 @@ if HAVE_MILTER
 sbin_PROGRAMS = clamav-milter
 
 clamav_milter_SOURCES = \
-    $(top_srcdir)/shared/optparser.c \
-    $(top_srcdir)/shared/optparser.h \
-    $(top_srcdir)/shared/output.c \
-    $(top_srcdir)/shared/output.h \
-    $(top_srcdir)/shared/getopt.c \
-    $(top_srcdir)/shared/getopt.h \
-    $(top_srcdir)/shared/misc.c \
-    $(top_srcdir)/shared/misc.h \
     whitelist.c \
     whitelist.h \
     connpool.c \
@@ -46,6 +38,6 @@ endif
 
 DEFS = @DEFS@ -DCL_NOLIBCLAMAV
 CFLAGS=`echo "@CFLAGS@" | sed -e 's/-Wwrite-strings//' -e 's/-Werror /-Werror 
-Wno-error=format-nonliteral /'`
-LIBS = $(top_builddir)/libclamav/libclamav_internal_utils.la 
@CLAMAV_MILTER_LIBS@ @THREAD_LIBS@
+LIBS = $(top_builddir)/libclamav/libclamav_internal_utils.la 
$(top_builddir)/shared/libshared.la @CLAMAV_MILTER_LIBS@ @THREAD_LIBS@
 AM_CPPFLAGS = -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav 
-I$(top_srcdir)/shared -I$(top_srcdir)
 CLEANFILES=*.gcda *.gcno
diff --git a/clambc/Makefile.am b/clambc/Makefile.am
index ff710e2..e9383b1 100644
--- a/clambc/Makefile.am
+++ b/clambc/Makefile.am
@@ -1,13 +1,7 @@
 bin_PROGRAMS = clambc
 clambc_SOURCES = \
-    $(top_srcdir)/shared/optparser.c \
-    $(top_srcdir)/shared/optparser.h \
-    $(top_srcdir)/shared/getopt.c \
-    $(top_srcdir)/shared/getopt.h \
-    $(top_srcdir)/shared/misc.c \
-    $(top_srcdir)/shared/misc.h \
     bcrun.c
 
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
-LIBS = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@
+LIBS = $(top_builddir)/libclamav/libclamav.la 
$(top_builddir)/shared/libshared.la @THREAD_LIBS@
 CLEANFILES=*.gcda *.gcno
diff --git a/clamconf/Makefile.am b/clamconf/Makefile.am
index f4d0fe8..619b61e 100644
--- a/clamconf/Makefile.am
+++ b/clamconf/Makefile.am
@@ -19,15 +19,9 @@
 bin_PROGRAMS = clamconf
 
 clamconf_SOURCES = \
-    $(top_srcdir)/shared/optparser.c \
-    $(top_srcdir)/shared/optparser.h \
-    $(top_srcdir)/shared/getopt.c \
-    $(top_srcdir)/shared/getopt.h \
-    $(top_srcdir)/shared/misc.c \
-    $(top_srcdir)/shared/misc.h \
     clamconf.c
 
 DEFS = @DEFS@ -DCL_NOTHREADS
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
-LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMD_LIBS@ @THREAD_LIBS@
+LIBS = $(top_builddir)/libclamav/libclamav.la 
$(top_builddir)/shared/libshared.la @CLAMD_LIBS@ @THREAD_LIBS@
 CLEANFILES=*.gcda *.gcno
diff --git a/clamd/Makefile.am b/clamd/Makefile.am
index 573ff64..a3ca414 100644
--- a/clamd/Makefile.am
+++ b/clamd/Makefile.am
@@ -21,16 +21,6 @@ if BUILD_CLAMD
 sbin_PROGRAMS = clamd
 
 clamd_SOURCES = \
-    $(top_srcdir)/shared/output.c \
-    $(top_srcdir)/shared/output.h \
-    $(top_srcdir)/shared/optparser.c \
-    $(top_srcdir)/shared/optparser.h \
-    $(top_srcdir)/shared/getopt.c \
-    $(top_srcdir)/shared/getopt.h \
-    $(top_srcdir)/shared/misc.c \
-    $(top_srcdir)/shared/misc.h \
-    $(top_srcdir)/shared/network.c \
-    $(top_srcdir)/shared/network.h \
     clamd.c \
     tcpserver.c \
     tcpserver.h \
@@ -58,7 +48,7 @@ clamd_SOURCES = \
 
 endif
 
-LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMD_LIBS@ @THREAD_LIBS@
+LIBS = $(top_builddir)/libclamav/libclamav.la 
$(top_builddir)/shared/libshared.la @CLAMD_LIBS@ @THREAD_LIBS@
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
 
 # it does support --help and --version but with the default config file
diff --git a/clamdscan/Makefile.am b/clamdscan/Makefile.am
index 8a58219..cace364 100644
--- a/clamdscan/Makefile.am
+++ b/clamdscan/Makefile.am
@@ -21,17 +21,6 @@ if BUILD_CLAMD
 bin_PROGRAMS = clamdscan
 
 clamdscan_SOURCES = \
-    $(top_srcdir)/shared/output.c \
-    $(top_srcdir)/shared/output.h \
-    $(top_srcdir)/shared/optparser.c \
-    $(top_srcdir)/shared/optparser.h \
-    $(top_srcdir)/shared/misc.c \
-    $(top_srcdir)/shared/misc.h \
-    $(top_srcdir)/shared/getopt.c \
-    $(top_srcdir)/shared/getopt.h \
-    $(top_srcdir)/shared/actions.c \
-    $(top_srcdir)/shared/actions.h \
-    $(top_srcdir)/libclamav/regex/strlcpy.c\
     clamdscan.c \
     proto.c \
     proto.h \
@@ -41,7 +30,7 @@ endif
 
 DEFS = @DEFS@ -DCL_NOTHREADS -DCL_NOLIBCLAMAV
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared 
-I$(top_srcdir)/libclamav
-LIBS = $(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la  
@FRESHCLAM_LIBS@
+LIBS = $(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la 
$(top_builddir)/shared/libshared.la @FRESHCLAM_LIBS@
 
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamdscan$(EXEEXT)
 CLEANFILES=*.gcda *.gcno
diff --git a/clamdtop/Makefile.am b/clamdtop/Makefile.am
index f3ed3e5..c76f053 100644
--- a/clamdtop/Makefile.am
+++ b/clamdtop/Makefile.am
@@ -2,16 +2,10 @@ if HAVE_CURSES
 bin_PROGRAMS = clamdtop
 man_MANS = $(top_builddir)/docs/man/clamdtop.1
 clamdtop_SOURCES = \
-    $(top_srcdir)/shared/optparser.c \
-    $(top_srcdir)/shared/optparser.h \
-    $(top_srcdir)/shared/getopt.c \
-    $(top_srcdir)/shared/getopt.h \
-    $(top_srcdir)/shared/misc.c \
-    $(top_srcdir)/shared/misc.h \
     clamdtop.c
 
 AM_CPPFLAGS = -I$(top_srcdir) @CURSES_CPPFLAGS@
-clamdtop_LDADD = @CURSES_LIBS@ 
$(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la
+clamdtop_LDADD = @CURSES_LIBS@ 
$(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la 
$(top_builddir)/shared/libshared.la
 endif
 DEFS = @DEFS@ -DCL_NOTHREADS -DCL_NOLIBCLAMAV
 EXTRA_DIST = clamdtop.c
diff --git a/clamscan/Makefile.am b/clamscan/Makefile.am
index c965af4..a296ebe 100644
--- a/clamscan/Makefile.am
+++ b/clamscan/Makefile.am
@@ -20,16 +20,6 @@
 bin_PROGRAMS = clamscan
 
 clamscan_SOURCES = \
-    $(top_srcdir)/shared/output.c \
-    $(top_srcdir)/shared/output.h \
-    $(top_srcdir)/shared/getopt.c \
-    $(top_srcdir)/shared/getopt.h \
-    $(top_srcdir)/shared/optparser.c \
-    $(top_srcdir)/shared/optparser.h \
-    $(top_srcdir)/shared/actions.c \
-    $(top_srcdir)/shared/actions.h \
-    $(top_srcdir)/shared/misc.c \
-    $(top_srcdir)/shared/misc.h \
     clamscan.c \
     others.c \
     others.h \
@@ -38,7 +28,7 @@ clamscan_SOURCES = \
     manager.h
 
 DEFS = @DEFS@ -DCL_NOTHREADS
-LIBS = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@
+LIBS = $(top_builddir)/libclamav/libclamav.la 
$(top_builddir)/shared/libshared.la @THREAD_LIBS@
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
 
 CLEANFILES=*.gcda *.gcno
diff --git a/configure.in b/configure.in
index 7fbcfc2..9f63734 100644
--- a/configure.in
+++ b/configure.in
@@ -1596,6 +1596,7 @@ test/Makefile
 unit_tests/Makefile
 clamdtop/Makefile
 clambc/Makefile
+shared/Makefile
 Makefile
 clamav-config
 libclamav.pc
diff --git a/freshclam/Makefile.am b/freshclam/Makefile.am
index 7b691f4..30c3367 100644
--- a/freshclam/Makefile.am
+++ b/freshclam/Makefile.am
@@ -20,18 +20,6 @@
 bin_PROGRAMS = freshclam
 
 freshclam_SOURCES = \
-    $(top_srcdir)/shared/output.c \
-    $(top_srcdir)/shared/output.h \
-    $(top_srcdir)/shared/optparser.c \
-    $(top_srcdir)/shared/optparser.h \
-    $(top_srcdir)/shared/getopt.c \
-    $(top_srcdir)/shared/getopt.h \
-    $(top_srcdir)/shared/misc.c \
-    $(top_srcdir)/shared/misc.h \
-    $(top_srcdir)/shared/cdiff.c \
-    $(top_srcdir)/shared/cdiff.h \
-    $(top_srcdir)/shared/tar.c \
-    $(top_srcdir)/shared/tar.h \
     freshclam.c \
     manager.c \
     manager.h \
@@ -48,7 +36,7 @@ freshclam_SOURCES = \
 
 DEFS = @DEFS@ -DCL_NOTHREADS
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
-LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @THREAD_LIBS@
+LIBS = $(top_builddir)/libclamav/libclamav.la 
$(top_builddir)/shared/libshared.la @FRESHCLAM_LIBS@ @THREAD_LIBS@
 
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=freshclam$(EXEEXT)
 CLEANFILES=*.gcda *.gcno
diff --git a/sigtool/Makefile.am b/sigtool/Makefile.am
index 3c4180b..7c8d041 100644
--- a/sigtool/Makefile.am
+++ b/sigtool/Makefile.am
@@ -19,23 +19,11 @@
 bin_PROGRAMS = sigtool
 
 sigtool_SOURCES = \
-    $(top_srcdir)/shared/output.c \
-    $(top_srcdir)/shared/output.h \
-    $(top_srcdir)/shared/getopt.c \
-    $(top_srcdir)/shared/getopt.h \
-    $(top_srcdir)/shared/optparser.c \
-    $(top_srcdir)/shared/optparser.h \
-    $(top_srcdir)/shared/misc.c \
-    $(top_srcdir)/shared/misc.h \
-    $(top_srcdir)/shared/cdiff.c \
-    $(top_srcdir)/shared/cdiff.h \
-    $(top_srcdir)/shared/tar.c \
-    $(top_srcdir)/shared/tar.h \
     vba.c \
     vba.h \
     sigtool.c
 
 DEFS = @DEFS@ -DCL_NOTHREADS
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
-LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @THREAD_LIBS@
+LIBS = $(top_builddir)/libclamav/libclamav.la 
$(top_builddir)/shared/libshared.la @FRESHCLAM_LIBS@ @THREAD_LIBS@
 CLEANFILES=*.gcda *.gcno

Cheers,
-- 
 --------------------------------------------------------------------------
|  Stephen Gran                  | Do not underestimate the value of print |
|  [email protected]             | statements for debugging. Don't have    |
|  http://www.lobefin.net/~steve | aesthetic convulsions when using them,  |
|                                | either.                                 |
 --------------------------------------------------------------------------

Attachment: signature.asc
Description: Digital signature

_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net

Reply via email to