aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/auctex.rb
blob: 2a199c2646d650c2e91827666a07efdfe0e95da0 (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
require 'formula'

class TexInstalled < Requirement
  def message; <<-EOS.undent
    A TeX/LaTeX installation is required to install.
    You can obtain the TeX distribution for Mac OS X from:
        http://www.tug.org/mactex/
    EOS
  end
  def satisfied?
    which 'latex'
  end
  def fatal?
    true
  end
end

class Auctex < Formula
  homepage 'http://ftp.gnu.org/pub/gnu/auctex'
  url 'http://ftpmirror.gnu.org/auctex/auctex-11.86.tar.gz'
  mirror 'http://ftp.gnu.org/gnu/auctex/auctex-11.86.tar.gz'
  md5 '6bc33a67b6ac59db1aa238f3693b36d2'

  depends_on TexInstalled.new

  def options
    [['--with-emacs=</full/path/to/emacs>', "Force a different emacs"]]
  end

  def which_emacs
    # check arguments for a different emacs
    ARGV.each do |a|
      if a.index('--with-emacs')
        return a.sub('--with-emacs=', '')
      end
    end
    return `which emacs`.chomp
  end

  def install
    # configure fails if the texmf dir is not there yet
    brew_texmf = share + 'texmf'
    brew_texmf.mkpath

    system "./configure", "--prefix=#{prefix}",
                          "--with-texmf-dir=#{brew_texmf}",
                          "--with-emacs=#{which_emacs}",
                          "--with-lispdir=#{share}/emacs/site-lisp"

    system "make"
    ENV.deparallelize # Needs a serialized install
    system "make install"
  end

  def caveats
    # check if the used emacs is in HOMEBREW_PREFIX/bin
    # for which case HOMEBREW_PREFIX/share/emacs/site-lisp should already
    # be by default in the load-path
    if which_emacs.index("#{HOMEBREW_PREFIX}/bin")
      dot_emacs = <<-EOS
      (require 'tex-site)
      EOS
    else
      dot_emacs = <<-EOS
      (add-to-list 'load-path "#{HOMEBREW_PREFIX}/share/emacs/site-lisp")
      (require 'tex-site)
      EOS
    end

    <<-EOS.undent
    texmf files installed into:
      #{HOMEBREW_PREFIX}/share/texmf/

    You can add it to your TEXMFHOME using:
      sudo tlmgr conf texmf TEXMFHOME "~/Library/texmf:#{HOMEBREW_PREFIX}/share/texmf"

    Emacs package installed into:
      #{HOMEBREW_PREFIX}/share/emacs/site-lisp

    To activate, add the following to your .emacs:
#{dot_emacs}
    EOS
  end

end