homebrew-core/Formula/emacs.rb
2018-09-17 20:42:01 +10:00

147 lines
4.3 KiB
Ruby

class Emacs < Formula
desc "GNU Emacs text editor"
homepage "https://www.gnu.org/software/emacs/"
url "https://ftp.gnu.org/gnu/emacs/emacs-26.1.tar.xz"
mirror "https://ftpmirror.gnu.org/emacs/emacs-26.1.tar.xz"
sha256 "1cf4fc240cd77c25309d15e18593789c8dbfba5c2b44d8f77c886542300fd32c"
revision 1
bottle do
sha256 "9a9f7ae57531504d56f3a0bce2d810ce3208fbe1250958c9ba3586a50bd9e098" => :mojave
sha256 "f7cb2b2b9b7e519186657ac86929b0e07ab885781f3c0d5e281a4df9beb61b3a" => :high_sierra
sha256 "3e517198c33af574942a5d7beb031791825aedc029f98a2dd0ec5d24ba9f7121" => :sierra
sha256 "490eb74c1f94db84d77311eb9d3aa6c0c9085e9f971a48e31386488a92799514" => :el_capitan
end
head do
url "https://github.com/emacs-mirror/emacs.git"
depends_on "autoconf" => :build
depends_on "gnu-sed" => :build
depends_on "texinfo" => :build
end
option "with-cocoa", "Build a Cocoa version of emacs"
option "with-ctags", "Don't remove the ctags executable that emacs provides"
option "without-libxml2", "Don't build with libxml2 support"
option "with-modules", "Compile with dynamic modules support"
deprecated_option "cocoa" => "with-cocoa"
deprecated_option "keep-ctags" => "with-ctags"
deprecated_option "with-d-bus" => "with-dbus"
deprecated_option "imagemagick" => "imagemagick@6"
depends_on "pkg-config" => :build
depends_on "gnutls"
depends_on "dbus" => :optional
# Emacs does not support ImageMagick 7:
# Reported on 2017-03-04: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25967
depends_on "imagemagick@6" => :optional
depends_on "librsvg" => :optional
depends_on "mailutils" => :optional
def install
args = %W[
--disable-dependency-tracking
--disable-silent-rules
--enable-locallisppath=#{HOMEBREW_PREFIX}/share/emacs/site-lisp
--infodir=#{info}/emacs
--prefix=#{prefix}
--with-gnutls
--without-x
]
if build.with? "libxml2"
args << "--with-xml2"
else
args << "--without-xml2"
end
if build.with? "dbus"
args << "--with-dbus"
else
args << "--without-dbus"
end
# Note that if ./configure is passed --with-imagemagick but can't find the
# library it does not fail but imagemagick support will not be available.
# See: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24455
if build.with? "imagemagick@6"
args << "--with-imagemagick"
else
args << "--without-imagemagick"
end
args << "--with-modules" if build.with? "modules"
args << "--with-rsvg" if build.with? "librsvg"
args << "--without-pop" if build.with? "mailutils"
if build.head?
ENV.prepend_path "PATH", Formula["gnu-sed"].opt_libexec/"gnubin"
system "./autogen.sh"
end
if build.with? "cocoa"
args << "--with-ns" << "--disable-ns-self-contained"
else
args << "--without-ns"
end
system "./configure", *args
system "make"
system "make", "install"
if build.with? "cocoa"
prefix.install "nextstep/Emacs.app"
# Replace the symlink with one that avoids starting Cocoa.
(bin/"emacs").unlink # Kill the existing symlink
(bin/"emacs").write <<~EOS
#!/bin/bash
exec #{prefix}/Emacs.app/Contents/MacOS/Emacs "$@"
EOS
end
# Follow MacPorts and don't install ctags from Emacs. This allows Vim
# and Emacs and ctags to play together without violence.
if build.without? "ctags"
(bin/"ctags").unlink
(man1/"ctags.1.gz").unlink
end
end
def caveats
if build.with? "cocoa" then <<~EOS
Please try the Cask for a better-supported Cocoa version:
brew cask install emacs
EOS
end
end
plist_options :manual => "emacs"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/emacs</string>
<string>--fg-daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
assert_equal "4", shell_output("#{bin}/emacs --batch --eval=\"(print (+ 2 2))\"").strip
end
end