80 lines
2.4 KiB
Diff
80 lines
2.4 KiB
Diff
|
From 1a5184d4e21391a5ac8ea28fa84a7ba7689a33dd Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||
|
Date: Thu, 16 Oct 2014 13:16:53 +0200
|
||
|
Subject: [PATCH 2/2] Prefer external miniz library in Sereal::Decoder
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
This patch checks for presence of miniz library and header file and
|
||
|
if they are available, they will be used to link to the
|
||
|
Sereal::Decoder XS module. Otherwise the bundled miniz code will be
|
||
|
used.
|
||
|
|
||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||
|
---
|
||
|
Perl/Decoder/Makefile.PL | 16 +++++++++++++++-
|
||
|
Perl/Decoder/srl_decoder.c | 4 ++++
|
||
|
2 files changed, 19 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/Perl/Decoder/Makefile.PL b/Perl/Decoder/Makefile.PL
|
||
|
index 864b89b..6750b3d 100644
|
||
|
--- a/Perl/Decoder/Makefile.PL
|
||
|
+++ b/Perl/Decoder/Makefile.PL
|
||
|
@@ -26,6 +26,7 @@ our $OPTIMIZE;
|
||
|
# #define MINIZ_HAS_64BIT_REGISTERS 1
|
||
|
|
||
|
my $libs = '';
|
||
|
+my $objects = '$(BASEEXT)$(OBJ_EXT) srl_decoder$(OBJ_EXT)';
|
||
|
my $defines = join " ", map "-D$_", grep exists $ENV{$_}, qw(NOINLINE DEBUG MEMDEBUG NDEBUG);
|
||
|
if ($Config{gccversion}) {
|
||
|
$OPTIMIZE = '-O3 -Wall -W';
|
||
|
@@ -65,6 +66,19 @@ if ($have_csnappy) {
|
||
|
$defines .= ' -DHAVE_CSNAPPY';
|
||
|
}
|
||
|
|
||
|
+# Prefer external miniz library over the bundled one.
|
||
|
+my $have_miniz = Devel::CheckLib::check_lib(
|
||
|
+ lib => 'miniz',
|
||
|
+ header => 'miniz.h'
|
||
|
+);
|
||
|
+
|
||
|
+if ($have_miniz) {
|
||
|
+ $libs .= ' -lminiz';
|
||
|
+ $defines .= ' -DHAVE_MINIZ';
|
||
|
+} else {
|
||
|
+ $objects .= ' miniz$(OBJ_EXT)';
|
||
|
+}
|
||
|
+
|
||
|
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
|
||
|
# the contents of the Makefile that is written.
|
||
|
WriteMakefile1(
|
||
|
@@ -106,7 +120,7 @@ WriteMakefile1(
|
||
|
DEFINE => $defines,
|
||
|
INC => '-I.', # e.g., '-I. -I/usr/include/other'
|
||
|
OPTIMIZE => $OPTIMIZE,
|
||
|
- OBJECT => '$(O_FILES)',
|
||
|
+ OBJECT => $objects,
|
||
|
test => {
|
||
|
TESTS => "t/*.t t/*/*/*.t"
|
||
|
},
|
||
|
diff --git a/Perl/Decoder/srl_decoder.c b/Perl/Decoder/srl_decoder.c
|
||
|
index 09b5e52..f21b993 100644
|
||
|
--- a/Perl/Decoder/srl_decoder.c
|
||
|
+++ b/Perl/Decoder/srl_decoder.c
|
||
|
@@ -57,7 +57,11 @@ extern "C" {
|
||
|
#include "snappy/csnappy_decompress.c"
|
||
|
#endif
|
||
|
|
||
|
+#if defined(HAVE_MINIZ)
|
||
|
+#include <miniz.h>
|
||
|
+#else
|
||
|
#include "miniz.h"
|
||
|
+#endif
|
||
|
|
||
|
/* 5.8.8 and earlier have a nasty bug in their handling of overloading:
|
||
|
* The overload-flag is set on the referer of the blessed object instead of
|
||
|
--
|
||
|
1.9.3
|
||
|
|