git: af9050eeb8d0 - main - emulators/86Box: New port: low level x86 emulator based on PCem

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Sat, 03 Aug 2024 11:40:02 UTC
The branch main has been updated by vvd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=af9050eeb8d0c504ca1347398222f751bab6f329

commit af9050eeb8d0c504ca1347398222f751bab6f329
Author:     gatekeeper <tiago.gasiba@gmail.com>
AuthorDate: 2024-08-03 11:34:17 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-08-03 11:34:17 +0000

    emulators/86Box: New port: low level x86 emulator based on PCem
    
    86Box is a low level x86 emulator that runs older operating systems and
    software designed for IBM PC systems and compatibles from 1981 through
    fairly recent system designs based on the PCI bus.
    https://86box.net
    https://github.com/86Box/86Box
    
    PR:     280205
---
 emulators/86Box/Makefile                           | 74 ++++++++++++++++++++++
 emulators/86Box/distinfo                           |  3 +
 .../files/patch-cmake_flags-gcc-aarch64.cmake      | 10 +++
 .../86Box/files/patch-cmake_flags-gcc-armv7.cmake  | 10 +++
 .../files/patch-cmake_flags-gcc-x86__64.cmake      | 12 ++++
 emulators/86Box/files/patch-cmake_flags-gcc.cmake  | 11 ++++
 .../86Box/files/patch-src_printer_CMakeLists.txt   | 10 +++
 .../86Box/files/patch-src_qt_qt__mainwindow.cpp    | 10 +++
 emulators/86Box/pkg-descr                          |  3 +
 emulators/86Box/pkg-plist                          | 10 +++
 emulators/Makefile                                 |  1 +
 11 files changed, 154 insertions(+)

diff --git a/emulators/86Box/Makefile b/emulators/86Box/Makefile
new file mode 100644
index 000000000000..8cae024dfbba
--- /dev/null
+++ b/emulators/86Box/Makefile
@@ -0,0 +1,74 @@
+PORTNAME=	86Box
+DISTVERSIONPREFIX=	v
+DISTVERSION=	4.2
+CATEGORIES=	emulators
+
+MAINTAINER=	tiago.gasiba@gmail.com
+COMMENT=	Emulator of x86-based machines based on PCem
+WWW=		https://86box.net/
+
+LICENSE=	GPLv2
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+ONLY_FOR_ARCHS=	amd64
+
+BUILD_DEPENDS=	evdev-proto>=5.8:devel/evdev-proto
+LIB_DEPENDS=	libevdev.so:devel/libevdev \
+		libfluidsynth.so:audio/fluidsynth \
+		libfreetype.so:print/freetype2 \
+		libopenal.so:audio/openal-soft \
+		libpng.so:graphics/png \
+		librtmidi.so:audio/rtmidi \
+		libslirp.so:net/libslirp \
+		libsndfile.so:audio/libsndfile \
+		libxkbcommon.so:x11/libxkbcommon
+
+FLAVORS=		qt5 qt6
+FLAVOR?=		${FLAVORS:[2]}
+qt5_PKGNAMESUFFIX=	-qt5
+qt6_PKGNAMESUFFIX=	-qt6
+
+USES=		cmake compiler gnome pkgconfig qmake sdl xorg
+USE_GITHUB=	yes
+USE_GNOME=	glib20
+USE_SDL=	sdl2
+USE_XORG=	x11 xcb xext xi
+
+.if ${FLAVOR} == qt5
+USES+=		qt:5
+USE_QT=		core gui network opengl widgets buildtools:build linguisttools:build
+.else
+BUILD_DEPENDS+=	vulkan-headers>0:graphics/vulkan-headers
+USES+=		gl qt:6
+USE_GL=		opengl
+USE_QT=		base tools:build
+CMAKE_ON=	USE_QT6
+CXXFLAGS+=	-I${LOCALBASE}/include/qt6/QtGui/`pkg-config --modversion Qt6Gui`/QtGui
+.endif
+
+OPTIONS_DEFINE=		NLS WAYLAND
+OPTIONS_DEFAULT=	WAYLAND
+
+NLS_USES=		gettext-runtime
+NLS_CONFIGURE_ENABLE=	nls
+
+WAYLAND_LIB_DEPENDS=	libwayland-client.so:graphics/wayland
+WAYLAND_USES=		kde:5
+WAYLAND_USE=		kde=ecm:build
+WAYLAND_CMAKE_OFF=	-DCMAKE_DISABLE_FIND_PACKAGE_Wayland:BOOL=ON
+
+ICON_RESOLUTIONS=	128x128 192x192 256x256 48x48 512x512 64x64 72x72 96x96
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKDIR}/.build/src/86Box ${STAGEDIR}${PREFIX}/bin
+	${REINPLACE_CMD} -e 's|Exec=86Box|Exec=/bin/sh -c "${PREFIX}/bin/86Box -C $${HOME}/86box.cfg"|' \
+		${WRKSRC}/src/unix/assets/net.86box.86Box.desktop
+	${INSTALL_DATA} ${WRKSRC}/src/unix/assets/net.86box.86Box.desktop \
+		${STAGEDIR}${PREFIX}/share/applications
+.for F in ${ICON_RESOLUTIONS}
+	${MKDIR} ${STAGEDIR}${PREFIX}/share/icons/hicolor/${F}/apps
+	${INSTALL_DATA} ${WRKSRC}/src/unix/assets/${F}/net.86box.86Box.png \
+		${STAGEDIR}${PREFIX}/share/icons/hicolor/${F}/apps
+.endfor
+
+.include <bsd.port.mk>
diff --git a/emulators/86Box/distinfo b/emulators/86Box/distinfo
new file mode 100644
index 000000000000..95cede5345c6
--- /dev/null
+++ b/emulators/86Box/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1722535296
+SHA256 (86Box-86Box-v4.2_GH0.tar.gz) = 891787580b67607490aa2257c0efa8b6a8afe954fa6fdb7c0db574caf307d615
+SIZE (86Box-86Box-v4.2_GH0.tar.gz) = 5297797
diff --git a/emulators/86Box/files/patch-cmake_flags-gcc-aarch64.cmake b/emulators/86Box/files/patch-cmake_flags-gcc-aarch64.cmake
new file mode 100644
index 000000000000..3a58a593294f
--- /dev/null
+++ b/emulators/86Box/files/patch-cmake_flags-gcc-aarch64.cmake
@@ -0,0 +1,10 @@
+--- cmake/flags-gcc-aarch64.cmake.orig	2024-07-26 18:14:45 UTC
++++ cmake/flags-gcc-aarch64.cmake
+@@ -14,7 +14,4 @@
+ #          Copyright 2021 David Hrdlička.
+ #
+ 
+-string(APPEND CMAKE_C_FLAGS_INIT    " -march=armv8-a")
+-string(APPEND CMAKE_CXX_FLAGS_INIT  " -march=armv8-a")
+-
+ include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake)
diff --git a/emulators/86Box/files/patch-cmake_flags-gcc-armv7.cmake b/emulators/86Box/files/patch-cmake_flags-gcc-armv7.cmake
new file mode 100644
index 000000000000..5809748fa55e
--- /dev/null
+++ b/emulators/86Box/files/patch-cmake_flags-gcc-armv7.cmake
@@ -0,0 +1,10 @@
+--- cmake/flags-gcc-armv7.cmake.orig	2024-07-26 18:16:08 UTC
++++ cmake/flags-gcc-armv7.cmake
+@@ -14,7 +14,4 @@
+ #          Copyright 2021 David Hrdlička.
+ #
+ 
+-string(APPEND CMAKE_C_FLAGS_INIT    " -march=armv7-a+fp -mfloat-abi=hard")
+-string(APPEND CMAKE_CXX_FLAGS_INIT  " -march=armv7-a+fp -mfloat-abi=hard")
+-
+ include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake)
diff --git a/emulators/86Box/files/patch-cmake_flags-gcc-x86__64.cmake b/emulators/86Box/files/patch-cmake_flags-gcc-x86__64.cmake
new file mode 100644
index 000000000000..100bdd0cb47c
--- /dev/null
+++ b/emulators/86Box/files/patch-cmake_flags-gcc-x86__64.cmake
@@ -0,0 +1,12 @@
+--- cmake/flags-gcc-x86_64.cmake.orig	2024-07-26 18:16:26 UTC
++++ cmake/flags-gcc-x86_64.cmake
+@@ -14,7 +14,7 @@
+ #          Copyright 2021 David Hrdlička.
+ #
+ 
+-string(APPEND CMAKE_C_FLAGS_INIT    " -m64 -march=x86-64 -msse2 -mfpmath=sse -mstackrealign")
+-string(APPEND CMAKE_CXX_FLAGS_INIT  " -m64 -march=x86-64 -msse2 -mfpmath=sse -mstackrealign")
++string(APPEND CMAKE_C_FLAGS_INIT    " -mstackrealign")
++string(APPEND CMAKE_CXX_FLAGS_INIT  " -mstackrealign")
+ 
+ include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake)
diff --git a/emulators/86Box/files/patch-cmake_flags-gcc.cmake b/emulators/86Box/files/patch-cmake_flags-gcc.cmake
new file mode 100644
index 000000000000..d9b56c9c71ed
--- /dev/null
+++ b/emulators/86Box/files/patch-cmake_flags-gcc.cmake
@@ -0,0 +1,11 @@
+--- cmake/flags-gcc.cmake.orig	2024-07-26 18:17:03 UTC
++++ cmake/flags-gcc.cmake
+@@ -16,8 +16,6 @@ string(APPEND CMAKE_CXX_FLAGS_INIT              " -fom
+ # Define our flags
+ string(APPEND CMAKE_C_FLAGS_INIT                " -fomit-frame-pointer -Wall -fno-strict-aliasing -Werror=implicit-int -Werror=implicit-function-declaration -Werror=int-conversion -Werror=strict-prototypes -Werror=old-style-definition")
+ string(APPEND CMAKE_CXX_FLAGS_INIT              " -fomit-frame-pointer -Wall -fno-strict-aliasing")
+-string(APPEND CMAKE_C_FLAGS_RELEASE_INIT        " -g0 -O3")
+-string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT      " -g0 -O3")
+ string(APPEND CMAKE_C_FLAGS_DEBUG_INIT          " -ggdb -Og")
+ string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT        " -ggdb -Og")
+ string(APPEND CMAKE_C_FLAGS_OPTIMIZED_INIT      " -march=native -mtune=native -O3 -ffp-contract=fast -flto")
diff --git a/emulators/86Box/files/patch-src_printer_CMakeLists.txt b/emulators/86Box/files/patch-src_printer_CMakeLists.txt
new file mode 100644
index 000000000000..a6da4a25f91e
--- /dev/null
+++ b/emulators/86Box/files/patch-src_printer_CMakeLists.txt
@@ -0,0 +1,10 @@
+--- src/printer/CMakeLists.txt.orig	2024-08-02 00:15:09 UTC
++++ src/printer/CMakeLists.txt
+@@ -29,6 +29,7 @@ target_link_libraries(86Box PkgConfig::FREETYPE)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(FREETYPE REQUIRED IMPORTED_TARGET freetype2)
+ target_link_libraries(86Box PkgConfig::FREETYPE)
++target_include_directories(print PRIVATE ${FREETYPE_INCLUDE_DIRS})
+ if(STATIC_BUILD)
+     # if(QT)
+         # Qt provides its own version of harfbuzz which leads to duplicated symbols.
diff --git a/emulators/86Box/files/patch-src_qt_qt__mainwindow.cpp b/emulators/86Box/files/patch-src_qt_qt__mainwindow.cpp
new file mode 100644
index 000000000000..e6bbf8c52860
--- /dev/null
+++ b/emulators/86Box/files/patch-src_qt_qt__mainwindow.cpp
@@ -0,0 +1,10 @@
+--- src/qt/qt_mainwindow.cpp.orig	2024-08-02 00:15:09 UTC
++++ src/qt/qt_mainwindow.cpp
+@@ -378,6 +378,7 @@ MainWindow::MainWindow(QWidget *parent)
+ 
+ #if QT_CONFIG(vulkan)
+     bool vulkanAvailable = false;
++    if (0)
+     {
+         QVulkanInstance instance;
+         instance.setApiVersion(QVersionNumber(1, 0));
diff --git a/emulators/86Box/pkg-descr b/emulators/86Box/pkg-descr
new file mode 100644
index 000000000000..7d5b9f1a6f35
--- /dev/null
+++ b/emulators/86Box/pkg-descr
@@ -0,0 +1,3 @@
+86Box is a low level x86 emulator that runs older operating systems
+and software designed for IBM PC systems and compatibles from 1981
+through fairly recent system designs based on the PCI bus.
diff --git a/emulators/86Box/pkg-plist b/emulators/86Box/pkg-plist
new file mode 100644
index 000000000000..9dd5dc91a4a7
--- /dev/null
+++ b/emulators/86Box/pkg-plist
@@ -0,0 +1,10 @@
+bin/86Box
+share/applications/net.86box.86Box.desktop
+share/icons/hicolor/128x128/apps/net.86box.86Box.png
+share/icons/hicolor/192x192/apps/net.86box.86Box.png
+share/icons/hicolor/256x256/apps/net.86box.86Box.png
+share/icons/hicolor/48x48/apps/net.86box.86Box.png
+share/icons/hicolor/512x512/apps/net.86box.86Box.png
+share/icons/hicolor/64x64/apps/net.86box.86Box.png
+share/icons/hicolor/72x72/apps/net.86box.86Box.png
+share/icons/hicolor/96x96/apps/net.86box.86Box.png
diff --git a/emulators/Makefile b/emulators/Makefile
index 8474e5a06209..e93755f0ec1c 100644
--- a/emulators/Makefile
+++ b/emulators/Makefile
@@ -1,5 +1,6 @@
     COMMENT = Emulators for other operating systems
 
+    SUBDIR += 86Box
     SUBDIR += adamem
     SUBDIR += almostti
     SUBDIR += anese