# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 55183 2009-08-07 11:39:54Z snc@macports.org $

PortSystem      1.0

name            guile16
version         1.6.8
revision        3
categories      lang
maintainers     nomaintainer
platforms       darwin

description     GNU's Ubiquitous Intelligent Language for Extension (guile)
long_description    \
        Guile is an interpreter for the Scheme programming    \
        language, packaged for use in a wide variety of        \
        environments. Guile implements Scheme as described in    \
        the Revised^5 Report on the Algorithmic Language Scheme    \
        (usually known as R5RS), providing clean and general    \
        data and control structures.                \
                                    \
        Guile goes beyond the rather austere language presented    \
        in R5RS, extending it with a module system, full access    \
        to POSIX system calls, networking support, multiple    \
        threads, dynamic linking, a foreign function call    \
        interface, powerful string processing, and many other    \
        features needed for programming in the real world.

#bugs        On Apple's darwin, the putenv library function acts    \
#        differently than the GNU version. The patch to        \
#        libguile/posix.c fixes this, so the guile 'putenv'    \
#        function doesn't throw a system error.

#user_notes    You may need to set the environment variable        \
#        DYLD_LIBRARY_PATH to ${prefix}/lib (or wherever    \
#        the guile libraries have been installed) if you want    \
#        to load guile modules from an application linked with    \
#        libguile.  This should only apply to developers using    \
#        guile as an extension language.

homepage        http://www.gnu.org/software/guile/guile.html
master_sites    gnu:guile
distname        guile-${version}

checksums       md5 2756b01f428b910d33267aeaa0e2d59a

patchfiles      patch-scmsigs.c.diff        \
                patch-posix.c.diff        \
                patch-guile.c.diff

depends_lib     port:readline

configure.args  CPPFLAGS="-I${prefix}/include"    \
                LDFLAGS=-L${prefix}/lib        \
                --infodir=${prefix}/share/info    \
                --mandir=${prefix}/share/man

platform darwin {
    configure.args-append    CFLAGS="-no-cpp-precomp -Dmacosx"
}

post-destroot {
    file delete ${destroot}${prefix}/share/${name}/1.6/ice-9/and-let\*.scm
    file delete ${destroot}${prefix}/share/info/goops.info
    file delete ${destroot}${prefix}/share/info/guile-tut.info
    file delete ${destroot}${prefix}/share/info/guile.info
    file delete ${destroot}${prefix}/share/info/guile.info-1
    file delete ${destroot}${prefix}/share/info/guile.info-2
    file delete ${destroot}${prefix}/share/info/guile.info-3
    file delete ${destroot}${prefix}/share/info/guile.info-4
    file delete ${destroot}${prefix}/share/info/r5rs.info
    
    file rename ${destroot}${prefix}/bin/guile ${destroot}${prefix}/bin/${name}
    file rename ${destroot}${prefix}/bin/guile-config ${destroot}${prefix}/bin/${name}-config
    file rename ${destroot}${prefix}/bin/guile-snarf ${destroot}${prefix}/bin/${name}-snarf
    file rename ${destroot}${prefix}/bin/guile-tools ${destroot}${prefix}/bin/${name}-tools

    file rename ${destroot}${prefix}/include/guile ${destroot}${prefix}/include/guile16

    file rename ${destroot}${prefix}/include/libguile ${destroot}${prefix}/include/libguile16
    file rename ${destroot}${prefix}/include/libguile.h ${destroot}${prefix}/include/libguile16.h

    file rename ${destroot}${prefix}/share/aclocal/guile.m4 ${destroot}${prefix}/share/aclocal/guile16.m4

    file rename ${destroot}${prefix}/lib/libguile.a ${destroot}${prefix}/lib/libguile16.a
    file rename ${destroot}${prefix}/lib/libguile.la ${destroot}${prefix}/lib/libguile16.la
    file rename ${destroot}${prefix}/lib/libguile.dylib ${destroot}${prefix}/lib/libguile16.dylib

    reinplace "s|-lguile |-lguile16 |g" ${destroot}${prefix}/bin/guile16-config
    reinplace "s|${prefix}/bin/guile|${prefix}/bin/guile16|g" ${destroot}${prefix}/bin/guile16-config
    reinplace "s|libguile\\.|libguile16\\.|g" ${destroot}${prefix}/lib/libguile16.la
    reinplace "s|libguile.la|libguile16.la|g" ${destroot}${prefix}/lib/libguilereadline-v-12.la
    
    fs-traverse src_file  ${destroot}${prefix}/include/ {
        if { [ file isfile ${src_file} ] } {
            reinplace "s|\\<guile\\/|\\<guile16\\/|g"   $src_file
            reinplace "s|libguile\\.h|libguile16\\.h|g" $src_file
            reinplace "s|libguile/|libguile16/|g"       $src_file
        }
    }
}

livecheck.regex {guile-(1\.6(?:\.\d+)*)}
