xref: /freebsd/share/mk/local.sys.env.mk (revision e2afbc45258f2fa4bdcf126e959ac660e76fc802)
1
2# This makefile is for customizations that should be done early
3
4.if !defined(_TARGETS)
5# some things we do only once
6_TARGETS:= ${.TARGETS}
7.export _TARGETS
8.endif
9
10# some handy macros
11_this = ${.PARSEDIR:tA}/${.PARSEFILE}
12# some useful modifiers
13
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,}}
17M_ListToMatch = L:@m@$${V:M$$m}@
18# match against our initial targets (see above)
19M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,}
20
21# turn a list into a set of :N modifiers
22# NskipFoo = ${Foo:${M_ListToSkip}}
23M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N,
24
25# :sh1 evaluates command only once and caches the result.
26.if ${MAKE_VERSION} < 20251111
27M_sh1 = sh
28.else
29M_sh1 = sh1
30.endif
31
32# type should be a builtin in any sh since about 1980,
33# AUTOCONF := ${autoconf:L:${M_whence}}
34M_type = @x@(type $$x 2> /dev/null); echo;@:${M_sh1:Ush}:[0]:N* found*:[@]:C,[()],,g
35M_whence = ${M_type}:M/*:[1]
36
37# convert a path to a valid shell variable
38M_P2V = tu:C,[./-],_,g
39
40# these are handy
41# we can use this for a cheap timestamp at the start of a target's script,
42# but not at the end - since make will expand both at the same time.
43TIME_STAMP_FMT = @ %s [%Y-%m-%d %T]
44TIME_STAMP = ${TIME_STAMP_FMT:localtime}
45# this will produce the same output but as of when date(1) is run.
46TIME_STAMP_DATE = `date '+${TIME_STAMP_FMT}'`
47TIME_STAMP_END?= ${TIME_STAMP_DATE}
48
49# Simplify auto.obj.mk mkdir -p handling and avoid unneeded/redundant
50# error spam and show a proper error.
51Mkdirs= Mkdirs() { mkdir -p $$* || :; }
52
53# jobs.mk wants this
54.if empty(NEWLOG_SH)
55NEWLOG_SH:= ${SRCTOP}/contrib/bmake/mk/newlog.sh
56.export NEWLOG_SH
57.endif
58
59.if !empty(.MAKEFLAGS:M-s)
60ECHO_TRACE?=	true
61.endif
62
63.include "src.sys.env.mk"
64.-include <site.sys.env.mk>
65
66.if !defined(HOST_TARGET) || !defined(HOST_MACHINE)
67# we need HOST_TARGET etc below.
68.include <host-target.mk>
69.export HOST_TARGET
70.endif
71
72.include <local.sys.machine.mk>
73