sudo: required
dist: bionic
language: cpp
compiler:
  - gcc
before_install:
  - echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main" >> /etc/apt/sources.list
  - echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe" >> /etc/apt/sources.list
  - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
  - sudo apt-get -qq update
install:
  - sudo apt-get -qq install rake bison git gperf zlib1g-dev g++-4.9 libstdc++-4.9-dev
  - sudo apt-get remove -y libssl-dev
  - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9" LD="gcc-4.9"; fi
  - $CXX -v
env:
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=19
    NGINX_SRC_PATCH=6
    OPENSSL_SRC_VERSION='1.1.1i'
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=19
    NGINX_SRC_PATCH=6
    BUILD_DYNAMIC_MODULE='TRUE'
    OPENSSL_SRC_VERSION='1.1.1i'
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=19
    NGINX_SRC_PATCH=6
    BUILD_WITH_OPENSSL_SRC='TRUE'
    OPENSSL_SRC_VERSION='1.1.1i'
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=18
    NGINX_SRC_PATCH=0
    OPENSSL_SRC_VERSION='1.1.1i'
  - BUILD_DYNAMIC_MODULE='TRUE'
    NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=18
    NGINX_SRC_PATCH=0
    OPENSSL_SRC_VERSION='1.1.1i'
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=18
    NGINX_SRC_PATCH=0
    BUILD_WITH_OPENSSL_SRC='TRUE'
    OPENSSL_SRC_VERSION='1.1.1i'
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=16
    NGINX_SRC_PATCH=1
    OPENSSL_SRC_VERSION='1.1.1i'
  - BUILD_DYNAMIC_MODULE='TRUE'
    NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=16
    NGINX_SRC_PATCH=1
    OPENSSL_SRC_VERSION='1.1.1i'
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=16
    NGINX_SRC_PATCH=1
    BUILD_WITH_OPENSSL_SRC='TRUE'
    OPENSSL_SRC_VERSION='1.1.1i'
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=14
    NGINX_SRC_PATCH=2
    OPENSSL_SRC_VERSION='1.1.1i'
  - BUILD_DYNAMIC_MODULE='TRUE'
    NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=14
    NGINX_SRC_PATCH=2
    OPENSSL_SRC_VERSION='1.1.1i'
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=14
    NGINX_SRC_PATCH=2
    BUILD_WITH_OPENSSL_SRC='TRUE'
    OPENSSL_SRC_VERSION='1.1.1i'
before_script:
  - curl -sfL https://www.openssl.org/source/openssl-${OPENSSL_SRC_VERSION}.tar.gz -o openssl-${OPENSSL_SRC_VERSION}.tar.gz
  - mkdir openssl-${OPENSSL_SRC_VERSION} && tar -xzf openssl-${OPENSSL_SRC_VERSION}.tar.gz -C openssl-${OPENSSL_SRC_VERSION} --strip-components 1
  - rm openssl-${OPENSSL_SRC_VERSION}.tar.gz
  - cd openssl-${OPENSSL_SRC_VERSION}
  - ./config --prefix=/usr/local --shared zlib -fPIC >> /dev/null 2>&1
  - make >> /dev/null 2>&1
  - sudo make install >> /dev/null 2>&1
  - sudo ldconfig /usr/local/lib
  - cd -
  - openssl version

script:
  - echo "NGINX_SRC_MAJOR=${NGINX_SRC_MAJOR}" > nginx_version
  - echo "NGINX_SRC_MINOR=${NGINX_SRC_MINOR}" >> nginx_version
  - echo "NGINX_SRC_PATCH=${NGINX_SRC_PATCH}" >> nginx_version
  - echo "NGINX_SRC_VER=nginx-${NGINX_SRC_MAJOR}.${NGINX_SRC_MINOR}.${NGINX_SRC_PATCH}" >> nginx_version
  - if [ "${BUILD_WITH_OPENSSL_SRC}" == "TRUE" ]; then build_opts="--with-openssl-src=${PWD}/openssl-${OPENSSL_SRC_VERSION}"; fi
  - sh test.sh ${build_opts}

after_failure:
  - if [ -e build/nginx/logs/error.log ]; then cat build/nginx/logs/error.log ; else cat build_dynamic/nginx/logs/error.log; fi
  - if [ -e build/nginx/logs/stderr.log ]; then cat build/nginx/logs/stderr.log ; else cat build_dynamic/nginx/logs/stderr.log; fi
