Skip to content

Instantly share code, notes, and snippets.

@tyler274
Created November 9, 2016 17:03
Show Gist options
  • Save tyler274/8a1c74229e59c6ce4aec2faf053069b5 to your computer and use it in GitHub Desktop.
Save tyler274/8a1c74229e59c6ce4aec2faf053069b5 to your computer and use it in GitHub Desktop.
class UniversalBrewedPython < Requirement
satisfy { archs_for_command("python").universal? }
def message; <<-EOS.undent
A build of GDB using a brewed Python was requested, but Python is not
a universal build.
GDB requires Python to be built as a universal binary or it will fail
if attempting to debug a 32-bit binary on a 64-bit host.
EOS
end
end
class Gdb < Formula
desc "GNU debugger"
homepage "https://www.gnu.org/software/gdb/"
head "http://sourceware.org/git/binutils-gdb.git"
deprecated_option "with-brewed-python" => "with-python"
option "with-python", "Use the Homebrew version of Python; by default system Python is used"
option "with-version-suffix", "Add a version suffix to program"
option "with-all-targets", "Build with support for all targets"
depends_on "pkg-config" => :build
depends_on "python" => :optional
depends_on "guile" => :optional
if build.with? "python"
depends_on UniversalBrewedPython
end
def install
args = [
"--prefix=#{prefix}",
"--disable-debug",
"--disable-dependency-tracking",
]
args << "--with-guile" if build.with? "guile"
args << "--enable-targets=all" if build.with? "all-targets"
if build.with? "python"
args << "--with-python=#{HOMEBREW_PREFIX}"
else
args << "--with-python=/usr"
end
if build.with? "version-suffix"
args << "--program-suffix=-#{version.to_s.slice(/^\d/)}"
end
system "./configure", *args
system "make"
system "make", "install"
# Remove conflicting items with binutils
rm_rf include
rm_rf lib
rm_rf share/"locale"
rm_rf share/"info"
end
def caveats; <<-EOS.undent
gdb requires special privileges to access Mac ports.
You will need to codesign the binary. For instructions, see:
https://sourceware.org/gdb/wiki/BuildingOnDarwin
EOS
end
test do
system bin/"gdb", bin/"gdb", "-configuration"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment