# $Id: Portfile 57375 2009-09-10 08:16:41Z ryandesign@macports.org $

PortSystem 1.0

name                apple-gcc42-devel
version             5564
categories          lang
platforms           darwin
maintainers         illogic-al
description         Updated version of Apple's version of gcc 4.2
long_description    Apple's version of the GNU compiler collection, \
                    version 4.2. Supports C, C++ and Objective-C.

homepage            http://developer.apple.com/documentation/DeveloperTools/gcc-4.2/gcc/
master_sites        http://www.opensource.apple.com/darwinsource/tarballs/other/
distname            gcc_42-${version}
checksums           md5 cc919b07776db1a209ccaa48b0e19da7

# The prefix is set to /usr because parts of the script are hardcoded to expect it
set build_prefix      /usr

post-extract { 
    file mkdir ${worksrcpath}/debug
    file mkdir ${destroot}
}

post-patch {
    reinplace "s|MAKEINFO=\$\(MAKEINFO\) \$\(MAKEINFOFLAGS\)|MAKEINFO=makeinfo \$\(MAKEINFOFLAGS\)|" ${worksrcpath}/Makefile.in
}

use_configure   no

# first parameter: space-separated list of archs compiler will run on
# second parameter: space-separated list of archs compiler will generate code for
# third parameter: path to the compiler sources
# fourth parameter: location compiler will be installed to. /usr is expected
# fifth parameter: place compiler will be copied once it's built
# sixth parameter: a directory to place information helpful in debugging compiler
# This build.cmd line will build gcc 4.2 with c++ and obj-c++ support
build.cmd   ${worksrcpath}/build_gcc \
            \"${configure.universal_archs}\" \"${configure.universal_archs}\" \
            ${worksrcpath} ${build_prefix} ${destroot} ${worksrcpath}/debug

destroot {}

platform darwin 8 {
    destroot.violate_mtree yes
    # Delete docs and not violate_mtree
    #system "rm -rf ${destroot}/Developer"
}

platform darwin 9 {
    post-destroot {
        # This documentation is already installed in Xcode for 10.5
        system "rm -rf ${destroot}/Developer"
    }
}

post-destroot {
    system "mkdir -p ${destroot}${prefix}"
    system "rm -rf ${destroot}${prefix}/*"
    system "mv -f ${destroot}${build_prefix}/* ${destroot}${prefix}"
    system "rmdir ${destroot}${build_prefix}"
}

livecheck.type		moddate
livecheck.url		${master_sites}

