HOW TO COMPILE MAME

Why would you want to compile MAME yourself? There's always an executable version available at the home page, right? Well, there's a couple reasons why:
- Immediate updates. In between each major release, there are "u" releases ("u" stands for update). Binaries for these are never available on the main page.
- You already have the source. Even if you don't know how to program, the source is interesting to browse through. It'll give you an idea just how much time is actually spent on this wonderful project. Plus, the devs have included notes throughout the source that aren't anywhere else.
You don't have to be a programmer to compile MAME. If your only goal is to be able to compile the new versions, here's the step-by-step (for a Windows system):
NOTE: This is to compile MAME starting with version 0.146u5.
Apply the "u" Update DIFFs

If you are just compiling the main source code, then you can skip this section.
- Double-click the command prompt shortcut to open a command-line window.
- The actual command to patch with a DIFF file is:
patch -p0 -E <0146u1.diff
(in this example, using 0146u1.diff)
- The batch file makes it a little easier to type; you can use the command:
patchmame 0146u1
(in this example, using 0146u1.diff)
- You will see a window similar to the one shown. These are all of the source files that are changing.
- When applying DIFFs, make sure to apply them in order (0146u1, 0146u2, 0146u3, etc.)
Create the MAME executable

At the command prompt, type
makemame, then go grab a Dr Pepper, as it's going to take a bit.
- You'll see a bunch of lines of code scroll by. That's the compiler doing its work.
- When the code is done compiling, go back and check your mamesrc folder. You will have a shiny new MAME:
- The 32-bit version will be named mame.exe; the 64-bit version (shown here) will be named mame64.exe
- Copy to whichever folder you use for MAME.
- If you also want a copy of the various tools that come with MAME, use the command make -all
CONGRATULATIONS!! You have now entered the world of compiling! You can now stay up to date within the world of MAME on your own, without having to wait for another website to upload a pre-compiled version.
What about MAMEUI ?
If you prefer to point and click, you have a couple more steps before you create the MAME executable if you want to create the GUI version, MAMEUI.
NOTE: This is to compile MAMEUI starting with version 0.146u5.
- Download the MAMEUI source. It is a self-extracting executable like the MinGW package above.
- Make sure the MAMEUI source you grab matches the "u" version you are compiling.
- For example, if you are grabbing the MAME UI source for 0.146.5, make sure you are applying to 0.146u5 command-line version.
- MAMEUI is not always updated the same day a command-line version is updated, depending on what changes have been made.
- From the MAMEUI source:
- Copy \src directory to mame\src allow overwriting of the \lib\util\astring* files with these.
- The command to build MAMEUI is make OSD=winui
- Download these extra compiling tools (needed to create the help file).
- Extract the extra tools to C:\mingw\mingw64-w64, again, keeping the folder structure intact.
- If compiling 32-bit version, extract the extra tools to C:\mingw\mingw64-w32.
- Download these additional batch files.
- Edit the path in MakeHELPUI.bat and MakeMAMEUI.bat to the \bin folder where you installed MinGW, just as you did to MakeMAME.bat above (again, if you've been following using the examples above, you do not need to edit these files).
Create the MAMEUI executable
- At the command prompt, type makemameui, then grab a Dr Pepper again. Go ahead and get ice, too, as it will be slightly longer this time.
- There is no need to delete the obj directory if you want to do both versions, as each creates its own subfolder.
- When the code is done compiling, you'll be at the command prompt again.
- Type makehelpui to create the help file for MAMEUI.
- When complete, copy the MameUI and MameUI.chm to whichever folder you use for MAMEUI.
CONGRATULATIONS AGAIN!! You have now both versions of MAME, ready to run. Try both to see which suits you better.
Other Notes
- When you apply a DIFF patch after you have previously compiled (say, from 0.146u4 to 0.146u5), it is best to do a clean compile, which basically means to delete your obj folder before you compile. Otherwise you may end up with errors or a bad executable.
- If you have a dual-core or quad-core processor, you can use the option -j3 or -j5, respectively, to significantly decrease your compiling time.
- For example, I have an Intel i7, so I compile with the following command-line:
And finally, you can apply source changes from other people or other builds as they come about using these simple tools.
Hope you had fun =)