<commit_before><%
require File.dirname(File.absolute_path(__FILE__)) + '/helpers'
-%>
#!/usr/bin/make -f
export DH_VERBOSE=1

<% if is_distribution?(">= vivid") -%>
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
<% end -%>
<% if is_distribution?("<= saucy") || is_distribution?("<= wheezy") -%>
CFLAGS := $(shell dpkg-buildflags --get CFLAGS)
CFLAGS += -Wall -DFORTIFY_SOURCE=2 -fstack-protector
CFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
export CFLAGS LDFLAGS

debian_cflags = $(CFLAGS)
debian_ldflags = $(LDFLAGS)
<% elsif is_distribution?(">= zesty") -%>
debian_cflags:=$(shell dpkg-buildflags --get CFLAGS) -fPIC $(shell dpkg-buildflags --get CPPFLAGS)
debian_ldflags:=$(shell dpkg-buildflags --get LDFLAGS) -fPIC
<% else -%>
debian_cflags:=$(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
debian_ldflags:=$(shell dpkg-buildflags --get LDFLAGS)
<% end -%>

# export necessary perl hardening flags
# see: src/http/modules/perl/Makefile.PL
<% if is_distribution?(">= zesty") -%>
DEBIAN_NGINX_PERL_LDFLAGS:= $(shell DEB_BUILD_MAINT_OPTIONS=hardening=+all,-PIE dpkg-buildflags --get LDFLAGS)
<% elsif is_distribution?(">= vivid") -%>
DEBIAN_NGINX_PERL_LDFLAGS:= $(shell DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie dpkg-buildflags --get LDFLAGS)
<% else -%>
DEBIAN_NGINX_PERL_LDFLAGS:= $(debian_ldflags)
<% end -%>
export DEBIAN_NGINX_PERL_LDFLAGS

# Speed up ccache (reduce I/O) by lightly compressing things.
# Always set these variables because pbuilder uses ccache transparently.
CCACHE_COMPRESS=1
export CCACHE_COMPRESS
CCACHE_COMPRESS_LEVEL=3
export CCACHE_COMPRESS_LEVEL

FLAVOURS := extras
<% if is_distribution?(">= zesty") -%>
DYN_MODS := \
	http-auth-pam \
	http-cache-purge \
	http-dav-ext \
	http-echo \
	http-fancyindex \
	http-geoip \
	http-headers-more-filter \
	http-image-filter \
	http-lua \
	http-ndk \
	http-perl \
	http-subs-filter \
	http-uploadprogress \
	http-upstream-fair \
	http-xslt-filter \
	mail \
	nchan \
	stream
<% end -%>

MODULESDIR = $(CURDIR)/debian/modules
BASEDIR = $(CURDIR)
$(foreach flavour,$(FLAVOURS),$(eval BUILDDIR_$(flavour) = $(CURDIR)/debian/build-$(flavour)))

DEB_BUILD_ARCH ?=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
ifeq ($(DEB_BUILD_ARCH),sparc)
<% if is_distribution?(">= trusty") || is_distribution?(">= jessie") -%>
	debian_cflags += -m32 -mcpu=ultrasparc
<% else -%>
	CONFIGURE_OPTS = --with-cc-opt="-m32 -mcpu=ultrasparc"
<% end -%>
endif

# Compile Passenger support libraries without Debian's default optimization
# level. Passenger has its own recommended optimization levels.
debian_cflags_nooptimize := $(shell echo "$(debian_cflags)" | sed -E 's/-O[0-3]?//g')


ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKEFLAGS += -j$(NUMJOBS)
endif

<% if is_distribution?(">= zesty") -%>
MODULESPATCHDIR = $(CURDIR)/debian/modules/patches
modules_with_patches := $(notdir $(wildcard $(CURDIR)/debian/modules/patches/*))
<% end -%>

# configure flags
common_configure_flags := \
			--with-cc-opt="$(debian_cflags)" \
			--with-ld-opt="$(debian_ldflags)" \
			--prefix=/usr/share/nginx \
			--conf-path=/etc/nginx/nginx.conf \
			--http-log-path=/var/log/nginx/access.log \
			--error-log-path=/var/log/nginx/error.log \
			--lock-path=/var/lock/nginx.lock \
<% if is_distribution?("<= quantal") || is_distribution?("<= wheezy") -%>
			--pid-path=/var/run/nginx.pid \
<% else -%>
			--pid-path=/run/nginx.pid \
<% end -%>
<% if is_distribution?(">= zesty") -%>
			--modules-path=/usr/lib/nginx/modules \
<% end -%>
			--http-client-body-temp-path=/var/lib/nginx/body \
			--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
			--http-proxy-temp-path=/var/lib/nginx/proxy \
			--http-scgi-temp-path=/var/lib/nginx/scgi \
			--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
			--with-debug \
<% if is_distribution?(">= quantal") || is_distribution?(">= wheezy") -%>
			--with-pcre-jit \
<% end -%>
			--with-ipv6 \
			--with-http_ssl_module \
			--with-http_stub_status_module \
			--with-http_realip_module \
<% if is_distribution?(">= zesty") -%>
			--with-http_auth_request_module \
			--with-http_v2_module \
			--with-http_dav_module \
			--with-http_slice_module \
			--with-threads
<% else -%>
			--with-http_auth_request_module
<% end -%>

extras_configure_flags := \
			$(common_configure_flags) \
			--with-http_addition_module \
<% if is_distribution?("< zesty") -%>
			--with-http_dav_module \
<% end -%>
			--with-http_flv_module \
<% if is_distribution?(">= zesty") -%>
			--with-http_geoip_module=dynamic \
<% else -%>
			--with-http_geoip_module \
<% end -%>
			--with-http_gunzip_module \
			--with-http_gzip_static_module \
<% if is_distribution?(">= zesty") -%>
			--with-http_image_filter_module=dynamic \
<% else -%>
			--with-http_image_filter_module \
<% end -%>
			--with-http_mp4_module \
<% if is_distribution?(">= zesty") -%>
			--with-http_perl_module=dynamic \
<% else -%>
			--with-http_perl_module \
<% end -%>
			--with-http_random_index_module \
			--with-http_secure_link_module \
<% if is_distribution?("< zesty") -%>
			--with-http_v2_module \
<% end -%>
			--with-http_sub_module \
<% if is_distribution?(">= zesty") -%>
			--with-http_xslt_module=dynamic \
			--with-mail=dynamic \
<% else -%>
			--with-http_xslt_module \
			--with-mail \
<% end -%>
			--with-mail_ssl_module \
<% if is_distribution?(">= zesty") -%>
			--with-stream=dynamic \
<% else -%>
			--with-stream \
<% end -%>
			--with-stream_ssl_module \
<% if is_distribution?(">= zesty") -%>
			--add-dynamic-module=$(MODULESDIR)/headers-more-nginx-module \
			--add-dynamic-module=$(MODULESDIR)/nginx-auth-pam \
			--add-dynamic-module=$(MODULESDIR)/nginx-cache-purge \
			--add-dynamic-module=$(MODULESDIR)/nginx-dav-ext-module \
			--add-dynamic-module=$(MODULESDIR)/nginx-development-kit \
			--add-dynamic-module=$(MODULESDIR)/nginx-echo \
			--add-dynamic-module=$(MODULESDIR)/ngx-fancyindex \
			--add-dynamic-module=$(MODULESDIR)/nchan \
			--add-dynamic-module=$(MODULESDIR)/nginx-lua \
			--add-dynamic-module=$(MODULESDIR)/nginx-upload-progress \
			--add-dynamic-module=$(MODULESDIR)/nginx-upstream-fair \
			--add-dynamic-module=$(MODULESDIR)/ngx_http_substitutions_filter_module \
<% else -%>
			--with-threads \
			--add-module=$(MODULESDIR)/headers-more-nginx-module \
			--add-module=$(MODULESDIR)/nginx-auth-pam \
			--add-module=$(MODULESDIR)/nginx-cache-purge \
			--add-module=$(MODULESDIR)/nginx-dav-ext-module \
			--add-module=$(MODULESDIR)/nginx-development-kit \
			--add-module=$(MODULESDIR)/nginx-echo \
			--add-module=$(MODULESDIR)/ngx-fancyindex \
			--add-module=$(MODULESDIR)/nchan \
			--add-module=$(MODULESDIR)/nginx-lua \
			--add-module=$(MODULESDIR)/nginx-upload-progress \
			--add-module=$(MODULESDIR)/nginx-upstream-fair \
			--add-module=$(MODULESDIR)/ngx_http_substitutions_filter_module \
<% end -%>
			--add-module=$(MODULESDIR)/passenger/src/nginx_module

<% if is_distribution?(">= utopic") || is_distribution?(">= jessie") -%>
%:
	dh $@ --with systemd
<% else -%>
%:
	dh $@
<% end -%>

<% if is_distribution?(">= zesty") -%>
override_dh_auto_configure: config_patch_modules $(foreach flavour,$(FLAVOURS),config.arch.$(flavour))
<% else -%>
override_dh_auto_configure: $(foreach flavour,$(FLAVOURS),config.arch.$(flavour))
<% end -%>

override_dh_auto_build:     $(foreach flavour,$(FLAVOURS),build.arch.$(flavour))
	vendordir=`/usr/bin/ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendordir"]'` && \
		sed -i "s|@RUBYLIBDIR@|$$vendordir|g" debian/conf/passenger.conf
<% if is_distribution?("< wily") -%>
	rm debian/nginx-common.nginx.upstart
<% end -%>

<% if is_distribution?(">= zesty") -%>
override_dh_strip:          $(foreach flavour,$(FLAVOURS),strip.arch.$(flavour)) $(foreach mod,$(DYN_MODS),strip.mods.$(mod))
override_dh_clean:          clean_patch_modules $(foreach flavour,$(FLAVOURS),clean.$(flavour))
<% else -%>
override_dh_strip:          $(foreach flavour,$(FLAVOURS),strip.arch.$(flavour))
override_dh_clean:          $(foreach flavour,$(FLAVOURS),clean.$(flavour))
<% end -%>
	dh_clean

<% if is_distribution?(">= zesty") -%>
override_dh_install:
	dh_install
	DH_AUTOSCRIPTDIR=$(CURDIR)/debian/autoscripts debian/dh_nginx
<% end -%>

override_dh_installinit:
	dh_installinit --no-restart-on-upgrade --no-start --name=nginx

override_dh_systemd_enable:
	dh_systemd_enable --name=nginx

override_dh_installlogrotate:
	dh_installlogrotate --package nginx-common --name=nginx

build.arch.%:
	$(MAKE) -C $(BUILDDIR_$*) build

strip.arch.%:
<% if is_distribution?(">= zesty") -%>
	dh_strip --package=nginx-$(*) -O--dbgsym-migration='nginx-$(*)-dbg (<< 1.10.1-3~)'

strip.mods.%:
	dh_strip --package=libnginx-mod-$(*) -O--automatic-dbgsym

config_patch_modules: $(foreach mod,$(modules_with_patches),config.patch.$(mod))
config.patch.%:
	cd $(MODULESDIR)/$* && QUILT_PATCHES=$(MODULESPATCHDIR)/$* quilt push -a

clean_patch_modules: $(foreach mod,$(modules_with_patches),clean.patch.$(mod))
clean.patch.%:
	if [ -s $(MODULESDIR)/$*/.pc/applied-patches ]; then \
		cd $(MODULESDIR)/$* && QUILT_PATCHES=$(MODULESPATCHDIR)/$* quilt pop -q -a; \
		rm -rf $(MODULESDIR)/$*/.pc; \
	fi
<% else -%>
	dh_strip --package=nginx-$(*) --dbg-package=nginx-$(*)-dbg
<% end -%>

passenger_nginx_libs:
	cd $(MODULESDIR)/passenger/src/nginx_module && \
		EXTRA_CFLAGS="$(debian_cflags_nooptimize)" \
		EXTRA_CXXFLAGS="$(debian_cflags_nooptimize)" \
		EXTRA_LDFLAGS="$(debian_ldflags)" \
		OPTIMIZE=yes \
		rake nginx

<%
# For some reason, html copy was not specified in the xenial packaging rules (needed
# because of reference in nginx-common.install).
-%>
config.arch.%: passenger_nginx_libs
	dh_testdir
	mkdir -p $(BUILDDIR_$*)
	cp -Pa $(CURDIR)/auto $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/conf $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/configure $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/contrib $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/src $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/man $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/html $(BUILDDIR_$*)/
	cd $(BUILDDIR_$*) && ./configure $($*_configure_flags)

clean.%:
	rm -rf $(BUILDDIR_$*)

<% if is_distribution?(">= zesty") -%>
.PHONY: config_patch_modules clean_patch_modules
<% end -%>
<commit_msg>Nginx package: enable http_v2, http_dav, http_slice, threads on < zesty<commit_after><%
require File.dirname(File.absolute_path(__FILE__)) + '/helpers'
-%>
#!/usr/bin/make -f
export DH_VERBOSE=1

<% if is_distribution?(">= vivid") -%>
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
<% end -%>
<% if is_distribution?("<= saucy") || is_distribution?("<= wheezy") -%>
CFLAGS := $(shell dpkg-buildflags --get CFLAGS)
CFLAGS += -Wall -DFORTIFY_SOURCE=2 -fstack-protector
CFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
export CFLAGS LDFLAGS

debian_cflags = $(CFLAGS)
debian_ldflags = $(LDFLAGS)
<% elsif is_distribution?(">= zesty") -%>
debian_cflags:=$(shell dpkg-buildflags --get CFLAGS) -fPIC $(shell dpkg-buildflags --get CPPFLAGS)
debian_ldflags:=$(shell dpkg-buildflags --get LDFLAGS) -fPIC
<% else -%>
debian_cflags:=$(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
debian_ldflags:=$(shell dpkg-buildflags --get LDFLAGS)
<% end -%>

# export necessary perl hardening flags
# see: src/http/modules/perl/Makefile.PL
<% if is_distribution?(">= zesty") -%>
DEBIAN_NGINX_PERL_LDFLAGS:= $(shell DEB_BUILD_MAINT_OPTIONS=hardening=+all,-PIE dpkg-buildflags --get LDFLAGS)
<% elsif is_distribution?(">= vivid") -%>
DEBIAN_NGINX_PERL_LDFLAGS:= $(shell DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie dpkg-buildflags --get LDFLAGS)
<% else -%>
DEBIAN_NGINX_PERL_LDFLAGS:= $(debian_ldflags)
<% end -%>
export DEBIAN_NGINX_PERL_LDFLAGS

# Speed up ccache (reduce I/O) by lightly compressing things.
# Always set these variables because pbuilder uses ccache transparently.
CCACHE_COMPRESS=1
export CCACHE_COMPRESS
CCACHE_COMPRESS_LEVEL=3
export CCACHE_COMPRESS_LEVEL

FLAVOURS := extras
<% if is_distribution?(">= zesty") -%>
DYN_MODS := \
	http-auth-pam \
	http-cache-purge \
	http-dav-ext \
	http-echo \
	http-fancyindex \
	http-geoip \
	http-headers-more-filter \
	http-image-filter \
	http-lua \
	http-ndk \
	http-perl \
	http-subs-filter \
	http-uploadprogress \
	http-upstream-fair \
	http-xslt-filter \
	mail \
	nchan \
	stream
<% end -%>

MODULESDIR = $(CURDIR)/debian/modules
BASEDIR = $(CURDIR)
$(foreach flavour,$(FLAVOURS),$(eval BUILDDIR_$(flavour) = $(CURDIR)/debian/build-$(flavour)))

DEB_BUILD_ARCH ?=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
ifeq ($(DEB_BUILD_ARCH),sparc)
<% if is_distribution?(">= trusty") || is_distribution?(">= jessie") -%>
	debian_cflags += -m32 -mcpu=ultrasparc
<% else -%>
	CONFIGURE_OPTS = --with-cc-opt="-m32 -mcpu=ultrasparc"
<% end -%>
endif

# Compile Passenger support libraries without Debian's default optimization
# level. Passenger has its own recommended optimization levels.
debian_cflags_nooptimize := $(shell echo "$(debian_cflags)" | sed -E 's/-O[0-3]?//g')


ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKEFLAGS += -j$(NUMJOBS)
endif

<% if is_distribution?(">= zesty") -%>
MODULESPATCHDIR = $(CURDIR)/debian/modules/patches
modules_with_patches := $(notdir $(wildcard $(CURDIR)/debian/modules/patches/*))
<% end -%>

# configure flags
common_configure_flags := \
			--with-cc-opt="$(debian_cflags)" \
			--with-ld-opt="$(debian_ldflags)" \
			--prefix=/usr/share/nginx \
			--conf-path=/etc/nginx/nginx.conf \
			--http-log-path=/var/log/nginx/access.log \
			--error-log-path=/var/log/nginx/error.log \
			--lock-path=/var/lock/nginx.lock \
<% if is_distribution?("<= quantal") || is_distribution?("<= wheezy") -%>
			--pid-path=/var/run/nginx.pid \
<% else -%>
			--pid-path=/run/nginx.pid \
<% end -%>
<% if is_distribution?(">= zesty") -%>
			--modules-path=/usr/lib/nginx/modules \
<% end -%>
			--http-client-body-temp-path=/var/lib/nginx/body \
			--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
			--http-proxy-temp-path=/var/lib/nginx/proxy \
			--http-scgi-temp-path=/var/lib/nginx/scgi \
			--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
			--with-debug \
<% if is_distribution?(">= quantal") || is_distribution?(">= wheezy") -%>
			--with-pcre-jit \
<% end -%>
			--with-ipv6 \
			--with-http_ssl_module \
			--with-http_stub_status_module \
			--with-http_realip_module \
			--with-http_auth_request_module \
			--with-http_v2_module \
			--with-http_dav_module \
			--with-http_slice_module \
			--with-threads

extras_configure_flags := \
			$(common_configure_flags) \
			--with-http_addition_module \
<% if is_distribution?("< zesty") -%>
			--with-http_dav_module \
<% end -%>
			--with-http_flv_module \
<% if is_distribution?(">= zesty") -%>
			--with-http_geoip_module=dynamic \
<% else -%>
			--with-http_geoip_module \
<% end -%>
			--with-http_gunzip_module \
			--with-http_gzip_static_module \
<% if is_distribution?(">= zesty") -%>
			--with-http_image_filter_module=dynamic \
<% else -%>
			--with-http_image_filter_module \
<% end -%>
			--with-http_mp4_module \
<% if is_distribution?(">= zesty") -%>
			--with-http_perl_module=dynamic \
<% else -%>
			--with-http_perl_module \
<% end -%>
			--with-http_random_index_module \
			--with-http_secure_link_module \
			--with-http_v2_module \
			--with-http_sub_module \
<% if is_distribution?(">= zesty") -%>
			--with-http_xslt_module=dynamic \
			--with-mail=dynamic \
<% else -%>
			--with-http_xslt_module \
			--with-mail \
<% end -%>
			--with-mail_ssl_module \
<% if is_distribution?(">= zesty") -%>
			--with-stream=dynamic \
<% else -%>
			--with-stream \
<% end -%>
			--with-stream_ssl_module \
<% if is_distribution?(">= zesty") -%>
			--add-dynamic-module=$(MODULESDIR)/headers-more-nginx-module \
			--add-dynamic-module=$(MODULESDIR)/nginx-auth-pam \
			--add-dynamic-module=$(MODULESDIR)/nginx-cache-purge \
			--add-dynamic-module=$(MODULESDIR)/nginx-dav-ext-module \
			--add-dynamic-module=$(MODULESDIR)/nginx-development-kit \
			--add-dynamic-module=$(MODULESDIR)/nginx-echo \
			--add-dynamic-module=$(MODULESDIR)/ngx-fancyindex \
			--add-dynamic-module=$(MODULESDIR)/nchan \
			--add-dynamic-module=$(MODULESDIR)/nginx-lua \
			--add-dynamic-module=$(MODULESDIR)/nginx-upload-progress \
			--add-dynamic-module=$(MODULESDIR)/nginx-upstream-fair \
			--add-dynamic-module=$(MODULESDIR)/ngx_http_substitutions_filter_module \
<% else -%>
			--with-threads \
			--add-module=$(MODULESDIR)/headers-more-nginx-module \
			--add-module=$(MODULESDIR)/nginx-auth-pam \
			--add-module=$(MODULESDIR)/nginx-cache-purge \
			--add-module=$(MODULESDIR)/nginx-dav-ext-module \
			--add-module=$(MODULESDIR)/nginx-development-kit \
			--add-module=$(MODULESDIR)/nginx-echo \
			--add-module=$(MODULESDIR)/ngx-fancyindex \
			--add-module=$(MODULESDIR)/nchan \
			--add-module=$(MODULESDIR)/nginx-lua \
			--add-module=$(MODULESDIR)/nginx-upload-progress \
			--add-module=$(MODULESDIR)/nginx-upstream-fair \
			--add-module=$(MODULESDIR)/ngx_http_substitutions_filter_module \
<% end -%>
			--add-module=$(MODULESDIR)/passenger/src/nginx_module

<% if is_distribution?(">= utopic") || is_distribution?(">= jessie") -%>
%:
	dh $@ --with systemd
<% else -%>
%:
	dh $@
<% end -%>

<% if is_distribution?(">= zesty") -%>
override_dh_auto_configure: config_patch_modules $(foreach flavour,$(FLAVOURS),config.arch.$(flavour))
<% else -%>
override_dh_auto_configure: $(foreach flavour,$(FLAVOURS),config.arch.$(flavour))
<% end -%>

override_dh_auto_build:     $(foreach flavour,$(FLAVOURS),build.arch.$(flavour))
	vendordir=`/usr/bin/ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendordir"]'` && \
		sed -i "s|@RUBYLIBDIR@|$$vendordir|g" debian/conf/passenger.conf
<% if is_distribution?("< wily") -%>
	rm debian/nginx-common.nginx.upstart
<% end -%>

<% if is_distribution?(">= zesty") -%>
override_dh_strip:          $(foreach flavour,$(FLAVOURS),strip.arch.$(flavour)) $(foreach mod,$(DYN_MODS),strip.mods.$(mod))
override_dh_clean:          clean_patch_modules $(foreach flavour,$(FLAVOURS),clean.$(flavour))
<% else -%>
override_dh_strip:          $(foreach flavour,$(FLAVOURS),strip.arch.$(flavour))
override_dh_clean:          $(foreach flavour,$(FLAVOURS),clean.$(flavour))
<% end -%>
	dh_clean

<% if is_distribution?(">= zesty") -%>
override_dh_install:
	dh_install
	DH_AUTOSCRIPTDIR=$(CURDIR)/debian/autoscripts debian/dh_nginx
<% end -%>

override_dh_installinit:
	dh_installinit --no-restart-on-upgrade --no-start --name=nginx

override_dh_systemd_enable:
	dh_systemd_enable --name=nginx

override_dh_installlogrotate:
	dh_installlogrotate --package nginx-common --name=nginx

build.arch.%:
	$(MAKE) -C $(BUILDDIR_$*) build

strip.arch.%:
<% if is_distribution?(">= zesty") -%>
	dh_strip --package=nginx-$(*) -O--dbgsym-migration='nginx-$(*)-dbg (<< 1.10.1-3~)'

strip.mods.%:
	dh_strip --package=libnginx-mod-$(*) -O--automatic-dbgsym

config_patch_modules: $(foreach mod,$(modules_with_patches),config.patch.$(mod))
config.patch.%:
	cd $(MODULESDIR)/$* && QUILT_PATCHES=$(MODULESPATCHDIR)/$* quilt push -a

clean_patch_modules: $(foreach mod,$(modules_with_patches),clean.patch.$(mod))
clean.patch.%:
	if [ -s $(MODULESDIR)/$*/.pc/applied-patches ]; then \
		cd $(MODULESDIR)/$* && QUILT_PATCHES=$(MODULESPATCHDIR)/$* quilt pop -q -a; \
		rm -rf $(MODULESDIR)/$*/.pc; \
	fi
<% else -%>
	dh_strip --package=nginx-$(*) --dbg-package=nginx-$(*)-dbg
<% end -%>

passenger_nginx_libs:
	cd $(MODULESDIR)/passenger/src/nginx_module && \
		EXTRA_CFLAGS="$(debian_cflags_nooptimize)" \
		EXTRA_CXXFLAGS="$(debian_cflags_nooptimize)" \
		EXTRA_LDFLAGS="$(debian_ldflags)" \
		OPTIMIZE=yes \
		rake nginx

<%
# For some reason, html copy was not specified in the xenial packaging rules (needed
# because of reference in nginx-common.install).
-%>
config.arch.%: passenger_nginx_libs
	dh_testdir
	mkdir -p $(BUILDDIR_$*)
	cp -Pa $(CURDIR)/auto $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/conf $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/configure $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/contrib $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/src $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/man $(BUILDDIR_$*)/
	cp -Pa $(CURDIR)/html $(BUILDDIR_$*)/
	cd $(BUILDDIR_$*) && ./configure $($*_configure_flags)

clean.%:
	rm -rf $(BUILDDIR_$*)

<% if is_distribution?(">= zesty") -%>
.PHONY: config_patch_modules clean_patch_modules
<% end -%>

{'fraction_non_alphanumeric': 0.19714592903919462, 'fraction_numerical': 0.0019059720457433292, 'mean_word_length': 4.033948339483395, 'pattern_counts': {'":': 0, '<': 154, '<?xml version=': 0, '>': 185, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4011564', 'n_tokens_mistral': 8643, 'n_tokens_neox': 7988, 'n_words': 1158}