git: 3ebee3c508e5 - main - Mk/Uses/ada.mk: add support for gnat12

From: Thierry Thomas <thierry_at_FreeBSD.org>
Date: Wed, 14 Dec 2022 10:37:35 UTC
The branch main has been updated by thierry:

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

commit 3ebee3c508e538ea878b0572af09b5f16b752cbc
Author:     Thierry Thomas <thierry@FreeBSD.org>
AuthorDate: 2022-12-14 10:17:27 +0000
Commit:     Thierry Thomas <thierry@FreeBSD.org>
CommitDate: 2022-12-14 10:37:17 +0000

    Mk/Uses/ada.mk: add support for gnat12
    
    Keep lang/gcc6-aux by default for the moment.
---
 Mk/Uses/ada.mk | 49 ++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/Mk/Uses/ada.mk b/Mk/Uses/ada.mk
index 0cb5d0ed3002..cadd45051c5e 100644
--- a/Mk/Uses/ada.mk
+++ b/Mk/Uses/ada.mk
@@ -2,24 +2,59 @@
 # To change default compiler, define ADA_DEFAULT in make.conf
 #
 # Feature:      ada
-# Usage:        USES=ada
-# Valid ARGS:   run
+# Usage:        USES=ada:ARGS
+# Valid ARGS:   [<version>],[run]
+#
+# version	The chooseable versions are 6 (default) or 12
+#
+# run		Add run depends
 #
 # MAINTAINER: ports@FreeBSD.org
 
 .if !defined(_INCLUDE_USES_ADA_MK)
 _INCLUDE_USES_ADA_MK=    yes
 
-CC=	ada
+_ADA_SUPPORTED=	6 12
+
+_ada_version=	#
+.  for _ver in ${_ADA_SUPPORTED:O:u}
+.    if ${ada_ARGS:M${_ver}}
+.      if empty(_ada_version)
+_ada_version=	${_ver}
+.      else
+IGNORE=		Incorrect USES=ada:${ada_ARGS} - multiple versions defined
+.      endif
+.    endif
+.  endfor
+
+.  if empty(_ada_version)
+_ada_version=	6 # default, to be changed when gnat12 becomes self-supporting
+.  endif
+
+.  if ${_ada_version} == 6
+_ADAPATH=	${LOCALBASE}/gcc6-aux/bin
+_ADAPORT=	lang/gcc6-aux
+_BINDEP=	${_ADAPATH}/ada
+CC=		ada
+.  else
+_ADAPATH=	${LOCALBASE}/gnat${_ada_version}/bin
+_ADAPORT=	lang/gnat${_ada_version}
+_BINDEP=	${_ADAPATH}/gnat${_ada_version}
+CC=		gnatmake${_ada_version} -f -u
+BINARY_ALIAS+=	gcc=${_ADAPATH}/gcc12	\
+		ada=${_ADAPATH}/gcc12	\
+		gnatmake=${_ADAPATH}/gnatmake${_ada_version}	\
+		gnatbind=${_ADAPATH}/gnatbind${_ada_version}
+.  endif
 
 .  if ${ada_ARGS:Mrun}
-RUN_DEPENDS+=	${LOCALBASE}/gcc6-aux/bin/ada:lang/gcc6-aux
+RUN_DEPENDS+=	${_BINDEP}:${_ADAPORT}
 .  endif
 
-BUILD_DEPENDS+=	${LOCALBASE}/gcc6-aux/bin/ada:lang/gcc6-aux
-MAKE_ENV+=	PATH=${LOCALBASE}/gcc6-aux/bin:${PATH} \
+BUILD_DEPENDS+=	${_BINDEP}:${_ADAPORT}
+MAKE_ENV+=	PATH=${_ADAPATH}:${PATH} \
 		ADA_PROJECT_PATH=${LOCALBASE}/lib/gnat
-CONFIGURE_ENV+=	PATH=${LOCALBASE}/gcc6-aux/bin:${PATH} \
+CONFIGURE_ENV+=	PATH=${_ADAPATH}:${PATH} \
 		ADA_PROJECT_PATH=${LOCALBASE}/lib/gnat
 
 .endif