cairo 1.8.3-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of cairo might be problematic. Click here for more details.

Files changed (352) hide show
  1. data/AUTHORS +4 -0
  2. data/COPYING +59 -0
  3. data/GPL +340 -0
  4. data/NEWS +163 -0
  5. data/Rakefile +190 -0
  6. data/doc/doc.css +91 -0
  7. data/doc/en/cairo-antialias.html +38 -0
  8. data/doc/en/cairo-clip-not-representable-error.html +47 -0
  9. data/doc/en/cairo-color-base.html +69 -0
  10. data/doc/en/cairo-color-cmyk.html +157 -0
  11. data/doc/en/cairo-color-hsv.html +137 -0
  12. data/doc/en/cairo-color-rgb.html +142 -0
  13. data/doc/en/cairo-color-x11.html +173 -0
  14. data/doc/en/cairo-color.html +238 -0
  15. data/doc/en/cairo-content.html +37 -0
  16. data/doc/en/cairo-context-blur.html +39 -0
  17. data/doc/en/cairo-context-circle.html +39 -0
  18. data/doc/en/cairo-context-color.html +39 -0
  19. data/doc/en/cairo-context-path.html +44 -0
  20. data/doc/en/cairo-context-rectangle.html +39 -0
  21. data/doc/en/cairo-context-triangle.html +39 -0
  22. data/doc/en/cairo-context.html +643 -0
  23. data/doc/en/cairo-error.html +44 -0
  24. data/doc/en/cairo-extend.html +38 -0
  25. data/doc/en/cairo-file-not-found.html +47 -0
  26. data/doc/en/cairo-fill-rule.html +36 -0
  27. data/doc/en/cairo-filter.html +40 -0
  28. data/doc/en/cairo-font-extents.html +129 -0
  29. data/doc/en/cairo-font-face.html +38 -0
  30. data/doc/en/cairo-font-options.html +139 -0
  31. data/doc/en/cairo-font-slant.html +37 -0
  32. data/doc/en/cairo-font-type-mismatch.html +47 -0
  33. data/doc/en/cairo-font-weight.html +36 -0
  34. data/doc/en/cairo-format.html +46 -0
  35. data/doc/en/cairo-glyph.html +99 -0
  36. data/doc/en/cairo-gradient-pattern.html +74 -0
  37. data/doc/en/cairo-hint-metrics.html +37 -0
  38. data/doc/en/cairo-hint-style.html +39 -0
  39. data/doc/en/cairo-image-surface.html +82 -0
  40. data/doc/en/cairo-invalid-clusters.html +47 -0
  41. data/doc/en/cairo-invalid-content-error.html +47 -0
  42. data/doc/en/cairo-invalid-dash-error.html +47 -0
  43. data/doc/en/cairo-invalid-dsc-comment-error.html +47 -0
  44. data/doc/en/cairo-invalid-format-error.html +47 -0
  45. data/doc/en/cairo-invalid-index-error.html +47 -0
  46. data/doc/en/cairo-invalid-matrix-error.html +47 -0
  47. data/doc/en/cairo-invalid-path-data-error.html +47 -0
  48. data/doc/en/cairo-invalid-pop-group-error.html +47 -0
  49. data/doc/en/cairo-invalid-restore-error.html +47 -0
  50. data/doc/en/cairo-invalid-slant.html +47 -0
  51. data/doc/en/cairo-invalid-status-error.html +47 -0
  52. data/doc/en/cairo-invalid-stride-error.html +47 -0
  53. data/doc/en/cairo-invalid-string-error.html +47 -0
  54. data/doc/en/cairo-invalid-visual-error.html +47 -0
  55. data/doc/en/cairo-invalid-weight.html +47 -0
  56. data/doc/en/cairo-line-cap.html +37 -0
  57. data/doc/en/cairo-line-join.html +37 -0
  58. data/doc/en/cairo-linear-pattern.html +60 -0
  59. data/doc/en/cairo-matrix.html +259 -0
  60. data/doc/en/cairo-negative-count.html +47 -0
  61. data/doc/en/cairo-no-current-point-error.html +47 -0
  62. data/doc/en/cairo-null-pointer-error.html +47 -0
  63. data/doc/en/cairo-operator.html +48 -0
  64. data/doc/en/cairo-paper-parse-error.html +47 -0
  65. data/doc/en/cairo-paper-unknown-paper-name.html +66 -0
  66. data/doc/en/cairo-paper-unknown-unit.html +66 -0
  67. data/doc/en/cairo-paper-unrecognized-paper-description.html +66 -0
  68. data/doc/en/cairo-paper.html +184 -0
  69. data/doc/en/cairo-path-close-path.html +49 -0
  70. data/doc/en/cairo-path-curve-to.html +49 -0
  71. data/doc/en/cairo-path-data-type.html +38 -0
  72. data/doc/en/cairo-path-data.html +98 -0
  73. data/doc/en/cairo-path-line-to.html +49 -0
  74. data/doc/en/cairo-path-move-to.html +49 -0
  75. data/doc/en/cairo-path.html +155 -0
  76. data/doc/en/cairo-pattern-type-mismatch-error.html +47 -0
  77. data/doc/en/cairo-pattern.html +99 -0
  78. data/doc/en/cairo-pdf-surface.html +57 -0
  79. data/doc/en/cairo-point.html +74 -0
  80. data/doc/en/cairo-ps-level.html +49 -0
  81. data/doc/en/cairo-ps-surface.html +92 -0
  82. data/doc/en/cairo-quartz-image-surface.html +57 -0
  83. data/doc/en/cairo-quartz-surface.html +57 -0
  84. data/doc/en/cairo-radial-pattern.html +60 -0
  85. data/doc/en/cairo-read-error.html +47 -0
  86. data/doc/en/cairo-rectangle.html +89 -0
  87. data/doc/en/cairo-scaled-font.html +94 -0
  88. data/doc/en/cairo-solid-pattern.html +62 -0
  89. data/doc/en/cairo-subpixel-order.html +39 -0
  90. data/doc/en/cairo-surface-finished-error.html +47 -0
  91. data/doc/en/cairo-surface-pattern.html +57 -0
  92. data/doc/en/cairo-surface-type-mismatch-error.html +47 -0
  93. data/doc/en/cairo-surface.html +121 -0
  94. data/doc/en/cairo-svg-surface.html +77 -0
  95. data/doc/en/cairo-svg-version.html +49 -0
  96. data/doc/en/cairo-temp-file-error.html +47 -0
  97. data/doc/en/cairo-text-cluster-flag.html +35 -0
  98. data/doc/en/cairo-text-cluster.html +84 -0
  99. data/doc/en/cairo-text-extents.html +144 -0
  100. data/doc/en/cairo-toy-font-face.html +67 -0
  101. data/doc/en/cairo-user-font-error.html +47 -0
  102. data/doc/en/cairo-user-font-face-text-to-glyphs-data.html +94 -0
  103. data/doc/en/cairo-user-font-face.html +72 -0
  104. data/doc/en/cairo-user-font-immutable.html +47 -0
  105. data/doc/en/cairo-win32-printing-surface.html +57 -0
  106. data/doc/en/cairo-win32-surface.html +62 -0
  107. data/doc/en/cairo-write-error.html +47 -0
  108. data/doc/en/cairo.html +131 -0
  109. data/doc/en/index.html +1154 -0
  110. data/doc/index.html +18 -0
  111. data/doc/ja/cairo-antialias.html +57 -0
  112. data/doc/ja/cairo-clip-not-representable-error.html +56 -0
  113. data/doc/ja/cairo-color-base.html +75 -0
  114. data/doc/ja/cairo-color-cmyk.html +152 -0
  115. data/doc/ja/cairo-color-hsv.html +135 -0
  116. data/doc/ja/cairo-color-rgb.html +145 -0
  117. data/doc/ja/cairo-color-x11.html +183 -0
  118. data/doc/ja/cairo-color.html +317 -0
  119. data/doc/ja/cairo-content.html +51 -0
  120. data/doc/ja/cairo-context-blur.html +53 -0
  121. data/doc/ja/cairo-context-circle.html +54 -0
  122. data/doc/ja/cairo-context-color.html +52 -0
  123. data/doc/ja/cairo-context-path.html +77 -0
  124. data/doc/ja/cairo-context-rectangle.html +60 -0
  125. data/doc/ja/cairo-context-triangle.html +47 -0
  126. data/doc/ja/cairo-context.html +1542 -0
  127. data/doc/ja/cairo-error.html +56 -0
  128. data/doc/ja/cairo-extend.html +56 -0
  129. data/doc/ja/cairo-file-not-found.html +51 -0
  130. data/doc/ja/cairo-fill-rule.html +58 -0
  131. data/doc/ja/cairo-filter.html +43 -0
  132. data/doc/ja/cairo-font-extents.html +164 -0
  133. data/doc/ja/cairo-font-face.html +55 -0
  134. data/doc/ja/cairo-font-options.html +189 -0
  135. data/doc/ja/cairo-font-slant.html +50 -0
  136. data/doc/ja/cairo-font-type-mismatch.html +52 -0
  137. data/doc/ja/cairo-font-weight.html +47 -0
  138. data/doc/ja/cairo-format.html +81 -0
  139. data/doc/ja/cairo-glyph.html +115 -0
  140. data/doc/ja/cairo-gradient-pattern.html +119 -0
  141. data/doc/ja/cairo-hint-metrics.html +57 -0
  142. data/doc/ja/cairo-hint-style.html +64 -0
  143. data/doc/ja/cairo-image-surface.html +131 -0
  144. data/doc/ja/cairo-invalid-clusters.html +55 -0
  145. data/doc/ja/cairo-invalid-content-error.html +54 -0
  146. data/doc/ja/cairo-invalid-dash-error.html +54 -0
  147. data/doc/ja/cairo-invalid-dsc-comment-error.html +54 -0
  148. data/doc/ja/cairo-invalid-format-error.html +54 -0
  149. data/doc/ja/cairo-invalid-index-error.html +54 -0
  150. data/doc/ja/cairo-invalid-matrix-error.html +54 -0
  151. data/doc/ja/cairo-invalid-path-data-error.html +54 -0
  152. data/doc/ja/cairo-invalid-pop-group-error.html +54 -0
  153. data/doc/ja/cairo-invalid-restore-error.html +55 -0
  154. data/doc/ja/cairo-invalid-slant.html +57 -0
  155. data/doc/ja/cairo-invalid-status-error.html +55 -0
  156. data/doc/ja/cairo-invalid-stride-error.html +55 -0
  157. data/doc/ja/cairo-invalid-string-error.html +54 -0
  158. data/doc/ja/cairo-invalid-visual-error.html +57 -0
  159. data/doc/ja/cairo-invalid-weight.html +57 -0
  160. data/doc/ja/cairo-line-cap.html +50 -0
  161. data/doc/ja/cairo-line-join.html +53 -0
  162. data/doc/ja/cairo-linear-pattern.html +87 -0
  163. data/doc/ja/cairo-matrix.html +354 -0
  164. data/doc/ja/cairo-negative-count.html +52 -0
  165. data/doc/ja/cairo-no-current-point-error.html +54 -0
  166. data/doc/ja/cairo-null-pointer-error.html +54 -0
  167. data/doc/ja/cairo-operator.html +51 -0
  168. data/doc/ja/cairo-paper-parse-error.html +55 -0
  169. data/doc/ja/cairo-paper-unknown-paper-name.html +76 -0
  170. data/doc/ja/cairo-paper-unknown-unit.html +75 -0
  171. data/doc/ja/cairo-paper-unrecognized-paper-description.html +76 -0
  172. data/doc/ja/cairo-paper.html +357 -0
  173. data/doc/ja/cairo-path-close-path.html +57 -0
  174. data/doc/ja/cairo-path-curve-to.html +70 -0
  175. data/doc/ja/cairo-path-data-type.html +53 -0
  176. data/doc/ja/cairo-path-data.html +127 -0
  177. data/doc/ja/cairo-path-line-to.html +62 -0
  178. data/doc/ja/cairo-path-move-to.html +62 -0
  179. data/doc/ja/cairo-path.html +144 -0
  180. data/doc/ja/cairo-pattern-type-mismatch-error.html +56 -0
  181. data/doc/ja/cairo-pattern.html +128 -0
  182. data/doc/ja/cairo-pdf-surface.html +86 -0
  183. data/doc/ja/cairo-point.html +90 -0
  184. data/doc/ja/cairo-ps-level.html +62 -0
  185. data/doc/ja/cairo-ps-surface.html +214 -0
  186. data/doc/ja/cairo-quartz-image-surface.html +75 -0
  187. data/doc/ja/cairo-quartz-surface.html +93 -0
  188. data/doc/ja/cairo-radial-pattern.html +93 -0
  189. data/doc/ja/cairo-read-error.html +55 -0
  190. data/doc/ja/cairo-rectangle.html +109 -0
  191. data/doc/ja/cairo-scaled-font.html +180 -0
  192. data/doc/ja/cairo-solid-pattern.html +87 -0
  193. data/doc/ja/cairo-subpixel-order.html +57 -0
  194. data/doc/ja/cairo-surface-finished-error.html +54 -0
  195. data/doc/ja/cairo-surface-pattern.html +68 -0
  196. data/doc/ja/cairo-surface-type-mismatch-error.html +56 -0
  197. data/doc/ja/cairo-surface.html +213 -0
  198. data/doc/ja/cairo-svg-surface.html +114 -0
  199. data/doc/ja/cairo-svg-version.html +66 -0
  200. data/doc/ja/cairo-temp-file-error.html +50 -0
  201. data/doc/ja/cairo-text-cluster-flag.html +46 -0
  202. data/doc/ja/cairo-text-cluster.html +102 -0
  203. data/doc/ja/cairo-text-extents.html +163 -0
  204. data/doc/ja/cairo-toy-font-face.html +107 -0
  205. data/doc/ja/cairo-user-font-error.html +55 -0
  206. data/doc/ja/cairo-user-font-face-text-to-glyphs-data.html +156 -0
  207. data/doc/ja/cairo-user-font-face.html +268 -0
  208. data/doc/ja/cairo-user-font-immutable.html +54 -0
  209. data/doc/ja/cairo-win32-printing-surface.html +80 -0
  210. data/doc/ja/cairo-win32-surface.html +100 -0
  211. data/doc/ja/cairo-write-error.html +55 -0
  212. data/doc/ja/cairo.html +177 -0
  213. data/doc/ja/index.html +1156 -0
  214. data/ext/cairo/cairo.def +104 -0
  215. data/ext/cairo/extconf.rb +80 -0
  216. data/ext/cairo/rb_cairo.c +104 -0
  217. data/ext/cairo/rb_cairo.h +275 -0
  218. data/ext/cairo/rb_cairo_constants.c +478 -0
  219. data/ext/cairo/rb_cairo_context.c +1693 -0
  220. data/ext/cairo/rb_cairo_exception.c +354 -0
  221. data/ext/cairo/rb_cairo_font_extents.c +200 -0
  222. data/ext/cairo/rb_cairo_font_face.c +713 -0
  223. data/ext/cairo/rb_cairo_font_options.c +197 -0
  224. data/ext/cairo/rb_cairo_glyph.c +161 -0
  225. data/ext/cairo/rb_cairo_matrix.c +366 -0
  226. data/ext/cairo/rb_cairo_path.c +459 -0
  227. data/ext/cairo/rb_cairo_pattern.c +540 -0
  228. data/ext/cairo/rb_cairo_private.c +242 -0
  229. data/ext/cairo/rb_cairo_private.h +114 -0
  230. data/ext/cairo/rb_cairo_scaled_font.c +235 -0
  231. data/ext/cairo/rb_cairo_surface.c +1371 -0
  232. data/ext/cairo/rb_cairo_text_cluster.c +151 -0
  233. data/ext/cairo/rb_cairo_text_extents.c +221 -0
  234. data/extconf.rb +45 -0
  235. data/lib/1.8/cairo.so +0 -0
  236. data/lib/1.9/cairo.so +0 -0
  237. data/lib/cairo.rb +151 -0
  238. data/lib/cairo/color.rb +267 -0
  239. data/lib/cairo/colors.rb +656 -0
  240. data/lib/cairo/constants.rb +24 -0
  241. data/lib/cairo/context.rb +29 -0
  242. data/lib/cairo/context/blur.rb +45 -0
  243. data/lib/cairo/context/circle.rb +9 -0
  244. data/lib/cairo/context/color.rb +11 -0
  245. data/lib/cairo/context/path.rb +116 -0
  246. data/lib/cairo/context/rectangle.rb +33 -0
  247. data/lib/cairo/context/triangle.rb +12 -0
  248. data/lib/cairo/paper.rb +183 -0
  249. data/lib/cairo/papers.rb +41 -0
  250. data/lib/cairo/path.rb +15 -0
  251. data/lib/cairo/point.rb +7 -0
  252. data/misc/update-colors.rb +143 -0
  253. data/pkg-config.rb +313 -0
  254. data/samples/agg/README +4 -0
  255. data/samples/agg/aa_test.rb +304 -0
  256. data/samples/blur.rb +47 -0
  257. data/samples/pac.rb +99 -0
  258. data/samples/pac2.rb +171 -0
  259. data/samples/png.rb +45 -0
  260. data/samples/scalable.rb +56 -0
  261. data/samples/text-on-path.rb +60 -0
  262. data/samples/text2.rb +131 -0
  263. data/test-unit/Rakefile +30 -0
  264. data/test-unit/bin/testrb +5 -0
  265. data/test-unit/lib/test/unit.rb +280 -0
  266. data/test-unit/lib/test/unit/assertionfailederror.rb +14 -0
  267. data/test-unit/lib/test/unit/assertions.rb +722 -0
  268. data/test-unit/lib/test/unit/attribute.rb +125 -0
  269. data/test-unit/lib/test/unit/autorunner.rb +254 -0
  270. data/test-unit/lib/test/unit/collector.rb +43 -0
  271. data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
  272. data/test-unit/lib/test/unit/collector/dir.rb +108 -0
  273. data/test-unit/lib/test/unit/collector/load.rb +135 -0
  274. data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
  275. data/test-unit/lib/test/unit/color.rb +61 -0
  276. data/test-unit/lib/test/unit/diff.rb +524 -0
  277. data/test-unit/lib/test/unit/error.rb +124 -0
  278. data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
  279. data/test-unit/lib/test/unit/failure.rb +110 -0
  280. data/test-unit/lib/test/unit/fixture.rb +185 -0
  281. data/test-unit/lib/test/unit/notification.rb +125 -0
  282. data/test-unit/lib/test/unit/omission.rb +143 -0
  283. data/test-unit/lib/test/unit/pending.rb +146 -0
  284. data/test-unit/lib/test/unit/priority.rb +146 -0
  285. data/test-unit/lib/test/unit/runner/console.rb +46 -0
  286. data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
  287. data/test-unit/lib/test/unit/testcase.rb +281 -0
  288. data/test-unit/lib/test/unit/testresult.rb +89 -0
  289. data/test-unit/lib/test/unit/testsuite.rb +110 -0
  290. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
  291. data/test-unit/lib/test/unit/ui/console/testrunner.rb +195 -0
  292. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  293. data/test-unit/lib/test/unit/ui/testrunner.rb +20 -0
  294. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
  295. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  296. data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
  297. data/test-unit/lib/test/unit/util/observable.rb +90 -0
  298. data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
  299. data/test-unit/lib/test/unit/version.rb +7 -0
  300. data/test-unit/sample/adder.rb +13 -0
  301. data/test-unit/sample/subtracter.rb +12 -0
  302. data/test-unit/sample/tc_adder.rb +18 -0
  303. data/test-unit/sample/tc_subtracter.rb +18 -0
  304. data/test-unit/sample/ts_examples.rb +7 -0
  305. data/test-unit/test/collector/test_descendant.rb +135 -0
  306. data/test-unit/test/collector/test_dir.rb +406 -0
  307. data/test-unit/test/collector/test_load.rb +333 -0
  308. data/test-unit/test/collector/test_objectspace.rb +98 -0
  309. data/test-unit/test/run-test.rb +13 -0
  310. data/test-unit/test/test_assertions.rb +693 -0
  311. data/test-unit/test/test_attribute.rb +86 -0
  312. data/test-unit/test/test_color.rb +37 -0
  313. data/test-unit/test/test_diff.rb +477 -0
  314. data/test-unit/test/test_emacs_runner.rb +60 -0
  315. data/test-unit/test/test_error.rb +26 -0
  316. data/test-unit/test/test_failure.rb +33 -0
  317. data/test-unit/test/test_fixture.rb +252 -0
  318. data/test-unit/test/test_notification.rb +33 -0
  319. data/test-unit/test/test_omission.rb +81 -0
  320. data/test-unit/test/test_pending.rb +70 -0
  321. data/test-unit/test/test_priority.rb +89 -0
  322. data/test-unit/test/test_testcase.rb +430 -0
  323. data/test-unit/test/test_testresult.rb +113 -0
  324. data/test-unit/test/test_testsuite.rb +129 -0
  325. data/test-unit/test/testunit_test_util.rb +14 -0
  326. data/test-unit/test/ui/test_testrunmediator.rb +20 -0
  327. data/test-unit/test/util/test_backtracefilter.rb +41 -0
  328. data/test-unit/test/util/test_observable.rb +102 -0
  329. data/test-unit/test/util/test_procwrapper.rb +36 -0
  330. data/test/cairo-test-utils.rb +18 -0
  331. data/test/run-test.rb +28 -0
  332. data/test/test_color.rb +17 -0
  333. data/test/test_constants.rb +16 -0
  334. data/test/test_context.rb +105 -0
  335. data/test/test_exception.rb +27 -0
  336. data/test/test_font_extents.rb +36 -0
  337. data/test/test_font_face.rb +244 -0
  338. data/test/test_font_options.rb +13 -0
  339. data/test/test_paper.rb +81 -0
  340. data/test/test_pkg_config.rb +123 -0
  341. data/test/test_scaled_font.rb +34 -0
  342. data/test/test_surface.rb +41 -0
  343. data/test/test_text_cluster.rb +32 -0
  344. data/test/test_text_extents.rb +40 -0
  345. data/test/test_text_to_glyphs_data.rb +51 -0
  346. data/tmp/x86-mingw32/cairo/1.8.7/fake.rb +6 -0
  347. data/tmp/x86-mingw32/cairo/1.8.7/mkmf.rb +1836 -0
  348. data/tmp/x86-mingw32/cairo/1.8.7/rbconfig.rb +183 -0
  349. data/tmp/x86-mingw32/cairo/1.9.2/fake.rb +6 -0
  350. data/tmp/x86-mingw32/cairo/1.9.2/mkmf.rb +2079 -0
  351. data/tmp/x86-mingw32/cairo/1.9.2/rbconfig.rb +226 -0
  352. metadata +437 -0
@@ -0,0 +1,183 @@
1
+
2
+ # This file was created by mkconfig.rb when ruby was built. Any
3
+ # changes made to this file will be lost the next time ruby is built.
4
+
5
+ module Config
6
+ RUBY_VERSION == "1.8.7" or
7
+ raise "ruby lib version (1.8.7) doesn't match executable version (#{RUBY_VERSION})"
8
+
9
+ TOPDIR = File.dirname(__FILE__).chomp!("/lib/ruby/1.8/i386-mingw32")
10
+ DESTDIR = '' unless defined? DESTDIR
11
+ CONFIG = {}
12
+ CONFIG["DESTDIR"] = DESTDIR
13
+ CONFIG["INSTALL"] = '/usr/bin/install -c'
14
+ CONFIG["EXEEXT"] = ".exe"
15
+ CONFIG["prefix"] = (TOPDIR || DESTDIR + "/home/kou/.rake-compiler/ruby/ruby-1.8.7-p302")
16
+ CONFIG["ruby_install_name"] = "ruby"
17
+ CONFIG["RUBY_INSTALL_NAME"] = "ruby"
18
+ CONFIG["RUBY_SO_NAME"] = "msvcrt-ruby18"
19
+ CONFIG["MANTYPE"] = "doc"
20
+ CONFIG["NROFF"] = "/usr/bin/nroff"
21
+ CONFIG["configure_args"] = " '--target=i386-mingw32' '--host=i586-mingw32msvc' '--build=i686-linux' '--enable-shared' '--disable-install-doc' '--without-tk' '--without-tcl' '--prefix=/home/kou/.rake-compiler/ruby/ruby-1.8.7-p302' 'build_alias=i686-linux' 'host_alias=i586-mingw32msvc' 'target_alias=i386-mingw32'"
22
+ CONFIG["vendordir"] = "$(libdir)/ruby/vendor_ruby"
23
+ CONFIG["sitedir"] = "$(libdir)/ruby/site_ruby"
24
+ CONFIG["sitearch"] = "i386-msvcrt"
25
+ CONFIG["arch"] = "i386-mingw32"
26
+ CONFIG["MAKEFILES"] = "Makefile GNUmakefile"
27
+ CONFIG["EXPORT_PREFIX"] = ""
28
+ CONFIG["COMMON_HEADERS"] = "windows.h winsock.h"
29
+ CONFIG["COMMON_MACROS"] = ""
30
+ CONFIG["COMMON_LIBS"] = "m"
31
+ CONFIG["MAINLIBS"] = ""
32
+ CONFIG["ENABLE_SHARED"] = "yes"
33
+ CONFIG["DLDLIBS"] = ""
34
+ CONFIG["SOLIBS"] = "$(LIBS)"
35
+ CONFIG["LIBRUBYARG_SHARED"] = "-l$(RUBY_SO_NAME)"
36
+ CONFIG["LIBRUBYARG_STATIC"] = "-l$(RUBY_SO_NAME)-static"
37
+ CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_SHARED)"
38
+ CONFIG["LIBRUBY"] = "lib$(LIBRUBY_SO).a"
39
+ CONFIG["LIBRUBY_ALIASES"] = ""
40
+ CONFIG["LIBRUBY_SO"] = "$(RUBY_SO_NAME).dll"
41
+ CONFIG["LIBRUBY_A"] = "lib$(RUBY_SO_NAME)-static.a"
42
+ CONFIG["RUBYW_INSTALL_NAME"] = "rubyw"
43
+ CONFIG["rubyw_install_name"] = "rubyw"
44
+ CONFIG["LIBRUBY_DLDFLAGS"] = " -Wl,--enable-auto-image-base,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBRUBY)"
45
+ CONFIG["LIBRUBY_LDSHARED"] = "i586-mingw32msvc-gcc -shared -s"
46
+ CONFIG["debugflags"] = ""
47
+ CONFIG["optflags"] = ""
48
+ CONFIG["cflags"] = "$(optflags) $(debugflags)"
49
+ CONFIG["cppflags"] = ""
50
+ CONFIG["RDOCTARGET"] = ""
51
+ CONFIG["ARCHFILE"] = ""
52
+ CONFIG["EXTOUT"] = ".ext"
53
+ CONFIG["PREP"] = "fake.rb"
54
+ CONFIG["setup"] = "Setup"
55
+ CONFIG["EXTSTATIC"] = ""
56
+ CONFIG["STRIP"] = "strip"
57
+ CONFIG["TRY_LINK"] = ""
58
+ CONFIG["LIBPATHENV"] = ""
59
+ CONFIG["RPATHFLAG"] = ""
60
+ CONFIG["LIBPATHFLAG"] = " -L%s"
61
+ CONFIG["LINK_SO"] = ""
62
+ CONFIG["LIBEXT"] = "a"
63
+ CONFIG["DLEXT2"] = "dll"
64
+ CONFIG["DLEXT"] = "so"
65
+ CONFIG["LDSHARED"] = "i586-mingw32msvc-gcc -shared -s"
66
+ CONFIG["CCDLFLAGS"] = ""
67
+ CONFIG["STATIC"] = ""
68
+ CONFIG["ARCH_FLAG"] = ""
69
+ CONFIG["DLDFLAGS"] = " -Wl,--enable-auto-image-base,--enable-auto-import,--export-all"
70
+ CONFIG["ALLOCA"] = ""
71
+ CONFIG["MAKEDIRS"] = "mkdir -p"
72
+ CONFIG["CP"] = "cp"
73
+ CONFIG["RM"] = "rm -f"
74
+ CONFIG["INSTALL_DATA"] = "$(INSTALL) -m 644"
75
+ CONFIG["INSTALL_SCRIPT"] = "$(INSTALL)"
76
+ CONFIG["INSTALL_PROGRAM"] = "$(INSTALL)"
77
+ CONFIG["SET_MAKE"] = ""
78
+ CONFIG["LN_S"] = "ln -s"
79
+ CONFIG["OBJDUMP"] = "i586-mingw32msvc-objdump"
80
+ CONFIG["DLLWRAP"] = "i586-mingw32msvc-dllwrap"
81
+ CONFIG["WINDRES"] = "i586-mingw32msvc-windres"
82
+ CONFIG["NM"] = "i586-mingw32msvc-nm"
83
+ CONFIG["ASFLAGS"] = ""
84
+ CONFIG["AS"] = "i586-mingw32msvc-as"
85
+ CONFIG["AR"] = "i586-mingw32msvc-ar"
86
+ CONFIG["RANLIB"] = "i586-mingw32msvc-ranlib"
87
+ CONFIG["YFLAGS"] = ""
88
+ CONFIG["YACC"] = "bison -y"
89
+ CONFIG["OUTFLAG"] = "-o "
90
+ CONFIG["CPPOUTFILE"] = "-o conftest.i"
91
+ CONFIG["GNU_LD"] = "yes"
92
+ CONFIG["EGREP"] = "/bin/grep -E"
93
+ CONFIG["GREP"] = "/bin/grep"
94
+ CONFIG["CPP"] = "i586-mingw32msvc-gcc -E"
95
+ CONFIG["OBJEXT"] = "o"
96
+ CONFIG["CPPFLAGS"] = " $(DEFS) $(cppflags)"
97
+ CONFIG["LDFLAGS"] = "-L. "
98
+ CONFIG["CFLAGS"] = "-g -O2 $(cflags)"
99
+ CONFIG["CC"] = "i586-mingw32msvc-gcc"
100
+ CONFIG["target_os"] = "mingw32"
101
+ CONFIG["target_vendor"] = "pc"
102
+ CONFIG["target_cpu"] = "i386"
103
+ CONFIG["target"] = "i386-pc-mingw32"
104
+ CONFIG["host_os"] = "mingw32msvc"
105
+ CONFIG["host_vendor"] = "pc"
106
+ CONFIG["host_cpu"] = "i586"
107
+ CONFIG["host"] = "i586-pc-mingw32msvc"
108
+ CONFIG["build_os"] = "linux"
109
+ CONFIG["build_vendor"] = "pc"
110
+ CONFIG["build_cpu"] = "i686"
111
+ CONFIG["build"] = "i686-pc-linux"
112
+ CONFIG["TEENY"] = "7"
113
+ CONFIG["MINOR"] = "8"
114
+ CONFIG["MAJOR"] = "1"
115
+ CONFIG["target_alias"] = "i386-mingw32"
116
+ CONFIG["host_alias"] = "i586-mingw32msvc"
117
+ CONFIG["build_alias"] = "i686-linux"
118
+ CONFIG["LIBS"] = "-lshell32 -lwsock32 "
119
+ CONFIG["ECHO_T"] = ""
120
+ CONFIG["ECHO_N"] = "-n"
121
+ CONFIG["ECHO_C"] = ""
122
+ CONFIG["DEFS"] = ""
123
+ CONFIG["mandir"] = "$(datarootdir)/man"
124
+ CONFIG["localedir"] = "$(datarootdir)/locale"
125
+ CONFIG["libdir"] = "$(exec_prefix)/lib"
126
+ CONFIG["psdir"] = "$(docdir)"
127
+ CONFIG["pdfdir"] = "$(docdir)"
128
+ CONFIG["dvidir"] = "$(docdir)"
129
+ CONFIG["htmldir"] = "$(docdir)"
130
+ CONFIG["infodir"] = "$(datarootdir)/info"
131
+ CONFIG["docdir"] = "$(datarootdir)/doc/$(PACKAGE)"
132
+ CONFIG["oldincludedir"] = "/usr/include"
133
+ CONFIG["includedir"] = "$(prefix)/include"
134
+ CONFIG["localstatedir"] = "$(prefix)/var"
135
+ CONFIG["sharedstatedir"] = "$(prefix)/com"
136
+ CONFIG["sysconfdir"] = "$(prefix)/etc"
137
+ CONFIG["datadir"] = "$(datarootdir)"
138
+ CONFIG["datarootdir"] = "$(prefix)/share"
139
+ CONFIG["libexecdir"] = "$(exec_prefix)/libexec"
140
+ CONFIG["sbindir"] = "$(exec_prefix)/sbin"
141
+ CONFIG["bindir"] = "$(exec_prefix)/bin"
142
+ CONFIG["exec_prefix"] = "$(prefix)"
143
+ CONFIG["PACKAGE_URL"] = ""
144
+ CONFIG["PACKAGE_BUGREPORT"] = ""
145
+ CONFIG["PACKAGE_STRING"] = ""
146
+ CONFIG["PACKAGE_VERSION"] = ""
147
+ CONFIG["PACKAGE_TARNAME"] = ""
148
+ CONFIG["PACKAGE_NAME"] = ""
149
+ CONFIG["PATH_SEPARATOR"] = ":"
150
+ CONFIG["SHELL"] = "/bin/bash"
151
+ CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
152
+ CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
153
+ CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
154
+ CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
155
+ CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
156
+ CONFIG["vendorlibdir"] = "$(vendordir)/$(ruby_version)"
157
+ CONFIG["vendorarchdir"] = "$(vendorlibdir)/$(sitearch)"
158
+ CONFIG["topdir"] = File.dirname(__FILE__)
159
+ MAKEFILE_CONFIG = {}
160
+ CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
161
+ def Config::expand(val, config = CONFIG)
162
+ val.gsub!(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) do |var|
163
+ if !(v = $1 || $2)
164
+ '$'
165
+ elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]]
166
+ pat, sub = $1, $2
167
+ config[v] = false
168
+ Config::expand(key, config)
169
+ config[v] = key
170
+ key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat
171
+ key
172
+ else
173
+ var
174
+ end
175
+ end
176
+ val
177
+ end
178
+ CONFIG.each_value do |val|
179
+ Config::expand(val)
180
+ end
181
+ end
182
+ RbConfig = Config # compatibility for ruby-1.9
183
+ CROSS_COMPILING = nil unless defined? CROSS_COMPILING
@@ -0,0 +1,6 @@
1
+ class Object
2
+ remove_const :RUBY_PLATFORM
3
+ remove_const :RUBY_VERSION
4
+ RUBY_PLATFORM = "i386-mingw32"
5
+ RUBY_VERSION = "1.9.2"
6
+ end
@@ -0,0 +1,2079 @@
1
+ # -*- indent-tabs-mode: t -*-
2
+ # module to create Makefile for extension modules
3
+ # invoke like: ruby -r mkmf extconf.rb
4
+
5
+ require 'rbconfig'
6
+ require 'fileutils'
7
+ require 'shellwords'
8
+
9
+ CONFIG = RbConfig::MAKEFILE_CONFIG
10
+ ORIG_LIBPATH = ENV['LIB']
11
+
12
+ CXX_EXT = %w[cc cxx cpp]
13
+ if File::FNM_SYSCASE.zero?
14
+ CXX_EXT.concat(%w[C])
15
+ end
16
+ SRC_EXT = %w[c m].concat(CXX_EXT)
17
+ $static = nil
18
+ $config_h = '$(arch_hdrdir)/ruby/config.h'
19
+ $default_static = $static
20
+
21
+ unless defined? $configure_args
22
+ $configure_args = {}
23
+ args = CONFIG["configure_args"]
24
+ if ENV["CONFIGURE_ARGS"]
25
+ args << " " << ENV["CONFIGURE_ARGS"]
26
+ end
27
+ for arg in Shellwords::shellwords(args)
28
+ arg, val = arg.split('=', 2)
29
+ next unless arg
30
+ arg.tr!('_', '-')
31
+ if arg.sub!(/^(?!--)/, '--')
32
+ val or next
33
+ arg.downcase!
34
+ end
35
+ next if /^--(?:top|topsrc|src|cur)dir$/ =~ arg
36
+ $configure_args[arg] = val || true
37
+ end
38
+ for arg in ARGV
39
+ arg, val = arg.split('=', 2)
40
+ next unless arg
41
+ arg.tr!('_', '-')
42
+ if arg.sub!(/^(?!--)/, '--')
43
+ val or next
44
+ arg.downcase!
45
+ end
46
+ $configure_args[arg] = val || true
47
+ end
48
+ end
49
+
50
+ $libdir = CONFIG["libdir"]
51
+ $rubylibdir = CONFIG["rubylibdir"]
52
+ $archdir = CONFIG["archdir"]
53
+ $sitedir = CONFIG["sitedir"]
54
+ $sitelibdir = CONFIG["sitelibdir"]
55
+ $sitearchdir = CONFIG["sitearchdir"]
56
+ $vendordir = CONFIG["vendordir"]
57
+ $vendorlibdir = CONFIG["vendorlibdir"]
58
+ $vendorarchdir = CONFIG["vendorarchdir"]
59
+
60
+ $mswin = /mswin/ =~ RUBY_PLATFORM
61
+ $bccwin = /bccwin/ =~ RUBY_PLATFORM
62
+ $mingw = /mingw/ =~ RUBY_PLATFORM
63
+ $cygwin = /cygwin/ =~ RUBY_PLATFORM
64
+ $netbsd = /netbsd/ =~ RUBY_PLATFORM
65
+ $os2 = /os2/ =~ RUBY_PLATFORM
66
+ $beos = /beos/ =~ RUBY_PLATFORM
67
+ $haiku = /haiku/ =~ RUBY_PLATFORM
68
+ $solaris = /solaris/ =~ RUBY_PLATFORM
69
+ $universal = /universal/ =~ RUBY_PLATFORM
70
+ $dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/)
71
+
72
+ # :stopdoc:
73
+
74
+ def config_string(key, config = CONFIG)
75
+ s = config[key] and !s.empty? and block_given? ? yield(s) : s
76
+ end
77
+
78
+ def dir_re(dir)
79
+ Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
80
+ end
81
+
82
+ def relative_from(path, base)
83
+ dir = File.join(path, "")
84
+ if File.expand_path(dir) == File.expand_path(dir, base)
85
+ path
86
+ else
87
+ File.join(base, path)
88
+ end
89
+ end
90
+
91
+ INSTALL_DIRS = [
92
+ [dir_re('commondir'), "$(RUBYCOMMONDIR)"],
93
+ [dir_re('sitedir'), "$(RUBYCOMMONDIR)"],
94
+ [dir_re('vendordir'), "$(RUBYCOMMONDIR)"],
95
+ [dir_re('rubylibdir'), "$(RUBYLIBDIR)"],
96
+ [dir_re('archdir'), "$(RUBYARCHDIR)"],
97
+ [dir_re('sitelibdir'), "$(RUBYLIBDIR)"],
98
+ [dir_re('vendorlibdir'), "$(RUBYLIBDIR)"],
99
+ [dir_re('sitearchdir'), "$(RUBYARCHDIR)"],
100
+ [dir_re('vendorarchdir'), "$(RUBYARCHDIR)"],
101
+ [dir_re('rubyhdrdir'), "$(RUBYHDRDIR)"],
102
+ [dir_re('sitehdrdir'), "$(SITEHDRDIR)"],
103
+ [dir_re('vendorhdrdir'), "$(VENDORHDRDIR)"],
104
+ [dir_re('bindir'), "$(BINDIR)"],
105
+ ]
106
+
107
+ def install_dirs(target_prefix = nil)
108
+ if $extout
109
+ dirs = [
110
+ ['BINDIR', '$(extout)/bin'],
111
+ ['RUBYCOMMONDIR', '$(extout)/common'],
112
+ ['RUBYLIBDIR', '$(RUBYCOMMONDIR)$(target_prefix)'],
113
+ ['RUBYARCHDIR', '$(extout)/$(arch)$(target_prefix)'],
114
+ ['HDRDIR', '$(extout)/include/ruby$(target_prefix)'],
115
+ ['ARCHHDRDIR', '$(extout)/include/$(arch)/ruby$(target_prefix)'],
116
+ ['extout', "#$extout"],
117
+ ['extout_prefix', "#$extout_prefix"],
118
+ ]
119
+ elsif $extmk
120
+ dirs = [
121
+ ['BINDIR', '$(bindir)'],
122
+ ['RUBYCOMMONDIR', '$(rubylibdir)'],
123
+ ['RUBYLIBDIR', '$(rubylibdir)$(target_prefix)'],
124
+ ['RUBYARCHDIR', '$(archdir)$(target_prefix)'],
125
+ ['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'],
126
+ ['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'],
127
+ ]
128
+ elsif $configure_args.has_key?('--vendor')
129
+ dirs = [
130
+ ['BINDIR', '$(bindir)'],
131
+ ['RUBYCOMMONDIR', '$(vendordir)$(target_prefix)'],
132
+ ['RUBYLIBDIR', '$(vendorlibdir)$(target_prefix)'],
133
+ ['RUBYARCHDIR', '$(vendorarchdir)$(target_prefix)'],
134
+ ['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'],
135
+ ['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'],
136
+ ]
137
+ else
138
+ dirs = [
139
+ ['BINDIR', '$(bindir)'],
140
+ ['RUBYCOMMONDIR', '$(sitedir)$(target_prefix)'],
141
+ ['RUBYLIBDIR', '$(sitelibdir)$(target_prefix)'],
142
+ ['RUBYARCHDIR', '$(sitearchdir)$(target_prefix)'],
143
+ ['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'],
144
+ ['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'],
145
+ ]
146
+ end
147
+ dirs << ['target_prefix', (target_prefix ? "/#{target_prefix}" : "")]
148
+ dirs
149
+ end
150
+
151
+ def map_dir(dir, map = nil)
152
+ map ||= INSTALL_DIRS
153
+ map.inject(dir) {|d, (orig, new)| d.gsub(orig, new)}
154
+ end
155
+
156
+ topdir = File.dirname(libdir = File.dirname(__FILE__))
157
+ extdir = File.expand_path("ext", topdir)
158
+ path = File.expand_path($0)
159
+ $extmk = path[0, topdir.size+1] == topdir+"/"
160
+ $extmk &&= %r"\A(?:ext|enc|tool|test(?:/.+))\z" =~ File.dirname(path[topdir.size+1..-1])
161
+ $extmk &&= true
162
+ if not $extmk and File.exist?(($hdrdir = RbConfig::CONFIG["rubyhdrdir"]) + "/ruby/ruby.h")
163
+ $topdir = $hdrdir
164
+ $top_srcdir = $hdrdir
165
+ $arch_hdrdir = $hdrdir + "/$(arch)"
166
+ elsif File.exist?(($hdrdir = ($top_srcdir ||= topdir) + "/include") + "/ruby.h")
167
+ $topdir ||= RbConfig::CONFIG["topdir"]
168
+ $arch_hdrdir = "$(extout)/include/$(arch)"
169
+ else
170
+ abort "mkmf.rb can't find header files for ruby at #{$hdrdir}/ruby.h"
171
+ end
172
+
173
+ OUTFLAG = CONFIG['OUTFLAG']
174
+ COUTFLAG = CONFIG['COUTFLAG']
175
+ CPPOUTFILE = CONFIG['CPPOUTFILE']
176
+
177
+ CONFTEST_C = "conftest.c".freeze
178
+
179
+ class String
180
+ # Wraps a string in escaped quotes if it contains whitespace.
181
+ def quote
182
+ /\s/ =~ self ? "\"#{self}\"" : "#{self}"
183
+ end
184
+
185
+ # Generates a string used as cpp macro name.
186
+ def tr_cpp
187
+ strip.upcase.tr_s("^A-Z0-9_", "_")
188
+ end
189
+ end
190
+ class Array
191
+ # Wraps all strings in escaped quotes if they contain whitespace.
192
+ def quote
193
+ map {|s| s.quote}
194
+ end
195
+ end
196
+
197
+ def rm_f(*files)
198
+ opt = (Hash === files.last ? [files.pop] : [])
199
+ FileUtils.rm_f(Dir[*files.flatten], *opt)
200
+ end
201
+
202
+ def rm_rf(*files)
203
+ opt = (Hash === files.last ? [files.pop] : [])
204
+ FileUtils.rm_rf(Dir[*files.flatten], *opt)
205
+ end
206
+
207
+ # Returns time stamp of the +target+ file if it exists and is newer
208
+ # than or equal to all of +times+.
209
+ def modified?(target, times)
210
+ (t = File.mtime(target)) rescue return nil
211
+ Array === times or times = [times]
212
+ t if times.all? {|n| n <= t}
213
+ end
214
+
215
+ def merge_libs(*libs)
216
+ libs.inject([]) do |x, y|
217
+ xy = x & y
218
+ xn = yn = 0
219
+ y = y.inject([]) {|ary, e| ary.last == e ? ary : ary << e}
220
+ y.each_with_index do |v, yi|
221
+ if xy.include?(v)
222
+ xi = [x.index(v), xn].max()
223
+ x[xi, 1] = y[yn..yi]
224
+ xn, yn = xi + (yi - yn + 1), yi + 1
225
+ end
226
+ end
227
+ x.concat(y[yn..-1] || [])
228
+ end
229
+ end
230
+
231
+ # This is a custom logging module. It generates an mkmf.log file when you
232
+ # run your extconf.rb script. This can be useful for debugging unexpected
233
+ # failures.
234
+ #
235
+ # This module and its associated methods are meant for internal use only.
236
+ #
237
+ module Logging
238
+ @log = nil
239
+ @logfile = 'mkmf.log'
240
+ @orgerr = $stderr.dup
241
+ @orgout = $stdout.dup
242
+ @postpone = 0
243
+ @quiet = $extmk
244
+
245
+ def self::log_open
246
+ @log ||= File::open(@logfile, 'wb')
247
+ @log.sync = true
248
+ end
249
+
250
+ def self::open
251
+ log_open
252
+ $stderr.reopen(@log)
253
+ $stdout.reopen(@log)
254
+ yield
255
+ ensure
256
+ $stderr.reopen(@orgerr)
257
+ $stdout.reopen(@orgout)
258
+ end
259
+
260
+ def self::message(*s)
261
+ log_open
262
+ @log.printf(*s)
263
+ end
264
+
265
+ def self::logfile file
266
+ @logfile = file
267
+ if @log and not @log.closed?
268
+ @log.flush
269
+ @log.close
270
+ @log = nil
271
+ end
272
+ end
273
+
274
+ def self::postpone
275
+ tmplog = "mkmftmp#{@postpone += 1}.log"
276
+ open do
277
+ log, *save = @log, @logfile, @orgout, @orgerr
278
+ @log, @logfile, @orgout, @orgerr = nil, tmplog, log, log
279
+ begin
280
+ log.print(open {yield})
281
+ ensure
282
+ @log.close
283
+ File::open(tmplog) {|t| FileUtils.copy_stream(t, log)}
284
+ @log, @logfile, @orgout, @orgerr = log, *save
285
+ @postpone -= 1
286
+ rm_f tmplog
287
+ end
288
+ end
289
+ end
290
+
291
+ class << self
292
+ attr_accessor :quiet
293
+ end
294
+ end
295
+
296
+ def xsystem command
297
+ varpat = /\$\((\w+)\)|\$\{(\w+)\}/
298
+ if varpat =~ command
299
+ vars = Hash.new {|h, k| h[k] = ''; ENV[k]}
300
+ command = command.dup
301
+ nil while command.gsub!(varpat) {vars[$1||$2]}
302
+ end
303
+ Logging::open do
304
+ puts command.quote
305
+ system(command)
306
+ end
307
+ end
308
+
309
+ def xpopen command, *mode, &block
310
+ Logging::open do
311
+ case mode[0]
312
+ when nil, /^r/
313
+ puts "#{command} |"
314
+ else
315
+ puts "| #{command}"
316
+ end
317
+ IO.popen(command, *mode, &block)
318
+ end
319
+ end
320
+
321
+ def log_src(src)
322
+ src = src.split(/^/)
323
+ fmt = "%#{src.size.to_s.size}d: %s"
324
+ Logging::message <<"EOM"
325
+ checked program was:
326
+ /* begin */
327
+ EOM
328
+ src.each_with_index {|line, no| Logging::message fmt, no+1, line}
329
+ Logging::message <<"EOM"
330
+ /* end */
331
+
332
+ EOM
333
+ end
334
+
335
+ def create_tmpsrc(src)
336
+ src = "#{COMMON_HEADERS}\n#{src}"
337
+ src = yield(src) if block_given?
338
+ src.gsub!(/[ \t]+$/, '')
339
+ src.gsub!(/\A\n+|^\n+$/, '')
340
+ src.sub!(/[^\n]\z/, "\\&\n")
341
+ count = 0
342
+ begin
343
+ open(CONFTEST_C, "wb") do |cfile|
344
+ cfile.print src
345
+ end
346
+ rescue Errno::EACCES
347
+ if (count += 1) < 5
348
+ sleep 0.2
349
+ retry
350
+ end
351
+ end
352
+ src
353
+ end
354
+
355
+ def have_devel?
356
+ unless defined? $have_devel
357
+ $have_devel = true
358
+ $have_devel = try_link(MAIN_DOES_NOTHING)
359
+ end
360
+ $have_devel
361
+ end
362
+
363
+ def try_do(src, command, &b)
364
+ unless have_devel?
365
+ raise <<MSG
366
+ The complier failed to generate an executable file.
367
+ You have to install development tools first.
368
+ MSG
369
+ end
370
+ begin
371
+ src = create_tmpsrc(src, &b)
372
+ xsystem(command)
373
+ ensure
374
+ log_src(src)
375
+ rm_rf 'conftest.dSYM'
376
+ end
377
+ end
378
+
379
+ def link_command(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
380
+ conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote,
381
+ 'src' => "#{CONFTEST_C}",
382
+ 'arch_hdrdir' => "#$arch_hdrdir",
383
+ 'top_srcdir' => $top_srcdir.quote,
384
+ 'INCFLAGS' => "#$INCFLAGS",
385
+ 'CPPFLAGS' => "#$CPPFLAGS",
386
+ 'CFLAGS' => "#$CFLAGS",
387
+ 'ARCH_FLAG' => "#$ARCH_FLAG",
388
+ 'LDFLAGS' => "#$LDFLAGS #{ldflags}",
389
+ 'LIBPATH' => libpathflag(libpath),
390
+ 'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
391
+ 'LIBS' => "#$LIBRUBYARG_STATIC #{opt} #$LIBS")
392
+ RbConfig::expand(TRY_LINK.dup, conf)
393
+ end
394
+
395
+ def cc_command(opt="")
396
+ conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote,
397
+ 'arch_hdrdir' => "#$arch_hdrdir",
398
+ 'top_srcdir' => $top_srcdir.quote)
399
+ RbConfig::expand("$(CC) #$INCFLAGS #$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_C}",
400
+ conf)
401
+ end
402
+
403
+ def cpp_command(outfile, opt="")
404
+ conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote,
405
+ 'arch_hdrdir' => "#$arch_hdrdir",
406
+ 'top_srcdir' => $top_srcdir.quote)
407
+ RbConfig::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
408
+ conf)
409
+ end
410
+
411
+ def libpathflag(libpath=$DEFLIBPATH|$LIBPATH)
412
+ libpath.map{|x|
413
+ case x
414
+ when "$(topdir)", /\A\./
415
+ LIBPATHFLAG
416
+ else
417
+ LIBPATHFLAG+RPATHFLAG
418
+ end % x.quote
419
+ }.join
420
+ end
421
+
422
+ def try_link0(src, opt="", &b)
423
+ cmd = link_command("", opt)
424
+ if $universal
425
+ require 'tmpdir'
426
+ Dir.mktmpdir("mkmf_", oldtmpdir = ENV["TMPDIR"]) do |tmpdir|
427
+ begin
428
+ ENV["TMPDIR"] = tmpdir
429
+ try_do(src, cmd, &b)
430
+ ensure
431
+ ENV["TMPDIR"] = oldtmpdir
432
+ end
433
+ end
434
+ else
435
+ try_do(src, cmd, &b)
436
+ end
437
+ end
438
+
439
+ def try_link(src, opt="", &b)
440
+ try_link0(src, opt, &b)
441
+ ensure
442
+ rm_f "conftest*", "c0x32*"
443
+ end
444
+
445
+ def try_compile(src, opt="", &b)
446
+ try_do(src, cc_command(opt), &b)
447
+ ensure
448
+ rm_f "conftest*"
449
+ end
450
+
451
+ def try_cpp(src, opt="", &b)
452
+ try_do(src, cpp_command(CPPOUTFILE, opt), &b)
453
+ ensure
454
+ rm_f "conftest*"
455
+ end
456
+
457
+ class Object
458
+ alias_method :try_header, (config_string('try_header') || :try_cpp)
459
+ end
460
+
461
+ def cpp_include(header)
462
+ if header
463
+ header = [header] unless header.kind_of? Array
464
+ header.map {|h| String === h ? "#include <#{h}>\n" : h}.join
465
+ else
466
+ ""
467
+ end
468
+ end
469
+
470
+ def with_cppflags(flags)
471
+ cppflags = $CPPFLAGS
472
+ $CPPFLAGS = flags
473
+ ret = yield
474
+ ensure
475
+ $CPPFLAGS = cppflags unless ret
476
+ end
477
+
478
+ def with_cflags(flags)
479
+ cflags = $CFLAGS
480
+ $CFLAGS = flags
481
+ ret = yield
482
+ ensure
483
+ $CFLAGS = cflags unless ret
484
+ end
485
+
486
+ def with_ldflags(flags)
487
+ ldflags = $LDFLAGS
488
+ $LDFLAGS = flags
489
+ ret = yield
490
+ ensure
491
+ $LDFLAGS = ldflags unless ret
492
+ end
493
+
494
+ def try_static_assert(expr, headers = nil, opt = "", &b)
495
+ headers = cpp_include(headers)
496
+ try_compile(<<SRC, opt, &b)
497
+ #{headers}
498
+ /*top*/
499
+ int conftest_const[(#{expr}) ? 1 : -1];
500
+ SRC
501
+ end
502
+
503
+ def try_constant(const, headers = nil, opt = "", &b)
504
+ includes = cpp_include(headers)
505
+ if CROSS_COMPILING
506
+ if try_static_assert("#{const} > 0", headers, opt)
507
+ # positive constant
508
+ elsif try_static_assert("#{const} < 0", headers, opt)
509
+ neg = true
510
+ const = "-(#{const})"
511
+ elsif try_static_assert("#{const} == 0", headers, opt)
512
+ return 0
513
+ else
514
+ # not a constant
515
+ return nil
516
+ end
517
+ upper = 1
518
+ lower = 0
519
+ until try_static_assert("#{const} <= #{upper}", headers, opt)
520
+ lower = upper
521
+ upper <<= 1
522
+ end
523
+ return nil unless lower
524
+ while upper > lower + 1
525
+ mid = (upper + lower) / 2
526
+ if try_static_assert("#{const} > #{mid}", headers, opt)
527
+ lower = mid
528
+ else
529
+ upper = mid
530
+ end
531
+ end
532
+ upper = -upper if neg
533
+ return upper
534
+ else
535
+ src = %{#{includes}
536
+ #include <stdio.h>
537
+ /*top*/
538
+ int conftest_const = (int)(#{const});
539
+ int main() {printf("%d\\n", conftest_const); return 0;}
540
+ }
541
+ if try_link0(src, opt, &b)
542
+ xpopen("./conftest") do |f|
543
+ return Integer(f.gets)
544
+ end
545
+ end
546
+ end
547
+ nil
548
+ end
549
+
550
+ def try_func(func, libs, headers = nil, &b)
551
+ headers = cpp_include(headers)
552
+ try_link(<<"SRC", libs, &b) or
553
+ #{headers}
554
+ /*top*/
555
+ #{MAIN_DOES_NOTHING}
556
+ int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
557
+ SRC
558
+ try_link(<<"SRC", libs, &b)
559
+ #{headers}
560
+ /*top*/
561
+ #{MAIN_DOES_NOTHING}
562
+ int t() { #{func}(); return 0; }
563
+ SRC
564
+ end
565
+
566
+ def try_var(var, headers = nil, &b)
567
+ headers = cpp_include(headers)
568
+ try_compile(<<"SRC", &b)
569
+ #{headers}
570
+ /*top*/
571
+ #{MAIN_DOES_NOTHING}
572
+ int t() { const volatile void *volatile p; p = &(&#{var})[0]; return 0; }
573
+ SRC
574
+ end
575
+
576
+ def egrep_cpp(pat, src, opt = "", &b)
577
+ src = create_tmpsrc(src, &b)
578
+ xpopen(cpp_command('', opt)) do |f|
579
+ if Regexp === pat
580
+ puts(" ruby -ne 'print if #{pat.inspect}'")
581
+ f.grep(pat) {|l|
582
+ puts "#{f.lineno}: #{l}"
583
+ return true
584
+ }
585
+ false
586
+ else
587
+ puts(" egrep '#{pat}'")
588
+ begin
589
+ stdin = $stdin.dup
590
+ $stdin.reopen(f)
591
+ system("egrep", pat)
592
+ ensure
593
+ $stdin.reopen(stdin)
594
+ end
595
+ end
596
+ end
597
+ ensure
598
+ rm_f "conftest*"
599
+ log_src(src)
600
+ end
601
+
602
+ # This is used internally by the have_macro? method.
603
+ def macro_defined?(macro, src, opt = "", &b)
604
+ src = src.sub(/[^\n]\z/, "\\&\n")
605
+ try_compile(src + <<"SRC", opt, &b)
606
+ /*top*/
607
+ #ifndef #{macro}
608
+ # error
609
+ >>>>>> #{macro} undefined <<<<<<
610
+ #endif
611
+ SRC
612
+ end
613
+
614
+ def try_run(src, opt = "", &b)
615
+ if try_link0(src, opt, &b)
616
+ xsystem("./conftest")
617
+ else
618
+ nil
619
+ end
620
+ ensure
621
+ rm_f "conftest*"
622
+ end
623
+
624
+ def install_files(mfile, ifiles, map = nil, srcprefix = nil)
625
+ ifiles or return
626
+ ifiles.empty? and return
627
+ srcprefix ||= "$(srcdir)/#{srcprefix}".chomp('/')
628
+ RbConfig::expand(srcdir = srcprefix.dup)
629
+ dirs = []
630
+ path = Hash.new {|h, i| h[i] = dirs.push([i])[-1]}
631
+ ifiles.each do |files, dir, prefix|
632
+ dir = map_dir(dir, map)
633
+ prefix &&= %r|\A#{Regexp.quote(prefix)}/?|
634
+ if /\A\.\// =~ files
635
+ # install files which are in current working directory.
636
+ files = files[2..-1]
637
+ len = nil
638
+ else
639
+ # install files which are under the $(srcdir).
640
+ files = File.join(srcdir, files)
641
+ len = srcdir.size
642
+ end
643
+ f = nil
644
+ Dir.glob(files) do |fx|
645
+ f = fx
646
+ f[0..len] = "" if len
647
+ case File.basename(f)
648
+ when *$NONINSTALLFILES
649
+ next
650
+ end
651
+ d = File.dirname(f)
652
+ d.sub!(prefix, "") if prefix
653
+ d = (d.empty? || d == ".") ? dir : File.join(dir, d)
654
+ f = File.join(srcprefix, f) if len
655
+ path[d] << f
656
+ end
657
+ unless len or f
658
+ d = File.dirname(files)
659
+ d.sub!(prefix, "") if prefix
660
+ d = (d.empty? || d == ".") ? dir : File.join(dir, d)
661
+ path[d] << files
662
+ end
663
+ end
664
+ dirs
665
+ end
666
+
667
+ def install_rb(mfile, dest, srcdir = nil)
668
+ install_files(mfile, [["lib/**/*.rb", dest, "lib"]], nil, srcdir)
669
+ end
670
+
671
+ def append_library(libs, lib) # :no-doc:
672
+ format(LIBARG, lib) + " " + libs
673
+ end
674
+
675
+ def message(*s)
676
+ unless Logging.quiet and not $VERBOSE
677
+ printf(*s)
678
+ $stdout.flush
679
+ end
680
+ end
681
+
682
+ # This emits a string to stdout that allows users to see the results of the
683
+ # various have* and find* methods as they are tested.
684
+ #
685
+ # Internal use only.
686
+ #
687
+ def checking_for(m, fmt = nil)
688
+ f = caller[0][/in `([^<].*)'$/, 1] and f << ": " #` for vim #'
689
+ m = "checking #{/\Acheck/ =~ f ? '' : 'for '}#{m}... "
690
+ message "%s", m
691
+ a = r = nil
692
+ Logging::postpone do
693
+ r = yield
694
+ a = (fmt ? fmt % r : r ? "yes" : "no") << "\n"
695
+ "#{f}#{m}-------------------- #{a}\n"
696
+ end
697
+ message(a)
698
+ Logging::message "--------------------\n\n"
699
+ r
700
+ end
701
+
702
+ def checking_message(target, place = nil, opt = nil)
703
+ [["in", place], ["with", opt]].inject("#{target}") do |msg, (pre, noun)|
704
+ if noun
705
+ [[:to_str], [:join, ","], [:to_s]].each do |meth, *args|
706
+ if noun.respond_to?(meth)
707
+ break noun = noun.send(meth, *args)
708
+ end
709
+ end
710
+ msg << " #{pre} #{noun}" unless noun.empty?
711
+ end
712
+ msg
713
+ end
714
+ end
715
+
716
+ # :startdoc:
717
+
718
+ # Returns whether or not +macro+ is defined either in the common header
719
+ # files or within any +headers+ you provide.
720
+ #
721
+ # Any options you pass to +opt+ are passed along to the compiler.
722
+ #
723
+ def have_macro(macro, headers = nil, opt = "", &b)
724
+ checking_for checking_message(macro, headers, opt) do
725
+ macro_defined?(macro, cpp_include(headers), opt, &b)
726
+ end
727
+ end
728
+
729
+ # Returns whether or not the given entry point +func+ can be found within
730
+ # +lib+. If +func+ is nil, the 'main()' entry point is used by default.
731
+ # If found, it adds the library to list of libraries to be used when linking
732
+ # your extension.
733
+ #
734
+ # If +headers+ are provided, it will include those header files as the
735
+ # header files it looks in when searching for +func+.
736
+ #
737
+ # The real name of the library to be linked can be altered by
738
+ # '--with-FOOlib' configuration option.
739
+ #
740
+ def have_library(lib, func = nil, headers = nil, &b)
741
+ func = "main" if !func or func.empty?
742
+ lib = with_config(lib+'lib', lib)
743
+ checking_for checking_message("#{func}()", LIBARG%lib) do
744
+ if COMMON_LIBS.include?(lib)
745
+ true
746
+ else
747
+ libs = append_library($libs, lib)
748
+ if try_func(func, libs, headers, &b)
749
+ $libs = libs
750
+ true
751
+ else
752
+ false
753
+ end
754
+ end
755
+ end
756
+ end
757
+
758
+ # Returns whether or not the entry point +func+ can be found within the library
759
+ # +lib+ in one of the +paths+ specified, where +paths+ is an array of strings.
760
+ # If +func+ is nil , then the main() function is used as the entry point.
761
+ #
762
+ # If +lib+ is found, then the path it was found on is added to the list of
763
+ # library paths searched and linked against.
764
+ #
765
+ def find_library(lib, func, *paths, &b)
766
+ func = "main" if !func or func.empty?
767
+ lib = with_config(lib+'lib', lib)
768
+ paths = paths.collect {|path| path.split(File::PATH_SEPARATOR)}.flatten
769
+ checking_for "#{func}() in #{LIBARG%lib}" do
770
+ libpath = $LIBPATH
771
+ libs = append_library($libs, lib)
772
+ begin
773
+ until r = try_func(func, libs, &b) or paths.empty?
774
+ $LIBPATH = libpath | [paths.shift]
775
+ end
776
+ if r
777
+ $libs = libs
778
+ libpath = nil
779
+ end
780
+ ensure
781
+ $LIBPATH = libpath if libpath
782
+ end
783
+ r
784
+ end
785
+ end
786
+
787
+ # Returns whether or not the function +func+ can be found in the common
788
+ # header files, or within any +headers+ that you provide. If found, a
789
+ # macro is passed as a preprocessor constant to the compiler using the
790
+ # function name, in uppercase, prepended with 'HAVE_'.
791
+ #
792
+ # For example, if have_func('foo') returned true, then the HAVE_FOO
793
+ # preprocessor macro would be passed to the compiler.
794
+ #
795
+ def have_func(func, headers = nil, &b)
796
+ checking_for checking_message("#{func}()", headers) do
797
+ if try_func(func, $libs, headers, &b)
798
+ $defs.push(format("-DHAVE_%s", func.tr_cpp))
799
+ true
800
+ else
801
+ false
802
+ end
803
+ end
804
+ end
805
+
806
+ # Returns whether or not the variable +var+ can be found in the common
807
+ # header files, or within any +headers+ that you provide. If found, a
808
+ # macro is passed as a preprocessor constant to the compiler using the
809
+ # variable name, in uppercase, prepended with 'HAVE_'.
810
+ #
811
+ # For example, if have_var('foo') returned true, then the HAVE_FOO
812
+ # preprocessor macro would be passed to the compiler.
813
+ #
814
+ def have_var(var, headers = nil, &b)
815
+ checking_for checking_message(var, headers) do
816
+ if try_var(var, headers, &b)
817
+ $defs.push(format("-DHAVE_%s", var.tr_cpp))
818
+ true
819
+ else
820
+ false
821
+ end
822
+ end
823
+ end
824
+
825
+ # Returns whether or not the given +header+ file can be found on your system.
826
+ # If found, a macro is passed as a preprocessor constant to the compiler using
827
+ # the header file name, in uppercase, prepended with 'HAVE_'.
828
+ #
829
+ # For example, if have_header('foo.h') returned true, then the HAVE_FOO_H
830
+ # preprocessor macro would be passed to the compiler.
831
+ #
832
+ def have_header(header, preheaders = nil, &b)
833
+ checking_for header do
834
+ if try_header(cpp_include(preheaders)+cpp_include(header), &b)
835
+ $defs.push(format("-DHAVE_%s", header.tr_cpp))
836
+ true
837
+ else
838
+ false
839
+ end
840
+ end
841
+ end
842
+
843
+ # Instructs mkmf to search for the given +header+ in any of the +paths+
844
+ # provided, and returns whether or not it was found in those paths.
845
+ #
846
+ # If the header is found then the path it was found on is added to the list
847
+ # of included directories that are sent to the compiler (via the -I switch).
848
+ #
849
+ def find_header(header, *paths)
850
+ message = checking_message(header, paths)
851
+ header = cpp_include(header)
852
+ checking_for message do
853
+ if try_header(header)
854
+ true
855
+ else
856
+ found = false
857
+ paths.each do |dir|
858
+ opt = "-I#{dir}".quote
859
+ if try_header(header, opt)
860
+ $INCFLAGS << " " << opt
861
+ found = true
862
+ break
863
+ end
864
+ end
865
+ found
866
+ end
867
+ end
868
+ end
869
+
870
+ # Returns whether or not the struct of type +type+ contains +member+. If
871
+ # it does not, or the struct type can't be found, then false is returned. You
872
+ # may optionally specify additional +headers+ in which to look for the struct
873
+ # (in addition to the common header files).
874
+ #
875
+ # If found, a macro is passed as a preprocessor constant to the compiler using
876
+ # the type name and the member name, in uppercase, prepended with 'HAVE_'.
877
+ #
878
+ # For example, if have_struct_member('struct foo', 'bar') returned true, then the
879
+ # HAVE_STRUCT_FOO_BAR preprocessor macro would be passed to the compiler.
880
+ #
881
+ # HAVE_ST_BAR is also defined for backward compatibility.
882
+ #
883
+ def have_struct_member(type, member, headers = nil, &b)
884
+ checking_for checking_message("#{type}.#{member}", headers) do
885
+ if try_compile(<<"SRC", &b)
886
+ #{cpp_include(headers)}
887
+ /*top*/
888
+ #{MAIN_DOES_NOTHING}
889
+ int s = (char *)&((#{type}*)0)->#{member} - (char *)0;
890
+ SRC
891
+ $defs.push(format("-DHAVE_%s_%s", type.tr_cpp, member.tr_cpp))
892
+ $defs.push(format("-DHAVE_ST_%s", member.tr_cpp)) # backward compatibility
893
+ true
894
+ else
895
+ false
896
+ end
897
+ end
898
+ end
899
+
900
+ def try_type(type, headers = nil, opt = "", &b)
901
+ if try_compile(<<"SRC", opt, &b)
902
+ #{cpp_include(headers)}
903
+ /*top*/
904
+ typedef #{type} conftest_type;
905
+ int conftestval[sizeof(conftest_type)?1:-1];
906
+ SRC
907
+ $defs.push(format("-DHAVE_TYPE_%s", type.tr_cpp))
908
+ true
909
+ else
910
+ false
911
+ end
912
+ end
913
+
914
+ # Returns whether or not the static type +type+ is defined. You may
915
+ # optionally pass additional +headers+ to check against in addition to the
916
+ # common header files.
917
+ #
918
+ # You may also pass additional flags to +opt+ which are then passed along to
919
+ # the compiler.
920
+ #
921
+ # If found, a macro is passed as a preprocessor constant to the compiler using
922
+ # the type name, in uppercase, prepended with 'HAVE_TYPE_'.
923
+ #
924
+ # For example, if have_type('foo') returned true, then the HAVE_TYPE_FOO
925
+ # preprocessor macro would be passed to the compiler.
926
+ #
927
+ def have_type(type, headers = nil, opt = "", &b)
928
+ checking_for checking_message(type, headers, opt) do
929
+ try_type(type, headers, opt, &b)
930
+ end
931
+ end
932
+
933
+ # Returns where the static type +type+ is defined.
934
+ #
935
+ # You may also pass additional flags to +opt+ which are then passed along to
936
+ # the compiler.
937
+ #
938
+ # See also +have_type+.
939
+ #
940
+ def find_type(type, opt, *headers, &b)
941
+ opt ||= ""
942
+ fmt = "not found"
943
+ def fmt.%(x)
944
+ x ? x.respond_to?(:join) ? x.join(",") : x : self
945
+ end
946
+ checking_for checking_message(type, nil, opt), fmt do
947
+ headers.find do |h|
948
+ try_type(type, h, opt, &b)
949
+ end
950
+ end
951
+ end
952
+
953
+ def try_const(const, headers = nil, opt = "", &b)
954
+ const, type = *const
955
+ if try_compile(<<"SRC", opt, &b)
956
+ #{cpp_include(headers)}
957
+ /*top*/
958
+ typedef #{type || 'int'} conftest_type;
959
+ conftest_type conftestval = #{type ? '' : '(int)'}#{const};
960
+ SRC
961
+ $defs.push(format("-DHAVE_CONST_%s", const.tr_cpp))
962
+ true
963
+ else
964
+ false
965
+ end
966
+ end
967
+
968
+ # Returns whether or not the constant +const+ is defined. You may
969
+ # optionally pass the +type+ of +const+ as <code>[const, type]</code>,
970
+ # like as:
971
+ #
972
+ # have_const(%w[PTHREAD_MUTEX_INITIALIZER pthread_mutex_t], "pthread.h")
973
+ #
974
+ # You may also pass additional +headers+ to check against in addition
975
+ # to the common header files, and additional flags to +opt+ which are
976
+ # then passed along to the compiler.
977
+ #
978
+ # If found, a macro is passed as a preprocessor constant to the compiler using
979
+ # the type name, in uppercase, prepended with 'HAVE_CONST_'.
980
+ #
981
+ # For example, if have_const('foo') returned true, then the HAVE_CONST_FOO
982
+ # preprocessor macro would be passed to the compiler.
983
+ #
984
+ def have_const(const, headers = nil, opt = "", &b)
985
+ checking_for checking_message([*const].compact.join(' '), headers, opt) do
986
+ try_const(const, headers, opt, &b)
987
+ end
988
+ end
989
+
990
+ STRING_OR_FAILED_FORMAT = "%s"
991
+ # :stopdoc:
992
+ def STRING_OR_FAILED_FORMAT.%(x)
993
+ x ? super : "failed"
994
+ end
995
+ # :startdoc:
996
+
997
+ # Returns the size of the given +type+. You may optionally specify additional
998
+ # +headers+ to search in for the +type+.
999
+ #
1000
+ # If found, a macro is passed as a preprocessor constant to the compiler using
1001
+ # the type name, in uppercase, prepended with 'SIZEOF_', followed by the type
1002
+ # name, followed by '=X' where 'X' is the actual size.
1003
+ #
1004
+ # For example, if check_sizeof('mystruct') returned 12, then the
1005
+ # SIZEOF_MYSTRUCT=12 preprocessor macro would be passed to the compiler.
1006
+ #
1007
+ def check_sizeof(type, headers = nil, opts = "", &b)
1008
+ typename, member = type.split('.', 2)
1009
+ prelude = cpp_include(headers).split(/$/)
1010
+ prelude << "typedef #{typename} rbcv_typedef_;\n"
1011
+ prelude << "static rbcv_typedef_ *rbcv_ptr_;\n"
1012
+ prelude = [prelude]
1013
+ expr = "sizeof((*rbcv_ptr_)#{"." << member if member})"
1014
+ fmt = STRING_OR_FAILED_FORMAT
1015
+ checking_for checking_message("size of #{type}", headers), fmt do
1016
+ if UNIVERSAL_INTS.include?(type)
1017
+ type
1018
+ elsif size = UNIVERSAL_INTS.find {|t|
1019
+ try_static_assert("#{expr} == sizeof(#{t})", prelude, opts, &b)
1020
+ }
1021
+ $defs.push(format("-DSIZEOF_%s=SIZEOF_%s", type.tr_cpp, size.tr_cpp))
1022
+ size
1023
+ elsif size = try_constant(expr, prelude, opts, &b)
1024
+ $defs.push(format("-DSIZEOF_%s=%s", type.tr_cpp, size))
1025
+ size
1026
+ end
1027
+ end
1028
+ end
1029
+
1030
+ # Returns the signedness of the given +type+. You may optionally
1031
+ # specify additional +headers+ to search in for the +type+.
1032
+ #
1033
+ # If the +type+ is found and is a numeric type, a macro is passed as a
1034
+ # preprocessor constant to the compiler using the +type+ name, in
1035
+ # uppercase, prepended with 'SIGNEDNESS_OF_', followed by the +type+
1036
+ # name, followed by '=X' where 'X' is positive integer if the +type+ is
1037
+ # unsigned, or negative integer if the +type+ is signed.
1038
+ #
1039
+ # For example, if size_t is defined as unsigned, then
1040
+ # check_signedness('size_t') would returned +1 and the
1041
+ # SIGNEDNESS_OF_SIZE_T=+1 preprocessor macro would be passed to the
1042
+ # compiler, and SIGNEDNESS_OF_INT=-1 if check_signedness('int') is
1043
+ # done.
1044
+ #
1045
+ def check_signedness(type, headers = nil)
1046
+ signed = nil
1047
+ checking_for("signedness of #{type}", STRING_OR_FAILED_FORMAT) do
1048
+ if try_static_assert("(#{type})-1 < 0")
1049
+ signed = -1
1050
+ elsif try_static_assert("(#{type})-1 > 0")
1051
+ signed = +1
1052
+ else
1053
+ next nil
1054
+ end
1055
+ $defs.push("-DSIGNEDNESS_OF_%s=%+d" % [type.tr_cpp, signed])
1056
+ signed < 0 ? "signed" : "unsigned"
1057
+ end
1058
+ signed
1059
+ end
1060
+
1061
+ # :stopdoc:
1062
+
1063
+ # Used internally by the what_type? method to determine if +type+ is a scalar
1064
+ # pointer.
1065
+ def scalar_ptr_type?(type, member = nil, headers = nil, &b)
1066
+ try_compile(<<"SRC", &b) # pointer
1067
+ #{cpp_include(headers)}
1068
+ /*top*/
1069
+ volatile #{type} conftestval;
1070
+ #{MAIN_DOES_NOTHING}
1071
+ int t() {return (int)(1-*(conftestval#{member ? ".#{member}" : ""}));}
1072
+ SRC
1073
+ end
1074
+
1075
+ # Used internally by the what_type? method to determine if +type+ is a scalar
1076
+ # pointer.
1077
+ def scalar_type?(type, member = nil, headers = nil, &b)
1078
+ try_compile(<<"SRC", &b) # pointer
1079
+ #{cpp_include(headers)}
1080
+ /*top*/
1081
+ volatile #{type} conftestval;
1082
+ #{MAIN_DOES_NOTHING}
1083
+ int t() {return (int)(1-(conftestval#{member ? ".#{member}" : ""}));}
1084
+ SRC
1085
+ end
1086
+
1087
+ # Used internally by the what_type? method to check if _typeof_ GCC
1088
+ # extension is available.
1089
+ def have_typeof?
1090
+ return $typeof if defined?($typeof)
1091
+ $typeof = %w[__typeof__ typeof].find do |t|
1092
+ try_compile(<<SRC)
1093
+ int rbcv_foo;
1094
+ #{t}(rbcv_foo) rbcv_bar;
1095
+ SRC
1096
+ end
1097
+ end
1098
+
1099
+ def what_type?(type, member = nil, headers = nil, &b)
1100
+ m = "#{type}"
1101
+ var = val = "*rbcv_var_"
1102
+ func = "rbcv_func_(void)"
1103
+ if member
1104
+ m << "." << member
1105
+ else
1106
+ type, member = type.split('.', 2)
1107
+ end
1108
+ if member
1109
+ val = "(#{var}).#{member}"
1110
+ end
1111
+ prelude = [cpp_include(headers).split(/^/)]
1112
+ prelude << ["typedef #{type} rbcv_typedef_;\n",
1113
+ "extern rbcv_typedef_ *#{func};\n",
1114
+ "static rbcv_typedef_ #{var};\n",
1115
+ ]
1116
+ type = "rbcv_typedef_"
1117
+ fmt = member && !(typeof = have_typeof?) ? "seems %s" : "%s"
1118
+ if typeof
1119
+ var = "*rbcv_member_"
1120
+ func = "rbcv_mem_func_(void)"
1121
+ member = nil
1122
+ type = "rbcv_mem_typedef_"
1123
+ prelude[-1] << "typedef #{typeof}(#{val}) #{type};\n"
1124
+ prelude[-1] << "extern #{type} *#{func};\n"
1125
+ prelude[-1] << "static #{type} #{var};\n"
1126
+ val = var
1127
+ end
1128
+ def fmt.%(x)
1129
+ x ? super : "unknown"
1130
+ end
1131
+ checking_for checking_message(m, headers), fmt do
1132
+ if scalar_ptr_type?(type, member, prelude, &b)
1133
+ if try_static_assert("sizeof(*#{var}) == 1", prelude)
1134
+ return "string"
1135
+ end
1136
+ ptr = "*"
1137
+ elsif scalar_type?(type, member, prelude, &b)
1138
+ unless member and !typeof or try_static_assert("(#{type})-1 < 0", prelude)
1139
+ unsigned = "unsigned"
1140
+ end
1141
+ ptr = ""
1142
+ else
1143
+ next
1144
+ end
1145
+ type = UNIVERSAL_INTS.find do |t|
1146
+ pre = prelude
1147
+ unless member
1148
+ pre += [["static #{unsigned} #{t} #{ptr}#{var};\n",
1149
+ "extern #{unsigned} #{t} #{ptr}*#{func};\n"]]
1150
+ end
1151
+ try_static_assert("sizeof(#{ptr}#{val}) == sizeof(#{unsigned} #{t})", pre)
1152
+ end
1153
+ type or next
1154
+ [unsigned, type, ptr].join(" ").strip
1155
+ end
1156
+ end
1157
+
1158
+ # This method is used internally by the find_executable method.
1159
+ #
1160
+ # Internal use only.
1161
+ #
1162
+ def find_executable0(bin, path = nil)
1163
+ exts = config_string('EXECUTABLE_EXTS') {|s| s.split} || config_string('EXEEXT') {|s| [s]}
1164
+ if File.expand_path(bin) == bin
1165
+ return bin if File.executable?(bin)
1166
+ if exts
1167
+ exts.each {|ext| File.executable?(file = bin + ext) and return file}
1168
+ end
1169
+ return nil
1170
+ end
1171
+ if path ||= ENV['PATH']
1172
+ path = path.split(File::PATH_SEPARATOR)
1173
+ else
1174
+ path = %w[/usr/local/bin /usr/ucb /usr/bin /bin]
1175
+ end
1176
+ file = nil
1177
+ path.each do |dir|
1178
+ return file if File.executable?(file = File.join(dir, bin))
1179
+ if exts
1180
+ exts.each {|ext| File.executable?(ext = file + ext) and return ext}
1181
+ end
1182
+ end
1183
+ nil
1184
+ end
1185
+
1186
+ # :startdoc:
1187
+
1188
+ # Searches for the executable +bin+ on +path+. The default path is your
1189
+ # PATH environment variable. If that isn't defined, it will resort to
1190
+ # searching /usr/local/bin, /usr/ucb, /usr/bin and /bin.
1191
+ #
1192
+ # If found, it will return the full path, including the executable name,
1193
+ # of where it was found.
1194
+ #
1195
+ # Note that this method does not actually affect the generated Makefile.
1196
+ #
1197
+ def find_executable(bin, path = nil)
1198
+ checking_for checking_message(bin, path) do
1199
+ find_executable0(bin, path)
1200
+ end
1201
+ end
1202
+
1203
+ # :stopdoc:
1204
+
1205
+ def arg_config(config, default=nil, &block)
1206
+ $arg_config << [config, default]
1207
+ defaults = []
1208
+ if default
1209
+ defaults << default
1210
+ elsif !block
1211
+ defaults << nil
1212
+ end
1213
+ $configure_args.fetch(config.tr('_', '-'), *defaults, &block)
1214
+ end
1215
+
1216
+ # :startdoc:
1217
+
1218
+ # Tests for the presence of a --with-<tt>config</tt> or --without-<tt>config</tt>
1219
+ # option. Returns true if the with option is given, false if the without
1220
+ # option is given, and the default value otherwise.
1221
+ #
1222
+ # This can be useful for adding custom definitions, such as debug information.
1223
+ #
1224
+ # Example:
1225
+ #
1226
+ # if with_config("debug")
1227
+ # $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
1228
+ # end
1229
+ #
1230
+ def with_config(config, default=nil)
1231
+ config = config.sub(/^--with[-_]/, '')
1232
+ val = arg_config("--with-"+config) do
1233
+ if arg_config("--without-"+config)
1234
+ false
1235
+ elsif block_given?
1236
+ yield(config, default)
1237
+ else
1238
+ break default
1239
+ end
1240
+ end
1241
+ case val
1242
+ when "yes"
1243
+ true
1244
+ when "no"
1245
+ false
1246
+ else
1247
+ val
1248
+ end
1249
+ end
1250
+
1251
+ # Tests for the presence of an --enable-<tt>config</tt> or
1252
+ # --disable-<tt>config</tt> option. Returns true if the enable option is given,
1253
+ # false if the disable option is given, and the default value otherwise.
1254
+ #
1255
+ # This can be useful for adding custom definitions, such as debug information.
1256
+ #
1257
+ # Example:
1258
+ #
1259
+ # if enable_config("debug")
1260
+ # $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
1261
+ # end
1262
+ #
1263
+ def enable_config(config, default=nil)
1264
+ if arg_config("--enable-"+config)
1265
+ true
1266
+ elsif arg_config("--disable-"+config)
1267
+ false
1268
+ elsif block_given?
1269
+ yield(config, default)
1270
+ else
1271
+ return default
1272
+ end
1273
+ end
1274
+
1275
+ # Generates a header file consisting of the various macro definitions generated
1276
+ # by other methods such as have_func and have_header. These are then wrapped in
1277
+ # a custom #ifndef based on the +header+ file name, which defaults to
1278
+ # 'extconf.h'.
1279
+ #
1280
+ # For example:
1281
+ #
1282
+ # # extconf.rb
1283
+ # require 'mkmf'
1284
+ # have_func('realpath')
1285
+ # have_header('sys/utime.h')
1286
+ # create_header
1287
+ # create_makefile('foo')
1288
+ #
1289
+ # The above script would generate the following extconf.h file:
1290
+ #
1291
+ # #ifndef EXTCONF_H
1292
+ # #define EXTCONF_H
1293
+ # #define HAVE_REALPATH 1
1294
+ # #define HAVE_SYS_UTIME_H 1
1295
+ # #endif
1296
+ #
1297
+ # Given that the create_header method generates a file based on definitions
1298
+ # set earlier in your extconf.rb file, you will probably want to make this
1299
+ # one of the last methods you call in your script.
1300
+ #
1301
+ def create_header(header = "extconf.h")
1302
+ message "creating %s\n", header
1303
+ sym = header.tr_cpp
1304
+ hdr = ["#ifndef #{sym}\n#define #{sym}\n"]
1305
+ for line in $defs
1306
+ case line
1307
+ when /^-D([^=]+)(?:=(.*))?/
1308
+ hdr << "#define #$1 #{$2 ? Shellwords.shellwords($2)[0].gsub(/(?=\t+)/, "\\\n") : 1}\n"
1309
+ when /^-U(.*)/
1310
+ hdr << "#undef #$1\n"
1311
+ end
1312
+ end
1313
+ hdr << "#endif\n"
1314
+ hdr = hdr.join
1315
+ unless (IO.read(header) == hdr rescue false)
1316
+ open(header, "wb") do |hfile|
1317
+ hfile.write(hdr)
1318
+ end
1319
+ end
1320
+ $extconf_h = header
1321
+ end
1322
+
1323
+ # Sets a +target+ name that the user can then use to configure various 'with'
1324
+ # options with on the command line by using that name. For example, if the
1325
+ # target is set to "foo", then the user could use the --with-foo-dir command
1326
+ # line option.
1327
+ #
1328
+ # You may pass along additional 'include' or 'lib' defaults via the +idefault+
1329
+ # and +ldefault+ parameters, respectively.
1330
+ #
1331
+ # Note that dir_config only adds to the list of places to search for libraries
1332
+ # and include files. It does not link the libraries into your application.
1333
+ #
1334
+ def dir_config(target, idefault=nil, ldefault=nil)
1335
+ if dir = with_config(target + "-dir", (idefault unless ldefault))
1336
+ defaults = Array === dir ? dir : dir.split(File::PATH_SEPARATOR)
1337
+ idefault = ldefault = nil
1338
+ end
1339
+
1340
+ idir = with_config(target + "-include", idefault)
1341
+ $arg_config.last[1] ||= "${#{target}-dir}/include"
1342
+ ldir = with_config(target + "-lib", ldefault)
1343
+ $arg_config.last[1] ||= "${#{target}-dir}/lib"
1344
+
1345
+ idirs = idir ? Array === idir ? idir.dup : idir.split(File::PATH_SEPARATOR) : []
1346
+ if defaults
1347
+ idirs.concat(defaults.collect {|d| d + "/include"})
1348
+ idir = ([idir] + idirs).compact.join(File::PATH_SEPARATOR)
1349
+ end
1350
+ unless idirs.empty?
1351
+ idirs.collect! {|d| "-I" + d}
1352
+ idirs -= Shellwords.shellwords($CPPFLAGS)
1353
+ unless idirs.empty?
1354
+ $CPPFLAGS = (idirs.quote << $CPPFLAGS).join(" ")
1355
+ end
1356
+ end
1357
+
1358
+ ldirs = ldir ? Array === ldir ? ldir.dup : ldir.split(File::PATH_SEPARATOR) : []
1359
+ if defaults
1360
+ ldirs.concat(defaults.collect {|d| d + "/lib"})
1361
+ ldir = ([ldir] + ldirs).compact.join(File::PATH_SEPARATOR)
1362
+ end
1363
+ $LIBPATH = ldirs | $LIBPATH
1364
+
1365
+ [idir, ldir]
1366
+ end
1367
+
1368
+ # :stopdoc:
1369
+
1370
+ # Handles meta information about installed libraries. Uses your platform's
1371
+ # pkg-config program if it has one.
1372
+ def pkg_config(pkg)
1373
+ if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig)
1374
+ # iff package specific config command is given
1375
+ get = proc {|opt| `#{pkgconfig} --#{opt}`.chomp}
1376
+ elsif ($PKGCONFIG ||=
1377
+ (pkgconfig = with_config("pkg-config", ("pkg-config" unless CROSS_COMPILING))) &&
1378
+ find_executable0(pkgconfig) && pkgconfig) and
1379
+ system("#{$PKGCONFIG} --exists #{pkg}")
1380
+ # default to pkg-config command
1381
+ get = proc {|opt| `#{$PKGCONFIG} --#{opt} #{pkg}`.chomp}
1382
+ elsif find_executable0(pkgconfig = "#{pkg}-config")
1383
+ # default to package specific config command, as a last resort.
1384
+ get = proc {|opt| `#{pkgconfig} --#{opt}`.chomp}
1385
+ end
1386
+ if get
1387
+ cflags = get['cflags']
1388
+ ldflags = get['libs']
1389
+ libs = get['libs-only-l']
1390
+ ldflags = (Shellwords.shellwords(ldflags) - Shellwords.shellwords(libs)).quote.join(" ")
1391
+ $CFLAGS += " " << cflags
1392
+ $LDFLAGS += " " << ldflags
1393
+ $libs += " " << libs
1394
+ Logging::message "package configuration for %s\n", pkg
1395
+ Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n",
1396
+ cflags, ldflags, libs
1397
+ [cflags, ldflags, libs]
1398
+ else
1399
+ Logging::message "package configuration for %s is not found\n", pkg
1400
+ nil
1401
+ end
1402
+ end
1403
+
1404
+ def with_destdir(dir)
1405
+ dir = dir.sub($dest_prefix_pattern, '')
1406
+ /\A\$[\(\{]/ =~ dir ? dir : "$(DESTDIR)"+dir
1407
+ end
1408
+
1409
+ # Converts forward slashes to backslashes. Aimed at MS Windows.
1410
+ #
1411
+ # Internal use only.
1412
+ #
1413
+ def winsep(s)
1414
+ s.tr('/', '\\')
1415
+ end
1416
+
1417
+ # Converts native path to format acceptable in Makefile
1418
+ #
1419
+ # Internal use only.
1420
+ #
1421
+ if !CROSS_COMPILING
1422
+ case CONFIG['build_os']
1423
+ when 'mingw32'
1424
+ def mkintpath(path)
1425
+ # mingw uses make from msys and it needs special care
1426
+ # converts from C:\some\path to /C/some/path
1427
+ path = path.dup
1428
+ path.tr!('\\', '/')
1429
+ path.sub!(/\A([A-Za-z]):(?=\/)/, '/\1')
1430
+ path
1431
+ end
1432
+ end
1433
+ end
1434
+ unless defined?(mkintpath)
1435
+ def mkintpath(path)
1436
+ path
1437
+ end
1438
+ end
1439
+
1440
+ def configuration(srcdir)
1441
+ mk = []
1442
+ vpath = $VPATH.dup
1443
+ if !CROSS_COMPILING
1444
+ case CONFIG['build_os']
1445
+ when 'cygwin'
1446
+ if CONFIG['target_os'] != 'cygwin'
1447
+ vpath = vpath.map {|p| p.sub(/.*/, '$(shell cygpath -u \&)')}
1448
+ end
1449
+ end
1450
+ end
1451
+ CONFIG["hdrdir"] ||= $hdrdir
1452
+ mk << %{
1453
+ SHELL = /bin/sh
1454
+
1455
+ #### Start of system configuration section. ####
1456
+ #{"top_srcdir = " + $top_srcdir.sub(%r"\A#{Regexp.quote($topdir)}/", "$(topdir)/") if $extmk}
1457
+ srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {mkintpath(CONFIG[$1||$2])}.quote}
1458
+ topdir = #{mkintpath($extmk ? CONFIG["topdir"] : $topdir).quote}
1459
+ hdrdir = #{mkintpath(CONFIG["hdrdir"]).quote}
1460
+ arch_hdrdir = #{$arch_hdrdir}
1461
+ VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
1462
+ }
1463
+ if $extmk
1464
+ mk << "RUBYLIB = -\nRUBYOPT = -r$(top_srcdir)/ext/purelib.rb\n"
1465
+ end
1466
+ if destdir = CONFIG["prefix"][$dest_prefix_pattern, 1]
1467
+ mk << "\nDESTDIR = #{destdir}\n"
1468
+ end
1469
+ CONFIG.each do |key, var|
1470
+ next unless /prefix$/ =~ key
1471
+ mk << "#{key} = #{with_destdir(var)}\n"
1472
+ end
1473
+ CONFIG.each do |key, var|
1474
+ next if /^abs_/ =~ key
1475
+ next if /^(?:src|top|hdr)dir$/ =~ key
1476
+ next unless /dir$/ =~ key
1477
+ mk << "#{key} = #{with_destdir(var)}\n"
1478
+ end
1479
+ if !$extmk and !$configure_args.has_key?('--ruby') and
1480
+ sep = config_string('BUILD_FILE_SEPARATOR')
1481
+ sep = ":/=#{sep}"
1482
+ else
1483
+ sep = ""
1484
+ end
1485
+ possible_command = (proc {|s| s if /top_srcdir/ !~ s} unless $extmk)
1486
+ extconf_h = $extconf_h ? "-DRUBY_EXTCONF_H=\\\"$(RUBY_EXTCONF_H)\\\" " : $defs.join(" ") << " "
1487
+ mk << %{
1488
+ CC = #{CONFIG['CC']}
1489
+ CXX = #{CONFIG['CXX']}
1490
+ LIBRUBY = #{CONFIG['LIBRUBY']}
1491
+ LIBRUBY_A = #{CONFIG['LIBRUBY_A']}
1492
+ LIBRUBYARG_SHARED = #$LIBRUBYARG_SHARED
1493
+ LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
1494
+ OUTFLAG = #{OUTFLAG}
1495
+ COUTFLAG = #{COUTFLAG}
1496
+
1497
+ RUBY_EXTCONF_H = #{$extconf_h}
1498
+ cflags = #{CONFIG['cflags']}
1499
+ optflags = #{CONFIG['optflags']}
1500
+ debugflags = #{CONFIG['debugflags']}
1501
+ warnflags = #{CONFIG['warnflags']}
1502
+ CFLAGS = #{$static ? '' : CONFIG['CCDLFLAGS']} #$CFLAGS #$ARCH_FLAG
1503
+ INCFLAGS = -I. #$INCFLAGS
1504
+ DEFS = #{CONFIG['DEFS']}
1505
+ CPPFLAGS = #{extconf_h}#{$CPPFLAGS}
1506
+ CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']}
1507
+ ldflags = #{$LDFLAGS}
1508
+ dldflags = #{$DLDFLAGS}
1509
+ ARCH_FLAG = #{$ARCH_FLAG}
1510
+ DLDFLAGS = $(ldflags) $(dldflags)
1511
+ LDSHARED = #{CONFIG['LDSHARED']}
1512
+ LDSHAREDXX = #{config_string('LDSHAREDXX') || '$(LDSHARED)'}
1513
+ AR = #{CONFIG['AR']}
1514
+ EXEEXT = #{CONFIG['EXEEXT']}
1515
+
1516
+ RUBY_BASE_NAME = #{CONFIG['RUBY_BASE_NAME']}
1517
+ RUBY_INSTALL_NAME = #{CONFIG['RUBY_INSTALL_NAME']}
1518
+ RUBY_SO_NAME = #{CONFIG['RUBY_SO_NAME']}
1519
+ arch = #{CONFIG['arch']}
1520
+ sitearch = #{CONFIG['sitearch']}
1521
+ ruby_version = #{RbConfig::CONFIG['ruby_version']}
1522
+ ruby = #{$ruby}
1523
+ RUBY = $(ruby#{sep})
1524
+ RM = #{config_string('RM', &possible_command) || '$(RUBY) -run -e rm -- -f'}
1525
+ RM_RF = #{'$(RUBY) -run -e rm -- -rf'}
1526
+ RMDIRS = #{config_string('RMDIRS', &possible_command) || '$(RUBY) -run -e rmdir -- -p'}
1527
+ MAKEDIRS = #{config_string('MAKEDIRS', &possible_command) || '@$(RUBY) -run -e mkdir -- -p'}
1528
+ INSTALL = #{config_string('INSTALL', &possible_command) || '@$(RUBY) -run -e install -- -vp'}
1529
+ INSTALL_PROG = #{config_string('INSTALL_PROG') || '$(INSTALL) -m 0755'}
1530
+ INSTALL_DATA = #{config_string('INSTALL_DATA') || '$(INSTALL) -m 0644'}
1531
+ COPY = #{config_string('CP', &possible_command) || '@$(RUBY) -run -e cp -- -v'}
1532
+
1533
+ #### End of system configuration section. ####
1534
+
1535
+ preload = #{defined?($preload) && $preload ? $preload.join(' ') : ''}
1536
+ }
1537
+ if $nmake == ?b
1538
+ mk.each do |x|
1539
+ x.gsub!(/^(MAKEDIRS|INSTALL_(?:PROG|DATA))+\s*=.*\n/) do
1540
+ "!ifndef " + $1 + "\n" +
1541
+ $& +
1542
+ "!endif\n"
1543
+ end
1544
+ end
1545
+ end
1546
+ mk
1547
+ end
1548
+ # :startdoc:
1549
+
1550
+ def dummy_makefile(srcdir)
1551
+ configuration(srcdir) << <<RULES << CLEANINGS
1552
+ CLEANFILES = #{$cleanfiles.join(' ')}
1553
+ DISTCLEANFILES = #{$distcleanfiles.join(' ')}
1554
+
1555
+ all install static install-so install-rb: Makefile
1556
+ .PHONY: all install static install-so install-rb
1557
+ .PHONY: clean clean-so clean-rb
1558
+
1559
+ RULES
1560
+ end
1561
+
1562
+ def depend_rules(depend)
1563
+ suffixes = []
1564
+ depout = []
1565
+ cont = implicit = nil
1566
+ impconv = proc do
1567
+ COMPILE_RULES.each {|rule| depout << (rule % implicit[0]) << implicit[1]}
1568
+ implicit = nil
1569
+ end
1570
+ ruleconv = proc do |line|
1571
+ if implicit
1572
+ if /\A\t/ =~ line
1573
+ implicit[1] << line
1574
+ next
1575
+ else
1576
+ impconv[]
1577
+ end
1578
+ end
1579
+ if m = /\A\.(\w+)\.(\w+)(?:\s*:)/.match(line)
1580
+ suffixes << m[1] << m[2]
1581
+ implicit = [[m[1], m[2]], [m.post_match]]
1582
+ next
1583
+ elsif RULE_SUBST and /\A(?!\s*\w+\s*=)[$\w][^#]*:/ =~ line
1584
+ line.gsub!(%r"(\s)(?!\.)([^$(){}+=:\s\/\\,]+)(?=\s|\z)") {$1 + RULE_SUBST % $2}
1585
+ end
1586
+ depout << line
1587
+ end
1588
+ depend.each_line do |line|
1589
+ line.gsub!(/\.o\b/, ".#{$OBJEXT}")
1590
+ line.gsub!(/\$\((?:hdr|top)dir\)\/config.h/, $config_h)
1591
+ line.gsub!(%r"\$\(hdrdir\)/(?!ruby(?![^:;/\s]))(?=[-\w]+\.h)", '\&ruby/')
1592
+ if $nmake && /\A\s*\$\(RM|COPY\)/ =~ line
1593
+ line.gsub!(%r"[-\w\./]{2,}"){$&.tr("/", "\\")}
1594
+ line.gsub!(/(\$\((?!RM|COPY)[^:)]+)(?=\))/, '\1:/=\\')
1595
+ end
1596
+ if /(?:^|[^\\])(?:\\\\)*\\$/ =~ line
1597
+ (cont ||= []) << line
1598
+ next
1599
+ elsif cont
1600
+ line = (cont << line).join
1601
+ cont = nil
1602
+ end
1603
+ ruleconv.call(line)
1604
+ end
1605
+ if cont
1606
+ ruleconv.call(cont.join)
1607
+ elsif implicit
1608
+ impconv.call
1609
+ end
1610
+ unless suffixes.empty?
1611
+ depout.unshift(".SUFFIXES: ." + suffixes.uniq.join(" .") + "\n\n")
1612
+ end
1613
+ depout.unshift("$(OBJS): $(RUBY_EXTCONF_H)\n\n") if $extconf_h
1614
+ depout.flatten!
1615
+ depout
1616
+ end
1617
+
1618
+ # Generates the Makefile for your extension, passing along any options and
1619
+ # preprocessor constants that you may have generated through other methods.
1620
+ #
1621
+ # The +target+ name should correspond the name of the global function name
1622
+ # defined within your C extension, minus the 'Init_'. For example, if your
1623
+ # C extension is defined as 'Init_foo', then your target would simply be 'foo'.
1624
+ #
1625
+ # If any '/' characters are present in the target name, only the last name
1626
+ # is interpreted as the target name, and the rest are considered toplevel
1627
+ # directory names, and the generated Makefile will be altered accordingly to
1628
+ # follow that directory structure.
1629
+ #
1630
+ # For example, if you pass 'test/foo' as a target name, your extension will
1631
+ # be installed under the 'test' directory. This means that in order to
1632
+ # load the file within a Ruby program later, that directory structure will
1633
+ # have to be followed, e.g. "require 'test/foo'".
1634
+ #
1635
+ # The +srcprefix+ should be used when your source files are not in the same
1636
+ # directory as your build script. This will not only eliminate the need for
1637
+ # you to manually copy the source files into the same directory as your build
1638
+ # script, but it also sets the proper +target_prefix+ in the generated
1639
+ # Makefile.
1640
+ #
1641
+ # Setting the +target_prefix+ will, in turn, install the generated binary in
1642
+ # a directory under your RbConfig::CONFIG['sitearchdir'] that mimics your local
1643
+ # filesystem when you run 'make install'.
1644
+ #
1645
+ # For example, given the following file tree:
1646
+ #
1647
+ # ext/
1648
+ # extconf.rb
1649
+ # test/
1650
+ # foo.c
1651
+ #
1652
+ # And given the following code:
1653
+ #
1654
+ # create_makefile('test/foo', 'test')
1655
+ #
1656
+ # That will set the +target_prefix+ in the generated Makefile to 'test'. That,
1657
+ # in turn, will create the following file tree when installed via the
1658
+ # 'make install' command:
1659
+ #
1660
+ # /path/to/ruby/sitearchdir/test/foo.so
1661
+ #
1662
+ # It is recommended that you use this approach to generate your makefiles,
1663
+ # instead of copying files around manually, because some third party
1664
+ # libraries may depend on the +target_prefix+ being set properly.
1665
+ #
1666
+ # The +srcprefix+ argument can be used to override the default source
1667
+ # directory, i.e. the current directory . It is included as part of the VPATH
1668
+ # and added to the list of INCFLAGS.
1669
+ #
1670
+ def create_makefile(target, srcprefix = nil)
1671
+ $target = target
1672
+ libpath = $DEFLIBPATH|$LIBPATH
1673
+ message "creating Makefile\n"
1674
+ rm_f "conftest*"
1675
+ if CONFIG["DLEXT"] == $OBJEXT
1676
+ for lib in libs = $libs.split
1677
+ lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%)
1678
+ end
1679
+ $defs.push(format("-DEXTLIB='%s'", libs.join(",")))
1680
+ end
1681
+
1682
+ if target.include?('/')
1683
+ target_prefix, target = File.split(target)
1684
+ target_prefix[0,0] = '/'
1685
+ else
1686
+ target_prefix = ""
1687
+ end
1688
+
1689
+ srcprefix ||= "$(srcdir)/#{srcprefix}".chomp('/')
1690
+ RbConfig.expand(srcdir = srcprefix.dup)
1691
+
1692
+ ext = ".#{$OBJEXT}"
1693
+ if not $objs
1694
+ srcs = $srcs || Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
1695
+ objs = srcs.inject(Hash.new {[]}) {|h, f| h[File.basename(f, ".*") << ext] <<= f; h}
1696
+ $objs = objs.keys
1697
+ unless objs.delete_if {|b, f| f.size == 1}.empty?
1698
+ dups = objs.sort.map {|b, f|
1699
+ "#{b[/.*\./]}{#{f.collect {|n| n[/([^.]+)\z/]}.join(',')}}"
1700
+ }
1701
+ abort "source files duplication - #{dups.join(", ")}"
1702
+ end
1703
+ else
1704
+ $objs.collect! {|o| File.basename(o, ".*") << ext} unless $OBJEXT == "o"
1705
+ srcs = $srcs || $objs.collect {|o| o.chomp(ext) << ".c"}
1706
+ end
1707
+ $srcs = srcs
1708
+
1709
+ target = nil if $objs.empty?
1710
+
1711
+ if target and EXPORT_PREFIX
1712
+ if File.exist?(File.join(srcdir, target + '.def'))
1713
+ deffile = "$(srcdir)/$(TARGET).def"
1714
+ unless EXPORT_PREFIX.empty?
1715
+ makedef = %{-pe "$_.sub!(/^(?=\\w)/,'#{EXPORT_PREFIX}') unless 1../^EXPORTS$/i"}
1716
+ end
1717
+ else
1718
+ makedef = %{-e "puts 'EXPORTS', '#{EXPORT_PREFIX}Init_$(TARGET)'"}
1719
+ end
1720
+ if makedef
1721
+ $cleanfiles << '$(DEFFILE)'
1722
+ origdef = deffile
1723
+ deffile = "$(TARGET)-$(arch).def"
1724
+ end
1725
+ end
1726
+ origdef ||= ''
1727
+
1728
+ if $extout and $INSTALLFILES
1729
+ $cleanfiles.concat($INSTALLFILES.collect {|files, dir|File.join(dir, files.sub(/\A\.\//, ''))})
1730
+ $distcleandirs.concat($INSTALLFILES.collect {|files, dir| dir})
1731
+ end
1732
+
1733
+ if $extmk and not $extconf_h
1734
+ create_header
1735
+ end
1736
+
1737
+ libpath = libpathflag(libpath)
1738
+
1739
+ dllib = target ? "$(TARGET).#{CONFIG['DLEXT']}" : ""
1740
+ staticlib = target ? "$(TARGET).#$LIBEXT" : ""
1741
+ mfile = open("Makefile", "wb")
1742
+ conf = configuration(srcprefix)
1743
+ conf = yield(conf) if block_given?
1744
+ mfile.puts(conf)
1745
+ mfile.print "
1746
+ libpath = #{($DEFLIBPATH|$LIBPATH).join(" ")}
1747
+ LIBPATH = #{libpath}
1748
+ DEFFILE = #{deffile}
1749
+
1750
+ CLEANFILES = #{$cleanfiles.join(' ')}
1751
+ DISTCLEANFILES = #{$distcleanfiles.join(' ')}
1752
+ DISTCLEANDIRS = #{$distcleandirs.join(' ')}
1753
+
1754
+ extout = #{$extout && $extout.quote}
1755
+ extout_prefix = #{$extout_prefix}
1756
+ target_prefix = #{target_prefix}
1757
+ LOCAL_LIBS = #{$LOCAL_LIBS}
1758
+ LIBS = #{$LIBRUBYARG} #{$libs} #{$LIBS}
1759
+ SRCS = #{srcs.collect(&File.method(:basename)).join(' ')}
1760
+ OBJS = #{$objs.join(" ")}
1761
+ TARGET = #{target}
1762
+ DLLIB = #{dllib}
1763
+ EXTSTATIC = #{$static || ""}
1764
+ STATIC_LIB = #{staticlib unless $static.nil?}
1765
+ #{!$extout && defined?($installed_list) ? "INSTALLED_LIST = #{$installed_list}\n" : ""}
1766
+ " #"
1767
+ # TODO: fixme
1768
+ install_dirs.each {|d| mfile.print("%-14s= %s\n" % d) if /^[[:upper:]]/ =~ d[0]}
1769
+ n = ($extout ? '$(RUBYARCHDIR)/' : '') + '$(TARGET)'
1770
+ mfile.print "
1771
+ TARGET_SO = #{($extout ? '$(RUBYARCHDIR)/' : '')}$(DLLIB)
1772
+ CLEANLIBS = #{n}.#{CONFIG['DLEXT']} #{config_string('cleanlibs') {|t| t.gsub(/\$\*/) {n}}}
1773
+ CLEANOBJS = *.#{$OBJEXT} #{config_string('cleanobjs') {|t| t.gsub(/\$\*/, "$(TARGET)#{deffile ? '-$(arch)': ''}")} if target} *.bak
1774
+
1775
+ all: #{$extout ? "install" : target ? "$(DLLIB)" : "Makefile"}
1776
+ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
1777
+ .PHONY: all install static install-so install-rb
1778
+ .PHONY: clean clean-so clean-rb
1779
+ "
1780
+ mfile.print CLEANINGS
1781
+ fsep = config_string('BUILD_FILE_SEPARATOR') {|s| s unless s == "/"}
1782
+ if fsep
1783
+ sep = ":/=#{fsep}"
1784
+ fseprepl = proc {|s|
1785
+ s = s.gsub("/", fsep)
1786
+ s = s.gsub(/(\$\(\w+)(\))/) {$1+sep+$2}
1787
+ s = s.gsub(/(\$\{\w+)(\})/) {$1+sep+$2}
1788
+ }
1789
+ else
1790
+ fseprepl = proc {|s| s}
1791
+ sep = ""
1792
+ end
1793
+ dirs = []
1794
+ mfile.print "install: install-so install-rb\n\n"
1795
+ sodir = (dir = "$(RUBYARCHDIR)").dup
1796
+ mfile.print("install-so: ")
1797
+ if target
1798
+ f = "$(DLLIB)"
1799
+ dest = "#{dir}/#{f}"
1800
+ mfile.puts dir, "install-so: #{dest}"
1801
+ if $extout
1802
+ mfile.print "clean-so::\n"
1803
+ mfile.print "\t@-$(RM) #{fseprepl[dest]}\n"
1804
+ mfile.print "\t@-$(RMDIRS) #{fseprepl[dir]}\n"
1805
+ else
1806
+ mfile.print "#{dest}: #{f}\n\t@-$(MAKEDIRS) $(@D#{sep})\n"
1807
+ mfile.print "\t$(INSTALL_PROG) #{fseprepl[f]} $(@D#{sep})\n"
1808
+ if defined?($installed_list)
1809
+ mfile.print "\t@echo #{dir}/#{File.basename(f)}>>$(INSTALLED_LIST)\n"
1810
+ end
1811
+ end
1812
+ else
1813
+ mfile.puts "Makefile"
1814
+ end
1815
+ mfile.print("install-rb: pre-install-rb install-rb-default\n")
1816
+ mfile.print("install-rb-default: pre-install-rb-default\n")
1817
+ mfile.print("pre-install-rb: Makefile\n")
1818
+ mfile.print("pre-install-rb-default: Makefile\n")
1819
+ for sfx, i in [["-default", [["lib/**/*.rb", "$(RUBYLIBDIR)", "lib"]]], ["", $INSTALLFILES]]
1820
+ files = install_files(mfile, i, nil, srcprefix) or next
1821
+ for dir, *files in files
1822
+ unless dirs.include?(dir)
1823
+ dirs << dir
1824
+ mfile.print "pre-install-rb#{sfx}: #{dir}\n"
1825
+ end
1826
+ for f in files
1827
+ dest = "#{dir}/#{File.basename(f)}"
1828
+ mfile.print("install-rb#{sfx}: #{dest}\n")
1829
+ mfile.print("#{dest}: #{f}\n\t@-$(MAKEDIRS) $(@D#{sep})\n")
1830
+ mfile.print("\t$(#{$extout ? 'COPY' : 'INSTALL_DATA'}) #{f} $(@D#{sep})\n")
1831
+ if defined?($installed_list) and !$extout
1832
+ mfile.print("\t@echo #{dest}>>$(INSTALLED_LIST)\n")
1833
+ end
1834
+ if $extout
1835
+ mfile.print("clean-rb#{sfx}::\n")
1836
+ mfile.print("\t@-$(RM) #{fseprepl[dest]}\n")
1837
+ end
1838
+ end
1839
+ end
1840
+ if $extout
1841
+ dirs.uniq!
1842
+ unless dirs.empty?
1843
+ mfile.print("clean-rb#{sfx}::\n")
1844
+ for dir in dirs.sort_by {|d| -d.count('/')}
1845
+ mfile.print("\t@-$(RMDIRS) #{fseprepl[dir]}\n")
1846
+ end
1847
+ end
1848
+ end
1849
+ end
1850
+ dirs.unshift(sodir) if target and !dirs.include?(sodir)
1851
+ dirs.each {|d| mfile.print "#{d}:\n\t$(MAKEDIRS) $@\n"}
1852
+
1853
+ mfile.print <<-SITEINSTALL
1854
+
1855
+ site-install: site-install-so site-install-rb
1856
+ site-install-so: install-so
1857
+ site-install-rb: install-rb
1858
+
1859
+ SITEINSTALL
1860
+
1861
+ return unless target
1862
+
1863
+ mfile.puts SRC_EXT.collect {|e| ".path.#{e} = $(VPATH)"} if $nmake == ?b
1864
+ mfile.print ".SUFFIXES: .#{SRC_EXT.join(' .')} .#{$OBJEXT}\n"
1865
+ mfile.print "\n"
1866
+
1867
+ CXX_EXT.each do |e|
1868
+ COMPILE_RULES.each do |rule|
1869
+ mfile.printf(rule, e, $OBJEXT)
1870
+ mfile.printf("\n\t%s\n\n", COMPILE_CXX)
1871
+ end
1872
+ end
1873
+ %w[c].each do |e|
1874
+ COMPILE_RULES.each do |rule|
1875
+ mfile.printf(rule, e, $OBJEXT)
1876
+ mfile.printf("\n\t%s\n\n", COMPILE_C)
1877
+ end
1878
+ end
1879
+
1880
+ mfile.print "$(RUBYARCHDIR)/" if $extout
1881
+ mfile.print "$(DLLIB): "
1882
+ mfile.print "$(DEFFILE) " if makedef
1883
+ mfile.print "$(OBJS) Makefile\n"
1884
+ mfile.print "\t@-$(RM) $(@#{sep})\n"
1885
+ mfile.print "\t@-$(MAKEDIRS) $(@D)\n" if $extout
1886
+ link_so = LINK_SO.gsub(/^/, "\t")
1887
+ if srcs.any?(&%r"\.(?:#{CXX_EXT.join('|')})\z".method(:===))
1888
+ link_so = link_so.sub(/\bLDSHARED\b/, '\&XX')
1889
+ end
1890
+ mfile.print link_so, "\n\n"
1891
+ unless $static.nil?
1892
+ mfile.print "$(STATIC_LIB): $(OBJS)\n\t@-$(RM) $(@#{sep})\n\t"
1893
+ mfile.print "$(AR) #{config_string('ARFLAGS') || 'cru '}$@ $(OBJS)"
1894
+ config_string('RANLIB') do |ranlib|
1895
+ mfile.print "\n\t@-#{ranlib} $(DLLIB) 2> /dev/null || true"
1896
+ end
1897
+ end
1898
+ mfile.print "\n\n"
1899
+ if makedef
1900
+ mfile.print "$(DEFFILE): #{origdef}\n"
1901
+ mfile.print "\t$(RUBY) #{makedef} #{origdef} > $@\n\n"
1902
+ end
1903
+
1904
+ depend = File.join(srcdir, "depend")
1905
+ if File.exist?(depend)
1906
+ mfile.print("###\n", *depend_rules(File.read(depend)))
1907
+ else
1908
+ headers = %w[$(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h]
1909
+ if RULE_SUBST
1910
+ headers.each {|h| h.sub!(/.*/, &RULE_SUBST.method(:%))}
1911
+ end
1912
+ headers << $config_h
1913
+ headers << '$(RUBY_EXTCONF_H)' if $extconf_h
1914
+ mfile.print "$(OBJS): ", headers.join(' '), "\n"
1915
+ end
1916
+
1917
+ $makefile_created = true
1918
+ ensure
1919
+ mfile.close if mfile
1920
+ end
1921
+
1922
+ # :stopdoc:
1923
+
1924
+ def init_mkmf(config = CONFIG)
1925
+ $makefile_created = false
1926
+ $arg_config = []
1927
+ $enable_shared = config['ENABLE_SHARED'] == 'yes'
1928
+ $defs = []
1929
+ $extconf_h = nil
1930
+ $CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup
1931
+ $ARCH_FLAG = with_config("arch_flag", arg_config("ARCH_FLAG", config["ARCH_FLAG"])).dup
1932
+ $CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", config["CPPFLAGS"])).dup
1933
+ $LDFLAGS = with_config("ldflags", arg_config("LDFLAGS", config["LDFLAGS"])).dup
1934
+ $INCFLAGS = "-I$(arch_hdrdir)"
1935
+ $INCFLAGS << " -I$(hdrdir)/ruby/backward" unless $extmk
1936
+ $INCFLAGS << " -I$(hdrdir) -I$(srcdir)"
1937
+ $DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS", config["DLDFLAGS"])).dup
1938
+ $LIBEXT = config['LIBEXT'].dup
1939
+ $OBJEXT = config["OBJEXT"].dup
1940
+ $LIBS = "#{config['LIBS']} #{config['DLDLIBS']}"
1941
+ $LIBRUBYARG = ""
1942
+ $LIBRUBYARG_STATIC = config['LIBRUBYARG_STATIC']
1943
+ $LIBRUBYARG_SHARED = config['LIBRUBYARG_SHARED']
1944
+ $DEFLIBPATH = [$extmk ? "$(topdir)" : "$(libdir)"]
1945
+ $DEFLIBPATH.unshift(".")
1946
+ $LIBPATH = []
1947
+ $INSTALLFILES = []
1948
+ $NONINSTALLFILES = [/~\z/, /\A#.*#\z/, /\A\.#/, /\.bak\z/i, /\.orig\z/, /\.rej\z/, /\.l[ao]\z/, /\.o\z/]
1949
+ $VPATH = %w[$(srcdir) $(arch_hdrdir)/ruby $(hdrdir)/ruby]
1950
+
1951
+ $objs = nil
1952
+ $srcs = nil
1953
+ $libs = ""
1954
+ if $enable_shared or RbConfig.expand(config["LIBRUBY"].dup) != RbConfig.expand(config["LIBRUBY_A"].dup)
1955
+ $LIBRUBYARG = config['LIBRUBYARG']
1956
+ end
1957
+
1958
+ $LOCAL_LIBS = ""
1959
+
1960
+ $cleanfiles = config_string('CLEANFILES') {|s| Shellwords.shellwords(s)} || []
1961
+ $cleanfiles << "mkmf.log"
1962
+ $distcleanfiles = config_string('DISTCLEANFILES') {|s| Shellwords.shellwords(s)} || []
1963
+ $distcleandirs = config_string('DISTCLEANDIRS') {|s| Shellwords.shellwords(s)} || []
1964
+
1965
+ $extout ||= nil
1966
+ $extout_prefix ||= nil
1967
+
1968
+ $arg_config.clear
1969
+ dir_config("opt")
1970
+ end
1971
+
1972
+ FailedMessage = <<MESSAGE
1973
+ Could not create Makefile due to some reason, probably lack of
1974
+ necessary libraries and/or headers. Check the mkmf.log file for more
1975
+ details. You may need configuration options.
1976
+
1977
+ Provided configuration options:
1978
+ MESSAGE
1979
+
1980
+ # Returns whether or not the Makefile was successfully generated. If not,
1981
+ # the script will abort with an error message.
1982
+ #
1983
+ # Internal use only.
1984
+ #
1985
+ def mkmf_failed(path)
1986
+ unless $makefile_created or File.exist?("Makefile")
1987
+ opts = $arg_config.collect {|t, n| "\t#{t}#{n ? "=#{n}" : ""}\n"}
1988
+ abort "*** #{path} failed ***\n" + FailedMessage + opts.join
1989
+ end
1990
+ end
1991
+
1992
+ # :startdoc:
1993
+
1994
+ init_mkmf
1995
+
1996
+ $make = with_config("make-prog", ENV["MAKE"] || "make")
1997
+ make, = Shellwords.shellwords($make)
1998
+ $nmake = nil
1999
+ case
2000
+ when $mswin
2001
+ $nmake = ?m if /nmake/i =~ make
2002
+ when $bccwin
2003
+ $nmake = ?b if /Borland/i =~ `#{make} -h`
2004
+ end
2005
+
2006
+ RbConfig::CONFIG["srcdir"] = CONFIG["srcdir"] =
2007
+ $srcdir = arg_config("--srcdir", File.dirname($0))
2008
+ $configure_args["--topsrcdir"] ||= $srcdir
2009
+ if $curdir = arg_config("--curdir")
2010
+ RbConfig.expand(curdir = $curdir.dup)
2011
+ else
2012
+ curdir = $curdir = "."
2013
+ end
2014
+ unless File.expand_path(RbConfig::CONFIG["topdir"]) == File.expand_path(curdir)
2015
+ CONFIG["topdir"] = $curdir
2016
+ RbConfig::CONFIG["topdir"] = curdir
2017
+ end
2018
+ $configure_args["--topdir"] ||= $curdir
2019
+ $ruby = arg_config("--ruby", File.join(RbConfig::CONFIG["bindir"], CONFIG["ruby_install_name"]))
2020
+
2021
+ split = Shellwords.method(:shellwords).to_proc
2022
+
2023
+ EXPORT_PREFIX = config_string('EXPORT_PREFIX') {|s| s.strip}
2024
+
2025
+ hdr = ['#include "ruby.h"' "\n"]
2026
+ config_string('COMMON_MACROS') do |s|
2027
+ Shellwords.shellwords(s).each do |w|
2028
+ hdr << "#define " + w.split(/=/, 2).join(" ")
2029
+ end
2030
+ end
2031
+ config_string('COMMON_HEADERS') do |s|
2032
+ Shellwords.shellwords(s).each {|w| hdr << "#include <#{w}>"}
2033
+ end
2034
+ COMMON_HEADERS = hdr.join("\n")
2035
+ COMMON_LIBS = config_string('COMMON_LIBS', &split) || []
2036
+
2037
+ COMPILE_RULES = config_string('COMPILE_RULES', &split) || %w[.%s.%s:]
2038
+ RULE_SUBST = config_string('RULE_SUBST')
2039
+ COMPILE_C = config_string('COMPILE_C') || '$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<'
2040
+ COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<'
2041
+ TRY_LINK = config_string('TRY_LINK') ||
2042
+ "$(CC) #{OUTFLAG}conftest $(INCFLAGS) $(CPPFLAGS) " \
2043
+ "$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
2044
+ LINK_SO = config_string('LINK_SO') ||
2045
+ if CONFIG["DLEXT"] == $OBJEXT
2046
+ "ld $(DLDFLAGS) -r -o $@ $(OBJS)\n"
2047
+ else
2048
+ "$(LDSHARED) #{OUTFLAG}$@ $(OBJS) " \
2049
+ "$(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)"
2050
+ end
2051
+ LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"'
2052
+ RPATHFLAG = config_string('RPATHFLAG') || ''
2053
+ LIBARG = config_string('LIBARG') || '-l%s'
2054
+ MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || 'int main() {return 0;}'
2055
+ UNIVERSAL_INTS = config_string('UNIVERSAL_INTS') {|s| Shellwords.shellwords(s)} ||
2056
+ %w[int short long long\ long]
2057
+
2058
+ sep = config_string('BUILD_FILE_SEPARATOR') {|s| ":/=#{s}" if s != "/"} || ""
2059
+ CLEANINGS = "
2060
+ clean-rb-default::
2061
+ clean-rb::
2062
+ clean-so::
2063
+ clean: clean-so clean-rb-default clean-rb
2064
+ \t\t@-$(RM) $(CLEANLIBS#{sep}) $(CLEANOBJS#{sep}) $(CLEANFILES#{sep})
2065
+
2066
+ distclean-rb-default::
2067
+ distclean-rb::
2068
+ distclean-so::
2069
+ distclean: clean distclean-so distclean-rb-default distclean-rb
2070
+ \t\t@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
2071
+ \t\t@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES#{sep})
2072
+ \t\t@-$(RMDIRS) $(DISTCLEANDIRS#{sep})
2073
+
2074
+ realclean: distclean
2075
+ "
2076
+
2077
+ if not $extmk and /\A(extconf|makefile).rb\z/ =~ File.basename($0)
2078
+ END {mkmf_failed($0)}
2079
+ end