# -*- 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           makefile 1.0

name                NetSurf
version             3.11
revision            3
checksums           rmd160  ebc6fd8b80eaa44f67ff2b7c9a178718a7863a20 \
                    sha256  4dea880ff3c2f698bfd62c982b259340f9abcd7f67e6c8eb2b32c61f71644b7b \
                    size    9080781

categories          www
maintainers         {ryandesign @ryandesign} openmaintainer
license             {GPL-2 OpenSSLException}

description         small and fast web browser

long_description    ${name} is a {*}${description}.

homepage            http://www.netsurf-browser.org
master_sites        http://download.netsurf-browser.org/netsurf/releases/source-full/
distname            netsurf-all-${version}

depends_build       port:bison \
                    port:flex \
                    path:bin/pkg-config:pkgconfig

depends_lib         port:curl \
                    port:expat \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:libiconv \
                    port:libjxl \
                    port:libpng \
                    port:libutf8proc \
                    path:lib/libssl.dylib:openssl \
                    port:webp \
                    port:zlib

patchfiles          perl.patch
patchfiles-append   trace.patch

compiler.c_standard 1999

build.target
build.args          BUILD_CC=${configure.cc} \
                    NETSURF_USE_BMP=YES \
                    NETSURF_USE_CURL=YES \
                    NETSURF_USE_DUKTAPE=YES \
                    NETSURF_USE_GIF=YES \
                    NETSURF_USE_HARU_PDF=NO \
                    NETSURF_USE_JPEG=YES \
                    NETSURF_USE_JPEGXL=YES \
                    NETSURF_USE_LIBICONV_PLUG=NO \
                    NETSURF_USE_LIBPNG=YES \
                    NETSURF_USE_NSLOG=YES \
                    NETSURF_USE_NSPSL=YES \
                    NETSURF_USE_NSSVG=YES \
                    NETSURF_USE_OPENSSL=YES \
                    NETSURF_USE_PNG=YES \
                    NETSURF_USE_ROSPRITE=YES \
                    NETSURF_USE_RSVG=NO \
                    NETSURF_USE_UTF8PROC=YES \
                    NETSURF_USE_VIDEO=NO \
                    NETSURF_USE_WEBP=YES \
                    PERL=/usr/bin/perl \
                    TARGET=gtk3 \
                    V=1

destroot.args       {*}${build.args}

platform darwin {
    # https://bugs.netsurf-browser.org/mantis/view.php?id=2815
    configure.cflags-append -D_DARWIN_C_SOURCE
}

variant universal {
    # The build system needs to be told we're building universal so that
    # it adds the -s flag when calling ar. The way to tell it to do that
    # is to set UNIVERSAL to a nonempty value. It expects you to set it
    # to the archs to build for and it sets UNIVERSAL_FLAGS to the -arch
    # flags. We already set the -arch flags so fudge it a bit.
    build.args-append \
                    UNIVERSAL=YES \
                    UNIVERSAL_FLAGS=
}

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     (\[0-9.\]+)[quotemeta ${extract.suffix}]
