aboutsummaryrefslogtreecommitdiff
path: root/externals/gridflow/devices4ruby/extconf.rb
blob: 9e49cbdcba2aedbb4d51f427e65a12ad722bc4ed (plain)
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
#!/usr/bin/env ruby
# $Id: extconf.rb,v 1.1 2005-10-04 02:02:14 matju Exp $
# installer for RubyX11 / MetaRuby / etc
# by Mathieu Bouchard

require "rbconfig"
require "ftools"
include Config

$DESTDIR = "#{CONFIG["sitedir"]}/#{CONFIG["MAJOR"]}.#{CONFIG["MINOR"]}"
#$DESTDIR = "/home/matju/lib/ruby/#{RUBY_VERSION[0,3]}"
$RUBY = "ruby"

while ARGV.length>0
  arg=ARGV.shift
  case arg
  when /=/
    i=arg.index '='
    ARGV.unshift arg[0..i-1], arg[i+1..-1]
  when "--prefix"
    $DESTDIR = ARGV.shift + "/lib/ruby/#{CONFIG["MAJOR"]}.#{CONFIG["MINOR"]}"
  end
end



def install_files(f,base,entries)
  entries.each {|type,name,*rest|
    case type
    when :ruby
      f.puts "\tinstall -m644 #{base+name} $(DESTDIR)/#{base+name}"
    when :directory
      f.puts "\t@mkdir $(DESTDIR)/#{base+name} || true"
      install_files(f,base+name,rest) 
    end
  }
end

def uninstall_files(f,base,entries)
  entries.each {|type,name,*rest|
    case type
    when :ruby
      f.puts "\trm $(DESTDIR)/#{base+name}"
    when :directory
      uninstall_files(f,base+name,rest) 
    end
  }
end

def make_makefile
  File.open("Makefile","w") {|f|
    f.puts "# Warning: this file is GENERATED by ./extconf.rb", ""
    f.puts "DESTDIR = #{$DESTDIR}", ""
    f.puts "RUBY = #{$RUBY}"
    f.puts "all::", ""
    f.puts "Makefile: extconf.rb"
    f.puts "\t$(RUBY) extconf.rb", ""

    f.puts "install::"
    f.puts "\t@mkdir -p $(DESTDIR)"
    install_files(f,"",FILES)
    f.puts
    f.puts "uninstall::"
    uninstall_files(f,"",FILES)
    f.puts
  }
  #FILES.each {|name|
  #  File.install "lib/#{name}", "#{DSTPATH}/#{name}", 0644, true   
  #end
end

#----------------------------------------------------------------#

$DESTDIR += "/linux/" #(HACK!)

FILES = [
#  [:directory, "linux/",
    [:ruby, "ioctl.rb"],
    [:ruby, "SoundPCM.rb"],
    [:ruby, "ParallelPort.rb"],
    [:ruby, "SoundMixer.rb"],
#  ]
]

make_makefile


__END__
### the following is discarded (just a test)

require "mkmf"

srcs = %w(
	termios
)

#have_library("m")
#have_func("sincos")
#have_func("asinh")

#if have_header("fftw.h")
#  if have_library("fftw", "fftwnd_create_plan")
#    srcs.push "na_fftw"
#  else
#    $defs.delete "-DHAVE_FFTW_H"
#  end
#end

$objs = srcs.map {|i| i+".o"}

#dir_config("linux")
create_makefile("linux")