nokogiri 1.11.0.rc4-arm64-darwin

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

Potentially problematic release.


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

Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-DEPENDENCIES.md +1682 -0
  3. data/LICENSE.md +9 -0
  4. data/README.md +200 -0
  5. data/bin/nokogiri +118 -0
  6. data/dependencies.yml +74 -0
  7. data/ext/nokogiri/depend +477 -0
  8. data/ext/nokogiri/extconf.rb +819 -0
  9. data/ext/nokogiri/html_document.c +171 -0
  10. data/ext/nokogiri/html_document.h +10 -0
  11. data/ext/nokogiri/html_element_description.c +279 -0
  12. data/ext/nokogiri/html_element_description.h +10 -0
  13. data/ext/nokogiri/html_entity_lookup.c +32 -0
  14. data/ext/nokogiri/html_entity_lookup.h +8 -0
  15. data/ext/nokogiri/html_sax_parser_context.c +116 -0
  16. data/ext/nokogiri/html_sax_parser_context.h +11 -0
  17. data/ext/nokogiri/html_sax_push_parser.c +87 -0
  18. data/ext/nokogiri/html_sax_push_parser.h +9 -0
  19. data/ext/nokogiri/include/libexslt/exslt.h +102 -0
  20. data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
  21. data/ext/nokogiri/include/libexslt/exsltexports.h +140 -0
  22. data/ext/nokogiri/include/libxml2/libxml/DOCBparser.h +96 -0
  23. data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +306 -0
  24. data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +147 -0
  25. data/ext/nokogiri/include/libxml2/libxml/SAX.h +173 -0
  26. data/ext/nokogiri/include/libxml2/libxml/SAX2.h +178 -0
  27. data/ext/nokogiri/include/libxml2/libxml/c14n.h +126 -0
  28. data/ext/nokogiri/include/libxml2/libxml/catalog.h +182 -0
  29. data/ext/nokogiri/include/libxml2/libxml/chvalid.h +230 -0
  30. data/ext/nokogiri/include/libxml2/libxml/debugXML.h +217 -0
  31. data/ext/nokogiri/include/libxml2/libxml/dict.h +79 -0
  32. data/ext/nokogiri/include/libxml2/libxml/encoding.h +245 -0
  33. data/ext/nokogiri/include/libxml2/libxml/entities.h +151 -0
  34. data/ext/nokogiri/include/libxml2/libxml/globals.h +508 -0
  35. data/ext/nokogiri/include/libxml2/libxml/hash.h +236 -0
  36. data/ext/nokogiri/include/libxml2/libxml/list.h +137 -0
  37. data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +163 -0
  38. data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +81 -0
  39. data/ext/nokogiri/include/libxml2/libxml/parser.h +1241 -0
  40. data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +644 -0
  41. data/ext/nokogiri/include/libxml2/libxml/pattern.h +100 -0
  42. data/ext/nokogiri/include/libxml2/libxml/relaxng.h +217 -0
  43. data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +958 -0
  44. data/ext/nokogiri/include/libxml2/libxml/schematron.h +142 -0
  45. data/ext/nokogiri/include/libxml2/libxml/threads.h +89 -0
  46. data/ext/nokogiri/include/libxml2/libxml/tree.h +1311 -0
  47. data/ext/nokogiri/include/libxml2/libxml/uri.h +94 -0
  48. data/ext/nokogiri/include/libxml2/libxml/valid.h +458 -0
  49. data/ext/nokogiri/include/libxml2/libxml/xinclude.h +129 -0
  50. data/ext/nokogiri/include/libxml2/libxml/xlink.h +189 -0
  51. data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +366 -0
  52. data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +146 -0
  53. data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +945 -0
  54. data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +153 -0
  55. data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +224 -0
  56. data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +57 -0
  57. data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +428 -0
  58. data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +222 -0
  59. data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +88 -0
  60. data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +246 -0
  61. data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +151 -0
  62. data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +140 -0
  63. data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +202 -0
  64. data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +485 -0
  65. data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +488 -0
  66. data/ext/nokogiri/include/libxml2/libxml/xpath.h +566 -0
  67. data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +632 -0
  68. data/ext/nokogiri/include/libxml2/libxml/xpointer.h +114 -0
  69. data/ext/nokogiri/include/libxslt/attributes.h +38 -0
  70. data/ext/nokogiri/include/libxslt/documents.h +93 -0
  71. data/ext/nokogiri/include/libxslt/extensions.h +262 -0
  72. data/ext/nokogiri/include/libxslt/extra.h +72 -0
  73. data/ext/nokogiri/include/libxslt/functions.h +78 -0
  74. data/ext/nokogiri/include/libxslt/imports.h +75 -0
  75. data/ext/nokogiri/include/libxslt/keys.h +53 -0
  76. data/ext/nokogiri/include/libxslt/namespaces.h +68 -0
  77. data/ext/nokogiri/include/libxslt/numbersInternals.h +73 -0
  78. data/ext/nokogiri/include/libxslt/pattern.h +84 -0
  79. data/ext/nokogiri/include/libxslt/preproc.h +43 -0
  80. data/ext/nokogiri/include/libxslt/security.h +104 -0
  81. data/ext/nokogiri/include/libxslt/templates.h +77 -0
  82. data/ext/nokogiri/include/libxslt/transform.h +207 -0
  83. data/ext/nokogiri/include/libxslt/variables.h +118 -0
  84. data/ext/nokogiri/include/libxslt/xslt.h +110 -0
  85. data/ext/nokogiri/include/libxslt/xsltInternals.h +1978 -0
  86. data/ext/nokogiri/include/libxslt/xsltconfig.h +180 -0
  87. data/ext/nokogiri/include/libxslt/xsltexports.h +142 -0
  88. data/ext/nokogiri/include/libxslt/xsltlocale.h +76 -0
  89. data/ext/nokogiri/include/libxslt/xsltutils.h +313 -0
  90. data/ext/nokogiri/nokogiri.c +135 -0
  91. data/ext/nokogiri/nokogiri.h +130 -0
  92. data/ext/nokogiri/xml_attr.c +103 -0
  93. data/ext/nokogiri/xml_attr.h +9 -0
  94. data/ext/nokogiri/xml_attribute_decl.c +70 -0
  95. data/ext/nokogiri/xml_attribute_decl.h +9 -0
  96. data/ext/nokogiri/xml_cdata.c +62 -0
  97. data/ext/nokogiri/xml_cdata.h +9 -0
  98. data/ext/nokogiri/xml_comment.c +69 -0
  99. data/ext/nokogiri/xml_comment.h +9 -0
  100. data/ext/nokogiri/xml_document.c +622 -0
  101. data/ext/nokogiri/xml_document.h +23 -0
  102. data/ext/nokogiri/xml_document_fragment.c +48 -0
  103. data/ext/nokogiri/xml_document_fragment.h +10 -0
  104. data/ext/nokogiri/xml_dtd.c +202 -0
  105. data/ext/nokogiri/xml_dtd.h +10 -0
  106. data/ext/nokogiri/xml_element_content.c +123 -0
  107. data/ext/nokogiri/xml_element_content.h +10 -0
  108. data/ext/nokogiri/xml_element_decl.c +69 -0
  109. data/ext/nokogiri/xml_element_decl.h +9 -0
  110. data/ext/nokogiri/xml_encoding_handler.c +79 -0
  111. data/ext/nokogiri/xml_encoding_handler.h +8 -0
  112. data/ext/nokogiri/xml_entity_decl.c +110 -0
  113. data/ext/nokogiri/xml_entity_decl.h +10 -0
  114. data/ext/nokogiri/xml_entity_reference.c +52 -0
  115. data/ext/nokogiri/xml_entity_reference.h +9 -0
  116. data/ext/nokogiri/xml_io.c +63 -0
  117. data/ext/nokogiri/xml_io.h +11 -0
  118. data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
  119. data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
  120. data/ext/nokogiri/xml_namespace.c +111 -0
  121. data/ext/nokogiri/xml_namespace.h +14 -0
  122. data/ext/nokogiri/xml_node.c +1773 -0
  123. data/ext/nokogiri/xml_node.h +13 -0
  124. data/ext/nokogiri/xml_node_set.c +486 -0
  125. data/ext/nokogiri/xml_node_set.h +12 -0
  126. data/ext/nokogiri/xml_processing_instruction.c +56 -0
  127. data/ext/nokogiri/xml_processing_instruction.h +9 -0
  128. data/ext/nokogiri/xml_reader.c +657 -0
  129. data/ext/nokogiri/xml_reader.h +10 -0
  130. data/ext/nokogiri/xml_relax_ng.c +179 -0
  131. data/ext/nokogiri/xml_relax_ng.h +9 -0
  132. data/ext/nokogiri/xml_sax_parser.c +305 -0
  133. data/ext/nokogiri/xml_sax_parser.h +39 -0
  134. data/ext/nokogiri/xml_sax_parser_context.c +262 -0
  135. data/ext/nokogiri/xml_sax_parser_context.h +10 -0
  136. data/ext/nokogiri/xml_sax_push_parser.c +159 -0
  137. data/ext/nokogiri/xml_sax_push_parser.h +9 -0
  138. data/ext/nokogiri/xml_schema.c +276 -0
  139. data/ext/nokogiri/xml_schema.h +9 -0
  140. data/ext/nokogiri/xml_syntax_error.c +64 -0
  141. data/ext/nokogiri/xml_syntax_error.h +13 -0
  142. data/ext/nokogiri/xml_text.c +52 -0
  143. data/ext/nokogiri/xml_text.h +9 -0
  144. data/ext/nokogiri/xml_xpath_context.c +374 -0
  145. data/ext/nokogiri/xml_xpath_context.h +10 -0
  146. data/ext/nokogiri/xslt_stylesheet.c +263 -0
  147. data/ext/nokogiri/xslt_stylesheet.h +14 -0
  148. data/lib/nokogiri.rb +127 -0
  149. data/lib/nokogiri/2.5/nokogiri.bundle +0 -0
  150. data/lib/nokogiri/2.6/nokogiri.bundle +0 -0
  151. data/lib/nokogiri/2.7/nokogiri.bundle +0 -0
  152. data/lib/nokogiri/3.0/nokogiri.bundle +0 -0
  153. data/lib/nokogiri/css.rb +28 -0
  154. data/lib/nokogiri/css/node.rb +53 -0
  155. data/lib/nokogiri/css/parser.rb +751 -0
  156. data/lib/nokogiri/css/parser.y +272 -0
  157. data/lib/nokogiri/css/parser_extras.rb +94 -0
  158. data/lib/nokogiri/css/syntax_error.rb +8 -0
  159. data/lib/nokogiri/css/tokenizer.rb +154 -0
  160. data/lib/nokogiri/css/tokenizer.rex +55 -0
  161. data/lib/nokogiri/css/xpath_visitor.rb +260 -0
  162. data/lib/nokogiri/decorators/slop.rb +43 -0
  163. data/lib/nokogiri/html.rb +38 -0
  164. data/lib/nokogiri/html/builder.rb +36 -0
  165. data/lib/nokogiri/html/document.rb +322 -0
  166. data/lib/nokogiri/html/document_fragment.rb +50 -0
  167. data/lib/nokogiri/html/element_description.rb +24 -0
  168. data/lib/nokogiri/html/element_description_defaults.rb +672 -0
  169. data/lib/nokogiri/html/entity_lookup.rb +14 -0
  170. data/lib/nokogiri/html/sax/parser.rb +63 -0
  171. data/lib/nokogiri/html/sax/parser_context.rb +17 -0
  172. data/lib/nokogiri/html/sax/push_parser.rb +37 -0
  173. data/lib/nokogiri/jruby/dependencies.rb +20 -0
  174. data/lib/nokogiri/syntax_error.rb +5 -0
  175. data/lib/nokogiri/version.rb +3 -0
  176. data/lib/nokogiri/version/constant.rb +5 -0
  177. data/lib/nokogiri/version/info.rb +182 -0
  178. data/lib/nokogiri/xml.rb +76 -0
  179. data/lib/nokogiri/xml/attr.rb +15 -0
  180. data/lib/nokogiri/xml/attribute_decl.rb +19 -0
  181. data/lib/nokogiri/xml/builder.rb +447 -0
  182. data/lib/nokogiri/xml/cdata.rb +12 -0
  183. data/lib/nokogiri/xml/character_data.rb +8 -0
  184. data/lib/nokogiri/xml/document.rb +290 -0
  185. data/lib/nokogiri/xml/document_fragment.rb +159 -0
  186. data/lib/nokogiri/xml/dtd.rb +33 -0
  187. data/lib/nokogiri/xml/element_content.rb +37 -0
  188. data/lib/nokogiri/xml/element_decl.rb +14 -0
  189. data/lib/nokogiri/xml/entity_decl.rb +20 -0
  190. data/lib/nokogiri/xml/entity_reference.rb +19 -0
  191. data/lib/nokogiri/xml/namespace.rb +14 -0
  192. data/lib/nokogiri/xml/node.rb +1240 -0
  193. data/lib/nokogiri/xml/node/save_options.rb +62 -0
  194. data/lib/nokogiri/xml/node_set.rb +372 -0
  195. data/lib/nokogiri/xml/notation.rb +7 -0
  196. data/lib/nokogiri/xml/parse_options.rb +127 -0
  197. data/lib/nokogiri/xml/pp.rb +3 -0
  198. data/lib/nokogiri/xml/pp/character_data.rb +19 -0
  199. data/lib/nokogiri/xml/pp/node.rb +57 -0
  200. data/lib/nokogiri/xml/processing_instruction.rb +9 -0
  201. data/lib/nokogiri/xml/reader.rb +116 -0
  202. data/lib/nokogiri/xml/relax_ng.rb +37 -0
  203. data/lib/nokogiri/xml/sax.rb +5 -0
  204. data/lib/nokogiri/xml/sax/document.rb +172 -0
  205. data/lib/nokogiri/xml/sax/parser.rb +123 -0
  206. data/lib/nokogiri/xml/sax/parser_context.rb +17 -0
  207. data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
  208. data/lib/nokogiri/xml/schema.rb +72 -0
  209. data/lib/nokogiri/xml/searchable.rb +239 -0
  210. data/lib/nokogiri/xml/syntax_error.rb +71 -0
  211. data/lib/nokogiri/xml/text.rb +10 -0
  212. data/lib/nokogiri/xml/xpath.rb +11 -0
  213. data/lib/nokogiri/xml/xpath/syntax_error.rb +12 -0
  214. data/lib/nokogiri/xml/xpath_context.rb +17 -0
  215. data/lib/nokogiri/xslt.rb +57 -0
  216. data/lib/nokogiri/xslt/stylesheet.rb +26 -0
  217. data/lib/xsd/xmlparser/nokogiri.rb +103 -0
  218. metadata +565 -0
@@ -0,0 +1,819 @@
1
+ # :stopdoc:
2
+ ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
3
+
4
+ require "mkmf"
5
+ require "rbconfig"
6
+ require "fileutils"
7
+ require "shellwords"
8
+ require "pathname"
9
+
10
+ #
11
+ # helpful constants
12
+ #
13
+ PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
14
+ REQUIRED_LIBXML_VERSION = "2.6.21"
15
+ RECOMMENDED_LIBXML_VERSION = "2.9.3"
16
+
17
+ # The gem version constraint in the Rakefile is not respected at install time.
18
+ # Keep this version in sync with the one in the Rakefile !
19
+ REQUIRED_MINI_PORTILE_VERSION = "~> 2.5.0"
20
+ REQUIRED_PKG_CONFIG_VERSION = "~> 1.1"
21
+
22
+ # Keep track of what versions of what libraries we build against
23
+ OTHER_LIBRARY_VERSIONS = {}
24
+
25
+ NOKOGIRI_HELP_MESSAGE = <<~HELP
26
+ USAGE: ruby #{$0} [options]
27
+
28
+ Flags that are always valid:
29
+
30
+ --use-system-libraries
31
+ Use system libraries instead of building and using the packaged libraries
32
+
33
+ --disable-clean
34
+ Do not clean out intermediate files after successful build
35
+
36
+
37
+ Flags only used when using system libraries:
38
+
39
+ --with-opt-dir=DIRECTORY
40
+ Look for headers and libraries in DIRECTORY
41
+
42
+ --with-zlib-dir=DIR
43
+ Look for zlib header and library in DIRECTORY
44
+
45
+ --with-iconv-dir=DIRECTORY
46
+ Look for iconv header and library in DIRECTORY
47
+
48
+ --with-xml2-dir=DIRECTORY
49
+ Look for xml2 headers and library in DIRECTORY
50
+
51
+ --with-xml2-lib=DIRECTORY
52
+ Look for xml2 library in DIRECTORY
53
+
54
+ --with-xslt-include=DIRECTORY
55
+ Look for xslt headers in DIRECTORY
56
+
57
+ --with-xslt-dir=DIRECTORY
58
+ Look for xslt headers and library in DIRECTORY
59
+
60
+ --with-xslt-lib=DIRECTORY
61
+ Look for xslt library in DIRECTORY
62
+
63
+ --with-xslt-include=DIRECTORY
64
+ Look for xslt headers in DIRECTORY
65
+
66
+ --with-exslt-dir=DIRECTORY
67
+ Look for exslt headers and library in DIRECTORY
68
+
69
+ --with-exslt-lib=DIRECTORY
70
+ Look for exslt library in DIRECTORY
71
+
72
+ --with-exslt-include=DIRECTORY
73
+ Look for exslt headers in DIRECTORY
74
+
75
+
76
+ Flags only used when building and using the packaged libraries:
77
+
78
+ --disable-static
79
+ Do not statically link packaged libraries, instead use shared libraries
80
+
81
+ --enable-cross-build
82
+ Enable cross-build mode. (You probably do not want to set this manually.)
83
+
84
+ Environment variables used:
85
+
86
+ NOKOGIRI_USE_SYSTEM_LIBRARIES
87
+ When set, even if nil or blank, use system libraries instead of building and using the
88
+ packaged libraries. Equivalent to `--use-system-libraries`.
89
+
90
+ CC
91
+ Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
92
+
93
+ CPPFLAGS
94
+ If this string is accepted by the C preprocessor, add it to the flags passed to the C preprocessor
95
+
96
+ CFLAGS
97
+ If this string is accepted by the compiler, add it to the flags passed to the compiler
98
+
99
+ LDFLAGS
100
+ If this string is accepted by the linker, add it to the flags passed to the linker
101
+
102
+ LIBS
103
+ Add this string to the flags passed to the linker
104
+ HELP
105
+
106
+ #
107
+ # utility functions
108
+ #
109
+ def windows?
110
+ RbConfig::CONFIG['target_os'] =~ /mingw32|mswin/
111
+ end
112
+
113
+ def solaris?
114
+ RbConfig::CONFIG['target_os'] =~ /solaris/
115
+ end
116
+
117
+ def darwin?
118
+ RbConfig::CONFIG['target_os'] =~ /darwin/
119
+ end
120
+
121
+ def openbsd?
122
+ RbConfig::CONFIG['target_os'] =~ /openbsd/
123
+ end
124
+
125
+ def aix?
126
+ RbConfig::CONFIG["target_os"] =~ /aix/
127
+ end
128
+
129
+ def nix?
130
+ ! (windows? || solaris? || darwin?)
131
+ end
132
+
133
+ def concat_flags *args
134
+ args.compact.join(" ")
135
+ end
136
+
137
+ def local_have_library(lib, func=nil, headers=nil)
138
+ have_library(lib, func, headers) or have_library("lib#{lib}", func, headers)
139
+ end
140
+
141
+ LOCAL_PACKAGE_RESPONSE = Object.new
142
+ def LOCAL_PACKAGE_RESPONSE.%(package)
143
+ package ? "yes: #{package}" : "no"
144
+ end
145
+
146
+ # wrapper around MakeMakefil#pkg_config and the PKGConfig gem
147
+ def try_package_configuration(pc)
148
+ if !ENV.key?("NOKOGIRI_TEST_PKG_CONFIG_GEM")
149
+ # try MakeMakefile#pkg_config, which uses the system utility `pkg-config`.
150
+ return if checking_for("#{pc} using `pkg_config`", LOCAL_PACKAGE_RESPONSE) do
151
+ pkg_config(pc)
152
+ end
153
+ end
154
+
155
+ # `pkg-config` probably isn't installed, which appears to be the case for lots of freebsd systems.
156
+ # let's fall back to the pkg-config gem, which knows how to parse .pc files, and wrap it with the
157
+ # same logic as MakeMakefile#pkg_config
158
+ begin
159
+ require 'rubygems'
160
+ gem 'pkg-config', REQUIRED_PKG_CONFIG_VERSION
161
+ require 'pkg-config'
162
+
163
+ checking_for("#{pc} using pkg-config gem version #{PKGConfig::VERSION}", LOCAL_PACKAGE_RESPONSE) do
164
+ if PKGConfig.have_package(pc)
165
+ cflags = PKGConfig.cflags(pc)
166
+ ldflags = PKGConfig.libs_only_L(pc)
167
+ libs = PKGConfig.libs_only_l(pc)
168
+
169
+ Logging::message "pkg-config gem found package configuration for %s\n", pc
170
+ Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n", cflags, ldflags, libs
171
+
172
+ [cflags, ldflags, libs]
173
+ end
174
+ end
175
+ rescue LoadError
176
+ message "Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n"
177
+ end
178
+ end
179
+
180
+ # set up mkmf to link against the library if we can find it
181
+ def have_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
182
+ if opt
183
+ dir_config(opt)
184
+ dir_config("opt")
185
+ end
186
+
187
+ # see if we have enough path info to do this without trying any harder
188
+ if !ENV.key?("NOKOGIRI_TEST_PKG_CONFIG")
189
+ return true if local_have_library(lib, func, headers)
190
+ end
191
+
192
+ try_package_configuration(pc) if pc
193
+
194
+ # verify that we can compile and link against the library
195
+ local_have_library(lib, func, headers)
196
+ end
197
+
198
+ def ensure_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
199
+ have_package_configuration(opt: opt, pc: pc, lib: lib, func: func, headers: headers) or
200
+ abort_could_not_find_library(lib)
201
+ end
202
+
203
+ def ensure_func(func, headers=nil)
204
+ have_func(func, headers) or abort_could_not_find_library(lib)
205
+ end
206
+
207
+ def preserving_globals
208
+ values = [$arg_config, $INCFLAGS, $CFLAGS, $CPPFLAGS, $LDFLAGS, $DLDFLAGS, $LIBPATH, $libs].map(&:dup)
209
+ yield
210
+ ensure
211
+ $arg_config, $INCFLAGS, $CFLAGS, $CPPFLAGS, $LDFLAGS, $DLDFLAGS, $LIBPATH, $libs = values
212
+ end
213
+
214
+ def abort_could_not_find_library(lib)
215
+ abort "-----\n#{caller[0]}\n#{lib} is missing. Please locate mkmf.log to investigate how it is failing.\n-----"
216
+ end
217
+
218
+ def chdir_for_build
219
+ # When using rake-compiler-dock on Windows, the underlying Virtualbox shared
220
+ # folders don't support symlinks, but libiconv expects it for a build on
221
+ # Linux. We work around this limitation by using the temp dir for cooking.
222
+ build_dir = ENV['RCD_HOST_RUBY_PLATFORM'].to_s =~ /mingw|mswin|cygwin/ ? '/tmp' : '.'
223
+ Dir.chdir(build_dir) do
224
+ yield
225
+ end
226
+ end
227
+
228
+ def sh_export_path path
229
+ # because libxslt 1.1.29 configure.in uses AC_PATH_TOOL which treats ":"
230
+ # as a $PATH separator, we need to convert windows paths from
231
+ #
232
+ # C:/path/to/foo
233
+ #
234
+ # to
235
+ #
236
+ # /C/path/to/foo
237
+ #
238
+ # which is sh-compatible, in order to find things properly during
239
+ # configuration
240
+ return path if !windows?
241
+
242
+ match = Regexp.new("^([A-Z]):(/.*)").match(path)
243
+ if match && match.length == 3
244
+ return File.join("/", match[1], match[2])
245
+ end
246
+
247
+ path
248
+ end
249
+
250
+ def libflag_to_filename(ldflag)
251
+ case ldflag
252
+ when /\A-l(.+)/
253
+ "lib#{$1}.#{$LIBEXT}"
254
+ end
255
+ end
256
+
257
+ def using_system_libraries?
258
+ # NOTE: TruffleRuby uses this env var as it does not support using static libraries yet.
259
+ arg_config('--use-system-libraries', ENV.key?("NOKOGIRI_USE_SYSTEM_LIBRARIES"))
260
+ end
261
+
262
+ def have_libxml_headers?(version=nil)
263
+ source = if version.nil?
264
+ <<~SRC
265
+ #include <libxml/xmlversion.h>
266
+ SRC
267
+ else
268
+ version_int = sprintf "%d%2.2d%2.2d", *(version.split("."))
269
+ <<~SRC
270
+ #include <libxml/xmlversion.h>
271
+ #if LIBXML_VERSION < #{version_int}
272
+ # error libxml2 is older than #{version}
273
+ #endif
274
+ SRC
275
+ end
276
+
277
+ try_cpp source
278
+ end
279
+
280
+ def try_link_iconv(using = nil)
281
+ checking_for(using ? "iconv using #{using}" : 'iconv') do
282
+ ['', '-liconv'].any? do |opt|
283
+ preserving_globals do
284
+ yield if block_given?
285
+
286
+ try_link(<<~'SRC', opt)
287
+ #include <stdlib.h>
288
+ #include <iconv.h>
289
+ int main(void)
290
+ {
291
+ iconv_t cd = iconv_open("", "");
292
+ iconv(cd, NULL, NULL, NULL, NULL);
293
+ return EXIT_SUCCESS;
294
+ }
295
+ SRC
296
+ end
297
+ end
298
+ end
299
+ end
300
+
301
+ def iconv_configure_flags
302
+ # give --with-iconv-dir and --with-opt-dir first priority
303
+ ["iconv", "opt"].each do |target|
304
+ config = preserving_globals { dir_config(target) }
305
+ if config.any? && try_link_iconv("--with-#{target}-* flags") { dir_config(target) }
306
+ idirs, ldirs = config.map do |dirs|
307
+ Array(dirs).flat_map do |dir|
308
+ dir.split(File::PATH_SEPARATOR)
309
+ end if dirs
310
+ end
311
+
312
+ return [
313
+ '--with-iconv=yes',
314
+ *("CPPFLAGS=#{idirs.map { |dir| '-I' + dir }.join(' ')}" if idirs),
315
+ *("LDFLAGS=#{ldirs.map { |dir| '-L' + dir }.join(' ')}" if ldirs),
316
+ ]
317
+ end
318
+ end
319
+
320
+ if try_link_iconv
321
+ return ['--with-iconv=yes']
322
+ end
323
+
324
+ config = preserving_globals { have_package_configuration('libiconv') }
325
+ if config && try_link_iconv('pkg-config libiconv') { have_package_configuration('libiconv') }
326
+ cflags, ldflags, libs = config
327
+
328
+ return [
329
+ '--with-iconv=yes',
330
+ "CPPFLAGS=#{cflags}",
331
+ "LDFLAGS=#{ldflags}",
332
+ "LIBS=#{libs}",
333
+ ]
334
+ end
335
+
336
+ abort_could_not_find_library "libiconv"
337
+ end
338
+
339
+ def process_recipe(name, version, static_p, cross_p)
340
+ require 'rubygems'
341
+ gem 'mini_portile2', REQUIRED_MINI_PORTILE_VERSION
342
+ require 'mini_portile2'
343
+ message "Using mini_portile version #{MiniPortile::VERSION}\n"
344
+
345
+ if name != "libxml2" && name != "libxslt"
346
+ OTHER_LIBRARY_VERSIONS[name] = version
347
+ end
348
+
349
+ MiniPortile.new(name, version).tap do |recipe|
350
+ recipe.target = File.join(PACKAGE_ROOT_DIR, "ports")
351
+ # Prefer host_alias over host in order to use i586-mingw32msvc as
352
+ # correct compiler prefix for cross build, but use host if not set.
353
+ recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
354
+ recipe.patch_files = Dir[File.join(PACKAGE_ROOT_DIR, "patches", name, "*.patch")].sort
355
+ recipe.configure_options << "--libdir=#{File.join(recipe.path, "lib")}"
356
+
357
+ yield recipe
358
+
359
+ env = Hash.new do |hash, key|
360
+ hash[key] = "#{ENV[key]}" # (ENV[key].dup rescue '')
361
+ end
362
+
363
+ recipe.configure_options.flatten!
364
+
365
+ recipe.configure_options.delete_if do |option|
366
+ case option
367
+ when /\A(\w+)=(.*)\z/
368
+ if env.key?($1)
369
+ env[$1] = concat_flags(env[$1], $2)
370
+ else
371
+ env[$1] = $2
372
+ end
373
+ true
374
+ else
375
+ false
376
+ end
377
+ end
378
+
379
+ if static_p
380
+ recipe.configure_options += [
381
+ "--disable-shared",
382
+ "--enable-static",
383
+ ]
384
+ env["CFLAGS"] = concat_flags(env["CFLAGS"], "-fPIC")
385
+ else
386
+ recipe.configure_options += [
387
+ "--enable-shared",
388
+ "--disable-static",
389
+ ]
390
+ end
391
+
392
+ if cross_p
393
+ recipe.configure_options += [
394
+ "--target=#{recipe.host}",
395
+ "--host=#{recipe.host}",
396
+ ]
397
+ end
398
+
399
+ if RbConfig::CONFIG['target_cpu'] == 'universal'
400
+ %w[CFLAGS LDFLAGS].each do |key|
401
+ unless env[key].include?('-arch')
402
+ env[key] = concat_flags(env[key], RbConfig::CONFIG['ARCH_FLAG'])
403
+ end
404
+ end
405
+ end
406
+
407
+ recipe.configure_options += env.map do |key, value|
408
+ "#{key}=#{value.strip}"
409
+ end
410
+
411
+ checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
412
+ if File.exist?(checkpoint)
413
+ message "Building Nokogiri with a packaged version of #{name}-#{version}.\n"
414
+ else
415
+ message <<~EOM
416
+ ---------- IMPORTANT NOTICE ----------
417
+ Building Nokogiri with a packaged version of #{name}-#{version}.
418
+ Configuration options: #{recipe.configure_options.shelljoin}
419
+ EOM
420
+
421
+ unless recipe.patch_files.empty?
422
+ message "The following patches are being applied:\n"
423
+
424
+ recipe.patch_files.each do |patch|
425
+ message " - %s\n" % File.basename(patch)
426
+ end
427
+ end
428
+
429
+ message <<~EOM
430
+
431
+ The Nokogiri maintainers intend to provide timely security updates, but if
432
+ this is a concern for you and want to use your OS/distro system library
433
+ instead, then abort this installation process and install nokogiri as
434
+ instructed at:
435
+
436
+ https://nokogiri.org/tutorials/installing_nokogiri.html#install-with-system-libraries
437
+
438
+ EOM
439
+
440
+ message <<~EOM if name == 'libxml2'
441
+ Note, however, that nokogiri cannot guarantee compatiblity with every
442
+ version of libxml2 that may be provided by OS/package vendors.
443
+
444
+ EOM
445
+
446
+ chdir_for_build do
447
+ recipe.cook
448
+ end
449
+ FileUtils.touch checkpoint
450
+ end
451
+ recipe.activate
452
+ end
453
+ end
454
+
455
+ def copy_packaged_libraries_headers(to_path:, from_recipes:)
456
+ FileUtils.rm_rf(to_path, secure: true)
457
+ FileUtils.mkdir(to_path)
458
+ from_recipes.each do |recipe|
459
+ FileUtils.cp_r(Dir[File.join(recipe.path, 'include/*')], to_path)
460
+ end
461
+ end
462
+
463
+ def do_help
464
+ print NOKOGIRI_HELP_MESSAGE
465
+ exit! 0
466
+ end
467
+
468
+ def do_clean
469
+ root = Pathname(PACKAGE_ROOT_DIR)
470
+ pwd = Pathname(Dir.pwd)
471
+
472
+ # Skip if this is a development work tree
473
+ unless (root + '.git').exist?
474
+ message "Cleaning files only used during build.\n"
475
+
476
+ # (root + 'tmp') cannot be removed at this stage because
477
+ # nokogiri.so is yet to be copied to lib.
478
+
479
+ # clean the ports build directory
480
+ Pathname.glob(pwd.join('tmp', '*', 'ports')) do |dir|
481
+ FileUtils.rm_rf(dir, verbose: true)
482
+ end
483
+
484
+ if enable_config('static')
485
+ # ports installation can be safely removed if statically linked.
486
+ FileUtils.rm_rf(root + 'ports', verbose: true)
487
+ else
488
+ FileUtils.rm_rf(root + 'ports' + 'archives', verbose: true)
489
+ end
490
+ end
491
+
492
+ exit! 0
493
+ end
494
+
495
+ #
496
+ # main
497
+ #
498
+ do_help if arg_config('--help')
499
+ do_clean if arg_config('--clean')
500
+
501
+ if openbsd? && !using_system_libraries?
502
+ if `#{ENV['CC'] || '/usr/bin/cc'} -v 2>&1` !~ /clang/
503
+ ENV['CC'] ||= find_executable('egcc') or
504
+ abort "Please install gcc 4.9+ from ports using `pkg_add -v gcc`"
505
+ end
506
+ append_cppflags "-I/usr/local/include"
507
+ end
508
+
509
+ if ENV['CC']
510
+ RbConfig::CONFIG['CC'] = RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC']
511
+ end
512
+
513
+ # use same c compiler for libxml and libxslt
514
+ ENV['CC'] = RbConfig::CONFIG['CC']
515
+
516
+ # adopt environment config
517
+ append_cflags(ENV["CFLAGS"].split(/\s+/)) if !ENV["CFLAGS"].nil?
518
+ append_cppflags(ENV["CPPFLAGS"].split(/\s+/)) if !ENV["CPPFLAGS"].nil?
519
+ append_ldflags(ENV["LDFLAGS"].split(/\s+/)) if !ENV["LDFLAGS"].nil?
520
+ $LIBS = concat_flags($LIBS, ENV["LIBS"])
521
+
522
+ append_cflags("-g") # always include debugging information
523
+ append_cflags("-Winline") # we use at least one inline function in the C extension
524
+ append_cflags("-Wmissing-noreturn") # good to have no matter what Ruby was compiled with
525
+ append_cflags("-Wno-error=unused-command-line-argument-hard-error-in-future") if darwin?
526
+ # append_cflags(["-Wcast-qual", "-Wwrite-strings"]) # these tend to be noisy, but on occasion useful during development
527
+
528
+ # Add SDK-specific include path for macOS and brew versions before v2.2.12 (2020-04-08) [#1851, #1801]
529
+ macos_mojave_sdk_include_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2"
530
+ if using_system_libraries? && darwin? && Dir.exist?(macos_mojave_sdk_include_path)
531
+ append_cppflags("-I#{macos_mojave_sdk_include_path}")
532
+ end
533
+
534
+ # Work around a character escaping bug in MSYS by passing an arbitrary double-quoted parameter to gcc.
535
+ # See https://sourceforge.net/p/mingw/bugs/2142
536
+ append_cppflags(' "-Idummypath"') if windows?
537
+
538
+ if using_system_libraries?
539
+ message "Building nokogiri using system libraries.\n"
540
+ ensure_package_configuration(opt: "zlib", pc: "zlib", lib: "z", headers: "zlib.h", func: "gzdopen")
541
+ ensure_package_configuration(opt: "xml2", pc: "libxml-2.0", lib: "xml2", headers: "libxml/parser.h", func: "xmlParseDoc")
542
+ ensure_package_configuration(opt: "xslt", pc: "libxslt", lib: "xslt", headers: "libxslt/xslt.h", func: "xsltParseStylesheetDoc")
543
+ ensure_package_configuration(opt: "exslt", pc: "libexslt", lib: "exslt", headers: "libexslt/exslt.h", func: "exsltFuncRegister")
544
+
545
+ have_libxml_headers?(REQUIRED_LIBXML_VERSION) or
546
+ abort "ERROR: libxml2 version #{REQUIRED_LIBXML_VERSION} or later is required!"
547
+ have_libxml_headers?(RECOMMENDED_LIBXML_VERSION) or
548
+ warn "WARNING: libxml2 version #{RECOMMENDED_LIBXML_VERSION} or later is highly recommended, but proceeding anyway."
549
+
550
+ else
551
+ message "Building nokogiri using packaged libraries.\n"
552
+
553
+ static_p = enable_config("static", true)
554
+ message "Static linking is #{static_p ? "enabled" : "disabled"}.\n"
555
+
556
+ cross_build_p = enable_config("cross-build")
557
+ message "Cross build is #{cross_build_p ? "enabled" : "disabled"}.\n"
558
+
559
+ require 'yaml'
560
+ dependencies = YAML.load_file(File.join(PACKAGE_ROOT_DIR, "dependencies.yml"))
561
+
562
+ dir_config('zlib')
563
+
564
+ if cross_build_p || windows?
565
+ zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
566
+ recipe.files = [{
567
+ url: "http://zlib.net/fossils/#{recipe.name}-#{recipe.version}.tar.gz",
568
+ sha256: dependencies["zlib"]["sha256"]
569
+ }]
570
+ if windows?
571
+ class << recipe
572
+ attr_accessor :cross_build_p
573
+
574
+ def configure
575
+ Dir.chdir work_path do
576
+ mk = File.read 'win32/Makefile.gcc'
577
+ File.open 'win32/Makefile.gcc', 'wb' do |f|
578
+ f.puts "BINARY_PATH = #{path}/bin"
579
+ f.puts "LIBRARY_PATH = #{path}/lib"
580
+ f.puts "INCLUDE_PATH = #{path}/include"
581
+ mk.sub!(/^PREFIX\s*=\s*$/, "PREFIX = #{host}-") if cross_build_p
582
+ f.puts mk
583
+ end
584
+ end
585
+ end
586
+
587
+ def configured?
588
+ Dir.chdir work_path do
589
+ !! (File.read('win32/Makefile.gcc') =~ /^BINARY_PATH/)
590
+ end
591
+ end
592
+
593
+ def compile
594
+ execute "compile", "make -f win32/Makefile.gcc"
595
+ end
596
+
597
+ def install
598
+ execute "install", "make -f win32/Makefile.gcc install"
599
+ end
600
+ end
601
+ recipe.cross_build_p = cross_build_p
602
+ else
603
+ class << recipe
604
+ def configure
605
+ cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
606
+ execute "configure", ["env", "CHOST=#{host}", "CFLAGS=#{cflags}", "./configure", "--static", configure_prefix]
607
+ end
608
+
609
+ def compile
610
+ if host=~/darwin/
611
+ execute "compile", "make AR=#{host}-libtool"
612
+ else
613
+ super
614
+ end
615
+ end
616
+ end
617
+ end
618
+ end
619
+
620
+ unless nix?
621
+ libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"]["version"], static_p, cross_build_p) do |recipe|
622
+ recipe.files = [{
623
+ url: "http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
624
+ sha256: dependencies["libiconv"]["sha256"]
625
+ }]
626
+
627
+ cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
628
+
629
+ recipe.configure_options += [
630
+ "CPPFLAGS=-Wall",
631
+ "CFLAGS=#{cflags}",
632
+ "CXXFLAGS=#{cflags}",
633
+ "LDFLAGS="
634
+ ]
635
+ end
636
+ end
637
+ else
638
+ if darwin? && !have_header('iconv.h')
639
+ abort <<~EOM.chomp
640
+ -----
641
+ The file "iconv.h" is missing in your build environment,
642
+ which means you haven't installed Xcode Command Line Tools properly.
643
+
644
+ To install Command Line Tools, try running `xcode-select --install` on
645
+ terminal and follow the instructions. If it fails, open Xcode.app,
646
+ select from the menu "Xcode" - "Open Developer Tool" - "More Developer
647
+ Tools" to open the developer site, download the installer for your OS
648
+ version and run it.
649
+ -----
650
+ EOM
651
+ end
652
+ end
653
+
654
+ unless windows?
655
+ preserving_globals { local_have_library('z', 'gzdopen', 'zlib.h') } or
656
+ abort 'zlib is missing; necessary for building libxml2'
657
+ end
658
+
659
+ libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"]["version"], static_p, cross_build_p) do |recipe|
660
+ recipe.files = [{
661
+ url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
662
+ sha256: dependencies["libxml2"]["sha256"]
663
+ }]
664
+
665
+ cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
666
+
667
+ if zlib_recipe
668
+ recipe.configure_options << "--with-zlib=#{zlib_recipe.path}"
669
+ cflags = concat_flags(cflags, "-I#{zlib_recipe.path}/include")
670
+ end
671
+
672
+ if libiconv_recipe
673
+ recipe.configure_options << "--with-iconv=#{libiconv_recipe.path}"
674
+ else
675
+ recipe.configure_options += iconv_configure_flags
676
+ end
677
+
678
+ if darwin? && !cross_build_p
679
+ recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
680
+ end
681
+
682
+ recipe.configure_options += [
683
+ "--without-python",
684
+ "--without-readline",
685
+ "--with-c14n",
686
+ "--with-debug",
687
+ "--with-threads",
688
+ "CFLAGS=#{cflags}",
689
+ ]
690
+ end
691
+
692
+ libxslt_recipe = process_recipe("libxslt", dependencies["libxslt"]["version"], static_p, cross_build_p) do |recipe|
693
+ recipe.files = [{
694
+ url: "http://xmlsoft.org/sources/#{recipe.name}-#{recipe.version}.tar.gz",
695
+ sha256: dependencies["libxslt"]["sha256"]
696
+ }]
697
+
698
+ cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
699
+
700
+ if darwin? && !cross_build_p
701
+ recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
702
+ end
703
+
704
+ recipe.configure_options += [
705
+ "--without-python",
706
+ "--without-crypto",
707
+ "--with-debug",
708
+ "--with-libxml-prefix=#{sh_export_path(libxml2_recipe.path)}",
709
+ "CFLAGS=#{cflags}",
710
+ ]
711
+ end
712
+
713
+ append_cppflags("-DNOKOGIRI_PACKAGED_LIBRARIES")
714
+ append_cppflags("-DNOKOGIRI_PRECOMPILED_LIBRARIES") if cross_build_p
715
+
716
+ $LIBPATH = ["#{zlib_recipe.path}/lib"] | $LIBPATH if zlib_recipe
717
+ $LIBPATH = ["#{libiconv_recipe.path}/lib"] | $LIBPATH if libiconv_recipe
718
+
719
+ $libs = $libs.shellsplit.tap do |libs|
720
+ [libxml2_recipe, libxslt_recipe].each do |recipe|
721
+ libname = recipe.name[/\Alib(.+)\z/, 1]
722
+ File.join(recipe.path, "bin", "#{libname}-config").tap do |config|
723
+ # call config scripts explicit with 'sh' for compat with Windows
724
+ $CPPFLAGS = `sh #{config} --cflags`.strip << ' ' << $CPPFLAGS
725
+ `sh #{config} --libs`.strip.shellsplit.each do |arg|
726
+ case arg
727
+ when /\A-L(.+)\z/
728
+ # Prioritize ports' directories
729
+ if $1.start_with?(PACKAGE_ROOT_DIR + '/')
730
+ $LIBPATH = [$1] | $LIBPATH
731
+ else
732
+ $LIBPATH = $LIBPATH | [$1]
733
+ end
734
+ when /\A-l./
735
+ libs.unshift(arg)
736
+ else
737
+ $LDFLAGS << ' ' << arg.shellescape
738
+ end
739
+ end
740
+ end
741
+
742
+ patches_string = recipe.patch_files.map { |path| File.basename(path) }.join(' ')
743
+ append_cppflags(%Q[-DNOKOGIRI_#{recipe.name.upcase}_PATCHES="\\\"#{patches_string}\\\""])
744
+
745
+ case libname
746
+ when 'xml2'
747
+ # xslt-config --libs or pkg-config libxslt --libs does not include
748
+ # -llzma, so we need to add it manually when linking statically.
749
+ if static_p && preserving_globals { local_have_library('lzma') }
750
+ # Add it at the end; GH #988
751
+ libs << '-llzma'
752
+ end
753
+ when 'xslt'
754
+ # xslt-config does not have a flag to emit options including
755
+ # -lexslt, so add it manually.
756
+ libs.unshift('-lexslt')
757
+ end
758
+ end
759
+ end.shelljoin
760
+
761
+ if static_p
762
+ $libs = $libs.shellsplit.map do |arg|
763
+ case arg
764
+ when '-lxml2'
765
+ File.join(libxml2_recipe.path, 'lib', libflag_to_filename(arg))
766
+ when '-lxslt', '-lexslt'
767
+ File.join(libxslt_recipe.path, 'lib', libflag_to_filename(arg))
768
+ else
769
+ arg
770
+ end
771
+ end.shelljoin
772
+ end
773
+
774
+ ensure_func("xmlParseDoc", "libxml/parser.h")
775
+ ensure_func("xsltParseStylesheetDoc", "libxslt/xslt.h")
776
+ ensure_func("exsltFuncRegister", "libexslt/exslt.h")
777
+ end
778
+
779
+ have_func('xmlHasFeature') or abort("xmlHasFeature() is missing.") # introduced in libxml 2.6.21
780
+ have_func('xmlFirstElementChild') # introduced in libxml 2.7.3
781
+ have_func('xmlRelaxNGSetParserStructuredErrors') # introduced in libxml 2.6.24
782
+ have_func('xmlRelaxNGSetValidStructuredErrors') # introduced in libxml 2.6.21
783
+ have_func('xmlSchemaSetValidStructuredErrors') # introduced in libxml 2.6.23
784
+ have_func('xmlSchemaSetParserStructuredErrors') # introduced in libxml 2.6.23
785
+
786
+ have_func('vasprintf')
787
+
788
+ other_library_versions_string = OTHER_LIBRARY_VERSIONS.map { |k,v| [k,v].join(":") }.join(",")
789
+ append_cppflags(%Q[-DNOKOGIRI_OTHER_LIBRARY_VERSIONS="\\\"#{other_library_versions_string}\\\""])
790
+
791
+ unless using_system_libraries?
792
+ if cross_build_p
793
+ # When precompiling native gems, copy packaged libraries' headers to ext/nokogiri/include
794
+ # These are packaged up by the cross-compiling callback in the ExtensionTask
795
+ copy_packaged_libraries_headers(to_path: File.join(PACKAGE_ROOT_DIR, "ext/nokogiri/include"),
796
+ from_recipes: [libxml2_recipe, libxslt_recipe])
797
+ else
798
+ # When compiling during installation, install packaged libraries' header files into ext/nokogiri/include
799
+ copy_packaged_libraries_headers(to_path: "include",
800
+ from_recipes: [libxml2_recipe, libxslt_recipe])
801
+ $INSTALLFILES << ["include/**/*.h", "$(rubylibdir)"]
802
+ end
803
+ end
804
+
805
+ create_makefile('nokogiri/nokogiri')
806
+
807
+ if enable_config('clean', true)
808
+ # Do not clean if run in a development work tree.
809
+ File.open('Makefile', 'at') do |mk|
810
+ mk.print <<~EOF
811
+
812
+ all: clean-ports
813
+ clean-ports: $(DLLIB)
814
+ \t-$(Q)$(RUBY) $(srcdir)/extconf.rb --clean --#{static_p ? 'enable' : 'disable'}-static
815
+ EOF
816
+ end
817
+ end
818
+
819
+ # :startdoc: