Mario 64 on DragonflyBSD

Steps to build and run an enhanced, Dragonfly-native Mario 64, built from the decompilation available on Github. With surprisingly little effort too!

The build environment

You'll need a few things in place. DragonflyBSD isn't Linux, and it isn't OSX, and the project doesn't actually consider building on *BSD. So we need to do a few things before we can build it. The commands below will install the dependencies we'll be compiling-with/linking-against, clone the repository, and create the appropriate symlinks the Makefile currently expects.

doas pkg install gcc9 sdl2 python3 libGLU glew
git clone
cd sm64ex/
ln -s /usr/include/sys/malloc.h $(pwd)/include/
ln -s /usr/local/bin/cpp9 $(pwd)/bin/cpp-9
ln -s /usr/local/bin/gmake $(pwd)/bin/make
export PATH=$(pwd)/bin:$PATH

Source material

The decompilation of Mario 64 is seriously cool. But unlike code which you can maybe get away with - you really can't get away with redistributing the sound effects, music, and artwork. So you'll need a copy of the game on hand, placed in the project root. I've provided the sha256 sum of the file I used, as a reference. Yours may differ.

SHA256 ( = 17ce077343c6133f8c9f2d6d6d9a4ab62c8cd2aa57c40aea1f490b4c8bb21d91

File changes

Before building, we want to make a few small changes. In the main Makefile, we want to remove its attempt at OS detection. Currently this will cause the build to assume we're running some form of Windows, causing it to go looking for mingw:

diff --git a/Makefile b/Makefile
index 8360415..b501b25 100644
--- a/Makefile
+++ b/Makefile
@@ -78,16 +77,6 @@ WINDOWS_BUILD ?= 0
# Attempt to detect OS
-ifeq ($(OS),Windows_NT)
-  HOST_OS ?= Windows
-  HOST_OS ?= $(shell uname -s 2>/dev/null || echo Unknown)
-  # some weird MINGW/Cygwin env that doesnt define $OS
-  ifneq (,$(findstring MINGW,HOST_OS))
-    HOST_OS := Windows
-  endif
ifeq ($(TARGET_WEB),0)
ifeq ($(HOST_OS),Windows)

We also need to make a small change to src/pc/gfx/gfx_opengl.c to properly pull in GLEW. This codeblock was originally intended for MacOS - but we can make use of it:

diff --git a/src/pc/gfx/gfx_opengl.c b/src/pc/gfx/gfx_opengl.c
index b3476ce..23b6696 100644
--- a/src/pc/gfx/gfx_opengl.c
+++ b/src/pc/gfx/gfx_opengl.c
@@ -15,8 +15,8 @@
#if FOR_WINDOWS || defined(OSX_BUILD)
-# define GLEW_STATIC
-# include <GL/glew.h>
+include <GL/glew.h>

Building and Running

With everything ready, we can now build. The end result should be a directory in build/ for your region. In my case this was build/us_pc/ Performance will vary based on your machine, but you do have the option of setting the GLLEGACY render API, or setting GRUCODE to f3dnew. See the Makefile for all your options!

$ ./build/us_pc/

Mario 64 on Dragonfly 5.9-DEVELOPMENT