# -*- 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
# $Id: Portfile 84550 2011-09-27 21:05:11Z snc@macports.org $

PortSystem           1.0

name                 mozart
version              1.4.0
revision            1
set tardate          20080704
set urldate          2008-07-02
categories           lang
platforms            darwin
maintainers	     bfulgham
homepage             http://www.mozart-oz.org
description          Mozart-Oz multiparadigms programming language.
long_description     The Mozart system is a development platform focused on open \
			distributed computing and constraint-based inferrence.  \
			The system provides excellent support for logic and \
			constraint programming, making it an excellent choice \
			for implementing multi-agent systems.  The language has \
			recently been popularized by the book "Concepts, \
			Techniques, and Models of Computer Progamming."

depends_build	     port:gmp port:zlib port:gdbm
#depends_lib          port:emacs
depends_run          bin:wish:tk 

master_sites         ${homepage}/download/mozart-ftp/store/${version}-${urldate}-tar/
distname             ${name}-${version}.${tardate}-src
checksums            md5 d34156dce23a84925f7eae121feb3afe \
                     sha1 5a12a1d66c871f01dc1223aa614d4e0bf7717b3f \
                     rmd160 090c0af3cba9db422c58c37d5fa3e703c8cc82d7

patchfiles           patch-share-bin-oz.in \
                     patch-platform_dss_configure.ac \
                     casts.diff \
                     patch-platform_emulator_Makefile.in

worksrcdir           ${name}-${version}.${tardate}
configure.ldflags
configure.args       --prefix=${prefix}/share/mozart \
                     --enable-modules-static \
                     --disable-contrib-micq

use_autoconf         yes
autoconf.dir         ${worksrcpath}/platform/dss

# endless errors in 64-bit due to casting from pointer to int
supported_archs i386 ppc
# and it doesn't consistently use cxxflags
if {[variant_isset universal]} {
    set archflags ${configure.universal_cxxflags}
} else {
    set archflags ${configure.cxx_archflags}
}
configure.env-append CPU_FLAGS="${archflags}"
eval configure.cxx ${configure.cxx} ${archflags}
configure.args-append --with-cxx="${configure.cxx}"

use_parallel_build no
build.target

destroot.args        PREFIX=${destroot}${prefix}/share/mozart

post-destroot {
	delete ${destroot}${prefix}/share/mozart/cache/x-oz/doc
	file delete -force ${destroot}${prefix}/share/mozart/doc

	xinstall -m 0644 ${filespath}/README.MacPorts ${destroot}${prefix}/share/mozart

	xinstall -d ${destroot}${prefix}/man/man1
	# foreach x [glob ${destroot}${prefix}/share/mozart/doc/man/*.1] { system "ln $x ${destroot}${prefix}/man/man1" }

	reinplace "s|^# OZHOME=.*|OZHOME=${prefix}/share/mozart|" ${destroot}${prefix}/share/mozart/bin/oz
	xinstall -d ${destroot}${prefix}/bin
	foreach x [glob -type {x} ${destroot}${prefix}/share/mozart/bin/*] { system "ln $x ${destroot}${prefix}/bin" }

	file delete -force ${destroot}${prefix}/share/mozart/doc/.htaccess
}
