File: 0004-Be-smart-about-extra-library-checks.patch

package info (click to toggle)
ruby-pgplot 0.1.9-3
  • links: PTS, VCS
  • area: contrib
  • in suites: buster, stretch
  • size: 604 kB
  • ctags: 144
  • sloc: ruby: 1,607; makefile: 76; ansic: 57; sh: 17
file content (171 lines) | stat: -rw-r--r-- 4,975 bytes parent folder | download
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
From: David MacMahon <davidm@astro.berkeley.edu>
Date: Sun, 3 Mar 2013 11:04:45 -0800
Subject: Be smart about extra library checks

Try to find libcpgplot before looking for extra libs like x11, gfortran,
png, etc.  If the initial check for libcpgplot fails, then look for the
extra libraries and re-check for libcpgplot.  This removes the need for
the --enable-extra-libs option.
---
 ext/extconf.rb | 132 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 66 insertions(+), 66 deletions(-)

diff --git a/ext/extconf.rb b/ext/extconf.rb
index d091c5d..48d1c1b 100644
--- a/ext/extconf.rb
+++ b/ext/extconf.rb
@@ -15,19 +15,6 @@ require "mkmf"
 
 #$DEBUG = true
 
-# Allow user to pass --disable-extra-libs to prevent checking for some libs.
-# Some PGPLOT installations need these extra checks and the extra checks are
-# mostly benign for PGPLOT installations that don't need them so the extra
-# checks are enabled by default.  The extra checks can cause problems on some
-# installations where they are not necessary.
-check_extra_libs = enable_config('extra-libs', true)
-
-# configure options:
-#  --with-x11-dir=path
-#  --with-x11-include=path
-#  --with-x11-lib=path
-dir_config("x11") if check_extra_libs
-
 # configure options:
 #  --with-pgplot-dir=path
 #  --with-pgplot-include=path
@@ -75,68 +62,81 @@ if RUBY_PLATFORM =~ /cygwin|mingw/
   exit unless have_library("narray","na_make_object")
 end
 
-if check_extra_libs
-  # Check FORTRAN Libraries
-  #
-  # SUN WorkShop FORTRAN 77 compiler ver5.0
-  # configure options: --with-sunws
-  if with_config("sunws")
-    $libs = "-lM77 -lsunmath "+$libs
-    exit unless find_library("F77", "f77_init", "/opt/SUNWspro/lib")
-    $defs.push "-DSPARC_FORTRAN"
-  #
-  # GNU FORTRAN v4
-  elsif have_library("gfortran")
-    $CFLAGS = "-Wall "+$CFLAGS
-    $defs.push "-DGNU_FORTRAN"
-  #
-  # GNU FORTRAN v3
-  elsif have_library("g77")
-    $CFLAGS = "-Wall "+$CFLAGS
-    $defs.push "-DGNU_FORTRAN"
-  else
-    puts "failed"
-    exit
-  end
+$have_pgplot = false
+
+# Check PGPLOT Header
+if have_header("cpgplot.h")
 
-  # Check GrWin Library (for cygwin (and mingw32?))
-  #  configure options: --with-grwin
-  if with_config("grwin")
-    #$LDFLAGS = "-Wl,--subsystem,console "+$LDFLAGS
-    if RUBY_PLATFORM =~ /cygwin|mingw/
-      $libs += " -mwindows"
+  # Check PGPLOT Library without extra libs
+  if find_library("cpgplot","cpgbeg", "/usr/lib",
+		  "/usr/local/lib", "/usr/local/pgplot" )
+    $have_pgplot = true
+  else
+    # Check for extra libs then re-check for PGPLOT library
+    puts "First check for PGPLOT library failed,"
+    puts "checking for auxiliary libraries and retrying."
+
+    # Check FORTRAN Libraries
+    #
+    # SUN WorkShop FORTRAN 77 compiler ver5.0
+    # configure options: --with-sunws
+    if with_config("sunws")
+      $libs = "-lM77 -lsunmath "+$libs
+      exit unless find_library("F77", "f77_init", "/opt/SUNWspro/lib")
+      $defs.push "-DSPARC_FORTRAN"
+    #
+    # GNU FORTRAN v4
+    elsif have_library("gfortran")
+      $CFLAGS = "-Wall "+$CFLAGS
+      $defs.push "-DGNU_FORTRAN"
+    #
+    # GNU FORTRAN v3
+    elsif have_library("g77")
+      $CFLAGS = "-Wall "+$CFLAGS
+      $defs.push "-DGNU_FORTRAN"
+    else
+      puts "failed"
+      exit
     end
-    exit unless have_library("GrWin", "GWinit")
-  end
 
-  $found_lib = []
+    # Check GrWin Library (for cygwin (and mingw32?))
+    #  configure options: --with-grwin
+    if with_config("grwin")
+      #$LDFLAGS = "-Wl,--subsystem,console "+$LDFLAGS
+      if RUBY_PLATFORM =~ /cygwin|mingw/
+        $libs += " -mwindows"
+      end
+      exit unless have_library("GrWin", "GWinit")
+    end
 
-  # Check X11 Library
-  if have_library("X11", "XOpenDisplay")
-    $found_lib << 'X11'
-  end
+    $found_lib = []
 
-  # Check PNG Library
-  libs_save = $libs
-  $libs = append_library($libs, "z")
-  if have_library("png","png_create_write_struct")
-    $found_lib << 'png'
-  else
-    $libs = libs_save
-  end
+    # configure options:
+    #  --with-x11-dir=path
+    #  --with-x11-include=path
+    #  --with-x11-lib=path
+    dir_config("x11")
 
-  $libs = append_library($libs, "pgplot")
-end # check_extra_libs
+    # Check X11 Library
+    if have_library("X11", "XOpenDisplay")
+      $found_lib << 'X11'
+    end
 
-$have_pgplot = false
+    # Check PNG Library
+    libs_save = $libs
+    $libs = append_library($libs, "z")
+    if have_library("png","png_create_write_struct")
+      $found_lib << 'png'
+    else
+      $libs = libs_save
+    end
 
-# Check PGPLOT Header
-if have_header("cpgplot.h")
+    $libs = append_library($libs, "pgplot")
 
-  # Check PGPLOT Library
-  if find_library("cpgplot","cpgbeg", "/usr/lib",
-		  "/usr/local/lib", "/usr/local/pgplot" )
-    $have_pgplot = true
+    if find_library("cpgplot","cpgbeg", "/usr/lib",
+        "/usr/local/lib", "/usr/local/pgplot" )
+      $have_pgplot = true
+    end
   end
 end