Top Level Namespace
Defined Under Namespace
Modules: Pgplot Classes: PgCursorError
Instance Method Summary collapse
- #autobuild_pgplot ⇒ Object
- #check_extra_libs ⇒ Object
- #check_narray ⇒ Object
- #cogen_pgplot ⇒ Object
- #extconf_start ⇒ Object
- #find_cmd(a) ⇒ Object
- #find_libnarray_a ⇒ Object
- #find_narray_h ⇒ Object
- #main ⇒ Object
- #pgfuncgen(name, inp, out) ⇒ Object
Instance Method Details
#autobuild_pgplot ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'ext/extconf.rb', line 155 def autobuild_pgplot # Exit unless a fortran compiler was found exit unless %w[gfortran g77].any?{|cmd| system("which #{cmd}")} puts "enabling auto-build PGPLOT Library..." $subdir = 'build_lib' $CFLAGS = "-I#{$subdir}/build "+$CFLAGS $LDFLAGS = "-L#{$subdir}/build "+$LDFLAGS $libs = append_library($libs, "cpgplot") $defs.push '-DPGPLOT_DIR=\\"$(PGPLOT_DIR)\\"' # Generate Makefile create_makefile("pgplot") # Append PGPLOT install task to Makefile exit unless $makefile_created puts "appending extra install tasks to Makefile" File.open("Makefile","a") do |w| w.print " PGPLOT_DIR = $(RUBYARCHDIR)/pgplot PGPLOT_BUILD = #{$subdir}/build $(PGPLOT_BUILD)/libcpgplot.a: (cd #{$subdir}; make build/libcpgplot.a) $(PGPLOT_BUILD)/cpgplot.h: $(PGPLOT_BUILD)/libcpgplot.a rb_pgplot.o: $(PGPLOT_BUILD)/cpgplot.h $(DLLIB): $(PGPLOT_BUILD)/libcpgplot.a install: install-pgplot install-pgplot: $(MAKEDIRS) $(PGPLOT_DIR) $(INSTALL_DATA) $(PGPLOT_BUILD)/grfont.dat $(PGPLOT_DIR) $(INSTALL_DATA) $(PGPLOT_BUILD)/rgb.txt $(PGPLOT_DIR) " if $found_lib.include? "X11" w.print \ " $(INSTALL_PROG) $(PGPLOT_BUILD)/pgxwin_server $(PGPLOT_DIR) $(PGPLOT_BUILD)/pgxwin_server: $(PGPLOT_BUILD)/cpgplot.h (cd #{$subdir}; make build/pgxwin_server) $(DLLIB): $(PGPLOT_BUILD)/pgxwin_server " end end puts "creating #{$subdir}/drivers.conf" File.open("#{$subdir}/drivers.conf","w") do |w| w.puts "GIDRIV PPDRIV PSDRIV" w.puts "PNDRIV" if $found_lib.include? "png" w.puts "WDDRIV XWDRIV" if $found_lib.include? "X11" end puts "Ready to download and auto-build PGPLOT !!" end |
#check_extra_libs ⇒ Object
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 |
# File 'ext/extconf.rb', line 105 def 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" end exit unless have_library("GrWin", "GWinit") 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 end |
#check_narray ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'ext/extconf.rb', line 85 def check_narray require "narray" find_narray_h if !have_header("narray.h") puts " Header numo/narray.h was not found. Give pathname as follows: % ruby extconf.rb --with-narray-include=narray_h_dir" exit(1) end if RUBY_PLATFORM =~ /mswin|cygwin|mingw/ find_libnarray_a unless have_library("narray","na_make_object") puts "libnarray.a not found" exit(1) end end end |
#cogen_pgplot ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'ext/cogen.rb', line 142 def cogen_pgplot fin = open("rb_pgplot.c.in","r") fout = open("rb_pgplot.c","w") while l = fin.gets if /--- auto-generated funcs will be placed here ---/ =~ l $pgfuncs.each{|x| fout.print pgfuncgen(*x)} elsif /--- auto-generated defs will be placed here ---/ =~ l $pgfuncs.each{|x| n = x[1].split(",").size fout.print " rb_define_module_function(mPgplot,\"#{x[0]}\",rb_pgplot_#{x[0]},#{n});\n"} else fout.print end end fout.close fin.close end |
#extconf_start ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'ext/extconf.rb', line 47 def extconf_start # configure options: # --with-pgplot-dir=path # --with-pgplot-include=path # --with-pgplot-lib=path dir_config("pgplot") # configure options: # --with-x11-dir=path # --with-x11-include=path # --with-x11-lib=path dir_config("x11") # Otherwise you can also specify: # --with-opt-dir=path # --with-opt-include=path # --with-opt-lib=path end |
#find_cmd(a) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'ext/build_lib/makefile.rb', line 23 def find_cmd(a) a.each do |cmd| if system("which #{cmd}") return cmd end end raise "No FORTRAN compiler found in: [#{a.join(' ')}]" end |
#find_libnarray_a ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'ext/extconf.rb', line 76 def find_libnarray_a $LOAD_PATH.each do |x| if File.exist? File.join(x,'libnarray.a') $LDFLAGS = "-L#{x} " + $LDFLAGS break end end end |
#find_narray_h ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'ext/extconf.rb', line 66 def find_narray_h $LOAD_PATH.each do |x| p x if File.exist? File.join(x,'narray.h') $INCFLAGS = "-I#{x} " + $INCFLAGS break end end end |
#main ⇒ Object
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 |
# File 'ext/extconf.rb', line 3 def main extconf_start check_narray $objs = %w(rb_pgplot.o kwarg.o) $enable_autobuild = enable_config('autobuild', false) $found_lib = [] # Check PGPLOT Header if have_header("cpgplot.h") if have_library("cpgplot","cpgbeg") create_makefile("pgplot") exit end # Check for extra libs then re-check for PGPLOT library puts "First check for PGPLOT library failed." check_extra_libs $libs = append_library($libs, "pgplot") if have_library("cpgplot","cpgbeg") create_makefile("pgplot") exit end elsif $enable_autobuild check_extra_libs end if $enable_autobuild autobuild_pgplot else puts " The PGPLOT library was not found. To auto-build PGPLOT library as part of installing Ruby/PGPLOT, pass the --enable-autobuild option. Examples: Gem install: gem install pgplot -- --enable-autobuild Manual install: ruby extconf.rb --enable-autobuild " end end |
#pgfuncgen(name, inp, out) ⇒ Object
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 |
# File 'ext/cogen.rb', line 95 def pgfuncgen(name, inp, out) inp = inp.split(",").collect{|i| i.to_i} out = out.split(",").collect{|i| i.to_i} ninp = inp.size nout = out.size # int->0, float->1 val2 = ["NUM2INT","NUM2DBL","StringValuePtr"] type = ["int","float",nil] conv = ["INT2NUM","rb_float_new",nil] # Initialize Array prot = ["VALUE obj"] pass = [] vars = [] retn = [] inp.each_with_index { |i,x| prot << "VALUE arg#{x}" pass << "#{val2[i]}(arg#{x})" } out.each_with_index { |i,x| vars << "#{type[i]} var#{x};" pass << "&var#{x}" retn << "#{conv[i]}(var#{x})" } if nout==0 then retn = "Qtrue"; elsif nout>1 then retn = "rb_ary_new3(#{nout},"+retn.join(",")+")" else retn = retn.join("") end vars = vars.join("") prot = prot.join(",") pass = pass.join(",") return " static VALUE rb_pgplot_#{name}(#{prot}) { #{vars} c#{name}(#{pass}); return #{retn}; } " end |