git: 326005b3bb9f - main - Mk/Uses/magick.mk: Improve readability

From: Felix Palmen <zirias_at_FreeBSD.org>
Date: Tue, 09 May 2023 06:22:07 UTC
The branch main has been updated by zirias:

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

commit 326005b3bb9fae43c2bbd321c7391dc58091af65
Author:     Felix Palmen <zirias@FreeBSD.org>
AuthorDate: 2023-05-02 06:36:25 +0000
Commit:     Felix Palmen <zirias@FreeBSD.org>
CommitDate: 2023-05-09 06:20:49 +0000

    Mk/Uses/magick.mk: Improve readability
    
    Improve readability by replacing the AT&T-style expansions with some
    explicit logic. This also avoids incompatibility with very old make
    versions where % in these expansions also matches empty strings.
    
    Approved by:            tcberner (mentor)
    Differential Revision:  https://reviews.freebsd.org/D39986
---
 Mk/Uses/magick.mk | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/Mk/Uses/magick.mk b/Mk/Uses/magick.mk
index 08802d7ccebd..9739a8260f9d 100644
--- a/Mk/Uses/magick.mk
+++ b/Mk/Uses/magick.mk
@@ -60,6 +60,8 @@ IGNORE=		Invalid version of ImageMagick: "${_magick_version}"
 #=== Flavor selection ===
 _magick_flavors=	x11 nox11
 _magick_flavor=		#
+_magick_portflavor=	#
+_magick_pkgflavor=	#
 .  for _flavor in ${_magick_flavors:O:u}
 .    if ${magick_ARGS:M${_flavor}}
 .      if empty(_magick_flavor)
@@ -73,8 +75,15 @@ IGNORE=		Incorrect USES=magick:${magick_ARGS} - multiple flavors defined
 .  if empty(_magick_flavor) && ${IMAGEMAGICK_DEFAULT:M*-*}
 _magick_flavor=		${IMAGEMAGICK_DEFAULT:C/.*-//}
 .  endif
-.  if !empty(_magick_flavor) && !${_magick_flavors:M${_magick_flavor}}
+.  if !empty(_magick_flavor)
+.    if !${_magick_flavors:M${_magick_flavor}}
 IGNORE=		Invalid flavor of ImageMagick: "${_magick_flavor}"
+.    else
+_magick_portflavor=	@${_magick_flavor}
+.      if ${_magick_flavor:Mnox11}
+_magick_pkgflavor=	-nox11
+.      endif
+.    endif
 .  endif
 
 #=== Dependency selection ===
@@ -99,9 +108,9 @@ IGNORE=		Invalid USES=magick - unsupported argument(s): ${_magick_unknown_args}
 .  endif
 
 #=== Dependency setup ===
-_MAGICK_PORT=	graphics/ImageMagick${_magick_version}${_magick_flavor:%=@%}
+_MAGICK_PORT=	graphics/ImageMagick${_magick_version}${_magick_portflavor}
 _MAGICK_LIB=	libMagick++-${_magick_version}.so
-_MAGICK_PKG=	ImageMagick${_magick_version}${_magick_flavor:Mnox11:%=-%}
+_MAGICK_PKG=	ImageMagick${_magick_version}${_magick_pkgflavor}
 
 _MAGICK_BUILD_DEPENDS=	${_MAGICK_PKG}>=${_magick_version}:${_MAGICK_PORT}
 _MAGICK_LIB_DEPENDS=	${_MAGICK_LIB}:${_MAGICK_PORT}