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

Wednesday, March 31, 2021

Minetest better

minetest game example screenshot
Minetest gallery pic

This post has been revisited a couple times but I feel it is in its final form as I chose to continue with the development version instead of worrying about something I cannot control.

October 2020

There is a game in our ports collection which I spent far too many hours playing due to being temporarily out of work (but not jobless) beyond my control beginning mid March 2020.  It gave me something to do, to fill the empty, and I played it from a vanilla ports install.  When I say "vanilla ports install" what I mean is that I did not modify anything about it except for the configuration exposed by the person who ported it to FreeBSD.  This 'vanilla install' became customized when I saw that a newer version was available to the wider gamer community but had not yet been updated for FreeBSD.

I did my best to get it to work but discovered that some of the patches automatically applied did not need to be used, they failed to be applied to the newer version.  This was just the beginning of my tinkering to get minetest to function as well as possible.  I am sure that using a bundled, abbreviated, adequately functional component would be less efficient than to use the full version which may be available from ports.  I discovered this by investigating the various exposed options I could tick to know what they were about, and seeing others described by the Linux devs which were not.

The overview of the change, the left is how it appeared on October 3, 2020 at svnweb.freebsd.org and the right is how the Makefile was on my box then, the changes emphasized with highlighting.

# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>						# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>
# $FreeBSD$											# $FreeBSD$

PORTNAME=	minetest									PORTNAME=	minetest
PORTVERSION=    5.3.0										PORTVERSION=    5.3.0
CATEGORIES=     games										CATEGORIES=     games

MAINTAINER=	amdmi3@FreeB									MAINTAINER=	amdmi3@FreeBSD.org
COMMENT=	Near-infinite-world block sandbox game						COMMENT=	Near-infinite-world block sandbox game

LICENSE=	LGPL21+										LICENSE=	LGPL21+
LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt							LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt

LIB_DEPENDS=	libsqlite3.so:databases/sqlite3 \						LIB_DEPENDS=	libsqlite3.so:databases/sqlite3 \
		libgmp.so:math/gmp				|       					libgmp.so:math/gmp \
								>       					libjsoncpp.so:devel/jsoncpp

USE_GITHUB=	yes										USE_GITHUB=	yes
GH_ACCOUNT=	minetest									GH_ACCOUNT=	minetest

USES=		cmake compiler:c11 iconv:wchar_t						USES=		cmake compiler:c11 iconv:wchar_t
CMAKE_ARGS=	-DCUSTOM_MANDIR="${PREFIX}/man" \						CMAKE_ARGS=	-DCUSTOM_MANDIR="${PREFIX}/man" \
		-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc"	|       					-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \
								>       					-DENABLE_SYSTEM_JSONCPP=ON \
								>       					-DJSON_INCLUDE_DIR=/usr/local/include/json \
								>       					-DCMAKE_BUILD_TYPE=MinSizeRel \
								>       					-DOPENGL_GL_PREFERENCE=LEGACY \
								>       					-DENABLE_SYSTEM_GMP=ON

LDFLAGS_i386=	-Wl,-znotext									LDFLAGS_i386=	-Wl,-znotext

PORTDATA=	*										PORTDATA=	*
PORTDOCS=	*										PORTDOCS=	*

OPTIONS_DEFINE=	CURL SOUND FREETYPE NCURSES LUAJIT \						OPTIONS_DEFINE=	CURL SOUND FREETYPE NCURSES LUAJIT \
		DOCS EXAMPLES NLS										DOCS EXAMPLES NLS
OPTIONS_MULTI=	COMP										OPTIONS_MULTI=	COMP
OPTIONS_GROUP=	DATABASE									OPTIONS_GROUP=	DATABASE

COMP_DESC=		Software components							COMP_DESC=		Software components
OPTIONS_MULTI_COMP=	CLIENT SERVER								OPTIONS_MULTI_COMP=	CLIENT SERVER

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

OPTIONS_DEFAULT=	CLIENT SERVER \								OPTIONS_DEFAULT=	CLIENT SERVER \
			CURL SOUND FREETYPE NCURSES LUAJIT								CURL SOUND FREETYPE NCURSES LUAJIT
OPTIONS_EXCLUDE_powerpc64=	LUAJIT								OPTIONS_EXCLUDE_powerpc64=	LUAJIT
OPTIONS_SUB=		yes									OPTIONS_SUB=		yes

CLIENT_DESC=		Build client								CLIENT_DESC=		Build client
CLIENT_CMAKE_BOOL=	BUILD_CLIENT								CLIENT_CMAKE_BOOL=	BUILD_CLIENT
CLIENT_LIB_DEPENDS=	libpng.so:graphics/png \						CLIENT_LIB_DEPENDS=	libpng.so:graphics/png \
			libIrrlicht.so:x11-toolkits/irrlicht					libIrrlicht.so:x11-toolkits/irrlicht
CLIENT_USES=		gl jpeg xorg								CLIENT_USES=		gl jpeg xorg
CLIENT_USE=		GL=gl XORG=x11,xext,xxf86vm						CLIENT_USE=		GL=gl XORG=x11,xext,xxf86vm
SERVER_DESC=		Build server								SERVER_DESC=		Build server
SERVER_CMAKE_BOOL=	BUILD_SERVER								SERVER_CMAKE_BOOL=	BUILD_SERVER

CURL_DESC=		Enable cURL support for fetching media					CURL_DESC=		Enable cURL support for fetching media
CURL_CMAKE_BOOL=	ENABLE_CURL								CURL_CMAKE_BOOL=	ENABLE_CURL
CURL_LIB_DEPENDS=	libcurl.so:ftp/curl							CURL_LIB_DEPENDS=	libcurl.so:ftp/curl
SOUND_DESC=		Enable sound								SOUND_DESC=		Enable sound
SOUND_CMAKE_BOOL=	ENABLE_SOUND								SOUND_CMAKE_BOOL=	ENABLE_SOUND
FREETYPE_DESC=		Support for TrueType fonts with unicode					FREETYPE_DESC=		Support for TrueType fonts with unicode
FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE								FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE
FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2						FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2
NCURSES_DESC=		Enable ncurses console							NCURSES_DESC=		Enable ncurses console
NCURSES_CMAKE_BOOL=	ENABLE_CURSES								NCURSES_CMAKE_BOOL=	ENABLE_CURSES
NCURSES_USES=		ncurses									NCURSES_USES=		ncurses

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

PGSQL_USES=		pgsql									PGSQL_USES=		pgsql
PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL							PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL
LEVELDB_DESC=		Enable LevelDB backend							LEVELDB_DESC=		Enable LevelDB backend
LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB								LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB
LEVELDB_LIB_DEPENDS=	libleveldb.so:databases/leveldb						LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB
REDIS_DESC=		Enable Redis backend							REDIS_DESC=		Enable Redis backend
REDIS_CMAKE_BOOL=	ENABLE_REDIS								REDIS_CMAKE_BOOL=	ENABLE_REDIS
REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis						REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis
SPATIAL_DESC=		Enable SpatialIndex AreaStore backend					SPATIAL_DESC=		Enable SpatialIndex AreaStore backend
SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex					SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex
SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL								SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL

NLS_CMAKE_BOOL=		ENABLE_GETTEXT								NLS_CMAKE_BOOL=		ENABLE_GETTEXT
NLS_USES=		gettext									NLS_USES=		gettext
NLS_LDFLAGS=		-L${LOCALBASE}/lib							NLS_LDFLAGS=		-L${LOCALBASE}/lib

.include <bsd.port.options.mk>									.include <bsd.port.options.mk>

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

.if ${PORT_OPTIONS:MSERVER}									.if ${PORT_OPTIONS:MSERVER}
USE_RC_SUBR=	${PORTNAME}									USE_RC_SUBR=	${PORTNAME}
USERS=		${PORTNAME}									USERS=		${PORTNAME}
GROUPS=		${PORTNAME}									GROUPS=		${PORTNAME}
.endif												.endif

# hacky way to not bring irrlicht and X11 depends for server only				# hacky way to not bring irrlicht and X11 depends for server only
.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}					.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}
BUILD_DEPENDS+=	${NONEXISTENT}:x11-toolkits/irrlicht:patch					BUILD_DEPENDS+=	${NONEXISTENT}:x11-toolkits/irrlicht:patch
IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include	IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include
CMAKE_ARGS+=	-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"				CMAKE_ARGS+=	-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"
EXTRA_PATCHES+=	${FILESDIR}/extra-patch-irrlichtdepend						EXTRA_PATCHES+=	${FILESDIR}/extra-patch-irrlichtdepend
.endif												.endif

post-extract:											post-extract:
# make sure no bundled gmp is used								# make sure no bundled gmp is used
	@${RM} -rf ${WRKSRC}/lib/gmp									@${RM} -rf ${WRKSRC}/lib/gmp
# bundled jsoncpp is OK, see comment in cmake/Modules/FindJson.cmake				# bundled jsoncpp is OK, see comment in cmake/Modules/FindJson.cmake
#	(not sure if it affects FreeBSD, but too lazy to investigate)				#	(not sure if it affects FreeBSD, but too lazy to investigate)
# bundled lua is OK, there's no option to use system one					# bundled lua is OK, there's no option to use system one

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

.include <bsd.port.mk>										.include <bsd.port.mk>


In addition to the above adjustments to the Makefile, there may be a patch file which must be removed or hidden in order for my modified build to succeed.  The file is /usr/ports/games/files/patch-src_CMakeLists.txt

As you can see, my preference is for those things installed within the system as opposed to those which may be bundled as part of the tarball.  As yet I have not absolutely verified or conclusively tested whether the changes I made actually result in a speedier or more efficient minetest executable.  Take the above as you wish, choose to use it as described but I suggest caution if you further adjust the modifications.  Specifically, the LIB_DEPENDS should in most cases have a matching CMAKE_ARGS equivalent.

I believe the iconv:wchar_t which I removed relates to languages which would need wide characters, and this allows for conversions which may be necessary for that situation.  I will not be needing wide characters for my singleplayer or client gameplay, so that is safe for me to excise.  I do not know exactly how the cmake compiler:c++11-lang definition changes the way it is built but it is the one that works for me and my other adjustments.  The other CMAKE_ARGS item, -DCMAKE_BUILD_TYPE=MinSizeRel is there because I believe it is an improvement, it builds with it but I do not know exactly what its function or change is.

I would like to make a proper comparison between the vanilla install and my modification but this needs a bit more research and possibly additional software tools for testing.

Had I used portlint in the minetest directory at any time during my modification, I would have discovered a mistake in the original Makefile.  A report from portlint indicates that the USES= line should appear before any USE_ lines which in this specific example is USE_GITHUB=yes so if poudriere is used with portlint=yes, it may deny building.  Change this in the Makefile unless it gets fixed by the port maintainer first, but then make note that my Makefile had the flaw and so do not restore that flaw by copying it from above.

Update - March 2021

The port maintainer has since adopted some changes with recent updates to minetest by upstream causing this port to be reexamined.  I have also decided to look over my changes and how they relate to the current Makefile and try to make any possible improvements for myself which would enhance performance.  I am also going to submit a few bug reports for this port so that my changes can be affected officially.  The primary one being that the patch I remove is not necessary because it canbe accomplished properly by cmake arguements.  I may have missed some things or made slightly incorrect adjustments my first time through, even though the changes may have been appropriate and correct aside from syntax. So lets see how the current modified Makefile looks as the comparison below illustrates today, March 30, 2021.

First the hard-coded default method which is similar to my previous modification from back in October.

# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>						# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>
# $FreeBSD$												# $FreeBSD$

PORTNAME=	minetest										PORTNAME=	minetest
PORTVERSION=	5.4.0											PORTVERSION=	5.4.0
PORTREVISION=	1											PORTREVISION=	1
CATEGORIES=	games											CATEGORIES=	games

MAINTAINER=	amdmi3@FreeBSD.org									MAINTAINER=	amdmi3@FreeBSD.org
COMMENT=	Near-infinite-world block sandbox game							COMMENT=	Near-infinite-world block sandbox game

LICENSE=	LGPL21+											LICENSE=	LGPL21+
LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt								LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt

LIB_DEPENDS=	libsqlite3.so:databases/sqlite3 \						|       LIB_DEPENDS=	libgmp.so:math/gmp \
		libgmp.so:math/gmp \								|       		libjsoncpp.so:devel/jsoncpp \
		libjsoncpp.so:devel/jsoncpp							|       		libsqlite3.so:databases/sqlite3

USE_GITHUB=	yes										<
GH_ACCOUNT=	minetest									<
												<
USES=		cmake compiler:c11 iconv:wchar_t							USES=		cmake compiler:c11 iconv:wchar_t
CMAKE_ARGS=	-DCUSTOM_MANDIR="${PREFIX}/man" \						|       CMAKE_ARGS=	-DBUILD_UNITTESTS="FALSE" \
												>       		-DCMAKE_BUILD_TYPE="MinSizeRel" \
		-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \								-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \
		-DENABLE_SYSTEM_JSONCPP=ON							|       		-DCUSTOM_MANDIR="${PREFIX}/man" \
												>       		-DENABLE_SYSTEM_GMP="ON" \
												>       		-DENABLE_SYSTEM_JSONCPP="ON" \
												>       		-DJSON_INCLUDE_DIR="${PREFIX}/include/jsoncpp" \
												>       		-DOPENGL_GL_PREFERENCE="GLVND" \
												>       		-DREQUIRE_LUAJIT="ON"
												>       #		-DVERSION_EXTRA="_${PORTREVISION}"
												>       # OpenGL_GL_PREFERENCE Allowed values are 'GLVND' and 'LEGACY'
												>       # See CMake Policy CMP0072 for reference. GLVND is broken on some nvidia setups, so use LEGACY instead.

												>       USE_GITHUB=	yes
												>       GH_ACCOUNT=	minetest
												>
LDFLAGS_i386=	-Wl,-znotext										LDFLAGS_i386=	-Wl,-znotext

PORTDATA=	*											PORTDATA=	*
PORTDOCS=	*											PORTDOCS=	*

OPTIONS_DEFINE=	CURL SOUND FREETYPE NCURSES LUAJIT \						|       OPTIONS_DEFINE=	CURL DOCS EXAMPLES FREETYPE LUAJIT NCURSES NLS SOUND
		DOCS EXAMPLES NLS								<
OPTIONS_MULTI=	COMP											OPTIONS_MULTI=	COMP
OPTIONS_GROUP=	DATABASE										OPTIONS_GROUP=	DATABASE

COMP_DESC=		Software components								COMP_DESC=		Software components
OPTIONS_MULTI_COMP=	CLIENT SERVER									OPTIONS_MULTI_COMP=	CLIENT SERVER

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

OPTIONS_DEFAULT=	CLIENT SERVER \								|       OPTIONS_DEFAULT=	CLIENT CURL FREETYPE LUAJIT NCURSES SERVER SOUND
			CURL SOUND FREETYPE NCURSES LUAJIT					<
OPTIONS_SUB=		yes										OPTIONS_SUB=		yes

CLIENT_DESC=		Build client									CLIENT_DESC=		Build client
CLIENT_CMAKE_BOOL=	BUILD_CLIENT									CLIENT_CMAKE_BOOL=	BUILD_CLIENT
CLIENT_LIB_DEPENDS=	libpng.so:graphics/png \						|       CLIENT_LIB_DEPENDS=	libIrrlicht.so:x11-toolkits/irrlicht \
			libIrrlicht.so:x11-toolkits/irrlicht					|       			libpng.so:graphics/png
CLIENT_USES=		gl jpeg xorg									CLIENT_USES=		gl jpeg xorg
CLIENT_USE=		GL=gl XORG=x11,xext,xxf86vm						|       CLIENT_USE=		GL=gl \
												>       			XORG=x11,xext,xxf86vm
SERVER_DESC=		Build server									SERVER_DESC=		Build server
SERVER_CMAKE_BOOL=	BUILD_SERVER									SERVER_CMAKE_BOOL=	BUILD_SERVER

CURL_DESC=		Enable cURL support for fetching media						CURL_DESC=		Enable cURL support for fetching media
CURL_CMAKE_BOOL=	ENABLE_CURL									CURL_CMAKE_BOOL=	ENABLE_CURL
CURL_LIB_DEPENDS=	libcurl.so:ftp/curl								CURL_LIB_DEPENDS=	libcurl.so:ftp/curl
SOUND_DESC=		Enable sound									SOUND_DESC=		Enable sound
SOUND_CMAKE_BOOL=	ENABLE_SOUND									SOUND_CMAKE_BOOL=	ENABLE_SOUND
FREETYPE_DESC=		Support for TrueType fonts with unicode						FREETYPE_DESC=		Support for TrueType fonts with unicode
FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE									FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE
FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2							FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2
NCURSES_DESC=		Enable ncurses console								NCURSES_DESC=		Enable ncurses console
NCURSES_CMAKE_BOOL=	ENABLE_CURSES									NCURSES_CMAKE_BOOL=	ENABLE_CURSES
NCURSES_USES=		ncurses										NCURSES_USES=		ncurses

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

PGSQL_USES=		pgsql										PGSQL_USES=		pgsql
PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL								PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL
LEVELDB_DESC=		Enable LevelDB backend								LEVELDB_DESC=		Enable LevelDB backend
LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB									LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB
LEVELDB_LIB_DEPENDS=	libleveldb.so:databases/leveldb							LEVELDB_LIB_DEPENDS=	libleveldb.so:databases/leveldb
REDIS_DESC=		Enable Redis backend								REDIS_DESC=		Enable Redis backend
REDIS_CMAKE_BOOL=	ENABLE_REDIS									REDIS_CMAKE_BOOL=	ENABLE_REDIS
REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis							REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis
SPATIAL_DESC=		Enable SpatialIndex AreaStore backend						SPATIAL_DESC=		Enable SpatialIndex AreaStore backend
SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex						SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex
SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL									SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL

NLS_CMAKE_BOOL=		ENABLE_GETTEXT								|       NLS_CMAKE_BOOL=	ENABLE_GETTEXT
NLS_USES=		gettext									|       NLS_USES=	gettext
NLS_LDFLAGS=		-L${LOCALBASE}/lib							|       NLS_LDFLAGS=	-L${LOCALBASE}/lib

.include <bsd.port.options.mk>										.include <bsd.port.options.mk>

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

.if ${PORT_OPTIONS:MSERVER}										.if ${PORT_OPTIONS:MSERVER}
USE_RC_SUBR=	${PORTNAME}										USE_RC_SUBR=	${PORTNAME}
USERS=		${PORTNAME}										USERS=		${PORTNAME}
GROUPS=		${PORTNAME}										GROUPS=		${PORTNAME}
.endif													.endif

# hacky way to not bring irrlicht and X11 depends for server only					# hacky way to not bring irrlicht and X11 depends for server only
.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}						.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}
BUILD_DEPENDS+=	${NONEXISTENT}:x11-toolkits/irrlicht:patch					|       BUILD_DEPENDS+=		${NONEXISTENT}:x11-toolkits/irrlicht:patch
IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include		IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include
CMAKE_ARGS+=	-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"				|       CMAKE_ARGS+=		-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"
EXTRA_PATCHES+=	${FILESDIR}/extra-patch-irrlichtdepend						|       EXTRA_PATCHES+=		${FILESDIR}/extra-patch-irrlichtdepend
.endif													.endif

post-extract:												post-extract:
# make sure no bundled gmp is used									# make sure no bundled gmp is used
	@${RM} -rf ${WRKSRC}/lib/gmp ${WRKSRC}/lib/jsoncpp							@${RM} -rf ${WRKSRC}/lib/gmp ${WRKSRC}/lib/jsoncpp
# bundled lua is OK, there's no option to use system one						# bundled lua is OK, there's no option to use system one

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

.include <bsd.port.mk>											.include <bsd.port.mk>

Sometime after deciding that the above was perfected, I realized that if I am to eventually submit a bug report to the maintainer for improvement, that I might attempt a more rococo version which will have all the option configs that interest me exposed to the light of day rather than hiding in the shadows of a developer's documentation.  This much more complex version will take a bit of effort to perfect and I still may flub something.  My makefile (below) permits the user to choose bundled gmp or jsoncpp rather than deciding that either is not desirable.

# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>							# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>
# $FreeBSD$												# $FreeBSD$

PORTNAME=	minetest										PORTNAME=	minetest
PORTVERSION=	5.4.0											PORTVERSION=	5.4.0
PORTREVISION=	1											PORTREVISION=	1
CATEGORIES=	games											CATEGORIES=	games

MAINTAINER=	amdmi3@FreeBSD.org									MAINTAINER=	amdmi3@FreeBSD.org
COMMENT=	Near-infinite-world block sandbox game							COMMENT=	Near-infinite-world block sandbox game

LICENSE=	LGPL21+											LICENSE=	LGPL21+
LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt								LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt

LIB_DEPENDS=	libsqlite3.so:databases/sqlite3 \						|       LIB_DEPENDS=	libsqlite3.so:databases/sqlite3
		libgmp.so:math/gmp \								<
		libjsoncpp.so:devel/jsoncpp							<

USE_GITHUB=	yes										<
GH_ACCOUNT=	minetest									<
												<
USES=		cmake compiler:c11 iconv:wchar_t							USES=		cmake compiler:c11 iconv:wchar_t
CMAKE_ARGS=	-DCUSTOM_MANDIR="${PREFIX}/man" \						|       CMAKE_ARGS=	-DBUILD_UNITTESTS="FALSE" \
												>       		-DCMAKE_BUILD_TYPE="MinSizeRel" \
		-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \								-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \
		-DENABLE_SYSTEM_JSONCPP=ON							|       		-DCUSTOM_MANDIR="${PREFIX}/man"
												>       #               -DVERSION_EXTRA="_${PORTREVISION}"  # Except that there is an automatic added dash seperator.
												>       # OpenGL_GL_PREFERENCE Allowed values are 'GLVND' and 'LEGACY'
												>       # See CMake Policy CMP0072 for reference: cmake --help-policy CMP0072. GLVND is broken on some nvidia setups, so use LEGACY instead.

												>       USE_GITHUB=	yes
												>       GH_ACCOUNT=	minetest
												>
LDFLAGS_i386=	-Wl,-znotext										LDFLAGS_i386=	-Wl,-znotext

PORTDATA=	*											PORTDATA=	*
PORTDOCS=	*											PORTDOCS=	*

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

COMP_DESC=		Software components								COMP_DESC=		Software components
OPTIONS_MULTI_COMP=	CLIENT SERVER									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
												>
												>       GLVND_CMAKE_ON=		-DOPENGL_GL_PREFERENCE="GLVND"
												>       LEGACY_CMAKE_ON=	-DOPENGL_GL_PREFERENCE="LEGACY"
												>
DATABASE_DESC=		Database support								DATABASE_DESC=		Database support
OPTIONS_GROUP_DATABASE=	PGSQL LEVELDB REDIS SPATIAL						|       OPTIONS_GROUP_DATABASE=	LEVELDB PGSQL REDIS SPATIAL

OPTIONS_DEFAULT=	CLIENT SERVER \								|       OPTIONS_DEFAULT=	CLIENT CURL FREETYPE GLVND LUAJIT NCURSES SERVER SOUND \
			CURL SOUND FREETYPE NCURSES LUAJIT					|       			SYSTEM_GMP SYSTEM_JSONCPP
OPTIONS_SUB=		yes										OPTIONS_SUB=		yes

CLIENT_DESC=		Build client									CLIENT_DESC=		Build client
CLIENT_CMAKE_BOOL=	BUILD_CLIENT									CLIENT_CMAKE_BOOL=	BUILD_CLIENT
CLIENT_LIB_DEPENDS=	libpng.so:graphics/png \						|       CLIENT_LIB_DEPENDS=	libIrrlicht.so:x11-toolkits/irrlicht \
			libIrrlicht.so:x11-toolkits/irrlicht					|       			libpng.so:graphics/png
CLIENT_USES=		gl jpeg xorg									CLIENT_USES=		gl jpeg xorg
CLIENT_USE=		GL=gl XORG=x11,xext,xxf86vm						|       CLIENT_USE=		GL=gl \
												>       			XORG=x11,xext,xxf86vm
SERVER_DESC=		Build server									SERVER_DESC=		Build server
SERVER_CMAKE_BOOL=	BUILD_SERVER									SERVER_CMAKE_BOOL=	BUILD_SERVER

CURL_DESC=		Enable cURL support for fetching media						CURL_DESC=		Enable cURL support for fetching media
CURL_CMAKE_BOOL=	ENABLE_CURL									CURL_CMAKE_BOOL=	ENABLE_CURL
CURL_LIB_DEPENDS=	libcurl.so:ftp/curl								CURL_LIB_DEPENDS=	libcurl.so:ftp/curl
SOUND_DESC=		Enable sound									SOUND_DESC=		Enable sound
SOUND_CMAKE_BOOL=	ENABLE_SOUND									SOUND_CMAKE_BOOL=	ENABLE_SOUND
FREETYPE_DESC=		Support for TrueType fonts with unicode						FREETYPE_DESC=		Support for TrueType fonts with unicode
FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE									FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE
FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2							FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2
NCURSES_DESC=		Enable ncurses console								NCURSES_DESC=		Enable ncurses console
NCURSES_CMAKE_BOOL=	ENABLE_CURSES									NCURSES_CMAKE_BOOL=	ENABLE_CURSES
NCURSES_USES=		ncurses										NCURSES_USES=		ncurses

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

PGSQL_USES=		pgsql										PGSQL_USES=		pgsql
PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL								PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL
LEVELDB_DESC=		Enable LevelDB backend								LEVELDB_DESC=		Enable LevelDB backend
LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB									LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB
LEVELDB_LIB_DEPENDS=	libleveldb.so:databases/leveldb							LEVELDB_LIB_DEPENDS=	libleveldb.so:databases/leveldb
REDIS_DESC=		Enable Redis backend								REDIS_DESC=		Enable Redis backend
REDIS_CMAKE_BOOL=	ENABLE_REDIS									REDIS_CMAKE_BOOL=	ENABLE_REDIS
REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis							REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis
SPATIAL_DESC=		Enable SpatialIndex AreaStore backend						SPATIAL_DESC=		Enable SpatialIndex AreaStore backend
SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex						SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex
SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL									SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL

NLS_CMAKE_BOOL=		ENABLE_GETTEXT								|       NLS_CMAKE_BOOL=	ENABLE_GETTEXT
NLS_USES=		gettext									|       NLS_USES=	gettext
NLS_LDFLAGS=		-L${LOCALBASE}/lib							|       NLS_LDFLAGS=	-L${LOCALBASE}/lib

.include <bsd.port.options.mk>										.include <bsd.port.options.mk>

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

.if ${PORT_OPTIONS:MSERVER}										.if ${PORT_OPTIONS:MSERVER}
USE_RC_SUBR=	${PORTNAME}										USE_RC_SUBR=	${PORTNAME}
USERS=		${PORTNAME}										USERS=		${PORTNAME}
GROUPS=		${PORTNAME}										GROUPS=		${PORTNAME}
.endif													.endif

# hacky way to not bring irrlicht and X11 depends for server only					# hacky way to not bring irrlicht and X11 depends for server only
.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}						.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}
BUILD_DEPENDS+=	${NONEXISTENT}:x11-toolkits/irrlicht:patch					|       BUILD_DEPENDS+=		${NONEXISTENT}:x11-toolkits/irrlicht:patch
IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include		IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include
CMAKE_ARGS+=	-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"				|       CMAKE_ARGS+=		-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"
EXTRA_PATCHES+=	${FILESDIR}/extra-patch-irrlichtdepend						|       EXTRA_PATCHES+=		${FILESDIR}/extra-patch-irrlichtdepend
.endif													.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-extract:											|       #post-extract:
# make sure no bundled gmp is used									# make sure no bundled gmp is used
	@${RM} -rf ${WRKSRC}/lib/gmp ${WRKSRC}/lib/jsoncpp					|       #	@${RM} -rf ${WRKSRC}/lib/gmp ${WRKSRC}/lib/jsoncpp
# bundled lua is OK, there's no option to use system one						# bundled lua is OK, there's no option to use system one

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

.include <bsd.port.mk>											.include <bsd.port.mk>

As before and with any of my modifications above, in addition to the above adjustments to the Makefile, there may be a patch file which must be removed or hidden in order for my modified build to succeed.  The file is /usr/ports/games/files/patch-src_CMakeLists.txt

The final result comparison of the ncurses configuration menu for default (as it is in ports now) on the left and my new rococo version on the right.

 

It should be noted that while these modifications are not yet made official (and I cannot say for certain if they will be since my philosophy/understanding may be different than the maintainer) this port is also not set to be built locally by poudriere.  Poudriere handles updates to the ports tree in a manner which any local changes would become an extra hassle as it wishes to maintain an exact duplicate, and so instead I will be adding games/minetest to the blacklist, keeping it out of the poudriere repo.  I will build it "manually" from ports and use gitup to keep a seperate /usr/ports tree updated without repairing (wiping out) my changes or at least not complaining when it does so.  This seems to be the most reasonable method to have local modified Makefiles for any relatively small subset of ports.  I thought I might periodically revisit this port for any improvements I can make to its Makefile which meant this blog post could become rather long over time and be re-published but have since decided against this.  Bug report for games/minetest to propose my revised Makefile.

No comments:

Post a Comment

Thank you for your interest!

Frequently viewed this week