Skip to content

Instantly share code, notes, and snippets.

@pxia
Forked from stolendata/mpv.md
Created November 7, 2018 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pxia/da0408f282a8b714b02999a786349f4f to your computer and use it in GitHub Desktop.
Save pxia/da0408f282a8b714b02999a786349f4f to your computer and use it in GitHub Desktop.

The time-consuming part is not building MPV itself, but the long list of dependencies requiring a rebuild in order to fully satisfy the deployment target version. Setting MACOSX_DEPLOYMENT_TARGET in the immediate environment doesn't always propagate, resulting in target mix-ups and build failures for some dependencies. The only working solution I've found is to enforce within the formulas themselves. The following script adjusts the bulk of this:

#!/bin/sh
path='/path/to/homebrew/Library/Taps/homebrew/homebrew-core/Formula'
for dep in pkg-config makedepend autoconf automake openssl lua@5.1 libpng jpeg libtiff youtube-dl little-cms2 gettext libffi pcre libtool freetype fontconfig cairo pixman graphite2 icu4c harfbuzz glib libogg libvorbis flac libsamplerate libsndfile rubberband theora nasm readline sqlite gdbm xz python@2 python gobject-introspection docutils fribidi texi2html libass ffmpeg mujs mpv
do
    sed -i.bu $'s/def install/def install\\\n    ENV["MACOSX_DEPLOYMENT_TARGET"] = "10.10"\\\n/' $path/$dep.rb
done

...followed by a manual fix:

brew edit python@2    # comment out "args << MACOSX_DEPLOYMENT_TARGET=..."

I do these separately with tests disabled (which comes with some small risk) in order to speed things up since I'm still using pre-2010 hardware:

brew edit libpng      # comment out "make test"
brew install --build-from-source pkg-config makedepend autoconf automake
brew install --build-from-source --without-test openssl

Build most of the dependencies (this will take a while):

brew install --build-from-source --without-luarocks lua@5.1
brew install --build-from-source libpng jpeg libtiff youtube-dl little-cms2 gettext libffi pcre libtool glib freetype fontconfig pixman cairo libogg libvorbis theora readline sqlite gdbm xz python@2 python gobject-introspection docutils fribidi texi2html nasm flac libsamplerate libsndfile rubberband graphite2 icu4c ragel harfbuzz libass mujs

Build ffmpeg with a few twists - this is not optimal for everyone but I'm still lacking feedback from users:

brew install --build-from-source --with-openssl --with-theora --with-rubberband --without-lame --without-x264 --without-xvid ffmpeg

Finally, build MPV:

brew install --build-from-source --with-bundle mpv

A simple check to make sure all libraries came out with the correct target version:

for l in /path/to/mpv.app/Contents/MacOS/lib/*.dylib; do echo -e "\n$l"; otool -l $l | grep -A 2 LC_VERSION_MIN_MACOSX; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment