# $Id: Portfile,v 1.18 2006/05/29 05:18:49 mww Exp $

PortSystem 1.0

name			gcc41
version			4.1.1
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, 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.nluug.nl/mirror/languages/gcc/releases/gcc-${version}/ \
				ftp://ftp.gwdg.de/pub/linux/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 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} ${djava} ${dobjc}

checksums		${dcore} sha1 147e12bf96a8d857fda1d43f0d7ea599b89cebf9 \
				${dfort} sha1 27f3aa7554e1ef2eb9cb97adaa9e18086bb05059 \
				${dcxx} sha1 909672543af9a7b88898cd256e25ccd4a9f009b1 \
				${djava} sha1 4a74c8a470fa94c797faf041d71ebd8fa893c4ec \
				${dobjc} sha1 35117f1b355a29732b54e0ec369330ec2f6be9b2

use_bzip2		yes

depends_lib		port:gmp port:mpfr port:libiconv port:odcctools

set major		4.1

worksrcdir		build

pre-configure {
	file mkdir ${worksrcpath}
}

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

build.target	profiledbootstrap

post-destroot {
	cd ${destroot}${prefix}
	file delete -force share/man/man7
	file delete -force share/info
}

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

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 {
	configure.args-append --disable-multilib
	post-destroot {
		system "cd ${destroot}${prefix}/include/${name} && \
			cp ../../lib/${name}/gcc/*/${version}/include/libffi/ffitarget.h ."
	}
}

