env:
  global:
   # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
   #   via the "travis encrypt" command using the project repo's public key
   - secure: "Ms5I/fBICPT8kpIxkdoeSK+iLHA7rsaUaCDXCoYX9ufiB9uqT1FP+66W1e9mJa2H5QSv44eoOw0dvfoZm4ThJbehdXYhUrTWM6Am5hpOZmWp1ttYNTXkzxQRpKMthjZJvTMi5SAYJB13lk4/x5xt1zVFA9ZQgCPVvrRaQcZ820E="
   # Coverity run condition (avoid matrix multiple runs), need customized
   # build script. Need an update if new matrix cases.
   - coverity_scan_run_condition='"$CC" = gcc -a "$TRAVIS_OS_NAME" != osx'
   # Coverity script test mode (if true no uploading, avoid reaching the quota)
   # usual processing: false.
   - coverity_scan_script_test_mode=false

language: c
compiler:
  - gcc
  - clang
  
before_install:
  - sudo apt-get install gfortran libblas-dev liblapack-dev libilmbase-dev
  - sudo pip install cpp-coveralls

script:
  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make double longdouble float lapack fortran half LDADD_L='-llapack -lblas'; fi
  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make check; fi
  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make -C examples checklapack LDADD_L='-llapack -lblas'; fi
  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make veryclean; fi
  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make -k -C examples test ctest testdrv ctestdrv CFLAGS='-g -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror' FFLAGS='-g -fprofile-arcs -ftest-coverage'; fi
  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make fortran FFLAGS='-g -fprofile-arcs -ftest-coverage'; fi
  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make -C examples ftest ftestdrv LIBSUFFIX= MINPACK=../fortran/libminpack.a FFLAGS='-g -fprofile-arcs -ftest-coverage'; fi

after_success:
  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then coveralls --extension .c --extension .f --extension .h --exclude examples; fi

addons:
  coverity_scan:
    # customized build script URL
    # TRAVIS_REPO_SLUG: owner_name/repo_name of repository currently being built
    # TRAVIS_BRANCH: name of the branch currently being built
    build_script_url: https://raw.githubusercontent.com/$TRAVIS_REPO_SLUG/$TRAVIS_BRANCH/.travis-coverity-scan-build.sh
    # project metadata
    project:
      name: $TRAVIS_REPO_SLUG
    # Where email notification of build analysis results will be sent
    notification_email: frederic.devernay@m4x.org
    # Commands to prepare for build_command
    #build_command_prepend: ./configure
    # This command will be added as an argument to "cov-build" to compile
    # the project for analysis
    build_command:   "make double longdouble float lapack fortran half"
    # Pattern to match selecting branches that will run analysis
    branch_pattern: coverity_scan
