#!/bin/sh

### travis-tool -- Continuous integration test for travis

# BSD Owl Scripts (https://github.com/michipili/bsdowl)
# This file is part of BSD Owl Scripts
#
# Copyright © 2015 Michael Grünewald. All Rights Reserved.
#
# This file must be used under the terms of the BSD license.
# This source file is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.

INSTALL_PREFIX="${HOME}/.bsdowl"

TRAVIS_WITH_EMACS=${TRAVIS_FULL}
TRAVIS_WITH_FINDLIB=${TRAVIS_FULL}
TRAVIS_WITH_NOWEB=${TRAVIS_FULL}
TRAVIS_WITH_OPENSP=${TRAVIS_FULL}
TRAVIS_WITH_TEX=${TRAVIS_FULL}

eval $(opam config env --switch ${TRAVIS_OCAML_VERSION:?})

set -a
BSDOWL_WITH_EMACS=${TRAVIS_WITH_EMACS}
BSDOWL_WITH_FINDLIB=${TRAVIS_WITH_FINDLIB}
BSDOWL_WITH_NOWEB=${TRAVIS_WITH_NOWEB}
BSDOWL_WITH_OPENSP=${TRAVIS_WITH_OPENSP}
BSDOWL_WITH_TEX=${TRAVIS_WITH_TEX}
set +a

install -d "${INSTALL_PREFIX}"
autoconf
./configure\
    --prefix="${INSTALL_PREFIX}"\
    --disable-test-gpg\
    --enable-test-emacs=${TRAVIS_WITH_EMACS}\
    --enable-test-findlib=${TRAVIS_WITH_FINDLIB}\
    --enable-test-noweb=no\
    --enable-test-opensp=${TRAVIS_WITH_OPENSP}\
    --enable-test-texmf=${TRAVIS_WITH_TEX}\
    --with-credentials=sudo\
    --with-emacs=${TRAVIS_WITH_EMACS}\
    --with-gm\
    --with-gpg\
    --with-noweb=${TRAVIS_WITH_NOWEB}\
    --with-ocaml\
    --with-opensp=${TRAVIS_WITH_OPENSP}\
    --with-sqlite3\
    --with-tex=${TRAVIS_WITH_TEX}
bmake build
bmake install
test -f "${INSTALL_PREFIX}/share/bsdowl/bps.bpsconfig.mk"
./Library/Ancillary/testtool -i
./Library/Ancillary/testtool -I -D -a "${TRAVIS_TEST_EXCLUDE:+-x }${TRAVIS_TEST_EXCLUDE}"

### End of file `travis-tool'
