summaryrefslogtreecommitdiff
path: root/math/ruby-gsl/files/patch-extconf
blob: 01cbe9c5178423337e600f659e620ed9392865a1 (plain) (blame)
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
--- ext/extconf.rb.orig	Sat Aug 11 00:46:52 2007
+++ ext/extconf.rb	Mon Sep 24 19:29:49 2007
@@ -1,5 +1,35 @@
 require 'mkmf'
 
+
+module GSL
+	class Version
+		def initialize(str)
+			@str = str
+			@ary = str.split(".").collect { |elm| elm.to_i }
+		end
+		def to_s; @str; end
+		def inspect; @str; end
+		def >=(ver)
+			ary2 = ver.split(".").collect { |elm| elm.to_i }
+			if @ary[0] > ary2[0]; return true; end			
+			if @ary[0] < ary2[0]; return false; end
+			if @ary[1] > ary2[1]; return true; end
+			if @ary[1] < ary2[1]; return false; end
+			if @ary.size < ary2.size; return false; end
+			if @ary.size == 3 and ary2.size == 3
+				if @ary[2] < ary2[2]; return false; end
+			end		
+			return true
+		end
+		def <(ver)
+			ary2 = ver.split(".").collect { |elm| elm.to_i }
+			if @ary[0] >= ary2[0]; return false; end
+			if @ary[0] >= ary2[0]; return false; end
+			return true
+		end
+	end
+end
+
 if /mingw/ =~ RUBY_PLATFORM
   GSL_CONFIG = "sh gsl-config"
 else
@@ -36,9 +66,10 @@
   
   print("checking gsl version... ")
   IO.popen("#{GSL_CONFIG} --version") do |f|
-    ver = f.gets.chomp
+    ver = GSL::Version.new(f.gets.chomp)
     puts(ver)
     configfile.printf("#ifndef GSL_VERSION\n#define GSL_VERSION \"#{ver}\"\n#endif\n")
+
     if ver >= "0.9.4"
       configfile.printf("#ifndef GSL_0_9_4_LATER\n#define GSL_0_9_4_LATER\n#endif\n")
     else
@@ -77,7 +108,10 @@
     if ver >= "1.8.90"
       configfile.printf("#ifndef GSL_1_9_LATER\n#define GSL_1_9_LATER\n#endif\n")
     end
-    
+
+    if ver >= "1.9.90"
+      configfile.printf("#ifndef GSL_1_10_LATER\n#define GSL_1_10_LATER\n#endif\n")
+    end    
     if ver < "1.4"
       configfile.printf("#ifndef GSL_CONST_OLD\n#define GSL_CONST_OLD\n#endif\n")
     end
@@ -93,7 +127,7 @@
   RB_GSL_CONFIG = File.open("../include/rb_gsl_config.h", "w")
   RB_GSL_CONFIG.printf("#ifndef ___RB_GSL_CONFIG_H___\n")
   RB_GSL_CONFIG.printf("#define ___RB_GSL_CONFIG_H___\n\n")
-  
+
   check_version(RB_GSL_CONFIG)
 
   gsl_config()
@@ -135,26 +169,21 @@
     RB_GSL_CONFIG.printf("#ifndef HAVE_EIGEN_FRANCIS\n#define HAVE_EIGEN_FRANCIS\n#endif\n")
   end
 
-  if have_library("gsl", "gsl_eigen_gen_alloc")
-    RB_GSL_CONFIG.printf("#ifndef HAVE_EIGEN_GEN\n#define HAVE_EIGEN_GEN\n#endif\n")
-  end
-
-  if have_library("gsl", "gsl_stats_correlation")
-    RB_GSL_CONFIG.printf("#ifndef HAVE_GSL_STATS_CORRELATION\n#define HAVE_GSL_STATS_CORRELATION\n#endif\n")
-  end
-  
   begin
     print("checking rb-gsl version...")
     IO.popen("cat ../VERSION") do |f|
-      ver = f.gets.chomp
+      ver = GSL::Version.new(f.gets.chomp)
       puts(ver)
       RB_GSL_CONFIG.printf("#ifndef RUBY_GSL_VERSION\n#define RUBY_GSL_VERSION \"#{ver}\"\n#endif\n")
     end
   end
+
+  RUBY_VERSION2 = GSL::Version.new(RUBY_VERSION)
   
-  puts("checking ruby version... #{RUBY_VERSION}")
-  if RUBY_VERSION >= "1.8"
+  puts("checking ruby version... #{RUBY_VERSION2}")
+  if RUBY_VERSION2 >= "1.8"
     RB_GSL_CONFIG.printf("#ifndef RUBY_1_8_LATER\n#define RUBY_1_8_LATER\n#endif\n")
+
     if find_executable("graph")
       RB_GSL_CONFIG.printf("#ifndef HAVE_GNU_GRAPH\n#define HAVE_GNU_GRAPH\n#endif\n")
     end
@@ -172,7 +201,7 @@
     end
     puts("no") if flag == 0
   end
-  if RUBY_VERSION >= "1.9"
+  if RUBY_VERSION2 >= "1.9"
     RB_GSL_CONFIG.printf("#ifndef RUBY_1_9_LATER\n#define RUBY_1_9_LATER\n#endif\n")
   end