dist: xenial
# osx_image: xcode12.2

cache: ccache

language: cpp

os:
  - linux
  ## disabled:  - osx

compiler:
  - gcc
  ## disabled:  - clang

env:
  - |
    ANALYZE=false
    DOC=false

jobs:
  include:
    os: linux
    ## compiler: clang
    ## env: ANALYZE=true DOC=true

branches:
  only:
  - master
  - branch-1.3
  - /^feature-.*/
  - /^fix-.*/
  - /^issue-.*/
  - /^str-.*/

before_script:
  - |
    if [ $TRAVIS_OS_NAME = linux ]; then
       sudo apt-get update -q
       sudo apt-get install -y libxinerama-dev libxcursor-dev libasound2-dev libglew-dev
       sudo apt-get install -y doxygen
    elif [ $TRAVIS_OS_NAME = osx ]; then
      # brew install ccache # need to install on macOS
      # export PATH="/usr/local/opt/ccache/libexec:$PATH"
      # brew install doxygen
      echo "macOS build is currently disabled"
    fi

script:
  - |
    if [ $ANALYZE = "false" ]; then
      echo
      echo "start configure/make at `date`"
      echo
      autoconf
      ./configure
      make
      echo
      echo "start CMake/make at `date`"
      echo
      mkdir cmake-build
      cd cmake-build
      cmake -G "Unix Makefiles" -D FLTK_BUILD_EXAMPLES=ON ..
      make
    else
      echo
      echo "start scan-build/make at `date`"
      echo
      mkdir scan-build
      cd scan-build
      scan-build cmake -G "Unix Makefiles" -D FLTK_BUILD_EXAMPLES=ON ..
      scan-build -v make
    fi
    echo
    echo "done at `date`"
    echo

after_success:
  - |
    if [ $DOC = "true" ]; then
      doxygen --version
      cd documentation
      make html
      cd -
    fi

# use default email notification: committer and author get notifications
