name=sdl2
version=2.30.3
revision=1
tarball_url="https://github.com/libsdl-org/SDL/releases/download/release-${version}/SDL2-${version}.tar.gz"
tarball_blake2b="9918723bc3a0bc3abfc6d47b4fc7eeabcafdc9925ee93e4f31b3637e843a5b060ae61aef9b93743340a9df914248cff510e5d38e758e032b5ed4df9eed587746"
imagedeps="gcc ninja git"
hostdeps="gcc cmake pkg-config"
deps="core-libs libx11 libxext libxcursor libxi libxfixes libxrandr libxrender libxxf86vm mesa"

build() {
    cmake \
        -GNinja \
        -DCMAKE_TOOLCHAIN_FILE=${base_dir}/build-support/CMakeToolchain.txt \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE=Release \
        -DSDL_ALTIVEC=OFF \
        -DSDL_DISKAUDIO=OFF \
        -DSDL_DIRECTFB=ON \
        -DSDL_OPENGL=ON \
        -DSDL_OPENGLES=ON \
        -DSDL_PTHREADS=ON \
        -DSDL_PTHREADS_SEM=OFF \
        -DSDL_OSS=OFF \
        -DSDL_ALSA=OFF \
        -DSDL_JACK=OFF \
        -DSDL_ESD=OFF \
        -DSDL_PULSEAUDIO=OFF \
        -DSDL_ARTS=OFF \
        -DSDL_NAS=OFF \
        -DSDL_SNDIO=OFF \
        -DSDL_FUSIONSOUND=OFF \
        -DSDL_LIBSAMPLERATE=OFF \
        -DSDL_RPATH=OFF \
        -DSDL_X11=ON \
        -DSDL_WAYLAND=OFF \
        -DSDL_WAYLAND_QT_TOUCH=OFF \
        -DSDL_RPI=OFF \
        -DSDL_COCOA=OFF \
        -DSDL_DIRECTX=OFF \
        -DSDL_WASAPI=OFF \
        -DSDL_RENDER_D3D=OFF \
        -DSDL_VIVANTE=OFF \
        -DSDL_VULKAN=OFF \
        -DSDL_KMSDRM=OFF \
        -DSDL_HIDAPI=OFF \
        -DSDL_SHARED=ON \
        -DSDL_STATIC=OFF \
        ${source_dir}

    ninja -j${parallelism}
}

package() {
    DESTDIR="${dest_dir}" ninja install

    rm "${dest_dir}${prefix}"/lib/{libSDL2_test.a,libSDL2main.a}

    post_package_strip
}
