]>
Commit | Line | Data |
---|---|---|
f6a9480e AC |
1 | #!/bin/sh |
2 | ||
3 | # Try to find a GNU indent. There could be a BSD indent in front of a | |
4 | # GNU gindent so when indent is found, keep looking. | |
5 | ||
6 | gindent= | |
7 | indent= | |
8 | paths=`echo $PATH | sed \ | |
9 | -e 's/::/:.:/g' \ | |
10 | -e 's/^:/.:/' \ | |
11 | -e 's/:$/:./' \ | |
12 | -e 's/:/ /g'` | |
13 | for path in $paths | |
14 | do | |
15 | if test ! -n "${gindent}" -a -x ${path}/gindent | |
16 | then | |
17 | gindent=${path}/gindent | |
18 | break | |
19 | elif test ! -n "${indent}" -a -x ${path}/indent | |
20 | then | |
21 | indent=${path}/indent | |
22 | fi | |
23 | done | |
24 | ||
25 | if test -n "${gindent}" | |
26 | then | |
27 | indent=${gindent} | |
28 | elif test -n "${indent}" | |
29 | then | |
30 | : | |
31 | else | |
32 | echo "Indent not found" 1>&2 | |
33 | fi | |
34 | ||
35 | ||
36 | # Check that the indent found is both GNU and a reasonable version. | |
37 | # Different indent versions give different indentation. | |
38 | ||
3f5a3016 AC |
39 | m1=2 |
40 | m2=2 | |
41 | m3=9 | |
42 | ||
43 | version=`${indent} --version 2>/dev/null < /dev/null` | |
44 | case "${version}" in | |
45 | *GNU* ) ;; | |
46 | * ) echo "error: GNU indent $m1.$m2.$m3 expected" 1>&2 ; exit 1;; | |
f6a9480e | 47 | esac |
3f5a3016 AC |
48 | v1=`echo "${version}" | sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\1/'` |
49 | v2=`echo "${version}" | sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\2/'` | |
50 | v3=`echo "${version}" | sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\3/'` | |
51 | ||
52 | if test $m1 -ne $v1 -o $m2 -ne $v2 -o $m3 -gt $v3 | |
53 | then | |
54 | echo "error: Must be GNU indent version $m1.$m2.$m3 or later" 1>&2 | |
55 | exit 1 | |
56 | fi | |
f6a9480e | 57 | |
3f5a3016 AC |
58 | if test $m3 -ne $v3 |
59 | then | |
60 | echo "warning: GNU indent version $m1.$m2.$m3 recommended" 1>&2 | |
61 | fi | |
f6a9480e AC |
62 | |
63 | # Check that we're in the GDB source directory | |
64 | ||
65 | case `pwd` in | |
66 | */gdb ) ;; | |
8efe637d | 67 | */sim/* ) ;; |
f6a9480e AC |
68 | * ) echo "Not in GDB directory" 1>&2 ; exit 1 ;; |
69 | esac | |
70 | ||
71 | ||
72 | # Run indent per GDB specs | |
73 | ||
9b02dd1b AC |
74 | types="\ |
75 | -T FILE \ | |
5378adc4 | 76 | -T bfd -T asection \ |
9b02dd1b AC |
77 | -T prgregset_t -T fpregset_t -T gregset_t \ |
78 | `cat *.h | sed -n \ | |
f6a9480e AC |
79 | -e 's/^.*[^a-z0-9_]\([a-z0-9_]*_ftype\).*$/-T \1/p' \ |
80 | -e 's/^.*[^a-z0-9_]\([a-z0-9_]*_func\).*$/-T \1/p' \ | |
81 | -e 's/^typedef.*[^a-zA-Z0-9_]\([a-zA-Z0-9_]*[a-zA-Z0-9_]\);$/-T \1/p' \ | |
82 | | sort -u`" | |
83 | ||
84 | ${indent} ${types} "$@" |