svn commit: r563416 - head/Mk

Gerald Pfeifer gerald at FreeBSD.org
Sat Jan 30 15:15:01 UTC 2021


Author: gerald
Date: Sat Jan 30 15:15:01 2021
New Revision: 563416
URL: https://svnweb.freebsd.org/changeset/ports/563416

Log:
  In some cases one may want to use GCC to build something when its
  runtimes or GCC at runtime are not required.
  
  Introduce an optional argument for USE_GCC that indicates GCC is
  only required at build time.
  
  Examples for the new syntax are USE_GCC=yes:build, USE_GCC=9:build,
  or USE_GCC=11+:build.
  
  Submitted by:	Fabian Freyer <fabian.freyer at physik.tu-berlin.de>
  PR:		211154
  Differential Revision:	https://reviews.freebsd.org/D7223

Modified:
  head/Mk/bsd.gcc.mk

Modified: head/Mk/bsd.gcc.mk
==============================================================================
--- head/Mk/bsd.gcc.mk	Sat Jan 30 15:09:08 2021	(r563415)
+++ head/Mk/bsd.gcc.mk	Sat Jan 30 15:15:01 2021	(r563416)
@@ -17,12 +17,25 @@
 # do so by specifying USE_GCC=X+ which requests at least GCC version X.
 # To request a specific version omit the trailing + sign.
 #
+# Optionally comma-separated arguments follow the version specifier.
+# Currently we support:
+#   build ... which adds GCC as a build dependency (BUILD_DEPENDS) only.
+#
+# If no arguments are specified, GCC is added as both a build dependency
+# and a run time dependency.
+#
+#
 # Examples:
 #   USE_GCC=	yes			# port requires a current version of GCC
 #							# as defined in bsd.default-versions.mk.
 #   USE_GCC=	any			# port requires GCC 4.2 or later.
 #   USE_GCC=	9+			# port requires GCC 9 or later.
 #   USE_GCC=	8			# port requires GCC 8.
+#   USE_GCC=	yes:build	# port requires a current version of GCC at
+#							# build time only.
+#   USE_GCC=	9:build		# port requires GCC 9 at build time only.
+#   USE_GCC=	11+:build	# port requires GCC 11 or later at build
+#							# time only.
 #
 # If you are wondering what your port exactly does, use "make test-gcc"
 # to see some debugging.
@@ -39,6 +52,23 @@ GCCVERSIONS=	4.8 7 8 9 10 11
 # No configurable parts below this. ####################################
 #
 
+# Split arguments
+.if defined(USE_GCC)
+__USE_GCC:=		${USE_GCC:C/\:.*//}
+_USE_GCC_ARGS:=	${USE_GCC:C/^[^\:]*(\:|\$)//:S/,/ /g}
+USE_GCC=		${__USE_GCC}
+.endif
+
+.if ${_USE_GCC_ARGS:Mbuild}
+_USE_GCC_ARGS:=		${_USE_GCC_ARGS:Nbuild}
+.else
+_USE_GCC_RUN_DEPENDS=	yes
+.endif
+
+.if !empty(_USE_GCC_ARGS)
+IGNORE=	bad target specification in USE_GCC; only "build" is supported
+.endif
+
 .if defined(USE_GCC) && !defined(FORCE_BASE_CC_FOR_TESTING)
 
 .if ${USE_GCC} == any && exists(/usr/bin/gcc)
@@ -116,7 +146,9 @@ CXXFLAGS:=		${CXXFLAGS:N-mretpoline}
 
 .if defined(_GCC_PORT)
 BUILD_DEPENDS+=	${CC}:lang/${_GCC_PORT}
+. if defined(_USE_GCC_RUN_DEPENDS)
 RUN_DEPENDS+=	${CC}:lang/${_GCC_PORT}
+. endif
 # GCC ports already depend on binutils; make sure whatever we build
 # leverages this as well.
 USE_BINUTILS=	yes


More information about the svn-ports-head mailing list