Created
March 2, 2017 16:21
-
-
Save fxcoudert/ffeb1169cb103822ae84d4d2cf87f63a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: When updating Wine, please check Wine-Gecko and Wine-Mono for updates | |
# too: | |
# - https://wiki.winehq.org/Gecko | |
# - https://wiki.winehq.org/Mono | |
class Wine2 < Formula | |
desc "Run Windows applications without a copy of Microsoft Windows" | |
homepage "https://www.winehq.org/" | |
head "git://source.winehq.org/git/wine.git" | |
stable do | |
url "https://dl.winehq.org/wine/source/2.0/wine-2.0.tar.bz2" | |
mirror "https://downloads.sourceforge.net/project/wine/Source/wine-2.0.tar.bz2" | |
sha256 "9756f5a2129b6a83ba701e546173cbff86caa671b0af73eb8f72c03b20c066c6" | |
end | |
bottle do | |
sha256 "29ab2b430945643e3473866017e6cd9e200271d11457d80c24ec69464de0f2f3" => :sierra | |
sha256 "0c2efb3577a97bd16fc61ce6910a1269698e4f59e8d6a43b5708f707c45cc5f1" => :el_capitan | |
sha256 "f2de1ecef894c6ea79d7bdb1b60703879cb114180272edca0cfbba18a4051893" => :yosemite | |
end | |
devel do | |
url "https://dl.winehq.org/wine/source/2.x/wine-2.1.tar.xz" | |
mirror "https://downloads.sourceforge.net/project/wine/Source/wine-2.1.tar.xz" | |
sha256 "bfb9abf63691c93df28d9599aaa866dc2b4e27209b3b7b546df8a37d7d9d1e6e" | |
end | |
if MacOS.version >= :el_capitan | |
option "without-win64", "Build without 64-bit support" | |
depends_on :xcode => ["8.0", :build] if build.with? "win64" | |
end | |
# Wine will build both the Mac and the X11 driver by default, and you can switch | |
# between them. But if you really want to build without X11, you can. | |
depends_on :x11 => :recommended | |
depends_on "pkg-config" => :build | |
depends_on "cmake" => :build | |
depends_on "makedepend" => :build | |
depends_on "libtool" => :run | |
depends_on "gnutls" | |
# Patch to fix texture compression issues. Still relevant on 2.0. | |
# https://bugs.winehq.org/show_bug.cgi?id=14939 | |
patch do | |
url "https://bugs.winehq.org/attachment.cgi?id=52384" | |
sha256 "30766403f5064a115f61de8cacba1defddffe2dd898b59557956400470adc699" | |
end | |
# Patch to fix screen-flickering issues. Still relevant on 2.0. | |
# https://bugs.winehq.org/show_bug.cgi?id=34166 | |
patch do | |
url "https://bugs.winehq.org/attachment.cgi?id=55968" | |
sha256 "1b5086798ce6dc959b3cbb8f343ee236ae06c7910e4bbae7d9fde3f162f03a79" | |
end | |
resource "gecko" do | |
url "https://downloads.sourceforge.net/wine/wine_gecko-2.40-x86.msi", :using => :nounzip | |
sha256 "1a29d17435a52b7663cea6f30a0771f74097962b07031947719bb7b46057d302" | |
end | |
resource "mono" do | |
url "https://downloads.sourceforge.net/wine/wine-mono-4.5.6.msi", :using => :nounzip | |
sha256 "ac681f737f83742d786706529eb85f4bc8d6bdddd8dcdfa9e2e336b71973bc25" | |
end | |
resource "openssl" do | |
url "https://www.openssl.org/source/openssl-1.0.2k.tar.gz" | |
sha256 "6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0" | |
end | |
resource "jpeg" do | |
url "http://www.ijg.org/files/jpegsrc.v8d.tar.gz" | |
sha256 "00029b1473f0f0ea72fbca3230e8cb25797fbb27e58ae2e46bb8bf5a806fe0b3" | |
end | |
resource "libtiff" do | |
url "http://download.osgeo.org/libtiff/tiff-4.0.7.tar.gz" | |
sha256 "9f43a2cfb9589e5cecaa66e16bf87f814c945f22df7ba600d63aac4632c4f019" | |
end | |
resource "little-cms2" do | |
url "https://downloads.sourceforge.net/project/lcms/lcms/2.8/lcms2-2.8.tar.gz" | |
sha256 "66d02b229d2ea9474e62c2b6cd6720fde946155cd1d0d2bffdab829790a0fb22" | |
end | |
resource "libpng" do | |
url "ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.28.tar.xz" | |
sha256 "d8d3ec9de6b5db740fefac702c37ffcf96ae46cb17c18c1544635a3852f78f7a" | |
end | |
resource "freetype" do | |
url "https://downloads.sf.net/project/freetype/freetype2/2.7.1/freetype-2.7.1.tar.bz2" | |
sha256 "3a3bb2c4e15ffb433f2032f50a5b5a92558206822e22bfe8cbe339af4aa82f88" | |
end | |
resource "jasper" do | |
url "https://github.com/mdadams/jasper/archive/version-2.0.11.tar.gz" | |
sha256 "09b4e6446d0fb8a6abe63a67500ef170218fd06a5cc9cf855b7a79b6351f87c0" | |
end | |
resource "libicns" do | |
url "https://downloads.sourceforge.net/project/icns/libicns-0.8.1.tar.gz" | |
sha256 "335f10782fc79855cf02beac4926c4bf9f800a742445afbbf7729dab384555c2" | |
end | |
resource "libusb" do | |
url "https://github.com/libusb/libusb/releases/download/v1.0.21/libusb-1.0.21.tar.bz2" | |
sha256 "7dce9cce9a81194b7065ee912bcd55eeffebab694ea403ffb91b67db66b1824b" | |
end | |
resource "libusb-compat" do | |
url "https://downloads.sourceforge.net/project/libusb/libusb-compat-0.1/libusb-compat-0.1.5/libusb-compat-0.1.5.tar.bz2" | |
sha256 "404ef4b6b324be79ac1bfb3d839eac860fbc929e6acb1ef88793a6ea328bc55a" | |
end | |
resource "webp" do | |
url "http://downloads.webmproject.org/releases/webp/libwebp-0.6.0.tar.gz" | |
sha256 "c928119229d4f8f35e20113ffb61f281eda267634a8dc2285af4b0ee27cf2b40" | |
end | |
resource "fontconfig" do | |
url "https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.1.tar.bz2" | |
sha256 "b449a3e10c47e1d1c7a6ec6e2016cca73d3bd68fbbd4f0ae5cc6b573f7d6c7f3" | |
end | |
resource "gd" do | |
url "https://github.com/libgd/libgd/releases/download/gd-2.2.4/libgd-2.2.4.tar.xz" | |
sha256 "137f13a7eb93ce72e32ccd7cebdab6874f8cf7ddf31d3a455a68e016ecd9e4e6" | |
end | |
resource "libgphoto2" do | |
url "https://downloads.sourceforge.net/project/gphoto/libgphoto/2.5.12/libgphoto2-2.5.12.tar.bz2" | |
sha256 "b9bb28990fde45ac385e4851a07dbad2e1250404b535b0a3a3b898bb431e4e2e" | |
end | |
resource "net-snmp" do | |
url "https://downloads.sourceforge.net/project/net-snmp/net-snmp/5.7.3/net-snmp-5.7.3.tar.gz" | |
sha256 "12ef89613c7707dc96d13335f153c1921efc9d61d3708ef09f3fc4a7014fb4f0" | |
end | |
resource "sane-backends" do | |
url "https://fossies.org/linux/misc/sane-backends-1.0.25.tar.gz" | |
sha256 "a4d7ba8d62b2dea702ce76be85699940992daf3f44823ddc128812da33dc6e2c" | |
end | |
fails_with :clang do | |
build 425 | |
cause "Clang prior to Xcode 5 miscompiles some parts of wine" | |
end | |
# These libraries are not specified as dependencies, or not built as 32-bit: | |
# configure: libv4l, gstreamer-0.10, libcapi20, libgsm | |
def install | |
mkdir_p "#{prefix}/deps/bin" | |
ENV.prepend_path "PATH", "#{prefix}/deps/bin" | |
mkdir_p "#{prefix}/deps/lib/pkgconfig" | |
ENV.prepend_path "PKG_CONFIG_PATH", "#{prefix}/deps/lib/pkgconfig" | |
# Build OpenSSL first, as it does not use ENV.universal_binary | |
resource("openssl").stage do | |
ENV.deparallelize | |
ENV.permit_arch_flags | |
# OpenSSL will prefer the PERL environment variable if set over $PATH | |
# which can cause some odd edge cases & isn't intended. Unset for safety, | |
# along with perl modules in PERL5LIB. | |
ENV.delete("PERL") | |
ENV.delete("PERL5LIB") | |
# Load zlib from an explicit path instead of relying on dyld's fallback | |
# path, which is empty in a SIP context. This patch will be unnecessary | |
# when we begin building openssl with no-comp to disable TLS compression. | |
# https://langui.sh/2015/11/27/sip-and-dlopen | |
inreplace "crypto/comp/c_zlib.c", | |
'zlib_dso = DSO_load(NULL, "z", NULL, 0);', | |
'zlib_dso = DSO_load(NULL, "/usr/lib/libz.dylib", NULL, DSO_FLAG_NO_NAME_TRANSLATION);' | |
archs = Hardware::CPU.universal_archs | |
def arch_args | |
{ | |
:x86_64 => %w[darwin64-x86_64-cc enable-ec_nistp_64_gcc_128], | |
:i386 => %w[darwin-i386-cc], | |
} | |
end | |
dirs = [] | |
archs.each do |arch| | |
dir = "build-#{arch}" | |
dirs << dir | |
mkdir_p "#{dir}/engines" | |
system "make", "clean" | |
system "perl", "./Configure", "--prefix=#{prefix}/deps", | |
"no-ssl2", | |
"zlib-dynamic", | |
"shared", | |
"enable-cms", | |
*(arch_args[arch]) | |
system "make", "depend" | |
system "make" | |
cp "include/openssl/opensslconf.h", dir | |
cp Dir["*.?.?.?.dylib", "*.a", "apps/openssl"], dir | |
cp Dir["engines/**/*.dylib"], "#{dir}/engines" | |
end | |
system "make", "install" | |
%w[libcrypto libssl].each do |libname| | |
system "lipo", "-create", "#{dirs.first}/#{libname}.1.0.0.dylib", | |
"#{dirs.last}/#{libname}.1.0.0.dylib", | |
"-output", "#{prefix}/deps/lib/#{libname}.1.0.0.dylib" | |
system "lipo", "-create", "#{dirs.first}/#{libname}.a", | |
"#{dirs.last}/#{libname}.a", | |
"-output", "#{prefix}/deps/lib/#{libname}.a" | |
end | |
Dir.glob("#{dirs.first}/engines/*.dylib") do |engine| | |
libname = File.basename(engine) | |
system "lipo", "-create", "#{dirs.first}/engines/#{libname}", | |
"#{dirs.last}/engines/#{libname}", | |
"-output", "#{prefix}/deps/lib/engines/#{libname}" | |
end | |
system "lipo", "-create", "#{dirs.first}/openssl", | |
"#{dirs.last}/openssl", | |
"-output", "#{prefix}/deps/bin/openssl" | |
confs = archs.map do |arch| | |
<<-EOS.undent | |
#ifdef __#{arch}__ | |
#{(Pathname.pwd/"build-#{arch}/opensslconf.h").read} | |
#endif | |
EOS | |
end | |
(prefix/"deps/include/openssl/opensslconf.h").atomic_write confs.join("\n") | |
end | |
# All other resources use ENV.universal_binary | |
ENV.universal_binary | |
resource("jpeg").stage do | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps" | |
system "make", "install" | |
end | |
resource("libtiff").stage do | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps", | |
"--without-x", | |
"--disable-lzma", | |
"--with-jpeg-lib-dir=#{prefix}/deps/lib", | |
"--with-jpeg-include-dir=#{prefix}/deps/include" | |
system "make", "install" | |
end | |
resource("little-cms2").stage do | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps", | |
"--with-jpeg=#{prefix}/deps", | |
"--with-tiff=#{prefix}/deps" | |
system "make", "install" | |
end | |
resource("libpng").stage do | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps" | |
system "make", "install" | |
end | |
resource("freetype").stage do | |
system "./configure", "--prefix=#{prefix}/deps", | |
"--without-harfbuzz" | |
system "make", "install" | |
end | |
resource("jasper").stage do | |
mkdir "build" do | |
system "cmake", "..", *std_cmake_args, | |
"-DCMAKE_INSTALL_PREFIX=${prefix}/deps", | |
"-DJPEG_INCLUDE_DIR=#{prefix}/deps/include", | |
"-DJPEG_LIBRARY=#{prefix}/deps/lib/libjpeg.dylib" | |
system "make", "install" | |
end | |
end | |
resource("libicns").stage do | |
system "./configure", "--disable-dependency-tracking", | |
"--disable-debug", | |
"--prefix=#{prefix}/deps", | |
"CPPFLAGS=-I#{prefix}/deps/include", | |
"LDFLAGS=-L#{prefix}/deps/lib" | |
system "make", "install" | |
end | |
resource("libusb").stage do | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps" | |
system "make", "install" | |
end | |
resource("libusb-compat").stage do | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps" | |
system "make", "install" | |
end | |
resource("webp").stage do | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps", | |
"--disable-gl", | |
"--enable-libwebpmux", | |
"--enable-libwebpdemux", | |
"--enable-libwebpdecoder" | |
system "make", "install" | |
end | |
resource("fontconfig").stage do | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps", | |
"--enable-static", | |
"--with-add-fonts=/System/Library/Fonts,/Library/Fonts,~/Library/Fonts", | |
"--localstatedir=#{var}", | |
"--sysconfdir=#{prefix}" | |
system "make", "install", "RUN_FC_CACHE_TEST=false" | |
end | |
resource("gd").stage do | |
# Poor man's patch as this is a resource | |
inreplace "src/gd_gd2.c", | |
"#include <math.h>", | |
"#include <math.h>\n#include <limits.h>" | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps", | |
"--without-x", | |
"--without-xpm", | |
"--with-png=#{prefix}/deps", | |
"--with-fontconfig=#{prefix}/deps", | |
"--with-freetype=#{prefix}/deps", | |
"--with-jpeg=#{prefix}/deps", | |
"--with-tiff=#{prefix}/deps", | |
"--with-webp=#{prefix}/deps" | |
system "make", "install" | |
end | |
resource("libgphoto2").stage do | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps" | |
system "make", "install" | |
end | |
resource("net-snmp").stage do | |
# https://sourceforge.net/p/net-snmp/bugs/2504/ | |
ln_s "darwin13.h", "include/net-snmp/system/darwin14.h" | |
ln_s "darwin13.h", "include/net-snmp/system/darwin15.h" | |
ln_s "darwin13.h", "include/net-snmp/system/darwin16.h" | |
system "./configure", "--disable-debugging", | |
"--prefix=#{prefix}/deps", | |
"--enable-ipv6", | |
"--with-defaults", | |
"--with-persistent-directory=#{var}/db/net-snmp", | |
"--with-logfile=#{var}/log/snmpd.log", | |
"--with-mib-modules=host\ ucd-snmp/diskio", | |
"--without-rpm", | |
"--without-kmem-usage", | |
"--disable-embedded-perl", | |
"--without-perl-modules", | |
"--with-openssl=#{prefix}/deps" | |
system "make", "install" | |
end | |
resource("sane-backends").stage do | |
ENV.deparallelize | |
system "./configure", "--disable-dependency-tracking", | |
"--prefix=#{prefix}/deps", | |
"--localstatedir=#{var}", | |
"--without-gphoto2", | |
"--enable-local-backends", | |
"--enable-libusb", | |
"--disable-latex" | |
system "make", "install" | |
end | |
if build.with? "win64" | |
args64 = ["--prefix=#{prefix}"] | |
args64 << "--enable-win64" | |
args64 << "--without-x" if build.without? "x11" | |
mkdir "wine-64-build" do | |
system "../configure", *args64 | |
system "make", "install" | |
end | |
end | |
args = ["--prefix=#{prefix}"] | |
# 64-bit builds of mpg123 are incompatible with 32-bit builds of Wine | |
args << "--without-mpg123" | |
args << "--without-x" if build.without? "x11" | |
args << "--with-wine64=../wine-64-build" if build.with? "win64" | |
mkdir "wine-32-build" do | |
ENV.m32 | |
system "../configure", *args | |
system "make", "install" | |
end | |
(pkgshare/"gecko").install resource("gecko") | |
(pkgshare/"mono").install resource("mono") | |
end | |
def caveats | |
s = <<-EOS.undent | |
You may want to get winetricks: | |
brew install winetricks | |
EOS | |
if build.with? "x11" | |
s += <<-EOS.undent | |
By default Wine uses a native Mac driver. To switch to the X11 driver, use | |
regedit to set the "graphics" key under "HKCU\Software\Wine\Drivers" to | |
"x11" (or use winetricks). | |
For best results with X11, install the latest version of XQuartz: | |
https://xquartz.macosforge.org/ | |
EOS | |
end | |
s | |
end | |
def post_install | |
# For fontconfig | |
ohai "Regenerating font cache, this may take a while" | |
system "#{prefix}/deps/bin/fc-cache", "-frv" | |
# For net-snmp | |
(var/"db/net-snmp").mkpath | |
(var/"log").mkpath | |
end | |
test do | |
system "#{bin}/wine", "--version" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment