Skip to content

Building From Source

Sasha Koshka edited this page May 7, 2022 · 4 revisions

Linux/Unix prerequisites

Mandatory dependencies

  • clang or gcc
  • SDL2 installed, as well as its development headers.

Note: if you use gcc, you will need to edit build.sh. This will be fixed in the future.

Optional dependencies

  • gzexe

Note: if you don't have gzexe installed, you cannot build a minified executable.

Windows prerequisites

In order to build this on Windows, you need to get an MSYS2/MINGW shell running, with gcc. Install MSYS2, and follow these instructions in order to open up a MINGW shell. Next, you need to install MINGW gcc. Then, you need to make sure this repository's files are located within a path you can navigate to within MSYS2. The easiest way to do this is to install git through msys2 and then use that to clone the repository.

Building

The build script is highly flexible. Here is how to use it:

  • ./build.sh [all]: Build the program.
  • ./build.sh <module>: Build a single module.
  • ./build.sh clean: Remove all object files and binaries.
  • ./build.sh redo: Rebuild the entire program.
  • ./build.sh run: Build and run the program.
  • ./build.sh release Build and package the program for release. Creates a zip file in release.
  • ./build.sh install Rebuild the entire program, and install. Should be run as root.
  • ./build.sh uninstall Uninstall the program. Should be run as root.

A module is defined as a .c file. When building the program, the build script scans the entire src directory for .c files, compiles each one to a .o file (if it needs to be re-compiled), and links them all together.

Adding small as an argument to the end of the command will build the minified release version.

Note: there is currently a bug in the build script where if a header is modified, the modules that include that header won't be rebuilt. This causes random crashes and bugs. This issue will be fixed eventually, but for now, the codebase is small enough that running ./build.sh redo every time a definition in a header file is altered is not that big of a deal.

build.sh should be fully POSIX compliant, and not contain any bash-isms.

Running

To run the program, you can run ./build.sh run to build and run the debug version automatically. You can also run the executables manually. If you are on Windows, in win/bin there will be a file called SDL2.dll, and a file called m4kc.exe. In order for m4kc to run, it must be in the same directory as SDL2.dll. In the future, this file will be statically linked.

If you install the program by running ./build.sh install (Linux/Unix only), you should be able to launch the program by running the command m4kc or finding it in your application launcher or main menu. Note that to run it after it has been installed, /usr/games must be in your PATH. This will eventually be moved to /usr/local/games.

Clone this wiki locally