1 # $Id: sys.vars.mk,v 1.2 2017/01/31 07:44:45 sjg Exp $
3 # @(#) Copyright (c) 2003-2009, Simon J. Gerraty
5 # This file is provided in the hope that it will
6 # be of use. There is absolutely NO WARRANTY.
7 # Permission to copy, redistribute or otherwise
8 # use this file is hereby granted provided that
9 # the above copyright notice and this notice are
12 # Please send copies of changes and bug-fixes to:
16 # We use the following paradigm for preventing multiple inclusion.
17 # It relies on the fact that conditionals and dependencies are resolved
18 # at the time they are read.
20 # _this ?= ${.PARSEFILE}
21 # .if !target(__${_this}__)
24 .if
${MAKE_VERSION
:U0
} > 20100408
25 _this
= ${.PARSEDIR
:tA
}/${.PARSEFILE
}
27 _this
= ${.PARSEDIR
}/${.PARSEFILE
}
30 # if this is an ancient version of bmake
32 .if
${MAKE_VERSION
:M
*make-
*}
33 # turn it into what we want - just the date
34 MAKE_VERSION
:= ${MAKE_VERSION
:[1]:C
,.
*-,,}
37 # some useful modifiers
39 # A useful trick for testing multiple :M's against something
40 # :L says to use the variable's name as its value - ie. literal
41 # got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}}
42 M_ListToMatch
= L
:@m@
$${V
:M
$$m}@
43 # match against our initial targets (see above)
44 M_L_TARGETS
= ${M_ListToMatch
:S
,V
,_TARGETS
,}
46 # turn a list into a set of :N modifiers
47 # NskipFoo = ${Foo:${M_ListToSkip}}
48 M_ListToSkip
= O
:u
:ts
::S
,:,:N
,g
:S
,^
,N
,
50 # type should be a builtin in any sh since about 1980,
51 # but sadly there are exceptions!
52 .if
${.MAKE.OS
:Unknown
:NBSD
/OS
} == ""
56 # AUTOCONF := ${autoconf:L:${M_whence}}
57 M_type
= @x@
(${_type_sh
:Utype
} $$x) 2> /dev
/null
; echo
;@
:sh
:[0]:N
* found
*:[@
]:C
,[()],,g
58 M_whence
= ${M_type}:M
/*:[1]
60 # convert a path to a valid shell variable
61 M_P2V
= tu
:C
,[.
/-],_
,g
63 # convert path to absolute
64 .if
${MAKE_VERSION
:U0
} > 20100408
67 M_tA
= C
,.
*,('cd' & \
&\
& 'pwd') 2> /dev
/null || echo
&,:sh
70 .if
${MAKE_VERSION
:U0
} >= 20170130
71 # M_cmpv allows comparing dotted versions like 3.1.2
72 # ${3.1.2:L:${M_cmpv}} -> 3001002
73 # we use big jumps to handle 3 digits per dot:
74 # ${123.456.789:L:${M_cmpv}} -> 123456789
75 M_cmpv.units
= 1 1000 1000000
76 M_cmpv
= S
,.
, ,g
:_
:range
:@i@
+ $${_
:[-$$i]} \
* $${M_cmpv.units
:[$$i]}@
:S
,^
,expr
0 ,1:sh
79 # absoulte path to what we are reading.
80 _PARSEDIR
= ${.PARSEDIR
:${M_tA}}