Skip to content

Mac Build Process Overview

Chris Mosetick edited this page Jan 27, 2015 · 8 revisions

Overview of Revolution R Open for Mac build process

These notes are specific to OS X 10.10 (Yosemite), but will apply to 10.9 (Mavericks) as well.

Prepare for build

Here's what you will need:

  • XCode
  • Homebrew
  • Xquartz
  • GFortran
  • Packages Build
  • Java

We recommend you use brew to install the required components. (Some components will still need to be installed manually.) Full instructions are below, but if you already have brew installed you can just use the script below.

#!/bin/bash
# TL;DR
# You can use a script like this to get the download pieces going quickly.
# Please read the discussion for important notes.

brew install wget gnu-tar cairo jpeg libtiff libpng Caskroom/cask/xquartz Caskroom/cask/java
wget http://coudert.name/software/gfortran-4.8.2-Mavericks.dmg
wget http://s.sudre.free.fr/Software/files/Packages.dmg

Discussion of items needed for build

Xcode

Install Apple Xcode 6.1.1 via the Mac App Store on your Mac.
Home Page: https://developer.apple.com/xcode/downloads/

Important: Accept the Xcode license agreement by manually opening Xcode.app at least once from the /Applications directory on your system.

XQuartz

X11 is not shipped with newer versions of OS X. You will need to install it for RRO to build correctly. Specifically, there are libraries needed for R graphics capabilities to function.

brew install Caskroom/cask/xquartz

Home Page: http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.7.dmg

Install XQuartz with the default options.

Alternative install option: wget http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.7.dmg

GFortran

GFortran 4.8 for Mac.
Note: 4.8 is what we use. 4.9 is untested but may work too.
Note: Using this DMG is a much smaller install footprint than installing gcc via brew which will provide gfortran too.

Home Page: https://gcc.gnu.org/wiki/GFortranBinaries
Download GFortran for Mac
wget http://coudert.name/software/gfortran-4.8.2-Mavericks.dmg

Install this GFortran with the default options.

Packages Build

Packages Build creates a menu driven GUI installer to install RRO on a end user system.

Home Page: http://s.sudre.free.fr/Software/Packages/about.html
Download Packages:
wget http://s.sudre.free.fr/Software/files/Packages.dmg

Install Packages with the default options.

Homebrew

You will need Mac Homebrew installed or optionally find another way to install the following components. Installing Homebrew is outside the scope of this document, but easy to do:
Follow install instructions found at: http://brew.sh

It is advised, though not strictly required to adjust your $SHELL path to make /usr/local/bin first, before /usr/bin.

e.g. /usr/local/bin:/usr/local/sbin:/bin:/usr/sbin:/sbin:/usr/bin:/opt/X11/bin

brew install gnu-tar cairo jpeg libtiff libpng
brew install Caskroom/cask/java

Note: Java is not used in the build process, but needed for the make process to complete with success.

You are missing Java, or it's not in your PATH if you get this warning:

configuring Java ...
Java interpreter : /usr/bin/java
No Java runtime present, requesting install.

*** Java interpreter doesn't work properly.

Note: Mac Yosemite will ship with a /usr/bin/java but it is not functional, it will just bring up a pop-up window in your GUI.

java -version should return real output:

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

See brew install steps above for Java

A note on tar and the R source

The RRO repository already contains the R source for the current version of R that RRO uses. This is located in the top level of the repo, in the R-src directory.
If you want to try building with a newer (or older) version of R, then be sure to use GNU tar for your extraction of the R source. (tar as found on Linux systems) e.g. gtar was previously installed by brew package gnu-tar.

You do not have to run the command below if you are using the R-src that is found in the RRO repo: Check for correct symlinks in src directory:

gtar xzf R-3.1.2.tar.gz
cd R-3.1.2/src/library/Recommended
ls -la

You should see an elaborate symlink structure in Recommended directory.

Start the build

Use the build script build-OSX.sh to start the build.

git clone [email protected]:RevolutionAnalytics/RRO.git
cd OSX
./build-OSX.sh > /tmp/RRO-build.log

As the script runs, in a new terminal tab run: tail -f /tmp/RRO-build.log to keep an eye on the build process, or to review any possible errors or warnings received.

Test the build

It's now time for a few quick sanity tests of the build.
If the build process runs correctly you should have: an R.framework on your system:

Check for the presence of RRO:

  • ls /Library/Frameworks/R.framework/
  • ls /Applications | grep Revo*
  • ls /usr/bin/R

Check to see if the executables launch correctly.

  • Run RRO from the terminal by typing R

  • Run RRO from the GUI by launching Revolution R Open.app from the /Applications directory.

From both the terminal and GUI R sessions type:
capabilities()

  • The RRO terminal should report all items TRUE except X11, if you do not have X11 environment variables configured and XQuartz running.

  • The RRO GUI session should report all items TRUE

Benchmark the build

Below is a simple test, but it will give an idea of what to expect from RRO on your system.

source (url("http://r.research.att.com/benchmarks/R-benchmark-25.R"))

Congratulations, you have successfully built Revolution R Open.

Troubleshooting

To troubleshoot it is helpful to run the configure portion of the script by itself:

./configure 'CC=clang' 'CXX=clang++' 'OBJC=clang' 'CFLAGS=-Wall -mtune=core2 -g -O2' 'CXXFLAGS=-Wall -mtune=core2 -g -O2' 'OBJCFLAGS=-Wall -mtune=core2' --with-blas="-framework Accelerate" '--with-lapack' '--with-system-zlib' '--enable-memory-profiling' "CPPFLAGS=-I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -DPLATFORM_PKGTYPE='\"mac.binary.mavericks\"'" '--x-libraries=/opt/X11/lib' '--x-includes=/opt/X11/include/' '--with-libtiff=yes'

OTHER NOTES:
You can safely ignore this warning:
pdflatex' is needed to make vignettes but is missing on your system.

** EXAMPLE LOG OUTPUT ON SUCCESS:**
tail -n 50 /tmp/RRO-build.log

export USER_LIBRARY_DIR=/Users/chris/Library
export USE_DYNAMIC_NO_PIC=YES
export USE_HEADERMAP=YES
export USE_HEADER_SYMLINKS=NO
export VALIDATE_PRODUCT=NO
export VALID_ARCHS="i386 x86_64"
export VERBOSE_PBXCP=NO
export VERSIONPLIST_PATH="Revolution R Open.app/Contents/version.plist"
export VERSION_INFO_BUILDER=chris
export VERSION_INFO_FILE="Revolution R Open_vers.c"
export VERSION_INFO_STRING="\"@(#)PROGRAM:Revolution R Open  PROJECT:Revolution R Open-\""
export WARNING_CFLAGS="-Wmost -Wall"
export WRAPPER_EXTENSION=app
export WRAPPER_NAME="Revolution R Open.app"
export WRAPPER_SUFFIX=.app
export XCODE_APP_SUPPORT_DIR=/Applications/Xcode.app/Contents/Developer/Library/Xcode
export XCODE_PRODUCT_BUILD_VERSION=6A2008a
export XCODE_VERSION_ACTUAL=0611
export XCODE_VERSION_MAJOR=0600
export XCODE_VERSION_MINOR=0610
export XPCSERVICES_FOLDER_PATH="Revolution R Open.app/Contents/XPCServices"
export YACC=yacc
export ZERO_LINK=NO
export arch=x86_64
export variant=normal
/bin/sh -c \"/Users/chris/src/RRO-temp/OSX/Mac-GUI-1.65/build/Revolution\ R\ Open.build/Release/Revolution\ R\ Open.build/Script-680F0D4C0997D201009CDBE8.sh\"
Revision: 6784

Touch build/Release/Revolution\ R\ Open.app
cd /Users/chris/src/RRO-temp/OSX/Mac-GUI-1.65
/usr/bin/touch -c /Users/chris/src/RRO-temp/OSX/Mac-GUI-1.65/build/Release/Revolution\ R\ Open.app

RegisterWithLaunchServices build/Release/Revolution\ R\ Open.app
cd /Users/chris/src/RRO-temp/OSX/Mac-GUI-1.65
builtin-lsRegisterURL /Users/chris/src/RRO-temp/OSX/Mac-GUI-1.65/build/Release/Revolution\ R\ Open.app

** BUILD SUCCEEDED **