#!/bin/sh

###########################################################
#
# Licensed Material - Property of IBM
#
# BogoSec - Source Code Security Quality Metric Calculator
#
# (C) Copyright IBM Corp. 2004-2008
#
# FILE   : configure 
#
# PURPOSE: Configure script for Bogosec
#
# HISTORY
#          07/2004 originated by Tony Petz (petz.agoston@gmail.com)
#          02/2005 Dustin Kirkland (dustin.kirkland@us.ibm.com) - search for rpm and rpmbuild binaries
###########################################################

scanners="flawfinder rats"

# By default, assume no scanners found
warn_scanner=1

echo
echo -n checking for Perl interpretter...
which perl > /dev/null 2>&1
if [ $? != 0 ]; then
	echo no
	echo
	echo You must have a Perl interpretter installed to run bogosec... Aborting...
	echo 
	exit 1
else
echo yes
fi

echo -n checking for tar...
which tar > /dev/null 2>&1
if [ $? != 0 ]; then
	echo no
	echo \* tar binary not found... you will not be able to run bogosec on tarballs.
else
echo yes
fi

echo -n checking for gunzip...
which gunzip > /dev/null 2>&1
if [ $? != 0 ]; then
	echo no
	echo \* gunzip binary not found... you will not be able to run bogosec on tar.gz\'s.
else
echo yes
fi

echo -n checking for rpm...
which rpm > /dev/null 2>&1
if [ $? != 0 ]; then
	echo no
	echo \* rpm binary not found... you will not be able to run bogosec on .src.rpm\'s.
else
echo yes
fi

echo -n checking for rpmbuild...
which rpmbuild > /dev/null 2>&1
if [ $? != 0 ]; then
	echo no
	echo \* rpmbuild binary not found... you will not be able to run bogosec on .src.rpm\'s.
else
echo yes
fi

for scanner in $scanners; do
    echo -n checking for $scanner...
    which $scanner > /dev/null 2>&1

    # If found, turn off warning
    if [ $? -eq "0" ]; then
        warn_scanner=0
	    echo yes
    else
	    echo no
    fi
done

if [ $warn_scanner -eq "1" ]; then
    echo \* One or more scanners not found... you must have at least one scanner to run bogosec
fi

echo
