#!/bin/sh

# create Makefiles from Make.protos
#
# usage: 
#        CONFIG <architecture> <config> <packList> <tools>
#        CONFIG <architecture> <config>
#        CONFIG <architecture>
#        CONFIG
#        CONFIG ?
#
# $Header: /archiv/stx/stx/CONFIG,v 1.83 2003/02/04 13:05:34 cg Exp $
#
# this script recursively visits all directories and creates Makefiles
# from Make.proto files.
#
# to do so, each Make.proto must have a "ALLSUBDIRS=" line
# which names all directories which are to be included
# in the visit.
#
#
# Makefiles are created by concatenating:
#    rules/stdHeader, 
#    configurations/COMMON/defines,
#    configurations/architecture/COMMON/defines,
#    configurations/architecture/config/defines,
#    configurations/PACKS/packList,
#    [ configurations/COMMON/tools ] - optional,
#    rules/stdHeader2, 
#    <your Make.proto>
#    rules/stdRules
#

DEFAULT_PACK=gl

#
# optimistic ...
#
hasSymbolicLinks=1

#
# redefined below ...
#
MAKE=make
YACC=yacc

#
# need to know what this is ...
#
#
# some machines do not have uname (mhmh NeXT - that one is a must)
#
if uname >/dev/null 2>/dev/null; then
    hasUNAME=1;
else
    hasUNAME=0;
fi

#
# is gcc available ?
#
if gcc --version >/dev/null 2>/dev/null; then
    hasGCC=1;
else
    hasGCC=0;
fi

#
# is make available ?
#
if type make >/dev/null 2>/dev/null; then
    hasMake=1
else
    hasMake=0
fi

#
# is gmake available ?
#
if type gmake >/dev/null 2>/dev/null; then
    hasGNUMake=1
    MAKE=gmake
else
    hasGNUMake=0
fi

#
# is make actually a gmake ?
#
if [ "$hasGNUMake" = "0" ]; then
    if [ "$hasMake" != "0" ]; then
	if make --version 2>&1 | grep GNU >/dev/null 2>/dev/null; then
	    hasGNUMake=1;
	else
	    hasGNUMake=0;
	fi
    fi
fi

#
# cannot build without any make
#
if [ "$hasGNUMake" = "0" ]; then
    if [ "$hasMake" = "0" ]; then
	echo "Neither 'make' nor 'gmake' found."
	echo "Build not possible."
	exit 1
    fi
else
    MAKEFLAGS=--no-print-directory
fi

if type yacc >/dev/null 2>/dev/null; then
    YACC=yacc
else
    if type bison >/dev/null 2>/dev/null; then
	YACC=bison
    else
	echo "Neither 'yacc' nor 'bison' found."
	echo "Build not possible."
	exit 1
    fi
fi

export YACC
if [ "$YACC" = "bison" ]; then
    CONF_TOOLS=tools_gnu
fi

if [ "$hasUNAME" = "0" ]; then
#
#   try NeXT - known to have no uname
#
    if [ -d /NextAdmin ]; then
	UNAME=NeXT3
	echo "Assuming this is a NeXT running NS3.x"
	hasGNUMake=0
	MAKE=make
        MAKEFLAGS=
    fi

    if [ "$UNAME" = "" ]; then
	echo "cannot figure out the type of this system."
	echo "You have to manually configure things."
	exit 1
    fi
else
    UNAME=`uname`
fi

export MAKE

#
# SunOS and realIX have a broken 'expr' in the shell ... bad bad bad.
#
case $UNAME in
    SunOS)
	hasBrokenExpr=1
	;;

    realix)
	hasBrokenExpr=1
	;;

    IRIX)
	hasBrokenExpr=1
	;;

    FreeBSD)
	hasBrokenExpr=1
	;;

    *)
	hasBrokenExpr=0
	;;
esac


if [ "$1" = "auto" ]
then
#    heuristics - for now.
#    the explicit system versions are known to work (without trouble ?)
#    Maybe we should change this to use autoconfig ...
#

    if [ "$2" != "" ]
    then
        echo "Set default pack for auto configuration to $2";
	DEFAULT_PACK=$2;
    fi

    case $UNAME in
	OSF1)
	    case `uname -m` in
		alpha)
		    if [ $hasGCC = 1 ]; then
			./CONFIG dec alpha-osf-gcc $DEFAULT_PACK $CONF_TOOLS
		    else
			./CONFIG dec alpha-osf $DEFAULT_PACK $CONF_TOOLS
		    fi
		    ;;

		vax)
		    ./CONFIG dec vax-osf $DEFAULT_PACK $CONF_TOOLS
		    ;;

		mips)
		    ./CONFIG dec mips-osf $DEFAULT_PACK $CONF_TOOLS
		    ;;

		*)
		    echo "mhmh - not an alpha - assume alpha"
		    ./CONFIG dec alpha-osf $DEFAULT_PACK $CONF_TOOLS
		    ;;
	    esac
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	QNX)
	    if [ $hasGCC = 1 ]; then
	        ./CONFIG qnx gcc $DEFAULT_PACK $CONF_TOOLS
	    else
	        ./CONFIG qnx watcom $DEFAULT_PACK $CONF_TOOLS
	    fi
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	NeXT3)
	    ./CONFIG NeXT ns3-cc $DEFAULT_PACK $CONF_TOOLS
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	SunOS)
	    case `uname -r` in
		4.*)
		    if [ $hasGCC = 1 ]; then
			./CONFIG sun sun4-sunos-sep $DEFAULT_PACK $CONF_TOOLS
		    else
			echo "Non-gcc configuration for Sun4 is not available.";
			exit 1
		    fi
		    ;;

		5.*)
		    if [ $hasGCC = 1 ]; then
			./CONFIG sun sun5-solaris-gcc $DEFAULT_PACK $CONF_TOOLS;
		    else
			echo "Non-gcc configuration for Sun5 is not available.";
			exit 1
		    fi
		    ;;
	    esac
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	FreeBSD)
	    case `uname -r` in
		4.5*)
		    ./CONFIG freeBSD opt $DEFAULT_PACK $CONF_TOOLS
		    ;;

		*)
	            echo "mhmh - a FreeBSD Unix - only 4.5 release supported..."
		    ./CONFIG freeBSD opt $DEFAULT_PACK $CONF_TOOLS
		    ;;
	    esac
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	Linux)
	    case `uname -r` in
		*)
		    case `file /bin/rmdir` in
			*ELF*)
			    echo "mhmh - an ELF linux"
			    echo "- looks like a good system to work with."
			    case `gcc --version` in
				*3.2*)
		    	    	    echo "mhmh - assume gcc has PIC bug..."
				    ./CONFIG linux-elf opt-cs-oc-gcc_PIC_BUG $DEFAULT_PACK $CONF_TOOLS
				    ;;

				*)
		    	    	    echo "mhmh - assume gcc works ok..."
				    ./CONFIG linux-elf opt-cs-oc $DEFAULT_PACK $CONF_TOOLS
				    ;;
			    esac
			    ;;

			*)
			    echo "mhmh - a non-ELF linux - assuming a.out"
		    	    echo "mhmh - assume gcc works ok..."
			    echo "- looks like a good system to work with."
			    ./CONFIG linux opt-cs-oc-sep $DEFAULT_PACK $CONF_TOOLS
			    ;;
		    esac
		    ;;
	    esac
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	realix)
	    case `uname -r` in
		V.3.2)
		    echo "well - a realix - your problem"
		    ./CONFIG motorola realIX-gcc-opt $DEFAULT_PACK $CONF_TOOLS
		    ;;

		*)
		    echo "well - lets see if it works with that realix too ..."
		    ./CONFIG motorola realIX-gcc-opt $DEFAULT_PACK $CONF_TOOLS
		    ;;
	    esac
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	UNIX_SV | UnixWare)
	    case `uname -r` in
		5)
		    case `gcc --version` in
			*2.9* | 3.2*)
		    	    echo "mhmh - assume gcc has PIC bug..."
			    if [ -f /usr/include/X11/Xlib.h ]; then
		   	        ./CONFIG unixware gcc-sl-oc-gcc_PIC_BUG $DEFAULT_PACK $CONF_TOOLS;
			    else
		   	        ./CONFIG unixware gcc-sl-oc-gcc_PIC_BUG-NO_XINCLUDE $DEFAULT_PACK $CONF_TOOLS;
			    fi
			    ;;

			*)
		    	    echo "mhmh - assume gcc works ok..."
			    if [ -f /usr/include/X11/Xlib.h ]; then
		   	        ./CONFIG unixware gcc-sl-oc $DEFAULT_PACK $CONF_TOOLS;
			    else
		   	        ./CONFIG unixware gcc-sl-oc-NO_XINCLUDE $DEFAULT_PACK $CONF_TOOLS;
			    fi
			    ;;
		    esac
		    ;;

		4.2MP)
		    echo "a sys5.4 system. ok, that one is known to work ..."
		    ./CONFIG unixware gcc-sl-oc $DEFAULT_PACK $CONF_TOOLS
		    ;;
		*)
		    echo "mhmh - lets see if it works with that SYSV4 too ..."
		    ./CONFIG unixware gcc-sl-oc $DEFAULT_PACK $CONF_TOOLS
		    ;;
	    esac
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	IRIX)
	    case `uname -r` in
		5.2)
		    echo "an IRIX5.2"
		    ./CONFIG sgi iris5-cs-oc $DEFAULT_PACK $CONF_TOOLS
		    ;;

		5.3)
		    echo "an IRIX5.3"
		    ./CONFIG sgi iris5-gcc standard $CONF_TOOLS
		    ;;

		5.*)
		    echo "mhmh - I guess the 5.2 setup should work too ..."
		    ./CONFIG sgi iris5-cs-oc $DEFAULT_PACK $CONF_TOOLS
		    ;;

		4.*)
		    echo "Old IRIX4.x releases are no longer supported"
		    exit 1 
		    ;;

		*)
		    echo "mhmh - lets try the 5.2 settings ..."
		    ./CONFIG sgi iris5-cs-oc $DEFAULT_PACK $CONF_TOOLS
		    ;;
	    esac
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	HP-UX)
	    echo "huh! - an HP-UX..."
	    case `uname -r` in
		A.09.01)
		    echo "well, well an oldish SYSV3 type of unix ..."
		    echo " -- sorry; HP does not provide Xt/Xaw include files"
		    echo " -- therefore, there is no Xt / html support."
		    ./CONFIG hp hppa gl $CONF_TOOLS
		    ;;

		*.09.*)
		    echo "donnu of that works ... lets try old hpux 9.x settings"
		    ./CONFIG hp hppa gl $CONF_TOOLS
		    ;;

		B.10.*)
		    echo "well, marginally better than 9.x HP-UXes (but not much ;-( ..."
		    ./CONFIG hp hppa10 gl $CONF_TOOLS
		    ;;

		*.10.*)
		    echo "donnu of that works ... lets try hpux 10.x settings"
		    ./CONFIG hp hppa10 gl $CONF_TOOLS
		    ;;

		*)
		    echo "donnu of that works ... lets try old hpux settings"
		    ./CONFIG hp hppa-oc gl $CONF_TOOLS
		    ;;
	    esac
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	AIX)
	    case `uname -r` in
		2)
		    case `uname -v` in
			3)
			    echo "an AIX3.2"
			    echo "that one is known to work ... (somehow)"
			    if [ $hasGCC = 1 ]; then
				echo "Found gcc - using it."
				./CONFIG aix aix3.2-shared-gcc $DEFAULT_PACK $CONF_TOOLS;
			    else
				./CONFIG aix aix3.2-cs-opt-sep-shared $DEFAULT_PACK $CONF_TOOLS
			    fi
			    ;;

			4)
			    echo "a 2.4 AIX"
			    echo "that has never been tested ..."
			    echo "... lets try the 2.3 settings ..."
			    if [ $hasGCC = 1 ]; then
				echo "Found gcc - using it."
				./CONFIG aix aix3.2-shared-gcc $DEFAULT_PACK $CONF_TOOLS;
			    else
				./CONFIG aix aix3.2-cs-opt-sep-shared $DEFAULT_PACK $CONF_TOOLS
			    fi
			    ;;

			*)
			    echo "lets try the 2.3 settings ..."
			    if [ $hasGCC = 1 ]; then
				echo "Found gcc - using it."
				./CONFIG aix aix3.2-shared-gcc $DEFAULT_PACK $CONF_TOOLS;
			    else
				./CONFIG aix aix3.2-cs-opt-sep-shared $DEFAULT_PACK $CONF_TOOLS
			    fi
			    ;;
		    esac
		    ;;

		*)
		    echo "lets try the 2.3 settings ..."
		    ./CONFIG aix aix3.2-cs-opt-sep-shared $DEFAULT_PACK $CONF_TOOLS
		    ;;
	    esac
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	ULTRIX)
	    if [ `uname -m` != RISC ]
	    then
		echo "for now, only the mips version is tested."
		exit 1
	    fi

	    case `uname -r` in
		4.4)
		    echo "an ultrix4.4"
		    echo "the last of decs ultrix's ..."
		    ./CONFIG dec mips-ultrix4.4-sl $DEFAULT_PACK $CONF_TOOLS
		    ;;

		4.3)
		    echo "an ultrix4.3 - need manual help for xt system"
		    ./CONFIG dec mips-ultrix4.3-sl gl $CONF_TOOLS
		    ;;

		*)
		    echo "mhmh - stx was never tested on that system."
		    echo "lets try the 4.4 settings ..."
		    ./CONFIG dec mips-ultrix4.4-sl standard $CONF_TOOLS
		    ;;
	    esac
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

	CYGWIN32/95)
	    echo "mhmh - a WIN95 box, with cygwin32 gcc installed."
	    echo "I'll do my very best ..."
	    hasSymbolicLinks=0
	    export MAKE=gmake
	    ./CONFIG NT cygwin32-gcc gl $CONF_TOOLS
	    if [ "$2" != "noMake" ]; then
		$MAKE $MAKEFLAGS initialTarget
	    fi
	    exit 0
	    ;;

    esac

    if [ "$(OSTYPE)" = "win32" ]; then
	echo "looking for borland-C ..."
    fi
    echo "no automatic configuration for that machine."
    shift
fi

if [ "$1" = "?" ]
then
    if [ ! -f Makefile ]; then
	echo "not yet configured."
	exit 0
    fi

    l1=`grep "^CONF=" Makefile`
    l2=`grep "^CONF_PACKS=" Makefile`
    l3=`grep "^CONF_TOOLS=" Makefile`
    case $l1 in
	CONF=*)
	    ok=1 ;;

	*)
	    ok=0 ;;
    esac

    if [ $ok = 1 ]; then
	if [ $hasBrokenExpr = 1 ]; then
	    pack=`grep "^CONF_PACKS=" Makefile | sed "s/CONF_PACKS=//"`
	    tools=`grep "^CONF_TOOLS=" Makefile | sed "s/CONF_TOOLS=//"`
	    system=`grep "^CONF_VENDOR=" Makefile | sed "s/CONF_VENDOR=//"`
	    conf=`grep "^CONF=" Makefile | sed "s/CONF=//"`
	else
	    idx=`expr index "$l1" "\\/" `
	    len=`expr $idx - 1 - 5`
	    idx=`expr $idx + 1 `
	    system=`expr substr "$l1" 6 "$len" `
	    conf=`expr substr "$l1" "$idx" "99" `
	    pack=`expr substr "$l2" 12 "99" `
	    tools=`expr substr "$l2" 12 "99" `
	fi

	echo "the current configuration is:"
	echo "   vendor: "$system
	echo "     conf: "$conf
	echo "     pack: "$pack
	echo "    tools: "$tools
    else
	echo "not yet configured correctly."
    fi
    exit 0
fi

#
# find out how to echo without newline
#
if [ "-n"x = `echo -n`x ]; then
	NL=
	NL1="\c"
else
	NL="-n"
	NL1=
fi

if [ "$1" = "" ]; then
    if [ ! -f configurations/myConf ]; then
# mhmh - a clean distribution; try to figure out what that is ...
#
	echo "Assume this is a clean distribution"
	echo "trying to auto-configure 'CONFIG auto' ..."
	./CONFIG auto
	exit
    fi

    echo "This is not a clean distribution."
    echo "To reconfigure, either give explicit target arguments,"
    echo "or force auto-configuration with 'CONFIG auto [packList]'."
    echo
    echo "usage: $0 <vendor> <configuration> [<packList>]"
    echo "to get the current configuration, use: $0 ?"
    echo
    echo "Type return for a list of available configurations"
    read dummy

    if [ -r configurations/myConf ]; then
	echo
	./CONFIG \?
#      echo "the current configuration is:"
#      head -1 configurations/myConf
    fi

    echo
    echo "available vendors / configurations are:"
    echo
    cd configurations
    for i in *
    do
      ignore=1
      case $i in
	conf.inc)
		;;
	myConf)
		;;
	vendorConf)
		;;
	myPack)
		;;
	myTools)
		;;
	COMMON)
		;;
	RCS)
		;;
	CVS)
		;;
	PACKS)
		;;
	Make.proto)
		;;
	Makefile)
		;;
	obsolete)
		;;
	not_delivered)
	        ;;
	*)
	      ignore=0
		;;
      esac
      if [ $ignore = 0 ]
      then
	 echo vendor: $i
	 cd $i
#        echo $NL "    " $NL1
                
	 first=y
	 for j in *
	 do
	     ignore=1
	     case $j in
		README)
			;;
		COMMON)
			;;
		SUGGESTED)
			;;
		RCS)
			;;
		obsolete)
			;;
		CVS)
			;;
		Make.proto)
			;;
		Makefile)
			;;
		*)
			ignore=0
			;;
	     esac
	     if [ $ignore = 0 ]
	     then
#                if [ $first = "n" ]
#                then
#                    echo $NL " , " $NL1
#                fi
#                first=n
#                echo $NL $j $NL1

		 echo $NL "    " $NL1
		 echo $j
	     fi
	 done
	 echo
	 echo
	 cd ..
      fi
    done | more
    cd ..

    if [ -d configurations/PACKS ]
    then
      echo
      echo "available package lists are:"
      echo
      cd configurations/PACKS 
      for i in *
      do
	case $i in
	    not_delivered)
		;;
	    README)
		;;
	    RCS)
		;;
	    CVS)
		;;
	    Make.proto)
		;;
	    Makefile)
		;;
	    *)
		echo $NL "    " $NL1
		echo $i
		echo $NL "        " $NL1
		(sh -c 'read skip name info; echo $info') < $i
		echo
		;;
	  esac
      done | more
      cd ../..
    fi

    exit 1
fi

if [ "$2" != "" ]
then
#   echo $1 $2 $3
    if [ -r configurations/$1/$2/defines ]
    then
	echo "Setting up everything for:"
	echo
	echo $NL "    " $NL1
	(sh -c 'read skip name; echo $name') < configurations/$1/$2/defines
	echo
	rm -f configurations/myConf
	rm -f configurations/vendorConf
	rm -f configurations/myPack 
	rm -f configurations/myTools 
	(cd configurations; ln -s $1/$2/defines myConf)
	(cd configurations; ln -s $1/COMMON/defines vendorConf)
	echo "creating initial TOP Makefile ..."
	echo
	cat rules/stdHeader > Makefile
	if [ -r configurations/COMMON/defines ]; then
	    cat configurations/COMMON/defines >> Makefile
	fi
	if [ -r configurations/$1/COMMON/defines ]; then
	    cat configurations/$1/COMMON/defines >> Makefile
	fi
	if [ "$4" != "" ]; then
	  if [ -r configurations/COMMON/$4 ]; then
	    (cd configurations; ln -s COMMON/$4 myTools)
	    cat configurations/COMMON/$4 >> Makefile
	  fi
	fi
	cat configurations/$1/$2/defines >> Makefile
	if [ "$3" != "" ]; then
	  if [ -r configurations/PACKS/$3 ]; then
	    (cd configurations; ln -s PACKS/$3 myPack)
	    cat configurations/PACKS/$3  >> Makefile
	  fi
	fi
	cat rules/stdHeader2             >> Makefile
	cat Make.proto                   >> Makefile
	echo                             >> Makefile
	echo "CONF=$1/$2"                >> Makefile
	echo "CONF_VENDOR=$1"            >> Makefile
	echo "CONF_PACKS=$3"             >> Makefile
	echo "CONF_TOOLS=$4"             >> Makefile
	echo                             >> Makefile

	echo "CONF=$1/$2"                >  configurations/conf.inc
	echo "CONF_VENDOR=$1"            >> configurations/conf.inc
	echo "CONF_PACKS=$3"             >> configurations/conf.inc
	echo "CONF_TOOLS=$4"             >> configurations/conf.inc

	cat rules/stdRules               >> Makefile

#
# need stc first, for makeDepend to work
#
	echo "recreate Makefile (using Makefile) ..."
	echo
	$MAKE $MAKEFLAGS mf
	echo "create Makefile in stc ..."
	echo
	$MAKE $MAKEFLAGS subMakefiles ALLSUBDIRS=stc
	(cd stc ; $MAKE $MAKEFLAGS mf)
	echo "generate stc ..."
	echo
	(cd stc ; $MAKE $MAKEFLAGS)
#
# see if stc was built
#
	if stc/stc --version >/dev/null 2>/dev/null; then
	   echo "stc build ok."
	else
	   echo "Failed to build stc - cannot proceed."
	    exit 1
	fi

	echo "recursively create sub Makefiles ..."
	echo

	$MAKE $MAKEFLAGS qMakefiles

	echo
	echo "*** Makefiles are now created"
	echo
	echo "if this is not a clean installation, consider"
	echo "a 'make depend' and 'make clean' before doing the real make."
	echo "Or, continue with 'make target'."
	exit
    fi
fi

if [ -d configurations/$1 ]
then
    if [ "$2" = "" ]
    then
	echo "usage: $0 <vendor> <configuration> [<packageList]"
    else
	if [ -d configurations/$1/$2 ]
	then
	    echo "error reading configurations/$1/$2/defines."
	else
	    echo "missing configuration configurations/$1/$2."
	fi
    fi
    echo
    ./CONFIG \?
    echo
    echo "available configurations are:"
    echo
    hasReadme=n
    hasSuggested=
    cd configurations/$1
    for j in *
    do
      case $j in
	not_delivered)
	    ;;
	obsolete)
	    ;;
	RCS)
	    ;;
	COMMON)
	    ;;
	CVS)
	    ;;
	Make.proto)
	    ;;
	Makefile)
	    ;;
	README)
	    hasReadme=y
	    ;;
	SUGGESTED)
	    hasSuggested=y
	    ;;
	*)
	    echo "    "$j":"
	    echo $NL "        " $NL1
	    (sh -c 'read skip name info; echo $info') < $j/defines
	    ;;
      esac
    done
    echo
    if [ "$hasReadme" = "y" ]
    then
	echo "see configurations/$1/README for more info"
	echo
    fi 
    if [ "$hasSuggested" = "y" ]
    then
	echo $NL "The suggested configuration for this machine is: " $NL1
	(sh -c 'read skip name info; echo $name') < SUGGESTED/defines
	echo 
    fi
    cd ../..

    if [ -d configurations/PACKS ]
    then
      echo
      echo "available package lists are:"
      echo
      cd configurations/PACKS 
      for i in *
      do
	  case $i in
		not_delivered)
		    ;;
		README)
		    ;;
		RCS)
		    ;;
		CVS)
		    ;;
		Make.proto)
		    ;;
		Makefile)
		    ;;
		*)
		    echo $NL "    " $NL1
		    echo $i
		    echo $NL "        " $NL1
		    (sh -c 'read skip name info; echo $info') < $i
		    echo
		    ;;
	  esac
      done | more
      cd ../..
    fi

else
    echo "no such vendor: " configurations/$1 
    echo
    echo "configurations are available for vendors:"
    echo
    cd configurations
    for i in *
    do
	echo "    " $i
    done
    echo
fi
exit 1
