gentoo-overlay/app-emulation/np2kai/np2kai-9999.ebuild

169 lines
5.3 KiB
Shell

# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
WX_GTK_VER="3.2-gtk3"
inherit cmake desktop git-r3 wxwidgets xdg
DESCRIPTION="PC-9801 series emulator (NP2kai fork with a Qt 6 frontend, development branch)"
HOMEPAGE="
https://github.com/legal-hkr/NP2kai
https://github.com/AZO234/NP2kai
"
# A fork of upstream's wx_alpha branch that adds the Qt 6 frontend. It follows
# the work in progress: whatever is pushed to the branch is what gets built.
EGIT_REPO_URI="https://github.com/legal-hkr/NP2kai.git"
EGIT_BRANCH="qt-port"
# The VST3 SDK, the WDK finder for Windows and SDL2 find modules; the SDL3
# build here needs none of them.
EGIT_SUBMODULES=()
# MIT for NP2kai itself, BSD and BSD-2 for the NP2 core, i386c, the BSD MAME
# sound cores and SoftFloat 3, GPL-2+ for the DOSBox FPU, ZLIB for the bundled
# zlib, fmgen for the FM sound generator. See LICENSES/ in the sources.
LICENSE="MIT BSD BSD-2 GPL-2+ ZLIB fmgen"
SLOT="0"
# A live ebuild off a development branch, not a release. Requires "**" in
# package.accept_keywords.
KEYWORDS=""
IUSE="i286 nls +qt6 sdl +wayland wxwidgets"
REQUIRED_USE="
|| ( qt6 sdl wxwidgets )
wayland? ( qt6 )
"
# Every frontend takes its audio from SDL and the character font, when no
# font ROM is given, from SDL_ttf. The Qt port locks the pointer under Wayland
# through Qt's private API, hence the slot operator on qtbase; qtsvg draws its
# window icon. With nls the Qt port speaks German, Japanese or Polish when the
# system does, its standard buttons and file dialogs worded by qttranslations.
RDEPEND="
dev-libs/libcdio:=
media-libs/libpng:=
media-libs/libsdl3
media-libs/sdl3-ttf
qt6? (
dev-cpp/tomlplusplus
>=dev-qt/qtbase-6.8:6=[gui,widgets,wayland?]
dev-qt/qtsvg:6
nls? ( dev-qt/qttranslations:6 )
wayland? ( dev-libs/wayland )
)
wxwidgets? (
dev-cpp/tomlplusplus
x11-libs/wxGTK:${WX_GTK_VER}
)
"
DEPEND="
${RDEPEND}
qt6? ( wayland? ( dev-libs/wayland-protocols ) )
"
# CMake refuses to configure without a working git binary, even when the
# version is handed to it from the environment; git-r3 already pulls it in.
BDEPEND="
virtual/pkgconfig
qt6? (
nls? ( dev-qt/qttools:6[linguist] )
wayland? ( dev-util/wayland-scanner )
)
"
PATCHES=(
"${FILESDIR}"/${PN}-wx-wayland-mouse.patch
)
# BUILD_I286 picks one CPU core per configure run, so i286 is a second build
# tree next to the IA-32 one.
np2kai_variants() {
echo ia32
use i286 && echo i286
}
src_configure() {
use wxwidgets && setup-wxwidgets
# Taken from the environment, so the result doesn't depend on which tags
# git-r3 happened to fetch for git describe.
export NP2KAI_VERSION="rev.22"
export NP2KAI_HASH="${EGIT_VERSION:0:7}"
local variant
for variant in $(np2kai_variants); do
local mycmakeargs=(
-DBUILD_QT=$(usex qt6)
-DBUILD_SDL=$(usex sdl)
-DBUILD_WX=$(usex wxwidgets)
-DBUILD_X=OFF
-DBUILD_LIBRETRO=OFF
-DBUILD_I286=$([[ ${variant} == i286 ]] && echo ON || echo OFF)
-DUSE_SDL=3
-DUSE_HAXM=OFF
# Would pull Steinberg's SDK in as a git submodule at configure
# time.
-DUSE_VST3SDK=OFF
)
use qt6 && mycmakeargs+=(
-DUSE_QT_TRANSLATIONS=$(usex nls ON OFF)
-DUSE_WAYLAND=$(usex wayland ON OFF)
)
use wxwidgets && mycmakeargs+=(
-DwxWidgets_CONFIG_EXECUTABLE="${WX_CONFIG}"
)
BUILD_DIR="${WORKDIR}/build-${variant}" cmake_src_configure
done
}
src_compile() {
local variant
for variant in $(np2kai_variants); do
BUILD_DIR="${WORKDIR}/build-${variant}" cmake_src_compile
done
}
# Upstream's install() rules are limited to the Release and RelWithDebInfo
# configurations, so under the Gentoo build type they install nothing. The Qt
# port's rules have no such limit: its program, menu entry, icon and man pages
# come from cmake_src_install, the other frontends are installed by hand.
src_install() {
local variant name
for variant in $(np2kai_variants); do
BUILD_DIR="${WORKDIR}/build-${variant}" cmake_src_install
[[ ${variant} == i286 ]] && name=np2kai || name=np21kai
use sdl && dobin "${WORKDIR}/build-${variant}/sdl${name}"
if use wxwidgets; then
dobin "${WORKDIR}/build-${variant}/wx${name}"
newman wx/wx${name}.man1 wx${name}.1
newman wx/wx${name}.jman1 wx${name}.ja.1
domenu wx/resources/wx${name}.desktop
fi
done
use wxwidgets && doicon -s scalable misc/np2.svg
}
pkg_postinst() {
xdg_pkg_postinst
elog "This is a development fork: it builds the current state of the qt-port"
elog "branch of https://github.com/legal-hkr/NP2kai, which may change or break"
elog "between updates."
elog
elog "NP2kai works best with ROM images dumped from a real PC-98 (bios.rom,"
elog "font.rom or font.bmp, itf.rom, sound.rom), made there with GETBIOS from"
elog "np2tool, and the 2608_*.wav samples for the YM2608 rhythm part. Each"
elog "program looks for them in its own directory under"
elog "\${XDG_CONFIG_HOME:-~/.config}, e.g. ~/.config/qtnp21kai/,"
elog "~/.config/sdlnp21kai/ or ~/.config/wxnp21kai/."
elog
elog "Without font.rom the character font is built from a Japanese TrueType"
elog "font linked there as default.ttf, e.g. one from media-fonts/noto-cjk."
elog "Delete font.tmp in that directory after changing it."
if use sdl; then
elog
elog "The SDL port has no window menus; F11 or the middle mouse button"
elog "opens its own menu, which swaps floppy and hard disk images."
fi
}