# $Id: Portfile,v 1.10 2006/05/30 16:34:07 mww Exp $

PortSystem 1.0

name			gcc42
version			4.2-20060311
revision		1
platforms		darwin
categories		lang
maintainers		mww@opendarwin.org
description		The GNU compiler collection, prerelease BETA
long_description	The GNU compiler collection, including front ends for C, \
				C++, Objective-C, Objective-C++, Java and Fortran95, \
				prerelease BETA version.

homepage		http://gcc.gnu.org/
master_sites    ftp://ftp.funet.fi/pub/mirrors/sources.redhat.com/pub/gcc/snapshots/${version}/ \
				ftp://ftp.gwdg.de/pub/linux/gcc/snapshots/${version}/ \
				ftp://gcc.gnu.org/pub/gcc/snapshots/${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 371b2b0a7b7fd97fd75473d0bbdd3cb9d4cbeaa7 \
				${dfort} sha1 30588798e23613ba8b576fbb64642eaf58df82e3 \
				${dcxx} sha1 b1ea6e8f1329bd9240863532f40ac1142cba5971 \
				${djava} sha1 3400959bfcacce46908da1773e1f1507f9596236 \
				${dobjc} sha1 9b865860e1c7d878d67d9874779077a060d39b6b

use_bzip2		yes

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

set major		4.2

worksrcdir		build

patch {
	reinplace "s|/usr/bin/libtool|${prefix}/bin/odlibtool|g" \
		${workpath}/gcc-${version}/gcc/config/darwin.h
}

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} \
				--with-as=${prefix}/bin/odas \
				--with-ld=${prefix}/bin/odld \
				--with-ar=${prefix}/bin/odar

build.target	bootstrap
build.args		-j 2

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

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

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/*/4.2.0/include/libffi/ffitarget.h ."
	}
}

