require 'formula' class Libmikmod < Formula url 'https://github.com/mistydemeo/libmikmod.git', :tag => '446324a45a6d165b1941a4758f6cd221301b479e' homepage 'http://mikmod.raphnet.net/' version '3.2.0b2' def options [[ '--with-debug', 'Enable debugging symbols and build without optimization' ]] end def patches # When aclocal is run on configure.in, it is told to use a macro AM_PATH_ESD that # only exists if esound is installed. Here CoreAudio is used not esound. DATA unless Formula.factory('esound').installed? end def install ENV.no_optimization if ARGV.include? '--with-debug' # leave code unoptimzed 4 debug ENV['LIBTOOLIZE'] = '/usr/bin/glibtoolize' # system libtoolize for autoreconf acpath = "#{HOMEBREW_PREFIX}/share/aclocal" # esd.m4 if installed would be here ENV['ACLOCAL'] = "/usr/bin/aclocal -I #{acpath}" if Formula.factory('esound').installed? # Macports patched libmikmod-3.2.0-beta2.tar.bz2 in 2004. Most of their work # was merged into the upstream source by 2005 when the devs moved to sourceforge. # Development stopped a year later, after many more bug fixes and improvements. # The version was never changed. It is still called 3.2.0b2 inside their code. # This formula builds 3.2.0b2 from cvs, the final libmikmod at this time. # The patch below is the only one from Macports the devs didn't merge. It # prevents a crash on accessing the samples menu in Mikmod. Check if Samples[] # exists before letting the subsequent code try to access the array items. # Also in cvs is one error that stops the build. Below is a new patch # that fixes the error when linking libmikmod.dylib, where the build outputs: # ld: duplicate symbol _vc_callback in .libs/virtch2.o and .libs/virtch.o # Problem: vc_callback is declared twice globally and once as an extern. # Solution: Switch it to declared once globally and twice as extern. # And finally in cvs the function vc_callback() is defined to use unsigned char*. # With this patch, virtch2.c and virtch.c will use vc_callback() identically. inreplace 'playercode/virtch_common.c', '(handle