#!/bin/sh

# Time-stamp: <05/09/21 00:17:55 ptr>
# $Id: configure,v 1.1.2.8 2005/09/20 20:20:20 complement Exp $


configmak=../Makefiles/config.mak

# rm -f ${configmak}

# echo "# STLPORT_DIR := /export/home/windows/guest/STLlab/STLport" >> ${configmak}
# echo "# MSVC_DIR := c:/Program Files/Microsoft Visual Studio/VC98" >> ${configmak}
# echo "# TARGET_PROC=x86" >> ${configmak}

write_option() {
  target=`echo $1 | sed -e 's/^[^=]*=//'`
  echo $2 := $target >> ${configmak}
}

print_help() {
  cat <<EOF
Configuration utility.

Usage:

  configure [options]

Available options:

  --target=<target>     target platform (cross-compiling)
  --help                print this help message and exit
  --with-stlport=<dir>  use STLport in catalog <dir>
  --with-mwcw=<dir>     Metrowerks CodeWarrior compiler catalog (useful for mw* compilers)
                        i.e. something like "c:/Program Files/Metrowerks/CodeWarrior"
  --with-nwsdk=<dir>    use Novell NDK/SDK from this catalog (useful for *-*-netware target)
                        i.e. something like "c:/Novell/ndk/nwsdk"
  --no-cygwin           Specific cygwin distribution option. Use it to build STLport using
                        the cygwin tools but without dependency on the cygwin1.dll
  --with-extra-cxxflags=<options>
                        pass extra options to C++ compiler
  --clean               remove custom settings (file ${configmak})
                        and use default values

EOF
}

case $# in
  0)
    exit 0
    ;;
esac

case $1 in
  --help)
    print_help
    exit 0
    ;;
esac

rm -f ${configmak}

while :
do
  case $# in
    0)
      break
      ;;
  esac
  option=$1
  shift
  case $option in
    --clean)
      rm -f ${configmak}
      ;; 
    --target=*)
      write_option "$option" TARGET_OS
      ;;
    --with-stlport=*)
      write_option "$option" STLPORT_DIR
      ;;
    --with-extra-cxxflags=*)
      write_option "$option" EXTRA_CXXFLAGS
      ;;
    --with-nwsdk=*)
      write_option "$option" NWSDK_DIR
      ;;
    --with-mwcw=*)
      write_option "$option" MWCW_BASE
      ;;
    --no-cygwin)
      write_option "-mno-cygwin" OPT
      write_option -D_STLP_NO_CYGWIN DEFS
      echo "--no-cygwin: Don't forget to uncomment _STLP_NO_CYGWIN macro"
      echo "in stlport/stl/_site_config.h to use such a configuration."
      ;;
  esac
done

