[buildout]
extends =
  ../coreutils/buildout.cfg
  ../git/buildout.cfg
  ../libexpat/buildout.cfg
  ../openssl/buildout.cfg
  ../patch/buildout.cfg
  ../pcre/buildout.cfg
  ../zlib/buildout.cfg

parts = nginx-output

[nginx-common]
recipe = slapos.recipe.cmmi
shared = false
url = https://nginx.org/download/nginx-1.17.6.tar.gz
md5sum = 55022aa5715386c994f6773478822853

[nginx]
<= nginx-common
shared = true
configure-options=
  --with-http_ssl_module
  --with-http_v2_module
  --with-http_gzip_static_module
  --with-http_realip_module
  --with-mail
  --with-mail_ssl_module
  --with-ld-opt="-L ${openssl-1.0:location}/lib -L ${pcre:location}/lib -L ${zlib:location}/lib -Wl,-rpath=${openssl-1.0:location}/lib -Wl,-rpath=${pcre:location}/lib -Wl,-rpath=${zlib:location}/lib"
  --with-cc-opt="-I ${openssl-1.0:location}/include -I ${pcre:location}/include -I ${zlib:location}/include"

[nginx-dav-ext-module]
recipe = slapos.recipe.build:download-unpacked
url = https://github.com/arut/nginx-dav-ext-module/archive/v0.0.3.tar.gz
strip-top-level-dir = true
md5sum = 2cb502dbda335be4ebd5fed0b3182bae
mode = 0644

[nginx-webdav]
<= nginx-common
configure-options =
  --with-ipv6
  --with-http_ssl_module
  --with-http_v2_module
  --with-http_gzip_static_module
  --with-mail
  --with-mail_ssl_module
  --error-log-path=var/log/nginx.error.log
  --with-ld-opt=" -L ${libexpat:location}/lib -L ${openssl-1.0:location}/lib -L ${pcre:location}/lib -L ${zlib:location}/lib -Wl,-rpath=${libexpat:location}/lib -Wl,-rpath=${openssl-1.0:location}/lib -Wl,-rpath=${pcre:location}/lib -Wl,-rpath=${zlib:location}/lib"
  --with-cc-opt="-I ${libexpat:location}/include -I ${openssl-1.0:location}/include -I ${pcre:location}/include -I ${zlib:location}/include"
  --with-http_dav_module 
  --add-module='${nginx-dav-ext-module:location}'

[nginx-output]
# Shared binary location to ease migration
recipe = plone.recipe.command
stop-on-error = true
update-command = ${:command}
command = ${coreutils-output:test} -x ${:nginx} -a -f ${:mime}
nginx = ${nginx:location}/sbin/nginx
mime = ${nginx:location}/conf/mime.types

[hexaglobe-nginx-module]
recipe = hexagonit.recipe.download
ignore-existing = true
url = http://easicloud-p.cdn.hexaglobe.net/nginx-easicloud.tar.gz
md5sum = 57fe2ceb09740f22b5b1023f29889e0e
strip-top-level-dir = true

[nginx-enable-sub]
# Used by Hexaglobe for watermarking
<= nginx
configure-options=
  --with-ipv6
  --with-http_ssl_module
  --with-ld-opt="-L ${zlib:location}/lib -L ${openssl-1.0:location}/lib -L ${pcre:location}/lib  -Wl,-rpath=${pcre:location}/lib -Wl,-rpath=${zlib:location}/lib -Wl,-rpath=${openssl-1.0:location}/lib"
  --with-cc-opt="-I ${pcre:location}/include -I ${openssl-1.0:location}/include -I ${zlib:location}/include"
  --add-module=${hexaglobe-nginx-module:location}/sub_module
# --add-module=${hexaglobe-nginx-module:location}/nginx-upstream-fair

[nginx-push-stream-module]
recipe = slapos.recipe.build:gitclone
repository = https://github.com/wandenberg/nginx-push-stream-module.git
revision = 3d3a204177d3a7ab8a2858e04e792a6d11bf133f
git-executable = ${git:location}/bin/git

[nginx-push-stream]
<= nginx
configure-options=
  --with-ipv6
  --with-http_ssl_module
  --with-http_v2_module
  --with-http_gzip_static_module
  --with-ld-opt="-L ${zlib:location}/lib -L ${openssl-1.0:location}/lib -L ${pcre:location}/lib  -Wl,-rpath=${pcre:location}/lib -Wl,-rpath=${zlib:location}/lib -Wl,-rpath=${openssl-1.0:location}/lib"
  --with-cc-opt="-I ${pcre:location}/include -I ${openssl-1.0:location}/include -I ${zlib:location}/include -Wno-error"
  --add-module=${nginx-push-stream-module:location}

[nginx-push-stream-output]
<= nginx-output
nginx = ${nginx-push-stream:location}/sbin/nginx
mime = ${nginx-push-stream:location}/conf/mime.types
