# $Id: Portfile 54310 2009-07-24 18:54:23Z toby@macports.org $

PortSystem 	1.0

name		swi-prolog-lite
version		5.6.62

categories	lang
maintainers	uva.nl:J.Wielemaker logtalk.org:pmoura
platforms	darwin
description	SWI-Prolog compiler (without extra packages)

long_description	\
		ISO/Edinburgh-style Prolog compiler including modules, 		\
		autoload, libraries, Garbage-collector, stack-expandor,		\
		C/C++-interface, Multiple threads, GNU-readline interface, 	\
		very fast compiler. Including packages clib (Unix process	\
		control, sockets, MIME), cpp (C++ interface), sgml (reading \
		XML/SGML), sgml/RDF (reading RDF into triples), ODBC 		\
		interface and XPCE (Graphics UI toolkit, integrated editor 	\
		(Emacs-clone) and graphical debugger).

homepage	http://www.swi-prolog.org/

master_sites	http://gollem.science.uva.nl/cgi-bin/nph-download/SWI-Prolog/

dist_subdir	swi-prolog

checksums       \
        md5     0305ac720f6d1277bcaf33876570f0d2 \
        sha1    bd87c39f9b87c8f8981507de76b1e46a83380de4 \
        rmd160  7356d072091d363584fd8262a04c30509c018a0a

depends_lib	port:readline

distname	pl-${version}
worksrcdir 	pl-${version}/src

configure.env	\
	LIBRARY_PATH=/usr/lib:${prefix}/lib 	\
	CPATH=/usr/include:${prefix}/include

configure.ldflags

configure.args	\
	--prefix=${prefix}				\
	--mandir=${prefix}/share/man	\
	--disable-gmp \
	--enable-shared

build.env	\
	LIBRARY_PATH=${prefix}/lib	\
	CPATH=/usr/include:${prefix}/include

post-build {
	file mkdir ${workpath}/macosx
	file copy -force -- ${workpath}/pl-${version}/man/macosx/License.html ${workpath}/macosx/
	file copy -force -- ${workpath}/pl-${version}/man/macosx/macosx.html ${workpath}/macosx/
	file copy -force -- ${workpath}/pl-${version}/man/macosx/Welcome.html ${workpath}/macosx/
}

post-pkg {
	set resources ${workpath}/${name}-${version}.pkg/Contents/Resources/
	file copy -force -- ${workpath}/macosx/License.html ${resources}
	file copy -force -- ${workpath}/macosx/macosx.html ${resources}
	file copy -force -- ${workpath}/macosx/Welcome.html ${resources}
	file rename ${resources}/macosx.html ${resources}/ReadMe.html
	file delete -force -- ${resources}/Welcome.rtf
}

post-mpkg {
	set resources ${workpath}/${name}-${version}.mpkg/Contents/Resources/
	file copy -force -- ${workpath}/macosx/License.html ${resources}
	file copy -force -- ${workpath}/macosx/macosx.html ${resources}
	file copy -force -- ${workpath}/macosx/Welcome.html ${resources}
	file rename ${resources}/macosx.html ${resources}/ReadMe.html
	file delete -force -- ${resources}/Welcome.rtf
}

if {![variant_isset st]} {
	default_variants +mt
}

variant st conflicts mt description {Single-threaded} {
	configure.args-append --disable-mt
}

variant mt conflicts st description {Multi-threaded (default)} {
	configure.args-append --enable-mt
}

livecheck.check     regexm
livecheck.url       ${homepage}dl-stable.html
livecheck.regex     "Gzipped tar file holding the sources for version <b>(\\d+\\.\\d+\\.\\d+)"
