# $Id$

PortSystem          1.0

name                ocaml-json-wheel
version             1.0.6
revision            6
categories          devel ml
license             BSD
maintainers         mww openmaintainer
description         JSON parsing library for OCaml
long_description    Implements RFC4627 for parsing the JSON interchange format.\
                    Uses key/value pairs to represent objects, and lists to \
                    represent JSON arrays.  Also provides pretty-print support.
homepage            http://martin.jambon.free.fr/json-wheel.html
platforms           darwin
master_sites        http://martin.jambon.free.fr/

distname            json-wheel-${version}
use_bzip2           yes

checksums           md5 8685ecee7a7416c77c14fbdf05c5a06e \
                    sha1 dea8a5b3bd580c39f3cfb3139aeca4fef653aa31 \
                    rmd160 cd31f74e67c4241dbb3e3b792440d02ea45b739b

depends_lib         port:ocaml \
                    port:ocaml-findlib \
                    port:ocaml-ocamlnet

use_configure       no
use_parallel_build  no
destroot.env-append BINDIR=${destroot}${prefix}/bin

livecheck.type      regex
livecheck.url       http://martin.jambon.free.fr/json-wheel.html
livecheck.regex     {>json-wheel-(.*)\.tar\.gz}

post-patch {
    set ocaml_site_path [exec ocamlfind printconf destdir]
    reinplace       "s|\$(OCAMLFIND) install|\$(OCAMLFIND) install -destdir ${destroot}/${ocaml_site_path}|g" \
                    ${worksrcpath}/Makefile
}

build.target        all opt

pre-destroot {
    set ocaml_site_path [exec ocamlfind printconf destdir]
    file mkdir ${destroot}${ocaml_site_path}/stublibs
    destroot.args DESTDIR="${destroot}" OCAMLFIND_DESTDIR="${destroot}${ocaml_site_path}"
}

pre-activate {
    # caml-json-wheel 1.0.6_0 installed an item in ${prefix}/bin; remove it if found
    set filepath ${prefix}/bin/jsoncat
    if {[file exists ${filepath}] && [registry_file_registered ${filepath}] == "0"} {
        if {[catch {delete ${filepath}}]} {
            ui_warn "Cannot delete ${filepath}; please remove it manually"
        }
    }
}