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