diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-09-05 00:26:46 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-09-05 00:26:46 +1200 |
commit | b94c199f29ba6223127dfb5c2becda9176e95c9c (patch) | |
tree | 54642ac9cbc8b4fd27a7eadb9434256652f26674 /bin/mftl.awk | |
parent | Don't prescribe msmtp(1) path (diff) | |
download | dotfiles-b94c199f29ba6223127dfb5c2becda9176e95c9c.tar.gz dotfiles-b94c199f29ba6223127dfb5c2becda9176e95c9c.zip |
Add mftl(1df)
Diffstat (limited to 'bin/mftl.awk')
-rw-r--r-- | bin/mftl.awk | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bin/mftl.awk b/bin/mftl.awk new file mode 100644 index 00000000..c6d65409 --- /dev/null +++ b/bin/mftl.awk @@ -0,0 +1,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=0; 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" +} |