|
| 1 | +class Pdf2htmlex < Formula |
| 2 | + desc "PDF to HTML converter" |
| 3 | + homepage "https://coolwanglu.github.io/pdf2htmlEX/" |
| 4 | + url "https://github.com/coolwanglu/pdf2htmlEX/archive/v0.14.6.tar.gz" |
| 5 | + sha256 "320ac2e1c2ea4a2972970f52809d90073ee00a6c42ef6d9833fb48436222f0e5" |
| 6 | + revision 22 |
| 7 | + head "https://github.com/coolwanglu/pdf2htmlEX.git" |
| 8 | + |
| 9 | + bottle do |
| 10 | + sha256 "a668d32544101f61f3ca1c4c76f7b2342c91827c63615e129f07781a3aef00d6" => :mojave |
| 11 | + sha256 "41ef0b1e152aa0e15a3934a9f3143818c05b5a46ceb44196f9425c398ab877e2" => :high_sierra |
| 12 | + sha256 "194a3c710b1408a83ab49a8aea30fb7e1189502766c3d4804f4737fcace2d957" => :sierra |
| 13 | + end |
| 14 | + |
| 15 | + depends_on "autoconf" => :build # for fontforge |
| 16 | + depends_on "automake" => :build # for fontforge |
| 17 | + depends_on "cmake" => :build |
| 18 | + depends_on "pkg-config" => :build |
| 19 | + depends_on "cairo" # for fontforge |
| 20 | + depends_on "freetype" # for fontforge |
| 21 | + depends_on "gettext" # for fontforge |
| 22 | + depends_on "giflib" # for fontforge |
| 23 | + depends_on "glib" # for fontforge |
| 24 | + depends_on "gnu-getopt" |
| 25 | + depends_on "jpeg" # for fontforge |
| 26 | + depends_on "libpng" # for fontforge |
| 27 | + depends_on "libtiff" # for fontforge |
| 28 | + depends_on "libtool" # for fontforge |
| 29 | + |
| 30 | + depends_on "openjpeg" # for poppler |
| 31 | + depends_on "pango" # for fontforge |
| 32 | + depends_on "ttfautohint" |
| 33 | + |
| 34 | + # Pdf2htmlex use an outdated, customised Fontforge installation. |
| 35 | + # See https://github.com/coolwanglu/pdf2htmlEX/wiki/Building |
| 36 | + resource "fontforge" do |
| 37 | + url "https://github.com/coolwanglu/fontforge.git", :branch => "pdf2htmlEX" |
| 38 | + end |
| 39 | + |
| 40 | + # Upstream issue "poppler 0.59.0 incompatibility" |
| 41 | + # Reported 4 Sep 2017 https://github.com/coolwanglu/pdf2htmlEX/issues/733 |
| 42 | + resource "poppler" do |
| 43 | + url "https://poppler.freedesktop.org/poppler-0.57.0.tar.xz" |
| 44 | + sha256 "0ea37de71b7db78212ebc79df59f99b66409a29c2eac4d882dae9f2397fe44d8" |
| 45 | + end |
| 46 | + |
| 47 | + resource "poppler-data" do |
| 48 | + url "https://poppler.freedesktop.org/poppler-data-0.4.8.tar.gz" |
| 49 | + sha256 "1096a18161f263cccdc6d8a2eb5548c41ff8fcf9a3609243f1b6296abdf72872" |
| 50 | + end |
| 51 | + |
| 52 | + def install |
| 53 | + resource("fontforge").stage do |
| 54 | + # Fix for incomplete giflib 5 support, see |
| 55 | + # https://github.com/coolwanglu/pdf2htmlEX/issues/713 |
| 56 | + inreplace "gutils/gimagereadgif.c", "DGifCloseFile(gif)", "DGifCloseFile(gif, NULL)" |
| 57 | + |
| 58 | + # Fix linker error; see: https://trac.macports.org/ticket/25012 |
| 59 | + ENV.append "LDFLAGS", "-lintl" |
| 60 | + |
| 61 | + # Reset ARCHFLAGS to match how we build |
| 62 | + ENV["ARCHFLAGS"] = "-arch #{MacOS.preferred_arch}" |
| 63 | + |
| 64 | + system "./autogen.sh" |
| 65 | + system "./configure", "--prefix=#{libexec}/fontforge", |
| 66 | + "--without-libzmq", |
| 67 | + "--without-x", |
| 68 | + "--without-iconv", |
| 69 | + "--without-libspiro", |
| 70 | + "--without-libuninameslist", |
| 71 | + "--disable-python-scripting", |
| 72 | + "--disable-python-extension" |
| 73 | + system "make" |
| 74 | + system "make", "install" |
| 75 | + end |
| 76 | + |
| 77 | + ENV.prepend_path "PKG_CONFIG_PATH", "#{libexec}/fontforge/lib/pkgconfig" |
| 78 | + ENV.prepend_path "PATH", "#{libexec}/fontforge/bin" |
| 79 | + |
| 80 | + resource("poppler").stage do |
| 81 | + inreplace "poppler.pc.in", "Cflags: -I${includedir}/poppler", |
| 82 | + "Cflags: -I${includedir}/poppler -I${includedir}" |
| 83 | + |
| 84 | + system "./configure", "--disable-dependency-tracking", |
| 85 | + "--prefix=#{libexec}/poppler", |
| 86 | + "--enable-xpdf-headers", |
| 87 | + "--enable-poppler-glib", |
| 88 | + "--disable-gtk-test", |
| 89 | + "--enable-introspection=no", |
| 90 | + "--disable-poppler-qt4" |
| 91 | + system "make", "install" |
| 92 | + resource("poppler-data").stage do |
| 93 | + system "make", "install", "prefix=#{libexec}/poppler" |
| 94 | + end |
| 95 | + end |
| 96 | + |
| 97 | + ENV.prepend_path "PKG_CONFIG_PATH", "#{libexec}/poppler/lib/pkgconfig" |
| 98 | + ENV.prepend_path "PATH", "#{libexec}/poppler/bin" |
| 99 | + |
| 100 | + system "cmake", ".", *std_cmake_args |
| 101 | + system "make" |
| 102 | + system "make", "install" |
| 103 | + end |
| 104 | + |
| 105 | + test do |
| 106 | + system "#{bin}/pdf2htmlEX", test_fixtures("test.pdf") |
| 107 | + end |
| 108 | +end |
0 commit comments