# Template file for 'ocaml'
pkgname=ocaml
_majorver=4.00
version=${_majorver}.0
revision=3
makedepends="gdbm-devel ncurses-devel libX11-devel"
short_desc="The main implementation of the Caml language"
maintainer="davehome <davehome@redthumb.info.tm>"
homepage="http://caml.inria.fr"
license="QPL-1,LGPL-2"
distfiles="${homepage}/pub/distrib/${pkgname}-${_majorver}/${pkgname}-${version}.tar.bz2"
checksum=ec886d7bc587ce472fcbdf294feb4b1fa2d8e7ef78ab6a4e66551699435d5cd7
long_desc="
 Caml is a general-purpose programming language, designed with program safety
 and reliability in mind. It is very expressive, yet easy to learn and use. Caml
 supports functional, imperative, and object-oriented programming styles.

Some features are:
 - A powerful type system, with parametric polymorphism and type inference.
 - User-definable algebraic data types and pattern matching. 
 - Automatic memory management: fast, unobtrusive, incremental GC.
 - A sophisticated module system.
 - Expressive OO layer; multiple inheritance and parametric classes.
 - Efficient native code compilers."

disable_parallel_build=yes

do_configure() {
	./configure -prefix /usr -mandir /usr/share/man
}

do_build() {
	make ${makejobs} world.opt
}

do_install() {
	local compiler_libs=${DESTDIR}/usr/lib/ocaml/compiler-libs

	make PREFIX=${DESTDIR}/usr MANDIR=${DESTDIR}/usr/share/man install

	vinstall LICENSE 644 usr/share/licenses/${pkgname}

	mkdir -pv "${compiler_libs}"/{parsing,typing,utils}
	cp -v parsing/*.{cmi,cmo,cmx,ml,mli,mll,o} "${compiler_libs}"/parsing
	cp -v typing/*.{cmi,cmo,cmx,ml,mli,o} "${compiler_libs}"/typing
	cp -v utils/*.{cmi,cmo,cmx,ml,mli,o} "${compiler_libs}"/utils
}


ocaml-compiler-libs_package() {
	depends="ocaml>=${version}"
	short_desc+=" -- shared libraries"
	pkg_install() {
		vmove usr/lib/ocaml/compiler-libs	
		vinstall ${wrksrc}/LICENSE 644 usr/share/licenses/${pkgname}
		rm -f ${PKGDESTDIR}/usr/lib/ocaml/compiler-libs/typing/outcometree.{cmi,mli}
	}
}

ocaml_package() {
	pkg_install() {
		vmove all
	}
}
