-
Notifications
You must be signed in to change notification settings - Fork 4
/
makedeps.sh
executable file
·58 lines (53 loc) · 1.16 KB
/
makedeps.sh
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
#!/bin/sh
# $MawkId: makedeps.sh,v 1.2 2010/12/10 17:00:00 tom Exp $
###############################################################################
# copyright 2009, Thomas E. Dickey
#
# This is a source file for mawk, an implementation of
# the AWK programming language.
#
# Mawk is distributed without warranty under the terms of
# the GNU General Public License, version 2, 1991.
###############################################################################
if test ! -f config.h
then
echo "? config.h not found"
exit 1
fi
if test ! -f mawk
then
echo "? mawk not found"
exit 1
fi
cat >makedeps.awk <<'EOF'
# vile:awkmode
# regexp.c is a special case
function AddDeps() {
for (n = 1; n < NF; ++n) {
name = $n;
if ( name == ":" ) {
;
} else {
sub("\.o$", ".c", name);
deps[name] = 1;
}
}
}
BEGIN { count = 0; }
EOF
egrep 'include.*\.c"' regexp.c |
sed -e 's/^#[^"]*"/\/^/' \
-e 's/\.c/\\.o/' \
-e 's/"/\/ { AddDeps(); next; }/' \
>>makedeps.awk
cat >>makedeps.awk <<'EOF'
{ print; }
END {
printf "regexp.o :";
for (name in deps) {
printf " %s", name;
}
printf "\n";
}
EOF
WHINY_USERS=yes ./mawk -f examples/deps.awk *.c | mawk -f makedeps.awk