Setup script to create the binary installer for the released clang binaries used to compile R
Clone or download
coatless Add link to macos toolchain project and update vanity URLs (close #13)
- Emphasizes the new macOS toolchain installer
- Switch away from box to github releases using the UIUC short link vanity
Latest commit 9ac0539 Mar 26, 2018

This installer has been superceded by the r-macOS-rtools installer, which automatically installs and configures the R toolchain for compiled code on macOS, e.g. XCode Command Line Tools, clang4, and gfortran.

Installer Package for clang4 R Binaries License

The repository contains the scripts used to create a macOS installer package (.pkg) for the clang4 binaries. For those interested, the installer can be obtained on either the project's Release page or through

The pre-built binaries this installer setups during the installation can be found at:

The scripts have the potential to be generalized further so that .pkg installers are available to be created for all binaries listed on

Financial support was provided to sign the installer by Professor Timothy Bates of the University of Edinburgh.

How do I use the installer?

Download it from, open the installer by right clicking to bring up menu and selecting "Open". From here, navigate through it like a normal macOS installer.

If you have yet to install Xcode Command Line Interface Tools ("Xcode CLI"), you will then need to open Terminal (Applications/Utilities/Terminal) and type:

xcode-select --install

That's it. Once installed, you can start using compiled code in R like normal with the added benefit of OpenMP.

If you want to see behind the curtain, continue reading...

What does the installer do?

The clang4-r installer performs two actions that require the users password to accomplish. These actions are:

  1. unpack a set of pre-made binary files into the /usr/local/clang4 directory
  2. establish the proper paths for CC, CXX, CXX**, and LDFLAGS in the ~/.R/Makevars file

In essence, it provides a graphical user interface installation guide, more secure path manipulation, and a smarter handling of a pre-existing ~/.R/Makevars when compared to the following pure bash approach:

# Download binary
curl -O
# Extract binary onto root directory
tar fvxz clang-4.0.0-darwin15.6-Release.tar.gz -C /

# Overwrites ~/.R/Makevars file if present otherwise creates it
cat <<- EOF > ~/.R/Makevars
# The following statements are required to use the clang4 binary
# End clang4 inclusion statements

# Install Xcode CLI tools
xcode-select --install

Verify the Installer

Thanks to the financial support provided by Professor Timothy Bates of the University of Edinburgh to join the Apple Developer program. The installer is now signed using developer credentials.

As a result, the installer should have a "lock" icon in the upper right corner:

Signed Installer Lock Icon

Clicking the lock icon will reveal the signed developer certificate:

Signed Developer Certificate

With this being said, the code used to generate the installer has been made publically available under an open source license (GPL >= 2).

Overview of Files

Below is an abridged version of the actions of each file provided.

    • Downloads the clang-4.0.0-darwin15.6-Release.tar.gz from and extracts it into a temporary ROOT/ directory established in the working directory
  • scripts/postinstall
    • Create or modify the ~/.R/Makevars file with the necessary implicit variables to compile with clang4.
    • This is run at the end of the installer routine.
    • Create the installer package R binary installer .pkg
      • Builds the package from the extracted tar using pkgbuild
      • Analyzing the package using productbuild to create a distribution.xml
      • Inserts customizations into the distribution.xml (title, background, ...)
      • Calls productbuild to rebuild the package.
  • distribution.xml
    • Customization options (e.g. title, background) of installer built by analyzing a temporary .pkg
  • build_files/Rlogo.png
    • R logo
  • build_files/LICENSE.rtf
    • License of the LLVM installer
  • build_files/WELCOME_DISPLAY.rtf
    • Text displayed on welcome screen


GPL (>= 2)