Contents
IntroductionCautionary Notes
Downloading the Tools and Sources
Building
Creating an App Bundle
Introduction
These notes describe how to build SAGA for OS X using the following software tools and sources:
- OS X 10.7 (Lion)
- Xcode 4.5 or 4.6
- SAGA 2.1.0 source code
- wxWidgets 2.9.4 source code
- JasPer 1.900.1 source code
- GDAL 1.9 framework and PROJ 4.8 framework
- PROJ 4.8 projects.h header file
- GNU autoconf, automake and libtool packages
- TextWrangler text editor
Cautionary Notes
- Don't use versions that are earlier than what's listed above. If you do,
you're entirely on your own. More recent versions might work, but they
have not been tested.
- Trust the make. Deviating from the steps listed here will
almost certainly result in problems.
Downloading the Tools and Sources
Xcode
Xcode is free from Apple's Mac App Store. If you're in an Apple developer program, you can also download Xcode from an Apple Dev Center.Xcode is a standalone app and includes all the compilers and other tools that it needs internal to the Xcode.app bundle. To use these tools outside of Xcode, it's easiest to install the Xcode command line tools, as follows:
- In Xcode, choose Xcode | Preferences.
- Click the Downloads tab and, under Components, select Command Line Tools and click Install.
SAGA source code
You can check out the latest SAGA source from the SVN code repository. Open a terminal window and cd to where you want to create the source folder, then enter the following:
mkdir saga-gis cd saga-gis svn co svn://svn.code.sf.net/p/saga-gis/code-0/trunk/saga-gis .If SAGA 2.1.0 is available, you can use the source from that release instead. Go to the SAGA Web site and follow the download links:
Important! Be sure to download the .tar.gz file, not the .zip file.
Once you've downloaded the source code's .tar.gz file, double-click it to unzip it, then move the unzipped folder to wherever you want.
wxWidgets source code
To obtain the wxWidgets 2.9.4 source, go to the wxWidgets Web site and follow the download links:Important! Be sure to download the .tar.bz2 file, not the .zip file.
Once you've downloaded the source code's .tar.bz2 file, double-click it to unzip it, then move the unzipped folder to wherever you want.
You can also check out the latest wxWidgets source from the SVN code repository. Open a terminal window and cd to where you want to create the source folder, then enter the following:
mxdir wxWidgets cd wxWidgets svn co http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk .
JasPer source code
JasPer is a small JPEG library that you'll need to build yourself. The source is available from the JasPer home page:http://www.ece.uvic.ca/~frodo/jasper/
Download file jasper-1.900.1.zip, double-click it to unzip it, then move the unzipped folder to wherever you want.
GDAL and PROJ frameworks
The GDAL and PROJ frameworks have already been built for you and can be downloaded as part of the "GDAL Complete" package from here:http://www.kyngchaos.com/software/qgis
Download the GDAL Complete .dmg file and double-click it, then double-click GDAL Complete.pkg to install the GDAL and PROJ frameworks.
The GDAL package will install five frameworks under /Library/Frameworks. While only GDAL and PROJ are needed for SAGA, the other three frameworks (GEOS, UnixImageIO and SQLite3) are fairly small and will be needed if you plan to install Quantum GIS. (Tip: If you plan to install QGIS, be sure to download and install the GSL framework too.)
PROJ projects.h header file
SAGA depends on this header file, which is now considered "private" and thus is not included in the PROJ 4.8 framework's Headers folder. Download proj-4.8.0.zip from this site:http://download.osgeo.org/proj
Unzip it and copy its projects.h file to your SAGA source src/modules_projection/pj_proj4/pj_proj4 folder.
GNU packages
Download the latest .tar.gz files for each of these GNU packages from this site:- autoconf
- automake
- libtool
TextWrangler
If you don't have a good programmer's editor, download TextWrangler from the Mac App Store (free) or from here:
http://www.barebones.com/products/textwrangler/
Building
Building JasPer
In a terminal window, cd to where you unzipped the JasPer source, then enter the following:
./configure make sudo make installThis creates the libjasper.a static library. The last command requires that you enter your password since it will copy libjasper.a to /usr/local/lib.
Building wxWidgets
Important! If your Mac had OS X 10.5 (Leopard) installed previously, you may have a symlink in /usr/bin to an out-of-date copy of wx-config. This will interfere with configuring wxWidgets, so check and remove if so:
ls -l /usr/bin/wx-config sudo rm /usr/bin/wx-configIn a terminal window, cd to where you checked out or unzipped the wxWidgets source (make sure this is the directory that contains configure). Create a build directory, for example:
mkdir build-cocoa-debug cd build-cocoa-debugNow create the wxWidgets make files, using the following command. To simpify running the command again, you can put it in a script file:
../configure --enable-unicode --enable-debug --enable-shared --enable-monolithic --with-osx_cocoa --enable-macosx_arch=x86_64 \ --with-macosx-version-min=10.7 \ --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdkOnce this is finished, build and copy the wxWidgets library to /usr/local/lib:
make sudo make installNote that the make will take a long time to complete (up to half an hour), so be patient.
Note that you can compile wxWidgets with clang instead of gcc by adding CXX="/usr/bin/clang++" to the configure command. This will also reduce the size of the resulting wxWidgets .dylib by about 10% compared to gcc.
Building GNU packages
Build each package from a terminal command line. The resulting scripts will be installed in /usr/local/bin and /usr/local/share.
./configure make sudo make install
Patching SAGA
Currently the SAGA source requires several small edits in order to link and run:
- Edit src/saga_core/saga_odbc/Makefile.am and change "-lodbc" to "-liodbc"
(without the quotes).
OS X 10.7 does not include libodbc.dylib, but it does include libiodbc.dylib.
- Edit src/saga_core/saga_gui/Makefile.am and delete "aui,base,"
and "propgrid," from the first AM_LDFLAGS line.
For some reason, the make tries to link against these libraries, which are part of the monolithic wxWidgets library.
Building SAGA
In a terminal window, cd to where you checked out or unzipped the SAGA source (make sure this is the directory that contains configure.in).Enter this command to create the configure file:
autoreconf -iWith a text editor, create a script file in this directory, for example:
touch my-saga-config.sh open -a textwrangler my-saga-config.shCopy and paste the following lines into the file and save it:
FEATURES="--enable-debug --disable-openmp" CXX="/usr/bin/clang" DEFINES="-D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__" GDAL_H="-I/Library/Frameworks/GDAL.framework/Headers" PROJ_H="-I/Library/Frameworks/PROJ.framework/Headers" GDAL_SRCH="-L/Library/Frameworks/GDAL.framework/unix/lib" PROJ_SRCH="-L/Library/Frameworks/PROJ.framework/unix/lib" LINK_MISC="-arch x86_64 -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -lstdc++" ./configure $FEATURES CXX="$CXX" CPPFLAGS="$DEFINES $GDAL_H $PROJ_H" LDFLAGS="$GDAL_SRCH $PROJ_SRCH $LINK_MISC"Make the script executable and run it:
chmod +x my-saga-config.sh ./my-saga-config.shOnce this is finished, build and copy the SAGA executables to /usr/local/bin and the SAGA libraries to /usr/local/lib and /usr/local/lib/saga:
make sudo make installNote that the make will take a long time to complete (up to half an hour), so be patient.
Creating an App Bundle
The SAGA GUI executable (saga_gui) is copied to /usr/local/bin. However, since it lacks an app bundle, it does not run properly. To create an app bundle, download the following script and icon file:http://web.fastermac.net/~MacPgmr/SAGA/create_saga_app.sh
http://web.fastermac.net/~MacPgmr/SAGA/saga_gui.icns
Change to where you downloaded the script and enter the following:
chmod +x create_saga_app.sh ./create_saga_app.sh /usr/local/bin/saga_gui SAGAThis will create a SAGA.app bundle in the current directory for saga_gui. In Finder you can move this bundle to wherever you want. To start SAGA, double-click it in Finder. You can also drag and drop it on the Dock to start SAGA from there.
Note that the SAGA GUI does not work very well yet. It has problems with creating a preferences file in the correct location and sometimes won't shut down (use Activity Monitor to force quit if necessary).