mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 11:45:45 +03:00
np2kai: 0.86rev22 -> 0.86rev22-unstable-2024-12-22
This commit is contained in:
parent
3f08fcf3da
commit
f0b38d6cc0
1 changed files with 90 additions and 193 deletions
|
@ -2,32 +2,23 @@
|
||||||
stdenv,
|
stdenv,
|
||||||
lib,
|
lib,
|
||||||
fetchFromGitHub,
|
fetchFromGitHub,
|
||||||
enable16Bit ? true,
|
unstableGitUpdater,
|
||||||
enable32Bit ? true,
|
writeShellApplication,
|
||||||
|
cmake,
|
||||||
enableSDL ? true,
|
fontconfig,
|
||||||
withSDLVersion ? "2",
|
freetype,
|
||||||
SDL,
|
glib,
|
||||||
SDL_ttf,
|
gtk2,
|
||||||
SDL_mixer,
|
libusb1,
|
||||||
|
libX11,
|
||||||
|
openssl,
|
||||||
|
pkg-config,
|
||||||
SDL2,
|
SDL2,
|
||||||
SDL2_ttf,
|
SDL2_ttf,
|
||||||
SDL2_mixer,
|
SDL2_mixer,
|
||||||
|
|
||||||
|
enable16Bit ? true,
|
||||||
enableX11 ? stdenv.hostPlatform.isLinux,
|
enableX11 ? stdenv.hostPlatform.isLinux,
|
||||||
automake,
|
|
||||||
autoconf,
|
|
||||||
autoconf-archive,
|
|
||||||
libtool,
|
|
||||||
pkg-config,
|
|
||||||
unzip,
|
|
||||||
gtk2,
|
|
||||||
libusb1,
|
|
||||||
libXxf86vm,
|
|
||||||
nasm,
|
|
||||||
libICE,
|
|
||||||
libSM,
|
|
||||||
|
|
||||||
# HAXM build succeeds but the binary segfaults, seemingly due to the missing HAXM kernel module
|
# HAXM build succeeds but the binary segfaults, seemingly due to the missing HAXM kernel module
|
||||||
# Enable once there is a HAXM kernel module option in NixOS? Or somehow bind it to the system kernel having HAXM?
|
# Enable once there is a HAXM kernel module option in NixOS? Or somehow bind it to the system kernel having HAXM?
|
||||||
# Or leave it disabled by default?
|
# Or leave it disabled by default?
|
||||||
|
@ -35,198 +26,104 @@
|
||||||
enableHAXM ? false,
|
enableHAXM ? false,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert lib.assertMsg (
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
enable16Bit || enable32Bit
|
|
||||||
) "Must enable 16-Bit and/or 32-Bit system variant.";
|
|
||||||
assert lib.assertMsg (enableSDL || enableX11) "Must enable SDL and/or X11 graphics interfaces.";
|
|
||||||
assert lib.assertOneOf "withSDLVersion" withSDLVersion [
|
|
||||||
"1"
|
|
||||||
"2"
|
|
||||||
];
|
|
||||||
assert enableHAXM -> (lib.assertMsg enableX11 "Must enable X11 graphics interface for HAXM build.");
|
|
||||||
let
|
|
||||||
inherit (lib) optional optionals optionalString;
|
|
||||||
inherit (lib.strings) concatStringsSep concatMapStringsSep;
|
|
||||||
isSDL2 = (withSDLVersion == "2");
|
|
||||||
sdlInfix = optionalString isSDL2 "2";
|
|
||||||
sdlDeps1 = [
|
|
||||||
SDL
|
|
||||||
SDL_ttf
|
|
||||||
SDL_mixer
|
|
||||||
];
|
|
||||||
sdlDeps2 = [
|
|
||||||
SDL2
|
|
||||||
SDL2_ttf
|
|
||||||
SDL2_mixer
|
|
||||||
];
|
|
||||||
sdlDepsBuildonly = if isSDL2 then sdlDeps1 else sdlDeps2;
|
|
||||||
sdlDepsTarget = if isSDL2 then sdlDeps2 else sdlDeps1;
|
|
||||||
sdlMakefileSuffix =
|
|
||||||
if stdenv.hostPlatform.isWindows then
|
|
||||||
"win"
|
|
||||||
else if stdenv.hostPlatform.isDarwin then
|
|
||||||
"mac"
|
|
||||||
else
|
|
||||||
"unix";
|
|
||||||
sdlMakefiles = concatMapStringsSep " " (x: x + "." + sdlMakefileSuffix) (
|
|
||||||
optionals enable16Bit [
|
|
||||||
"Makefile"
|
|
||||||
]
|
|
||||||
++ optionals enable32Bit [
|
|
||||||
"Makefile21"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
sdlBuildFlags = concatStringsSep " " (
|
|
||||||
optionals enableSDL [
|
|
||||||
"SDL_VERSION=${withSDLVersion}"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
sdlBins = concatStringsSep " " (
|
|
||||||
optionals enable16Bit [
|
|
||||||
"np2kai"
|
|
||||||
]
|
|
||||||
++ optionals enable32Bit [
|
|
||||||
"np21kai"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
x11ConfigureFlags = concatStringsSep " " (
|
|
||||||
(
|
|
||||||
if ((enableHAXM && (enable16Bit || enable32Bit)) || (enable16Bit && enable32Bit)) then
|
|
||||||
[
|
|
||||||
"--enable-build-all"
|
|
||||||
]
|
|
||||||
else if enableHAXM then
|
|
||||||
[
|
|
||||||
"--enable-haxm"
|
|
||||||
]
|
|
||||||
else if enable32Bit then
|
|
||||||
[
|
|
||||||
"--enable-ia32"
|
|
||||||
]
|
|
||||||
else
|
|
||||||
[ ]
|
|
||||||
)
|
|
||||||
++ optionals (!isSDL2) [
|
|
||||||
"--enable-sdl"
|
|
||||||
"--enable-sdlmixer"
|
|
||||||
"--enable-sdlttf"
|
|
||||||
|
|
||||||
"--enable-sdl2=no"
|
|
||||||
"--enable-sdl2mixer=no"
|
|
||||||
"--enable-sdl2ttf=no"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
x11BuildFlags = concatStringsSep " " [
|
|
||||||
"SDL2_CONFIG=sdl2-config"
|
|
||||||
"SDL_CONFIG=sdl-config"
|
|
||||||
"SDL_CFLAGS=\"$(sdl${sdlInfix}-config --cflags)\""
|
|
||||||
"SDL_LIBS=\"$(sdl${sdlInfix}-config --libs) -lSDL${sdlInfix}_mixer -lSDL${sdlInfix}_ttf\""
|
|
||||||
];
|
|
||||||
x11Bins = concatStringsSep " " (
|
|
||||||
optionals enable16Bit [
|
|
||||||
"xnp2kai"
|
|
||||||
]
|
|
||||||
++ optionals enable32Bit [
|
|
||||||
"xnp21kai"
|
|
||||||
]
|
|
||||||
++ optionals enableHAXM [
|
|
||||||
"xnp21kai_haxm"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
in
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
pname = "np2kai";
|
pname = "np2kai";
|
||||||
version = "0.86rev22"; # update src.rev to commit rev accordingly
|
version = "0.86rev22-unstable-2024-12-22";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "AZO234";
|
owner = "AZO234";
|
||||||
repo = "NP2kai";
|
repo = "NP2kai";
|
||||||
rev = "4a317747724669343e4c33ebdd34783fb7043221";
|
rev = "da219658c24c610ba82d5a07ea9897e8e0eef670";
|
||||||
sha256 = "0kxysxhx6jyk82mx30ni0ydzmwdcbnlxlnarrlq018rsnwb4md72";
|
hash = "sha256-b0KOfqUgVtFuZxw8js6JCnzMh6Wh+f7o/IHcD6TiG1s=";
|
||||||
};
|
};
|
||||||
|
|
||||||
configurePhase =
|
# Don't require Git
|
||||||
''
|
# Use SDL2(_*) targets for correct includedirs
|
||||||
export GIT_VERSION=${builtins.substring 0 7 src.rev}
|
# Add return type in ancient code
|
||||||
''
|
postPatch = ''
|
||||||
+ optionalString enableParallelBuilding ''
|
substituteInPlace CMakeLists.txt \
|
||||||
appendToVar buildFlags "-j$NIX_BUILD_CORES"
|
--replace-fail 'if(NOT git_result EQUAL 0)' 'if(FALSE)' \
|
||||||
''
|
--replace-fail "\''${SDL2_DEFINE}" "" \
|
||||||
+ optionalString enableX11 ''
|
--replace-fail "\''${SDL2_INCLUDE_DIR}" "" \
|
||||||
cd x11
|
--replace-fail "\''${SDL2_LIBRARY}" "SDL2::SDL2" \
|
||||||
substituteInPlace Makefile.am \
|
--replace-fail "\''${SDL2_MIXER_DEFINE}" "" \
|
||||||
--replace 'GIT_VERSION :=' 'GIT_VERSION ?='
|
--replace-fail "\''${SDL2_MIXER_INCLUDE_DIR}" "" \
|
||||||
./autogen.sh ${x11ConfigureFlags}
|
--replace-fail "\''${SDL2_MIXER_LIBRARY}" "SDL2_mixer::SDL2_mixer" \
|
||||||
./configure ${x11ConfigureFlags}
|
--replace-fail "\''${SDL2_TTF_DEFINE}" "" \
|
||||||
cd ..
|
--replace-fail "\''${SDL2_TTF_INCLUDE_DIR}" "" \
|
||||||
'';
|
--replace-fail "\''${SDL2_TTF_LIBRARY}" "SDL2_ttf::SDL2_ttf" \
|
||||||
|
|
||||||
|
substituteInPlace x/cmserial.c \
|
||||||
|
--replace-fail 'convert_np2tocm(UINT port, UINT8* param, UINT32* speed) {' 'int convert_np2tocm(UINT port, UINT8* param, UINT32* speed) {'
|
||||||
|
substituteInPlace x/gtk2/gtk_menu.c \
|
||||||
|
--replace-fail 'xmenu_visible_item(MENU_HDL hdl, const char *name, BOOL onoff)' 'int xmenu_visible_item(MENU_HDL hdl, const char *name, BOOL onoff)'
|
||||||
|
'';
|
||||||
|
|
||||||
|
strictDeps = true;
|
||||||
|
|
||||||
nativeBuildInputs =
|
nativeBuildInputs =
|
||||||
sdlDepsBuildonly
|
[
|
||||||
++ optionals enableX11 [
|
cmake
|
||||||
automake
|
]
|
||||||
autoconf
|
++ lib.optionals enableX11 [
|
||||||
autoconf-archive
|
|
||||||
libtool
|
|
||||||
pkg-config
|
pkg-config
|
||||||
unzip
|
|
||||||
nasm
|
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
sdlDepsTarget
|
[
|
||||||
++ optionals enableX11 [
|
|
||||||
gtk2
|
|
||||||
libICE
|
|
||||||
libSM
|
|
||||||
libusb1
|
libusb1
|
||||||
libXxf86vm
|
openssl
|
||||||
|
SDL2
|
||||||
|
SDL2_ttf
|
||||||
|
SDL2_mixer
|
||||||
|
]
|
||||||
|
++ lib.optionals enableX11 [
|
||||||
|
fontconfig
|
||||||
|
freetype
|
||||||
|
glib
|
||||||
|
gtk2
|
||||||
|
libX11
|
||||||
];
|
];
|
||||||
|
|
||||||
|
cmakeFlags = [
|
||||||
|
(lib.cmakeBool "BUILD_SDL" true)
|
||||||
|
(lib.cmakeBool "BUILD_X" enableX11)
|
||||||
|
(lib.cmakeBool "BUILD_HAXM" enableHAXM)
|
||||||
|
(lib.cmakeBool "BUILD_I286" enable16Bit)
|
||||||
|
|
||||||
|
(lib.cmakeBool "USE_SDL" true)
|
||||||
|
(lib.cmakeBool "USE_SDL2" true)
|
||||||
|
(lib.cmakeBool "USE_SDL_MIXER" true)
|
||||||
|
(lib.cmakeBool "USE_SDL_TTF" true)
|
||||||
|
(lib.cmakeBool "USE_X" enableX11)
|
||||||
|
(lib.cmakeBool "USE_HAXM" enableHAXM)
|
||||||
|
];
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
# TODO Remove when bumping past rev22
|
env = {
|
||||||
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-D_DARWIN_C_SOURCE";
|
NP2KAI_VERSION = finalAttrs.version;
|
||||||
|
NP2KAI_HASH = builtins.substring 0 7 finalAttrs.src.rev;
|
||||||
|
# GCC 14 incompatibility
|
||||||
|
NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types";
|
||||||
|
};
|
||||||
|
|
||||||
buildPhase =
|
passthru.updateScript = unstableGitUpdater {
|
||||||
optionalString enableSDL ''
|
# 0.86 version prefix is implied, add it back for our versioning
|
||||||
cd sdl2
|
tagConverter = lib.getExe (writeShellApplication {
|
||||||
for mkfile in ${sdlMakefiles}; do
|
name = "update-np2kai";
|
||||||
substituteInPlace $mkfile \
|
text = ''
|
||||||
--replace 'GIT_VERSION :=' 'GIT_VERSION ?='
|
sed -e 's/^rev\./0.86rev/g'
|
||||||
echo make -f $mkfile $buildFlags ${sdlBuildFlags} clean
|
'';
|
||||||
make -f $mkfile $buildFlags ${sdlBuildFlags} clean
|
});
|
||||||
make -f $mkfile $buildFlags ${sdlBuildFlags}
|
};
|
||||||
done
|
|
||||||
cd ..
|
|
||||||
''
|
|
||||||
+ optionalString enableX11 ''
|
|
||||||
cd x11
|
|
||||||
make $buildFlags ${x11BuildFlags}
|
|
||||||
cd ..
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase =
|
meta = {
|
||||||
optionalString enableSDL ''
|
|
||||||
cd sdl2
|
|
||||||
for emu in ${sdlBins}; do
|
|
||||||
install -D -m 755 $emu $out/bin/$emu
|
|
||||||
done
|
|
||||||
cd ..
|
|
||||||
''
|
|
||||||
+ optionalString enableX11 ''
|
|
||||||
cd x11
|
|
||||||
for emu in ${x11Bins}; do
|
|
||||||
install -D -m 755 $emu $out/bin/$emu
|
|
||||||
done
|
|
||||||
cd ..
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description = "PC-9801 series emulator";
|
description = "PC-9801 series emulator";
|
||||||
homepage = "https://github.com/AZO234/NP2kai";
|
homepage = "https://github.com/AZO234/NP2kai";
|
||||||
license = licenses.mit;
|
license = lib.licenses.mit;
|
||||||
maintainers = with maintainers; [ OPNA2608 ];
|
maintainers = with lib.maintainers; [ OPNA2608 ];
|
||||||
platforms = platforms.x86;
|
mainProgram = "${if enableX11 then "x" else "sdl"}np21kai";
|
||||||
|
platforms = lib.platforms.x86;
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue