# $Id: Portfile 105526 2013-04-23 19:53:21Z ryandesign@macports.org $

PortSystem 1.0
name		gprolog
version		1.4.4

categories	lang
maintainers	logtalk.org:pmoura
platforms	darwin
license		LGPL-3
description	GNU Prolog compiler

long_description	\
		GNU Prolog is a free Prolog compiler with constraint	\
		solving over finite domains developed by Daniel Diaz.	\
		GNU Prolog accepts Prolog+constraint programs and	\
		produces native binaries (like gcc does from a C	\
		source). The obtained executable is then stand-alone.	\
		The size of this executable can be quite small since	\
		GNU Prolog can avoid linking the code of most unused	\
		built-in predicates. The performance of GNU Prolog is	\
		very encouraging (comparable to commercial systems).	\
		Beside native-code compilation, GNU Prolog offers a	\
		classical interactive interpreter (top-level) with a	\
		debugger.

homepage	http://gprolog.inria.fr/
master_sites	http://www.gprolog.org/

checksums	\
	sha1    658b0efa5d916510dcddbbd980d90bc4d43a6e58 \
	rmd160  081ad0e6a2edd47de63db79ab1dc65a0e0d341da

worksrcdir 	${name}-${version}/src

use_parallel_build  	no

patchfiles      cflags.patch

use_autoconf  yes

configure.args \
	--prefix=${destroot}${prefix} \
	--with-install-dir=${prefix}/lib/${name}-${version} \
	--with-examples-dir=${prefix}/share/${name}-${version} \
	--with-doc-dir=${prefix}/share/${name}-${version}

# https://trac.macports.org/ticket/30813
compiler.blacklist-append  clang macports-clang-2.9 macports-clang-3.0 macports-clang-3.1 macports-clang-3.2
compiler.blacklist-append  llvm-gcc-4.2 macports-llvm-gcc-4.2

# TODO: base should do this: http://trac.macports.org/ticket/32542
if {[info exists portconfigure::compiler_name_map(${configure.compiler})]} {
    depends_build-append port:$portconfigure::compiler_name_map(${configure.compiler})

    # base 2.1.x ignores the argument and just use ${configure.compiler}
    if {[portconfigure::arch_flag_supported ${configure.compiler}]} {
        depends_skip_archcheck-append $portconfigure::compiler_name_map(${configure.compiler})
    }

    if {[string match macports-gcc* ${configure.compiler}]} {
        depends_lib-append port:$portconfigure::compiler_name_map(${configure.compiler})
    }
}

post-destroot	{
	foreach cmd {fd2c gplc gprolog hexgplc ma2asm pl2wam wam2ma} {
		system "ln -fs ../lib/${name}-${version}/bin/${cmd} ${destroot}${prefix}/bin/${cmd}"
	}

	file delete -force ${destroot}${prefix}/var
}

package.flat	no

post-pkg {
	set resources ${workpath}/${name}-${version}.pkg/Contents/Resources/
	file copy -force -- ${workpath}/${name}-${version}/COPYING ${resources}/License.txt
	file copy -force -- ${workpath}/${name}-${version}/README ${resources}/ReadMe.txt
}
