#!/bin/bash

# 1 - find bad application definitions
LIBRARIES=`find . -name options | xargs grep -e '^LIB_LIBS' -sl`

#go through the list and check which are "damaged"
echo "List of libraries that are misconfigured" >&2
for item in $LIBRARIES; do
  if [ "$(basename ${item%/*})" = "Make" -a -z "`grep -e "^LIB" ${item%/*}/files`" ]; then
    echo ${item%/*}
  fi
done


# 2 - find bad application definitions
APPLICATIONS=`find . -name options | xargs grep -e '^EXE_LIBS' -sl`

#go through the list and check which are "damaged"
echo "List of applications that are misconfigured" >&2
for item in $APPLICATIONS; do
  if [ "$(basename ${item%/*})" = "Make" -a -z "`grep -e "^EXE" ${item%/*}/files`" ]; then
    echo ${item%/*}
  fi
done
