Skip to content

Instantly share code, notes, and snippets.

@mtyaka
Created August 19, 2013 13:11
Show Gist options
  • Save mtyaka/6268956 to your computer and use it in GitHub Desktop.
Save mtyaka/6268956 to your computer and use it in GitHub Desktop.
Homebrew formula that installs poppler 0.22.5 with several patches applied to the pdftocairo utility. The patches fix output to stdout and add -jpegquality <int> and -pngcompression <int> command line options.
require 'formula'
class PopplerData < Formula
url 'http://poppler.freedesktop.org/poppler-data-0.4.6.tar.gz'
sha1 'f030563eed9f93912b1a546e6d87936d07d7f27d'
end
class Poppler < Formula
homepage 'http://poppler.freedesktop.org'
url 'http://poppler.freedesktop.org/poppler-0.22.5.tar.gz'
sha1 '9491bb33788d7f0ee67da572dc4798004f98323a'
option 'with-qt4', 'Build Qt backend'
option 'with-glib', 'Build Glib backend'
depends_on 'pkg-config' => :build
depends_on :fontconfig
depends_on 'openjpeg'
depends_on 'libpng'
depends_on 'qt' if build.with? 'qt4'
depends_on 'glib' => :optional
depends_on 'cairo' if build.with? 'glib' # Needs a newer Cairo build than OS X 10.6.7 provides
def patches
['https://gist.github.com/mtyaka/6196945/raw/f786afd7d4e40a5c744dde9f4b823239a92c3d27/pdftocairo-stdout.patch',
'https://gist.github.com/mtyaka/6267472/raw/8057b6f9c222d89ae6c702a1963648f04251db0e/pdftocairo-jpegquality.patch',
'https://gist.github.com/mtyaka/6267779/raw/d9ff07c009f16e048723093420c4d9a60f3e6bbc/pdftocairo-pngcompression.patch']
end
def install
if build.with? 'qt4'
ENV['POPPLER_QT4_CFLAGS'] = `#{HOMEBREW_PREFIX}/bin/pkg-config QtCore QtGui --libs`.chomp
ENV.append 'LDFLAGS', "-Wl,-F#{HOMEBREW_PREFIX}/lib"
end
args = ["--disable-dependency-tracking", "--prefix=#{prefix}", "--enable-xpdf-headers"]
# Explicitly disable Qt if not requested because `POPPLER_QT4_CFLAGS` won't
# be set and the build will fail.
#
# Also, explicitly disable Glib as Poppler will find it and set up to
# build, but Superenv will have stripped the Glib utilities out of the
# PATH.
args << ( build.with?('qt4') ? '--enable-poppler-qt4' : '--disable-poppler-qt4' )
args << ( build.with?('glib') ? '--enable-poppler-glib' : '--disable-poppler-glib' )
system "./configure", *args
system "make install"
# Install poppler font data.
PopplerData.new.brew do
system "make", "install", "prefix=#{prefix}"
end
end
end
@mtyaka
Copy link
Author

mtyaka commented Aug 19, 2013

Install with:

brew install https://gist.github.com/mtyaka/6268956/raw/f56f36dc8338c6bf8cb14aa0f6a86ed496daa411/poppler.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment