Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified)) by mollari.NetBSD.org (Postfix) with ESMTPS id 28D721A9239 for ; Mon, 29 Nov 2021 15:57:58 +0000 (UTC) Received: by mail.netbsd.org (Postfix, from userid 605) id 3CE0984E74; Mon, 29 Nov 2021 15:57:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 7837184D17 for ; Mon, 29 Nov 2021 15:57:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id crCUa5-BqcDq for ; Mon, 29 Nov 2021 15:57:55 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id DC84684D04 for ; Mon, 29 Nov 2021 15:57:55 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id D0496FAEC; Mon, 29 Nov 2021 15:57:55 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_163820147521230" MIME-Version: 1.0 Date: Mon, 29 Nov 2021 15:57:55 +0000 From: "Jonathan Perkin" Subject: CVS commit: pkgsrc/mk To: pkgsrc-changes@NetBSD.org Reply-To: jperkin@netbsd.org X-Mailer: log_accum Message-Id: <20211129155755.D0496FAEC@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_163820147521230 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: jperkin Date: Mon Nov 29 15:57:55 UTC 2021 Modified Files: pkgsrc/mk: bsd.prefs.mk Log Message: mk: Introduce OPSYS_VERSION variable. This provides a single integer that can be used in arithmetic expressions when comparing the current operating system version in make(1). The two existing variables that are currently used for such tests are MACHINE_PLATFORM and OS_VERSION. The former usually results in complicated and hard to read empty() strings, and the latter is often used incorrectly in version comparisons where developers are unaware that a string comparison is being performed (for example ".if 5.9 >= 5.10" evaluates to true). The default based on uname -r should be correct for most systems, and can be overridden as it is on Darwin where the product version provides a more useful number than the kernel version. To generate a diff of this commit: cvs rdiff -u -r1.411 -r1.412 pkgsrc/mk/bsd.prefs.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_163820147521230 Content-Disposition: inline Content-Length: 1927 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Modified files: Index: pkgsrc/mk/bsd.prefs.mk diff -u pkgsrc/mk/bsd.prefs.mk:1.411 pkgsrc/mk/bsd.prefs.mk:1.412 --- pkgsrc/mk/bsd.prefs.mk:1.411 Fri Nov 12 20:29:05 2021 +++ pkgsrc/mk/bsd.prefs.mk Mon Nov 29 15:57:55 2021 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.prefs.mk,v 1.411 2021/11/12 20:29:05 nia Exp $ +# $NetBSD: bsd.prefs.mk,v 1.412 2021/11/29 15:57:55 jperkin Exp $ # # This file includes the mk.conf file, which contains the user settings. # @@ -93,6 +93,19 @@ OS_VERSION= ${_OS_VERSION_CMD:sh} MAKEFLAGS+= OS_VERSION=${OS_VERSION:Q} .endif +# +# OPSYS_VERSION differs from OS_VERSION in that it should always evaluate to +# an integer, allowing arithmetic expressions to simplify make(1) tests. The +# default command is likely correct for most OS, those that need to can set +# it to a custom command in the later OPSYS-specific section. +# +.if !defined(OPSYS_VERSION) +_OPSYS_VERSION_CMD= ${UNAME} -r | \ + awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' +OPSYS_VERSION= ${_OPSYS_VERSION_CMD:sh} +MAKEFLAGS+= OPSYS_VERSION=${OPSYS_VERSION:Q} +.endif + # Preload these for architectures not in all variations of bsd.own.mk, # which do not match their GNU names exactly. GNU_ARCH.aarch64eb?= aarch64_be @@ -161,6 +174,8 @@ OS_VARIANT!= ${UNAME} -s LOWER_OPSYS?= darwin LOWER_OPSYS_VERSUFFIX= ${LOWER_OS_VERSION:C/([0-9]*).*/\1/} LOWER_VENDOR?= apple +_OPSYS_VERSION_CMD= sw_vers -productVersion | \ + awk -F. '{printf("%02d%02d%02d", $$1, $$2, $$3)}' .elif ${OPSYS} == "DragonFly" OS_VERSION:= ${OS_VERSION:C/-.*$//} @@ -299,8 +314,9 @@ LOWER_OPSYS:= ${OPSYS:tl} LOWER_OPSYS:= ${OPSYS:tl} .endif -# Now commit the [LOWER_]OS_VERSION values computed above, eliding the :sh +# Now commit the version values computed above, eliding the :sh OS_VERSION:= ${OS_VERSION} +OPSYS_VERSION:= ${OPSYS_VERSION} LOWER_OS_VERSION:= ${OS_VERSION:tl} MAKEFLAGS+= LOWER_OPSYS=${LOWER_OPSYS:Q} --_----------=_163820147521230--