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

def TeX_installed?; return `which latex` != ''; end

class Asymptote < Formula
  url 'http://downloads.sourceforge.net/asymptote/asymptote-2.08.src.tgz'
  homepage 'http://asymptote.sourceforge.net/'
  md5 'ab7bc11c8110b6eb459285b9c206cfe6'

  depends_on 'readline'
  depends_on 'bdw-gc'

  def link_asy_texmfhome
    texmfhome = `kpsewhich -var-value=TEXMFHOME`.chop
    texmflocl = `kpsewhich -var-value=TEXMFLOCAL`.chop

    asyhome = "#{texmfhome}/tex/latex/asymptote-brew"
    asylocl = "#{texmflocl}/tex/latex/asymptote"
    system "mkdir -p #{asyhome}"

    for asyfile in ['asycolors.sty','asymptote.sty','ocg.sty','latexmkrc']
      system "ln -s -f #{asylocl}/#{asyfile} #{asyhome}/#{asyfile}"
    end
  end

  def install
    unless TeX_installed?
      onoe <<-EOS.undent
        Asymptote requires a TeX/LaTeX installation; aborting now.
        You can obtain the TeX distribution for Mac OS X from
            http://www.tug.org/mactex/
      EOS
      exit 1
    end

    system "./configure", "--prefix=#{prefix}",
                          "--enable-gc=#{HOMEBREW_PREFIX}"
    system "make install"
    link_asy_texmfhome
  end

  def caveats
    caveats = <<-EOS
1) This formula links the latest version of asymptote.sty into your user
   texmf directory:

       ~/Library/texmf/tex/asymptote-brew/asymptote.sty

   This file links back to where the Asymptote source installer puts it:

       /usr/local/texlive/texmf-local/tex/latex/asymptote/asymptote.sty

   Other users of your machine will not be able to use the source-installed
   version of asymptote.sty unless they perform a similar linking operation;
   e.g.,

       mkdir -p ~/Library/texmf/tex/asymptote-brew/
       ln -s /usr/local/texlive/texmf-local/tex/latex/asymptote/asymptote.sty  ~/Library/texmf/tex/asymptote-brew/asymptote.sty

   and similarly for asycolors.sty, ocg.sty, and latexmkrc.

   If you are not using MacTeX / TeX Live or you have customised your TeX
   distribution, the paths shown above may not match your particular system,
   but you get the idea.


2) If you want to have Asymptote compiled with support for fftw or gsl
   (fast fourier transforms or the GNU Scientific Library) they must be
   manually installed first:

       brew install fftw
       brew install gsl

   They are not compiled by default because they take a long time to compile
   and they are not required by most users. (And they're not included in the
   TeX Live build of Asymptote.)


3) If you wish to use xasy, you must first install the Python Imaging
   Library (PIL):

       easy_install http://effbot.org/downloads/Imaging-1.1.7.tar.gz

    EOS
  end
end