User:Jamesr/Makefile

From SRB2 Wiki
Jump to navigation Jump to search

The GNU Makefile is the preferred way of compiling the game at the time of writing. The Makefile supports and has been tested on Windows and Linux. (It ostensibly supports other platforms such as FreeBSD as well, but the project maintainers make no guarantee.)

Quick Start

Note

If you are compiling SRB2Kart, these are the URLs you should clone.

https://git.do.srb2.org/KartKrew/Kart-Public.git or https://github.com/STJr/Kart-Public.git

Windows

Selecting the 32-bit MSYS2 shortcut.

On Windows, you will need to install MinGW. This tutorial will use the MSYS2 method. Follow the install instructions on this website: msys2.org

After you've followed the steps listed there, close the MSYS2 window and open its 32-bit shortcut. Then enter these commands into the new window.

pacman -S git mingw-w64-i686-make mingw-w64-i686-gcc mingw-w64-i686-nasm

This will install Git, for downloading the source code, and GNU Make, GCC and NASM for compiling the source code. Read more about all of this in #Dependencies.

Once everything is installed, use Git to download the source code...

From git.do.srb2.org (preferred):

git clone https://git.do.srb2.org/STJr/SRB2.git

Or from GitHub:

git clone https://github.com/STJr/SRB2.git

Now enter this command to get to the source code folder.

cd SRB2/src

And you're ready to compile with this next command. (Using NOUPX and NOOBJDUMP speeds up the process a bit.)

mingw32-make.exe CC=i686-w64-mingw32-gcc NOUPX=1 NOOBJDUMP=1
Note

If you have a multi-core processor, try using -j to compile in parallel, speeding up the compilation a lot. A good number to start with is the number of cores on your processor, but you can go higher.

For example, on a four core processor:

mingw32-make.exe CC=i686-w64-mingw32-gcc NOUPX=1 NOOBJDUMP=1 -j 4

And you're done! Make will tell tell you anyway, but you can find srb2win.exe at SRB2/bin/Mingw/Release/srb2win.exe. Now you can go there with Windows Explorer and copy the EXE wherever you like.

How to find the EXE outside of MSYS2

Enter this command to get the current path in MSYS2.

pwd

It should look something like /home/james/SRB2/src. Then in Windows Explorer, find the folders starting from the left in your MSYS2 installation folder. Once you're inside the SRB2 folder, look for the bin folder as mentioned before.

If you forgot where you installed MSYS2, you can enter this command.

df .

The Windows folder path to MSYS2 will be in the "Filesystem" column.