Gcc42 version 4.2.4 - How to Download and Install on Mac OS X
Sunday the 22nd of November, 2009

    version 4.2.4

      View the most recent changes for the gcc42 port at: gcc42.darwinports.com/diff
      Scroll down toward the bottom of the page to get installation instructions for gcc42.
      The raw portfile for gcc42 4.2.4 is located here:
      http://gcc42.darwinports.com/dports/lang/gcc42/Portfile
      Find related portfiles with the unique DarwinPorts.com search feature.
      Check for any related Fink projects here: pdb.finkproject.org/pdb/package.php/gcc42


      The gcc42 Portfile 57804 2009-09-16 23:12:44Z jmr macports.org $

      PortSystem 1.0

      Name: gcc42
      Version: 4.2.4
      Revision: 1
      Platform: darwin
      Category: 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: ${dcore} sha1 540fa6949415ded321a7cbe80bbf8befe85e3566 ${dfort} sha1 7b476983f8b8405a456b30704cd91c7b238381c9 ${dcxx} sha1 8b0ed65c5314e0a598a120a841cd00eedd183760 ${djava} sha1 ce9587329585c35f870157f3fc937c0dd746b4f3 ${dobjc} sha1 5e14e4960b2a0bf74dd867fe71071429b2631406

      use_bzip2 yes

      # gmp and mpfr are not universal
      universal_variant no

      depends_lib port:gmp port:mpfr port:libiconv

      set major 4.2

      worksrcdir build

      patch {
      # fix names of infopages
      foreach f { cpp cppinternals gcc gccint} {
      reinplace "s|${f}.info|${f}-mp-${version}.info|g" ${workpath}/gcc-${version}/gcc/doc/${f}.texi
      }
      }

      # 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} --host=${build_arch}-apple-darwin${os.major}
      }

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

      use_parallel_build yes

      destroot.target install install-info-host

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

      platform darwin 7 {
      depends_build-append port:gmake
      build.cmd gmake
      # configure.cflags-append -force_cpusubtype_ALL
      # configure.env BOOT_CFLAGS="-g -O2 -force_cpusubtype_ALL"
      # build.args-append XCFLAGS=-force_cpusubtype_ALL
      }

      post-destroot {
      # 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}/
      }
      xinstall -m 755 -d ${destroot}${prefix}/etc/select/gcc
      xinstall -m 444 ${filespath}/mp-gcc42 ${destroot}${prefix}/etc/select/gcc/
      }

      # odcctools currently do not compile for x64 - move to variant for the time being
      Variant: odcctools {
      depends_lib-append bin:odas:odcctools
      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.2/
      livecheck.regex GCC (4\\.2\\.\[0-9\])


    If you haven't already installed Darwin Ports, you can find easy instructions for doing so at the main Darwin Ports page.

    Once Darwin Ports has been installed, in a terminal window and while online, type the following and hit return:


      %  cd /opt/local/bin/portslocation/dports/gcc42
      % sudo port install gcc42
      Password:
    You will then be prompted for your root password, which you should enter. You may have to wait for a few minutes while the software is retrieved from the network and installed for you. Y ou should see something that looks similar to:

      ---> Fetching gcc42
      ---> Verifying checksum for gcc42
      ---> Extracting gcc42
      ---> Configuring gcc42
      ---> Building gcc42 with target all
      ---> Staging gcc42 into destroot
      ---> Installing gcc42
    - Make sure that you do not close the terminal window while Darwin Ports is working. Once the software has been installed, you can find further information about using gcc42 with these commands:
      %  man gcc42
      % apropos gcc42
      % which gcc42
      % locate gcc42

     Where to find more information:

    Darwin Ports



    Lightbox this page.