]>
Commit | Line | Data |
---|---|---|
48d0341c | 1 | #!/bin/sh |
7a68c94a | 2 | |
6a4888ff AJ |
3 | OUTDIR=$1 |
4 | shift | |
5 | ||
7a68c94a UD |
6 | # Create libc.texinfo from the chapter files. |
7 | ||
6a4888ff | 8 | trap "rm -f ${OUTDIR}*.$$; exit 1" 1 2 15 |
07435eb4 | 9 | |
6a4888ff | 10 | exec 3>${OUTDIR}incl.$$ 4>${OUTDIR}smenu.$$ 5>${OUTDIR}lmenu.$$ |
07435eb4 UD |
11 | |
12 | build_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 | 24 | collect_nodes () { |
7df596a5 | 25 | grep -E '^(@c )?@node.*Top' "$@" /dev/null | cut -d, -f-2 | |
34992338 | 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 | ||
07435eb4 UD |
34 | collect_nodes $1 | build_menu |
35 | ||
07435eb4 UD |
36 | { echo; echo 'Appendices'; echo; } >&4 |
37 | ||
644d3857 | 38 | collect_nodes $2 | build_menu |
07435eb4 UD |
39 | |
40 | exec 3>&- 4>&- 5>&- | |
7a68c94a | 41 | |
6a4888ff | 42 | mv -f ${OUTDIR}incl.$$ ${OUTDIR}chapters.texi |
7a68c94a | 43 | |
07435eb4 UD |
44 | { |
45 | echo '@menu' | |
46 | $AWK -F: ' | |
47 | /^\*/ { | |
48 | printf("%-32s", $1 "::"); | |
49 | x = split($3, word, " "); | |
50 | hpos = 34; | |
51 | for (i = 1; i <= x; i++) { | |
52 | hpos += length(word[i]) + 1; | |
53 | if (hpos > 78) { | |
54 | printf("\n%34s", ""); | |
55 | hpos = 35 + length(word[i]); | |
56 | } | |
57 | printf(" %s", word[i]); | |
58 | } | |
59 | print "."; | |
60 | } | |
61 | ||
62 | !/^\*/ { print; } | |
6a4888ff | 63 | ' ${OUTDIR}smenu.$$ |
7a68c94a | 64 | cat <<EOF |
41713d4e | 65 | * Free Manuals:: Free Software Needs Free Documentation. |
a1b36134 | 66 | * Copying:: The GNU Lesser General Public License says |
7a68c94a | 67 | how you can copy and share the GNU C Library. |
7f2826c8 AJ |
68 | * Documentation License:: This manual is under the GNU Free |
69 | Documentation License. | |
7a68c94a UD |
70 | |
71 | Indices | |
72 | ||
73 | * Concept Index:: Index of concepts and names. | |
74 | * Type Index:: Index of types and type qualifiers. | |
75 | * Function Index:: Index of functions and function-like macros. | |
76 | * Variable Index:: Index of variables and variable-like macros. | |
77 | * File Index:: Index of programs and files. | |
78 | ||
b4d1fd33 | 79 | @detailmenu |
7a68c94a UD |
80 | --- The Detailed Node Listing --- |
81 | EOF | |
6a4888ff | 82 | cat ${OUTDIR}lmenu.$$ |
b4d1fd33 | 83 | echo '@end detailmenu' |
6a4888ff AJ |
84 | echo '@end menu'; } >${OUTDIR}top-menu.texi.$$ |
85 | mv -f ${OUTDIR}top-menu.texi.$$ ${OUTDIR}top-menu.texi | |
7a68c94a | 86 | |
6a4888ff | 87 | rm -f ${OUTDIR}*.$$ |