#! /bin/bash
#------------------------------------------------------------------------------
#$Author: saulius $
#$Date: 2017-11-23 14:18:17 +0000 (Thu, 23 Nov 2017) $
#$Revision: 3870 $
#$URL: file:///home/saulius/svn-repositories/paskaitos/VU/software/assignment-evaluation/trunk/scripts/do-check--makefile $
#------------------------------------------------------------------------------
#*
# Check that exactely one Makefile is present.
#**

set -ue
## set -x

DIRECTORY="$1"

ID='$Id: do-check--makefile 3870 2017-11-23 14:18:17Z saulius $'

cd "${DIRECTORY}"

COUNT=$(find . \
             -name .svn -prune -o \
             -name .git -prune -o \
             \( \
                 -type f -o \
                 -type l \
             \) \
             -a \
             \( \
                 -name makefile -o \
                 -name Makefile -o \
                 -name GNUmakefile \
             \) \
             -print | wc -l)

## echo $0: COUNT=$COUNT >&2

if [ $COUNT -ne 1 ]
then
    
cat <<EOF
-- [AUTO;INTERFACE;$(echo $ID | sed 's/\$//g')]
   Jūsų projekto direktorija turi turėti lygiai vieną failą arba
   simbolinę nuorodą vardu 'Makefile', 'makefile' arba
   'GNUmakefile'. Pateikite atitinkamą Makefile'ą su testavimo
   sistema. (-30 balų);

EOF

fi
