pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk mk: Introduce OPSYS_VERSION variable.
details: https://anonhg.NetBSD.org/pkgsrc/rev/6942cfe80702
branches: trunk
changeset: 770334:6942cfe80702
user: jperkin <jperkin%pkgsrc.org@localhost>
date: Mon Nov 29 15:57:55 2021 +0000
description:
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.
diffstat:
mk/bsd.prefs.mk | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diffs (49 lines):
diff -r af77ba408f20 -r 6942cfe80702 mk/bsd.prefs.mk
--- a/mk/bsd.prefs.mk Mon Nov 29 14:59:37 2021 +0000
+++ b/mk/bsd.prefs.mk Mon Nov 29 15:57:55 2021 +0000
@@ -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 @@
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 @@
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}
.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}
Home |
Main Index |
Thread Index |
Old Index