# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=8:sts=4
# $Id$

PortSystem	1.0

name			gnat-gcc
version			4.4.1
revision		0
platforms		darwin
categories		lang
maintainers		krischik
description		The GNU compiler collection with GNAT
long_description	The GNU compiler collection, including front ends for \
			C, C++, Ada, Objective-C, Objective-C++, Java and Fortran95.

homepage		http://gcc.gnu.org/
master_sites	ftp://ftp.funet.fi/pub/mirrors/sources.redhat.com/pub/gcc/releases/gcc-${version}/ \
		ftp://ftp.gwdg.de/pub/linux/gcc/releases/gcc-${version}/ \
		ftp://gcc.ftp.nluug.nl/mirror/languages/gcc/releases/gcc-${version}/ \
		ftp://gcc.gnu.org/pub/gcc/releases/gcc-${version}/ \
		gnu:/gcc/gcc-${version}

set dcore		gcc-core-${version}.tar.bz2
set dada		gcc-ada-${version}.tar.bz2
set dfort		gcc-fortran-${version}.tar.bz2
set dcxx		gcc-g++-${version}.tar.bz2
set djava		gcc-java-${version}.tar.bz2
set dobjc		gcc-objc-${version}.tar.bz2
distfiles		${dcore} ${dada} ${dfort} ${dcxx} ${djava} ${dobjc}

checksums		${dcore} sha1 7e18b5f49b77a78e0ccd31c82c6220c5756da754 \
			${dada}  sha1 796246366a69625a8790eec93130a361f7aa3831 \
			${dfort} sha1 65f729704eecffbcb115a3258c17919665066214 \
			${dcxx} sha1 921c8c18287cabc4c515b4a52c70e445160bd161 \
			${djava} sha1 65492e8e66569ba1cceec7fbc8a3e83dafa549f1 \
			${dobjc} sha1 f99d03177548c94184a8788c1d6eefecbd4b99bc

use_bzip2		yes

# gmp and mpfr are not universal
universal_variant	no

depends_lib		port:gmp port:mpfr port:libiconv port:gcc_select

set major		4.4

worksrcdir		build
dist_subdir		gcc43

pre-configure {
	file mkdir ${worksrcpath}
}

configure.cmd	../gcc-${version}/configure
configure.args	--enable-languages=c,c++,ada,objc,obj-c++,java,fortran \
		--libdir=${prefix}/lib/${name} \
		--includedir=${prefix}/include/${name} \
		--infodir=${prefix}/share/info \
		--mandir=${prefix}/share/man \
		--with-local-prefix=${prefix} \
		--with-system-zlib \
		--disable-nls \
		--program-suffix=-gnat-${major} \
		--with-gxx-include-dir=${prefix}/include/${name}/c++/ \
		--with-gmp=${prefix} \
		--with-mpfr=${prefix}
# do NOT use MacPorts binutils -- they do not work
configure.env-append	AR_FOR_TARGET=/usr/bin/ar \
			AS_FOR_TARGET=/usr/bin/as \
			LD_FOR_TARGET=/usr/bin/ld \
			NM_FOR_TARGET=/usr/bin/nm \
			OBJDUMP_FOR_TARGET=/usr/bin/objdump \
			RANLIB_FOR_TARGET=/usr/bin/ranlib \
			STRIP_FOR_TARGET=/usr/bin/strip
#			LIPO_FOR_TARGET=/usr/bin/lipo

use_parallel_build	yes

destroot.target install install-info-host
# install-info # errors on objc-info files

post-destroot {
	file delete -force ${destroot}${prefix}/share/man/man7 \
		${destroot}${prefix}/share/info
	# install/copy ffitarget.h only if we have it
	if {![catch {set ffitarget.h [glob ${destroot}${prefix}/lib/${name}/gcc/*/${version}/include/ffitarget.h]} result]} {
		file copy ${ffitarget.h} ${destroot}${prefix}/include/${name}/
	}
	# install select file for gcc_select
	xinstall -m 755 -d ${destroot}${prefix}/etc/select/gcc
	xinstall -m 444 ${filespath}/gnat-gcc ${destroot}${prefix}/etc/select/gcc/

    set dest_src_dir	${destroot}${prefix}/src/gnat
    set src_ada_dir	${workpath}/gcc-${version}/gcc/ada
    set src_c_dir	${workpath}/gcc-${version}/gcc
    set target_ada_dir	${workpath}/${worksrcdir}/gcc/ada;

    xinstall -m 775 -d							${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 ali.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 ali.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 alloc.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 atree.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 atree.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 butil.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 butil.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 casing.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 casing.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 csets.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 csets.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 debug.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 debug.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 einfo.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 einfo.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 elists.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 elists.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 err_vars.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 errout.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 errout.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 erroutc.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 erroutc.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 errutil.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 errutil.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 fmap.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 fmap.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 fname.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 fname.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 g-string.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 g-string.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 gnatvsn.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 gnatvsn.ads			${dest_src_dir}
    #xinstall -m 664 -W ${src_ada_dir}	 gprmake.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 hostparm.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 impunit.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 krunch.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 krunch.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 lib-list.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 lib-sort.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 lib.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 lib.ads			${dest_src_dir}
    #xinstall -m 664 -W ${src_ada_dir}	 makegpr.adb			${dest_src_dir}
    #xinstall -m 664 -W ${src_ada_dir}	 makegpr.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 makeutl.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 makeutl.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-fil.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-fil.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-tgt-specific-darwin.adb	${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-tgt-specific-linux.adb	${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-tgt-specific-mingw.adb	${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-tgt-specific.adb		${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-tgt-specific.ads		${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-tgt.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-tgt.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-utl.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib-utl.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 mlib.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 namet.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 namet.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 nlists.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 nlists.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 opt.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 opt.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 osint.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 osint.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 output.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 output.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-attr-pm.adb		${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-attr-pm.ads		${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-attr.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-attr.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-com.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-dect.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-dect.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-env.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-env.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-err.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-err.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-ext.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-ext.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-nmsc.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-nmsc.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-pars.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-pars.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-part.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-part.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-pp.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-pp.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-proc.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-proc.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-strt.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-strt.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-tree.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-tree.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-util.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj-util.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 prj.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 repinfo.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 repinfo.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 rident.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 scans.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 scans.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 scng.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 scng.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sdefault.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sinfo-cn.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sinfo-cn.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sinfo.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sinfo.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sinput-c.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sinput-c.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sinput-p.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sinput-p.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sinput.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 sinput.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 snames.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 snames.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 stand.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 stand.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 stringt.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 stringt.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 style.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 styleg-c.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 styleg-c.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 styleg.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 styleg.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 stylesw.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 stylesw.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 switch-m.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 switch-m.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 switch.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 switch.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 table.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 table.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 targparm.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 targparm.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 tempdir.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 tempdir.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 tree_in.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 tree_in.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 tree_io.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 tree_io.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 types.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 types.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 uintp.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 uintp.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 uname.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 uname.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 urealp.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 urealp.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 widechar.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 widechar.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 g-comlin.ads			${dest_src_dir}
    xinstall -m 664 -W ${src_ada_dir}	 g-comlin.adb			${dest_src_dir}
    xinstall -m 664 -W ${src_c_dir}	 version.c			${dest_src_dir}
    xinstall -m 664 -W ${src_c_dir}	 version.h			${dest_src_dir}
    xinstall -m 664 -W ${target_ada_dir} sdefault.adb			${dest_src_dir}
}

#platform darwin 7 {
#	configure.cflags-append	-force_cpusubtype_ALL
#	confgiure.env	BOOT_CFLAGS="-g -O2 -force_cpusubtype_ALL"
#	build.args-append	XCFLAGS=-force_cpusubtype_ALL
#}

platform powerpc {
	configure.args-append --disable-multilib
}

# odcctools currently do not compile for x64 - move to variant for the time being
variant odcctools \
	description "Use the odcctools instead of the system provided ones - does not work for x64 currently!" {
	depends_lib-append	port:odcctools
	patch {
		reinplace "s|/usr/bin/libtool|${prefix}/bin/odlibtool|g" \
			${workpath}/gcc-${version}/gcc/config/darwin.h
	}
	configure.args-append	--with-as=${prefix}/bin/odas \
				--with-ld=${prefix}/bin/odld \
				--with-ar=${prefix}/bin/odar
}

#variant x86_64										\
	#description "Create an Intel 64 bit compiler." {
	#configure.args-append				\
		#--build=i386-apple-darwin9		\
		#--host=i386-apple-darwin9		\
		#--target=x86_64-apple-darwin9
		##APXSLDFLAGS='-arch x86_64'		\
		##--with-apxs=/usr/sbin/apxs
		##CFLAGS='-arch x86_64'			\
#}

#
# Ada is the only language apart from C which is self hosted - meaning: you need
# an ada compiler to compile ada. hence it is just a variant.
#
variant macada									\
    description "Uses MacAda compiler (http://www.macada.org) to bootstrap!"	{
    set bootprefix /usr/local/ada-4.3
    if {![file executable ${bootprefix}/bin/gnat]} {
        ui_msg "####################################################################"
        ui_msg "#  Ada is self hosted (http://en.wikipedia.org/wiki/Self-hosting)  #"
        ui_msg "#                                                                  #"
        ui_msg "#  Bootstrap compiler not found. Please download and install from  #"
        ui_msg "#  http://www.macada.org                                           #"
        ui_msg "####################################################################"
    }
    configure.cc		${bootprefix}/bin/gcc
    configure.cpp		${bootprefix}/bin/cpp
    configure.cxx		${bootprefix}/bin/g++
    configure.objc		${bootprefix}/bin/gcc
    configure.env-append	PATH=${bootprefix}/bin:$env(PATH)
    configure.env-append	GNATMAKE=${bootprefix}/bin/gnatmake
    configure.env-append	GNATBIND=${bootprefix}/bin/gnatbind
}

variant gnatgpl										\
    description "Uses GNAT/GPL compiler (http://libre.adacore.com) to bootstrap!"	{
    set bootprefix /opt/gnat-2009-x86_64-apple-darwin9.6.0-bin
    if {![file executable ${bootprefix}/bin/gnat]} {
        ui_msg "####################################################################"
        ui_msg "#  Ada is self hosted (http://en.wikipedia.org/wiki/Self-hosting)  #"
        ui_msg "#                                                                  #"
        ui_msg "#  Bootstrap compiler not found. Please download and install from  #"
        ui_msg "#  http://libre.adacore.com                                        #"
        ui_msg "####################################################################"
    }
    configure.cc		${bootprefix}/bin/gcc
    configure.cpp		${bootprefix}/bin/cpp
    configure.cxx		${bootprefix}/bin/g++
    configure.objc		${bootprefix}/bin/gcc
    configure.env-append	PATH=${bootprefix}/bin:$env(PATH)
    configure.env-append	GNATMAKE=${bootprefix}/bin/gnatmake
    configure.env-append	GNATBIND=${bootprefix}/bin/gnatbind
}

variant gnuada											\
    description "Uses the GnuAda (http://gnuada.sourceforge.net/) compiler to bootstrap!"	{
    set bootprefix /opt/local
    if {![file executable ${bootprefix}/bin/gnat]} {
        ui_msg "####################################################################"
        ui_msg "#  Ada is self hosted (http://en.wikipedia.org/wiki/Self-hosting)  #"
        ui_msg "#                                                                  #"
        ui_msg "#  Bootstrap compiler not found. Please download and install from  #"
        ui_msg "#  http://gnuada.sourceforge.net                                   #"
        ui_msg "####################################################################"
    }
    configure.cc		${bootprefix}/bin/gcc-gnat-4.3
    configure.cpp		${bootprefix}/bin/cpp-gnat-4.3
    configure.cxx		${bootprefix}/bin/g++-gnat-4.3
    configure.objc		${bootprefix}/bin/gcc-gnat-4.3
    configure.env-append	PATH=${bootprefix}/bin:$env(PATH)
    configure.env-append	GNATMAKE=${bootprefix}/bin/gnatmake
    configure.env-append	GNATBIND=${bootprefix}/bin/gnatbind
}

variant ada											\
    description "Uses the MacPorts Ada (http://www.macports.org/) compiler to bootstrap!"	{
    if {![file executable ${prefix}/bin/gnat]} {
        ui_msg "####################################################################"
        ui_msg "#  Ada is self hosted (http://en.wikipedia.org/wiki/Self-hosting)  #"
        ui_msg "#                                                                  #"
        ui_msg "#  For the first intital installation you need to choose one       #"
        ui_msg "#  one of the other variants                                       #"
        ui_msg "####################################################################"
    } else {
        ui_msg "######################################################################"
        ui_msg "#  To use this variant you need activate the existing compiler with: #"
        ui_msg "#                                                                    #"
        ui_msg "#  sudo gcc_select gnat-gcc                                          #"
        ui_msg "######################################################################"
    }
    configure.cc		${prefix}/bin/gcc
    configure.cpp		${prefix}/bin/cpp
    configure.cxx		${prefix}/bin/g++
    configure.objc		${prefix}/bin/gcc
    configure.env-append	PATH=${prefix}/bin:$env(PATH)
    configure.env-append	GNATMAKE=${prefix}/bin/gnatmake
    configure.env-append	GNATBIND=${prefix}/bin/gnatbind
}

pre-configure {
    if {![variant_isset macada] &&  ![variant_isset gnatgpl] &&  ![variant_isset gnuada]  &&  ![variant_isset ada]} {
        ui_msg "####################################################################"
        ui_msg "#  Ada is self hosted (http://en.wikipedia.org/wiki/Self-hosting)  #"
        ui_msg "#                                                                  #"
        ui_msg "#  You need to install an existing Ada compiler and then choose    #"
        ui_msg "#  an appropiate variant. For more info use:                       #"
        ui_msg "#                                                                  #"
        ui_msg "#  port variants gnat-gcc                                          #"
        ui_msg "####################################################################"
    }
}

post-activate {
    ui_msg "######################################################"
    ui_msg "#  Remember to activate the compiler with:           #"
    ui_msg "#                                                    #"
    ui_msg "#  sudo gcc_select gnat-gcc                          #"
    ui_msg "######################################################"
}

livecheck.check regex
livecheck.url	http://gcc.gnu.org/gcc-4.4/
livecheck.regex GCC (4\\.4\\.\[0-9\])
