#!/bin/sh

# Time-stamp: <06/01/22 21:32:31 ptr>

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
  --use-static-gcc      use static gcc libs instead of shared libgcc_s (useful for gcc compiler,
                        that was builded with --enable-shared [default]; if compiler was builded
                        with --disable-shared, static libraries will be used in any case)
  --with-boost=<dir>    Request use of boost support (www.boost.org). For the moment only the boost
                        type_traits library is used to get type information and to implement some
                        specific workaround not directly implemented by STLport. To use the same
                        support using STLport don't forget to define _STLP_USE_BOOST_SUPPORT in
                        stlport/stl_user_config.h file.
  --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."
      ;;
    --use-static-gcc)
      write_option "$option" USE_STATIC_LIBGCC
      ;;
    --with-boost=*)
      echo "Don't forget to define _STLP_USE_BOOST_SUPPORT in stlport/stl_user_config.h file"
      write_option "$option" STLP_BUILD_BOOST_PATH
      ;;
  esac
done

