# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           ruby 1.0

# If you update this port, also update the port rb-mini_portile2 to the latest
# compatible with this port.
#
#   ../rb-mini_portile2/Portfile
#
# See https://rubygems.org/gems/nokogiri
ruby.branches       3.3 3.2 3.1 3.0 2.7
ruby.setup          nokogiri 1.16.2 gem
revision            0
maintainers         {kimuraw @kimuraw} \
                    {judaew @judaew} openmaintainer
description         Nokogiri is an HTML, XML, SAX, and Reader parser.
long_description    Nokogiri is an HTML, XML, SAX, and Reader parser. \
                    Among Nokogiri's many features is the ability to search \
                    documents via XPath or CSS3 selectors.
license             MIT
homepage            https://nokogiri.org

checksums           rmd160  8fd487801f14553a8e30f4631622a672c6f7271f \
                    sha256  68922ee5cde27497d995c46f2821957bae961947644eed2822d173daf7567f9c \
                    size    4626944

if {${name} ne ${subport}} {
    depends_extract     port:rb${ruby.suffix}-gem-patch

    post-patch {
        copy ${filespath}/patch-extconf.rb.diff ${worksrcpath}
        reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/patch-extconf.rb.diff
        system -W ${worksrcpath} "${ruby.gem} patch ${ruby.filename}.gem patch-extconf.rb.diff -o ${ruby.filename}.gem -p0"
    }

    depends_lib-append  port:libxml2 \
                        port:libxslt \
                        port:zlib \
                        port:libiconv \
                        port:rb${ruby.suffix}-mini_portile2

    if {${ruby.branch} < 3.3} {
        depends_run-append \
                        port:rb${ruby.suffix}-racc
    }

    destroot.env-append NOKOGIRI_USE_SYSTEM_LIBRARIES=YES
}
