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/
$ diskutil eject /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}
$ cd $HOME/Desktop
$ rm DOSBox-0.74-1_Universal.dmg
$ rm -rf staticbuild
$ rm -rf build
$ rm -rf DMGSRC

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.

Advertisements

10 thoughts on “Building a x64 DOSBox binary for macOS Sierra

  1. Thank you for writing this! In my case I saved myself some hassle by using homebrew to install the dependencies.

    • I think HomeBrew is a really good project and for the three dependencies (autoconf, automake and SDL) I do not think you really needed the full HomeBrew setup :-)

  2. Since I’m the guy who does the Dosbox snapshots, there is a simple reason that Dosbox is not built in 64bit: the dynamic core is made for 32bit and the 64bit adaption isn’t as capable. You should have noticed that the 64bit built is much slower on OS X than the 32bit one.

    • When I looked for a current build I saw your snapshots but as they were marked for 10.4-10.7 ppc/intel I did not check how current they were. My main motivation to build DOSBox from the svn repository was to fix a graphics problem with Command and Conquer Red Alert which did go away in r4000. I do not play that often and have not noticed that the r4000 64bit DOSBox is considerably slower than the 0.74 public release but that is just a very subjective impression. Do you know of any plans to make the 64bit dynamic core more stable?

    • I am in a similar situation to hexeract; I have not experienced any noticeable performance loss when building 64-bit from SVN. I have also been doing so in the last few months because of planned deprecation of 32-bit applications in macOS (see: https://apple.slashdot.org/story/17/06/07/0538233/apple-to-phase-out-32-bit-mac-apps-starting-in-january-2018). While no one knows the details of this plan as of yet, do you know whether the DOSBox team plans to release a 64-bit stable build in the future?

  3. With the introduction of high sierra and macOS going all 64bit in 2018, will this version work? I’m already losing a lot of iOS apps if I swap to 11, I would hate to lose dosbox games on my mac.

    • It depends if High Sierra will just issue a warning or will simply not run 32bit applications.

      If you build DOSBox following my posting you should end up with a 64bit binary:


      $ file DOSBox
      DOSBox: Mach-O 64-bit executable x86_64

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s