summaryrefslogtreecommitdiff
path: root/mk/sys.vars.mk
diff options
context:
space:
mode:
Diffstat (limited to 'mk/sys.vars.mk')
-rw-r--r--mk/sys.vars.mk16
1 files changed, 15 insertions, 1 deletions
diff --git a/mk/sys.vars.mk b/mk/sys.vars.mk
index 24e0ed26a15f..592cbdc644dc 100644
--- a/mk/sys.vars.mk
+++ b/mk/sys.vars.mk
@@ -1,4 +1,4 @@
-# $Id: sys.vars.mk,v 1.5 2020/08/19 17:51:53 sjg Exp $
+# $Id: sys.vars.mk,v 1.6 2020/10/28 20:50:04 sjg Exp $
#
# @(#) Copyright (c) 2003-2009, Simon J. Gerraty
#
@@ -57,6 +57,20 @@ _type_sh = which
M_type = @x@(${_type_sh:Utype} $$x) 2> /dev/null; echo;@:sh:[0]:N* found*:[@]:C,[()],,g
M_whence = ${M_type}:M/*:[1]
+# produce similar output to jot(1)
+# eg. ${LIST:[#]:${M_JOT}}
+# would be 1 2 3 4 5 if LIST has 5 words
+# ${9:L:${M_JOT}}
+# would be 1 2 3 4 5 6 7 8 9
+M_JOT = @x@i=1;while [ $$$$i -le $$x ]; do echo $$$$i; i=$$$$((i + 1)); done;@:sh
+
+# ${LIST:${M_RANGE}} is 1 2 3 4 5 if LIST has 5 words
+.if ${MAKE_VERSION} >= 20170130
+M_RANGE = range
+.else
+M_RANGE = [#]:${M_JOT}
+.endif
+
# convert a path to a valid shell variable
M_P2V = tu:C,[./-],_,g