]> git.ipfire.org Git - thirdparty/glibc.git/blame - manual/libc-texinfo.sh
Fix trailing space.
[thirdparty/glibc.git] / manual / libc-texinfo.sh
CommitLineData
7a68c94a
UD
1#! /bin/sh
2
6a4888ff
AJ
3OUTDIR=$1
4shift
5
7a68c94a
UD
6# Create libc.texinfo from the chapter files.
7
6a4888ff 8trap "rm -f ${OUTDIR}*.$$; exit 1" 1 2 15
07435eb4 9
6a4888ff 10exec 3>${OUTDIR}incl.$$ 4>${OUTDIR}smenu.$$ 5>${OUTDIR}lmenu.$$
07435eb4
UD
11
12build_menu () {
13 while IFS=: read file node; do
14 echo "@include $file" >&3
15 echo "* $node:: `sed -n 's/^@c %MENU% //p' $file`" >&4
16 $AWK 'BEGIN { do_menu = 0 }
17 /^@node / { sub(/^@node /, ""); sub(/,.*$/, ""); node = $0 }
18 /^@menu/ { printf "\n%s\n\n", node; do_menu = 1; next }
19 /^@end menu/ { do_menu = 0 }
20 do_menu { print }' $file >&5
21 done
22}
7a68c94a 23
07435eb4 24collect_nodes () {
34992338
UD
25 egrep '^(@c )?@node.*Top' "$@" /dev/null | cut -d, -f-2 |
26 sed 's/@c //; s/, /:/; s/:@node /:/; s/ /_/g; s/:/ /g' |
07435eb4
UD
27 $AWK '{ file[$2] = $1; nnode[$2] = $3 }
28 END { for (x in file)
29 if (file[x] != "")
30 print file[x] ":" x, file[nnode[x]] ":" nnode[x] }' |
464d646f 31 $AWK -f tsort.awk | sed 's/_/ /g'
7a68c94a
UD
32}
33
f0baa823
RM
34# Emit "@set ADD-ON" for each add-on contributing a manual chapter.
35for addon in $2; do
36 addon=`basename $addon .texi`
37 echo >&3 "@set $addon"
38done
39
07435eb4
UD
40collect_nodes $1 | build_menu
41
42if [ -n "$2" ]; then
43
44 { echo; echo 'Add-ons'; echo; } >&4
45
34992338
UD
46 egrep '^(@c )?@node.*Top' `echo $2 /dev/null | tr ' ' '\n' | sort` |
47 cut -d, -f1 | sed 's/@c //;s/@node //' | build_menu
07435eb4
UD
48
49fi
50
51{ echo; echo 'Appendices'; echo; } >&4
52
53collect_nodes $3 | build_menu
54
55exec 3>&- 4>&- 5>&-
7a68c94a 56
6a4888ff 57mv -f ${OUTDIR}incl.$$ ${OUTDIR}chapters.texi
7a68c94a 58
07435eb4
UD
59{
60 echo '@menu'
61 $AWK -F: '
62 /^\*/ {
63 printf("%-32s", $1 "::");
64 x = split($3, word, " ");
65 hpos = 34;
66 for (i = 1; i <= x; i++) {
67 hpos += length(word[i]) + 1;
68 if (hpos > 78) {
69 printf("\n%34s", "");
70 hpos = 35 + length(word[i]);
71 }
72 printf(" %s", word[i]);
73 }
74 print ".";
75 }
76
77 !/^\*/ { print; }
6a4888ff 78 ' ${OUTDIR}smenu.$$
7a68c94a 79 cat <<EOF
41713d4e 80* Free Manuals:: Free Software Needs Free Documentation.
a1b36134 81* Copying:: The GNU Lesser General Public License says
7a68c94a 82 how you can copy and share the GNU C Library.
7f2826c8
AJ
83* Documentation License:: This manual is under the GNU Free
84 Documentation License.
7a68c94a
UD
85
86Indices
87
88* Concept Index:: Index of concepts and names.
89* Type Index:: Index of types and type qualifiers.
90* Function Index:: Index of functions and function-like macros.
91* Variable Index:: Index of variables and variable-like macros.
92* File Index:: Index of programs and files.
93
b4d1fd33 94 @detailmenu
7a68c94a
UD
95 --- The Detailed Node Listing ---
96EOF
6a4888ff 97 cat ${OUTDIR}lmenu.$$
b4d1fd33 98 echo '@end detailmenu'
6a4888ff
AJ
99 echo '@end menu'; } >${OUTDIR}top-menu.texi.$$
100mv -f ${OUTDIR}top-menu.texi.$$ ${OUTDIR}top-menu.texi
7a68c94a 101
6a4888ff 102rm -f ${OUTDIR}*.$$