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

PortSystem 1.0

name			gcc45
version			4.5.0
revision                2
epoch                   1
platforms		darwin
categories		lang
maintainers		mww
license			GPLv3
description		The GNU compiler collection
long_description	The GNU compiler collection, including front ends for \
			C, C++, Objective-C, Objective-C++, Fortran and Java.

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 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           gcc-core-${version}.tar.bz2 \
                    md5     58eda33c3184303628f91c42a7ab15b5 \
                    sha1    c0dac59ff47a4de527c2e84047e83d5bf2192056 \
                    rmd160  7cb03a30acda93ed6960657fbc0295bb6b16288d \
                    gcc-fortran-${version}.tar.bz2 \
                    md5     670c35720f9a599ae7b469da95152552 \
                    sha1    2b5b09372b3aec0d9fe91b10a79e78e71adce3b3 \
                    rmd160  b4da72559d1728353a00718da067593ce678f92a \
                    gcc-g++-${version}.tar.bz2 \
                    md5     5ab93605af40def4844eda09ca769c2d \
                    sha1    a07af0417d66748a5f0dc06c4744e8990aaa7304 \
                    rmd160  785ea42e0011a9bdfe74efce14082f1f0b6ea05a \
                    gcc-java-${version}.tar.bz2 \
                    md5     945e6c4b17c60b0590c350238289b0af \
                    sha1    34340fbaef62808c6825f681753dba82adf78f5f \
                    rmd160  4d5c5dddeabeab74c4f6eb392afa1b5c29d723c4 \
                    gcc-objc-${version}.tar.bz2 \
                    md5     8d8c01b6631b020cc6c167860fde2398 \
                    sha1    bca51ee80f3bc240b6dd84535d49423423eb457e \
                    rmd160  9512ff932be7fa36d3f2c8b3ca3e41089ac5a6e8

use_bzip2		yes

# gmp and mpfr are not universal
universal_variant       no

depends_lib		port:gmp port:mpfr port:libiconv port:libmpc

set major		4.5

worksrcdir		build

# the generated compiler doesn't accept -arch
if {[info exists 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}
}

pre-configure {
	file mkdir ${worksrcpath}
}

configure.cmd	../gcc-${version}/configure
configure.args	--enable-languages=c,c++,objc,obj-c++,fortran,java \
		--libdir=${prefix}/lib/${name} \
		--includedir=${prefix}/include/${name} \
		--infodir=${prefix}/share/info \
		--mandir=${prefix}/share/man \
                --datarootdir=${prefix}/share/gcc-${major} \
		--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} \
		--with-mpc==${prefix} \
		--enable-stage1-checking
# 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

build.target	bootstrap
use_parallel_build	yes

destroot.target	install install-info-host

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}/mp-gcc45 ${destroot}${prefix}/etc/select/gcc/
	file rename ${destroot}${prefix}/share/python/aotcompile.py \
		${destroot}${prefix}/share/python/aotcompile-45.py
	file rename ${destroot}${prefix}/share/python/classfile.py \
		${destroot}${prefix}/share/python/classfile-45.py
}

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

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

