VOGONS


Compile SVN in macOS?

Topic actions

First post, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

A few years ago, with Dominus's patient and expert help, I was able to build SVN under macOS, but my Dominus-based method stopped working when macOS began requiring 64-bit applications. I know that Dominus has been maintaining a macOS version of DOSBox, but I wonder if there is a way for other people to compile SVN under macOS?

I'm asking because I've started work on one or two projects where I would like to use a customized SVN build.

Thanks in advance for any help.

EDIT: Corrected spelling.

Last edited by emendelson on 2021-03-03, 16:13. Edited 1 time in total.

Reply 1 of 172, by almeath

User metadata
Rank Member
Rank
Member

Last year, starting basically from scratch, but with support and encouragement from Dominus, I learned how to successfully compile 64-bit DOSBox SVN in macOS.

Not only that, but I worked out how to include custom patches for Munt, Glide (with OpenGlide), Nuked OPL3, and also the extra memory and large hard disks (8GB) for better Windows 9x support, all within a static binary that can be packed in a native macOS application bundle.

I am happy to share the results, I was just thinking I was the only one interested.. 😀

Reply 3 of 172, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

It would be terrific to see how you did this. You're not the only person who wants to build DOSBox under macOS. Thank you in advance!

If there's any possibility that you could post code on GitHub or SourceForge, of course that would be ideal, but I know it may be impractical. Back in 2017 I posted on GitHub a bash script named OneStopDOSBoxOSX that built 32-bit DOSBox from SVN. It's still there, but completely obsolete.

Reply 4 of 172, by almeath

User metadata
Rank Member
Rank
Member

Sure, if you can give me a day or so I will tidy up my notes and share them here. So much to discuss, as I have been at this since April of last year, keeping it mostly to myself because I was learning as I went. I was driven to do this because ECE and Staging (at the time) were not really supporting the Mac, and I have experienced performance issues with DOSBox-X. The other factor is that Boxer has been abandoned by the dev and is kind of only just kept going through Github, full of bugs.

I would be happy to post the code to Github if it is allowed .. it would be just the patched source code which can then be built using my instructions. For static builds I need to manually edit the make files after running configure, but not everyone needs that unless you want to transfer the app package between different Macs. Perhaps I can develop separate instructions for those that prefer everything within the binary vs. using dylibs (either installed at the OS level or stored within the app package).

Glide was particularly difficult because I had to fork and patch my own copy of OpenGlide, but in the last week I got it working in both DOSBox-X and SVN (https://github.com/joncampbell123/dosbox-x/issues/2314). Again, just haven't had time during the week to type up the full guide. The reason I want to stick to SVN is that despite all the great features in X, there seems to be some kind of bug causing a 30-50% performance reduction when compared to SVN, which I have confirmed with Dosbench results.

Also, I developed my own customized app wrapper that is kind of reverse engineered from what I saw GOG doing a few years ago. I am happy to provide that wrapper too, but it would be great if someone with more scripting knowledge could help me develop a self-building script for the whole thing, with the binary placed inside an app package.

Reply 5 of 172, by almeath

User metadata
Rank Member
Rank
Member

I am going to start by providing the instructions to compile an SDL1 based 64-bit binary of SVN. This is the simplest way to get it running for most users. My custom patched version would make the process very long, and I need to spend more time writing it up in a logical and easy to follow set of instructions. What I will probably do in the meantime is just place the fully patched source code on Github, which can then be directly compiled. There will be additional dependencies to install OpenGlide and Munt etc., and so that will all be included under the separate instructions.

So, this is how to build regular 64-bit SVN in macOS (confirmed as working in Mojave 10.14.6, but please let me know how this goes in Catalina and/or Big Sur):

A. Install DOSBox Dependencies

1. Install Xcode command line tools

xcode-select --install

2. Install Homebrew

https://docs.brew.sh/Installation

3. Install dependencies with Homebrew:

brew install libpng
brew install lzlib
brew install sdl_net
brew install sdl_sound

If running macOS 11 (Big Sur), Subversion was removed and needs to be installed as well:

brew install svn

• Packages should install by default to usr/local/Cellar

B. Prepare DOSBox SVN build folders

• These instructions result in the various build folders being installed on the desktop
• DOSBox working folder is 'build'
• SDL working folder is 'staticbuild'

1. Obtain the SVN 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

2. Obtain 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

3. Obtain 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

4. Download SDL 1.2x (Mercurial)

https://hg.libsdl.org/SDL/file/ab7529cb9558

• Download the source in a 'zip' file
• Unzip the folder to the desktop and rename it to SDL

cd $HOME/Desktop/SDL
./configure --prefix=$HOME/Desktop/staticbuild --enable-static --disable-shared --disable-video-x11
perl -p -i -e "/CGDirectPaletteRef palette;/d" ./src/video/quartz/SDL_QuartzVideo.h
make
make install

• Results in a folder called 'staticbuild' on your desktop

C. Build DOSBox SVN

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

For the last step you can use 4 threads to speed up the compilation:

make -j4

• The DOSBox binary should successfully build and be located in $HOME/Desktop/build/dosbox-code-0/src
• The resulting binary can then replace the one inside a standard DOSBox 0.74 application bundle (under /Contents/MacOS)
• You can edit /Contents/Info.plist to change the app name, copyright etc.
• Running the application should then generate a separate "DOSBox SVN Preferences" in the $HOME/Library/Preferences folder

Last edited by almeath on 2021-03-08, 04:56. Edited 3 times in total.

Reply 8 of 172, by almeath

User metadata
Rank Member
Rank
Member

To compile and patch Munt functionality into DOSBox SVN in macOS:

1. Follow steps 1 and 2 above if you have not already installed Xcode command line tools and Homebrew.

2. Intall Cmake

brew install cmake 

• Packages should install by default to usr/local/Cellar

3. Build the Munt dynamic library

git clone https://github.com/munt/munt.git
cd munt
mkdir build
cd build
cmake -Dmunt_WITH_MT32EMU_SMF2WAV=OFF -Dmunt_WITH_MT32EMU_QT=OFF -Dlibmt32emu_SHARED=0 ../
make -j4
sudo make install

• Munt static library should install to usr/lib/libmt32emu.a
• Munt source files should install to 'munt' folder in your home folder

4. Patch the DOSBox SVN code

• Ensure that the 'munt' folder is installed to your home folder as detailed above
• Patch files are located by default in munt/DOSBox-mt32-patch
• The specific name of the patch file may vary by version number (i.e. dosbox-SVN-r4319-mt32-patch)
• The SVN patch will be used - NOT the patch for vanilla DOSBox 0.74x etc.

cd $HOME/Desktop/build/dosbox-code-0
patch -p1 < $HOME/munt/DOSBox-mt32-patch/dosbox-SVN-r4319-mt32-patch.diff

5. Proceed with the DOSBox compilation process as described in my earlier post at Part C

6. Add the preferences file settings to enable Munt functionality

Open your DOSBox SVN Preferences ($HOME/Library/Preferences/DOSBox SVN Preferences

These are the default settings to enable the Munt emulator functionality:

[midi]
mpu401=intelligent
mididevice=mt32
midiconfig=
mt32.romdir=
mt32.reverse.stereo=false
mt32.verbose=false
mt32.thread=false
mt32.chunk=16
mt32.prebuffer=32
mt32.partials=32
mt32.dac=0
mt32.analog=2
mt32.reverb.mode=auto
mt32.reverb.time=5
mt32.reverb.level=3

• Specify an absolute path to the ROM files next to mt32.romdir=
• The ROM files for either the MT-32 or CM-32L must be named as follows:

MT32_CONTROL.ROM
MT32_PCM.ROM

or

CM32L_CONTROL.ROM
CM32L_PCM.ROM
Last edited by almeath on 2021-03-04, 14:05. Edited 1 time in total.

Reply 9 of 172, by almeath

User metadata
Rank Member
Rank
Member
emendelson wrote on 2021-03-04, 13:22:

This is terrific. Thank you. Will let you know how it works on Big Sur when I'm back at my development machine.

Thank you again for those very clear instructions!

I am happy to share these results. 😀

I won't get around to it today, but I will get my patched code onto Github next and also provide a pre-compiled binary for those who have trouble with these instructions. It will include all the stuff I have patched in so far - Glide, Nuked, Munt etc.. and I will also provide my custom wrapper to go with it. I am actively working on getting additional patches included.

One thing to note about my wrapper is that it is entirely self-contained - everything is inside it, even the preferences. It does not depend on anything being pre-installed on the macOS system, other than a default install of the OS. Just don't expect it to ever be "notarized" etc. as it is one of those evil "self-modifying" apps that Apple hates so much. 😉

Reply 10 of 172, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

One detail: In order to make sure that the code I distribute isn't limited to my system, I avoid installing brew or any equivalent, in case I mistakenly build something that requires something installed on my system by brew. (This happened to me years ago.) I'll experiment with installing local copies, as in my old OneStopDOSBox.sh script on GitHub.

Reply 11 of 172, by almeath

User metadata
Rank Member
Rank
Member

By all means, I am happy to accept any suggestions to improve the process. As mentioned, I had little to go on so I basically went with whatever process worked.

For the record, I have copied my binaries and wrappers to two other Macs, with default installs of Mojave and Catalina, and no Homebrew or other packages installed. The wrapper works as intended on those systems.

When I build my binary and wrapper, I have manually edited the make files to ensure a static build with everything within the binary. Dominus provided valuable advice in this area. The only thing is that it’s a fiddly manual process to do this .. I don’t have the scripting knowledge to automate it.

Reply 12 of 172, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

Manually editing the make files - that was amazingly fiddly, but Dominus showed me how to automate it. You might want to look at the old OneStopDOSBox OSX script that I created using Dominus's methods. The patch file starts getting created around line 697:

https://github.com/emendelson/OneStopDOSBoxOSX

Reply 13 of 172, by almeath

User metadata
Rank Member
Rank
Member

Thanks, I’ll take a look.

In the meantime, I think the best approach will be to upload the patched source, with instructions that will produce a standard binary with some external dependencies. These would be the same dependencies required to build it in the first place.

While also providing the transportable pre-built app, I will write up some special instructions for those interested in making their own static build.

I am open to some kind of collaboration on this if there is interest.. I would be happy to include an automated script to achieve the above, perhaps even supporting an automatic app package and DMG creation?

I did the same for PCem v17 .. I figured out how to patch and compile it for Big Sur compatibility, and then enlisted the help of some other devs to develop a DMG package.

Reply 14 of 172, by almeath

User metadata
Rank Member
Rank
Member

Just a quick update on Big Sur. I found out that Subversion was removed from macOS 11 command line tools, so it needs to be installed as an additional build dependency in order for the SVN checkout command to be recognized. I have updated my original post with this step.

Reply 15 of 172, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

Definitely interested in collaboration. When you've posted your instructions, I could get started on updating my OneStopDOSBoxOSX script so that it builds your version. I don't pretend to understand what happens my own script, because I'm basically a beginner who mostly uses code that other people wrote, but at least that old script worked correctly, and it should be possible to create a new one.

Reply 16 of 172, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

About svn under BigSur, you don't need svn to download the latest code, I think. This worked in my old script (using variables declared earlier in the script):

mkdir -p $DOSBOXFOLDER
rm -rf $TMPDIR/dosboxsource >/dev/null 2>&1
mkdir -p $TMPDIR/dosboxsource/
curl -OL http://source.dosbox.com/dosboxsvn.tgz
tar -xzf dosboxsvn.tgz -C $TMPDIR/dosboxsource/
rm dosboxsvn.tgz
ditto $TMPDIR/dosboxsource/dosbox $DOSBOXFOLDER

Presumably it should work still?

Reply 17 of 172, by almeath

User metadata
Rank Member
Rank
Member

@emendelson , I have uploaded the fully patched source code for SVN 4441 here:

https://github.com/almeath/DOSBox-SVN-64-bit-for-macOS

It is currently patched to include Munt, Glide, Nuked, 384 memory limit, 8GB hd image support.

I have posted the build instructions - not too pretty right now, but it is hard to format things well with Github. I am not saying these are optimal - there may be redundant steps and it could probably be streamlined.

Can you let me know if this works for you?

I have not yet had time to:

- post a fully built binary and wrapper
- provide instructions on how to make a "static" build (i.e. no external dylib dependencies)
- provide instructions on how to build and use OpenGlide and Munt

I will hopefully get those done in the coming days.

Reply 18 of 172, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

@almeath, Thank you for this. I'll test in the next day or two, but would be very interested in how to make a static build. That's the part that I would want to use in my projects, but what you've posted should be useful to many of us!

EDIT: I've been trying to update my old build script, but I can't build libtool or anything else because I get the error "configure: error: C compiler cannot create executables". This seems to be fairly standard under Catalina and Big Sur, and no one has a solution that works, as far as I can see. I'll try doing this under Mojave, and will then come back to Big Sur.

Reply 19 of 172, by almeath

User metadata
Rank Member
Rank
Member

Patch Make files to ensure a static build

Do this immediately after step C.4 (i.e. before running the "make" command).

1. Patch the primary Makefile

• The Makefile is located in $HOME/Desktop/build/dosbox-code-0/
• Open it in Xcode and check Line 241 (starts with LIBS =), which should appear as follows (yourusername will be substituted with your own macOS username, i.e. name of your Home folder):

LIBS =  -L/Users/yourusername/Desktop/staticbuild/lib /Users/yourusername/Desktop/staticbuild/lib/libSDLmain.a /Users/yourusername/Desktop/staticbuild/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit -framework CoreMIDI -framework AudioUnit -framework AudioToolbox -lpng -lz -lX11 -framework OpenGL

• Edit Line 241 to provide full paths for each of the references libraries, as follows:

LIBS =  -L/Users/yourusername/Desktop/staticbuild/lib /Users/yourusername/Desktop/staticbuild/lib/libSDLmain.a /Users/yourusername/Desktop/staticbuild/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit -framework CoreMIDI /usr/local/Cellar/libpng/1.6.37/lib/libpng.a /usr/local/Cellar/zlib/1.2.11/lib/libz.a /usr/local/Cellar/sdl_net/1.2.8/lib/libSDL_net.a /usr/local/Cellar/sdl_sound/1.0.3_1/lib/libSDL_sound.a /usr/local/Cellar/libogg/1.3.4/lib/libogg.a /usr/local/Cellar/libvorbis/1.3.7/lib/libvorbis.a /usr/local/Cellar/libvorbis/1.3.7/lib/libvorbisfile.a /usr/local/Cellar/libvorbis/1.3.7/lib/libvorbisenc.a

• Check the path to each dependency to make sure it exactly matches what is in your user/local folder
• You will notice that the macOS standard libraries remain as they are, but the additional dependencies (i.e. -lpng onwards) need to be removed or modified
• This presumes you installed dependencies to their default locations with homebrew (otherwise edit accordingly!)
• The version numbers above may vary depending on when you installed the dependencies

• Check that Line 257 (starts with SDL_LIBS =) reads as follows:

SDL_LIBS = -L/Users/yourusername/Desktop/staticbuild/lib /Users/yourusername/Desktop/staticbuild/lib/libSDLmain.a /Users/yourusername/Desktop/staticbuild/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit

• As above, "yourusername" should already be showing your own username.
• If the line reads as above, no further changes are needed here.

2. Patch the SRC Makefile

• The SRC Make file is located in $HOME/Desktop/build/dosbox-code-0/src
• Open it in Xcode, and as above, check that Line 246 (starts with LIBS =) appears as follows (again, you will see your username in the SDL paths)

LIBS =  -L/Users/yourusername/Desktop/staticbuild/lib /Users/yourusername/Desktop/staticbuild/lib/libSDLmain.a /Users/yourusername/Desktop/staticbuild/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit -framework CoreMIDI -framework AudioUnit -framework AudioToolbox -lpng -lz -lX11 -framework OpenGL -lmt32emu

• Edit Line 246 to provide full paths for each of the references libraries, as follows:

LIBS =  -L/Users/yourusername/Desktop/staticbuild/lib /Users/yourusername/Desktop/staticbuild/lib/libSDLmain.a /Users/yourusername/Desktop/staticbuild/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit -framework CoreMIDI -framework AudioUnit -framework AudioToolbox /usr/local/Cellar/libpng/1.6.37/lib/libpng.a /usr/local/Cellar/zlib/1.2.11/lib/libz.a /usr/local/Cellar/sdl_net/1.2.8/lib/libSDL_net.a /usr/local/Cellar/sdl_sound/1.0.3_1/lib/libSDL_sound.a /usr/local/Cellar/libogg/1.3.4/lib/libogg.a /usr/local/Cellar/libvorbis/1.3.7/lib/libvorbis.a /usr/local/Cellar/libvorbis/1.3.7/lib/libvorbisfile.a /usr/local/Cellar/libvorbis/1.3.7/lib/libvorbisenc.a -framework OpenGL /usr/local/lib/libmt32emu.a

• These edits are identical to the primary make file, except that if you build DOSBox with the Munt patch, you will see that we add an extra path for "libmt32emu.a" to ensure the Munt static library will be incorporated into the binary
• Check that Line 262 (starts with SDL_LIBS =) reads as follows (again, your username should already be substituted here):

SDL_LIBS = -L/Users/yourusername/Desktop/staticbuild/lib /Users/yourusername/Desktop/staticbuild/lib/libSDLmain.a /Users/yourusername/Desktop/staticbuild/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit

3. Build DOSBox and check the dylibs

1. Complete Step C.5 to "make" the DOSBox binary.

2. When complete, immediately run the binary and then while it is running, go to the Activity Monitor app in macOS.

3. Find "dosbox" and then double-click it. A window should pop up that provides three tabs. The last tab should be called "Open Files and Ports".

4. In that section you should see a text field below. Still in Activity Monitor, go to the Edit menu and select "Find" then "Find..."

5. Search for dylib

If your static binary build was successful, you should only see one dylib reference highlighted, which is "/usr/lib/libobjc-trampolines.dylib". This is a standard macOS library.

If any other dylibs show up (i.e. libx11, libxcb, libxau etc.) then you need to go back and carefully check that you followed the above instructions to the letter.

The resulting static binary of DOSBox should run on any macOS standard installation of Mojave, Catalina or Big Sur, without the need for that system to have any of the aforementioned dependencies installed.