Package: ruby-pgplot / 0.1.9-3

0002-Add-disable-extra-libs-option.patch Patch series | 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
From: David MacMahon <davidm@astro.berkeley.edu>
Date: Sat, 2 Mar 2013 11:31:48 -0800
Subject: Add --disable-extra-libs option

Some PGPLOT installations have incompletely linked PGPLOT libraries so linking
against libcpgplot requires also linking against other libraries such as
libpgplot, libX11, libpng, etc.  These extra checks are mostly benign for
PGPLOT installations that don't need them, but they can cause problems.
For example, mkmf uses "gcc" when checking for the Fortran libraries, but the
resulting Makefile uses "cc" when linking.  If "cc" uses a different library
path than "gcc", it is possible for the check to succeed but the link to fail.
This might have been due to a weird combination of factors in my system
(e.g. custom Ruby build using gcc installed via MacPorts and MacOS's cc), but
if it happened to me it could happen to others.  Adding the --disable-extra-lib
option provides a solution for this case.
---
 ext/extconf.rb | 100 +++++++++++++++++++++++++++++++--------------------------
 1 file changed, 55 insertions(+), 45 deletions(-)

diff --git a/ext/extconf.rb b/ext/extconf.rb
index e31d94b..d091c5d 100644
--- a/ext/extconf.rb
+++ b/ext/extconf.rb
@@ -15,11 +15,18 @@ 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")
+dir_config("x11") if check_extra_libs
 
 # configure options:
 #  --with-pgplot-dir=path
@@ -68,56 +75,59 @@ if RUBY_PLATFORM =~ /cygwin|mingw/
   exit unless have_library("narray","na_make_object")
 end
 
-# 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
+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
 
-# 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 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
-  exit unless have_library("GrWin", "GWinit")
-end
 
-$found_lib = []
+  $found_lib = []
 
-# Check X11 Library
-if have_library("X11", "XOpenDisplay")
-  $found_lib << 'X11'
-end
+  # Check X11 Library
+  if have_library("X11", "XOpenDisplay")
+    $found_lib << 'X11'
+  end
 
-# 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 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
+
+  $libs = append_library($libs, "pgplot")
+end # check_extra_libs
 
-$libs = append_library($libs, "pgplot")
 $have_pgplot = false
 
 # Check PGPLOT Header