#!/bin/sh
#
## lecture et interpretation du fichier d'options
#
# Andre Brouty octobre 2006 - Telecom Bretagne
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin
umask 077
OPT=./donnemdp.conf

if [ ! -f $OPT ]
then
	echo "fichier d'options $OPT absent!"
	exit
fi

dev=`grep "^device" $OPT | awk '{print $2}'`
str=`grep "^stracecon" $OPT | awk '{print $2}'`
argt=`grep "^traceargs" $OPT | sed 's/traceargs//'`
strn=`grep "^stracename" $OPT | awk '{print $2}'`
shn=`grep "^shellname" $OPT | awk '{print $2}'`
md5=`grep "^stracemd5" $OPT | awk '{print $2}'`

if [ $dev -a $dev = "no" ]
then
    CONTROLD="-DDEVICEC"
    export CONTROLD
fi

if [ $str -a $str = "no" ]
then
    CONTROLT="-DSTRACEC"
    export CONTROLT
fi

if [ "$argt" ]
then
    CONTROLA="-DARGNAME=\"\\\"$argt\"\\\""
    export CONTROLA
fi

if [ $strn ]
then
    if ["$CONTROLT" ]
    then
    	CONTROLTN="-DTRACENAME"
    	export CONTROLTN
    fi
fi

if [ "$shn" ]
then
    CONTROLS="-DSHELLNAME=\\\"$shn\\\""
    export CONTROLS
fi

if [ $md5 -a  $md5 = "yes" ]
then
    CONTROLM="-DSCRIPTMD5"
    export CONTROLM
fi

make
