# $Id: Portfile,v 1.15 2006/03/12 22:21:31 mww Exp $

PortSystem 1.0

name			gcc40
version			4.0.3
platforms		darwin
categories		lang
maintainers		mww@opendarwin.org
description		The GNU compiler collection
long_description	The GNU compiler collection, including front ends for C, \
				C++, Objective-C, Java and Fortran95.

homepage		http://gcc.gnu.org/
master_sites    ftp://gcc.gnu.org/pub/gcc/releases/gcc-${version}/ \
				ftp://ftp.gwdg.de/pub/linux/gcc/releases/gcc-${version}/ \
				gnu:/gcc/gcc-${version}
set dcore		gcc-core-${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} ${dfort} ${dcxx} ${dcxx} ${djava} ${dobjc}

checksums		${dcore} sha1 5aa3e370dddaa485909028120002c3bb21e86be2 \
				${dfort} sha1 02817e904c3387e2d55622004b650d4e0de4fb6b \
				${dcxx} sha1 e6a5e3da93dadc46fb8baa68826afb6dc41b0d88 \
				${djava} sha1 443f55a32f5291331d930363fef026e4935cfa0e \
				${dobjc} sha1 85fbc09865e8ee0a8d61c3f0734fb5fd9f5501b0

use_bzip2		yes

depends_lib		port:gmp port:mpfr

set major		4.0

worksrcdir		build

post-extract {
	file mkdir ${worksrcpath}
}

configure.cmd	${workpath}/gcc-${version}/configure
configure.args	--enable-languages=c,c++,java,objc,f95 \
				--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=-dp-${major} \
				--with-gxx-include-dir=${prefix}/include/${name}/c++/ \
				--with-gmp=${prefix} \
				--with-mpfr=${prefix}

build.target	profiledbootstrap
build.args		-j 2

post-destroot {
	cd ${destroot}${prefix}
	file delete -force share/man/man7
	file delete -force share/info
	if {[variant_isset powerpc]} {
	}
}

platform darwin 7 {
	depends_build	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
}

platform darwin 8 {
	configure.env	CC=/usr/bin/gcc-4.0 CPP=/usr/bin/cpp-4.0 CXX=/usr/bin/g++-4.0
}

platform powerpc {
	post-destroot {
		system "cd ${destroot}${prefix}/include/${name} && \
			cp ../../lib/${name}/gcc/*/${version}/include/libffi/ffitarget.h ."
	}
}

