# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 118891 2014-04-13 23:28:22Z devans@macports.org $

PortSystem      1.0

name            epiphany
version         3.8.2
revision        3
license         GPL-2+
set branch      [join [lrange [split ${version} .] 0 1] .]
description     A GNOME Web browser.
long_description \
                A web browser is more than an application, it is a \
                way of thinking, it is a way of seeing the world. \
                Epiphany's principles are simplicity and standards \
                compliance.
maintainers     devans openmaintainer
categories      gnome www
platforms       darwin
homepage        https://wiki.gnome.org/Apps/Web
master_sites    gnome:sources/${name}/${branch}/

use_xz          yes

checksums       rmd160  2aacd8b02f456e345b9f23ff6114d341bbf0013a \
                sha256  ae89d6902ed243304d2cbf2fa361f6dd0cb3401fdaf726e6fdd4acc09197d50a

depends_build   port:pkgconfig \
                port:intltool \
                port:gnome-common

depends_lib     port:desktop-file-utils \
                port:gnome-icon-theme \
                port:gnome-icon-theme-symbolic \
                port:gtk3 \
                path:lib/pkgconfig/webkitgtk-3.0.pc:webkit-gtk3 \
                port:gnome-desktop \
                port:libxslt\
                port:libsoup \
                port:libsecret \
                port:port:libnotify \
                port:libwnck3 \
                port:gsettings-desktop-schemas \
                port:nss \
                port:sqlite3 \
                port:gcr \
                port:avahi \
                port:xorg-libX11 \
                port:iso-codes

depends_run     port:gnome-settings-daemon

# TODO: Check ${configure.cxx_stdlib} directly once MacPorts 2.3 is released
platform darwin {
    set cxxstdlib {}

    if {[info exists configure.cxx_stdlib] &&
        ${configure.cxx_stdlib} ne {} &&
        [string match *clang* ${configure.cxx}]} {
        set cxxstdlib ${configure.cxx_stdlib}
    } elseif {[string match *clang* ${configure.cxx}] &&
              ${os.major} >= 13} {
        set cxxstdlib libc++
    } else {
        set cxxstdlib libstdc++
    }

    if {${cxxstdlib} eq "libstdc++"} {
       depends_lib-delete path:lib/pkgconfig/webkitgtk-3.0.pc:webkit-gtk3
       depends_lib-append path:lib/pkgconfig/webkitgtk-3.0.pc:webkit-gtk3-2.0
    }
}

patchfiles      patch-configure.ac.diff

# update m4/intltool.m4 and autoreconf

pre-configure {
    copy -force ${prefix}/share/aclocal/intltool.m4 ${worksrcpath}/m4
    reinplace "s|--rpath=|-rpath |g" ${worksrcpath}/configure.ac
}

use_autoreconf      yes
autoreconf.args     -fvi

configure.cflags-append -Wno-format-nonliteral

configure.args  --with-distributor-name=MacPorts \
                --disable-schemas-compile \
                --disable-tests

post-activate {
    system "${prefix}/bin/update-desktop-database -q ${prefix}/share/applications"
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
}

#
# nss is not universal
#

if {[variant_isset universal]} {
    configure.args-append --disable-nss
    depends_lib-delete port:nss
}

# this is the last version that will build on darwin < 13

livecheck.type  none
