default:
  tags:
    - docker
  # Image from https://hub.docker.com/_/gcc/ based on Debian
  image: gcc:9

.autoconf:
  stage: build
  before_script:
    - apt-get update &&
      apt-get install -y libogg-dev valgrind
  script:
    - ./autogen.sh
    - ./configure ${CONFIG_FLAGS}
    - make
    - make check

autoconf:
  extends: .autoconf
  script:
    - ./autogen.sh
    - ./configure ${CONFIG_FLAGS}
    - make
    - make distcheck

fixed-point:
  extends: .autoconf
  variables:
    CONFIG_FLAGS: --enable-fixed-point

no-float:
  extends: .autoconf
  variables:
    CONFIG_FLAGS: --enable-fixed-point --disable-float-api

vorbis-psy:
  extends: .autoconf
  variables:
    CONFIG_FLAGS: --enable-vorbis-psy

valgrind:
  extends: .autoconf
  variables:
    CONFIG_FLAGS: --enable-valgrind

no-binaries:
  extends: .autoconf
  variables:
    CONFIG_FLAGS: --disable-binaries

.meson:
  stage: build
  image: 'debian:bookworm'
  before_script:
    - apt-get update &&
      apt-get install -y libogg-dev ninja-build meson valgrind
  script:
    - meson setup builddir ${CONFIG_FLAGS}
    - ninja -C builddir
    - ninja -C builddir test
    - ninja -C builddir install
    - test $(head -n1 meson.build | awk '/version/ { printf $NF }'  | sed s/[\"\',]//g) = $(awk '/version/ { printf $NF }' library.json | sed s/[\"\',]//g)

meson fixed-point:
  extends: .meson
  variables:
    CONFIG_FLAGS: -Dfixed-point=enabled

meson no-float:
  extends: .meson
  variables:
    CONFIG_FLAGS: -Dfixed-point=enabled -Dfloat-api=disabled

meson vorbis-psy:
  extends: .meson
  variables:
    CONFIG_FLAGS: -Dvorbis-psy=enabled

meson valgrind:
  extends: .meson
  variables:
    CONFIG_FLAGS: -Dvalgrind=enabled

meson no-binaries:
  extends: .meson
  variables:
    CONFIG_FLAGS: -Dtools=disabled -Dtest-binaries=disabled
