I use Lilypond for all my music engraving. I am also an avid Apple user. The official compiled Lilypond package for the MacOS target is 32-bit; this will become a problem in the next major version of MacOS, which will no longer support 32-bit binaries. The Lilypond development team is aware of this limitation, but they are currently wrestling with their cross-platform build framework (GUB, or Grand Unified Builder) and cannot directly address this issue at the moment. So I set to work figuring out how to compile Lilypond natively, using Homebrew as my build environment. If you want to follow the instructions here, you should have already installed Homebrew and become familiar with what it does. You should also feel comfortable using Terminal.
These instructions install only the command-line Lilypond utilities. They do not install any GUI apps, nor do they register Lilypond.app in your “Applications” directory.
1. Text fonts
Lilypond uses the TeX Gyre font metafamily for its default text engraving. Change directories to a temp directory (such as
/tmp) and execute the following:
curl -LO http://www.gust.org.pl/projects/e-foundry/tex-gyre/whole/tg2_501otf.zip unzip tg2_501otf.zip mv tg2_501otf/*.otf /Libraries/Fonts/
This will give you several new font families in your universal fonts directory.
2. Dependencies supplied by Homebrew
First, we’ll install MacTeX, a precompiled distribution of TeX.
brew cask install mactex
Next, we need to add a couple of contributed taps. The
spl/homebrew-tex tap supplies
kpathsea, which is used by TeX to locate resources. The
sadhen/sadhen tap supplies Guile 1.8, which is Lilypond’s preferred version of Guile.
brew tap spl/homebrew-tex brew tap sadhen/sadhen
Now we can install all the dependencies that Homebrew can provide us:
brew install gcc@7 firstname.lastname@example.org ghostscript fontconfig freetype \ pango t1utils kpathsea fontforge texinfo gettext poppler gnu-sed
Finally, it may be necessary to get Homebrew to symlink some of these libraries/resources to common areas:
brew link fontforge brew link gettext --force
Homebrew supplies flex-2.6.4, but due to upstream bugs Lilypond will choke on any version higher than 2.5.37. So we get to install the older version of flex by hand. I couldn't get
texi2dvi to successfully process the documentation (it made the build process choke and die) so I deke out that part of the build. I also skip building the test directory. You’ll want to be in a temp directory to execute the following:
curl -LO https://github.com/westes/flex/archive/flex-2.5.37.tar.gz tar xzf flex-2.5.37.tar.gz cd flex-flex-2.5.37 gsed -i -e '/doc \\/d' -e '/tests/d' -e 's/tools \\/tools/' Makefile.am gsed -i -e '/doc\/Makefile/d' -e '/tests\/Makefile/d' -e '/tests\/.*\/Makefile/d' configure.in ./autogen.sh ./configure make && make install
This utility is, strictly speaking, optional, but it will supposedly result in much smaller PDF output from Lilypond, so I installed it. I couldn’t find a Homebrew package for this, so I installed from source:
curl -L -o extractpdfmark-1.1.0.tar.gz \ https://github.com/trueroad/extractpdfmark/archive/v1.1.0.tar.gz cd extractpdfmark-1.1.0 ./autogen.sh ./configure --disable-dependency-tracking make && make install
This was the most challenging part. Lilypond won’t compile with
clang, Apple’s built-in compiler. Apple pretends to have
gcc installed, but in fact the gcc in
/usr/bin is just a renamed clang. Lilypond also won’t compile with GCC 8, which is why in step 2 above we installed
gcc@7. We have to specify all the GCC-related compilers and preprocessors when we run configure for Lilypond, or it will fall back to using the built-in Apple ones and then fail late in the build process.
PATH="/usr/local/opt/texinfo/bin:/usr/local/opt/bison/bin:$PATH" \ CC=/usr/local/bin/gcc-7 CXX=/usr/local/bin/g++-7 CPP=/usr/local/bin/cpp-7 \ CPPFLAGS="-I/usr/local/include" \ LDFLAGS="-L/usr/local/lib" \ ./configure --with-texgyre-dir=/Library/Fonts --disable-documentation \ --disable-optimising --disable-pipe --disable-debugging --disable-guile2 \ --disable-profiling make all && make install
And that’s it! You should be able to invoke
lilypond from the terminal now.