-
Notifications
You must be signed in to change notification settings - Fork 1
/
gendep
executable file
·75 lines (57 loc) · 824 Bytes
/
gendep
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
#!/bin/bash
# This script is used to regenerate Makefile.dep using a sequence
# like this:
#
# $ ./configure
# $ make CFLAGS=-MMD
# $ gendep > Makefile.dep
mk_dep_list ()
{
local line
local f
while read line ; do
line=${line/:/}
for f in $line ; do
echo "$f"
done
done
}
mk_dep_sort ()
{
local tgt src
read tgt
read src
echo "$tgt"
echo "$src"
sort -u
}
mk_dep_rule ()
{
local tgt src
read tgt
read src
printf "%s: %s" "$tgt" "$src"
while read src ; do
printf " \\\\\\n"
printf "\\t%s" "$src"
done
printf "\\n"
}
mk_dep ()
{
local src=$1
cat "$src" |\
mk_dep_list |\
grep "^src/" |\
mk_dep_sort |\
mk_dep_rule
}
echo "# Makefile.dep"
echo "#"
echo "# This file was generated by gendep"
find . -type f -name "*.d" |\
sort |\
while read src ; do
echo
mk_dep "$src"
done