Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ClamAV: devel
use system libtommath when present
 

Index | Next | Previous | View Flat


steve at lobefin

Feb 19, 2009, 4:12 PM


Views: 725
Permalink
use system libtommath when present

Hopefully this will be a useful patch.

Cheers,

[PATCH] Modify build system to conditionally use system install of libtommath -
it will be used if it is installed, or if it is explicitly enabled in
configure
Signed-off-by: Stephen Gran <steve[at]lobefin.net>

---
configure.in | 13 +++++++++++++
libclamav/Makefile.am | 19 ++++++++++++++-----
libclamav/bignum.c | 6 ++++++
libclamav/bignum.h | 6 ++++++
libclamav/bignum_class.h | 6 ++++++
libclamav/dsig.c | 4 ++++
libclamav/dsig.h | 4 ++++
7 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/configure.in b/configure.in
index 3454abf..e400644 100644
--- a/configure.in
+++ b/configure.in
@@ -505,6 +505,19 @@ fi
AC_MSG_RESULT([$ZLIB_HOME])
])

+AC_ARG_ENABLE(system_tommath,
+[ --enable-system-tommath Enable use of system libtommath (default=auto)], enable_system_tommath=$enableval, enable_system_tommath="auto" )
+if test "x$enable_system_tommath" = "xauto"; then
+ AC_CHECK_HEADER([tommath.h],[have_tommath_h=yes],)
+fi
+
+if test "x$have_tommath_h" = "xyes" || "x$enable_system_tommath" = "xyes"; then
+ AC_DEFINE([USE_SYSTEM_TOMMATH], 1, [use system lintommath])
+ TOMMATH_LIBS="-ltommath"
+ AC_SUBST([TOMMATH_LIBS])
+fi
+AM_CONDITIONAL([SYSTEM_TOMMATH], test "x$ac_cv_use_system_tommath" = "xyes")
+
AC_ARG_ENABLE([zlib-vcheck],
[ --disable-zlib-vcheck do not check for buggy zlib version ],
zlib_check=$enableval, zlib_check="yes")
diff --git a/libclamav/Makefile.am b/libclamav/Makefile.am
index dd85399..931c852 100644
--- a/libclamav/Makefile.am
+++ b/libclamav/Makefile.am
@@ -87,15 +87,24 @@ libclamav_internal_utils_la_SOURCES=str.c \
regex/cname.h \
regex/regex.h \
regex/regex2.h \
- regex/utils.h \
- bignum.c \
- bignum.h \
- bignum_class.h
+ regex/utils.h
+
+if SYSTEM_TOMMATH
+else
+libclamavtommath_la_SOURCES = \
+ bignum.c \
+ bignum.h \
+ bignum_class.h
+
+lib_LTLIBRARIES += libclamavtommath.la
+libclamavtommath_la_LDFLAGS =-static
+libclamavtommath_la_CFLAGS= -fPIC -DPIC
+endif

libclamav_internal_utils_la_LDFLAGS=-static
libclamav_internal_utils_la_CFLAGS= -fPIC -DPIC

-libclamav_la_LIBADD = @LIBLTDL@ $(IFACELIBADD) lzma/liblzma.la libclamav_internal_utils.la @LIBCLAMAV_LIBS@ @THREAD_LIBS@
+libclamav_la_LIBADD = @LIBLTDL@ $(IFACELIBADD) lzma/liblzma.la libclamav_internal_utils.la @LIBCLAMAV_LIBS@ @THREAD_LIBS@ @TOMMATH_LIBS@
libclamav_la_DEPENDENCIES = @LIBLTDL@ $(IFACEDEP) libclamav_internal_utils.la
libclamav_la_LDFLAGS = @TH_SAFE@ -version-info @LIBCLAMAV_VERSION@ -no-undefined

diff --git a/libclamav/bignum.c b/libclamav/bignum.c
index b46be20..7c60f1d 100644
--- a/libclamav/bignum.c
+++ b/libclamav/bignum.c
@@ -1,3 +1,8 @@
+#if HAVE_CONFIG_H
+#include "clamav-config.h"
+#endif
+
+#ifndef USE_SYSTEM_TOMMATH
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
* LibTomMath is a library that provides multiple-precision
@@ -9514,3 +9519,4 @@ int KARATSUBA_MUL_CUTOFF = 80, /* Min. number of digits before Karatsub


/* EOF */
+#endif
diff --git a/libclamav/bignum.h b/libclamav/bignum.h
index f50ac6f..59ba109 100644
--- a/libclamav/bignum.h
+++ b/libclamav/bignum.h
@@ -1,3 +1,8 @@
+#if HAVE_CONFIG_H
+#include "clamav-config.h"
+#endif
+
+#ifndef USE_SYSTEM_TOMMATH
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
* LibTomMath is a library that provides multiple-precision
@@ -582,3 +587,4 @@ extern const char *mp_s_rmap;
/* $Source: /cvs/libtom/libtommath/tommath.h,v $ */
/* $Revision: 1.8 $ */
/* $Date: 2006/03/31 14:18:44 $ */
+#endif
diff --git a/libclamav/bignum_class.h b/libclamav/bignum_class.h
index be38efc..858d980 100644
--- a/libclamav/bignum_class.h
+++ b/libclamav/bignum_class.h
@@ -1,3 +1,8 @@
+#if HAVE_CONFIG_H
+#include "clamav-config.h"
+#endif
+
+#ifndef USE_SYSTEM_TOMMATH
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
* LibTomMath is a library that provides multiple-precision
@@ -1004,3 +1009,4 @@
/* $Revision: 1.3 $ */
/* $Date: 2005/07/28 11:59:32 $ */
#endif
+#endif
diff --git a/libclamav/dsig.c b/libclamav/dsig.c
index e1f9d46..a0bb048 100644
--- a/libclamav/dsig.c
+++ b/libclamav/dsig.c
@@ -31,7 +31,11 @@
#include "others.h"
#include "dsig.h"
#include "str.h"
+#ifdef USE_SYSTEM_TOMMATH
+#include <tommath.h>
+#else
#include "bignum.h"
+#endif

#define CLI_NSTR "118640995551645342603070001658453189751527774412027743746599405743243142607464144767361060640655844749760788890022283424922762488917565551002467771109669598189410434699034532232228621591089508178591428456220796841621637175567590476666928698770143328137383952820383197532047771780196576957695822641224262693037"

diff --git a/libclamav/dsig.h b/libclamav/dsig.h
index 8156b23..4843865 100644
--- a/libclamav/dsig.h
+++ b/libclamav/dsig.h
@@ -25,7 +25,11 @@
#include "clamav-config.h"
#endif

+#ifdef USE_SYSTEM_TOMMATH
+#include <tommath.h>
+#else
#include "bignum.h"
+#endif

int cli_versig(const char *md5, const char *dsig);
unsigned char *cli_decodesig(const char *sig, unsigned int plen, mp_int e, mp_int n);
--
1.6.0.6


--
--------------------------------------------------------------------------
| Stephen Gran | Questionable day. Ask somebody |
| steve[at]lobefin.net | something. |
| http://www.lobefin.net/~steve | |
--------------------------------------------------------------------------
_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net

Subject User Time
use system libtommath when present steve at lobefin Feb 19, 2009, 4:12 PM
    Re: use system libtommath when present steve at lobefin Feb 19, 2009, 4:57 PM
    Re: use system libtommath when present edwintorok at gmail Feb 20, 2009, 1:56 AM
        Re: use system libtommath when present steve at lobefin Feb 20, 2009, 3:03 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.