# Building mz800emu on Ubuntu 24.04

This guide describes how to compile the `mz800emu` emulator on Ubuntu. It will walk you through installing necessary development tools, downloading the source code, and building the executable.

## 1) Update your system

Before installing any packages, update your package database and upgrade existing packages:

```sh
sudo apt update
sudo apt upgrade
```

## 2a) Install required development packages

Install the base development tools and libraries required to compile `mz800emu`:

```sh
sudo apt install build-essential subversion doxygen
sudo apt install libglib2.0-dev libcurl4-openssl-dev
```

## 2b) Install SDL3 and SDL3-image

SDL3 and SDL3-image now is not available as oficial Ubuntu package.
Tady je můj postup jak nakompilovat vlastní SDL3 a SDL3_Image, nicméně lepší bude, když si ověříte oficiální postup zde https://www.libsdl.org/

```sh
sudo apt update
sudo apt install -y build-essential cmake ninja-build python3-pip libx11-dev libxext-dev libxrandr-dev \
  libxinerama-dev libxcursor-dev libxi-dev libwayland-dev wayland-protocols libdrm-dev libgbm-dev \
  libasound2-dev libpulse-dev libaudio-dev libxrender-dev libxfixes-dev libxss-dev libdbus-1-dev \
  libudev-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev fcitx-libs-dev libsamplerate0-dev \
  libpipewire-0.3-dev libdecor-0-dev git



cd /usr/local/src
git clone https://github.com/libsdl-org/SDL.git
cd SDL
git checkout main
mkdir build
cd build
cmake .. -G Ninja -DSDL_TEST=ON -DSDL_SHARED=ON -DSDL_STATIC=OFF
ninja
sudo ninja install
sudo ldconfig
pkg-config --modversion sdl3
```

Build SDL3_Image:

```sh
cd /usr/local/src
git clone https://github.com/libsdl-org/SDL_image.git
cd SDL_image
git checkout main
mkdir build
cd build
cmake .. -DSDL3IMAGE_VENDORED=OFF -DCMAKE_INSTALL_PREFIX=/usr/local
make -j$(nproc)
sudo make install
pkg-config --modversion sdl3-image
```

## 3) Download the latest mz800emu code

Download the source code using Subversion:

```sh
svn checkout https://svn.code.sf.net/p/mz800emu/code/ mz800emu-code
cd mz800emu-code/branches/2.0.x-preview
```

Compile the program:

```sh
make -j$(nproc)
```

## 4) Running the program

If the program was successfully compiled, you can run it directly from the terminal:

```sh
./mz800emu
```

## 5) Creating a distribution directory

If you want to prepare a directory with all necessary files for distribution:

```sh
make dist
```

All required files will be copied into the `./dist` directory.
