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