# -*- 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 118838 2014-04-11 21:25:34Z devans@macports.org $

PortSystem      1.0

name            devhelp
version         3.8.2
revision        1
license         GPL-2+
set branch      [join [lrange [split ${version} .] 0 1] .]
description     Devhelp is an API documentation browser for GTK+ and GNOME.
long_description \
                Devhelp is an API documentation browser for GTK+ and GNOME. It works \
                natively with gtk-doc (the API reference framework developed for GTK+ \
                and used throughout GNOME for API documentation). If you use gtk-doc \
                with your project, you can use Devhelp to browse the documentation.

maintainers     devans openmaintainer
categories      gnome
platforms       darwin
homepage        https://wiki.gnome.org/Apps/Devhelp
master_sites    gnome:sources/${name}/${branch}/

use_xz          yes

checksums       rmd160  8d855f485742a0bdc766591d36af09bdbea61801 \
                sha256  a245b53824c6f2ff89245ff807bb2140bde74951ea6f1d759a0fd0c6959ca9f7

depends_build   port:pkgconfig \
                port:intltool \
                port:gnome-common \
                port:autoconf \
                port:automake \
                port:libtool

depends_lib     port:desktop-file-utils \
                port:gnome-icon-theme \
                port:gtk3 \
                path:lib/pkgconfig/webkitgtk-3.0.pc:webkit-gtk3

# 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

# use upstream autogen.sh to update m4/intltool.m4 using intltoolize and autoreconf

post-patch {
    xinstall -m 755 ${filespath}/autogen.sh ${worksrcpath}
    copy ${worksrcpath}/libgd/libgd.m4 ${worksrcpath}/m4
}

configure.cmd   ./autogen.sh

configure.args  --with-webkit2=no \
                --disable-schemas-compile

variant python26 conflicts python27 description {Build using Python 2.6} {
    configure.python          ${prefix}/bin/python2.6
    depends_build-append      port:python26
}

variant python27 conflicts python26 description {Build using Python 2.7} {
    configure.python          ${prefix}/bin/python2.7
    depends_build-append      port:python27
}

if {![variant_isset python26]} {
    default_variants +python27
}

post-activate {
    system "${prefix}/bin/gtk-update-icon-cache-3.0 -f -t ${prefix}/share/icons/hicolor"
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
}

livecheck.type  none
