From nobody Fri Sep 1 16:54:53 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RckfP4VXpz4rlqZ; Fri, 1 Sep 2023 16:54:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RckfP3mycz3VGC; Fri, 1 Sep 2023 16:54:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693587293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Dg+y7GMNnb5JswPsdDOo0qDiqdzWWxe7wdrK9Yczvi0=; b=yKKUwsmseb/MzlgvN/f3snpCtmY9yf9tUcS+H5s7cO2Y66LoNzELWgEdTA4gZTN5ss9/sQ 4CAmCyGNRHKxxJZ66C4tnBSp91Rw7N4IibxCoAwGffnpNU2Rmrh/9QASr2ZwNxAYeykmap j1WMEYkJwLhz7v5dCx3bQWiIObbm+TYL98pqse5gaMrBqdec1SfVZCTk8BGS6LlzVp6BWM +SYIKOtJQ14wFNR7lZChpai7DlEODNvRWKYDvR5iZIMdwWFbAR21oW4OvlXRffNF8Ypqw6 E0pV2ruaQeKnJtpzsuQW3lm9BjQfb8BBuW5/ceOemS8SQsrmrKxBCgUsQqXqZw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693587293; a=rsa-sha256; cv=none; b=GsleNXs9U2oNf7bZVhbNimuDeZDjztZ8sn6MC7cUEfVrX/PkTjOjY18Og/pXbRL7d+6BSB xoyeg6twIPeNLKFaqW1CLrxSpYoTNoZE2wPeAPwDOK4qhsNiC8aNtatohP2Sk5K4ygPiQQ JPoo6KMDwJPrFuvKYQ3FYpgok4gMw892XMhOg5mCHMhu4XhtNyBCFg04oWJobpP6ir/Hro l/C7cwvc6/mokSIcD/Dsh2havzFP5NojqbxiYqwt0WEttAEfgV6vFJyk65OZJgRBYnTkO6 MROM9Ar9J3KDZwIk5O8nk3SD1m74s4v3A1VEEMISzZLPfR66qvK19PhagiouRQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693587293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Dg+y7GMNnb5JswPsdDOo0qDiqdzWWxe7wdrK9Yczvi0=; b=vpkujUc3SA1aaY44r8uvXf8BQXau+3it+yB0/+MLxsFSgls6eqnaj/fatxPpG9yOtXSq+D yfC/iT7tnb9Zf0e9xix7wTKoMMEVLXCyCmVaZO4mRP7/JqY36Wul51sPUHTicZ2JlWJbIS FIXwXaMkLK3yX3dpLX1FkzCTVWboWlvTxtA5DCdVmlWYvWRK14t30erxhAgBF93c6kqqli znydY8TkXREa9wt0mzkHP8bWJpgU11/U93Zcb0jOLvu5VF3gM4Fie8Ty6+srvp4CWJZMRc ODdl8pFzGoZDgDciLQmgc6IKbnxmCDODx2pPJq9oEoSqAP+Bi5rcpTSsGUy6Ng== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RckfP2qvfz17ck; Fri, 1 Sep 2023 16:54:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 381GsrPo070590; Fri, 1 Sep 2023 16:54:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 381GsraB070587; Fri, 1 Sep 2023 16:54:53 GMT (envelope-from git) Date: Fri, 1 Sep 2023 16:54:53 GMT Message-Id: <202309011654.381GsraB070587@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: ce5fa47cf02a - main - share/mk: support for "single" group options List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ce5fa47cf02ae97844a826d967d122cc8171dd58 Auto-Submitted: auto-generated The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=ce5fa47cf02ae97844a826d967d122cc8171dd58 commit ce5fa47cf02ae97844a826d967d122cc8171dd58 Author: Brooks Davis AuthorDate: 2023-09-01 16:41:07 +0000 Commit: Brooks Davis CommitDate: 2023-09-01 16:52:28 +0000 share/mk: support for "single" group options Support group options where 1 of n values will be selected (or a default value will be used). After processing, an OPT_FOO will be set to one value from __FOO_OPTIONS for each FOO in __SINGLE_OPTIONS. If the user sets FOO that value will be used, otherwise __FOO_DEFAULT will be used. Options that don't work an a particular system can be remapped to an alternative using BROKEN_SINGLE_OPTIONS which can be set to a list of 3-tuples of the form: OPTION broken_value replacement_value This is somewhat inspired by OPTIONS_SINGLE from ports, but the structure is quite different with a per-option variable in the style of MK_FOO={yes,no}. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41659 --- share/mk/bsd.mkopt.mk | 38 +++++++++++++++++++++++++++++++++++++- sys/conf/kern.opts.mk | 27 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/share/mk/bsd.mkopt.mk b/share/mk/bsd.mkopt.mk index 7d43e91b042d..043a41212064 100644 --- a/share/mk/bsd.mkopt.mk +++ b/share/mk/bsd.mkopt.mk @@ -1,7 +1,7 @@ # # # Generic mechanism to deal with WITH and WITHOUT options and turn -# them into MK_ options. +# them into MK_ options. Also turn group options into OPT_ options. # # For each option FOO in __DEFAULT_YES_OPTIONS, MK_FOO is set to # "yes", unless WITHOUT_FOO is defined, in which case it is set to @@ -31,6 +31,15 @@ # system should use MK_FOO={yes,no} when it needs to override the # user's desires or default behavior. # +# For each option in __SINGLE_OPTIONS, OPT_FOO is set to FOO if +# defined and __FOO_DEFAULT if not. Valid values for FOO are specified +# by __FOO_OPTIONS. +# +# Other parts of the build system will set BROKEN_SINGLE_OPTIONS to a +# list of 3-tuples of the form: "OPTION broken_value replacment_value". +# This will not be unset before returning. Clients are expected to +# always += this variable. +# # # MK_* options which default to "yes". @@ -93,6 +102,33 @@ MK_${var}:= no MK_${var}:= no .endfor +# +# Group options set an OPT_FOO variable for each option. +# +.for opt in ${__SINGLE_OPTIONS} +.if !defined(__${opt}_OPTIONS) || empty(__${opt}_OPTIONS) +.error __${opt}_OPTIONS undefined or empty +.endif +.if !defined(__${opt}_DEFAULT) || empty(__${opt}_DEFAULT) +.error __${opt}_DEFAULT undefined or empty +.endif +.if defined(${opt}) +OPT_${opt}:= ${${opt}} +.else +OPT_${opt}:= ${__${opt}_DEFAULT} +.endif +.if empty(OPT_${opt}) || ${__${opt}_OPTIONS:M${OPT_${opt}}} != ${OPT_${opt}} +.error Invalid option OPT_${opt} (${OPT_${opt}}), must be one of: ${__${opt}_OPTIONS} +.endif +.endfor +.undef __SINGLE_OPTIONS + +.for opt val rep in ${BROKEN_SINGLE_OPTIONS} +.if ${OPT_${opt}} == ${val} +OPT_${opt}:= ${rep} +.endif +.endfor + .for vv in ${__DEFAULT_DEPENDENT_OPTIONS} .if defined(WITH_${vv:H}) && defined(WITHOUT_${vv:H}) MK_${vv:H}?= no diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk index 178a4db61cb2..bad5e218a5b0 100644 --- a/sys/conf/kern.opts.mk +++ b/sys/conf/kern.opts.mk @@ -141,6 +141,33 @@ MK_${var}:= no MK_${var}:= no .endfor .undef BROKEN_OPTIONS + +# +# Group options set an OPT_FOO variable for each option. +# +.for opt in ${__SINGLE_OPTIONS} +.if !defined(__${opt}_OPTIONS) || empty(__${opt}_OPTIONS) +.error __${opt}_OPTIONS not defined or empty +.endif +.if !defined(__${opt}_DEFAULT) || empty(__${opt}_DEFAULT) +.error __${opt}_DEFAULT undefined or empty +.endif +.if defined(${opt}) +OPT_${opt}:= ${${opt}} +.else +OPT_${opt}:= ${__${opt}_DEFAULT} +.endif +.if empty(OPT_${opt}) || ${__${opt}_OPTIONS:M${OPT_${opt}}} != ${OPT_${opt}} +.error Invalid option OPT_${opt} (${OPT_${opt}}), must be one of: ${__${opt}_OPTIONS} +.endif +.endfor +.undef __SINGLE_OPTIONS + +.for opt val rep in ${BROKEN_SINGLE_OPTIONS} +.if ${OPT_${opt}} == ${val} +OPT_${opt}:= ${rep} +.endif +.endfor #end of bsd.mkopt.mk expanded inline. #