Skip to content

Instantly share code, notes, and snippets.

@sxua
Forked from Echos/pdftk.rb
Last active December 20, 2015 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sxua/6210636 to your computer and use it in GitHub Desktop.
Save sxua/6210636 to your computer and use it in GitHub Desktop.
--- pdftk/Makefile.OSX-10.6.orig 2013-07-24 21:27:36.000000000 +0300
+++ pdftk/Makefile.OSX-10.6 2013-08-12 19:44:24.000000000 +0300
@@ -20,13 +20,13 @@
# tools
# need direct path to libgcj for gcjh (starting in gcj 4.1.2 per Aurélien GÉRÔME)
-TOOLPATH=/sw/lib/gcc4.5/bin/
-export VERSUFF=-fsf-4.5
+TOOLPATH=@HOMEBREW_PREFIX@/bin/
+export VERSUFF= -4.6
export CXX= $(TOOLPATH)g++$(VERSUFF)
export GCJ= $(TOOLPATH)gcj$(VERSUFF)
export GCJH= $(TOOLPATH)gcjh$(VERSUFF)
export GJAR= $(TOOLPATH)gjar$(VERSUFF)
-export LIBGCJ= /sw/lib/gcc4.5/share/java/libgcj-4.5.0.jar
+export LIBGCJ= @PREFIX@/share/java/libgcj-@GCC_VERSION@.jar
export AR= ar
export RM= rm
export ARFLAGS= rs
@@ -63,11 +63,10 @@
# only effects libraries following option on the command line
#
#
-export MACOSX_DEPLOYMENT_TARGET= 10.4
-export CPPFLAGS= -DPATH_DELIM=0x2f -DASK_ABOUT_WARNINGS=false -DUNBLOCK_SIGNALS -fdollars-in-identifiers -mmacosx-version-min=10.4
+export CPPFLAGS= -DPATH_DELIM=0x2f -DASK_ABOUT_WARNINGS=false -DUNBLOCK_SIGNALS -fdollars-in-identifiers
export CXXFLAGS= -Wall -Wextra -Weffc++ -O2
-export GCJFLAGS= -Wall -fsource=1.3 -O2
+export GCJFLAGS= -Wall -fno-assert -O2
export GCJHFLAGS= -force
-export LDLIBS= /sw/lib/gcc4.5/lib/libgcj.dylib /sw/lib/gcc4.5/lib/libstdc++.dylib /sw/lib/gcc4.5/lib/libgcc_s.1.dylib -liconv -lz
+export LDLIBS= @PREFIX@/gcc/lib/libgcj.dylib @PREFIX@/gcc/lib/libstdc++.dylib @PREFIX@/gcc/lib/libgcc_s.1.dylib -liconv -lz
include Makefile.Base
require 'formula'
class Pdftk < Formula
url 'http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-2.02-src.zip'
homepage 'http://www.pdflabs.com/'
sha1 'a4a27e984c5e1401cfa44b8e92a64113d7396a06'
depends_on 'ecj'
depends_on 'gcc46' => 'enable-java'
def patches
# make it compartible with modern OS X
"https://gist.github.com/sxua/6210636/raw/d1d1c00ae67365799ecc59009a38643d888f7bc2/patch-Makefile.OSX-10.6.diff"
end
def install
doc.mkpath
doc.install "changelog.html" "changelog.txt" "pdftk.1.html" "pdftk.1.txt"
man1.install "pdftk.1"
cd "pdftk" do
inreplace "Makefile.OSX-10.6" do |s|
s.gsub! "@HOMEBREW_PREFIX@", "#{HOMEBREW_PREFIX}"
s.gsub! "@PREFIX@", "#{Formula.factory('gcc46').prefix}"
s.gsub! "@GCC_VERSION", "#{Formula.factory('gcc46').version}"
s.remove_make_var! "VERSUFF"
end
system "make -f Makefile.OSX-10.6"
bin.install "pdftk"
end
end
end
@jmccaffrey
Copy link

thanks for this.
While I was not able to get the original, or your fork working on mountain lion (10.8.5), I learned a lot more about homebrew and how it works.

(I was getting errors of "dyld: _dyld_bind_fully_image_containing_address() error" with the original install from the pdflabs site, and java compile/path issues during make with this formula)

the patch failed for me, and said it couldn't find the file. I played around with it and got it to work by setting the -po instead of -p (then applying the updated Makefile back into the zip and skipping the patch step)

the doc.install failed for me

the s.remove_make_var! "VERSUFF" didn't work for me, because remove_make_var is looking to match from the beginning of the line, and the Makefile has that var as 'export VERSUFF'.

Future users of your formula might be able to simplify the diff by removing the TOOLPATH and VERSUFF, and just setting them during the make call
make -f Makefile.OSX-10.6 TOOLPATH=/usr/local/bin/ VERSUFF=-4.6

After all the things I tried. It still got an error after the make, and didn't install.

Ultimately I used the binary directly from http://www.kunugiken.com/os-x/compiling-pdftk-for-snow-leopard

@nnadboralski-zz
Copy link

I was not able to make this gist work.

It failed on the patching step, not recognizing the correct file to modify I believe. However, i was able to make the changes to the makefile by hand, using your gist and diff to understand what needed to be done, and i was able to compile pdftk 1.45 with gcc47 installed frome homebrew with --enable-java

@spl
Copy link

spl commented Jan 15, 2014

If you came here (as I did) looking for a fully working Homebrew formula for pdftk, I hope this tap will help. It's my first formula, so feedback is welcome.

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