aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/pbrt.rb
blob: 3103f295726e2997dbb0b70a8afd50e5f5ff52a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'formula'

class Pbrt <Formula
  head 'git://github.com/mmp/pbrt-v2.git'
  homepage 'http://www.pbrt.org/'

  depends_on 'openexr'
  depends_on 'libtiff'
  depends_on 'ilmbase'

  def install
    openexr = Formula.factory('openexr')
    libtiff = Formula.factory('libtiff')
    ilmbase = Formula.factory('ilmbase')

    # Configure the Makefile
    inreplace 'src/Makefile' do |s|
      # Enable Tiff support
      s.change_make_var! "HAVE_LIBTIFF", "1"

      # Set LibTiff path
      s.change_make_var! "TIFF_INCLUDES", "-I#{libtiff.include}"
      s.change_make_var! "TIFF_LIBDIR", "-L#{libtiff.lib}"

      # Set OpenEXR path
      s.change_make_var! "EXR_INCLUDES", "-I#{openexr.include}/OpenEXR -I#{ilmbase.include}/OpenEXR"
      s.change_make_var! "EXR_LIBDIR", "-L#{openexr.lib} -L#{ilmbase.lib}"

      # Change settings if we are using a 32bit system
      if MACOS_VERSION < 10.6 or Hardware.is_32_bit?
        s.change_make_var! "MARCH", "-m32 -msse2 -mfpmath=sse"
      end
    end

    # Build and install
    system "make -C src"
    bin.install Dir['src/bin/*']

    # Copy resources
    prefix.install %w(dtrace exporters scenes)
  end
end