Solved What changes/additions do I need for the Makefile of torzu in order to build torzu correctly ?

Torzu is a continuation of the now dead Nintendo Switch emulator called yuzu.
In contrast to yuzu it is more privacy respecting, and has a broader game compatibility.
It is developed with care, and the team is very reliable.
I am now studying the code, and consider to make some commitments/contributions to that great project, too.

So far I took the Makefile of emulators/yuzu as a reference to create my torzu Makefile.
Code:
PORTNAME=        torzu
DISTVERSION=    1.0-0
PORTREVISION=    0
CATEGORIES=        emulators

MASTER_SITES=    https://notabug.org/litucks/${PORTNAME}/archive/master.tar.gz
MASTER_SITES+=    http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/${PORTNAME}-emu/${PORTNAME}/archive/master.tar.gz
DISTFILES=        torzu-master.tar.gz

MAINTAINER=        sdk-chan@protonmail.com
COMMENT=        Nintendo Switch emulator/debugger
WWW=            https://notabug.org/litucks/torzu/src/master/README.md

WRKSRC=                        ${WRKDIR}/${PORTNAME}
LICENSE=                    APACHE20 BSD3CLAUSE GPLv3+ ISCL MIT UNLICENSE
LICENSE_COMB=                multi
LICENSE_FILE_BSD3CLAUSE=    ${WRKSRC}/externals/sirit/LICENSE.txt
LICENSE_FILE_GPLv3+ =        ${WRKSRC}/LICENSE.txt
LICENSE_FILE_ISCL=            ${WRKSRC}/externals/cubeb/LICENSE
LICENSE_FILE_MIT=            ${WRKSRC}/externals/sirit/externals/SPIRV-Headers/LICENSE

ONLY_FOR_ARCHS=    aarch64 amd64
ONLY_FOR_ARCHS_REASON=    requires int128 and dynarmic backend

BUILD_DEPENDS=    boost-libs>0:devel/boost-libs \
                nlohmann-json>0:devel/nlohmann-json \
                simpleini>0:devel/simpleini \
                xbyak>0:devel/xbyak \
                glslangValidator:graphics/glslang \
                vulkan-headers>0:graphics/vulkan-headers \
                vulkan-utility-libraries>0:graphics/vulkan-utility-libraries

LIB_DEPENDS=    liblz4.so:archivers/liblz4 \
                libzstd.so:archivers/zstd \
                libopus.so:audio/opus \
                libfmt.so:devel/libfmt \
                libavcodec.so:multimedia/ffmpeg \
                libenet.so:net/enet

TEST_DEPENDS=    catch2>0:devel/catch2

USE_GITHUB=    nodefault
GH_TUPLE=    GPUOpen-LibrariesAndSDKs:VulkanMemoryAllocator:v3.0.1-114-g2f382df:VulkanMemoryAllocator/externals/VulkanMemoryAllocator \
            KhronosGroup:SPIRV-Headers:1.5.4.raytracing.fixed-201-gc214f6f:SPIRV_Headers/externals/sirit/externals/SPIRV-Headers \
            merryhime:oaknut:2.0.1:oaknut/externals/oaknut \
            arun11299:cpp-jwt:v1.4-18-g10ef573:cpp_jwt/externals/cpp-jwt \
            arsenm:sanitizers-cmake:aab6948:sanitizers_cmake/externals/cubeb/cmake/sanitizers-cmake \
            eggert:tz:2022g-11-g16ce126a:tz/externals/nx_tzdb/tzdb_to_nx/externals/tz/tz \
            kinetiknz:cubeb:cubeb-0.2-1452-g48689ae:cubeb/externals/cubeb \
            lat9nq:tzdb_to_nx:221202-15-g9792969:tzdb_to_nx/externals/nx_tzdb/tzdb_to_nx \
            yhirose:cpp-httplib:v0.14.1:cpp_httplib/externals/cpp-httplib

USES=        cmake:testing localbase:ldflags pkgconfig sdl ssl
USE_SDL=    sdl2

CMAKE_ON=    Boost_USE_STATIC_LIBS
CMAKE_ON+=    BUNDLE_SPEEX # only used by cubeb tests
CMAKE_ON+=    CMAKE_DISABLE_FIND_PACKAGE_LLVM # only need Demangle but llvm* is huge

CMAKE_OFF=    YUZU_CHECK_SUBMODULES YUZU_USE_EXTERNAL_SDL2
CMAKE_OFF+=    YUZU_USE_EXTERNAL_VULKAN_HEADERS YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES
CMAKE_OFF+=    HTTPLIB_USE_BROTLI_IF_AVAILABLE # unused by ENABLE_WEB_SERVICE

CMAKE_OFF+=    ${ARCH:Maarch64:C/.+/YUZU_USE_PRECOMPILED_HEADERS DYNARMIC_USE_PRECOMPILED_HEADERS/}
CMAKE_OFF+=    ${CMAKE_TESTING_ON}
CMAKE_TESTING_ON=    YUZU_TESTS
LDFLAGS+=    -Wl,--as-needed # Qt5Network
PLIST_FILES=    bin/${PORTNAME}-cmd \
                bin/${PORTNAME}-room

OPTIONS_DEFINE=        QT6 ALSA JACK LTO NLS SNDIO VAAPI VULKAN WEBENGINE
OPTIONS_DEFAULT=    QT6 ALSA JACK LTO NLS SNDIO VAAPI VULKAN WEBENGINE
QT6_DESC=            Graphical User Interface (GUI)
JACK_DESC=            Audio server which depends on ALSA/OSS
LTO_DESC=            Link Time Optimization
NLS_DESC=            UI translations (implies ${NLS_IMPLIES})
SNDIO_DESC=            OpenBSDs audio and midi framework
VAAPI_DESC=            Open source API for video acceleration
VULKAN_DESC=        Graphics API written in C and used as backend for rendering purposes
WEBENGINE_DESC=        Support for web related activities

VULKAN_RUN_DEPENDS=    ${LOCALBASE}/lib/libvulkan.so:graphics/vulkan-loader

ALSA_BUILD_DEPENDS=    alsa-lib>0:audio/alsa-lib
ALSA_CMAKE_BOOL=    USE_ALSA


JACK_BUILD_DEPENDS=    jackit>0:audio/jack
JACK_CMAKE_BOOL=    USE_JACK

LTO_CMAKE_BOOL=        YUZU_ENABLE_LTO

NLS_USE=            QT=${"${PORT_OPTIONS:MQT6}":?linguist:}tools:build
NLS_CMAKE_BOOL=        ENABLE_QT_TRANSLATION
NLS_IMPLIES=        QT6

QT6_USES=            qt:6 desktop-file-utils shared-mime-info
QT6_USE=            QT=base
QT6_CMAKE_BOOL=        ENABLE_QT6
QT6_PLIST_FILES=    bin/${PORTNAME} \
                    share/applications/org.yuzu_emu.yuzu.desktop \
                    share/icons/hicolor/scalable/apps/org.yuzu_emu.yuzu.svg \
                    share/metainfo/org.yuzu_emu.yuzu.metainfo.xml \
                    share/mime/packages/org.yuzu_emu.yuzu.xml

SNDIO_BUILD_DEPENDS=    sndio>0:audio/sndio
SNDIO_CMAKE_BOOL=        USE_SNDIO

VAAPI_LIB_DEPENDS=        libva.so:multimedia/libva

WEBENGINE_USE=            QT=webengine
WEBENGINE_CMAKE_BOOL=    YUZU_USE_QT_WEB_ENGINE
WEBENGINE_IMPLIES=        QT6

post-patch:
    @${REINPLACE_CMD} -e 's/@GIT_BRANCH@/master/' \
        -e 's/@GIT_DESC@/${GH_TAGNAME}/' \
        ${WRKSRC}/src/common/scm_rev.cpp.in
# https://github.com/ConsoleKit2/ConsoleKit2/issues/150
    @${REINPLACE_CMD} -e 's,/login1,/ConsoleKit/Manager,' \
        -e 's,login1,ConsoleKit,' \
        ${WRKSRC}/src/${PORTNAME}/main.cpp

post-patch-VAAPI-off:
    @${REINPLACE_CMD} -i .nova '/pkg_check.*libva/d' \
        ${WRKSRC}/CMakeLists.txt

post-install:
.if exists(/usr/bin/elfctl)
    ${ELFCTL} -e +wxneeded ${STAGEDIR}${PREFIX}/bin/*
.endif

.include <bsd.port.mk>

Yuzu Makefile content:
Code:
PORTNAME=    yuzu
PORTVERSION=    s20240301
PORTREVISION=    4
CATEGORIES=    emulators wayland
.if make(makesum)
MASTER_SITES=    https://api.yuzu-emu.org/gamedb/?dummy=/:gamedb
.else
MASTER_SITES=    LOCAL/jbeich:gamedb
.endif
MASTER_SITES+=    https://codeberg.org/TxzK/${PORTNAME}/archive/${GH_TAGNAME}${EXTRACT_SUFX}?dummy=/
DISTFILES=    ${PORTNAME}-s20230424/compatibility_list.json:gamedb
DISTFILES+=    ${DISTNAME}${EXTRACT_SUFX}
EXTRACT_ONLY=    ${DISTFILES:N*\:gamedb:C/\:.*//}

MAINTAINER=    jbeich@FreeBSD.org
COMMENT=    Nintendo Switch emulator/debugger
WWW=        https://yuzu-emu.org/

LICENSE=    APACHE20 BSD3CLAUSE GPLv3+ ISCL MIT UNLICENSE
LICENSE_COMB=    multi
LICENSE_FILE_BSD3CLAUSE=${WRKSRC}/externals/sirit/LICENSE.txt
LICENSE_FILE_GPLv3+ =    ${WRKSRC}/LICENSE.txt
LICENSE_FILE_ISCL=    ${WRKSRC}/externals/cubeb/LICENSE
LICENSE_FILE_MIT=    ${WRKSRC}/externals/sirit/externals/SPIRV-Headers/LICENSE

ONLY_FOR_ARCHS=    aarch64 amd64
ONLY_FOR_ARCHS_REASON=    requires int128 and dynarmic backend
# XXX Need Ryujinx or a Yuzu fork that regularly improves game compatibility
DEPRECATED=    Project discontinued

BUILD_DEPENDS=    boost-libs>0:devel/boost-libs \
        nlohmann-json>0:devel/nlohmann-json \
        simpleini>0:devel/simpleini \
        xbyak>0:devel/xbyak \
        glslangValidator:graphics/glslang \
        vulkan-headers>0:graphics/vulkan-headers \
        vulkan-utility-libraries>0:graphics/vulkan-utility-libraries
LIB_DEPENDS=    liblz4.so:archivers/liblz4 \
        libzstd.so:archivers/zstd \
        libopus.so:audio/opus \
        libfmt.so:devel/libfmt \
        libavcodec.so:multimedia/ffmpeg \
        libenet.so:net/enet
TEST_DEPENDS=    catch2>0:devel/catch2

FLAVORS=    qt6 qt5
qt5_PKGNAMESUFFIX=    -qt5
qt5_CONFLICTS_INSTALL=    ${PORTNAME}
qt5_OPTIONS_SLAVE=    QT5
qt5_OPTIONS_EXCLUDE=    QT6
qt6_CONFLICTS_INSTALL=    ${PORTNAME}-qt5

USE_GITHUB=    nodefault
GH_ACCOUNT=    yuzu-mirror
GH_TAGNAME=    15e6e48bef
GH_TUPLE=    yuzu-mirror:mbedtls:v2.16.9-115-g8c88150ca:mbedtls/externals/mbedtls \
        yuzu-mirror:sirit:ab75463:sirit/externals/sirit \
        GPUOpen-LibrariesAndSDKs:VulkanMemoryAllocator:v3.0.1-114-g2f382df:VulkanMemoryAllocator/externals/VulkanMemoryAllocator \
        KhronosGroup:SPIRV-Headers:1.5.4.raytracing.fixed-201-gc214f6f:SPIRV_Headers/externals/sirit/externals/SPIRV-Headers \
        yuzu-mirror:dynarmic:6.6.2-15-gba8192d8:dynarmic/externals/dynarmic \
        merryhime:oaknut:2.0.1:oaknut/externals/oaknut \
        arun11299:cpp-jwt:v1.4-18-g10ef573:cpp_jwt/externals/cpp-jwt \
        arsenm:sanitizers-cmake:aab6948:sanitizers_cmake/externals/cubeb/cmake/sanitizers-cmake \
        eggert:tz:2022g-11-g16ce126a:tz/externals/nx_tzdb/tzdb_to_nx/externals/tz/tz \
        kinetiknz:cubeb:cubeb-0.2-1452-g48689ae:cubeb/externals/cubeb \
        lat9nq:tzdb_to_nx:221202-15-g9792969:tzdb_to_nx/externals/nx_tzdb/tzdb_to_nx \
        yhirose:cpp-httplib:v0.14.1:cpp_httplib/externals/cpp-httplib

USES=        cmake:testing localbase:ldflags pkgconfig sdl ssl
USE_SDL=    sdl2
WRKSRC=        ${WRKDIR}/${PORTNAME}
CMAKE_ON=    Boost_USE_STATIC_LIBS
CMAKE_ON+=    BUNDLE_SPEEX # only used by cubeb tests
CMAKE_ON+=    CMAKE_DISABLE_FIND_PACKAGE_LLVM # only need Demangle but llvm* is huge
CMAKE_OFF=    YUZU_CHECK_SUBMODULES YUZU_USE_EXTERNAL_SDL2
CMAKE_OFF+=    YUZU_USE_EXTERNAL_VULKAN_HEADERS YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES
CMAKE_OFF+=    HTTPLIB_USE_BROTLI_IF_AVAILABLE # unused by ENABLE_WEB_SERVICE
CMAKE_OFF+=    ${ARCH:Maarch64:C/.+/YUZU_USE_PRECOMPILED_HEADERS DYNARMIC_USE_PRECOMPILED_HEADERS/}
CMAKE_OFF+=    ${CMAKE_TESTING_ON}
CMAKE_TESTING_ON=    YUZU_TESTS
LDFLAGS+=    -Wl,--as-needed # Qt5Network
PLIST_FILES=    bin/${PORTNAME}-cmd \
        bin/${PORTNAME}-room

OPTIONS_DEFINE=    ALSA GUI PULSEAUDIO JACK LTO NLS SNDIO VAAPI VULKAN WEBENGINE
OPTIONS_DEFAULT=PULSEAUDIO JACK LTO QT6 SNDIO VAAPI VULKAN WEBENGINE
OPTIONS_SINGLE=    GUI
OPTIONS_SINGLE_GUI=    QT5 QT6
OPTIONS_SLAVE=        ${${FLAVOR}_OPTIONS_SLAVE}
OPTIONS_EXCLUDE=    ${${FLAVOR}_OPTIONS_EXCLUDE}

ALSA_BUILD_DEPENDS=    alsa-lib>0:audio/alsa-lib
ALSA_CMAKE_BOOL=    USE_ALSA

GUI_USES=        desktop-file-utils shared-mime-info
GUI_CMAKE_BOOL=        ENABLE_QT
GUI_PLIST_FILES=    bin/${PORTNAME} \
            share/applications/org.yuzu_emu.yuzu.desktop \
            share/icons/hicolor/scalable/apps/org.yuzu_emu.yuzu.svg \
            share/metainfo/org.yuzu_emu.yuzu.metainfo.xml \
            share/mime/packages/org.yuzu_emu.yuzu.xml

JACK_BUILD_DEPENDS=    jackit>0:audio/jack
JACK_CMAKE_BOOL=    USE_JACK

LTO_CMAKE_BOOL=        YUZU_ENABLE_LTO

NLS_DESC=        UI translations (implies ${NLS_IMPLIES})
NLS_USE=        QT=${"${PORT_OPTIONS:MQT5}":?linguist:}tools:build
NLS_CMAKE_BOOL=        ENABLE_QT_TRANSLATION
NLS_IMPLIES=        GUI

PULSEAUDIO_BUILD_DEPENDS=pulseaudio>0:audio/pulseaudio
PULSEAUDIO_CMAKE_BOOL=    USE_PULSE

QT5_USES=        qt:5
QT5_USE=        QT=qmake:build,buildtools:build,concurrent:build,core,dbus,gui,multimedia,widgets
QT5_IMPLIES=        GUI

QT6_USES=        qt:6
QT6_USE=        QT=base
QT6_CMAKE_BOOL=        ENABLE_QT6
QT6_IMPLIES=        GUI

SNDIO_BUILD_DEPENDS=    sndio>0:audio/sndio
SNDIO_CMAKE_BOOL=    USE_SNDIO

VAAPI_LIB_DEPENDS=    libva.so:multimedia/libva

VULKAN_DESC=        Vulkan renderer
VULKAN_RUN_DEPENDS=    ${LOCALBASE}/lib/libvulkan.so:graphics/vulkan-loader

WEBENGINE_DESC=        Web applet support (implies ${WEBENGINE_IMPLIES})
WEBENGINE_USE=        QT=webengine
WEBENGINE_CMAKE_BOOL=    YUZU_USE_QT_WEB_ENGINE
WEBENGINE_IMPLIES=    GUI

post-extract:
    @${CP} ${DISTFILES:M*\:gamedb:C/\:.*//:S,^,${_DISTDIR},} \
        ${WRKSRC}/dist/compatibility_list/

post-patch:
    @${REINPLACE_CMD} -e 's/@GIT_BRANCH@/master/' \
        -e 's/@GIT_DESC@/${GH_TAGNAME}/' \
        ${WRKSRC}/src/common/scm_rev.cpp.in
# https://github.com/ConsoleKit2/ConsoleKit2/issues/150
    @${REINPLACE_CMD} -e 's,/login1,/ConsoleKit/Manager,' \
        -e 's,login1,ConsoleKit,' \
        ${WRKSRC}/src/${PORTNAME}/main.cpp
.ifdef DEPRECATED
    @${GREP} -Flr 'yuzu-emu' ${WRKSRC} | ${XARGS} ${REINPLACE_CMD} \
        -e 's,${WWW:S,/$,,},https://web.archive.org/web/20240304190805/&,g' \
        -e 's,https://api.yuzu-emu.org,,g' \
        -e 's,https://profile.yuzu-emu.org/,,g' \
        -e 's,\(https://github.com\)/\(yuzu-emu\),\1/${GH_ACCOUNT},g'
.endif

post-patch-VAAPI-off:
    @${REINPLACE_CMD} -i .nova '/pkg_check.*libva/d' \
        ${WRKSRC}/CMakeLists.txt

post-install:
.if exists(/usr/bin/elfctl)
    ${ELFCTL} -e +wxneeded ${STAGEDIR}${PREFIX}/bin/*
.endif

.include <bsd.port.mk>

What do the following commands mean?
Code:
1)
post-extract:
    @${CP} ${DISTFILES:M*\:gamedb:C/\:.*//:S,^,${_DISTDIR},} \
        ${WRKSRC}/dist/compatibility_list/
--------------------------------------------------------------
2)
post-patch:
    @${REINPLACE_CMD} -e 's/@GIT_BRANCH@/master/' \
        -e 's/@GIT_DESC@/${GH_TAGNAME}/' \
        ${WRKSRC}/src/common/scm_rev.cpp.in
# https://github.com/ConsoleKit2/ConsoleKit2/issues/150
    @${REINPLACE_CMD} -e 's,/login1,/ConsoleKit/Manager,' \
        -e 's,login1,ConsoleKit,' \
        ${WRKSRC}/src/${PORTNAME}/main.cpp
--------------------------------------------------------------
(
.ifdef DEPRECATED
    @${GREP} -Flr 'yuzu-emu' ${WRKSRC} | ${XARGS} ${REINPLACE_CMD} \
        -e 's,${WWW:S,/$,,},https://web.archive.org/web/20240304190805/&,g' \
        -e 's,https://api.yuzu-emu.org,,g' \
        -e 's,https://profile.yuzu-emu.org/,,g' \
        -e 's,\(https://github.com\)/\(yuzu-emu\),\1/${GH_ACCOUNT},g'
.endif
), I don't think I will need it.

3)
post-patch-VAAPI-off:
    @${REINPLACE_CMD} -i .nova '/pkg_check.*libva/d' \
        ${WRKSRC}/CMakeLists.txt
--------------------------------------------------------------

4)
post-install:
.if exists(/usr/bin/elfctl)
    ${ELFCTL} -e +wxneeded ${STAGEDIR}${PREFIX}/bin/*
.endif
--------------------------------------------------------------

I know there are 8 steps (default actions) after issuing make install.
You have either pre-*, or post-* targets you can use before or after these 8 steps, right ?

@ before each command means to silence it.

Code:
1)
post-extract:
    @${CP} ${DISTFILES:M*\:gamedb:C/\:.*//:S,^,${_DISTDIR},} \
        ${WRKSRC}/dist/compatibility_list/
Looking at this code closely, it copies over files.
But I don't understand "${DISTFILES:M*\:gamedb:C/\:.*//:S,^,${_DISTDIR},}" at all.
M* is some form of expansion.
gamedb is probably related to jbeichs game database so, I don't need it, I think.
Is "C/\:.*//:S,^,${_DISTDIR},}" a regular expression ?, and is everything here applying to ${_DISTDIR}, and then copied over to torzu/dist/compatibility_list/ ?
I think it is not mandatory for the program to work as I have a compatibility list in torzu available.
I wonder for what kind of purpose it is...

Code:
2)
post-patch:
    @${REINPLACE_CMD} -e 's/@GIT_BRANCH@/master/' \
        -e 's/@GIT_DESC@/${GH_TAGNAME}/' \
        ${WRKSRC}/src/common/scm_rev.cpp.in
# https://github.com/ConsoleKit2/ConsoleKit2/issues/150
    @${REINPLACE_CMD} -e 's,/login1,/ConsoleKit/Manager,' \
        -e 's,login1,ConsoleKit,' \
        ${WRKSRC}/src/${PORTNAME}/main.cpp
As I understand it, it replaces something ?
Do I need this part at all ?
If yes, how could I translate it to work on non-github related things like the notabug master site posted above ?

The first REINPLACE_CMD replaces every occurence of @GIT_BRANCH@ with master, and @GIT_DESC@ with the content of GH_TAGNAME in torzu/src/commong/scm_rev.cpp.in, I believe.
I wonder if it is really needed for the program to work...

The second REINPLACE_CMD I am not sure.
What does 's,/login1,/ConsoleKit/Manager,' mean ?
What is the purpose of (s,) instead of using plain s/login1/ConsoleKit/Manager etc...
Both commands are replacing part of the original code.
 
REINPLACE_CMD is sed(1) by default, but because these commands are set via a variable, you can substitute it for a different command without having to modify a gazillion port Makefiles. See Mk/bsd.commands.mk

What does 's,/login1,/ConsoleKit/Manager,' mean ?
What is the purpose of (s,) instead of using plain s/login1/ConsoleKit/Manager etc...
The terms themselves contain slashes. To prevent a backslash-hell you typically use a different separator. Any character except a backslash or newline can be used as separator:
Code:
     1.   In a context address, any character other than a backslash (“\”) or
          newline character may be used to delimit the regular expression.
          The opening delimiter needs to be preceded by a backslash unless it
          is a slash.  For example, the context address \xabcx is equivalent
          to /abc/.  Also, putting a backslash character before the delimiting
          character within the regular expression causes the character to be
          treated literally.  For example, in the context address \xabc\xdefx,
          the RE delimiter is an “x” and the second “x” stands for itself, so
          that the regular expression is “abcxdef”.

Compare: s/\/login1/\/ConsoleKit\/Manager/ vs s,/login1,/ConsoleKit/Manager, Both do exactly the same, the second is much more readable.
 
Ok, I always used the backslash hell, though, didn't know alternatives existed.
Now, the picture got a little bit clearer, thank you :)
Hopefully I am going to get this program to run, today. :-/
After re-reading part of the porters handbook I now know that REIMPLACE_CMD stands for sed in Make.
 
I often use the | (pipe) character: s|something|somewhere|, I like how it clearly shows the separation.
I read about it roughly 15 minutes ago in chapter 4 of porters handbook. :D
For example:
Code:
's,https://profile.yuzu-emu.org/,,g'
can be rewritten as
Code:
's|https://profile.yuzu-emu.org/||g'
and means, replace "https://profile.yuzu-emu.org" with blank " ", a blank space ?

One last question I have is, what does ELFCTL do in this context ?
Code:
post-install:
.if exists(/usr/bin/elfctl)
    ${ELFCTL} -e +wxneeded ${STAGEDIR}${PREFIX}/bin/*
.endif
 
I made progress, but I have one problem which occurred during build.
I want to get rid of QT5 completely, and use QT6 only, because full QT6 support was added into the emulator.
Here is my edited torzu make file:
Code:
PORTNAME= torzu
DISTVERSION= 1.0-0 
PORTREVISION= 0
CATEGORIES= emulators

MASTER_SITES= https://notabug.org/litucks/${PORTNAME}/archive/master.tar.gz

MAINTAINER= sdk-chan@protonmail.com
COMMENT= Nintendo Switch emulator/debugger
WWW= https://notabug.org/litucks/torzu/src/master/README.md

WRKSRC=    ${WRKDIR}/${PORTNAME}
LICENSE= APACHE20 BSD3CLAUSE GPLv3+ ISCL MIT UNLICENSE
LICENSE_COMB= multi
LICENSE_FILE_BSD3CLAUSE= ${WRKSRC}/externals/sirit/LICENSE.txt
LICENSE_FILE_GPLv3+ = ${WRKSRC}/LICENSE.txt
LICENSE_FILE_ISCL= ${WRKSRC}/externals/cubeb/LICENSE
LICENSE_FILE_MIT= ${WRKSRC}/externals/sirit/externals/SPIRV-Headers/LICENSE

ONLY_FOR_ARCHS=    aarch64 amd64
ONLY_FOR_ARCHS_REASON= requires int128 and dynarmic backend

BUILD_DEPENDS= boost-libs>0:devel/boost-libs \
               nlohmann-json>0:devel/nlohmann-json \
               simpleini>0:devel/simpleini \
               xbyak>0:devel/xbyak \
               glslangValidator:graphics/glslang \
               vulkan-headers>0:graphics/vulkan-headers \
               vulkan-utility-libraries>0:graphics/vulkan-utility-libraries

LIB_DEPENDS= liblz4.so:archivers/liblz4 \
             libzstd.so:archivers/zstd \
             libopus.so:audio/opus \
             libfmt.so:devel/libfmt \
             libavcodec.so:multimedia/ffmpeg \
             libenet.so:net/enet

TEST_DEPENDS= catch2>0:devel/catch2

DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
USE_GITHUB=    nodefault
GH_TUPLE= GPUOpen-LibrariesAndSDKs:VulkanMemoryAllocator:v3.0.1-114-g2f382df:VulkanMemoryAllocator/externals/VulkanMemoryAllocator \
          KhronosGroup:SPIRV-Headers:1.5.4.raytracing.fixed-201-gc214f6f:SPIRV_Headers/externals/sirit/externals/SPIRV-Headers \
          merryhime:oaknut:2.0.1:oaknut/externals/oaknut \
          arun11299:cpp-jwt:v1.4-18-g10ef573:cpp_jwt/externals/cpp-jwt \
          arsenm:sanitizers-cmake:aab6948:sanitizers_cmake/externals/cubeb/cmake/sanitizers-cmake \
          eggert:tz:2022g-11-g16ce126a:tz/externals/nx_tzdb/tzdb_to_nx/externals/tz/tz \
          kinetiknz:cubeb:cubeb-0.2-1452-g48689ae:cubeb/externals/cubeb \
          lat9nq:tzdb_to_nx:221202-15-g9792969:tzdb_to_nx/externals/nx_tzdb/tzdb_to_nx \
          yhirose:cpp-httplib:v0.14.1:cpp_httplib/externals/cpp-httplib

USES= cmake:testing qt:6 pkgconfig sdl ssl
USE_SDL= sdl2
USE_QT= base qmake_build buildtools_build concurrent_build dbus gui multimedia widgets
QT_CMAKE_BOOL= ENABLE_QT
QT6_USES= desktop-file-utils shared-mime-info
QT6_PLIST_FILES= bin/${PORTNAME} \
                 share/applications/org.yuzu_emu.yuzu.desktop \
                 share/icons/hicolor/scalable/apps/org.yuzu_emu.yuzu.svg \
                 share/metainfo/org.yuzu_emu.yuzu.metainfo.xml \
                 share/mime/packages/org.yuzu_emu.yuzu.xml

JACK_BUILD_DEPENDS=    jackit>0:audio/jack
JACK_CMAKE_BOOL= USE_JACK

LTO_CMAKE_BOOL= YUZU_ENABLE_LTO

NLS_DESC= UI translations (implies ${NLS_IMPLIES})
NLS_USE= QT=${"${PORT_OPTIONS:MQT6}":?linguist:}tools:build
NLS_CMAKE_BOOL=    ENABLE_QT_TRANSLATION
NLS_IMPLIES= QT6

PULSEAUDIO_BUILD_DEPENDS=pulseaudio>0:audio/pulseaudio
PULSEAUDIO_CMAKE_BOOL=    USE_PULSE

SNDIO_BUILD_DEPENDS=    sndio>0:audio/sndio
SNDIO_CMAKE_BOOL=    USE_SNDIO

VAAPI_LIB_DEPENDS=    libva.so:multimedia/libva

VULKAN_DESC=        Vulkan renderer
VULKAN_RUN_DEPENDS=    ${LOCALBASE}/lib/libvulkan.so:graphics/vulkan-loader

WEBENGINE_DESC=        Web applet support (implies ${WEBENGINE_IMPLIES})
WEBENGINE_USE=        QT=webengine
WEBENGINE_CMAKE_BOOL=    YUZU_USE_QT_WEB_ENGINE
WEBENGINE_IMPLIES=    QT6

CMAKE_ON= Boost_USE_STATIC_LIBS
CMAKE_ON+= BUNDLE_SPEEX # only used by cubeb tests
CMAKE_ON+= CMAKE_DISABLE_FIND_PACKAGE_LLVM # only need Demangle but llvm* is huge
CMAKE_OFF= YUZU_CHECK_SUBMODULES YUZU_USE_EXTERNAL_SDL2
CMAKE_OFF+=    YUZU_USE_EXTERNAL_VULKAN_HEADERS YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES
CMAKE_OFF+=    HTTPLIB_USE_BROTLI_IF_AVAILABLE # unused by ENABLE_WEB_SERVICE
CMAKE_OFF+=    ${ARCH:Maarch64:C/.+/YUZU_USE_PRECOMPILED_HEADERS DYNARMIC_USE_PRECOMPILED_HEADERS/}
CMAKE_OFF+=    ${CMAKE_TESTING_ON}
CMAKE_TESTING_ON= YUZU_TESTS
PLIST_FILES= bin/${PORTNAME}-cmd \
             bin/${PORTNAME}-room

OPTIONS_DEFINE=    ALSA QT6 PULSEAUDIO JACK LTO NLS SNDIO VAAPI VULKAN WEBENGINE
OPTIONS_DEFAULT= PULSEAUDIO JACK LTO QT6 SNDIO VAAPI VULKAN WEBENGINE

ALSA_BUILD_DEPENDS=    alsa-lib>0:audio/alsa-lib
ALSA_CMAKE_BOOL=    USE_ALSA

post-patch:
    # https://github.com/ConsoleKit2/ConsoleKit2/issues/150
    @${REINPLACE_CMD} -e 's|/login1|/ConsoleKit/Manager|' \
        -e 's|login1|ConsoleKit|' \
        ${WRKSRC}/src/${PORTNAME}/main.cpp

post-patch-VAAPI-off:
    @${REINPLACE_CMD} -i .nova '/pkg_check.*libva/d' \
        ${WRKSRC}/CMakeLists.txt

post-install:
.if exists(/usr/bin/elfctl)
    ${ELFCTL} -e +wxneeded ${STAGEDIR}${PREFIX}/bin/*
.endif

.include <bsd.port.mk>
It is ugly, and needs formatting.
I will do that after this program works, before submitting the port.
I can set the options for the port and its dependencies, no problem on that side.
The problem I have is:
Code:
[00:00:02] Ignoring emulators/torzu | torzu-1.0.0: cannot be installed: unknown USE_QT component 'widgets'
Strange...
Chapter 6.13.2 Component selection states I can use USE_QT= widgets, if I am not mistaking. :-/
Reference from the Yuzu Makefile:
Code:
QT5_USE=        QT=qmake:build,buildtools:build,concurrent:build,core,dbus,gui,multimedia,widgets

EDIT:
Next error after removing widgets from the list.
Code:
[00:00:02] Ignoring emulators/torzu | torzu-1.0.0: cannot be installed: unknown USE_QT component 'qmake_build'
 
.....
It builds.
I managed to get to fix the QT errors, now I hope it will work, once build. :D
The boost patch failed...
I need to investigate further, I guess.
The structure is completely messed up in torzu.
The patch problem is now more or less solved.
Why not just stay consistent with yuzu or torzu, instead of doing a mix...
I guess, I will need to clean up and fix this inconsistency, or poudriere is going to complain about not finding files... 😅
Since Torzu is the new Yuzu I will stay with the name Torzu, I guess.

Yuzu patches need some editing eventually, since they don't apply to 100%, but that was expected.
Looking at the structure, I am going to fix it up, and then fork it or else, everyone wanting to use that port is going to have building nightmares 😅

Interesting, although QT5 is not strictly needed, torzus CMAKE components depend on it...
I guess I am going to re-edit my Makefile adding JBeichs flavor options for QT5 to solve the CMAKE problems.
 
Torzu itself doesn't fail at the configuration stage anymore, issuing me not finding QT.
Some changes to CMakeList.txt after all solved the configuration part.
Hopefully it will complete the build without problems, and execute properly... :D
Until now it was very hard, because I literally don't know any CMake, and changed things because I had the feeling, I am going into the right direction...
Well, I can only pray now...
Theoretically it should work now, practically, who knows.

It still doesn't work.
I need to rename all yuzu instances to torzu, according to poudriere logs file...
What a mess.
 
Really ???
The torzu team really is a group of geniuses.
Using dual naming in a project is always a great source of failure.
I am in the last stage now.
Poudriere fails to package torzu, and here is poudrieres torzu log:
Code:
===>  Staging for torzu-1.0.0
===>   Generating temporary packing list
[  0% 1/1] cd /wrkdirs/usr/ports/emulators/torzu/work/.build && /usr/local/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
-- Install configuration: "Release"
-- Installing: /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/bin/yuzu-room
-- Installing: /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/bin/yuzu-cmd
-- Installing: /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/bin/yuzu
-- Set non-toolchain portion of runtime path of "/wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/bin/yuzu" to "/usr/local/lib/qt6"
-- Installing: /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/share/applications/onion.torzu_emu.torzu.desktop
-- Installing: /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/share/icons/hicolor/scalable/apps/onion.torzu_emu.torzu.svg
-- Installing: /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/share/mime/packages/onion.torzu_emu.torzu.xml
-- Installing: /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/share/metainfo/onion.torzu_emu.torzu.metainfo.xml
elfctl -e +wxneeded /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/bin/*

====> Compressing man pages (compress-man)
===========================================================================
=======================<phase: package        >============================
===== env: 'PKG_NOTES=build_timestamp ports_top_git_hash ports_top_checkout_unclean port_git_hash port_checkout_unclean built_by' 'PKG_NOTE_build_timestamp=2025-04-18T21:50:57+0000' 'PKG_NOTE_ports_top_git_hash=1e5fab34e' 'PKG_NOTE_ports_top_checkout_unclean=no' 'PKG_NOTE_port_git_hash=' 'PKG_NOTE_port_checkout_unclean=no' 'PKG_NOTE_built_by=poudriere-git-3.4.2' NO_DEPENDS=yes USER=root UID=0 GID=0
===>  Building packages for torzu-1.0.0
===>   Building torzu-1.0.0
pkg-static: Unable to access file /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/bin/torzu-cmd:No such file or directory
pkg-static: Unable to access file /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/bin/torzu-room:No such file or directory
pkg-static: Unable to access file /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/bin/torzu:No such file or directory
pkg-static: Unable to access file /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/share/applications/org.yuzu_emu.yuzu.desktop:No such file or directory
pkg-static: Unable to access file /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/share/icons/hicolor/scalable/apps/org.yuzu_emu.yuzu.svg:No such file or directory
pkg-static: Unable to access file /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/share/metainfo/org.yuzu_emu.yuzu.metainfo.xml:No such file or directory
pkg-static: Unable to access file /wrkdirs/usr/ports/emulators/torzu/work/stage/usr/local/share/mime/packages/org.yuzu_emu.yuzu.xml:No such file or directory
*** Error code 1

The problem is torzu tries to install yuzu-binaries, why ?, I guess the new developers behind the project could be asked about the weird dual naming scheme.
Poudriere doesn't seem to like dual naming so, my question is, which file or files in a project are responsible for assigning names to binaries ?

I am going to fork that project, to avoid weird dual naming schemes.
The functionality of torzu is great, but yuzu certainly needs to be renamed to torzu everywhere to avoid strange conflicts.
 
Torzu builds correctly now, and runs.
I am going to try out sudachi since, it is cleaner from the code, and back in the game again.
Then I am going to submit the new yuzu alternative.
 
Back
Top