#!/bin/sh
# This script generates the odbc.ini file for the platform supporting
# odbc. This is used as part of the IDL install process.
#
#
# $Id: gen_odbc_ini,v 1.18 2001/04/10 22:23:21 idl Exp $

# Parameter 1 is $IDL_DIR
if [ "$1" != "" ]; then
IDL_DIR=$1
else
exit 1
fi

# Parameter 2 is OS_NAME
if [ "$2" = "" ]; then
exit 1
else
  case $2 in
      "HP")
       OS_NAME=hp
       SO_EXT="sl"
       HAS_SYBASEASE="Y"
       HAS_OR7="Y"
       HAS_OR8="Y"
       HAS_INFX="Y"
       HAS_INFXWP="Y"
       HAS_MSSQL="Y"
       HAS_TEXT="Y"
      ;;

      "SOLARIS2")
       OS_NAME=solaris2.sparc
       SO_EXT="so"
       HAS_SYBASEASE="Y"
       HAS_OR7="Y"
       HAS_OR8="Y"
       HAS_INFX="Y"
       HAS_INFXWP="Y"
       HAS_MSSQL="Y"
       HAS_TEXT="Y"
      ;;

#      IRIX didn't upgrade to merant 3.7, so we have leave these
#      at intersolve 3.11 levels. 

      "IRIX")
       OS_NAME=sgi
       SO_EXT="so"
       HAS_IN_SYBASE="Y"
       HAS_IN_SYBASE11="Y"
       HAS_IN_OR7="Y"
       HAS_IN_OR8="Y"
       HAS_IN_INFX="Y"
       HAS_IN_INFX9="Y"
      ;;

      "AIX")
       OS_NAME=ibm
       SO_EXT="so"
       HAS_SYBASEASE="Y"
       HAS_OR7="Y"
       HAS_OR8="Y"
       HAS_INFX="Y"
       HAS_INFXWP="Y"
       HAS_MSSQL="Y"
       HAS_TEXT="Y"
      ;;

      "LINUX")
       OS_NAME=linux.x86
       SO_EXT="so"
       HAS_SYBASEASE="Y"
       HAS_OR8="Y"
       HAS_INFXWP="Y"
       HAS_MSSQL="Y"
       HAS_TEXT="Y"
      ;;

    *)
        echo "$2: Not supported"
        exit 1
        ;;
  esac

fi

# This script is called blindly by the installer. Make
# sure that the bin directory is there. If not ,exit normally
#
if [ ! -x $IDL_DIR/bin/bin.$OS_NAME ]; then
  exit 0
fi

# Set the ini filename. This is platform specific
INI_FILENAME=$IDL_DIR/resource/dm/$OS_NAME/odbc.ini

echo "[ODBC Data Sources]" >$INI_FILENAME

# Write the header section of the odbc.ini file. This section is for
# intersolve 3.11 drivers.
if [ "$HAS_IN_SYBASE" != "" ]; then
  echo "Sybase=INTERSOLV 3.11 Sybase Driver">>$INI_FILENAME
fi
if [ "$HAS_IN_SYBASE11" != "" ]; then
  echo "Sybase11=INTERSOLV 3.11 Sybase 11 Driver" >>$INI_FILENAME
fi
if [ "$HAS_IN_OR7" != "" ]; then
  echo "Oracle7=INTERSOLV 3.11 Oracle 7 Driver">>$INI_FILENAME
fi
if [ "$HAS_IN_OR8" != "" ]; then
  echo "Oracle8=INTERSOLV 3.11 Oracle 8 Driver">>$INI_FILENAME
fi
if [ "$HAS_IN_INFX" != "" ]; then 
  echo "Informix=INTERSOLV 3.11 Informix Driver">>$INI_FILENAME
fi
if [ "$HAS_IN_INFX9" != "" ]; then 
  echo "Informix9=INTERSOLV 3.11 Informix 9 Driver">>$INI_FILENAME
fi

# Now start the section for the Merant 3.7 Drivers
if [ "$HAS_SYBASEASE" != "" ]; then
  echo "Sybase=MERANT 3.70 Sybase ASE Driver">>$INI_FILENAME
fi
if [ "$HAS_OR7" != "" ]; then
  echo "Oracle7=MERANT 3.70 Oracle 7 Driver">>$INI_FILENAME
fi
if [ "$HAS_OR8" != "" ]; then
  echo "Oracle8=MERANT 3.70 Oracle 8 Driver">>$INI_FILENAME
fi
if [ "$HAS_INFX" != "" ]; then 
  echo "Informix=MERANT 3.70 Informix Driver">>$INI_FILENAME
fi
if [ "$HAS_INFXWP" != "" ]; then 
  echo "InformixWP=MERANT 3.70 Informix Clientless Driver">>$INI_FILENAME
fi
if [ "$HAS_MSSQL" != "" ]; then 
  echo "MS_SQLServer7=MERANT SQLServer driver">>$INI_FILENAME
fi
if [ "$HAS_TEXT" != "" ]; then 
  echo "Text=MERANT 3.70 Text Driver">>$INI_FILENAME
fi

# Handy constant
INST_DIR=$IDL_DIR/bin/bin.$OS_NAME/dm

# OK, the Intersolve 3.11 drivers first.

if [ "$HAS_IN_SYBASE" != "" ]; then
  echo "
[Sybase]
Driver=$INST_DIR/lib/dmsyb13.$SO_EXT
Description=Sybase
Database=odbc
ServerName=SYBASE
WorkstationID=id
LogonID=odbc01
Password=odbc01
OptimizePrepare=2
SelectMethod=1
">>$INI_FILENAME
fi

if [ "$HAS_IN_SYBASE11" != "" ]; then
  echo "
[Sybase11]
Driver=$INST_DIR/lib/dmsyb1113.$SO_EXT
Description=Sybase11
Database=odbc
ServerName=SYBASE
WorkstationID=id
LogonID=odbc01
Password=odbc01
OptimizePrepare=2
SelectMethod=1
">>$INI_FILENAME
fi


if [ "$HAS_IN_OR7" != "" ]; then
  echo "
[Oracle7]
Driver=$INST_DIR/lib/dmor713.$SO_EXT
Description=Oracle7
EnableScrollableCursors=1
ServerName=oraclehost
LogonID=odbc01
Password=odbc01
">>$INI_FILENAME
fi

if [ "$HAS_IN_OR8" != "" ]; then
  echo "
[Oracle8]
Driver=$INST_DIR/lib/dmor813.$SO_EXT
Description=Oracle8
EnableScrollableCursors=1
ServerName=oraclehost
LogonID=odbc01
Password=odbc01
">>$INI_FILENAME
fi

if [ "$HAS_IN_INFX" != "" ]; then
  echo "
[Informix]
Driver=$INST_DIR/lib/dminf13.$SO_EXT
Description=Informix7
Database=odbc
HostName=informixhost
LogonID=odbc01
Password=odbc01
">>$INI_FILENAME
fi

if [ "$HAS_IN_INFX9" != "" ]; then
  echo "
[Informix9]
Driver=$INST_DIR/lib/dminf913.$SO_EXT
Description=Informix9
Database=odbc
HostName=informixhost
LogonID=odbc01
Password=odbc01
">>$INI_FILENAME
fi


# Now the Merant 3.7 Driver section.

if [ "$HAS_SYBASEASE" != "" ]; then
  echo "
[SybaseASE]
Driver=$INST_DIR/lib/dmase16.$SO_EXT
Description=SybaseASE
Database=odbc
LogonID=odbc01
Password=odbc01
NetworkAddress=pilot,5000
">>$INI_FILENAME
fi

if [ "$HAS_OR7" != "" ]; then
  echo "
[Oracle7]
Driver=$INST_DIR/lib/dmor716.$SO_EXT
Description=Oracle7
EnableScrollableCursors=1
ServerName=oraclehost
LogonID=odbc01
Password=odbc01
">>$INI_FILENAME
fi

if [ "$HAS_OR8" != "" ]; then
  echo "
[Oracle8]
Driver=$INST_DIR/lib/dmor816.$SO_EXT
Description=Oracle8
EnableScrollableCursors=1
ServerName=oraclehost
LogonID=odbc01
Password=odbc01
">>$INI_FILENAME
fi

if [ "$HAS_INFX" != "" ]; then
  echo "
[Informix]
Driver=$INST_DIR/lib/dminf16.$SO_EXT
Description=Informix
Database=odbc
LogonID=odbc01
Password=odbc01
ServerName=zippy
HostName=luvpod
Service=turbo
Protocol=ontlitcp
">>$INI_FILENAME
fi

if [ "$HAS_INFXWP" != "" ]; then
  echo "
[InformixWP]
Driver=$INST_DIR/lib/dmifcl16.$SO_EXT
Description=Informix Clientless Driver
Database=odbc
LogonID=odbc01
Password=odbc01
HostName=beluga
PortNumber=1526
ServerName=beluga914
">>$INI_FILENAME
fi


if [ "$HAS_TEXT" != "" ]; then
  echo "
[MS_SQLServer7]
Driver=$INST_DIR/lib/dmmsss16.$SO_EXT
Description=SQL Server
Database=
Address=
LogonID=odbc01
Password=odbc01
QuotedId=No
AnsiNPW=No
">>$INI_FILENAME
fi


if [ "$HAS_TEXT" != "" ]; then
  echo "
[Text]
Driver=$INST_DIR/lib/dmtxt16.$SO_EXT
Description=Text driver
Database=$INST_DIR/demo
AllowUpdateAndDelete=1
">>$INI_FILENAME
fi

echo "

[ODBC]
Trace=0
TraceFile=odbctrace.out
TraceDll=$INST_DIR/lib/odbctrac.$SO_EXT
InstallDir=$INST_DIR
">>$INI_FILENAME

exit 0
