OSDN Git Service

Makefile for i?86-pc-msdosdjgpp
[pf3gnuchains/gcc-fork.git] / texinfo / gen-info-dir
1 #!/bin/sh
2 #
3 # generate an Info directory, given a directory of Info files and a
4 # list of entries.  The output will be suitable for a dir.info file,
5 # in the order given in the skeleton file
6
7 INFODIR=$1
8 if [ $# = 2 ] ; then
9   SKELETON=$2
10 else
11   SKELETON=/dev/null
12 fi
13
14 skip=
15
16 if [ $# -gt 2 ] ; then
17   echo usage: $0 info-directory [ skeleton-file ] 1>&2
18   exit 1
19 else
20   true
21 fi
22
23 if [ ! -d ${INFODIR} ] ; then
24   echo "$0: first argument must specify a directory"
25   exit 1
26 fi
27
28 infofiles=`(cd ${INFODIR}; ls *.info | sort | sed "s/dir\.info//")`
29 template=`cat ${SKELETON}`
30
31 ### output the dir.info header
32 echo "-*- Text -*-"
33 echo "This file was generated automatically by the gen-info-dir script."
34 echo "This version was generated on `date`"
35 echo "by `whoami`@`hostname` for `(cd ${INFODIR}; pwd)`"
36
37 cat << moobler
38
39 This is the file .../info/dir, which contains the topmost node of the
40 Info hierarchy.  The first time you invoke Info you start off
41 looking at that node, which is (dir)Top.
42 \1f
43 File: dir       Node: Top       This is the top of the INFO tree
44   This (the Directory node) gives a menu of major topics. 
45   Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h" 
46   gives a primer for first-timers, "mTexinfo<Return>" visits Texinfo topic,
47   etc.
48   --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) ---
49
50 * Menu: The list of major topics begins on the next line.
51
52 moobler
53
54
55 ### go through the list of files in the template.  If an info file
56 ### exists, grab the ENTRY information from it.  If there is no entry
57 ### info, then create a minimal dir entry, otherwise use the given info.
58 ###
59 ### Then remove that file from the list of existing files.  If any
60 ### additional files remain (ones that don't have a template entry), 
61 ### then generate entries for those in the same way, putting the info for 
62 ### those at the very end....
63
64 for file in ${template} ; do
65   if [ "${file}" = "--" ] ; then
66     skip=1
67   else
68     if [ -f ${INFODIR}/${file}.info ] ; then
69       entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}.info`
70       if [ ! -z "${skip}" ] ; then
71         echo
72         skip=
73       fi
74
75       if [ ! -z "${entry}" ] ; then
76         echo "${entry}"
77       else
78         echo "* ${file}: (${file})."
79       fi
80
81       infofiles=`echo ${infofiles} | sed -e "s/${file}\.info//"`
82     fi
83   fi 
84 done
85
86 if [ -z "${infofiles}" ] ; then
87   exit 0
88 else
89   echo
90 fi
91
92 for file in ${infofiles}; do
93   entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}`
94
95   if [ ! -z "${entry}" ] ; then
96     echo "${entry}"
97   else
98     echo "* ${file}: (${file})."
99   fi
100 done
101