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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#!/usr/bin/gawk -f
# This program should generate Maketests
BEGIN {
# read the list of files
for (i = 2; i < ARGC; i++)
files[ARGV[i]]
# throw it away
ARGC = 2
ntests = 0
}
# process the file Makefile.am:
/^[A-Z_]*_TESTS *=/,/[^\\]$/ {
gsub(/(^[A-Z_]*_TESTS *=|\\$)/,"")
for (i = 1; i <= NF; i++)
tests[++ntests] = $i
next
}
/^NEED_LINT *=/,/[^\\]$/ {
gsub(/(^NEED_LINT *=|\\$)/,"")
for (i = 1; i <= NF; i++)
lint[$i]
next
}
/^GENTESTS_UNUSED *=/,/[^\\]$/ {
gsub(/(^GENTESTS_UNUSED *=|\\$)/,"")
for (i = 1; i <= NF; i++)
unused[$i]
next
}
/^[a-zA-Z][a-zA-Z0-9]*:/ {
# remember all targets from Makefile.am
sub(/:.*/,"")
targets[$0]
}
# Now write the output file:
END {
# this line tells automake to keep the comment with the rules:
print "Gt-dummy:"
print "# file Maketests, generated from Makefile.am by the Gentests program"
for (i = 1; i <= ntests; i++) {
x = tests[i]
if (!(x in targets))
generate(x)
}
print "# end of file Maketests"
}
function generate(x, s)
{
if (!(x".awk" in files))
printf "WARNING: file `%s.awk' not found.\n", x > "/dev/stderr"
else
delete files[x".awk"]
print x ":"
s = ""
if (x in lint) {
s = s " --lint"
delete lint[x]
}
if (x".in" in files) {
s = s " < $(srcdir)/$@.in"
delete files[x".in"]
}
printf "\t@echo %s\n", x
printf "\t@AWKPATH=$(srcdir) $(AWK) -f $@.awk %s >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@\n", s
printf "\t@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@\n\n"
}
END {
for (x in lint)
if (!(x in targets))
printf "WARNING: --lint target `%s' is missing.\n", x > "/dev/stderr"
for (x in files)
if (!(x in unused) && \
!(gensub(/\.(awk|in)$/,"","",x) in targets))
printf "WARNING: unused file `%s'.\n", x > "/dev/stderr"
}
|