blob: f210de3312a68950cd2c038582547f8dba252ce6 (
plain) (
blame)
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
|
# Try to find the targets in a Makefile that look like they're targets the user
# could be reasonably expected to call directly
# Separators are space, tab, or colon
BEGIN {
FS = "[ \t:]"
}
# Skip comments
/^#/ { next }
# Join backslash-broken lines
/\\$/ {
sub(/\\$/, "")
line = line $0
next
}
{
$0 = line $0
line = ""
}
# Check lines matching expected "targets:dependencies" format
/^[a-zA-Z0-9][a-zA-Z0-9 \t_-]+:([^=]|$)/ {
# Iterate through the targets that don't look like substitutions or
# inference rules and stack them up into an array's keys to keep them
# unique; this probably needs refinement
for (i = 1; i < NF; i++)
if ($i ~ /^[a-zA-Z0-9][a-zA-Z0-9.\/_-]*$/)
ats[$i]
}
# Print unique determined targets, sorted
END {
for (t in ats)
print t | "sort"
}
|