forked from flightno23/OS161
-
Notifications
You must be signed in to change notification settings - Fork 0
/
os161.mkdirs.mk
59 lines (49 loc) · 1.43 KB
/
os161.mkdirs.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#
# MKDIRS logic
#
# This generates rules for all intermediate directories as well as
# the directories listed. (That is, if you say MKDIRS=/usr/bin/foo
# you get rules for /usr and /usr/bin as well as /usr/bin/foo.)
#
# Variable for complete list of dirs. Start empty.
_MKDIRS_=
# For each dir in the list...
.for _DIR_ in $(MKDIRS)
#
# Initialize some temporaries.
# _HEAD_ contains / if the path was absolute.
# _INCR_DIR_ accumulates the full directory name incrementally.
#
# Use := to force full evaluation of the RHS of each expression while
# still in the loop, instead of when the variables are used later.
#
_HEAD_:=$(_DIR_:M/*:C/..*/\//)
_INCR_DIR_:=
# For each component in the directory, split on slashes...
.for _COMPONENT_ in $(_DIR_:S/\// /g)
# Add the component to _INCR_DIR_.
_INCR_DIR_:=$(_INCR_DIR_)$(_COMPONENT_)/
# Add the current partial directory to the main list.
# Lose the trailing slash.
_MKDIRS_:=$(_MKDIRS_) $(_HEAD_)$(_INCR_DIR_:S/\/$//)
.endfor # _COMPONENT_
.endfor # _DIR_
#
# Now issue a rule for each directory in the expanded list,
# ordering and uniquifying it.
#
# XXX use /dev/null to suppress curious messages like "../../.. is up
# to date". This scheme probably ought to be reworked.
#
.for _DIR_ in $(_MKDIRS_:O:u)
.if !target($(_DIR_))
$(_DIR_):
.for _PRE_ in $(_DIR_:M*/*:H:N..)
@$(MAKE) $(_PRE_) >/dev/null 2>&1
.endfor
mkdir $(_DIR_)
.endif
.endfor
# Clear MKDIRS in case we're included again.
MKDIRS=
# End.