#!/usr/bin/env bash
#
# Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved.
#

set -e

if [[ "$OS" == "Windows_NT" ]]; then
    echo "You seem to be running on Windows under Cygwin / MSYS(2), like e.g. Git for Windows Bash. This script does"
    echo "not properly work in this scenario. As a Windows user, please run 'configure.bat' from a regular command"
    echo "prompt instead."
    exit 1
fi

################################
# change these variables to customize this script locally
################################
# you can define one or more thirdparty dirs, each prefixed with TPP_DIR
export TPP_DIR="thirdparty"

# default configurations
CONF_DEFAULT="etc/conf"


#################################

CFG_CMD_LINE_ARGS="$@"

if [[ "$1" == "" ]]; then
    # default for dev conf if not argument is provided
    CFG_CMD_LINE_ARGS=$CONF_DEFAULT
fi

CONFIGURE_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [[ "$PYTHON_EXE" == "" ]]; then
    PYTHON_EXE=python
fi

$PYTHON_EXE "$CONFIGURE_ROOT_DIR/etc/configure.py" $CFG_CMD_LINE_ARGS

set +e