File: 2001_system_shared_lib.patch

package info (click to toggle)
libre-engine-re2-perl 0.18%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 440 kB
  • sloc: cpp: 270; perl: 80; makefile: 2; sh: 1
file content (154 lines) | stat: -rw-r--r-- 4,518 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
Description: Use system shared libre2
Author: Jonas Smedegaard <dr@jones.dk>
Bug: https://rt.cpan.org/Public/Bug/Display.html?id=83467
Last-Update: 2018-10-18
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -8,7 +8,7 @@
 
 # TODO: Optionally use system libre2, via ExtUtils::Liblist?
 
-my @objects = qw(RE2.o re2_xs.o re2/obj/libre2.a);
+my @objects = qw(RE2.o re2_xs.o);
 
 my $guess = ExtUtils::CppGuess->new;
 
@@ -18,7 +18,7 @@
   VERSION_FROM       => 'lib/re/engine/RE2.pm',
   ABSTRACT_FROM      => 'lib/re/engine/RE2.pm',
   LICENSE            => 'perl',
-  INC                => '-Ire2',
+  LDLOADLIBS         => '-lre2',
   PMLIBDIRS          => ["lib"],
   OBJECT             => join(" ", @objects),
   test               => {TESTS => 't/*.t t/ree-pcre/*.t'},
@@ -46,116 +46,4 @@
 
 my $cc = (map +(/^CC=(.*)/i), @ARGV)[0] || $Config{cc};
 
-if (my $gcc_version = gcc_version($cc)) {
-  say "Compiling on gcc $gcc_version";
-
-  # If the user didn't explicitly provide optimisation settings, we'll try to do
-  # it ourselves, but only for gcc.
-  if(!grep(/^OPTIMIZE=/i, @ARGV)) {
-    my $optimize = $Config{optimize};
-
-    if($gcc_version) {
-      $optimize =~ s/-O[s0-2]/-O3/ and say "Optimize level set to -O3";
-    }
-
-    # Attempt to work out if we have a gcc that is likely to support -flto.
-    # This is probably a lot of work for a minimal gain, but it's worth a try.
-    if($gcc_version >= 4.5) {
-      my $try_optimize = "$optimize -flto";
-      # Try to use this flag
-      if(gcc_try(cc => $cc, %opt, OPTIMIZE => $try_optimize)) {
-        $optimize = $try_optimize;
-      }
-
-      # gcc 4.9 needs this otherwise it gets rid of nearly everything in libre2.a.
-      $try_optimize = "$optimize -ffat-lto-objects";
-      if(gcc_try(cc => $cc, %opt, OPTIMIZE => $try_optimize)) {
-        $optimize = $try_optimize;
-      }
-    }
-
-    say "OPTIMIZE is now: $optimize";
-    $opt{OPTIMIZE} = $optimize;
-  }
-
-  if ($gcc_version >= 4.8) {
-    $opt{DEFINE} .= " -std=c++11";
-  } else {
-    say "Need gcc version new enough to support C++11, exiting.";
-    exit 1;
-  }
-}
-
-if (my $clang_version = clang_version($cc)) {
-  say "Compiling on clang $clang_version";
-
-  if ($clang_version >= 3) {
-    $opt{DEFINE} .= " -std=c++11";
-  } else {
-    say "Need clang version new enough to support C++11, this will probably fail.";
-  }
-}
-
-if(defined $Config{usethreads} && $Config{usethreads} eq 'define') {
-  if(defined $Config{i_pthread} && $Config{i_pthread} eq 'define') {
-    $opt{DEFINE} .= " -DHAVE_PTHREAD -pthread";
-  } else {
-    # For now this allows compilation under Win32/Strawberry, but might cause weird crashes on thread
-    # destruction...
-    $opt{DEFINE} .= " -DNO_THREADS";
-  }
-} else {
-  $opt{DEFINE} .= " -DNO_THREADS";
-}
-
-# This is a bit hacky, RE2 makefile needs GNU make, for now we'll try to find
-# it, ideally should rewrite the RE2 makefile to not need GNU make.
-our $MAKE;
-for my $make(qw(make gmake)) {
-  if(qx{$make --version 2>&1} =~ /GNU Make/i) {
-    $MAKE = $make;
-    last;
-  }
-}
-
-if(!$MAKE) {
-  die "RE2 currently needs GNU Make, please install gmake.\n";
-}
-
 WriteMakefile(%opt);
-
-sub gcc_version {
-  my($cc) = @_;
-  my $gcc_out = qx{$cc -v 2>&1};
-  # Just the first two digits
-  $gcc_out =~ /gcc version (\d+\.\d+)/ ? $1 : 0;
-}
-
-# This is highly gcc and unix specific, but that's where I care about
-# optimising this anyway.
-sub gcc_try {
-  my(%opts) = @_;
-  system "$opts{cc} $opts{CCFLAGS} $opts{OPTIMIZE} -c -o /dev/null /dev/null >/dev/null 2>&1";
-  not $?;
-}
-
-sub clang_version {
-  my ($cc) = @_;
-  my $out = qx{$cc -v 2>&1};
-  # Just the major
-  $out =~ /clang version (\d+)/ ? $1 : 0;
-}
-
-sub MY::postamble {
-  return <<MAKE_FRAG;
-
-RE2_FLAGS = CC="\$(CC)" CXXFLAGS="\$(CCFLAGS) \$(CCCDLFLAGS) \$(OPTIMIZE) \$(DEFINE) -DUSE_CXX0X" LDFLAGS="\$(OTHERLDFLAGS) \$(LDLOADLIBS)"
-
-re2/obj/libre2.a: re2/Makefile
-	$MAKE -C re2 obj/libre2.a \$(RE2_FLAGS)
-
-re2-tests:
-	$MAKE -C re2 static-test \$(RE2_FLAGS) LDFLAGS="\$(OTHERLDFLAGS) \$(LDLOADLIBS) -lm -lpthread"
-
-MAKE_FRAG
-}
--- a/t/00.re2-tests.t
+++ b/t/00.re2-tests.t
@@ -1,6 +1,8 @@
 use Test::More;
 no warnings;
 
+plan skip_all => "Only when likning against local library";
+
 # Avoid running for everyone, these tests are quite slow, but useful for CPAN
 # testers to run. cpanminus sets automated testing when it isn't, so ignore
 # in that case too.