Skip to content

Instantly share code, notes, and snippets.

@giuliano108
Created September 30, 2014 23:15
Show Gist options
  • Save giuliano108/57d0532e84570a781f85 to your computer and use it in GitHub Desktop.
Save giuliano108/57d0532e84570a781f85 to your computer and use it in GitHub Desktop.
HomeBrew ncurses formula. Includes the pkgconfig files and plays nice with goncurses.
require 'formula'
# export PKG_CONFIG_PATH=/usr/local/Cellar/ncurses/5.9/lib/pkgconfig
class Ncurses < Formula
homepage 'http://www.gnu.org/s/ncurses/'
url 'http://ftpmirror.gnu.org/ncurses/ncurses-5.9.tar.gz'
mirror 'http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz'
sha1 '3e042e5f2c7223bffdaac9646a533b8c758b65b5'
keg_only :provided_by_osx
option :universal
depends_on 'pkg-config' => :build
# Fix building C++ bindings with clang
patch :p0 do
url "https://trac.macports.org/export/103963/trunk/dports/devel/ncurses/files/constructor_types.diff"
sha1 "60f3e64c7793381307e2a3849df7ae282e46c36e"
end
# Stop using obsolete -no-cpp-precomp flag, which breaks FSF GCC
# Reported upstream by email
patch :DATA
def install
ENV.universal_binary if build.universal?
mkdir "pkgconfig"
ENV["PKG_CONFIG_LIBDIR"] = "#{buildpath}/pkgconfig"
system "./configure", "--disable-debug",
"--prefix=#{prefix}",
"--mandir=#{man}",
"--with-shared",
"--with-pkg-config",
"--enable-pc-files",
"--enable-widec",
"--with-manpage-format=normal",
"--enable-symlinks"
system "make"
system "make install"
p = StringPatch.new :p0, <<EOP
*** pkgconfig.orig/ncursesw.pc 2014-09-30 22:53:22.000000000 +0100
--- pkgconfig/ncursesw.pc 2014-09-30 22:53:22.000000000 +0100
***************
*** 1,7 ****
prefix=/usr/local/Cellar/ncurses/5.9
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
! includedir=${prefix}/include/ncursesw
major_version=5
version=5.9.20110404
--- 1,7 ----
prefix=/usr/local/Cellar/ncurses/5.9
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
! includedir=${prefix}/include
major_version=5
version=5.9.20110404
EOP
p.apply
system "cp", "-a", "#{buildpath}/pkgconfig", lib
make_libncurses_symlinks
end
def make_libncurses_symlinks
major = version.to_s.split(".")[0]
cd lib do
%w{form menu ncurses panel}.each do |name|
ln_s "lib#{name}w.#{major}.dylib", "lib#{name}.dylib"
ln_s "lib#{name}w.#{major}.dylib", "lib#{name}.#{major}.dylib"
ln_s "lib#{name}w.a", "lib#{name}.a"
ln_s "lib#{name}w_g.a", "lib#{name}_g.a"
end
ln_s "libncurses++w.a", "libncurses++.a"
end
cd "#{lib}/pkgconfig" do
%w{form menu ncurses panel}.each do |name|
ln_s "#{name}w.pc", "#{name}.pc"
end
end
cd bin do
ln_s "ncursesw#{major}-config", "ncurses#{major}-config"
end
end
end
__END__
diff --git a/Ada95/configure b/Ada95/configure
index 4db6f1f..e82bb4b 100755
--- a/Ada95/configure
+++ b/Ada95/configure
@@ -7460,7 +7460,6 @@ CF_EOF
chmod +x mk_shared_lib.sh
;;
darwin*) #(vi
- EXTRA_CFLAGS="-no-cpp-precomp"
CC_SHARED_OPTS="-dynamic"
MK_SHARED_LIB='${CC} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $@` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $@'
test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
diff --git a/configure b/configure
index 639b790..25d69b3 100755
--- a/configure
+++ b/configure
@@ -5584,7 +5584,6 @@ CF_EOF
chmod +x mk_shared_lib.sh
;;
darwin*) #(vi
- EXTRA_CFLAGS="-no-cpp-precomp"
CC_SHARED_OPTS="-dynamic"
MK_SHARED_LIB='${CC} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $@` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $@'
test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment