aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/proof-general.rb
blob: 17785fe9d095a925fc71278ceaff97a5d068a3fb (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
require 'formula'

class ProofGeneral < Formula
  homepage 'http://proofgeneral.inf.ed.ac.uk'
  url 'http://proofgeneral.inf.ed.ac.uk/releases/ProofGeneral-4.2.tgz'
  sha1 'c8d2e4457478b9dbf4080d3cf8255325fcffe619'

  option 'with-doc', 'Install documentations'
  option 'with-emacs=</path/to/emacs>', 'Re-compile the lisp files with a specified emacs'

  def which_emacs
    ARGV.each do |a|
      if a.index('--with-emacs')
        emacs = a.sub('--with-emacs=', '')
        raise "#{emacs} not found" if not File.exists? "#{emacs}"
        ohai "Use Emacs: #{emacs}"

        version = `#{emacs} --version | grep -Eo "GNU Emacs \\d+(\\.\\d+)+"`.gsub /\n/, ""
        ohai "Emacs version: #{version}"
        major = `echo "#{version}" | awk {'print $3'} | cut -d "." -f 1`.gsub /\n/, ""
        raise "Only Emacs of major version 23 is supported." if major != "23"
        return emacs
      end
    end
    return ""
  end

  def install
    emacs = which_emacs
    args = ["PREFIX=#{prefix}",
            "DEST_PREFIX=#{prefix}",
            "ELISPP=share/emacs/site-lisp/ProofGeneral",
            "ELISP_START=#{share}/emacs/site-lisp/site-start.d",
            "EMACS=#{emacs}"];

    Dir.chdir "ProofGeneral" do
      if emacs != ""
        system "make clean"
        system "make", "compile", *args
      end
      system "make", "install", *args
      man1.install "doc/proofgeneral.1"
      info.install "doc/ProofGeneral.info", "doc/PG-adapting.info"

      doc.install "doc/ProofGeneral", "doc/PG-adapting" if build.include? 'with-doc'
    end
  end

  def caveats
    doc = ""
    if build.include? 'with-doc'
      doc += <<-EOS.undent
         The HTML documentations are available in:
               #{HOMEBREW_PREFIX}/share/doc/proof-general
      EOS
    end

    <<-EOS.undent
    To use ProofGeneral with Emacs, add the following line to your ~/.emacs file:
      (load-file "#{HOMEBREW_PREFIX}/share/emacs/site-lisp/ProofGeneral/generic/proof-site.el")
    #{doc}
    EOS
  end
end