File: extconf.rb

package info (click to toggle)
ruby-gnome2 0.19.3-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 11,556 kB
  • ctags: 14,033
  • sloc: ansic: 83,294; ruby: 33,426; makefile: 3,721; cpp: 47; xml: 35
file content (155 lines) | stat: -rw-r--r-- 3,520 bytes parent folder | 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
148
149
150
151
152
153
154
155
=begin
  top-level extconf.rb for Ruby-GNOME2

  $Id: extconf.rb,v 1.17 2007/10/22 12:19:17 ktou Exp $

  Copyright (C) 2003-2005 Ruby-GNOME2 Project Team
=end

require 'English'
require 'mkmf'
require 'fileutils'
require 'pathname'

priorlibs = ["glib", "gio", "gdkpixbuf", "pango", "atk", "gtk"]

#
# detect sub-directories
#
$ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['RUBY_INSTALL_NAME'] + Config::CONFIG['EXEEXT'])
$ruby = arg_config("--ruby", $ruby)

rm = "rm -f"
if /mswin32/ =~ RUBY_PLATFORM
  rm = "del"
end


$srcdir = File.dirname(__FILE__)
$topsrcdir = $configure_args["--topsrcdir"] ||= $srcdir
$topdir = $configure_args["--topdir"] ||= Dir.pwd
$strict = $configure_args["--strict"] ? "--strict" : ""

$srcdir = File.expand_path($srcdir)
$topsrcdir = File.expand_path($topsrcdir)
$topdir = File.expand_path($topdir)

subdirs = ARGV.select{|v|  /^--/ !~ v}

if subdirs.size == 0
  subdirs = Dir.glob($topsrcdir+"/*/**/extconf.rb")
  subdirs.collect! do |subdir|
    subdir[0..$topsrcdir.size] = ""
    File.dirname(subdir)
  end
  priorlibs &= subdirs
  subdirs -= priorlibs
  subdirs = priorlibs + subdirs #Change the order
end

#
# generate sub-directory Makefiles
#
targets = []
ignore = []

ruby, *ruby_args = Shellwords.shellwords($ruby)
if ARGV.grep(/\A--ruby=/)
  extra_args = ["--ruby=#{$ruby}"] + ARGV.reject {|arg| /\A--ruby=/ =~ arg}
else
  extra_args = ARGV.dup
end

subdirs.each do |subdir|
  STDERR.puts("#{$0}: Entering directory `#{subdir}'")
  FileUtils.mkdir_p(subdir)
  topdir = File.join(*([".."] * subdir.split(/\/+/).size))
  dir = $topsrcdir
  dir = File.join(topdir, dir) unless Pathname.new(dir).absolute?
  srcdir = File.join(dir, subdir)
  args = ruby_args + ["-C", subdir, File.join(srcdir, "extconf.rb"),
                      "--topsrcdir=#{dir}", "--topdir=#{topdir}",
                      "--srcdir=#{srcdir}", *extra_args]
  ret = system(ruby, *args)
  STDERR.puts("#{$0}: Leaving directory '#{subdir}'")
  if ret
    targets << subdir
  else
    if $strict
        exit(1)
    end

    ignore << subdir
  end
end
puts "\n-----"
puts "Target libraries: #{targets.join(', ')}" if targets.size > 0
puts "Ignored libraries: #{ignore.join(', ')}" if ignore.size > 0

#
# generate top-level Makefile
#

def run_make_in_sub_dirs(command)
  if /mswin32/ =~ RUBY_PLATFORM
    "	$(COMMAND) '$(SUBDIRS)' $(MAKE) #{command}"
  else
    <<-EOS.chomp
	@(					\\
	  succeeded='';				\\
	  failed='';				\\
	  for dir in $(SUBDIRS); do		\\
	    (cd $$dir; $(MAKE) #{command});	\\
	    if [ $$? -eq 0 ]; then		\\
	      succeeded="$$succeeded $$dir";	\\
	    else				\\
	      failed="$$failed $$dir";		\\
	    fi;					\\
	  done;					\\
	  if [ "$$succeeded" = "" ]; then	\\
	    succeeded="NONE";			\\
	  fi;					\\
	  if [ "$$failed" = "" ]; then		\\
	    failed="NONE";			\\
	  fi;					\\
	  echo;					\\
	  echo "-----";				\\
	  echo "SUCCEEDED: $$succeeded";	\\
	  echo "FAILED: $$failed";		\\
	  echo "-----";				\\
	  echo "Done.";				\\
	)
    EOS
  end
end


File.open("Makefile", "w") do |makefile|
  makefile.print(<<-EOM)
TOPSRCDIR = #{$topsrcdir}
SUBDIRS = #{targets.join(' ')}
COMMAND = #{$ruby} #{$topsrcdir}/exec_make.rb #{$strict}
RM = #{rm}

all:
#{run_make_in_sub_dirs('all')}

install:
#{run_make_in_sub_dirs('install')}

site-install:
#{run_make_in_sub_dirs('site-install')}

clean:
#{run_make_in_sub_dirs('clean')}

distclean:
#{run_make_in_sub_dirs('distclean')}
	$(RM) Makefile mkmf.log
EOM
end

puts "-----"
puts "Done."

$makefile_created = true