#!/bin/sh
# Configuration script for the make files of a library directory.
#
# Made by Jan Madsen
# Copyright: Computer Networking Laboratory,
#            Swiss Federal Institute of Technology, Lausanne - Switzerland

# By default set the directory to install to /usr/local/sCxx
INSTALL=/usr/local/sCxx

# Default compiler to use when compiling (should be a compiler that accepts
# sC++).
COMPILER=${INSTALL}/bin/gcc

# Default values for the Motif include files and Motif libraries.
MOTIF_INCLUDES_1=-I/logiciels/public/Motif/include
MOTIF_LIBRARIES_1=-L/logiciels/public/Motif/lib

# Default value for the X11 library directories.
X_INCLUDE=-I/logiciels/public/X11R5/include
X_LIB=-L/logiciels/public/X11R5/lib
#
# Default value for the persistency null
# to add the persistency just give PERSISTENT in parameter
#
PERSISTENT=

for param in $* ; do
   case ${param} in
   INSTALL=*)
       INSTALL=`echo $param | sed 's/INSTALL=//g'`
       ;;
   COMPILER=*)
	COMPILER=`echo $param | sed 's/COMPILER=//g'`
	;;
   MOTIF_INCLUDE_OPTIONS=*)
        MOTIF_INCLUDES_1=`echo $param | sed 's/MOTIF_INCLUDE_OPTIONS=//g'`
        ;;
   MOTIF_LIBRARY_OPTIONS=*)
        MOTIF_LIBRARIES_1=`echo $param | sed 's/MOTIF_LIBRARY_OPTIONS=//g'`
        ;;
   X_INCLUDE_OPTIONS=*)
        X_INCLUDE=`echo $param | sed 's/X_INCLUDE_OPTIONS=//g'`
        ;;
   X_LIBRARY_OPTIONS=*)
        X_LIB=`echo $param | sed 's/X_LIBRARY_OPTIONS=//g'`
        ;;
   PERSISTENT*)
	PERSISTENT=-DPERSISTENT_OBJECT
	;;
   esac
done

# Show the values of the variables passed by the caller (Normally not used).
#echo Install directory from ${PWD} : ${INSTALL}

# If they don't exist make the global installation directories.
if [ ! -d ${INSTALL} ] ; then
    mkdir ${INSTALL} ;
fi
if [ ! -d ${INSTALL}/lib ] ; then
    mkdir ${INSTALL}/lib ;
fi
if [ ! -d ${INSTALL}/include ] ; then
   mkdir ${INSTALL}/include ;
fi
if [ ! -d ${INSTALL}/bin ] ; then
   mkdir ${INSTALL}/bin ;
fi
if [ ! -d ${INSTALL}/config ] ; then
   mkdir ${INSTALL}/config ;
fi

RANLIB=/usr/ccs/bin/ranlib
echo ***Configuring examples/Sockets.

echo "# Automatically generated makefile from the configure script." > Makefile
echo "# Made by Jan Madsen," >> Makefile
echo "#         Computer Networking Laboratory," >> Makefile
echo "#         Swiss Federal Institute of Technology," >> Makefile
echo "#         Lausanne - Switzerland" >> Makefile
echo " " >> Makefile
echo "INSTALL_DIR=${INSTALL}" >>Makefile
echo " " >> Makefile
echo "# Compilers to use when compiling, CC = C compiler, CXX = C++ compiler" >> Makefile
echo "CC=${COMPILER}" >> Makefile
echo "CXX=${COMPILER}" >> Makefile
echo " " >> Makefile
echo "# Miscelaneous shell commands used" >> Makefile
echo "RM=rm -f" >> Makefile
echo "RANLIB=${RANLIB}" >> Makefile
echo "AR=ar" >> Makefile
echo " " >> Makefile
echo "# Motif include files and libraries path as they are passed to gcc" >> Makefile
echo "MOTIF_INCLUDES=${MOTIF_INCLUDES_1}" >> Makefile
echo "MOTIF_LIBRARIES=${MOTIF_LIBRARIES_1}" >> Makefile
echo " " >> Makefile
echo "# X include files and libraries path(s) as they are passed to gcc" >> Makefile
echo "X_INCLUDES=${X_INCLUDE}" >> Makefile
echo "X_LIBRARIES=${X_LIB}" >> Makefile
echo " " >> Makefile
echo "# To make the object persistent if PERSISTENT=-DPERSITENT_OBJECT " >> Makefile
echo "PERSISTENT=${PERSISTENT}" >> Makefile
echo " " >> Makefile
cat ./Makefile.in >> Makefile
