Warning: there may be occasional oddness due to css and blog edits. **KNOWN ISSUE: possible hidden text**

Sunday, September 3, 2023

Revised minetest-dev: fonts!

Anyone watching my git repo for minetest-dev or any of the others will know that I have expanded a bit on what I attempt to maintain in a reasonably timely manner.  Not too long ago, during a period when my FreeBSD install was functioning without hiccups, I eventually figured out another improvement to the minetest-dev Makefile.  I also have done a little cleanup for the options exposed to those who wish to install it.

Something I have wanted to do but hadn't the motivation or free time simultaneously is to have a way for the fonts installed on the system to be used by minetest, instead of duplicating them.  The solution I worked out is definitely not the best and actually begs upstream developers to include a proper mechanism to do this properly.  I understand that the minetest client should be guaranteed to have fonts it expects but without a mechanism within its build structure or configuration, we are stuck with a duplication of files for no real purpose.

minetest-dev:

PORTNAME=       minetest
DISTVERSION=    g20230902
CATEGORIES=     games
PKGNAMESUFFIX=  -dev
DISTNAME=       ${PORTNAME}-${GH_TAGNAME}
DIST_SUBDIR=    ${PORTNAME}${PKGNAMESUFFIX}

MAINTAINER=     nope@nothere
COMMENT=        Near-infinite-world block sandbox game
WWW=            https://www.minetest.net/

LICENSE=        LGPL21+

LIB_DEPENDS=    libIrrlichtMt.so:x11-toolkits/irrlicht-minetest libzstd.so:archivers/zstd

USES=           cmake compiler:c++14-lang iconv:wchar_t sqlite luajit
# Upstream requires Clang 3.5+ which for our criteria matches c++14-lang
# since https://en.cppreference.com/w/cpp/compiler_support
# lists "C++14 library support status (complete as of 3.5)"
# All other dependency version numbers are more direct and obvious, and surpass requirement.

CONFLICTS=      minetest

USE_GITHUB=     nodefault
GH_ACCOUNT=     minetest
GH_PROJECT=     minetest
GH_TAGNAME=     83b85ba16aaab7bddc479beada4ca3af9fa54a1b

CMAKE_ARGS=     -DCMAKE_BUILD_TYPE="MinSizeRel" \
                -DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \
                -DCUSTOM_MANDIR="${PREFIX}/man"

WRKSRC=         ${WRKDIR}/${PORTNAME}-${GH_TAGNAME}

OPTIONS_DEFINE=                 CURL DOCS FREETYPE LUAJIT NCURSES NLS SOUND SPATIAL TOUCH PROMETHEUS
OPTIONS_DEFAULT=                CURL DOCS FREETYPE LUAJIT SOUND SPATIAL SYSTEM_FONTS SYSTEM_GMP SYSTEM_JSONCPP CLIENT GLVND

OPTIONS_SINGLE=                 GRAPHICS
OPTIONS_MULTI=                  SYSTEM COMP
OPTIONS_GROUP=                  BUILD DATABASE

COMP_DESC=                      Software components
OPTIONS_MULTI_COMP=             CLIENT SERVER

SYSTEM_DESC=                    System subsitutes
OPTIONS_MULTI_SYSTEM=           SYSTEM_GMP SYSTEM_JSONCPP SYSTEM_FONTS

SYSTEM_GMP_DESC=                Use gmp from ports (ENABLE_SYSTEM_GMP)
SYSTEM_GMP_CMAKE_BOOL=          ENABLE_SYSTEM_GMP
SYSTEM_GMP_CMAKE_ON=            -DGMP_INCLUDE_DIR="${PREFIX}/include"
SYSTEM_GMP_LIB_DEPENDS=         libgmp.so:math/gmp

SYSTEM_JSONCPP_DESC=            Use jsoncpp from ports (ENABLE_SYSTEM_JSONCPP)
SYSTEM_JSONCPP_CMAKE_BOOL=      ENABLE_SYSTEM_JSONCPP
SYSTEM_JSONCPP_CMAKE_ON=        -DJSON_INCLUDE_DIR="${PREFIX}/include/jsoncpp"
SYSTEM_JSONCPP_LIB_DEPENDS=     libjsoncpp.so:devel/jsoncpp

SYSTEM_FONTS_DESC=              Use or install default fonts from ports
SYSTEM_FONTS_RUN_DEPENDS=       ${LOCALBASE}/share/fonts/ChromeOS/Arimo-Bold.ttf:x11-fonts/croscorefonts-fonts-ttf \
                                ${LOCALBASE}/share/fonts/Droid/DroidSans.ttf:x11-fonts/droid-fonts-ttf

BUILD_DESC=                     Dev Build options
OPTIONS_GROUP_BUILD=            BENCHMARKS EXAMPLES UNITTESTS DEVTEST

BENCHMARKS_DESC=                Build benchmark sources (BUILD_BENCHMARKS)
BENCHMARKS_CMAKE_BOOL=          BUILD_BENCHMARKS
EXAMPLES_DESC=                  BUILD_EXAMPLES
EXAMPLES_CMAKE_BOOL=            BUILD_EXAMPLES
DEVTEST_DESC=                   Install Development Test game also (INSTALL_DEVTEST)
DEVTEST_CMAKE_BOOL=             INSTALL_DEVTEST
UNITTESTS_DESC=                 Build unittest sources (BUILD_UNITTESTS)
UNITTESTS_CMAKE_BOOL=           BUILD_UNITTESTS

OPTIONS_SINGLE_GRAPHICS=        GLVND LEGACY
GRAPHICS_DESC=                  Graphics support

GLVND_DESC=                     Use libOpenGL or libGLX
GLVND_CMAKE_BOOL=               ENABLE_GLVND
GLVND_CMAKE_ON=                 -DOPENGL_GL_PREFERENCE="GLVND" -DOPENGL_xmesa_INCLUDE_DIR="${PREFIX}/lib"
GLVND_USE=                      GL+=opengl

LEGACY_DESC=                    Use libGL - where GLVND may be broken on nvidia
LEGACY_CMAKE_BOOL=              ENABLE_LEGACY
LEGACY_CMAKE_ON=                -DOPENGL_GL_PREFERENCE="LEGACY" -DOPENGL_xmesa_INCLUDE_DIR="${PREFIX}/lib"
LEGACY_USE=                     GL+=opengl

DATABASE_DESC=                  Database support
OPTIONS_GROUP_DATABASE=         LEVELDB PGSQL REDIS

OPTIONS_SUB=                    yes

CLIENT_DESC=                    Build client
CLIENT_CMAKE_BOOL=              BUILD_CLIENT
CLIENT_LIB_DEPENDS=             libIrrlichtMt.so:x11-toolkits/irrlicht-minetest \
                                libpng.so:graphics/png

CLIENT_USES=                    gl xorg
CLIENT_USE=                     jpeg GL=gl,glu \
                                XORG=ice,sm,x11,xext,xcb,xres,xshmfence,xau,xaw,xcomposite,xcursor,xdamage,xdmcp,\
                                xfixes,xft,xi,xinerama,xkbfile,xmu,xpm,xrandr,xrender,xscreensaver,xt,xtst,xv,xxf86vm

SERVER_DESC=                    Build server
SERVER_CMAKE_BOOL=              BUILD_SERVER

CURL_DESC=                      Enable cURL support for fetching media
CURL_CMAKE_BOOL=                ENABLE_CURL
CURL_LIB_DEPENDS=               libcurl.so:ftp/curl

SOUND_DESC=                     Enable sound via openal-soft
SOUND_CMAKE_BOOL=               ENABLE_SOUND

FREETYPE_DESC=                  Support for TrueType fonts with unicode
FREETYPE_CMAKE_BOOL=            ENABLE_FREETYPE
FREETYPE_LIB_DEPENDS=           libfreetype.so:print/freetype2

NCURSES_DESC=                   Enables server side terminal (cli option: --terminal)
NCURSES_CMAKE_BOOL=             ENABLE_CURSES
NCURSES_USES=                   ncurses

# This option is becoming uncertain, though it does something, is it useful?
LUAJIT_DESC=                    Require LUAJIT (always enabled)
LUAJIT_CMAKE_BOOL_ON=           REQUIRE_LUAJIT
LUAJIT_CMAKE_BOOL_OFF=          ENABLE_LUAJIT

LEVELDB_DESC=                   Enable LevelDB backend
LEVELDB_CMAKE_BOOL=             ENABLE_LEVELDB
LEVELDB_LIB_DEPENDS=            libleveldb.so:databases/leveldb

PGSQL_DESC=                     Enable PostgreSQL map backend
PGSQL_USES=                     pgsql
PGSQL_CMAKE_BOOL=               ENABLE_POSTGRESQL

REDIS_DESC=                     Enable Redis backend
REDIS_CMAKE_BOOL=               ENABLE_REDIS
REDIS_LIB_DEPENDS=              libhiredis.so:databases/hiredis

SPATIAL_DESC=                   Enable SpatialIndex (Speeds up AreaStores)
SPATIAL_LIB_DEPENDS=            libspatialindex.so:devel/spatialindex
SPATIAL_CMAKE_BOOL=             ENABLE_SPATIAL

NLS_DESC=                       Native Language Support (ENABLE_GETTEXT)
NLS_CMAKE_BOOL=                 ENABLE_GETTEXT
NLS_USES=                       gettext
NLS_LDFLAGS=                    -L${LOCALBASE}/lib

TOUCH_DESC=                     Build with touch interface support
TOUCH_CMAKE_BOOL=               ENABLE_TOUCH
# dependency?

PROMETHEUS_DESC=                Build with Prometheus metrics exporter
PROMETHEUS_CMAKE_BOOL=          ENABLE_PROMETHEUS
# dependency?

.include 

.if ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSOUND}
USES+=                  openal
LIB_DEPENDS+=           libogg.so:audio/libogg \
                        libvorbis.so:audio/libvorbis \
                        libvorbisfile.so:audio/libvorbis
.endif

.if ${PORT_OPTIONS:MSERVER}
#USE_RC_SUBR=   ${PORTNAME}
#USERS=         ${PORTNAME}
#GROUPS=        ${PORTNAME}
#USE_RC_SUBR=           minetest/ERX
USE_RC_SUBR=            minetest
USERS=                  minetest
GROUPS=                 minetest
.endif

# Exactly why this must be done this way eludes me but this works and satisfies the install needs.
.if ${PORT_OPTIONS:MSYSTEM_FONTS}
pre-install:
        ${MKDIR} ${LOCALBASE}/share/minetest/fonts
        ${RM} ${LOCALBASE}/share/minetest/fonts/Arimo-Bold.ttf
        ${RM} ${LOCALBASE}/share/minetest/fonts/Arimo-BoldItalic.ttf
        ${RM} ${LOCALBASE}/share/minetest/fonts/Arimo-Italic.ttf
        ${RM} ${LOCALBASE}/share/minetest/fonts/Cousine-Bold.ttf
        ${RM} ${LOCALBASE}/share/minetest/fonts/Cousine-BoldItalic.ttf
        ${RM} ${LOCALBASE}/share/minetest/fonts/Cousine-Italic.ttf
        ${RM} ${LOCALBASE}/share/minetest/fonts/Cousine-Regular.ttf
        ${RM} ${LOCALBASE}/share/minetest/fonts/DroidSansFallbackFull.ttf
        ${MKDIR} ${LOCALBASE}/share/minetest/fonts
        ${LN} -s ${LOCALBASE}/share/fonts/ChromeOS/Arimo-Bold.ttf ${LOCALBASE}/share/minetest/fonts/Arimo-Bold.ttf
        ${LN} -s ${LOCALBASE}/share/fonts/ChromeOS/Arimo-BoldItalic.ttf ${LOCALBASE}/share/minetest/fonts/Arimo-BoldItalic.ttf
        ${LN} -s ${LOCALBASE}/share/fonts/ChromeOS/Arimo-Italic.ttf ${LOCALBASE}/share/minetest/fonts/Arimo-Italic.ttf
        ${LN} -s ${LOCALBASE}/share/fonts/ChromeOS/Cousine-Bold.ttf ${LOCALBASE}/share/minetest/fonts/Cousine-Bold.ttf
        ${LN} -s ${LOCALBASE}/share/fonts/ChromeOS/Cousine-BoldItalic.ttf ${LOCALBASE}/share/minetest/fonts/Cousine-BoldItalic.ttf
        ${LN} -s ${LOCALBASE}/share/fonts/ChromeOS/Cousine-Italic.ttf ${LOCALBASE}/share/minetest/fonts/Cousine-Italic.ttf
        ${LN} -s ${LOCALBASE}/share/fonts/ChromeOS/Cousine-Regular.ttf ${LOCALBASE}/share/minetest/fonts/Cousine-Regular.ttf
        ${LN} -s ${LOCALBASE}/share/fonts/Droid/DroidSansFallbackFull.ttf ${LOCALBASE}/share/minetest/fonts/DroidSansFallbackFull.ttf
.endif

post-install:
        @${ECHO_MSG} " "
        @${ECHO_MSG} "-->  "${PREFIX}/etc/"minetest.conf.example explains options and gives their default values. "
        @${ECHO_MSG} " "
        @${ECHO_MSG} "-->  Local network issues could cause singleplayer to fail. "
        @${ECHO_MSG} " "
        @${ECHO_MSG} "-->  Alternate graphics driver may be set in client config, must be set to get used."
        @${ECHO_MSG} " "
        @${ECHO_MSG} " "

# hacky way to not bring irrlicht and X11 depends for server only
#.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}
#BROKEN= server only hack fails for irrlicht fork
#.endif
# From wiki:
#  Building without Irrlicht / X dependency
# You can build the Minetest server without library dependencies to Irrlicht or any graphical stuff.
# You still need the Irrlicht headers for this, so first, download the irrlicht source to somewhere.
#
# When invoking CMake, use -DBUILD_CLIENT=0 -DIRRLICHT_SOURCE_DIR=/wherever/you/unzipped/the/source.

#----------------------------------------------------------------------
#
# Strangely network issues can prevent singleplayer from functioning.
# GCC           7.5+    or Clang 6.0+
# CMake         3.5+
# IrrlichtMt    -       Custom version of Irrlicht, see https://github.com/minetest/irrlicht
# Freetype      2.0+
# SQLite3       3+
# Zstd          1.0+
# LuaJIT        2.0+    Bundled Lua 5.1 is used if not present
# GMP           5.0.0+  Bundled mini-GMP is used if not present
# JsonCPP       1.0.0+  Bundled JsonCPP is used if not present
# Curl          7.56.0+ Optional
# gettext       -       Optional
#----------------------------------------------------------------------
.include 

The post-install message is there for information which I believe an official port wouldn't even place within a pkg-message file, and why must I bother with another file if this remains the same much of the time. It would be one more file to track and possibly update.

Once more: I am not an official port maintainer of official ports, and although I may have based my initial Makefiles upon prior works, these are different, unique, and likely never to be annointed in their format or style or technique.  Use them as you choose, the risk is yours regardless of whether they seem safe and effective on my system, caveat emptor for both and all.  I will attempt to keep both updated nearly as frequently as I discover new commits.

Repo urls:

Maintaining these unofficial ports [tree leaf contents files] is an enjoyable hobby which ensures that I also have the very most current software.  The process to do this officially or not is not particularly difficult but it can certainly be a challenge.  I have yet to completely beat dbeaver into utter submission, but the datestamp solution is less than obvious even with a partial answer I am uncertain how to adapt it.  You will never know how you could succeed if you never attempt it.  If there is ANYTHING out there in the Linux world which you want to have for yourself, you can try to port it.  Read the porter's handbook, my own blog posts relate my experiences.

No comments:

Post a Comment

Thank you for your interest!

Frequently viewed this week