#!/bin/sh
# Copyright  1997, Guylhem Aznar (guylhem@danmark.linux.eu.org)
# Freely distribuable under the terms of the GPL license .

# Add menu options
analyse () {

  cd "$CURRENTREP"
  echo "Popup \"$CURRENTREP\"" >> ~/.step/tmp/_%%para$PARAGRAPH

  if [ "$CURRENTREP" = "start" ] ; then
    echo " Title \"Start ...\"" >> ~/.step/tmp/_%%para$PARAGRAPH
  else
    echo " Title \"$CURRENTREP\"" >> ~/.step/tmp/_%%para$PARAGRAPH
  fi

  for FILE in * ; do
    if [ -d "$FILE" ] ; then
    # case directory
       echo " Popup \"$FILE\"   $FILE" >> ~/.step/tmp/_%%para$PARAGRAPH
    elif [ -f "$FILE" ] ; then
    # case file
	if [ "$CURRENTREP" = "Modules" ] ; then
	  echo " Module \"$FILE\" `cat \"$FILE\"`" >> ~/.step/tmp/_%%para$PARAGRAPH
	elif [ "$CURRENTREP" = "Quit ?" ] ; then
	  echo " `cat \"$FILE\"`" >> ~/.step/tmp/_%%para$PARAGRAPH
	else
	  echo " Exec \"$FILE\" exec `cat \"$FILE\"`" >> ~/.step/tmp/_%%para$PARAGRAPH
	fi
     fi
  done

  echo "EndPopup
" >> ~/.step/tmp/_%%para$PARAGRAPH

  PARAGRAPH=`expr $PARAGRAPH - 1`

  for FILE in * ; do
    if [ -d "$FILE" ] ; then
          CURRENTREP=$FILE
          FILE=""
          analyse
          cd ..
    fi
  done
}

cd ~/.step
PARAGRAPH=255
CURRENTREP="start"
analyse

cat ~/.step/tmp/_%%para2* > ~/.step/tmp/startmenu-made
rm ~/.step/tmp/_%%para2*
