git: beb2c1dcea42 - main - games/openttd: handle port's dependencies somewhat better (+)

From: Alexey Dokuchaev <danfe_at_FreeBSD.org>
Date: Tue, 07 Feb 2023 05:51:29 UTC
The branch main has been updated by danfe:

URL: https://cgit.FreeBSD.org/ports/commit/?id=beb2c1dcea42b2712734a36aad1ab5103ad3b7d5

commit beb2c1dcea42b2712734a36aad1ab5103ad3b7d5
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2023-02-07 05:49:54 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2023-02-07 05:49:54 +0000

    games/openttd: handle port's dependencies somewhat better (+)
    
    - Prevent Fluidsynth detection if it was explicitly disabled
    - Depend on SDL2 if it's being installed (but prefer SDL1 by
      default); this should only affect local (manual) builds
    - Original proprietary game data files had not been required
      for a while, rephrase the installation message accordingly
    
    PR:     267862
---
 games/openttd/Makefile                   | 11 ++++++++++-
 games/openttd/files/patch-CMakeLists.txt | 22 ++++++++++++++++++++++
 games/openttd/files/pkg-message.in       | 18 +++++++++---------
 3 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/games/openttd/Makefile b/games/openttd/Makefile
index b60b0442e37e..7a61527202a4 100644
--- a/games/openttd/Makefile
+++ b/games/openttd/Makefile
@@ -26,13 +26,14 @@ OPTIONS_DEFINE=	DOCS FLUIDSYNTH SAVE_PASSWORDS SERVER
 SERVER_PREVENTS=	FLUIDSYNTH
 
 FLUIDSYNTH_LIB_DEPENDS=	libfluidsynth.so:audio/fluidsynth
+FLUIDSYNTH_CMAKE_ON=	-DWITH_FLUIDSYNTH:BOOL=ON
 
 SAVE_PASSWORDS_DESC=	Save passwords between server restarts
 SAVE_PASSWORDS_EXTRA_PATCHES=	${FILESDIR}/extra-patch-save-passwords
 
 SERVER_DESC=		Build dedicated server only (no GUI)
 SERVER_USES_OFF=	gnome sdl
-SERVER_USE_OFF=		SDL=sdl
+SERVER_USE_OFF=		SDL=${_SDL_VERSION}
 SERVER_CMAKE_ON=	-DOPTION_DEDICATED:BOOL=ON
 SERVER_LIB_DEPENDS_OFF=	libfontconfig.so:x11-fonts/fontconfig \
 			libfreetype.so:print/freetype2 \
@@ -41,6 +42,14 @@ SERVER_LIB_DEPENDS_OFF=	libfontconfig.so:x11-fonts/fontconfig \
 			libiculx.so:devel/icu-lx
 SERVER_VARS=		USE_RC_SUBR=${PORTNAME}
 
+.include <bsd.port.options.mk>
+
+.if exists(${LOCALBASE}/lib/libSDL2.so)
+_SDL_VERSION=		sdl2
+.else
+_SDL_VERSION=		sdl
+.endif
+
 post-install-SERVER-on:
 	@${REINPLACE_CMD} -E '/\.desktop|icons|pixmaps/d' ${TMPPLIST}
 
diff --git a/games/openttd/files/patch-CMakeLists.txt b/games/openttd/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..24881ccc445a
--- /dev/null
+++ b/games/openttd/files/patch-CMakeLists.txt
@@ -0,0 +1,22 @@
+--- CMakeLists.txt.orig	2022-04-02 10:38:20 UTC
++++ CMakeLists.txt
+@@ -133,7 +133,9 @@ if(NOT OPTION_DEDICATED)
+             if(NOT SDL2_FOUND)
+                 find_package(SDL)
+             endif()
++if(WITH_FLUIDSYNTH)
+             find_package(Fluidsynth)
++endif()
+             find_package(Fontconfig)
+             find_package(ICU OPTIONAL_COMPONENTS i18n lx)
+         endif()
+@@ -260,7 +262,9 @@ link_package(LIBLZMA TARGET LibLZMA::LibLZMA ENCOURAGE
+ link_package(LZO)
+ 
+ if(NOT OPTION_DEDICATED)
++  if(WITH_FLUIDSYNTH)
+     link_package(Fluidsynth)
++  endif()
+     link_package(SDL)
+     link_package(SDL2 TARGET SDL2::SDL2)
+     link_package(Allegro)
diff --git a/games/openttd/files/pkg-message.in b/games/openttd/files/pkg-message.in
index aa710e3a2c3e..e174e20f2745 100644
--- a/games/openttd/files/pkg-message.in
+++ b/games/openttd/files/pkg-message.in
@@ -1,10 +1,15 @@
 [
 { type: install
   message: <<EOM
-    OpenTTD requires the original Windows version of "Transport Tycoon
-    Deluxe" data files in order to function.  Copy the following files
-    to %%DATADIR%%/data/ (or better, $HOME/.openttd/data/)
-    directory:
+    OpenTTD can use free (libre) data files, split into OpenGFX for
+    graphics, OpenSFX for sounds, and OpenMSX for music; it will offer
+    to download them upon running the program.  Alternatively, they
+    can be installed as corresponding `games/opengfx', `games/opensfx',
+    and `games/openmsx' ports or packages.
+
+    If you'd rather use data files from the original Windows version
+    of ``Transport Tycoon Deluxe'', copy the following files to your
+    $HOME/.openttd/data directory:
 
 	sample.cat
 	trg1r.grf
@@ -17,11 +22,6 @@
     version of TTD to your OpenTTD folder (not your data folder).  The
     music from the DOS version does not work.
 
-    Alternatively, you can use free data files, split into OpenGFX for
-    graphics, OpenSFX for sounds, and OpenMSX for music.  They can be
-    installed from corresponding `games/opengfx', `games/opensfx', and
-   `games/openmsx' ports.
-
     If you are using a non-Latin language, you may see lots of `?'s on
     the screen.  Please open your configuration file and add desired
     fonts (file name with full path).  Bold fonts might look better: