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

Monday, April 5, 2021

Getting minetest-dev built

Here I go again.  I had recently finished making a substantial revision to the minetest makefile and I wrote about it in a blog post which I updated a short time ago.  I decided to attempt to make the unreleased development version of minetest buildable on my system.  The added wrinkle with this is that the minetest developers decided to fork irrlicht in order to have it work better with minetest.  So you may conclude that I now have two ports to successfully build.

Starting with my own rococo Makefile in a new port directory, games/minetest-dev, I worked at attempting to get the source and have the build succeed.  It took a bit of time to manipulate the Makefile for this unique situation which technically has no source tarball, though the master branch can be downloaded as a .zip file.  I could have used the github shortcut option in my Makefile but at least initially the arrangement is unique and not quite as described in the porter's handbook.

After a while, I finally was able to get the .zip file, unpack it and begin to build which stopped at the point that it discovered irrlicht on my system was not the forked version it needed.  This meant that I needed to begin my efforts on getting the irrlicht fork to build.  Similarly to my build of minetest-dev, I began with the irrlicht port that already exists in the tree by copying it all to another directory, x11-toolkits/irrlicht-minetest. It didn't take long to discover that it seemed as though this fork was built differently than the original irrlicht port which makes some sense as it is being modified by other developers and we all know different developers often prefer different tools.

As I am nearly finished with the irrlichtMt port except for installation, I now need to generate a package list for it.  This is one step I have not done often enough to remember it, like I can for make makesum so I have to look up what it is, a successful search confirms that it is make makeplist > pkg-plist but of course I will need to look over the generated file and edit out the top line.  While I had believed I was nearly finished, in fact my Makefile still had some flaws.  My solution was to simplify it by commenting out some lines until I finally happened upon the right combination which permitted me a successful build.  Once that was accomplished I could make the pkg-plist, edit it to remove the top line and call it done for now.

Back to the games/minetest-dev port to see if an install of irrlichtMt is found by it and then it will progress further in its build, hopefully to completion.  It seemed to build fine but failed on install I believe due to an old pkg-plist and the mechanism attempting to honor it.  Another clean build without that file so I can re-create it should solve this small issue.  It turns out that was not the issue, but my removal of the files directory which is usually used for patches, but also had something named minetest.in that was needed though how it is identified as a requirement I do not know.  I just copied the file from the minetest game port.  The remaining error messages seem to be caused by the lack of pkg-plist file but as the build was otherwaise successful, it was easily created.  Of course, after all of this, I get the last inescapable complaint, that this version of minetest conflicts with the minetest game already installed.

This was a rather pleasant experience even though there were moments when I was confused as to how to solve an issue with either port.  I can count these as my first successful ported software with mostly proper Makefiles and procedures, even if I had a bit of a head start with already existing Makefiles.  The main things which cause them to be less than proper is that I do not use any version numbers for distfiles as both are very generic .zip files direct from github.  If I discover how to solve that, or in the near future when the minetest project has cut a release for either of them, that issue can be solved.  Another minetest developer (of mods primarily) warned me that this dev version is somewhat of a mess, but I just installed it and have tested by playing the same minetest server games online which I usually do, and it seemed fine.  Maybe an earlier version was not as good but maybe I happened to grab a zip file of a coherent version that works, at least on FreeBSD.

For those who are curious, the two initially sucessful Makefiles are found at the repo links while more accurate (more recent) and complete ones are below.  I have realized that one way to maintain these port directories is to use a symbolic link into the ports tree for each of them if necessary while the actual content can reside on another account home directory in its own directory appropriately named (Ported_Software) containing them and any future port I manage to accomplish.  I chose to re-create the necessary subset of the ports tree, meaning that I made both hierarchies Ported_Software/x11-toolkits/irrlicht-minetest and Ported_Software/games/minetest-dev which will be easier to handle than any other variation and will be very much less cluttered until I make a very substantial number of ports.

minetest-dev:

PORTNAME=	minetest
DISTVERSION=	g20210612
CATEGORIES=	games
PKGNAMESUFFIX=	-dev
DISTNAME=	master
DIST_SUBDIR=	${PORTNAME}${PKGNAMESUFFIX}

MAINTAINER=	nope@nothere
COMMENT=	Near-infinite-world block sandbox game

LICENSE=	LGPL21+

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

USES=		cmake compiler:c11 iconv:wchar_t sqlite

CONFLICTS=	minetest

USE_GITHUB=     nodefault
GH_ACCOUNT=     minetest
GH_PROJECT=     minetest
GH_TAGNAME=	dc165fe942bcc48d7dea0a7b722886937d9c6914

CMAKE_ARGS=	-DBUILD_UNITTESTS="FALSE" \
		-DCMAKE_BUILD_TYPE="MinSizeRel" \
		-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \
		-DCUSTOM_MANDIR="${PREFIX}/man"
WRKSRC=	${WRKDIR}/minetest-${GH_TAGNAME}

LDFLAGS_i386=	-Wl,-znotext

#PORTDATA=	*
#PORTDOCS=	*

OPTIONS_DEFINE=	CURL DOCS EXAMPLES FREETYPE GLES LUAJIT NCURSES NLS SOUND SYSTEM_GMP \
		SYSTEM_JSONCPP PROMETHEUS
OPTIONS_MULTI=	COMP
OPTIONS_RADIO=	GRAPHICS
OPTIONS_GROUP=	DATABASE

COMP_DESC=		Software components
OPTIONS_MULTI_COMP=	CLIENT SERVER

OPTIONS_RADIO_GRAPHICS=	GLVND LEGACY

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

GRAPHICS_DESC=			Graphics support
GLVND_DESC=			Use libOpenGL or libGLX
LEGACY_DESC=			Use libGL - where GLVND may be broken on nvidia
GLES_DESC=			Use libOpenGLES instead of libOpenGL

GLVND_CMAKE_ON=			-DOPENGL_GL_PREFERENCE="GLVND"
LEGACY_CMAKE_ON=		-DOPENGL_GL_PREFERENCE="LEGACY"
GLES_CMAKE_BOOL=		ENABLE_GLES

DATABASE_DESC=			Database support
OPTIONS_GROUP_DATABASE=		LEVELDB REDIS SPATIAL
#OPTIONS_GROUP_DATABASE=	LEVELDB PGSQL REDIS SPATIAL

OPTIONS_DEFAULT=		CLIENT CURL DOCS FREETYPE GLVND LUAJIT NCURSES SOUND \
				SYSTEM_GMP SYSTEM_JSONCPP
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 jpeg xorg
CLIENT_USE=			GL=gl,glu \
				XORG=ice,sm,x11,xext,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=			Enable ncurses console
NCURSES_CMAKE_BOOL=		ENABLE_CURSES
NCURSES_USES=			ncurses

LUAJIT_DESC=			LuaJIT support (lang/luajit-openresty)
LUAJIT_CMAKE_BOOL=		ENABLE_LUAJIT REQUIRE_LUAJIT
LUAJIT_LIB_DEPENDS=		libluajit-5.1.so:lang/luajit-openresty

PGSQL_USES=			pgsql
PGSQL_CMAKE_BOOL=		ENABLE_POSTGRESQL
#PGSQL_LIB_DEPENDS=		libsqlite3.so:databases/sqlite3  # probable depend - check when this pgsql builds
LEVELDB_DESC=			Enable LevelDB backend
LEVELDB_CMAKE_BOOL=		ENABLE_LEVELDB
LEVELDB_LIB_DEPENDS=		libleveldb.so:databases/leveldb
REDIS_DESC=			Enable Redis backend
REDIS_CMAKE_BOOL=		ENABLE_REDIS
REDIS_LIB_DEPENDS=		libhiredis.so:databases/hiredis
SPATIAL_DESC=			Enable SpatialIndex AreaStore backend
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

PROMETHEUS_DESC=		Build with Prometheus metrics exporter
PROMETHEUS_CMAKE_BOOL=		ENABLE_PROMETHEUS
#PROMETHEUS_USES=		gettext

.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
USERS=		minetest
GROUPS=		minetest
.endif

# 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.

#post-patch:
#	@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' \
#		${WRKSRC}/cmake/Modules/*.cmake

.include 

irrlichtMt:

PORTNAME=	irrlichtMt
DISTVERSION=	g20210524
CATEGORIES=	x11-toolkits graphics
DISTNAME=	master
DIST_SUBDIR=	${PORTNAME}

MAINTAINER=	nope@nothere
COMMENT=	High performance realtime 3D engine - minetest fork

LICENSE=	ZLIB

LIB_DEPENDS=	libpng.so:graphics/png

USES=		alias cmake compiler:c11 dos2unix jpeg gl xorg

DOS2UNIX_GLOB=	*.cpp *.h *.txt Makefile

USE_GITHUB=	nodefault
GH_ACCOUNT=	minetest
GH_PROJECT=	irrlicht
GH_TAGNAME=	393793f28afa15641533f687f3a242e32a052fbc

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

USE_GL=		gl glu
USE_XORG=	x11 xxf86vm
USE_LDCONFIG=	yes

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

#OPTIONS_DEFINE= EXAMPLES

#EXAMPLES_CMAKE_BOOL=	BUILD_EXAMPLES
#Provided in directory below, right after make (prior to install), so need more mechanism to build and install them
#x11-toolkits/irrlicht-minetest/work/irrlicht-master/examples

.include 

Playing with the built port a bit more, it seems there are some items in the configuration panels in minetest itself which may lead to a crash, but other than fiddling with any of those I do not see any major issues.  The executable also seems to be smaller than the former minetest even with the same options ticked, so either those options do nothing in the dev version or a bit of bloat was removed.  One other thing, after I had to rebuild both due to moving these dev port directories into my home, and a minor issue with gitup caused by branch names on github, I found that a few details were not as perfected.  The CMAKE_SOURCE_PATH=${WRKDIR}/irrlicht-master or WRKSRC=${WRKDIR}/irrlicht-master lines needed to be added after too much trial-and-error and documentation chasing.  I also realized that there are conditional lines in any pkg-plist which relate to the options of the Makefile.  Any lines which have %%OPTION%% prefix will only be in effect when that OPTION is chosen in the configuration when it is built.  I am fairly certain that aside from the glaring issue of grabbing a master.zip file direct from github, though using wget since it doesn't seem to work automatically with the make process, and then revising the distinfo (make makesum) after, both which still need to be fixed if possible, this endeavor seems to finally actually complete.  Since my philosophy to expose things to the user, which allows them to make their own choices even if bad, and my methods are different than the maintainer, I will keep this Makefile as my own private project.  It may not ever be adopted as is, officially, although anyone might still be able to use it since I am making it available here.

Since all but the automated fetch of distribution source functions pretty well, this is the part I need to iron out.  This is much more of a challenge than it should be.  As usual, documentation gives some vaguely specific examples which of course are not near enough to what I seem to need.  That means there is likely room for improvement in the porter's handbook.  The portlint and portfmt tools are helpful to make a reasonably coherent and consistent Makefile.  I use them at the very least because I have not edited thousands nor constructed my own script for doing so, and do not usually know the exact order of items in the Makefile.  Since both ports need to be obtained similarly, once I solved it for one port I could adapt the same changes to the other one.  As I have finally completed the entire porting of minetest-dev and irrlicht-minetest (irrlichtMt) and created some github repos for them, if you so choose you can try them out as well.

I am not a port maintainer and although I may have based my Makefiles upon prior works, these are different, unique, and likely never to be official 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 I can do no more than suggest caveat emptor for both and all.  I will attempt to keep both updated nearly as frequently as I discover new commits.

Repo urls:

Anyone who tried the minetest-dev Makefile immediately after it was initially provided by my repo may have had a fetch issue.  This, oddly, was caused by the subdirectory for the distinfo file not being named minetest-dev.  This has now been corrected, and updated to the April 5th commit (see the distversion which means github 2021 April 5th), the pkg-plist also adjusted since some tests are now eliminated by upstream it seems.  Please note that until I can figure out some way for those distinfo version strings to be synchronized between minetest-dev and irrlicht-minetest, that if minetest-dev is updated, then you should update irrlichtMt also.

I have just corrected another oversight.  If you had built both ports there should have been no adverse effect, the devel version of minetest would seek and find libIrrlichtMt, but the minetest-dev Makefile had the former libIrrlicht as a dependency and so would not automatically cause it to be built.  The repo has been updated to fix this, the included Makefile has been updated for this blog post.  Future updates to the repo will not be updated here unless to correct any fundamental flaw as has been done previously.  If you wish to view the most current Makefile, please visit the appropriate repo.

Frequently viewed this week