# Cirrus CI configuration
# https://cirrus-ci.com/github/dfandrich/gpscorrelate

task:
  name: FreeBSD
  freebsd_instance:
    matrix:
      image: freebsd-12-0-release-amd64
      image: freebsd-11-2-release-amd64
      image: freebsd-10-4-release-amd64

  env:
    # Set to 10 instead of 1 to avoid problems when new commits are submitted
    # during a run.
    CIRRUS_CLONE_DEPTH: 10
    CFLAGS: -Wall -Wextra -Werror -O3 -DENABLE_NLS=1
    LDFLAGS: $CFLAGS -lintl
    CC: cc
    CXX: c++
    MAKE_FLAGS: -j 2
    matrix:
      - GTK: 2
      - GTK: 3

  pkginstall_script:
    - pkg install -y pkgconf docbook-xsl exiv2 libxml2 gtk"$GTK" libxslt gettext-tools desktop-file-utils

  compile_script:
    # GTK3 throws up some warnings, so avoid -Werror
    - if [ "$GTK" = 3 ] ; then CFLAGS='-Wall -Wextra -O3 -DENABLE_NLS=1'; fi
    - make CC="$CC" CXX="$CXX" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" GTK="$GTK"

  test_script:
    - ./gpscorrelate -V
    # The tests involving writing to read-only files fail when run as root
    # (because the OS allows the files to be overwritten then). Run the
    # tests as a normal user to get around that problem. The log directory
    # must be world-writable since files will be written there.
    - install -d -m 0777 tests/log
    - sudo -u nobody make check

  install_script:
    - make prefix= DESTDIR="${HOME}" install install-po install-desktop-file
