-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap
executable file
·59 lines (51 loc) · 1.38 KB
/
bootstrap
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
#!/bin/sh
set -eu
norm () {
sort | sed 's,^\.\/,,g'
}
real0 () {
grep -q '[ \t]*#[ \t]*include[ \t]*\"real\.h\"' "$1"
}
real () {
while read f
do if real0 "$f"
then printf "%s\n" "$f"
fi
done
}
nreal () {
while read f
do if ! real0 "$f"
then printf "%s\n" "$f"
fi
done
}
format () {
awk -v v="$1" '
BEGIN { printf "%s = \\\n", v }
{
printf "%s\\\n", $0
}
END { printf "%s", "\n" }
'
}
name () {
s=$1; shift
sed -e "s,\.c$,.$s,1" \
-e "s,\.c\.m4$,.$s,1" \
-e "s,\.f$,.$s,1" \
-e "s,\.f90$,.$s,1"
}
hname () { sed -e 's,\.h\.m4$,.h,1'; }
ftn () { find . -name '*.f' -or -name '*.f90' | sort ; }
src () { find . -name '*.c' -or -name '*.c.m4' | sort ; }
hdr () { find . -name '*.h' -or -name '*.h.m4' | sort ; }
hdr | norm | hname | format H > make/hdr.mk
(src | norm | nreal ; ftn | norm) | name o | format O > make/obj.mk
src | norm | real | name s.o | format O_S >> make/obj.mk
src | norm | real | name d.o | format O_D >> make/obj.mk
src | norm | real | name l.o | format O_L >> make/obj.mk
../tool/dep `src | norm | nreal` | ../tool/fmt o > make/dep.mk
../tool/dep `src | norm | real` | ../tool/fmt s.o >> make/dep.mk
../tool/dep `src | norm | real` | ../tool/fmt d.o >> make/dep.mk
../tool/dep `src | norm | real` | ../tool/fmt l.o >> make/dep.mk