2010-01-22 05:12:17 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Fontforge < Formula
|
2010-01-22 05:12:17 +00:00
|
|
|
homepage 'http://fontforge.sourceforge.net'
|
2012-08-03 09:25:12 +00:00
|
|
|
url 'http://downloads.sourceforge.net/project/fontforge/fontforge-source/fontforge_full-20120731-b.tar.bz2'
|
|
|
|
sha1 'b520f532b48e557c177dffa29120225066cc4e84'
|
2010-01-22 05:12:17 +00:00
|
|
|
|
2012-08-16 19:51:09 +00:00
|
|
|
head 'https://github.com/fontforge/fontforge.git'
|
2012-03-06 03:57:10 +00:00
|
|
|
|
2012-09-02 08:03:05 +00:00
|
|
|
option 'without-python', 'Build without Python'
|
|
|
|
option 'with-x', 'Build with X'
|
|
|
|
option 'with-cairo', 'Build with Cairo'
|
|
|
|
option 'with-pango', 'Build with Pango'
|
|
|
|
option 'with-libspiro', 'Build with Spiro spline support'
|
|
|
|
|
2010-01-22 05:12:17 +00:00
|
|
|
depends_on 'gettext'
|
2012-08-24 16:16:43 +00:00
|
|
|
depends_on :xcode # Because: #include </Developer/Headers/FlatCarbon/Files.h>
|
2010-01-22 05:12:17 +00:00
|
|
|
|
2012-09-02 08:03:05 +00:00
|
|
|
depends_on :x11 if build.include? "with-x"
|
|
|
|
depends_on 'cairo' if build.include? "with-cairo"
|
|
|
|
depends_on 'pango' if build.include? "with-pango"
|
|
|
|
depends_on 'libspiro' if build.include? "with-libspiro"
|
2011-06-13 22:06:03 +00:00
|
|
|
|
2012-03-18 20:33:24 +00:00
|
|
|
fails_with :llvm do
|
|
|
|
build 2336
|
|
|
|
cause "Compiling cvexportdlg.c fails with error: initializer element is not constant"
|
|
|
|
end
|
2011-03-13 18:13:53 +00:00
|
|
|
|
2011-03-21 21:24:22 +00:00
|
|
|
def install
|
2012-08-27 17:10:09 +00:00
|
|
|
# Reason: Designed for the 10.7 SDK because it uses FlatCarbon.
|
|
|
|
# MACOSX_DEPLOYMENT_TARGET fixes ensuing Python 10.7 vs 10.8 clash.
|
|
|
|
# Discussed: https://github.com/mxcl/homebrew/pull/14097
|
|
|
|
# Reported: Not yet.
|
2012-09-05 04:04:01 +00:00
|
|
|
if MacOS.version >= :mountain_lion
|
2012-08-27 17:10:09 +00:00
|
|
|
ENV.macosxsdk("10.7")
|
|
|
|
ENV.append "CFLAGS", "-isysroot #{MacOS.sdk_path(10.7)}"
|
|
|
|
ENV["MACOSX_DEPLOYMENT_TARGET"] = "10.8"
|
|
|
|
end
|
|
|
|
|
2012-03-06 03:57:10 +00:00
|
|
|
args = ["--prefix=#{prefix}",
|
|
|
|
"--enable-double",
|
|
|
|
"--without-freetype-bytecode"]
|
|
|
|
|
2012-08-27 17:10:09 +00:00
|
|
|
if build.include? "without-python"
|
2012-05-31 18:13:25 +00:00
|
|
|
args << "--without-python"
|
|
|
|
else
|
|
|
|
python_prefix = `python-config --prefix`.strip
|
|
|
|
python_version = `python-config --libs`.match('-lpython(\d+\.\d+)').captures.at(0)
|
|
|
|
args << "--with-python-headers=#{python_prefix}/include/python#{python_version}"
|
|
|
|
args << "--with-python-lib=-lpython#{python_version}"
|
|
|
|
args << "--enable-pyextension"
|
|
|
|
end
|
2011-06-13 22:06:03 +00:00
|
|
|
|
2012-05-31 18:13:25 +00:00
|
|
|
# Fix linking to correct Python library
|
2012-08-27 17:10:09 +00:00
|
|
|
ENV.prepend "LDFLAGS", "-L#{python_prefix}/lib" unless build.include? "without-python"
|
2011-03-13 18:13:53 +00:00
|
|
|
# Fix linker error; see: http://trac.macports.org/ticket/25012
|
|
|
|
ENV.append "LDFLAGS", "-lintl"
|
2012-05-31 18:13:25 +00:00
|
|
|
# Reset ARCHFLAGS to match how we build
|
|
|
|
ENV["ARCHFLAGS"] = MacOS.prefer_64_bit? ? "-arch x86_64" : "-arch i386"
|
|
|
|
|
2012-09-02 08:03:05 +00:00
|
|
|
args << "--without-cairo" unless build.include? "with-cairo"
|
|
|
|
args << "--without-pango" unless build.include? "with-pango"
|
|
|
|
|
2011-06-13 22:06:03 +00:00
|
|
|
system "./configure", *args
|
2010-09-09 19:38:22 +00:00
|
|
|
|
2011-07-29 16:05:08 +00:00
|
|
|
# Fix hard-coded install locations that don't respect the target bindir
|
2010-09-09 19:38:22 +00:00
|
|
|
inreplace "Makefile" do |s|
|
|
|
|
s.gsub! "/Applications", "$(prefix)"
|
2011-07-29 16:05:08 +00:00
|
|
|
s.gsub! "ln -s /usr/local/bin/fontforge", "ln -s $(bindir)/fontforge"
|
2010-09-09 19:38:22 +00:00
|
|
|
end
|
|
|
|
|
2012-05-31 18:13:25 +00:00
|
|
|
# Fix install location of Python extension; see:
|
|
|
|
# http://sourceforge.net/mailarchive/message.php?msg_id=26827938
|
|
|
|
inreplace "Makefile" do |s|
|
|
|
|
s.gsub! "python setup.py install --prefix=$(prefix) --root=$(DESTDIR)", "python setup.py install --prefix=$(prefix)"
|
|
|
|
end
|
|
|
|
|
2012-03-06 03:57:10 +00:00
|
|
|
# Fix hard-coded include file paths. Reported usptream:
|
|
|
|
# http://sourceforge.net/mailarchive/forum.php?thread_name=C1A32103-A62D-468B-AD8A-A8E0E7126AA5%40smparkes.net&forum_name=fontforge-devel
|
|
|
|
# https://trac.macports.org/ticket/33284
|
2012-08-27 17:10:09 +00:00
|
|
|
if MacOS::Xcode.version >= '4.4'
|
|
|
|
header_prefix = "#{MacOS.sdk_path(10.7)}/Developer"
|
|
|
|
else
|
|
|
|
header_prefix = MacOS::Xcode.prefix
|
|
|
|
end
|
2012-03-06 03:57:10 +00:00
|
|
|
inreplace %w(fontforge/macbinary.c fontforge/startui.c gutils/giomime.c) do |s|
|
2012-08-27 17:10:09 +00:00
|
|
|
s.gsub! "/Developer", header_prefix
|
2012-03-06 03:57:10 +00:00
|
|
|
end
|
|
|
|
|
2010-01-22 05:12:17 +00:00
|
|
|
system "make"
|
|
|
|
system "make install"
|
|
|
|
end
|
|
|
|
|
2012-05-31 18:13:25 +00:00
|
|
|
def which_python
|
|
|
|
"python" + `python -c 'import sys;print(sys.version[:3])'`.strip
|
|
|
|
end
|
2010-09-09 19:38:22 +00:00
|
|
|
|
2012-09-02 08:03:05 +00:00
|
|
|
def test
|
|
|
|
system "#{bin}/fontforge", "-version"
|
|
|
|
end
|
|
|
|
|
2012-05-31 18:13:25 +00:00
|
|
|
def caveats
|
2012-09-02 08:03:05 +00:00
|
|
|
x_caveats = <<-EOS.undent
|
2012-05-31 18:13:25 +00:00
|
|
|
fontforge is an X11 application.
|
|
|
|
|
|
|
|
To install the Mac OS X wrapper application run:
|
2011-04-04 23:56:47 +00:00
|
|
|
brew linkapps
|
2012-05-31 18:13:25 +00:00
|
|
|
or:
|
2011-07-29 16:05:08 +00:00
|
|
|
ln -s #{prefix}/FontForge.app /Applications
|
2010-09-09 19:38:22 +00:00
|
|
|
EOS
|
2012-05-31 18:13:25 +00:00
|
|
|
|
|
|
|
python_caveats = <<-EOS.undent
|
|
|
|
|
|
|
|
To use the Python extension with non-homebrew Python, you need to amend your
|
|
|
|
PYTHONPATH like so:
|
|
|
|
export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
|
|
|
|
EOS
|
|
|
|
|
2012-09-02 08:03:05 +00:00
|
|
|
s = ""
|
|
|
|
s += x_caveats if build.include? "with-x"
|
2012-08-27 17:10:09 +00:00
|
|
|
s += python_caveats unless build.include? "without-python"
|
2012-05-31 18:13:25 +00:00
|
|
|
return s
|
2010-01-22 05:12:17 +00:00
|
|
|
end
|
|
|
|
end
|