language: c
os:
  - linux
compiler:
  - clang
  - gcc
env:
  matrix:
    - BUILD_ARCH="x86"
    - BUILD_ARCH="x86_64"
  global:
    - MAKEFLAGS="-j 2"
matrix:
  include:
    - os: osx
      compiler: clang # Workaround travis setting CC=["clang", "gcc"]
      env: BUILD_ARCH="x86_64"
    # Build using the 10.12 SDK but target and run on OSX 10.11
#   - os: osx
#     compiler: clang
#     osx_image: xcode8
#     env: SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk MACOSX_DEPLOYMENT_TARGET=10.11
    # Build on the latest OSX version (will eventually become obsolete)
    - os: osx
      compiler: clang
      osx_image: xcode8.3
      env: BUILD_ARCH="x86_64"
    - os: osx
      compiler: clang
      osx_image: xcode9.4
      env: BUILD_ARCH="x86_64"
  exclude:
    - os: osx
      compiler: gcc
  exclude:
    - os: linux
      compiler: clang
      env: BUILD_ARCH="x86" # Only do the gcc x86 build to reduce clutter
before_install:
  - EXTRA_CFLAGS="-Werror"
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
        pkgs=(libaio-dev libnuma-dev libz-dev librbd-dev libibverbs-dev librdmacm-dev);
        if [[ "$BUILD_ARCH" == "x86" ]]; then
            pkgs=("${pkgs[@]/%/:i386}");
            pkgs+=(gcc-multilib);
            EXTRA_CFLAGS="${EXTRA_CFLAGS} -m32";
        else
            pkgs+=(glusterfs-common);
        fi;
        sudo apt-get -qq update;
        sudo apt-get install --no-install-recommends -qq -y "${pkgs[@]}";
    fi
script:
  - ./configure --extra-cflags="${EXTRA_CFLAGS}" && make
  - make test
