sudo: false

language: cpp

os:
  - linux
  - osx

compiler:
  - clang
  - gcc

addons:
  apt:
    packages:
    - texinfo

install:
  # Prepare for local installs
  - export LOCAL_INSTALL="$HOME/local"; mkdir "$LOCAL_INSTALL" && export PKG_CONFIG_PATH="$LOCAL_INSTALL/lib/pkgconfig"

  # Install libbinio
  - git clone http://github.com/adplug/libbinio.git
  - pushd libbinio && autoreconf -i && ./configure --prefix="$LOCAL_INSTALL" --enable-maintainer-mode && make && make install && popd

before_script:
  - autoreconf -i

script:
  - ./configure --enable-maintainer-mode || cat config.log
  - make && ulimit -c unlimited -S && make check

after_failure:
  - |-
    for I in test/*.log; do
      echo === $I ===
      cat $I
    done
    if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
      if [ -f core ]; then
        export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:./src/.libs/"
        gdb ./tests/.libs/tests core -ex "thread apply all bt" -ex "set pagination 0" -batch
      else
        echo "No core dump; skipping gdb for backtrace"
      fi

    elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
      # Make the build output lib dir located where dylib looks as default fallback,
      # since setting DYLD_FALLBACK_LIBRARY_PATH doesn't seem to work
      ln -s `pwd`"/src/.libs" "$HOME/lib"

      # Run the tests with core dumps enabled
      ulimit -c unlimited && ./tests/.libs/tests --no_catch_system_errors

      # Look for a core dump and examine it if found
      COREFILE=`ls -t /cores/* | head -n1`
      if [ -f "$COREFILE" ]; then
        echo "Found core dump: $COREFILE"
        lldb -c "$COREFILE" --batch -o 'thread backtrace all' -o 'quit'
      else
        echo "No core dump; skipping lldb for backtrace"
      fi
    else
      echo "Unknown OS, cannot check for core dump"
    fi
    sleep 5
  - echo == End of test log ==

Add Travis CI build config
Add Travis CI build config
