# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0

name                mosml
version             2.01
revision            2
categories          lang devel ml
platforms           darwin
license             GPL-2+
maintainers         nomaintainer
description         Moscow ML is an implementation of Standard ML (SML)
long_description    Moscow ML is a light-weight implementation of Standard ML \
                    (SML), a strict functional language widely used in teaching \
                    and research. Version 2.01 implements the full SML language, \
                    including SML Modules, and much of the SML Basis Library.

homepage            http://www.itu.dk/people/sestoft/mosml.html
master_sites        http://www.itu.dk/people/sestoft/mosml/
distfiles           mos201src.tar.gz

checksums           rmd160  b2a9582d8c0bfdad2b8a74740e54ab33d3856637 \
                    sha256  9ec5695358a4aa4702d856c026f3cf0bce77275e8d1318fd90d455a44c46edff \
                    size    2314392

patchfiles          patch-src-Makefile.diff \
                    patch-src-Makefile-inc.diff \
                    patch-src-launch-Makefile.diff \
                    patch-src-dynlibs.diff \
                    patch-src-runtime-mosml.c.diff \
                    patch-src-runtime-sys.c.diff

worksrcdir          mosml

post-patch {
    reinplace "s|LD=gcc|LD=${configure.cc}|" ${worksrcpath}/src/Makefile.inc
    reinplace "s|CC=gcc|CC=${configure.cc}|" ${worksrcpath}/src/Makefile.inc
    reinplace "s|CCP=|CPP=${configure.cpp}|" ${worksrcpath}/src/Makefile.inc
}

configure.dir       ${worksrcpath}/src/config
configure.cmd       ./autoconf
configure.pre_args  ${configure.cc}

build.target        world
build.pre_args      -Csrc DESTROOT=${prefix} ${build.target}

destroot.pre_args   -Csrc DESTROOT=${destroot}${prefix} ${destroot.target}
post-destroot {
    system "ln -sf ${prefix}/bin/camlrunm ${destroot}${prefix}/lib/mosml/camlrunm"
}