#! /bin/bash

# esy-configure
#
# Wrapper to delegate to configuration to the 
# appropriate `configure` strategy based on the active platform.
#
# Today, OCaml has separate build strategies:
# - Linux, OSX, Cygwin (gcc) - https://github.com/ocaml/ocaml/blob/trunk/INSTALL.adoc
# - Windows, Cygin (mingw) - https://github.com/ocaml/ocaml/blob/trunk/README.win32.adoc
#
# We want `esy` to work cross-platform, so this is a shim script that will delegate to the
# appropriate script depending on the platform. We assume that if the platform is `CYGWIN`
# that the `mingw` (native executable) strategy is desired.

set -u
set -e
set -o pipefail

case "$(uname -s)" in
    CYGWIN*|MINGW32*|MSYS*)
        echo "[esy-configure] Detected windows environment..."
        ./configure-windows "$@"
        ;;
    *)
        echo "[esy-configure] Detected OSX / Linux environment"
        ./configure "$@"
        ;;
esac
