* lisp/emacs-lisp/subr-x.el (hash-table-keys, hash-table-values): Use cl-loop.
[emacs.git] / build-aux / make-info-dir
blob31548125857ddf416c5cca75e4459d96d2d9c7cb
1 #!/bin/sh
3 ### make-info-dir - create info/dir, for systems without install-info
5 ## Copyright (C) 2013-2016 Free Software Foundation, Inc.
7 ## Author: Glenn Morris <rgm@gnu.org>
8 ## Maintainer: emacs-devel@gnu.org
10 ## This file is part of GNU Emacs.
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.
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.
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/>.
25 ### Commentary:
27 ## Generate info/dir, for systems without install-info.
28 ## Expects to be called from top-level Emacs source directory.
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.
34 ## Header contains non-printing characters, so this is more
35 ## reliable than using awk.
36 cat <"${1?}" || exit
37 shift
39 exec "${AWK-awk}" '
40 function detexinfo() {
41 gsub(/@value{emacsname}/, "Emacs")
42 gsub(/@[^{]*\{/, "")
43 gsub(/}/, "")
45 BEGIN {
46 ntopics = 0
47 topic[ntopics++] = "Texinfo documentation system"
48 topic[ntopics++] = "Emacs"
49 topic[ntopics++] = "Emacs lisp"
50 topic[ntopics++] = "Emacs editing modes"
51 topic[ntopics++] = "Emacs network features"
52 topic[ntopics++] = "Emacs misc features"
53 topic[ntopics++] = "Emacs lisp libraries"
54 topic[ntopics] = "Unknown category"
56 /^@dircategory / {
57 sub(/^@dircategory /, "")
58 detexinfo()
59 for (dircat = 0; dircat < ntopics && topic[dircat] != $0; dircat++)
60 continue;
62 /^@direntry/, /^@end direntry/ {
63 # FIXME do not ignore w32 if OS is w32.
64 if ($0 !~ /^@/ && $0 !~ /w32/) {
65 detexinfo()
66 data[dircat] = data[dircat] $0 "\n"
69 END {
70 for (dircat = 0; dircat <= ntopics; dircat++)
71 if (data[dircat])
72 printf "\n%s\n%s", topic[dircat], data[dircat]
74 ' "${@?}"