@rem Common file shared between external.bat and external-amd64.bat.  Responsible for
@rem fetching external components into the root\externals directory.

set protocol=https
set depth=

:CheckOpts
if '%1'=='--protocol' (set protocol=%2) & shift & shift & goto CheckOpts

if "%GITROOT%"=="" set GITROOT=github.intel.com/SSG-TCAR-SAT/

@rem for an unknown reason, using "--depth 1" with https causes it to hang, so only use with ssh
if %protocol%==ssh (
    set prefix=ssh://git@%GITROOT%
    set depth=--depth 1
)
if not %protocol%==ssh set prefix=https://%GITROOT%

if not exist externals mkdir externals
cd externals
@rem XXX: If you need to force the buildbots to start from a fresh environment, uncomment
@rem the following, check it in, then check it out, comment it out, then check it back in.
@rem if exist bzip2-1.0.6 rd /s/q bzip2-1.0.6
@rem if exist tcltk rd /s/q tcltk
@rem if exist tcltk64 rd /s/q tcltk64
@rem if exist tcl8.4.12 rd /s/q tcl8.4.12
@rem if exist tcl8.4.16 rd /s/q tcl8.4.16
@rem if exist tcl-8.4.18.1 rd /s/q tcl-8.4.18.1
@rem if exist tcl-8.5.2.1 rd /s/q tcl-8.5.2.1
@rem if exist tcl-8.5.15.0 rd /s/q tcl-8.5.15.0
@rem if exist tk8.4.12 rd /s/q tk8.4.12
@rem if exist tk8.4.16 rd /s/q tk8.4.16
@rem if exist tk-8.4.18.1 rd /s/q tk-8.4.18.1
@rem if exist tk-8.5.2.0 rd /s/q tk-8.5.2.0
@rem if exist tk-8.5.15.0 rd /s/q tk-8.5.15.0
@rem if exist tix-8.4.3.5 rd /s/q tix-8.4.3.5
@rem if exist db-4.4.20 rd /s/q db-4.4.20
@rem if exist db-4.7.25.0 rd /s/q db-4.7.25.0
@rem if exist openssl-0.9.8y rd /s/q openssl-0.9.8y
@rem if exist openssl-1.0.1g rd /s/q openssl-1.0.1g
@rem if exist openssl-1.0.1h rd /s/q openssl-1.0.1h
@rem if exist openssl-1.0.1i rd /s/q openssl-1.0.1i
@rem if exist openssl-1.0.1j rd /s/q openssl-1.0.1j
@rem if exist openssl-1.0.1l rd /s/q openssl-1.0.1l
@rem if exist openssl-1.0.2a rd /s/q openssl-1.0.2a
@rem if exist sqlite-3.6.21 rd /s/q sqlite-3.6.21

@rem bzip
@rem if exist bzip2-1.0.6 rd /s/q bzip2-1.0.6
if not exist bzip2-1.0.6 (
   git clone %depth% -b intel/v1.0.6 %prefix%bzip2 bzip2-1.0.6
)

@rem Berkeley DB
@rem if exist db-4.7.25.0 rd /s/q db-4.7.25.0
if not exist db-4.7.25.0 (
   git clone %depth% -b intel/v4.7.25.0 %prefix%db db-4.7.25.0
)

@rem NASM, for OpenSSL build
@rem if exist nasm-2.11.06 rd /s/q nasm-2.11.06
if not exist nasm-2.11.06 (
   git clone %depth% -b intel/v2.11.06 %prefix%nasm nasm-2.11.06
)

@rem OpenSSL
@rem if exist openssl-1.0.2a rd /s/q openssl-1.0.2a
if not exist openssl-1.0.2a (
   git clone %depth% -b intel/v1.0.2a %prefix%openssl openssl-1.0.2a
)

@rem tcl/tk
@rem if exist tcl-8.6.4.0 rd /s/q tcl-8.6.4.0
if not exist tcl-8.6.4.0 (
   rd /s/q tcltk tcltk64
   git clone %depth% -b develop %prefix%tcl tcl-8.6.4.0
)
@rem if exist tk-8.6.4.0 rd /s/q tk-8.6.4.0
if not exist tk-8.6.4.0 (
   git clone %depth% -b develop %prefix%tk tk-8.6.4.0
)
@rem tix
@rem if exist tix-8.4.3.6 rd /s/q tix-8.4.3.6
if not exist tix-8.4.3.6 (
   git clone %depth% -b develop %prefix%tix tix-8.4.3.6
)

@rem sqlite3
@rem if exist sqlite-3.6.21 rd /s/q sqlite-3.6.21
if not exist sqlite-3.6.21 (
   git clone %depth% -b intel/v3.6.21 %prefix%sqlite sqlite-3.6.21
)

