Build script for downloading and building gfortran on Apple's Mountain Lion with Xcode 4.4
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Automated build system for gfortran, on Apple OSX.


This is the README for gfortran-mlion


Apple have stopped distributing a Fortran compiler with Xcode, so there is a need to get a working Fortran cross-compiler on Mountain Lion. In the advent of an installer or binary, this project just aims to share a script I'm (still) writing, in order to build a multi-architecture version of llvm-gfortran-4.2.

For more info, see my stackoverflow question at:

The goal then, for this script, is to build a universal binary (i386, x86_64) of llvm-gfortran-4.2. I am unable to test or compile a powerpc compatible version, as I don't have the necessary hardware, or software, with which to do so.

Any comments, help or feedback are completely welcome, at:- beamesleach gmail com


This project contains the following files that should be of interest:-


The rest of the files in the package do all the work of downloading, building and installing gfortran and its dependencies:-


The following patches include all the source code modifications that need to be applied:-

  • patch/gmp.h.patch
  • patch/gcc.fortran.diff

File Descriptions


Any easily customisable configuration settings, like installation prefix, have been put into this file. The file is read as a bash script by

This does everything. Just run it from the command line, and this will download, build and install everything you need for a working fortran compiler on your system.

Anything else.

Don't worry about them, should do all the work for you. However, if you're installing somewhere you need root privileges, then you'll need to run as the root user, after has finished building everything.


  • 10th Sep 2012

    • Actually get it to work...
  • 21st May 2013

    • It's been working for a while now, and successfully builds gfortran-4.2, from the source code provided by Apple, at Do not expect it to pass all of GCC's unit tests, though!

    • Although it would be good to have this build a more recent version of gfortran, MacPorts already does that well. I started on upgrading these scripts to build GCC-4.7.2, but gave up before I finished them, as had more pressing engagements. I've commited the work I've done in upgrading it to a the #gcc-4.7.2 branch, however. Contributions would be welcome!