Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / build-aux / make-info-dir
blob56b2f74742a1812bcaf27a7e4e1ac25fd792476b
1 #!/bin/sh
3 ### make-info-dir - create info/dir, for systems without install-info
5 ## Copyright (C) 2013-2014 Free Software Foundation, Inc.
7 ## Author: Glenn Morris <rgm@gnu.org>
9 ## This file is part of GNU Emacs.
11 ## GNU Emacs is free software: you can redistribute it and/or modify
12 ## it under the terms of the GNU General Public License as published by
13 ## the Free Software Foundation, either version 3 of the License, or
14 ## (at your option) any later version.
16 ## GNU Emacs is distributed in the hope that it will be useful,
17 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ## GNU General Public License for more details.
21 ## You should have received a copy of the GNU General Public License
22 ## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ### Commentary:
26 ## Generate info/dir, for systems without install-info.
27 ## Expects to be called from top-level Emacs source directory.
29 ## It only handles the case where info/dir is missing from the
30 ## installation directory. It does not handle info/dir being present
31 ## but missing some entries.
33 ### Code:
35 if test $# -ne 1; then
36 echo "Specify destination file"
37 exit 1
40 outfile=$1
42 echo "Creating $outfile..."
44 if test -f "$outfile"; then
45 echo "$outfile already present"
46 exit 1
49 ## Header contains non-printing characters, so this is more
50 ## reliable than using echo.
51 basefile=build-aux/dir_top
53 if test ! -f "$basefile"; then
54 echo "$basefile not found"
55 exit 1
59 cp $basefile $outfile
62 ## FIXME inefficient looping.
63 ## What we should do is loop once over files, collecting topic and
64 ## direntry information for each. Then loop over topics and write
65 ## out the results. But that seems to require associative arrays,
66 ## and I do not know how to do that with portable sh.
67 ## Could use Emacs instead of sh, but till now info generation does
68 ## not require Emacs to have been built.
69 for topic in "Texinfo documentation system" "Emacs" "Emacs lisp" \
70 "Emacs editing modes" "Emacs network features" "Emacs misc features" \
71 "Emacs lisp libraries"; do
73 cat - <<EOF >> $outfile
75 $topic
76 EOF
77 ## Bit faster than doc/*/*.texi.
78 for file in doc/emacs/emacs.texi doc/lispintro/emacs-lisp-intro.texi \
79 doc/lispref/elisp.texi doc/misc/*.texi; do
81 ## FIXME do not ignore w32 if OS is w32.
82 case $file in
83 *-xtra.texi|*efaq-w32.texi|*doclicense.texi) continue ;;
84 esac
86 dircat=`sed -n -e 's/@value{emacsname}/Emacs/' -e 's/^@dircategory //p' $file`
88 ## TODO warn about unknown topics.
89 ## (check-info in top-level Makefile does that.)
90 test "$dircat" = "$topic" || continue
93 sed -n -e 's/@value{emacsname}/Emacs/' \
94 -e 's/@acronym{\([A-Z]*\)}/\1/' \
95 -e '/^@direntry/,/^@end direntry/ s/^\([^@]\)/\1/p' \
96 $file >> $outfile
98 done
99 done
101 echo "Created $outfile"
103 exit 0
105 ### make-info-dir ends here