2 # This makefile is for customizations that should be done early
5 # some things we do only once
11 _this = ${.PARSEDIR:tA}/${.PARSEFILE}
12 # some useful modifiers
14 # A useful trick for testing multiple :M's against something
15 # :L says to use the variable's name as its value - ie. literal
16 # got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}}
17 M_ListToMatch = L:@m@$${V:M$$m}@
18 # match against our initial targets (see above)
19 M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,}
21 # turn a list into a set of :N modifiers
22 # NskipFoo = ${Foo:${M_ListToSkip}}
23 M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N,
25 # type should be a builtin in any sh since about 1980,
26 # AUTOCONF := ${autoconf:L:${M_whence}}
27 M_type = @x@(type $$x 2> /dev/null); echo;@:sh:[0]:N* found*:[@]:C,[()],,g
28 M_whence = ${M_type}:M/*:[1]
30 # convert a path to a valid shell variable
31 M_P2V = tu:C,[./-],_,g
34 # we can use this for a cheap timestamp at the start of a target's script,
35 # but not at the end - since make will expand both at the same time.
36 TIME_STAMP_FMT = @ %s [%Y-%m-%d %T]
37 TIME_STAMP = ${TIME_STAMP_FMT:localtime}
38 # this will produce the same output but as of when date(1) is run.
39 TIME_STAMP_DATE = `date '+${TIME_STAMP_FMT}'`
40 TIME_STAMP_END?= ${TIME_STAMP_DATE}
42 # Simplify auto.obj.mk mkdir -p handling and avoid unneeded/redundant
43 # error spam and show a proper error.
44 Mkdirs= Mkdirs() { mkdir -p $$* || :; }
46 .if !empty(.MAKEFLAGS:M-s)
50 .include "src.sys.env.mk"
51 .-include <site.sys.env.mk>
53 .if !defined(HOST_TARGET) || !defined(HOST_MACHINE)
54 # we need HOST_TARGET etc below.
55 .include <host-target.mk>
59 .include <local.sys.machine.mk>