86 lines
3.0 KiB
Ruby
86 lines
3.0 KiB
Ruby
class Mupdf < Formula
|
|
desc "Lightweight PDF and XPS viewer"
|
|
homepage "https://mupdf.com/"
|
|
url "https://mupdf.com/downloads/archive/mupdf-1.20.0-source.tar.lz"
|
|
sha256 "68dbb1cf5e31603380ce3f1c7f6c431ad442fa735d048700f50ab4de4c3b0f82"
|
|
license "AGPL-3.0-or-later"
|
|
revision 1
|
|
head "https://git.ghostscript.com/mupdf.git", branch: "master"
|
|
|
|
livecheck do
|
|
url "https://mupdf.com/downloads/archive/"
|
|
regex(/href=.*?mupdf[._-]v?(\d+(?:\.\d+)+)-source\.(?:t|zip)/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "ede506c4bc48b3092f01c6cf28b010bc97335fecdd82868b26906fb2b40d7657"
|
|
sha256 cellar: :any, arm64_big_sur: "47a750c5a8496636ec95b6cb795f5d8c69fd8276a7d82bfa56f7c335f3752449"
|
|
sha256 cellar: :any, monterey: "521afd339695b937ee947ac532bee1167f4f9d0eacc78d7e7d85bbd6dd001555"
|
|
sha256 cellar: :any, big_sur: "fdf5620f1d447bbdfe12f933717500d018f0848d7dbf785d6c8b632a9037435b"
|
|
sha256 cellar: :any, catalina: "53fa93d6ad092065f3b2d734a275ea0c1123036978c11ba76791d6285fec102b"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "9e02cd29a6a482eb30cf82bd599cf014db70d70fd965d7c832d914f044afd128"
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "freetype"
|
|
depends_on "gumbo-parser"
|
|
depends_on "harfbuzz"
|
|
depends_on "jbig2dec"
|
|
depends_on "jpeg-turbo"
|
|
depends_on "mujs"
|
|
depends_on "openjpeg"
|
|
depends_on "openssl@1.1"
|
|
|
|
uses_from_macos "zlib"
|
|
|
|
on_linux do
|
|
depends_on "freeglut"
|
|
depends_on "libx11"
|
|
depends_on "libxext"
|
|
depends_on "mesa"
|
|
end
|
|
|
|
conflicts_with "mupdf-tools",
|
|
because: "mupdf and mupdf-tools install the same binaries"
|
|
|
|
def install
|
|
# Remove bundled libraries excluding `extract` and "strongly preferred" `lcms2mt` (lcms2 fork)
|
|
keep = %w[extract lcms2]
|
|
(buildpath/"thirdparty").each_child { |path| path.rmtree if keep.exclude? path.basename.to_s }
|
|
|
|
args = %W[
|
|
build=release
|
|
shared=yes
|
|
verbose=yes
|
|
prefix=#{prefix}
|
|
CC=#{ENV.cc}
|
|
USE_SYSTEM_LIBS=yes
|
|
USE_SYSTEM_MUJS=yes
|
|
]
|
|
# Build only runs pkg-config for libcrypto on macOS, so help find other libs
|
|
if OS.mac?
|
|
[
|
|
["FREETYPE", "freetype2"],
|
|
["GUMBO", "gumbo"],
|
|
["HARFBUZZ", "harfbuzz"],
|
|
["LIBJPEG", "libjpeg"],
|
|
["OPENJPEG", "libopenjp2"],
|
|
].each do |argname, libname|
|
|
args << "SYS_#{argname}_CFLAGS=#{Utils.safe_popen_read("pkg-config", "--cflags", libname).strip}"
|
|
args << "SYS_#{argname}_LIBS=#{Utils.safe_popen_read("pkg-config", "--libs", libname).strip}"
|
|
end
|
|
end
|
|
system "make", "install", *args
|
|
|
|
# Symlink `mutool` as `mudraw` (a popular shortcut for `mutool draw`).
|
|
bin.install_symlink bin/"mutool" => "mudraw"
|
|
man1.install_symlink man1/"mutool.1" => "mudraw.1"
|
|
|
|
lib.install_symlink lib/shared_library("libmupdf") => shared_library("libmupdf-third")
|
|
end
|
|
|
|
test do
|
|
assert_match "Homebrew test", shell_output("#{bin}/mudraw -F txt #{test_fixtures("test.pdf")}")
|
|
end
|
|
end
|