update makefile
[musl-tables] / maketags.sh
1 #!/bin/sh
2
3 export LC_ALL=C
4 MUSL=${MUSL:-../musl}
5 MUSL_PREFIX=${MUSL_PREFIX:-$MUSL}
6
7 (
8         cd $MUSL_PREFIX/include
9         ctags -f /tmp/musl.tags -R -n -u --language-force=c --c-kinds=pxdstuve --fields=k --exclude='*.sh' .
10
11         # fix wchar_t bug of ctags
12         awk '/typedef.* wchar_t/{print "wchar_t\tbits/alltypes.h\t" NR ";\"\tt"}' bits/alltypes.h >>/tmp/musl.tags
13 )
14
15 awk -v inc=$MUSL_PREFIX/include/ '
16 BEGIN {
17         FS="\t"
18 }
19 function proto(t,h,n) {
20         cmd = "awk '\''NR==" n
21         if (t == "p")
22                 cmd = cmd "{s=$0; if(s!~/;/){getline; s=s \" \" $0} print s; exit}"
23         else if (t == "d")
24                 cmd = cmd "{s=$0; while(gsub(/\\\\$/,\"\",s)){getline; s=s $0} print s; exit}"
25         else
26                 return ""
27         cmd = cmd "'\'' " inc h
28         cmd | getline s
29         close(cmd)
30         gsub(/\t/, " ", s)
31         gsub(/ +/, " ", s)
32         gsub(/ \(/, "(", s)
33         return s
34 }
35 /^[^!]/ {
36         gsub(/[^0-9]*/,"",$3)
37         if ($4 == "s")
38                 $1 = "struct " $1
39         if ($4 == "u")
40                 $1 = "union " $1
41         print $1 "\t" $2 "\t" $4 "\t" $3 "\t" proto($4,$2,$3)
42 }' /tmp/musl.tags |sort >data/musl.tags
43 rm -f /tmp/musl.tags