aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/lilypond.rb
blob: 34aa107f07353e715ef423613a348070ba4085bc (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
require 'formula'

# Necessary until upstream resolves the incompatibility issue with texinfo 5.
# When this is fixed upstream, replace with a normal texinfo dependency
class Texinfo4 < Formula
  homepage 'http://www.gnu.org/software/texinfo/'
  url 'http://ftp.gnu.org/gnu/texinfo/texinfo-4.13a.tar.gz'
  sha1 'a1533cf8e03ea4fa6c443b73f4c85e4da04dead0'
end

class Lilypond < Formula
  homepage 'http://lilypond.org/'
  url 'http://download.linuxaudio.org/lilypond/sources/v2.16/lilypond-2.16.2.tar.gz'
  sha1 '1eb3b0e5c117a8669dba19ab28f933351e51e39a'

  devel do
    url 'http://download.linuxaudio.org/lilypond/source/v2.17/lilypond-2.17.26.tar.gz'
    sha1 '3b9d7324407ad0159dff72af258cc04fd7d00952'
  end

  env :std

  option 'with-doc', "Build documentation in addition to binaries (may require several hours)."

  depends_on :tex
  depends_on :x11
  depends_on 'pkg-config' => :build
  depends_on 'gettext'
  depends_on 'pango'
  depends_on 'guile'
  depends_on 'ghostscript'
  depends_on 'mftrace'
  depends_on 'fontforge' => ["with-x", "with-cairo"]
  depends_on 'fondu'
  # Add dependency on keg-only Homebrew 'flex' because Apple bundles an older and incompatible
  # version of the library with 10.7 at least, seems slow keeping up with updates,
  # and the extra brew is tiny anyway.
  depends_on 'flex' => :build

  # Assert documentation dependencies if requested.
  if build.include? 'with-doc'
    depends_on 'netpbm'
    depends_on 'imagemagick'
    depends_on 'docbook'
    depends_on :python => ['dbtexmf.dblatex' => 'dblatex']
    depends_on 'texi2html'
  end

  fails_with :clang do
    cause 'Strict C99 compliance error in a pointer conversion.'
  end

  def install
    # This texinfo4 business will be no longer needed, either,
    # once the aforementioned issue is resolved.
    texinfo4_prefix = libexec+'texinfo4'
    Texinfo4.new.brew do
      system "./configure", "--disable-dependency-tracking",
                            "--disable-install-warnings",
                            "--prefix=#{texinfo4_prefix}"
      system "make CXX=#{ENV.cxx} install"
    end
    ENV.prepend_path 'PATH', "#{texinfo4_prefix}/bin"

    gs = Formula.factory('ghostscript')

    args = ["--prefix=#{prefix}",
            "--enable-rpath",
            "--with-ncsb-dir=#{gs.share}/ghostscript/fonts/"]

    args << "--disable-documentation" unless build.include? 'with-doc'
    system "./configure", *args

    # Separate steps to ensure that lilypond's custom fonts are created.
    system 'make all'
    system "make install"

    # Build documentation if requested.
    if build.include? 'with-doc'
      system "make doc"
      system "make install-doc"
    end
  end

  test do
    (testpath/'test.ly').write <<-EOS.undent
      \\header { title = "Do-Re-Mi" }
      { c' d' e' }
    EOS
    system "#{bin}/lilypond", "test.ly"
  end
end