#!/bin/csh
# Moritz Willers
# 13. August 1993
# Version 0.1
#
echo ""
echo "Let's see whether you've got ispell"
ispell -vv > /dev/null
if ($status) then
    echo "You must first install ispell before you can run this skript"
    exit 0
endif
echo "Ok"

echo ""
echo "Looking for your hash files"
set LIBDIR = `ispell -vv | grep LIBDIR | awk '{print $3}' | sed 'y/"/ /'`
set files = `ls ${LIBDIR}`
echo "There are:"
foreach file ($files)
    if ($file:e == "hash") then
	echo "      $file"
    endif
end

if (-d ~/Library/Services) then
else
    mkdir ~/Library/Services
endif

foreach file ($files)
    if ($file:e == "hash") then
	set name = ${file:r}spell
	echo ""
	echo "Making $name ..."
	switch ($file:r)
	    case english:
		echo "Spell Checker: ispell" > services
		echo "Language: English" >> services
		echo "Executable: $name" >> services
		
		echo '#define VENDOR "ispell"' > configure.h
		echo '#define LANGUAGE "English"' >> configure.h
		echo '#define ISPELL "ispell", "ispell", "-a"' >> configure.h
		make install NAME=$name > /dev/null
		breaksw

	    case french:
		echo "Spell Checker: ispell" > services
		echo "Language: French" >> services
		echo "Executable: $name" >> services
		
		echo '#define VENDOR "ispell"' > configure.h
		echo '#define LANGUAGE "French"' >> configure.h
		echo '#define ISPELL "ispell", "ispell", "-a", "-dfrench", "-TNeXT"' >> configure.h
		make install NAME=$name > /dev/null
		breaksw

	    case german:
		echo "Spell Checker: ispell" > services
		echo "Language: German" >> services
		echo "Executable: $name" >> services
		
		echo '#define VENDOR "ispell"' > configure.h
		echo '#define LANGUAGE "German"' >> configure.h
		echo '#define ISPELL "ispell", "ispell", "-a", "-C", "-dgerman", "-TNeXT"' >> configure.h
		make install NAME=$name > /dev/null
		breaksw

	    case italian:
		echo "Spell Checker: ispell" > services
		echo "Language: Italian" >> services
		echo "Executable: $name" >> services
		
		echo '#define VENDOR "ispell"' > configure.h
		echo '#define LANGUAGE "Italian"' >> configure.h
		echo '#define ISPELL "ispell", "ispell", "-a", "-ditalian", "-TNeXT"' >> configure.h
		make install NAME=$name > /dev/null
		breaksw

	    case portuguese:
		echo "Spell Checker: ispell" > services
		echo "Language: Portuguese" >> services
		echo "Executable: $name" >> services
		
		echo '#define VENDOR "ispell"' > configure.h
		echo '#define LANGUAGE "Portuguese"' >> configure.h
		echo '#define ISPELL "ispell", "ispell", "-a", "-dportuguese", "-TNeXT"' >> configure.h
		make install NAME=$name > /dev/null
		breaksw

	    case spanish:
		echo "Spell Checker: ispell" > services
		echo "Language: Spanish" >> services
		echo "Executable: $name" >> services
		
		echo '#define VENDOR "ispell"' > configure.h
		echo '#define LANGUAGE "Spanish"' >> configure.h
		echo '#define ISPELL "ispell", "ispell", "-a", "-dspanish", "-TNeXT"' >> configure.h
		make install NAME=$name > /dev/null
		breaksw
		
	    case    swedish:
		echo "Spell Checker: ispell" > services
		echo "Language: Swedish" >> services
		echo "Executable: $name" >> services
		
		echo '#define VENDOR "ispell"' > configure.h
		echo '#define LANGUAGE "Swedish"' >> configure.h
		echo '#define ISPELL "ispell", "ispell", "-a", "-dswedish", "-TNeXT"' >> configure.h
		make install NAME=$name > /dev/null
		breaksw
		
	    default:
		echo "Spell Checker: ispell" > services
		echo "Language: $file:r" >> services
		echo "Executable: $name" >> services
		
		echo '#define VENDOR "ispell"' > configure.h
		echo '#define LANGUAGE "'$file:r'"' >> configure.h
		echo '#define ISPELL "ispell", "ispell", "-a", "-d'$file:r'"' >> configure.h
		make install NAME=$name > /dev/null
		echo "$file:r is not a NeXT supported Language"
		echo "I did my best to include it into the spell checker anyway"
		
		breaksw
	endsw
    endif
end
echo ""
echo "Making services ..."
make_services
echo ""
echo "I'm done."
echo ""

