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