git: 4d8688269cc2 - main - devel/llvm: allow versions other than LLVM_DEFAULT

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Mon, 25 Apr 2022 22:33:38 UTC
The branch main has been updated by brooks:

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

commit 4d8688269cc20726878ca25974f9afd0dc7a35bd
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2022-04-25 22:33:26 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2022-04-25 22:33:26 +0000

    devel/llvm: allow versions other than LLVM_DEFAULT
    
    Allow the LLVM port to depend on and link to to be something other
    than LLVM_DEFAULT. This port can now be build with LLVM_SUFFIX set
    to other values including non-numeric values such as -devel, -cheri,
    or -morello. To accomodate this, change how the version is
    set so we use the major version rather than the suffix. This requires
    a PORTEPOCH bump.
---
 devel/llvm/Makefile | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/devel/llvm/Makefile b/devel/llvm/Makefile
index 24fb37c53762..1cf704252f68 100644
--- a/devel/llvm/Makefile
+++ b/devel/llvm/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	llvm
-PORTVERSION=	${LLVM_DEFAULT}
+PORTVERSION=	${LLVM_MAJOR}
 PORTREVISION=	0
+PORTEPOCH=	1
 CATEGORIES=	devel lang
 MASTER_SITES=	# not applicable
 DISTFILES=	# not applicable
@@ -14,7 +15,7 @@ COMMENT=	Meta-port for the default version of the LLVM Toolchain
 LICENSE=	BSD2CLAUSE
 LICENSE_FILE=	${.CURDIR}/../../COPYRIGHT
 
-RUN_DEPENDS=	bugpoint${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
+RUN_DEPENDS=	bugpoint${LLVM_SUFFIX}:devel/llvm${LLVM_SUFFIX}
 
 OPTIONS_DEFINE=		CLANG EXTRAS LIT LLD LLDB
 OPTIONS_DEFAULT=	CLANG EXTRAS LIT LLD LLDB
@@ -33,7 +34,28 @@ NO_BUILD=	yes
 PLIST_FILES=	${COMMANDS:S|^|bin/|}
 
 .include <bsd.port.options.mk>
-.include "${.CURDIR}/../llvm${LLVM_DEFAULT}/Makefile.COMMANDS"
+
+LLVM_SUFFIX?=	${LLVM_DEFAULT}
+
+.if ${LLVM_SUFFIX:M[789]0}
+# Pre-LLVM 10 releases have a <Major><Minor> suffix
+LLVM_MAJOR=${LLVM_SUFFIX:C/0$//}
+.elif ${LLVM_SUFFIX:M[1-9][0-9]}
+# LLVM 10 and later have a <Major> suffix
+LLVM_MAJOR=${LLVM_SUFFIX}
+.elif exists(${.CURDIR}/../llvm${LLVM_SUFFIX}/Makefile.snapshot)
+# Try to get the version from the snapshot file for named
+# suffixes.
+.include "${.CURDIR}/../llvm${LLVM_SUFFIX}/Makefile.snapshot"
+.else
+.error Don't know how to get version for ${LLVM_SUFFIX}
+.endif
+
+.if ${LLVM_SUFFIX} == "-cheri" || ${LLVM_SUFFIX} == "-morello"
+OPTIONS_EXCLUDE=	LLDB
+.endif
+
+.include "${.CURDIR}/../llvm${LLVM_SUFFIX}/Makefile.COMMANDS"
 
 COMMANDS=	${LLVM_COMMANDS}
 .if ${PORT_OPTIONS:MCLANG}
@@ -54,7 +76,7 @@ COMMANDS+=	${LLDB_COMMANDS}
 
 do-install:
 .for c in ${COMMANDS}
-	    ${LN} -s ${c}${LLVM_DEFAULT} ${STAGEDIR}${PREFIX}/bin/${c}
+	    ${LN} -s ${c}${LLVM_SUFFIX} ${STAGEDIR}${PREFIX}/bin/${c}
 .endfor
 
 .include <bsd.port.mk>