#!/bin/sh
# small shell script to frob out the menu lines from info files and
# create a dir.info for them.

if [ "$#" != "1" ] ; then
	echo Usage: $0 directory 1>&2
	exit 1
fi

cat <<'!E!O!F!'
-*- Text -*-
This file was generated automatically by the gen-info-dir script.
!E!O!F!

echo This version was generated on `date`
echo   by `whoami`@`hostname` for `(cd $1 ; pwd)`.

cat <<'!E!O!F!'

This is the file .../info/dir, which contains the topmost node of the
Info hierarchy.  The first time you invoke Info you start off
looking at that node, which is (dir)Top.

File: dir	Node: Top	This is the top of the INFO tree
  This (the Directory node) gives a menu of major topics. 
  Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h" 
  gives a primer for first-timers, "mTexinfo<Return>" visits Texinfo topic,
  etc.
  --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) ---

* Menu: The list of major topics begins on the next line.

!E!O!F!

for i in `find $1 -name \*.info -print` ; do
	sed -e '1,/START-INFO-DIR-ENTRY/d' \
		-e '/END-INFO-DIR-ENTRY/,$d' $i
done

exit 0

# eof
