Building a x64 DOSBox binary for macOS Sierra

Running DOSBox after a long time made me wonder if there isn’t a newer version for mac OS X / OS X / macOS available, preferably for x64. Looking through the DOSBox Wiki I did find a download link for a Mac OS X / OS X / macOS binary but that was an universal binary build for ppc / i386 (32bit). The last official release of DOSBox for this platform was version 0.74-1 released on the 20th September 2012, quite some time ago…

So I wondered if it would be very difficult to compile a current version of DOSBox for myself and maybe end up with a x64 binary which also might emulate things better and/or faster.

To begin with, I have set up a fresh virtual machine running macOS Sierra and installed Xcode 8.0 (8A218a). To save me from misery later on I decided it might me a good idea to make a snapshot so if things do go horribly wrong I can always revert to a fresh start. Better safe than sorry .. :-) So without much further ado, this is how I did it:

Notice: Everything is done via shell so you either can run “Terminal.app” locally on your Apple computer or ssh into your build machine (I did the latter).

Obtaining the source code

$ cd $HOME/Desktop
$ mkdir build
$ cd build
$ svn checkout svn://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk dosbox-code-0
$ cd dosbox-code-0

The source code does not have a configure script readily available so we need to provide
the tools for autogen.sh to run successfully

Obtaining autoconf

$ cd $HOME/Desktop/build
$ curl -LOs http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
$ tar xzpf autoconf-2.69.tar.gz
$ cd autoconf-2.69
$ ./configure
$ make
$ sudo make install

Obtaining automake

$ cd $HOME/Desktop/build
$ curl -LOs http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz
$ tar xzpf automake-1.15.tar.gz
$ cd automake-1.15
$./configure
$ make
$ sudo make install

DOSBox wants SDL 1.2.x so provide that too

$ cd $HOME/Desktop/build
$ curl -LOs https://www.libsdl.org/release/SDL-1.2.15.tar.gz
$ tar xzpf SDL-1.2.15.tar.gz
$ cd SDL-1.2.15
$ ./configure --prefix=$HOME/Desktop/staticbuild --enable-static --disable-shared --disable-video-x11
$ sed "/CGDirectPaletteRef palette;/d" ./src/video/quartz/SDL_QuartzVideo.h >./src/video/quartz/SDL_QuartzVideo.h.new
$ mv ./src/video/quartz/SDL_QuartzVideo.h.new ./src/video/quartz/SDL_QuartzVideo.h
$ make
$ make install

Compiling DOSBox

$ cd $HOME/Desktop/build/dosbox-code-0/
$ DOSBOXVERSION=$(svn log | head -2 | awk '/^r/ { print $1 }')
$ ./autogen.sh
$ ./configure --with-sdl-prefix=$HOME/Desktop/staticbuild/
$ make

Reaching this step, a fully functional DOSBox binary is available but why not just try and package it up into an Application and disk image? For this, I did cheat by using the old stable disk image provided by the DOSBox Team as a template which did save me some effort.

Getting the 0.74-1 DOSBox disk image

$ cd $HOME/Desktop
$ curl -LOs http://heanet.dl.sourceforge.net/project/dosbox/dosbox/0.74/DOSBox-0.74-1_Universal.dmg
$ hdiutil attach DOSBox-0.74-1_Universal.dmg
$ cp -R /Volumes/DOSBox\ 0.74-1/DOSBox.app $HOME/Desktop/
$ umount /Volumes/DOSBox\ 0.74-1/

Copying the newly created binary into the DOSBox.app

$ cp $HOME/Desktop/build/dosbox-code-0/src/dosbox $HOME/Desktop//DOSBox.app/Contents/MacOS/DOSBox

Fixing the package version information

$ /usr/libexec/PlistBuddy -c "Set :CFBundleGetInfoString ${DOSBOXVERSION}, Copyright 2010-2016 The DOSBox Team, compiled by snowy" $HOME/Desktop//DOSBox.app/Contents/Info.plist
$ /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $DOSBOXVERSION" $HOME/Desktop//DOSBox.app/Contents/Info.plist
$ /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $DOSBOXVERSION" $HOME/Desktop//DOSBox.app/Contents/Info.plist
$ /usr/libexec/PlistBuddy -c "Set :NSHumanReadableCopyright Copyright 2002-2016 The DOSBox Team, compiled by snowy" $HOME/Desktop//DOSBox.app/Contents/Info.plist

Creating the disk image

$ cd $HOME/Desktop
$ mkdir DMGSRC

At this stage you could put the manual, the GPL, a version history, a README, example configurations or anything else you think might be important to the user into the DMGSRC directory if you wanted to make a complete and unofficial distribution of DOSBox.

$ mv DOSBox.app DMGSRC/
$ hdiutil create -volname DOSBox-${DOSBOXVERSION} -srcfolder $HOME/Desktop/DMGSRC DOSBox-${DOSBOXVERSION}

And now you are ready to go. copy the disk image to your main machine and drop the DOSBox.app into /Applications or any other place you would like to keep it. Run it once and if you already have a DOSBosx 0.74 configuration, you can point the new configuration to the old one by executing the following commands

$ cd $HOME/Library/Preferences
$ rm "DOSBox SVN Preferences"
$ ln -s "DOSBox 0.74 Preferences" "DOSBox SVN Preferences"

For lot’s of fun with DOSBox I recommend reading Compile like it’s 1992 by Fabien Sanglard.