#!/bin/sh # Part of EasySQL, Copyright (c) 1997 by Andrew Maltsev # # Configuration utility for EasySQL drivers. Have to be run at least # once (usually from top level configure) #====================================================================== # Asking a question. Answer is in `asnwer' and default value is in `default' # ask () { if [ "x$default" = x ] then default=none fi echo -n "$* ? [$default] " read answer if [ "x$answer" = "x" ] then answer="$default" fi if [ "x$answer" = xnone ] then answer= fi default= } # List of all included drivers # driverlist () { drivers= for i in * do if [ -d "$i" -a -f "$i/Driver" -a "x$i" != "xinclude" ] then echo "$i" fi done } # Reading configs # readconfig () { sed -e '/^[ ]*#/d' \ -e '/^[ ]*$/d' \ -e 's/[ ]*=[ ]*/ /g' \ $configs | while read line do set - $line name=$1 shift value=$* if [ "x$name" = xDRIVERNAME ] || echo "x$name" | grep -q '^xDC_' then echo "$name='$value'" fi done } # Configure driver # driverconf () { drvpath=$1 if [ ! -d "$drvpath" ] then echo "$drvpath -- No such driver found!" exit 1 fi if [ ! -s "$drvpath/Driver" ] then echo "$drvpath -- No driver description found!" exit 1 fi configs="$drvpath/Driver" custconf="$drvpath/.config" if [ -s "$custconf" ] then configs="$configs $custconf" fi DRIVERNAME= eval `readconfig $configs` if [ "x$DRIVERNAME" = "x" ] then echo "$drvpath -- no driver name defined!" exit 1 fi echo "Configuring \`$DRIVERNAME' driver.." echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo if [ -f "$drvpath/.required" ] then default='Y/n' else default='y/N' fi ask "Do you want to compile \`$DRIVERNAME'" if [ "x$answer" != xy -a "x$answer" != xY -a "x$answer" != xY/n ] then rm -f "$drvpath/.required" touch "$drvpath/.config" echo "Ok. Compilation of this driver will be skipped.." echo return fi # Include path # default="$DC_INCPATH" ask "Include path" DC_INCPATH="$answer" # Library path # default="$DC_LIBPATH" ask "Libraries path" DC_LIBPATH="$answer" # Libraries # default="$DC_LIBRARIES" ask "Libraries itself" DC_LIBRARIES="$answer" # Flags # default="$DC_FLAGS" ask "Any additional compilator flags" DC_FLAGS="$answer" # Configuring driver # echo "DC_INCPATH = $DC_INCPATH" > $custconf echo "DC_LIBPATH = $DC_LIBPATH" >> $custconf echo "DC_LIBRARIES = $DC_LIBRARIES" >> $custconf echo "DC_FLAGS = $DC_FLAGS" >> $custconf # Enabling driver # touch "$drvpath/.required" # Ok # echo "\`$DRIVERNAME' driver has been configured.." echo } # Help # if [ "x$1" = "x-h" -o "x$1" = "x--help" ] then echo "Usage: configure [driver drvname] [list]" exit 1 fi # Individual driver configuring # if [ "x$1" = "xdriver" ] then driverconf $2 exit 0 fi # Driver's list # if [ "x$1" = "xlist" ] then driverlist exit 0 fi # Configuring drivers # echo "Configuring drivers.." echo "~~~~~~~~~~~~~~~~~~~~~" echo echo "For each driver you want to compile you will need to specify exact place" echo "of where appropriate header files and libraries are located." echo "If you do not want to build any specific driver - just answer \`no'" echo "to the first question". echo for drv in `driverlist` do driverconf $drv done echo "========================================================================="