Porting software

Mizu has a C library: musl, with a layer that answers Linux's system calls from Mizu's. Ordinary portable C builds for it with its usual configure and make. curl, NetSurf and FFmpeg came over this way.

The tools

The easy way: download the ready SDK (about 84 MB), unpack it, and everything below is already built. From Mizu's source instead, build musl into the SDK once, then use sdk/koi-gcc wherever a build wants a C compiler. It is your host's GCC with Mizu's headers, start-up code and linker script.

ports/musl/build.sh                    # sdk/libc: headers and libc.a (not needed with the archive)
sdk/koi-g++ -O2 game.cpp -o GAME.EXE    # C++, with libstdc++
sdk/koi-gcc -O2 hello.c -o HELLO.EXE    # one file, from any folder

# Autotools
./configure --host=x86_64-linux-musl CC=/path/to/sdk/koi-gcc \
            AR=ar RANLIB=ranlib --disable-shared
make

With the C library a program is ordinary C: #include <stdio.h> and int main(int argc, char** argv), not the main(const char* arguments) of a koi.h program.

#include <stdio.h>

int main(int argc, char** argv) {
    printf("Hello from musl, %d argument(s)\n", argc - 1);
    return 0;
}

What comes out is a static, position-independent ELF program. Name it .EXE, copy it to a Mizu drive and run it from the Command Prompt or the Run box. printf goes to the Command Prompt it was started from.

Libraries already in the SDK

Each is built by a script in ports/ and installs into sdk/libc, with a .pc file in sdk/libc/lib/pkgconfig for pkg-config.

ScriptWhat it gives
ports/libs/build.shzlib, libpng, libjpeg-turbo, expat, FreeType
ports/mbedtls/build.shMbed TLS: TLS and cryptography
ports/curl/build.shlibcurl with https, and CURL.EXE
ports/llvm, ports/libdrm, ports/mesaOpenGL: -lGL (Mesa's OSMesa, with llvmpipe)
ports/sdl2/build.shSDL 2: windows on the desktop (or the whole screen), keys, the pointer and sound
ports/ffmpeg/build.shFFmpeg's decoders, demuxers, libswscale and libswresample
ports/ncurses/build.shncurses (wide, UTF-8), with xterm, vt100 and ansi built in
ports/nano/build.shGNU nano, a whole program, as an example to read
ports/netsurf/build.shNetSurf, a whole program, as an example to read

Run them in that order: each needs the ones above it. The CA certificates for TLS are in Z:\MIZU\CACERT.PEM on every Mizu.

What works

What does not, yet

Each of these is a gap to fill when something worth running needs it. If your port runs into one, say so: koiayame.com/help-mizu.

Drawing and sound

The easiest way is SDL 2, which most games and many tools already use. Its window is a window of the desktop's, with keys going down and up, the pointer, both mouse buttons held, the wheel and sound; SDL_WINDOW_FULLSCREEN maximises it. Without a desktop it takes the whole screen instead, scaled to fit.

sdk/koi-gcc -O2 $(sdk/libc/bin/sdl2-config --cflags) game.c \
            $(sdk/libc/bin/sdl2-config --libs) -lm -o GAME.EXE

OpenGL is Mesa 24.3 through OSMesa (ports/mesa): llvmpipe on the processor (OpenGL 4.5), or the graphics card where Mizu drives one (crocus for Intel HD 2000/3000, virgl in QEMU). Link with -lGL and SDL's SDL_GL_* calls work; QuakeSpasm (ports/quakespasm) builds unchanged this way. A program that does not link -lGL does not carry Mesa.

A ported program can call the same koi_* functions as any Mizu program: include koi.h beside the C library and draw with koi_gfx_*, play with koi_sound_* (see Writing a program). For a window on the desktop, NetSurf's ports/netsurf/mizu.c shows how a program from elsewhere opens one.

Sharing it

Put the result in a package (Packages) and it can reach the App Store. Keep the program's licence beside it.

Writing an app →