From 7d1c4a39c862f487dca9d3fae9c8ad70226f9752 Mon Sep 17 00:00:00 2001 From: OscarL Date: Fri, 22 Mar 2024 10:57:55 -0300 Subject: [PATCH] previous: update to version 3.1. (#10126) Leaving it disabled for now, due to the unsafe SOURCE_URI, but seems pretty functional, on beta4 64 bits at least. --- .../previous/additional-files/previous.rdef | 15 ++ .../patches/previous-1.8~svn.patchset | 111 ----------- .../patches/previous-3.1~svn.patchset | 177 ++++++++++++++++++ .../previous/previous-1.8~svn.recipe | 61 ------ .../previous/previous-3.1~svn.recipe | 83 ++++++++ 5 files changed, 275 insertions(+), 172 deletions(-) create mode 100644 app-emulation/previous/additional-files/previous.rdef delete mode 100644 app-emulation/previous/patches/previous-1.8~svn.patchset create mode 100644 app-emulation/previous/patches/previous-3.1~svn.patchset delete mode 100644 app-emulation/previous/previous-1.8~svn.recipe create mode 100644 app-emulation/previous/previous-3.1~svn.recipe diff --git a/app-emulation/previous/additional-files/previous.rdef b/app-emulation/previous/additional-files/previous.rdef new file mode 100644 index 000000000..a43f1b376 --- /dev/null +++ b/app-emulation/previous/additional-files/previous.rdef @@ -0,0 +1,15 @@ +resource app_signature "application/x-vnd.emulators.previous"; + +resource app_flags B_SINGLE_LAUNCH; + +resource app_version { + major = 3, + middle = 1, + minor = 0, + + variety = B_APPV_FINAL, + internal = 0, + + short_info = "Previous", + long_info = "A NeXT emulator" +}; diff --git a/app-emulation/previous/patches/previous-1.8~svn.patchset b/app-emulation/previous/patches/previous-1.8~svn.patchset deleted file mode 100644 index 3aeaf0316..000000000 --- a/app-emulation/previous/patches/previous-1.8~svn.patchset +++ /dev/null @@ -1,111 +0,0 @@ -From 7c7827b8c58760d24973bfc9782d6cf58f0c792d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= -Date: Wed, 22 Nov 2017 11:02:24 +0100 -Subject: [PATCH 1/3] Haiku: CMake: fix search paths - ---- - cmake/FindSDL2.cmake | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/cmake/FindSDL2.cmake b/cmake/FindSDL2.cmake -index fc2ee31..d32bed1 100644 ---- a/cmake/FindSDL2.cmake -+++ b/cmake/FindSDL2.cmake -@@ -74,12 +74,13 @@ SET(SDL2_SEARCH_PATHS - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt -+ /system/develop # Haiku - ) - - FIND_PATH(SDL2_INCLUDE_DIR SDL_scancode.h - HINTS - $ENV{SDL2DIR} -- PATH_SUFFIXES include/SDL2 include -+ PATH_SUFFIXES include/SDL2 include headers/x86/SDL2 headers/SDL2 headers - PATHS ${SDL2_SEARCH_PATHS} - ) - -@@ -87,7 +88,7 @@ FIND_LIBRARY(SDL2_LIBRARY_TEMP - NAMES SDL2 - HINTS - $ENV{SDL2DIR} -- PATH_SUFFIXES lib64 lib -+ PATH_SUFFIXES lib64 lib/x86 lib - PATHS ${SDL2_SEARCH_PATHS} - ) - -@@ -101,7 +102,7 @@ IF(NOT SDL2_BUILDING_LIBRARY) - NAMES SDL2main - HINTS - $ENV{SDL2DIR} -- PATH_SUFFIXES lib64 lib -+ PATH_SUFFIXES lib64 lib/x86 lib - PATHS ${SDL2_SEARCH_PATHS} - ) - ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") --- -2.15.0 - - -From 0e3c6924d5b225393a70ccde7ce59d9446d2f135 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= -Date: Wed, 22 Nov 2017 11:02:50 +0100 -Subject: [PATCH 2/3] Haiku: CMake: link with libnetwork - ---- - src/CMakeLists.txt | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 2401099..0f6ccf2 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -124,6 +124,11 @@ if(WIN32) - target_link_libraries(Previous ws2_32 Iphlpapi) - endif(WIN32) - -+if(HAIKU) -+ # Needed for socket() on Haiku -+ target_link_libraries(Previous network) -+endif(HAIKU) -+ - if(ENABLE_OSX_BUNDLE) - install(TARGETS Previous BUNDLE DESTINATION /Applications) - else() --- -2.15.0 - - -From ea28cdb3f93736d1408d46aea8dba7a844dc3f9b Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= -Date: Wed, 22 Nov 2017 11:03:18 +0100 -Subject: [PATCH 3/3] Haiku: use existing uint* types from SupportDefs.h or - things break - ---- - src/slirp/slirp.h | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/src/slirp/slirp.h b/src/slirp/slirp.h -index 8496ce6..22da7a2 100755 ---- a/src/slirp/slirp.h -+++ b/src/slirp/slirp.h -@@ -92,10 +92,14 @@ typedef unsigned char u_int8_t; - # endif - #endif /* NEED_TYPEDEFS */ - -+#ifdef __HAIKU__ -+#include -+#else - /* Basilisk II types glue */ - typedef u_int8_t uint8; - typedef u_int16_t uint16; - typedef u_int32_t uint32; -+#endif - - #ifdef HAVE_UNISTD_H - # include --- -2.15.0 - diff --git a/app-emulation/previous/patches/previous-3.1~svn.patchset b/app-emulation/previous/patches/previous-3.1~svn.patchset new file mode 100644 index 000000000..ffae2101c --- /dev/null +++ b/app-emulation/previous/patches/previous-3.1~svn.patchset @@ -0,0 +1,177 @@ +From 5a8110e235ce7deb4b93585544a9845ed44b72ba Mon Sep 17 00:00:00 2001 +From: Oscar Lesta +Date: Mon, 19 Feb 2024 10:02:25 -0300 +Subject: Initial Haiku patch for Previous v3.1. + + +diff --git a/src/cpu/sysdeps.h b/src/cpu/sysdeps.h +index 7c7daf1..db293c0 100644 +--- a/src/cpu/sysdeps.h ++++ b/src/cpu/sysdeps.h +@@ -259,8 +259,12 @@ typedef uae_u32 uaecptr; + + #endif /* WINUAE_FOR_HATARI */ + ++#ifdef __HAIKU__ ++#include ++#else + uae_atomic atomic_and(volatile uae_atomic *p, uae_u32 v); + uae_atomic atomic_or(volatile uae_atomic *p, uae_u32 v); ++#endif + uae_atomic atomic_inc(volatile uae_atomic *p); + uae_atomic atomic_dec(volatile uae_atomic *p); + uae_u32 atomic_bit_test_and_reset(volatile uae_atomic *p, uae_u32 v); +diff --git a/src/ditool/DiskImage.cpp b/src/ditool/DiskImage.cpp +index 2ac751e..1fed570 100644 +--- a/src/ditool/DiskImage.cpp ++++ b/src/ditool/DiskImage.cpp +@@ -11,6 +11,10 @@ + #include + #include + ++#ifdef __HAIKU__ ++ #include ++#endif ++ + /* Pull in ntohs()/ntohl()/htons()/htonl() declarations... shotgun approach */ + #if defined(linux) || defined(__MINGW32__) + /* netinet/in.h doesn't have proper extern "C" declarations for these... may also apply to other Unices */ +diff --git a/src/paths.c b/src/paths.c +index e9e2ce5..ef95a60 100644 +--- a/src/paths.c ++++ b/src/paths.c +@@ -25,6 +25,8 @@ const char Paths_fileid[] = "Hatari paths.c"; + #define HATARI_HOME_DIR "Library/Application Support/Previous" + #elif defined(WIN32) + #define HATARI_HOME_DIR "AppData\\Local\\Previous" ++#elif defined(__HAIKU__) ++ #define HATARI_HOME_DIR "config/settings/previous" + #else + #define HATARI_HOME_DIR ".config/previous" + #endif +@@ -261,7 +263,7 @@ static void Paths_InitHomeDirs(void) + + /* Hatari home directory does not exists yet... + * ... so let's try to create it: */ +-#if !defined(__APPLE__) && !defined(WIN32) ++#if !defined(__APPLE__) && !defined(WIN32) && !defined(__HAIKU__) + sprintf(sHatariHomeDir, "%s%c.config", sUserHomeDir, PATHSEP); + if (!File_DirExists(sHatariHomeDir)) + { +@@ -289,6 +291,39 @@ static void Paths_InitHomeDirs(void) + * have to find out where the executable is. But thanks to this effort, we get + * a relocatable package (we don't have any absolute path names in the program)! + */ ++ ++#ifdef __HAIKU__ ++/*#include */ ++void Paths_Init(const char *argv0) ++{ ++ /* Init working directory string */ ++ sWorkingDir = malloc(FILENAME_MAX); ++ if (!sWorkingDir || getcwd(sWorkingDir, FILENAME_MAX) == NULL) ++ { ++ /* This should never happen... just in case... */ ++ sWorkingDir = Str_Dup("."); ++ } ++ ++ /* Init the user's home directory string */ ++ Paths_InitHomeDirs(); ++ ++ /* Init screenshot directory string */ ++ sScreenShotDir = Str_Dup(sUserHomeDir); ++ ++ sDataDir = Str_Alloc(FILENAME_MAX); ++ /* On Haiku' BIN2DATADIR is an absolute path already, use that as is. */ ++ strcpy(sDataDir, BIN2DATADIR); ++/* ++ syslog(LOG_INFO, ++ "[Previous] WorkingDir = '%s'\n" ++ "[Previous] DataDir = '%s'\n" ++ "[Previous] UserHomeDir = '%s'\n" ++ "[Previous] HatariHomeDir = '%s'\n" ++ "[Previous] ScreenShotDir = '%s'\n", ++ sWorkingDir, sDataDir, sUserHomeDir, sHatariHomeDir, sScreenShotDir); ++*/ ++} ++#else + void Paths_Init(const char *argv0) + { + char *psExecDir; /* Path string where the hatari executable can be found */ +@@ -331,6 +366,7 @@ void Paths_Init(const char *argv0) + /* fprintf(stderr, " WorkingDir = %s\n DataDir = %s\n UserHomeDir = %s\n HatariHomeDir = %s\n ScrenShotDir = %s\n", + sWorkingDir, sDataDir, sUserHomeDir, sHatariHomeDir, sScreenShotDir); */ + } ++#endif + + void Paths_UnInit(void) + { +diff --git a/src/slirp/nfs/CSocket.h b/src/slirp/nfs/CSocket.h +index 06f0409..0b512a7 100755 +--- a/src/slirp/nfs/CSocket.h ++++ b/src/slirp/nfs/CSocket.h +@@ -5,7 +5,11 @@ + #include + #else + #include +-#include ++#ifdef __HAIKU__ ++ #include ++#else ++ #include ++#endif + #include + #endif + #include +diff --git a/src/slirp/nfs/RPCProg.h b/src/slirp/nfs/RPCProg.h +index 1cbc6f4..cd9832f 100755 +--- a/src/slirp/nfs/RPCProg.h ++++ b/src/slirp/nfs/RPCProg.h +@@ -5,7 +5,9 @@ + #include + + /* The maximum number of bytes in a pathname argument. */ ++#ifndef MAXPATHLEN + #define MAXPATHLEN 1024 ++#endif + + /* The maximum number of bytes in a file name argument. */ + #define MAXNAMELEN 255 +diff --git a/src/slirp/slirp.h b/src/slirp/slirp.h +index 695afaa..cd1b88c 100755 +--- a/src/slirp/slirp.h ++++ b/src/slirp/slirp.h +@@ -356,7 +356,7 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err); + #define MAX_MRU 16384 + #endif + +-#ifndef _WIN32 ++#if !defined(_WIN32) && !defined(__HAIKU__) + #define min(x,y) ((x) < (y) ? (x) : (y)) + #define max(x,y) ((x) > (y) ? (x) : (y)) + #endif +diff --git a/src/zip.c b/src/zip.c +index 630b91e..aafe74c 100644 +--- a/src/zip.c ++++ b/src/zip.c +@@ -304,8 +304,15 @@ struct dirent **ZIP_GetFilesDir(const zip_dir *zip, const char *dir, int *entrie + ZIP_FreeZipDir(files); + return NULL; + } +- strncpy(fentries[i]->d_name, files->names[i], sizeof(fentries[i]->d_name)-1); +- fentries[i]->d_name[sizeof(fentries[i]->d_name) - 1] = 0; ++ ++#ifdef __HAIKU__ ++ // Not sure **at all** about this, but... it compiles at least :-D ++ size_t sz = strlen(fentries[i]->d_name); ++#else ++ size_t sz = sizeof(fentries[i]->d_name); ++#endif ++ strncpy(fentries[i]->d_name, files->names[i], sz - 1); ++ fentries[i]->d_name[sz - 1] = 0; + } + + ZIP_FreeZipDir(files); +-- +2.42.1 + diff --git a/app-emulation/previous/previous-1.8~svn.recipe b/app-emulation/previous/previous-1.8~svn.recipe deleted file mode 100644 index d3fa00a8f..000000000 --- a/app-emulation/previous/previous-1.8~svn.recipe +++ /dev/null @@ -1,61 +0,0 @@ -SUMMARY="A NeXT emulator" -DESCRIPTION=" -Previous is a Next computer hardware emulator. \ -It aims to emulate a Next Cube or a Next Station with all its peripheral. -" -HOMEPAGE="http://previous.alternative-system.com/" -SOURCE_URI="svn://svn.code.sf.net/p/previous/code/trunk#844" -REVISION="2" -#CHECKSUM_MD5="" -COPYRIGHT="2001-2017 Andreas Grabher" -LICENSE="GNU GPL v2" -PATCHES="previous-$portVersion.patchset" - -ARCHITECTURES="?all !x86_gcc2" -SECONDARY_ARCHITECTURES="x86" - -PROVIDES=" - previous = $portVersion - app:Previous = $portVersion - cmd:previous = $portVersion - " -REQUIRES=" - haiku${secondaryArchSuffix} - lib:libpng16$secondaryArchSuffix - lib:libreadline$secondaryArchSuffix - lib:libsdl2_2.0$secondaryArchSuffix - lib:libz$secondaryArchSuffix - " -BUILD_REQUIRES=" - haiku${secondaryArchSuffix}_devel - devel:libpng16$secondaryArchSuffix - devel:libreadline$secondaryArchSuffix - devel:libsdl2_2.0$secondaryArchSuffix - devel:libz$secondaryArchSuffix - " -BUILD_PREREQUIRES=" - cmd:aclocal - cmd:autoconf - cmd:cmake - cmd:make - cmd:python - cmd:gcc${secondaryArchSuffix} - cmd:sdl2_config${secondaryArchSuffix} - " - -BUILD() -{ - mkdir -p build - cd build - cmake -DCMAKE_INSTALL_PREFIX=$prefix -DBINDIR=$binDir -DDATADIR=$dataDir/previous -DMANDIR=$manDir/man1 -DDOCDIR=$docDir/previous .. - make -} - -INSTALL() -{ - cd build - make install - mv $binDir/Previous $prefix/bin/ - mimeset $prefix/bin/Previous - addAppDeskbarSymlink /bin/Previous Previous -} diff --git a/app-emulation/previous/previous-3.1~svn.recipe b/app-emulation/previous/previous-3.1~svn.recipe new file mode 100644 index 000000000..5d3b965cb --- /dev/null +++ b/app-emulation/previous/previous-3.1~svn.recipe @@ -0,0 +1,83 @@ +SUMMARY="A NeXT emulator" +DESCRIPTION=" +Previous is a Next computer hardware emulator. \ +It aims to emulate a Next Cube or a Next Station with all its peripheral. +" +HOMEPAGE="http://previous.alternative-system.com/" +COPYRIGHT="2001-2024 Andreas Grabher" +LICENSE="GNU GPL v2" +REVISION="1" +SOURCE_URI="svn://svn.code.sf.net/p/previous/code/trunk#1424" +SOURCE_DIR="" +PATCHES="previous-$portVersion.patchset" +ADDITIONAL_FILES="previous.rdef" + +ARCHITECTURES="?all !x86_gcc2" +SECONDARY_ARCHITECTURES="?x86" + +commandBinDir=$binDir +commandSuffix=$secondaryArchSuffix +if [ "$targetArchitecture" = x86_gcc2 ]; then + commandSuffix= + commandBinDir=$prefix/bin +fi + +PROVIDES=" + previous$secondaryArchSuffix = $portVersion + app:Previous = $portVersion + cmd:previous$commandSuffix = $portVersion + " +REQUIRES=" + haiku${secondaryArchSuffix} + lib:libpng16$secondaryArchSuffix + lib:libreadline$secondaryArchSuffix + lib:libsdl2_2.0$secondaryArchSuffix + lib:libz$secondaryArchSuffix + " +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + devel:libpng16$secondaryArchSuffix + devel:libreadline$secondaryArchSuffix + devel:libsdl2_2.0$secondaryArchSuffix + devel:libsdl$secondaryArchSuffix + devel:libz$secondaryArchSuffix + " +BUILD_PREREQUIRES=" + cmd:cmake + cmd:make + cmd:python3 + cmd:gcc$secondaryArchSuffix + cmd:sdl2_config$secondaryArchSuffix + cmd:pkg_config$secondaryArchSuffix + " + +BUILD() +{ + # Without -DENABLE_RENDERING_THREAD=0, `previous` crashes at startup. + # + # CMake seems to not set HAVE_LXETXATTR value correctly on build/config.h, which + # causes ntohl/ntohs to be undefined. Let's force it ON for now: + cmake -B build -S . $cmakeDirArgs \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_FLAGS="-DHAVE_LXETXATTR=1" \ + -DCMAKE_EXE_LINKER_FLAGS="-lbsd -lgnu" \ + -DENABLE_RENDERING_THREAD=0 \ + -DENABLE_TRACING=0 \ + -DDATADIR=$dataDir/previous \ + -DBIN2DATADIR=$dataDir/previous + + make -C build $jobArgs +} + +INSTALL() +{ + make -C build install + + # We don't need this big .bmp either + rm $dataDir/previous/Previous-icon.bmp + + addResourcesToBinaries $portDir/additional-files/previous.rdef $commandBinDir/previous$commandSuffix + mimeset $commandBinDir/previous$commandSuffix + + addAppDeskbarSymlink $commandBinDir/previous$commandSuffix Previous +}