Hello,
We have a few ports that are unmaintained upstream that uses scons and
keeping the build working is a bit of a pain. While testing the
latest scons release (4.5.0) I've noticed that a few stuff breaks, and
frankly I don't have the will to debug it. On the other hand, I'd
feel bad to drop ports like boswars: they may be unmaintained
upstream, but are still fully-functional games!
So, my proposal is to "de-sconsify" them. Diff below adds a simple
makefile (which is shorter than our diff against upstream 2to3'd
SConstruct file!) to build the port. Seems to work just fine :)
I had to set DESTDIRNAME to prevent bsd.sys.mk to add unwanted stuff
to CPPFLAGS/CXXFLAGS.
While here, I've also dropped the other patch (a simple -D is enough)
and regen'd WANTLIB.
OK?
Index: Makefile
===================================================================
RCS file: /home/cvs/ports/games/boswars/Makefile,v
retrieving revision 1.29
diff -u -p -r1.29 Makefile
--- Makefile 11 Mar 2022 19:04:09 -0000 1.29
+++ Makefile 7 Mar 2023 08:51:28 -0000
@@ -5,25 +5,23 @@ DISTNAME= boswars-${V}-src
PKGNAME= boswars-${V}
CATEGORIES= games x11
MASTER_SITES= https://www.boswars.org/dist/releases/
-REVISION= 3
+REVISION= 4
HOMEPAGE= https://www.boswars.org/
# GPLv2
PERMIT_PACKAGE= Yes
-WANTLIB += ${COMPILER_LIBCXX} GL SDL X11 c m ogg png theora vorbis z
-WANTLIB += ${MODLUA_WANTLIB}
+WANTLIB += ${COMPILER_LIBCXX} GL SDL X11 Xau Xdmcp c lua5.1 m
+WANTLIB += ogg png theora vorbis xcb z
COMPILER = base-clang ports-gcc base-gcc
-MODULES= devel/scons \
- lang/lua
-MODSCONS_FLAGS= CPPPATH="${LOCALBASE}/include ${X11BASE}/include" \
- opengl=1
+MODULES= lang/lua
BUILD_DEPENDS= devel/sdl-image \
graphics/optipng
+
LIB_DEPENDS= devel/sdl \
multimedia/libtheora \
audio/libvorbis \
@@ -35,14 +33,16 @@ NO_TEST= Yes
DATA_DIR= campaigns graphics intro languages maps patches \
scripts sounds units
-pre-patch:
- 2to3 -w ${WRKSRC}/SConstruct
+# causes unwanted side-effects in bsd.sys.mk
+DESTDIRNAME= TRUE_DESTDIR
+
+post-extract:
+ cp ${FILESDIR}/Makefile ${WRKSRC}
# the shipped images are considered broken by newer libpng: use opting
# to fix them
pre-configure:
- @${SUBST_CMD} ${WRKSRC}/SConstruct \
- ${WRKSRC}/engine/include/stratagus.h
+ @${SUBST_CMD} ${WRKSRC}/engine/include/stratagus.h
.for f in maps/antarticum.map/terrain.png graphics/ui/ui_*.png \
units/radar/radar*.png units/tree*/tree*.png
optipng -force -fix ${WRKSRC}/${f}
@@ -51,8 +51,7 @@ pre-configure:
do-install:
${INSTALL_DATA_DIR} ${PREFIX}/share/boswars
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/boswars/html/scripts
- ${INSTALL_PROGRAM} ${WRKSRC}/build/boswars-release \
- ${PREFIX}/bin/boswars
+ ${INSTALL_PROGRAM} ${WRKSRC}/boswars ${PREFIX}/bin/boswars
${INSTALL_DATA} ${WRKSRC}/doc/*.html ${PREFIX}/share/doc/boswars/html
${INSTALL_DATA} ${WRKSRC}/doc/scripts/{*.html,*.py} \
${PREFIX}/share/doc/boswars/html/scripts
Index: patches/patch-SConstruct
===================================================================
RCS file: patches/patch-SConstruct
diff -N patches/patch-SConstruct
--- patches/patch-SConstruct 11 Mar 2022 19:04:09 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,120 +0,0 @@
-Index: SConstruct
---- SConstruct.orig
-+++ SConstruct
-@@ -32,12 +32,12 @@ SConsignFile()
-
- def DefineOptions(filename, args):
- opts = Variables(filename, args)
-- opts.Add('CPPPATH', 'Additional preprocessor paths',
['/usr/local/include'])
-+ opts.Add('CPPPATH', 'Additional preprocessor paths',
['/usr/local/include'], Split(''))
- opts.Add('CPPFLAGS', 'Additional preprocessor flags')
- opts.Add('CPPDEFINES', 'defined constants', Split(''))
-- opts.Add('LIBPATH', 'Additional library paths', ['/usr/local/lib'])
-+ opts.Add('LIBPATH', 'Additional library paths', ['/usr/local/lib'],
Split(''))
- opts.Add('LIBS', 'Additional libraries')
-- opts.Add('CCFLAGS', 'C Compiler flags', Split(ccflags))
-+ opts.Add('CCFLAGS', 'C Compiler flags', Split(ccflags), Split(''))
- opts.Add('LINKFLAGS', 'Linker Compiler flags')
- opts.Add('CC', 'C Compiler')
- opts.Add('CXX', 'C++ Compiler')
-@@ -51,6 +51,9 @@ def DefineOptions(filename, args):
- opts = DefineOptions("build_options.py", ARGUMENTS)
- env = Environment(ENV = {'PATH':os.environ['PATH']}) # for an unknown reason
Environment(options=opts) doesnt work well
- opts.Update(env) # Needed as Environment(options=opts) doesnt seem to work
-+env['CCFLAGS'] = Split(ccflags) + Split(env['CCFLAGS'])
-+env['CPPPATH'] = Split(env['CPPPATH'])
-+env['LIBPATH'] = Split(env['LIBPATH'])
- Help(opts.GenerateHelpText(env))
- mingw = env.Clone()
- optionsChanged = True
-@@ -144,6 +147,10 @@ def CheckOpenGL(env, conf):
- 'LIBS': ['GL'],
- 'LIBPATH': ['/usr/lib', '/usr/X11R6/lib'],
- 'CPPPATH': ['/usr/include']}
-+ opengl['openbsd'] = {
-+ 'LIBS': ['GL'],
-+ 'LIBPATH': ['/usr/X11R6/lib'],
-+ 'CPPPATH': ['/usr/X11R6/include']}
- opengl['cygwin'] = {
- 'LIBS': ['opengl3']}
- opengl['darwin'] = {
-@@ -155,6 +162,8 @@ def CheckOpenGL(env, conf):
- else:
- if sys.platform[:5] == 'linux' or sys.platform.startswith('gnukfreebsd'):
- platform = 'linux'
-+ if sys.platform[:7] == 'openbsd':
-+ platform = 'openbsd'
- glconfig = opengl.get(platform, {})
- for key in glconfig:
- if key != 'LIBS':
-@@ -168,17 +177,12 @@ def CheckOpenGL(env, conf):
- return True
-
- def CheckLuaLib(env, conf):
-- if not 'USE_WIN32' in env['CPPDEFINES']:
-- if env.WhereIs('pkg-config'):
-- for packagename in ['lua5.1', 'lua51', 'lua']:
-- exitcode,_ = ParseConfig(env, 'pkg-config --cflags --libs ' +
packagename)
-- if exitcode == 0:
-- break
-+ env.ParseConfig('pkg-config --cflags --libs lua51')
- if conf.CheckLibWithHeader('lua51', 'lua.h', 'c'):
- return 1
- if conf.CheckLibWithHeader('lua5.1', 'lua.h', 'c'):
- return 1
-- if not conf.CheckLibWithHeader('lua', 'lua.h', 'c'):
-+ if not conf.CheckLibWithHeader('lua', 'lualib.h', 'c'):
- return 0
- # make sure we have lualib which is included in lua 5.1
- if conf.CheckFunc('luaopen_base'):
-@@ -189,13 +193,13 @@ def AutoConfigure(env):
- conf = Configure(env)
-
- ## check for required libs ##
-- if not conf.CheckLibWithHeader('png', 'png.h', 'c'):
-- print('Did not find png library or headers, exiting!')
-- Exit(1)
- if not conf.CheckLibWithHeader('z', 'zlib.h', 'c'):
- print('Did not find the zlib library or headers, exiting!')
- Exit(1)
-- if not 'USE_WIN32' in env['CPPDEFINES'] and not
sys.platform.startswith('freebsd'):
-+ if not conf.CheckLibWithHeader('png', 'png.h', 'c'):
-+ print('Did not find png library or headers, exiting!')
-+ Exit(1)
-+ if not 'USE_WIN32' in env['CPPDEFINES'] and not
sys.platform.startswith('openbsd'):
- if not conf.CheckLib('dl'):
- print('Did not find dl library or header which is needed on some
systems for lua. Exiting!')
- Exit(1)
-@@ -207,12 +211,12 @@ def AutoConfigure(env):
- Exit(1)
-
- # Check for optional libraries #
-+ if conf.CheckLib('ogg'):
-+ env.Append(CPPDEFINES = 'USE_OGG')
- if conf.CheckLib('vorbis'):
- env.Append(CPPDEFINES = 'USE_VORBIS')
- if conf.CheckLib('theora'):
- env.Append(CPPDEFINES = 'USE_THEORA')
-- if conf.CheckLib('ogg'):
-- env.Append(CPPDEFINES = 'USE_OGG')
-
- # check for optional functions
- if conf.CheckFunc('strcasestr'):
-@@ -265,7 +269,7 @@ addBosWarsPaths(env)
-
- # define the different build environments (variants)
- release = env.Clone()
--release.Append(CCFLAGS = Split('-O2 -pipe -fomit-frame-pointer
-fexpensive-optimizations -ffast-math'))
-+release.Append(CCFLAGS = Split('-fomit-frame-pointer -ffast-math'))
-
- if mingw['extrapath']:
- mingw.Tool('crossmingw', toolpath = ['tools/scons/'])
-@@ -311,7 +315,7 @@ if sys.platform.startswith('linux') or sys.platform.st
- def DefineVariant(venv, v, vv = None):
- if vv == None:
- vv = '-' + v
-- BuildDir('build/' + v, engineSourceDir, duplicate = 0)
-+ VariantDir('build/' + v, engineSourceDir, duplicate = 0)
- r = venv.Program('build/boswars' + vv, buildSourcesList('build/' + v))
- Alias(v, 'boswars' + vv)
- return r
Index: patches/patch-engine_include_stratagus_h
===================================================================
RCS file: patches/patch-engine_include_stratagus_h
diff -N patches/patch-engine_include_stratagus_h
--- patches/patch-engine_include_stratagus_h 11 Mar 2022 19:04:09 -0000
1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
---- engine/include/stratagus.h.orig Sun Apr 11 14:12:18 2010
-+++ engine/include/stratagus.h Mon Apr 12 12:49:55 2010
-@@ -133,7 +133,7 @@
- -- General
- ----------------------------------------------------------------------------*/
- #ifndef STRATAGUS_LIB_PATH
--#define STRATAGUS_LIB_PATH "." /// Where to find the data files
-+#define STRATAGUS_LIB_PATH "${PREFIX}/share/boswars" /// Where to find
the data files
- #endif
-
- #ifndef STRATAGUS_HOME_PATH
Index: files/Makefile
===================================================================
RCS file: files/Makefile
diff -N files/Makefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/Makefile 7 Mar 2023 08:56:03 -0000
@@ -0,0 +1,41 @@
+# rewriting of upstream' SConstruct as a Makefile since the former was
+# aging
+
+.for i in action ai apbuild editor game guichan guichan/sdl guichan/widgets \
+ map network particle pathfinder sound stratagus tolua ui unit video
+.PATH:${.CURDIR}/engine/${i}
+.endfor
+
+PROG = boswars
+FILES != cd ${.CURDIR} && find engine -type f -iname '*.cpp'
+SRCS = ${FILES:T}
+
+NOMAN = Yes
+
+LOCALBASE ?= /usr/local
+X11BASE ?= /usr/X11R6
+
+SDL_CPPFLAGS != sdl-config --cflags
+
+CPPFLAGS += -I${.CURDIR}/engine/include
+CPPFLAGS += -I${.CURDIR}/engine/guichan/include
+CPPFLAGS += -I${LOCALBASE}/include/libpng16
+CPPFLAGS += -I${LOCALBASE}/include/lua-5.1
+CPPFLAGS += -I${LOCALBASE}/include/SDL
+CPPFLAGS += -I${LOCALBASE}/include
+CPPFLAGS += -I${X11BASE}/include
+CPPFLAGS += -DUSE_VORBIS -DUSE_THEORA -DUSE_OGG -DHAVE_X
+CPPFLAGS += -DHAVE_STRCASESTR -DHAVE_STRNLEN
+CPPFLAGS += ${SDL_CPPFLAGS}
+
+CPPFLAGS += -DSTRATAGUS_LIB_PATH='"${TRUEPREFIX}/share/boswars"'
+
+CXXFLAGS += -ffast-math
+
+LDFLAGS += -L${LOCALBASE}/lib
+LDFLAGS += -L${X11BASE}/lib
+
+LDADD += -llua5.1 -lm -lvorbis -ltheora -logg -lpng -lz
+LDADD += -lGL -lSDL -lX11 -lxcb -lXau -lXdmcp -pthread
+
+.include <bsd.prog.mk>