dist: xenial

language: c

cache:
  ccache: true
  directories:
    - autom4te.cache
    - m4

addons:
  apt:
    packages:
      - autoconf-archive
      - autopoint
      - clang
      - libssl-dev
      - linux-libc-dev
      - txt2man
  homebrew:
    update: true
    packages:
      - autoconf-archive
      - gettext
      - openssl
      - pkg-config

env:
  global:
    - G_CFLAGS="-O3 -fPIC"
    - MAKEFLAGS="-j4"
    - target=distcheck
  matrix:
    - CONF_FLAGS="--without-ssl"
    - CONF_FLAGS="--with-ssl"

os:
  - linux
  - osx

compiler:
  - gcc
  - clang

matrix:
  exclude:
    - os: osx
      compiler: gcc

script:
  - if [ "${TRAVIS_OS_NAME}" = osx ]; then
      target=all
      GETTEXT="/usr/local/opt/gettext"
      OPENSSL="/usr/local/opt/openssl";
      export LIBRARY_PATH="$GETTEXT/lib"
             CPATH="$OPENSSL/include:$GETTEXT/include"
             PKG_CONFIG_PATH="$OPENSSL/lib/pkgconfig"
             PATH="$GETTEXT/bin:$PATH";
    fi
  - autoreconf -fiv &&
    ./configure $CONF_FLAGS CFLAGS="$G_CFLAGS" &&
    make DIST_TARGETS=dist-gzip GZIP_ENV=--fast $target
