# $Id: Portfile 90832 2012-03-15 06:17:44Z jmr@macports.org $

PortSystem 1.0

name            mzscheme
epoch           1
version         4.1.5
revision        3
categories      lang scheme
platforms       darwin
maintainers     nomaintainer
description     MzScheme is an implementation of the Scheme programming language
long_description    ${description}

homepage        http://www.plt-scheme.org/software/mzscheme/
set subdir      ${version}/mz/
master_sites \
  http://download.plt-scheme.org/bundles/${subdir} \
  http://www.eecs.northwestern.edu/plt-scheme/${subdir} \
  http://www.cs.utah.edu/plt/download/${subdir} \
  http://mirror.informatik.uni-tuebingen.de/mirror/plt/${subdir} \
  ftp://infogroep.be/pub/plt/bundles/${subdir} \
  http://gd.tuwien.ac.at/languages/scheme/plt/${subdir} \
  http://russell.cs.bilgi.edu.tr/plt-bundles/${subdir}
distfiles       mz-${version}-src-unix.tgz
checksums           md5     cc8545ac0346776c089da63b9ef1d188 \
                    sha1    54438d051d199bb713453362fa3bc75edef277e4 \
                    rmd160  47362cd4fc0be7b119f60390e51e54865c5c92b8
depends_lib     port:jpeg \
                port:libpng \
                port:libiconv

worksrcdir      mz-${version}/src

patchfiles patch-configure.diff patch-collects-setup-unixstyle-install.ss.diff patch-mzscheme-Makefile.in.diff
patch.dir   ${workpath}/mz-${version}

post-patch {
  reinplace "s|collects|share/mzscheme|g" \
    ${worksrcpath}/mzscheme/src/startup.ss \
    ${worksrcpath}/mzscheme/src/startup.inc
  reinplace "s|~/Library/PLT Scheme/|${prefix}/share/mzscheme/|g" \
    ${worksrcpath}/mzscheme/src/file.c
  reinplace "s|@FRAMEWORK_INSTALL_DIR@|${destroot}${frameworks_dir}|" \
    ${worksrcpath}/mzscheme/Makefile.in
  reinplace "s|-I\$(srcdir)|-iquote \$(srcdir)|g" \
    ${worksrcpath}/foreign/gcc/libffi/include/Makefile.in \
    ${worksrcpath}/foreign/gcc/libffi/Makefile.in \
    ${worksrcpath}/foreign/Makefile.in \
    ${worksrcpath}/Makefile.in \
    ${worksrcpath}/mzscheme/dynsrc/Makefile.in \
    ${worksrcpath}/mzscheme/gc/doc/Makefile.in \
    ${worksrcpath}/mzscheme/gc/include/Makefile.in \
    ${worksrcpath}/mzscheme/gc/Makefile.in \
    ${worksrcpath}/mzscheme/gc2/Makefile.in \
    ${worksrcpath}/mzscheme/Makefile.in \
    ${worksrcpath}/mzscheme/sgc/Makefile.in \
    ${worksrcpath}/mzscheme/src/Makefile.in    
}

configure.args  --enable-libfw

post-destroot {
  ln -s ${frameworks_dir}/PLT_MzScheme.framework/Versions/${version}/PLT_MzScheme \
    ${destroot}${prefix}/lib/libmzscheme.${version}.dylib
  
  system "/usr/bin/install_name_tool -change PLT_MzScheme.framework/Versions/${version}_3m/PLT_MzScheme ${frameworks_dir}/PLT_MzScheme.framework/Versions/${version}_3m/PLT_MzScheme ${destroot}${prefix}/bin/mzscheme"
}

livecheck.type  regex
livecheck.url   http://download.plt-scheme.org/mzscheme/
livecheck.regex {<b>([0-9.]+)</b>}
