File: makefile.rb

package info (click to toggle)
ruby-pgplot 0.2.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 496 kB
  • sloc: ruby: 1,625; makefile: 77; ansic: 57; sh: 17
file content (54 lines) | stat: -rw-r--r-- 1,011 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
$src_dir = ARGV[0] || 'pgplot'
$build_dir = ARGV[1] || 'build'

case RUBY_PLATFORM
when /-linux$/
  os='linux'
when /-cygwin$/
  os='cygwin'
when /-freebsd$/
  os='freebsd'
when /-bsd$/
  os='bsd'
when /sparc-solaris$/
  os='sol2'
when /x86-solaris$/
  os='solx86'
else
  raise "RUBY_PLATFORM=#{RUBY_PLATFORM}: not supported"
end
puts "Platform = "+os


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

fc = find_cmd %w[gfortran g77]
puts "FORTRAN compiler = "+fc
puts

Dir.chdir $build_dir do
  cmd="../#{$src_dir}/makemake ../#{$src_dir} #{os} g77_gcc"
  puts cmd+' ...'
  s=system cmd
  raise "failed: #{cmd}" if !s

  File.rename "makefile", "makefile.orig"
  File.open("makefile","w") do |w|
    File.open("makefile.orig","r") do |r|
      r.each_line do |l|
   	l.chomp!
   	l.sub!(/g77/,"gfortran") if fc=='gfortran'
   	if /^pndriv\.o : / !~ l
   	  w.puts l
   	end
      end
    end
  end
end