Skip to content

Instantly share code, notes, and snippets.

@alexpearce
Created November 20, 2014 14:02
Show Gist options
  • Save alexpearce/7c11c55a88b0890210fb to your computer and use it in GitHub Desktop.
Save alexpearce/7c11c55a88b0890210fb to your computer and use it in GitHub Desktop.
Homebrew ROOT formula for installing ROOT 6.02.00
require 'formula'
class Root < Formula
homepage 'http://root.cern.ch'
url 'ftp://root.cern.ch/root/root_v6.02.00.source.tar.gz'
mirror 'http://ftp.riken.jp/pub/ROOT/root_v6.02.00.source.tar.gz'
version '6.02.00'
sha1 '98449e9a4d91cc487c5ae59c1128d20286f134cc'
head 'https://github.com/root-mirror/root.git', :branch => 'v6-02-00-patches'
# url "ftp://root.cern.ch/root/root_v5.34.22.source.tar.gz"
# mirror "http://ftp.riken.jp/pub/ROOT/root_v5.34.22.source.tar.gz"
# version "5.34.22"
# sha1 "f0afdd16847e555c38b28e115a88bb4903ce9a29"
# head 'https://github.com/root-mirror/root.git', :branch => 'v5-34-00-patches'
option 'with-qt', "Build with Qt graphics backend and GSI's Qt integration"
depends_on 'xrootd' => :recommended
depends_on 'fftw' => :optional
depends_on 'qt' => [:optional, 'with-qt3support']
depends_on :x11 => :optional
depends_on :python
def install
# brew audit doesn't like non-executables in bin
# so we will move {thisroot,setxrd}.{c,}sh to libexec
# (and change any references to them)
inreplace Dir['config/roots.in', 'config/thisroot.*sh',
'etc/proof/utils/pq2/setup-pq2',
'man/man1/setup-pq2.1', 'README/INSTALL', 'README/README'],
/bin.thisroot/, 'libexec/thisroot'
# Determine architecture
arch = MacOS.prefer_64_bit? ? 'macosx64' : 'macosx'
# N.B. that it is absolutely essential to specify
# the --etcdir flag to the configure script. This is
# due to a long-known issue with ROOT where it will
# not display any graphical components if the directory
# is not specified:
# http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=15072
args = %W[
#{arch}
--all
--enable-builtin-glew
--enable-builtin-freetype
]
if build.with? 'x11'
args << "--disable-cocoa"
args << "--enable-x11"
end
if build.with? 'qt'
args << "--enable-qt"
args << "--enable-qtgsi"
end
args += %W[
--prefix=#{prefix}
--etcdir=#{prefix}/etc/root
--mandir=#{man}
]
system "./configure", *args
# ROOT configure script does not search for Qt framework
if build.with? 'qt'
inreplace "config/Makefile.config" do |s|
s.gsub! /^QTLIBDIR .*/, "QTLIBDIR := -F #{Formula["qt"].opt_lib}"
s.gsub! /^QTLIB .*/, "QTLIB := -framework QtCore -framework QtGui -framework Qt3Support"
end
end
system "make"
system "make install"
# needed to run test suite
prefix.install 'test'
libexec.mkpath
mv Dir["#{bin}/*.*sh"], libexec
end
test do
system "make -C #{prefix}/test/ hsimple"
system "#{prefix}/test/hsimple"
end
def caveats; <<-EOS.undent
Because ROOT depends on several installation-dependent
environment variables to function properly, you should
add the following commands to your shell initialization
script (.bashrc/.profile/etc.), or call them directly
before using ROOT.
For csh/tcsh users:
source `brew --prefix root`/libexec/thisroot.csh
For bash/zsh users:
. $(brew --prefix root)/libexec/thisroot.sh
EOS
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment