# $Id: Portfile,v 1.1 2006/04/29 19:52:55 yves Exp $

PortSystem   1.0
PortGroup   gnustep 1.0

name        gnustep-base
version     1.12.0
revision    1
platforms   darwin
maintainers yves@opendarwin.org

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 e2ab022f8312fbbc1a9cab938edf70c4
depends_lib   port:gnustep-make port:libxslt port:openssl

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

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

use_configure   yes

platform powerpc {
    configure.args-append --with-ffi-include=${prefix}/include/gcc41 \
                          --with-ffi-library=${prefix}/lib/gcc41
}

platform x86 {
    depends_lib-append port:ffcall
}

platform darwin {
    build.args-append    GUI_LIBS=""
    destroot.keepdirs    ${destroot}${prefix}/var/run
    
    post-destroot {
        file rename ${destroot}${prefix}/GNUstep/System/Tools/defaults \
            ${destroot}${prefix}/GNUstep/System/Tools/gdefaults
    }
    post-install { 
        ui_msg "\n\n\
            **** GNUstep 'defaults' tool is renamed 'gdefaults' to avoid\
            overriding Apple's defaults tool. *****\n\n"
    }

    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}"
}

