-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree.mk
More file actions
42 lines (38 loc) · 796 Bytes
/
Copy pathtree.mk
File metadata and controls
42 lines (38 loc) · 796 Bytes
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
%.mk: %.tree
@\mkdir -p $(dir $@)
@\awk 'BEGIN { \
printf toupper("$(basename $(notdir $@))") "_DEPS = $@" \
} \
{ \
if (NF == 2) { \
printf " " $$2 \
} \
} \
END { \
print "" \
}' $< > $@.tmp
@\awk 'BEGIN { \
print "define " toupper("$(basename $(notdir $@))") "_RECIPE" \
} \
{ \
if(NF == 2) { \
if ($$1 ~ /\/$$/) { \
print "\t@\\mkdir -p $$1" $$1 " $${LF}" \
} else {\
print "\t@\\mkdir -p $$(dir $$1" $$1 ") $${LF}" \
} \
print "\t@\\cp $$2/" $$2 " $$1" $$1 " $${LF}" \
} else if ($$1 ~ /^-/) { \
print "\t@\\rm -rf $$1" substr($$1, 2) " $${LF}" \
} else { \
print "\t@\\mkdir -p $$1" $$1 " $${LF}" \
} \
} \
END { \
print "endef" \
}' $< >> $@.tmp
@\mv $@.tmp $@
ifndef LF
define LF
endef
endif