# $Id$

PortSystem 1.0
PortGroup   gnustep 1.0

name                gnustep-base
version             1.19.1
revision            3
platforms           darwin
# libs are LGPL, tools are GPL
license             {LGPL-3+ GPL-3+}
maintainers         nomaintainer

description         A library of general-purpose Objective C objects.
long_description \
    The GNUstep Base Library is a library of general-purpose, non-graphical \
    Objective C objects.  For example, it includes classes for strings, \
    object collections, byte streams, typed coders, invocations, \
    notifications, notification dispatchers, moments in time, network ports, \
    remote object messaging support (distributed objects), and event loops. \
    \
    It provides functionality that aims to implement the non-graphical \
    portion of the OpenStep standard (the Foundation library).

checksums           md5     100e433a7e0624a6e4e5727b87e48c82 \
                    sha1    98d1881b44f412432547abd7504ad654dc9f711f \
                    rmd160  056e1d1a40479eddf6cd93b452897896e869733e

depends_lib         port:gnustep-make \
                    port:libxslt \
                    path:lib/libssl.dylib:openssl

universal_variant   no

use_configure       yes
configure.env-append    LIBOBJC=-lobjc-gnu
configure.args-append   --disable-tls

destroot.keepdirs   ${destroot}${prefix}/var/run

pre-extract {
    if { [variant_isset with_docs] &&
            [catch {set ilist [registry_installed ${name}]} result ]            
    } then {
        return -code error "
        
            gnustep-base documentation depends on gnustep-base ...
            You must install gnustep-base before trying to install\
            gnustep-base +with_docs
        "
    }
}

post-patch {
    reinplace "s|CODING-STANDARDS|GS-CODING-STANDARDS|g" \
        ${worksrcpath}/Documentation/GNUmakefile
}

startupitem.create  yes
startupitem.name    gdomap
set my_pid          ${prefix}/var/run/gdomap.pid
startupitem.start   \
    "GNUSTEP_SYSTEM_ROOT=${prefix}/GNUstep/System" \
    "\[ -f \$GNUSTEP_SYSTEM_ROOT/Tools/gdomap \] && \\" \
    "rm -f ${my_pid} && \\" \
    "\$GNUSTEP_SYSTEM_ROOT/Tools/gdomap -p -I ${my_pid}"
startupitem.stop    \
    "\[ -r ${prefix}/var/run/gdomap.pid \] && \\" \
    "kill -9 `cat ${my_pid}` && \\" \
    "rm -f ${my_pid}"


if { ![variant_isset ffcall] } {
    default_variants +ffi
}

variant ffi description conflicts ffcall description {Build with ffi} {
    depends_lib-append port:libffi
    configure.args-append \
        --enable-libffi \
        --with-ffi-include=${prefix}/include/gcc42 \
        --with-ffi-library=${prefix}/lib/gcc42
}

variant ffcall conflicts ffi description {Build with ffcall} {
    depends_lib-append port:ffcall
    configure.args-append \
        --enable-ffcall
}

platform darwin {
    patchfiles-append       patch-SSL-GNUMakefile.diff

    post-destroot {
        set system_dir ${destroot}${prefix}/GNUstep/Local
        move ${system_dir}/Tools/defaults ${system_dir}/Tools/gdefaults
        move ${system_dir}/Library/Documentation/man/man1/defaults.1.gz \
            ${system_dir}/Library/Documentation/man/man1/gdefaults.1.gz
    }
    post-install { 
        ui_msg "
            **** GNUstep 'defaults' tool is renamed 'gdefaults' to avoid\
            overriding Apple's defaults tool. *****
        "
    }
}