setup 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. data/COPYING +515 -0
  2. data/HISTORY +7 -0
  3. data/MANIFEST +231 -0
  4. data/METADATA +25 -0
  5. data/NEWS +21 -0
  6. data/README +110 -0
  7. data/bin/setup.rb +7 -0
  8. data/doc/manual/doc.en/devel.html +208 -0
  9. data/doc/manual/doc.en/hookapi.html +91 -0
  10. data/doc/manual/doc.en/index.html +28 -0
  11. data/doc/manual/doc.en/metaconfapi.html +79 -0
  12. data/doc/manual/doc.en/news.html +189 -0
  13. data/doc/manual/doc.en/usage.html +297 -0
  14. data/doc/manual/doc.ja/devel.html +301 -0
  15. data/doc/manual/doc.ja/hookapi.html +84 -0
  16. data/doc/manual/doc.ja/index.html +28 -0
  17. data/doc/manual/doc.ja/metaconfapi.html +80 -0
  18. data/doc/manual/doc.ja/news.html +186 -0
  19. data/doc/manual/doc.ja/usage.html +319 -0
  20. data/doc/rdoc/classes/Errno.html +89 -0
  21. data/doc/rdoc/classes/Errno/ENOTEMPTY.html +92 -0
  22. data/doc/rdoc/classes/File.html +134 -0
  23. data/doc/rdoc/classes/Setup.html +107 -0
  24. data/doc/rdoc/classes/Setup/Command.html +276 -0
  25. data/doc/rdoc/classes/Setup/ConfigTable.html +622 -0
  26. data/doc/rdoc/classes/Setup/Installer.html +2454 -0
  27. data/doc/rdoc/classes/Setup/Installer/Shebang.html +187 -0
  28. data/doc/rdoc/classes/SetupError.html +92 -0
  29. data/doc/rdoc/created.rid +1 -0
  30. data/doc/rdoc/files/COPYING.html +759 -0
  31. data/doc/rdoc/files/HISTORY.html +104 -0
  32. data/doc/rdoc/files/METADATA.html +92 -0
  33. data/doc/rdoc/files/NEWS.html +113 -0
  34. data/doc/rdoc/files/README.html +214 -0
  35. data/doc/rdoc/files/bin/setup_rb.html +96 -0
  36. data/doc/rdoc/files/lib/setup/build_rb.html +96 -0
  37. data/doc/rdoc/files/lib/setup/command_rb.html +98 -0
  38. data/doc/rdoc/files/lib/setup/config_rb.html +98 -0
  39. data/doc/rdoc/files/lib/setup/error_rb.html +92 -0
  40. data/doc/rdoc/files/lib/setup/install_rb.html +116 -0
  41. data/doc/rdoc/files/lib/setup/rake_rb.html +97 -0
  42. data/doc/rdoc/files/lib/setup/rubyver_rb.html +96 -0
  43. data/doc/rdoc/files/lib/setup_rb.html +92 -0
  44. data/doc/rdoc/fr_class_index.html +55 -0
  45. data/doc/rdoc/fr_file_index.html +60 -0
  46. data/doc/rdoc/fr_method_index.html +182 -0
  47. data/doc/rdoc/index.html +26 -0
  48. data/doc/rdoc/rdoc-style.css +177 -0
  49. data/doc/ri/Errno/ENOTEMPTY/cdesc-ENOTEMPTY.yaml +15 -0
  50. data/doc/ri/Errno/cdesc-Errno.yaml +15 -0
  51. data/doc/ri/File/cdesc-File.yaml +18 -0
  52. data/doc/ri/File/dir%3f-c.yaml +12 -0
  53. data/doc/ri/File/read-c.yaml +10 -0
  54. data/doc/ri/Setup/Command/cdesc-Command.yaml +28 -0
  55. data/doc/ri/Setup/Command/help-i.yaml +12 -0
  56. data/doc/ri/Setup/Command/run-c.yaml +11 -0
  57. data/doc/ri/Setup/Command/run-i.yaml +11 -0
  58. data/doc/ri/Setup/ConfigTable/%5b%5d%3d-i.yaml +12 -0
  59. data/doc/ri/Setup/ConfigTable/%5b%5d-i.yaml +12 -0
  60. data/doc/ri/Setup/ConfigTable/attr_accessor-c.yaml +12 -0
  61. data/doc/ri/Setup/ConfigTable/attr_boolean-c.yaml +12 -0
  62. data/doc/ri/Setup/ConfigTable/attr_pathlist-c.yaml +12 -0
  63. data/doc/ri/Setup/ConfigTable/attr_pathname-c.yaml +12 -0
  64. data/doc/ri/Setup/ConfigTable/cdesc-ConfigTable.yaml +66 -0
  65. data/doc/ri/Setup/ConfigTable/compiles%3f-i.yaml +10 -0
  66. data/doc/ri/Setup/ConfigTable/env_config-i.yaml +12 -0
  67. data/doc/ri/Setup/ConfigTable/extconfs-i.yaml +11 -0
  68. data/doc/ri/Setup/ConfigTable/extensions-i.yaml +10 -0
  69. data/doc/ri/Setup/ConfigTable/initialize_defaults-i.yaml +14 -0
  70. data/doc/ri/Setup/ConfigTable/installdirs%3d-i.yaml +12 -0
  71. data/doc/ri/Setup/ConfigTable/load_config-i.yaml +12 -0
  72. data/doc/ri/Setup/ConfigTable/new-c.yaml +12 -0
  73. data/doc/ri/Setup/ConfigTable/save_config-i.yaml +12 -0
  74. data/doc/ri/Setup/ConfigTable/shebang%3d-i.yaml +12 -0
  75. data/doc/ri/Setup/ConfigTable/show-i.yaml +10 -0
  76. data/doc/ri/Setup/Installer/Shebang/cdesc-Shebang.yaml +28 -0
  77. data/doc/ri/Setup/Installer/Shebang/load-c.yaml +10 -0
  78. data/doc/ri/Setup/Installer/Shebang/new-c.yaml +10 -0
  79. data/doc/ri/Setup/Installer/Shebang/parse-c.yaml +10 -0
  80. data/doc/ri/Setup/Installer/Shebang/to_s-i.yaml +10 -0
  81. data/doc/ri/Setup/Installer/binread-i.yaml +14 -0
  82. data/doc/ri/Setup/Installer/cdesc-Installer.yaml +281 -0
  83. data/doc/ri/Setup/Installer/clean_dir_bin-i.yaml +12 -0
  84. data/doc/ri/Setup/Installer/clean_dir_data-i.yaml +12 -0
  85. data/doc/ri/Setup/Installer/clean_dir_doc-i.yaml +12 -0
  86. data/doc/ri/Setup/Installer/clean_dir_etc-i.yaml +12 -0
  87. data/doc/ri/Setup/Installer/clean_dir_ext-i.yaml +10 -0
  88. data/doc/ri/Setup/Installer/clean_dir_lib-i.yaml +12 -0
  89. data/doc/ri/Setup/Installer/clean_dir_man-i.yaml +12 -0
  90. data/doc/ri/Setup/Installer/command-i.yaml +10 -0
  91. data/doc/ri/Setup/Installer/compiles%3f-i.yaml +10 -0
  92. data/doc/ri/Setup/Installer/config_dir_bin-i.yaml +12 -0
  93. data/doc/ri/Setup/Installer/config_dir_data-i.yaml +12 -0
  94. data/doc/ri/Setup/Installer/config_dir_doc-i.yaml +12 -0
  95. data/doc/ri/Setup/Installer/config_dir_etc-i.yaml +12 -0
  96. data/doc/ri/Setup/Installer/config_dir_ext-i.yaml +10 -0
  97. data/doc/ri/Setup/Installer/config_dir_lib-i.yaml +12 -0
  98. data/doc/ri/Setup/Installer/config_dir_man-i.yaml +12 -0
  99. data/doc/ri/Setup/Installer/curr_objdir-i.yaml +10 -0
  100. data/doc/ri/Setup/Installer/curr_srcdir-i.yaml +12 -0
  101. data/doc/ri/Setup/Installer/diff%3f-i.yaml +10 -0
  102. data/doc/ri/Setup/Installer/directories_of-i.yaml +10 -0
  103. data/doc/ri/Setup/Installer/distclean_dir_bin-i.yaml +12 -0
  104. data/doc/ri/Setup/Installer/distclean_dir_data-i.yaml +12 -0
  105. data/doc/ri/Setup/Installer/distclean_dir_doc-i.yaml +10 -0
  106. data/doc/ri/Setup/Installer/distclean_dir_etc-i.yaml +12 -0
  107. data/doc/ri/Setup/Installer/distclean_dir_ext-i.yaml +10 -0
  108. data/doc/ri/Setup/Installer/distclean_dir_lib-i.yaml +12 -0
  109. data/doc/ri/Setup/Installer/distclean_dir_man-i.yaml +12 -0
  110. data/doc/ri/Setup/Installer/dive_into-i.yaml +10 -0
  111. data/doc/ri/Setup/Installer/dllext-i.yaml +10 -0
  112. data/doc/ri/Setup/Installer/exec_all-i.yaml +12 -0
  113. data/doc/ri/Setup/Installer/exec_clean-i.yaml +12 -0
  114. data/doc/ri/Setup/Installer/exec_config-i.yaml +12 -0
  115. data/doc/ri/Setup/Installer/exec_distclean-i.yaml +12 -0
  116. data/doc/ri/Setup/Installer/exec_doc-i.yaml +11 -0
  117. data/doc/ri/Setup/Installer/exec_install-i.yaml +12 -0
  118. data/doc/ri/Setup/Installer/exec_rdoc-i.yaml +14 -0
  119. data/doc/ri/Setup/Installer/exec_ri-i.yaml +12 -0
  120. data/doc/ri/Setup/Installer/exec_setup-i.yaml +14 -0
  121. data/doc/ri/Setup/Installer/exec_show-i.yaml +12 -0
  122. data/doc/ri/Setup/Installer/exec_task_traverse-i.yaml +12 -0
  123. data/doc/ri/Setup/Installer/exec_test-i.yaml +14 -0
  124. data/doc/ri/Setup/Installer/exec_uninstall-i.yaml +12 -0
  125. data/doc/ri/Setup/Installer/existfiles-i.yaml +10 -0
  126. data/doc/ri/Setup/Installer/extconf-i.yaml +10 -0
  127. data/doc/ri/Setup/Installer/extdir%3f-i.yaml +10 -0
  128. data/doc/ri/Setup/Installer/extensions-i.yaml +12 -0
  129. data/doc/ri/Setup/Installer/files_of-i.yaml +10 -0
  130. data/doc/ri/Setup/Installer/force_remove_file-i.yaml +10 -0
  131. data/doc/ri/Setup/Installer/get_config-i.yaml +11 -0
  132. data/doc/ri/Setup/Installer/glob_reject-i.yaml +10 -0
  133. data/doc/ri/Setup/Installer/glob_select-i.yaml +10 -0
  134. data/doc/ri/Setup/Installer/globs2re-i.yaml +10 -0
  135. data/doc/ri/Setup/Installer/hookfiles-i.yaml +10 -0
  136. data/doc/ri/Setup/Installer/inspect-i.yaml +10 -0
  137. data/doc/ri/Setup/Installer/install-i.yaml +10 -0
  138. data/doc/ri/Setup/Installer/install_dir_bin-i.yaml +10 -0
  139. data/doc/ri/Setup/Installer/install_dir_data-i.yaml +10 -0
  140. data/doc/ri/Setup/Installer/install_dir_doc-i.yaml +12 -0
  141. data/doc/ri/Setup/Installer/install_dir_etc-i.yaml +10 -0
  142. data/doc/ri/Setup/Installer/install_dir_ext-i.yaml +10 -0
  143. data/doc/ri/Setup/Installer/install_dir_lib-i.yaml +10 -0
  144. data/doc/ri/Setup/Installer/install_dir_man-i.yaml +10 -0
  145. data/doc/ri/Setup/Installer/install_files-i.yaml +10 -0
  146. data/doc/ri/Setup/Installer/installation%21-i.yaml +10 -0
  147. data/doc/ri/Setup/Installer/installation%3f-i.yaml +12 -0
  148. data/doc/ri/Setup/Installer/libfiles-i.yaml +10 -0
  149. data/doc/ri/Setup/Installer/make-i.yaml +10 -0
  150. data/doc/ri/Setup/Installer/mapdir-i.yaml +10 -0
  151. data/doc/ri/Setup/Installer/mkdir_p-i.yaml +10 -0
  152. data/doc/ri/Setup/Installer/move_file-i.yaml +10 -0
  153. data/doc/ri/Setup/Installer/new-c.yaml +12 -0
  154. data/doc/ri/Setup/Installer/new_shebang-i.yaml +10 -0
  155. data/doc/ri/Setup/Installer/no_harm%3f-i.yaml +10 -0
  156. data/doc/ri/Setup/Installer/noop-i.yaml +54 -0
  157. data/doc/ri/Setup/Installer/objdir_root-i.yaml +10 -0
  158. data/doc/ri/Setup/Installer/open_atomic_writer-i.yaml +10 -0
  159. data/doc/ri/Setup/Installer/quiet%3f-i.yaml +10 -0
  160. data/doc/ri/Setup/Installer/record_installation-i.yaml +10 -0
  161. data/doc/ri/Setup/Installer/relpath-i.yaml +10 -0
  162. data/doc/ri/Setup/Installer/remove_file-i.yaml +10 -0
  163. data/doc/ri/Setup/Installer/remove_tree-i.yaml +10 -0
  164. data/doc/ri/Setup/Installer/remove_tree0-i.yaml +10 -0
  165. data/doc/ri/Setup/Installer/report_header-i.yaml +11 -0
  166. data/doc/ri/Setup/Installer/rm_f-i.yaml +10 -0
  167. data/doc/ri/Setup/Installer/rm_rf-i.yaml +10 -0
  168. data/doc/ri/Setup/Installer/rmdir-i.yaml +10 -0
  169. data/doc/ri/Setup/Installer/ruby-i.yaml +10 -0
  170. data/doc/ri/Setup/Installer/rubyextentions-i.yaml +10 -0
  171. data/doc/ri/Setup/Installer/run_hook-i.yaml +10 -0
  172. data/doc/ri/Setup/Installer/set_config-i.yaml +12 -0
  173. data/doc/ri/Setup/Installer/setup_dir_bin-i.yaml +10 -0
  174. data/doc/ri/Setup/Installer/setup_dir_data-i.yaml +12 -0
  175. data/doc/ri/Setup/Installer/setup_dir_doc-i.yaml +12 -0
  176. data/doc/ri/Setup/Installer/setup_dir_etc-i.yaml +12 -0
  177. data/doc/ri/Setup/Installer/setup_dir_ext-i.yaml +10 -0
  178. data/doc/ri/Setup/Installer/setup_dir_lib-i.yaml +12 -0
  179. data/doc/ri/Setup/Installer/setup_dir_man-i.yaml +12 -0
  180. data/doc/ri/Setup/Installer/srcdir_root-i.yaml +12 -0
  181. data/doc/ri/Setup/Installer/srcdirectories-i.yaml +10 -0
  182. data/doc/ri/Setup/Installer/srcdirectory%3f-i.yaml +10 -0
  183. data/doc/ri/Setup/Installer/srcentries-i.yaml +10 -0
  184. data/doc/ri/Setup/Installer/srcexist%3f-i.yaml +10 -0
  185. data/doc/ri/Setup/Installer/srcfile%3f-i.yaml +10 -0
  186. data/doc/ri/Setup/Installer/srcfile-i.yaml +10 -0
  187. data/doc/ri/Setup/Installer/srcfiles-i.yaml +10 -0
  188. data/doc/ri/Setup/Installer/targetfiles-i.yaml +10 -0
  189. data/doc/ri/Setup/Installer/traverse-i.yaml +10 -0
  190. data/doc/ri/Setup/Installer/update_shebang_line-i.yaml +10 -0
  191. data/doc/ri/Setup/Installer/verbose%3f-i.yaml +10 -0
  192. data/doc/ri/Setup/Installer/verbose_off-i.yaml +10 -0
  193. data/doc/ri/Setup/cdesc-Setup.yaml +15 -0
  194. data/doc/ri/SetupError/cdesc-SetupError.yaml +15 -0
  195. data/doc/ri/created.rid +1 -0
  196. data/lib/setup.rb +5 -0
  197. data/lib/setup/build.rb +2 -0
  198. data/lib/setup/command.rb +169 -0
  199. data/lib/setup/config.rb +339 -0
  200. data/lib/setup/error.rb +1 -0
  201. data/lib/setup/install.rb +915 -0
  202. data/lib/setup/rake.rb +62 -0
  203. data/lib/setup/rubyver.rb +25 -0
  204. data/script/install +6 -0
  205. metadata +293 -0
@@ -0,0 +1,15 @@
1
+ --- !ruby/object:RI::ClassDescription
2
+ attributes: []
3
+
4
+ class_methods: []
5
+
6
+ comment: ""
7
+ constants: []
8
+
9
+ full_name: Setup
10
+ includes: []
11
+
12
+ instance_methods: []
13
+
14
+ name: Setup
15
+ superclass:
@@ -0,0 +1,15 @@
1
+ --- !ruby/object:RI::ClassDescription
2
+ attributes: []
3
+
4
+ class_methods: []
5
+
6
+ comment:
7
+ constants: []
8
+
9
+ full_name: SetupError
10
+ includes: []
11
+
12
+ instance_methods: []
13
+
14
+ name: SetupError
15
+ superclass: StandardError
@@ -0,0 +1 @@
1
+ Sat, 16 Aug 2008 17:37:07 -0400
data/lib/setup.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Setup
2
+ VERSION = '4.0.0'
3
+ COPYRIGHT = 'Copyright (c) 2002,2008 Minero Aoki & Thomas Sawyer'
4
+ end
5
+
@@ -0,0 +1,2 @@
1
+ # TODO: Extract the compiler portion of setup and put it here.
2
+
@@ -0,0 +1,169 @@
1
+ require 'setup/config'
2
+ require 'setup/build'
3
+ require 'setup/install'
4
+
5
+ module Setup
6
+
7
+ # CLI for setup.
8
+ #
9
+ class Command
10
+
11
+ TASKS = %w(all config show setup test install uninstall rdoc ri clean distclean)
12
+
13
+ TASK_DESCRIPTIONS = [
14
+ [ 'all', 'do config, setup, then install' ],
15
+ [ 'config', 'saves your configurations' ],
16
+ [ 'show', 'shows current configuration' ],
17
+ [ 'setup', 'compiles ruby extentions and others' ],
18
+ [ 'rdoc', 'generate rdoc documentation' ],
19
+ [ 'ri', 'generate ri documentation' ],
20
+ [ 'install', 'installs files' ],
21
+ [ 'test', 'run all tests in test/' ],
22
+ [ 'clean', "does `make clean' for each extention" ],
23
+ [ 'distclean',"does `make distclean' for each extention" ]
24
+ ]
25
+
26
+ #
27
+ def self.run
28
+ new.run
29
+ end
30
+
31
+ #
32
+ def run
33
+ installer = Setup::Installer.new
34
+
35
+ task = ARGV.find{ |a| a !~ /^[-]/ }
36
+ task = 'all' unless task
37
+
38
+ unless TASKS.include?(task)
39
+ $stderr.puts "Not a valid task -- #{task}"
40
+ exit 1
41
+ end
42
+
43
+ opts = OptionParser.new
44
+
45
+ opts.banner = "Usage: #{File.basename($0)} [task] [options]"
46
+
47
+ if task == 'config' or task == 'all'
48
+ opts.separator ""
49
+ opts.separator "Config options:"
50
+ ConfigTable::DESCRIPTIONS.each do |name, type, desc|
51
+ opts.on("--#{name} #{type.to_s.upcase}", desc) do |val|
52
+ ENV[name.to_s] = val.to_s
53
+ end
54
+ end
55
+ end
56
+
57
+ if task == 'install'
58
+ opts.separator ""
59
+ opts.separator "Install options:"
60
+
61
+ opts.on("--prefix PATH", "Installation prefix") do |val|
62
+ installer.install_prefix = val
63
+ end
64
+ end
65
+
66
+ if task == 'test'
67
+ opts.separator ""
68
+ opts.separator "Install options:"
69
+
70
+ opts.on("--runner TYPE", "Test runner (auto|console|gtk|gtk2|tk)") do |val|
71
+ installer.config.testrunner = val
72
+ end
73
+ end
74
+
75
+ # common options
76
+ opts.separator ""
77
+ opts.separator "General options:"
78
+
79
+ opts.on("-q", "--quiet", "Silence output") do |val|
80
+ installer.quiet = val
81
+ end
82
+
83
+ opts.on("--verbose", "Provide verbose output") do |val|
84
+ installer.verbose = val
85
+ end
86
+
87
+ opts.on("-n", "--no-write", "Do not write to disk") do |val|
88
+ installer.no_harm = !val
89
+ end
90
+
91
+ opts.on("--dryrun", "Same as --no-write") do |val|
92
+ installer.no_harm = val
93
+ end
94
+
95
+ # common options
96
+ opts.separator ""
97
+ opts.separator "Inform options:"
98
+
99
+ # Tail options (eg. commands in option form)
100
+ opts.on_tail("-h", "--help", "display this help information") do
101
+ puts help
102
+ exit
103
+ end
104
+
105
+ opts.on_tail("--version", "Show version") do
106
+ puts File.basename($0) + ' v' + Setup::VERSION #Version.join('.')
107
+ exit
108
+ end
109
+
110
+ opts.on_tail("--copyright", "Show copyright") do
111
+ puts Setup::COPYRIGHT #opyright
112
+ exit
113
+ end
114
+
115
+ begin
116
+ opts.parse!(ARGV)
117
+ rescue OptionParser::InvalidOption
118
+ $stderr.puts $!.to_s.capitalize
119
+ exit 1
120
+ end
121
+
122
+ begin
123
+ installer.__send__("exec_#{task}")
124
+ rescue SetupError
125
+ raise if $DEBUG
126
+ $stderr.puts $!.message
127
+ $stderr.puts "Try 'ruby #{$0} --help' for detailed usage."
128
+ exit 1
129
+ end
130
+ end
131
+
132
+ # Generate help text.
133
+ def help
134
+ fmt = " " * 10 + "%-10s %s"
135
+ commands = TASK_DESCRIPTIONS.collect do |k,d|
136
+ (fmt % ["#{k}", d])
137
+ end.join("\n").strip
138
+
139
+ fmt = " " * 13 + "%-20s %s"
140
+ configs = ConfigTable::DESCRIPTIONS.collect do |k,t,d|
141
+ (fmt % ["--#{k}", d])
142
+ end.join("\n").strip
143
+
144
+ text = <<-END
145
+ USAGE: #{File.basename($0)} [command] [options]
146
+
147
+ Commands:
148
+ #{commands}
149
+
150
+ Options for CONFIG:
151
+ #{configs}
152
+
153
+ Options for INSTALL:
154
+ --prefix Set the install prefix
155
+
156
+ Options in common:
157
+ -q --quiet Silence output
158
+ --verbose Provide verbose output
159
+ -n --no-write Do not write to disk
160
+
161
+ END
162
+
163
+ text.gsub(/^ \ \ \ \ \ /, '')
164
+ end
165
+
166
+ end
167
+
168
+ end
169
+
@@ -0,0 +1,339 @@
1
+ require 'rbconfig'
2
+ require 'setup/rubyver'
3
+ require 'setup/error'
4
+
5
+ module Setup
6
+
7
+ # Config stores platform information.
8
+
9
+ class ConfigTable # TODO: Rename to Config (?)
10
+
11
+ RBCONFIG = ::Config::CONFIG
12
+
13
+ CONFIGFILE = '.config'
14
+
15
+ DESCRIPTIONS = [
16
+ [:prefix , :path, 'path prefix of target environment'],
17
+ [:bindir , :path, 'directory for commands'],
18
+ [:libdir , :path, 'directory for libraries'],
19
+ [:datadir , :path, 'directory for shared data'],
20
+ [:mandir , :path, 'directory for man pages'],
21
+ [:docdir , :path, 'Directory for documentation'],
22
+ [:sysconfdir , :path, 'directory for system configuration files'],
23
+ [:localstatedir , :path, 'directory for local state data'],
24
+ [:libruby , :path, 'directory for ruby libraries'],
25
+ [:librubyver , :path, 'directory for standard ruby libraries'],
26
+ [:librubyverarch , :path, 'directory for standard ruby extensions'],
27
+ [:siteruby , :path, 'directory for version-independent aux ruby libraries'],
28
+ [:siterubyver , :path, 'directory for aux ruby libraries'],
29
+ [:siterubyverarch , :path, 'directory for aux ruby binaries'],
30
+ [:rbdir , :path, 'directory for ruby scripts'],
31
+ [:sodir , :path, 'directory for ruby extentions'],
32
+ [:rubypath , :prog, 'path to set to #! line'],
33
+ [:rubyprog , :prog, 'ruby program using for installation'],
34
+ [:makeprog , :prog, 'make program to compile ruby extentions'],
35
+ [:extconfopt , :name, 'options to pass-thru to extconf.rb'],
36
+ [:without_ext , :bool, 'do not compile/install ruby extentions'],
37
+ [:without_doc , :bool, 'do not generate html documentation'],
38
+ [:shebang , :pick, 'shebang line (#!) editing mode (all,ruby,never)'],
39
+ [:doctemplate , :pick, 'document template to use (html|xml)'],
40
+ [:testrunner , :pick, 'Runner to use for testing (auto|console|tk|gtk|gtk2)'],
41
+ [:installdirs , :pick, 'install location mode (std,site,home :: libruby,site_ruby,$HOME)']
42
+ ]
43
+
44
+ # List of configurable options.
45
+ OPTIONS = DESCRIPTIONS.collect{ |(k,t,v)| k.to_s }
46
+
47
+ # Pathname attribute. Pathnames are automatically expanded
48
+ # unless they start with '$', a path variable.
49
+ def self.attr_pathname(name)
50
+ class_eval %{
51
+ def #{name}
52
+ @#{name}.gsub(%r<\\$([^/]+)>){ self[$1] }
53
+ end
54
+ def #{name}=(path)
55
+ raise SetupError, "bad config: #{name.to_s.upcase} requires argument" unless path
56
+ @#{name} = (path[0,1] == '$' ? path : File.expand_path(path))
57
+ end
58
+ }
59
+ end
60
+
61
+ # List of pathnames. These are not expanded though.
62
+ def self.attr_pathlist(name)
63
+ class_eval %{
64
+ def #{name}
65
+ @#{name}
66
+ end
67
+ def #{name}=(pathlist)
68
+ case pathlist
69
+ when Array
70
+ @#{name} = pathlist
71
+ else
72
+ @#{name} = pathlist.to_s.split(/[:;,]/)
73
+ end
74
+ end
75
+ }
76
+ end
77
+
78
+ # Adds boolean support.
79
+ def self.attr_accessor(*names)
80
+ bools, attrs = names.partition{ |name| name.to_s =~ /\?$/ }
81
+ attr_boolean *bools
82
+ super *attrs
83
+ end
84
+
85
+ # Boolean attribute. Can be assigned true, false, nil, or
86
+ # a string matching yes|true|y|t or no|false|n|f.
87
+ def self.attr_boolean(*names)
88
+ names.each do |name|
89
+ name = name.to_s.chomp('?')
90
+ attr_reader name # MAYBE: Deprecate
91
+ code = %{
92
+ def #{name}?; @#{name}; end
93
+ def #{name}=(val)
94
+ case val
95
+ when true, false, nil
96
+ @#{name} = val
97
+ else
98
+ case val.to_s.downcase
99
+ when 'y', 'yes', 't', 'true'
100
+ @#{name} = true
101
+ when 'n', 'no', 'f', 'false'
102
+ @#{name} = false
103
+ else
104
+ raise SetupError, "bad config: use #{name.upcase}=(yes|no) [\#{val}]"
105
+ end
106
+ end
107
+ end
108
+ }
109
+ class_eval code
110
+ end
111
+ end
112
+
113
+ DESCRIPTIONS.each do |k,t,d|
114
+ case t
115
+ when :path
116
+ attr_pathname k
117
+ when :bool
118
+ attr_boolean k
119
+ else
120
+ attr_accessor k
121
+ end
122
+ end
123
+
124
+ # # provide verbosity (default is true)
125
+ # attr_accessor :verbose?
126
+
127
+ # # don't actually write files to system
128
+ # attr_accessor :no_harm?
129
+
130
+ # shebang has only three options.
131
+ def shebang=(val)
132
+ if %w(all ruby never).include?(val)
133
+ @shebang = val
134
+ else
135
+ raise SetupError, "bad config: use SHEBANG=(all|ruby|never) [#{val}]"
136
+ end
137
+ end
138
+
139
+ # installdirs has only three options; and it has side-effects.
140
+ def installdirs=(val)
141
+ @installdirs = val
142
+ case val.to_s
143
+ when 'std'
144
+ self.rbdir = '$librubyver'
145
+ self.sodir = '$librubyverarch'
146
+ when 'site'
147
+ self.rbdir = '$siterubyver'
148
+ self.sodir = '$siterubyverarch'
149
+ when 'home'
150
+ raise SetupError, 'HOME is not set.' unless ENV['HOME']
151
+ self.prefix = ENV['HOME']
152
+ self.rbdir = '$libdir/ruby'
153
+ self.sodir = '$libdir/ruby'
154
+ else
155
+ raise SetupError, "bad config: use INSTALLDIRS=(std|site|home|local) [#{val}]"
156
+ end
157
+ end
158
+
159
+ # New ConfigTable
160
+ def initialize(values=nil)
161
+ initialize_defaults
162
+ if values
163
+ values.each{ |k,v| __send__("#{k}=", v) }
164
+ end
165
+ yeild(self) if block_given?
166
+ load_config if File.file?(CONFIGFILE)
167
+ end
168
+
169
+ # Assign CONFIG defaults
170
+ #
171
+ # TODO: Does this handle 'nmake' on windows?
172
+ def initialize_defaults
173
+ prefix = RBCONFIG['prefix']
174
+
175
+ rubypath = File.join(RBCONFIG['bindir'], RBCONFIG['ruby_install_name'] + RBCONFIG['EXEEXT'])
176
+
177
+ major = RBCONFIG['MAJOR'].to_i
178
+ minor = RBCONFIG['MINOR'].to_i
179
+ teeny = RBCONFIG['TEENY'].to_i
180
+ version = "#{major}.#{minor}"
181
+
182
+ # ruby ver. >= 1.4.4?
183
+ newpath_p = ((major >= 2) or
184
+ ((major == 1) and
185
+ ((minor >= 5) or
186
+ ((minor == 4) and (teeny >= 4)))))
187
+
188
+ if RBCONFIG['rubylibdir']
189
+ # V > 1.6.3
190
+ libruby = "#{prefix}/lib/ruby"
191
+ librubyver = RBCONFIG['rubylibdir']
192
+ librubyverarch = RBCONFIG['archdir']
193
+ siteruby = RBCONFIG['sitedir']
194
+ siterubyver = RBCONFIG['sitelibdir']
195
+ siterubyverarch = RBCONFIG['sitearchdir']
196
+ elsif newpath_p
197
+ # 1.4.4 <= V <= 1.6.3
198
+ libruby = "#{prefix}/lib/ruby"
199
+ librubyver = "#{prefix}/lib/ruby/#{version}"
200
+ librubyverarch = "#{prefix}/lib/ruby/#{version}/#{c['arch']}"
201
+ siteruby = RBCONFIG['sitedir']
202
+ siterubyver = "$siteruby/#{version}"
203
+ siterubyverarch = "$siterubyver/#{RBCONFIG['arch']}"
204
+ else
205
+ # V < 1.4.4
206
+ libruby = "#{prefix}/lib/ruby"
207
+ librubyver = "#{prefix}/lib/ruby/#{version}"
208
+ librubyverarch = "#{prefix}/lib/ruby/#{version}/#{c['arch']}"
209
+ siteruby = "#{prefix}/lib/ruby/#{version}/site_ruby"
210
+ siterubyver = siteruby
211
+ siterubyverarch = "$siterubyver/#{RBCONFIG['arch']}"
212
+ end
213
+
214
+ if arg = RBCONFIG['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
215
+ makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
216
+ else
217
+ makeprog = 'make'
218
+ end
219
+
220
+ parameterize = lambda do |path|
221
+ val = RBCONFIG[path]
222
+ raise "Unknown path -- #{path}" if val.nil?
223
+ val.sub(/\A#{Regexp.quote(prefix)}/, '$prefix')
224
+ end
225
+
226
+ self.prefix = prefix
227
+ self.bindir = parameterize['bindir']
228
+ self.libdir = parameterize['libdir']
229
+ self.datadir = parameterize['datadir']
230
+ self.mandir = parameterize['mandir']
231
+ self.docdir = File.dirname(parameterize['docdir']) # b/c of trailing $(PACKAGE)
232
+ self.sysconfdir = parameterize['sysconfdir']
233
+ self.localstatedir = parameterize['localstatedir']
234
+ self.libruby = libruby
235
+ self.librubyver = librubyver
236
+ self.librubyverarch = librubyverarch
237
+ self.siteruby = siteruby
238
+ self.siterubyver = siterubyver
239
+ self.siterubyverarch = siterubyverarch
240
+ self.rbdir = '$siterubyver'
241
+ self.sodir = '$siterubyverarch'
242
+ self.rubypath = rubypath
243
+ self.rubyprog = rubypath
244
+ self.makeprog = makeprog
245
+ self.extconfopt = ''
246
+ self.shebang = 'ruby'
247
+ self.without_ext = 'no'
248
+ self.without_doc = 'yes'
249
+ self.doctemplate = 'html'
250
+ self.testrunner = 'auto'
251
+ self.installdirs = 'site'
252
+ end
253
+
254
+ # Get configuration from environment.
255
+ def env_config
256
+ OPTIONS.each do |name|
257
+ if value = ENV[name]
258
+ __send__("#{name}=",value)
259
+ end
260
+ end
261
+ end
262
+
263
+ # Load configuration.
264
+ def load_config
265
+ #if File.file?(CONFIGFILE)
266
+ begin
267
+ File.foreach(CONFIGFILE) do |line|
268
+ k, v = *line.split(/=/, 2)
269
+ k.gsub!('-','_')
270
+ __send__("#{k}=",v.strip) #self[k] = v.strip
271
+ end
272
+ rescue Errno::ENOENT
273
+ raise SetupError, $!.message + "\n#{File.basename($0)} config first"
274
+ end
275
+ #end
276
+ end
277
+
278
+ # Save configuration.
279
+ def save_config
280
+ File.open(CONFIGFILE, 'w') do |f|
281
+ OPTIONS.each do |name|
282
+ val = self[name]
283
+ f << "#{name}=#{val}\n"
284
+ end
285
+ end
286
+ end
287
+
288
+ def show
289
+ fmt = "%-20s %s\n"
290
+ OPTIONS.each do |name|
291
+ value = self[name]
292
+ reslv = __send__(name)
293
+ case reslv
294
+ when String
295
+ reslv = "(none)" if reslv.empty?
296
+ when false, nil
297
+ reslv = "no"
298
+ when true
299
+ reslv = "yes"
300
+ end
301
+ printf fmt, name, reslv
302
+ end
303
+ end
304
+
305
+ #
306
+
307
+ def extconfs
308
+ @extconfs ||= Dir['ext/**/extconf.rb']
309
+ end
310
+
311
+ def extensions
312
+ @extensions ||= extconfs.collect{ |f| File.dirname(f) }
313
+ end
314
+
315
+ def compiles?
316
+ !extensions.empty?
317
+ end
318
+
319
+ private
320
+
321
+ # Get unresloved attribute.
322
+ def [](name)
323
+ instance_variable_get("@#{name}")
324
+ end
325
+
326
+ # Set attribute.
327
+ def []=(name, value)
328
+ instance_variable_set("@#{name}", value)
329
+ end
330
+
331
+ # Resolved attribute. (for paths)
332
+ #def resolve(name)
333
+ # self[name].gsub(%r<\\$([^/]+)>){ self[$1] }
334
+ #end
335
+
336
+ end
337
+
338
+ end
339
+