# $Id: Portfile 67222 2010-05-03 01:08:48Z ryandesign@macports.org $

PortSystem 1.0

name			gcc40
version			4.0.4
revision		1
platforms		darwin
categories		lang
maintainers		mww
license			GPLv2
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 55c664b33a4dc6b2130c47da28a1d6daab732ce9 \
				${dfort} sha1 fff9f58ff51e10dac89fb0b51ad74f5f90d5cabc \
				${dcxx} sha1 804870b31d1567e81c96a682dd9ef5a6175e8574 \
				${djava} sha1 9f0c56f4dabbe74811d40344ce0afe920798cca4 \
				${dobjc} sha1 5c5c3052796fef9e1fc4a468f6e04881c6dc9267

use_bzip2		yes

# gmp and mpfr are not universal
universal_variant       no

depends_lib		port:gmp port:mpfr

set major		4.0

worksrcdir		build

post-extract {
	file mkdir ${worksrcpath}
}

#patchfiles		patch-config-i386-darwin.h
#patch.dir		${workpath}/gcc-${version}

# the generated compiler doesn't accept -arch
if {$build_arch != "" && ${os.platform} == "darwin"} {
    configure.cc_archflags
    configure.cxx_archflags
    configure.objc_archflags
    configure.pre_args-append --build=${build_arch}-apple-darwin${os.major} \
                              --host=${build_arch}-apple-darwin${os.major}
}

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=-mp-${major} \
				--with-gxx-include-dir=${prefix}/include/${name}/c++/ \
				--with-gmp=${prefix} \
				--with-mpfr=${prefix}

#use_parallel_build	yes
build.target	profiledbootstrap
build.args		-j 2

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

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

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

