sudo: required
dist: trusty
language: cpp
compiler:
  - gcc
before_install:
  - 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
  - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
  - $CXX -v
env:
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=17
    NGINX_SRC_PATCH=3
  - BUILD_DYNAMIC_MODULE='TRUE'
    NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=17
    NGINX_SRC_PATCH=3
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=16
    NGINX_SRC_PATCH=1
  - BUILD_DYNAMIC_MODULE='TRUE'
    NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=16
    NGINX_SRC_PATCH=1
  - NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=14
    NGINX_SRC_PATCH=2
  - BUILD_DYNAMIC_MODULE='TRUE'
    NGINX_SRC_MAJOR=1
    NGINX_SRC_MINOR=14
    NGINX_SRC_PATCH=2

before_script:
  - curl -sfL https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz -o openssl-1.0.2.tar.gz
  - tar -xzf openssl-1.0.2.tar.gz
  - rm openssl-1.0.2.tar.gz
  - cd openssl-1.0.2*
  - ./config --prefix=/usr/local --shared zlib -fPIC enable-tlsext >> /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
  - sh test.sh

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
