# $Id: Portfile 53329 2009-07-03 17:57:01Z erickt@macports.org $

PortSystem		1.0

name 			ocaml
version			3.11.1
set major_vers	[join [lrange [split ${version} .] 0 1] .]
platforms		darwin
maintainers		kallisys.net:pguyot openmaintainer
categories		lang ml
description		Objective Caml is an implementation of the ML language
homepage		http://www.ocaml.org/
master_sites	http://caml.inria.fr/pub/distrib/ocaml-${major_vers}/
checksums       ocaml-${version}.tar.bz2 \
					md5 fe011781f37f6b41fe08e0706969a89e \
					sha1 570feab47b34b29f866ecadcc16153d5a4a4f6a1 \
					rmd160 991147354a85b975a86ce2dffafce669c9338db5 \
				ocaml-3.11-refman.html.tar.gz \
					md5 bfb4ed960974159f4224014a979baf6d \
					sha1 97159cf3d4ea64d0ca03f04997fdfc00982d22b0 \
					rmd160 8d77630ee0c3dcdae1ef142a59eb876271f1c335

long_description \
			Objective Caml is an implementation of the ML language, based on \
			the Caml Light dialect extended with a complete class-based object \
			system	and a powerful module system in the style of Standard ML.

use_bzip2			yes
use_parallel_build	no
universal_variant   no

set doc_distname	${name}-${major_vers}-refman
set docdir			${prefix}/share/doc/${name}-${version}

# Configure.
configure.pre_args	-prefix ${prefix}
configure.args		-no-tk -cc ${configure.cc} -aspp \"${configure.cc} -c\"

# Building.
build.target		world.opt
build.cmd           "unset LD_PREBIND LD_PREBIND_ALLOW_OVERLAP && ${build.cmd}"

# Install.
destroot.target		install
destroot.destdir	BINDIR=${destroot}${prefix}/bin \
					LIBDIR=${destroot}${prefix}/lib/ocaml \
					MANDIR=${destroot}${prefix}/share/man

post-destroot {
	# Change "ld.conf" to remove ${destroot} in paths.
	reinplace "s:${destroot}::g" ${destroot}${prefix}/lib/ocaml/ld.conf
}

# Variants.
variant labltk {
	depends_lib		lib:tcl8.4:tcl lib:tk8.4:tk
	configure.args-delete 	-no-tk
}

variant doc description {Install extra documentation} {
	extract.only        ${distfiles}
	distfiles-append    ${doc_distname}.html.tar.gz

	post-extract {
		system "tar xzvf ${distpath}/${doc_distname}.html.tar.gz -C ${workpath}"
	}

	post-destroot {
		xinstall -d ${destroot}${docdir}
		xinstall -m 0644 -W ${worksrcpath} Changes LICENSE README ${destroot}${docdir}
		xinstall -d ${destroot}${docdir}/html/libref
		eval xinstall -m 0644 [glob ${workpath}/htmlman/libref/*] \
			${destroot}${docdir}/html/libref
		eval xinstall -m 0644 [glob ${workpath}/htmlman/*.*] \
			${destroot}${docdir}/html
	}
}

livecheck.check	regex
livecheck.url	http://caml.inria.fr/news.en.rss
livecheck.regex	"<title>Objective Caml (.*) released"
