Compile MAME For Unix (Mac OS X and Linux)
Compiling MAME for Mac OS X and Linux is very similar because they both are based on Unix. However, dependancies are different. Take note of them throughout the guide.
We will be using MAME version 0.213 as an example. You may need to substitute where necessary depending on which version you would like to compile.
If running patched linux kernel for 15khz (GroovyArcade), you must tell pacman to not update the kernel.
$ sudo nano /etc/pacman.conf
#IgnorePkg = and change to
IgnorePkg = linux
7-Zip is not required to compile MAME. However, it is recommended to pack/unpack binaries. It can compress files to a smaller size than zip.
unzip is required to decompress the MAME source that we download.
$ sudo pacman -Syu # Update all packages on the system. $ sudo pacman -S dos2unix unzip p7zip # Install dependancies $ sudo pacman -S base-devel git sdl2 gconf sdl2_ttf gcc qt5 # Install dependancies for compiling MAME
Mac OS X
Install Command Line Developer Tools
Mac OS X 10.9+ can use the following terminal command to install command line developer tools. Mac OS X 10.7.3 can download from here.
$ xcode-select --install # Install command line developer tools
Install SDL2 via Disk Image
Download disk image 2.0.4+ here and then copy the framework to appropriate directory. It is recommended to install this way instead of using Homebrew. The Homebrew SDL2 formulae does not create a Mac style framework. See here for more details.
$ hdiutil attach /path/to/SDL2-2.0.10.dmg $ sudo cp -R /Volumes/SDL2/SDL2.framework /Library/Frameworks/SDL2.framework $ hdiutil detach /Volumes/SDL2 $ rm /path/to/SDL2-2.0.10.dmg
7-Zip is not required to compile MAME. However, it is recommended to pack/unpack binaries. It can compress files to a smaller size than zip. Homebrew is the missing package manager for macOS (or Linux).
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # Install Homebrew if haven't already $ brew update # Update Homebrew $ brew install p7zip # Install 7-Zip
$ cd ~/ $ curl -Lo mame0213.zip "https://github.com/mamedev/mame/archive/mame0213.zip" && unzip mame0205.zip && mv mame-mame0213 mame0213
Convert Line Endings
In DOS/Windows, a line break is Carriage Return + Line Feed \r\n. In Unix (Linux, Mac OS X), a line break is Line Feed \n. In Classic Mac OS, Commodore and TRS-80, a line break was CR \r. I encountered errors while compiling MAME due to uniformity.
$ cd ~/ $ curl -Lo endlines192.zip "https://github.com/mdolidon/endlines/archive/1.9.2.zip" && unzip endlines192.zip && mv endlines-master endlines192 $ cd endlines192 $ make $ make test $ sudo make install
Convert Line Endings
$ cd ~/mame0213 $ endlines check * -r # Will check all files in directory $ endlines unix * -r # Convert all files in directory to unix format, recursively
Patches are optional, and can be found at arcademvs/mame. The patches you apply may not be the same as shown below. I suggest reading the readme in the repo before continuing.
$ cd ~/mame0213 $ curl -Lo mame0213_groovymame_017o.diff "https://gitlab.com/arcademvs/mame/raw/master/diffs/mame0213_groovymame_017o.diff" $ curl -Lo mame0213_suppression.diff "https://gitlab.com/arcademvs/mame/raw/master/diffs/mame0213_suppression.diff" $ curl -Lo mame0213_various_fixes.diff "https://gitlab.com/arcademvs/mame/raw/master/diffs/mame0213_various_fixes.diff"
We use the patch utility. We are going to use the following options:
||Gives the entire file name unmodified.|
||Remove output files that are empty after the patches have been applied.|
$ cd ~/mame0213 $ patch -p0 -E < mame0213_groovymame_017o.diff $ patch -p0 -E < mame0213_suppression.diff $ patch -p0 -E < mame0213_various_fixes.diff
We use the make utility. We are going to use the following options:
||Optional and proceeding the flag with an integer determines the amount of parallel jobs (to speed up compiling). Integer should match the amount of cpu cores. The variables used in the example will automatically determine how many cores your processor has.|
||Disables treating compiler warnings as errors.|
$ cd ~/mame0213 $ make -j$(nproc) NOWERROR=1
Mac OS X
$ cd ~/mame0213 $ make -j$(sysctl -n hw.ncpu) NOWERROR=1