# $Id: Portfile 67282 2010-05-04 11:34:45Z mww@macports.org $

PortSystem 1.0

name			gcc44
epoch			1
version			4.4.4
revision		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++, 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.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     eb68755f64b9a4e37751992abb41c4fc \
                    sha1    658516995a560b06abc969b13d48248b4d80899d \
                    rmd160  68c0d424fe3e8f95e5e5d67bda0ab44fb0b0ed31 \
                    gcc-fortran-${version}.tar.bz2 \
                    md5     7fd6d06443f9ba2974c17ddb478b59d0 \
                    sha1    78efb8bf02066feaaa7cea7dc050f1087ff35c46 \
                    rmd160  4e9f01d59685f983786da0eb9c5de39fe38f4adf \
                    gcc-g++-${version}.tar.bz2 \
                    md5     d51a6ec3eac1a90e7fc280d976ce7f80 \
                    sha1    72b078698227e287674f732b005c76e83aea7ef6 \
                    rmd160  cc0ae7598eb405fccbb5a3817ea8bdd74198c55f \
                    gcc-java-${version}.tar.bz2 \
                    md5     a9bacfec108cb632069cc0537ca6fd5b \
                    sha1    6a7b7ac4798a4f041f509855d7ec6cc0c963c3d8 \
                    rmd160  afb5c23e9efde16795c28b677ce3dcad8c27ff4a \
                    gcc-objc-${version}.tar.bz2 \
                    md5     871cdd1a1ed8806a9bd5afcef0938fef \
                    sha1    7101540326439260688b7e246d6dffff86ac017a \
                    rmd160  9a1919cb2ecdfbb111a2e8badb55f7db21b60486

use_bzip2		yes

# gmp and mpfr are not universal
universal_variant       no

depends_lib		port:gmp port:mpfr port:libiconv

patch.dir       ${workpath}/gcc-${version}

set major		4.4

worksrcdir		build

# the generated compiler doesn't accept -arch
if {${os.platform} == "darwin"} {
    configure.cc_archflags
    configure.cxx_archflags
    configure.objc_archflags
    if {[info exists configure.ld_archflags]} {
        configure.ld_archflags
    }
    configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
}

post-extract {
	file mkdir ${worksrcpath}
}

configure.cmd	../gcc-${version}/configure
configure.args	--enable-languages=c,c++,objc,obj-c++,java,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=-mp-${major} \
		--with-gxx-include-dir=${prefix}/include/${name}/c++/ \
		--with-gmp=${prefix} \
		--with-mpfr=${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-gcc44 ${destroot}${prefix}/etc/select/gcc/
	file rename ${destroot}${prefix}/share/python/aotcompile.py \
		${destroot}${prefix}/share/python/aotcompile-44.py
	file rename ${destroot}${prefix}/share/python/classfile.py \
		${destroot}${prefix}/share/python/classfile-44.py
}

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

platform darwin 10 {
	configure.args-append --enable-fully-dynamic-string
}

# odcctools currently do not compile for x64 - move to variant for the time being
variant odcctools \
	description "Use the odcctools instead of the system provided ones - does not work for x64 currently!" {
	depends_lib-append	port:odcctools
	post-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
}

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

