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

<% if ['1', 'true', 'on', 'yes'].include?(ENV['USE_CCACHE']) -%>
export USE_CCACHE=1
NGINX_CONFIGURE_OPTIONS = CC=/usr/lib/ccache/cc CXX=/usr/lib/ccache/c++
<% else -%>
NGINX_CONFIGURE_OPTIONS =
<% end -%>

# 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_COMPRESSLEVEL=3
export CCACHE_COMPRESSLEVEL

%:
	dh $@

override_dh_auto_configure:
	# Do nothing

override_dh_auto_build:
	vendordir=`/usr/bin/ruby<%= distro_ruby_versions[0] %> -rrbconfig -e 'puts RbConfig::CONFIG["vendordir"]'` && \
		sed -i "s|@RUBYLIBDIR@|$$vendordir|g" \
			debian/locations.ini \
			debian/passenger.install \
			debian/mod-http-passenger.conf \
			debian/passenger.conf
<% distro_ruby_versions.each do |ruby_version| -%>
	vendordir=`/usr/bin/ruby<%= ruby_version %> -rrbconfig -e 'puts RbConfig::CONFIG["vendordir"]'` && \
		archdir=`/usr/bin/ruby<%= ruby_version %> -rrbconfig -e 'puts RbConfig::CONFIG["archdir"]'` && \
		/usr/bin/ruby<%= ruby_version %> /usr/bin/rake fakeroot \
			RUBYLIBDIR="$$vendordir" \
			RUBYARCHDIR="$$archdir" \
			RUBY=/usr/bin/passenger_system_ruby \
			FREE_RUBY=/usr/bin/passenger_free_ruby
	mv pkg/fakeroot pkg/fakeroot<%= ruby_version %>
	/usr/bin/ruby<%= ruby_version %> -rrbconfig -e 'puts RbConfig::CONFIG["archdir"]' >> debian/passenger.install
<% end -%>
	cc -Wall -Os debian/passenger_free_ruby.c -o debian/passenger_free_ruby
	cc -Wall -Os debian/passenger_system_ruby.c -o debian/passenger_system_ruby
	cd nginx-<%= PhusionPassenger::PREFERRED_NGINX_VERSION %> && \
		env $(NGINX_CONFIGURE_OPTIONS) ./configure --prefix=/tmp \
		<%= PhusionPassenger::Config::NginxEngineCompiler.configure_script_options %> \
		--add-module=`pwd`/../src/nginx_module && \
		make && \
		mv objs/nginx objs/nginx-<%= PhusionPassenger::PREFERRED_NGINX_VERSION %>
<% if dynamic_module_supported?(@distribution) -%>
	/usr/bin/rake nginx:as_dynamic_module && \
		cd nginx-<%= latest_nginx_available(@distribution) %> && \
		./configure --with-pcre-jit --with-threads \
<% if is_distribution?("== stretch")
# In stretch we have the unique situation of an Nginx new enough to support dynamic
# modules, but too old to have the ipv6 flag auto-enabled. The flag is already
# enabled in older distros because there we statically link against the latest Nginx, 
# and newer distros have Nginx 1.12+.
-%>
		--with-ipv6 \
<% end -%>
		--with-http_gzip_static_module --with-http_gunzip_module \
		--with-http_v2_module --with-http_dav_module \
		--with-http_realip_module --with-http_geoip_module=dynamic \
		--with-http_ssl_module --http-proxy-temp-path=/var/lib/nginx/proxy \
		--add-dynamic-module=`pwd`/../src/nginx_module && \
		echo '#define NGX_HTTP_HEADERS 1' >> objs/ngx_auto_config.h && \
		make -f objs/Makefile modules && \
		mv objs/ngx_http_passenger_module.so ../debian/ || \
		mv modules/ngx_http_passenger_module.so ../debian/
<% else -%>
	rm debian/libnginx-mod-http-passenger.*
<% end -%>

override_dh_auto_install:
	mkdir debian/tmp/<commit_msg>try to make dyn nginx module compatible with system nginx on disco<commit_after><%
require File.dirname(File.absolute_path(__FILE__)) + '/helpers'
-%>
#!/usr/bin/make -f
# export DH_VERBOSE=1

<% if ['1', 'true', 'on', 'yes'].include?(ENV['USE_CCACHE']) -%>
export USE_CCACHE=1
NGINX_CONFIGURE_OPTIONS = CC=/usr/lib/ccache/cc CXX=/usr/lib/ccache/c++
<% else -%>
NGINX_CONFIGURE_OPTIONS =
<% end -%>

# 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_COMPRESSLEVEL=3
export CCACHE_COMPRESSLEVEL

%:
	dh $@

override_dh_auto_configure:
	# Do nothing

override_dh_auto_build:
	vendordir=`/usr/bin/ruby<%= distro_ruby_versions[0] %> -rrbconfig -e 'puts RbConfig::CONFIG["vendordir"]'` && \
		sed -i "s|@RUBYLIBDIR@|$$vendordir|g" \
			debian/locations.ini \
			debian/passenger.install \
			debian/mod-http-passenger.conf \
			debian/passenger.conf
<% distro_ruby_versions.each do |ruby_version| -%>
	vendordir=`/usr/bin/ruby<%= ruby_version %> -rrbconfig -e 'puts RbConfig::CONFIG["vendordir"]'` && \
		archdir=`/usr/bin/ruby<%= ruby_version %> -rrbconfig -e 'puts RbConfig::CONFIG["archdir"]'` && \
		/usr/bin/ruby<%= ruby_version %> /usr/bin/rake fakeroot \
			RUBYLIBDIR="$$vendordir" \
			RUBYARCHDIR="$$archdir" \
			RUBY=/usr/bin/passenger_system_ruby \
			FREE_RUBY=/usr/bin/passenger_free_ruby
	mv pkg/fakeroot pkg/fakeroot<%= ruby_version %>
	/usr/bin/ruby<%= ruby_version %> -rrbconfig -e 'puts RbConfig::CONFIG["archdir"]' >> debian/passenger.install
<% end -%>
	cc -Wall -Os debian/passenger_free_ruby.c -o debian/passenger_free_ruby
	cc -Wall -Os debian/passenger_system_ruby.c -o debian/passenger_system_ruby
	cd nginx-<%= PhusionPassenger::PREFERRED_NGINX_VERSION %> && \
		env $(NGINX_CONFIGURE_OPTIONS) ./configure --prefix=/tmp \
		<%= PhusionPassenger::Config::NginxEngineCompiler.configure_script_options %> \
		--add-module=`pwd`/../src/nginx_module && \
		make && \
		mv objs/nginx objs/nginx-<%= PhusionPassenger::PREFERRED_NGINX_VERSION %>
<% if dynamic_module_supported?(@distribution) -%>
	/usr/bin/rake nginx:as_dynamic_module && \
		cd nginx-<%= latest_nginx_available(@distribution) %> && \
		./configure --with-pcre-jit --with-threads \
<% if is_distribution?("== stretch")
# In stretch we have the unique situation of an Nginx new enough to support dynamic
# modules, but too old to have the ipv6 flag auto-enabled. The flag is already
# enabled in older distros because there we statically link against the latest Nginx, 
# and newer distros have Nginx 1.12+.
-%>
		--with-ipv6 \
<% elsif is_distribution?("== disco") -%>
		--with-compat \
<% end -%>
		--with-http_gzip_static_module --with-http_gunzip_module \
		--with-http_v2_module --with-http_dav_module \
		--with-http_realip_module --with-http_geoip_module=dynamic \
		--with-http_ssl_module --http-proxy-temp-path=/var/lib/nginx/proxy \
		--add-dynamic-module=`pwd`/../src/nginx_module && \
		echo '#define NGX_HTTP_HEADERS 1' >> objs/ngx_auto_config.h && \
		make -f objs/Makefile modules && \
		mv objs/ngx_http_passenger_module.so ../debian/ || \
		mv modules/ngx_http_passenger_module.so ../debian/
<% else -%>
	rm debian/libnginx-mod-http-passenger.*
<% end -%>

override_dh_auto_install:
	mkdir debian/tmp/
{'fraction_non_alphanumeric': 0.157227904136773, 'fraction_numerical': 0.0039688597160738815, 'mean_word_length': 4.300970873786408, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 54, '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': '3691247', 'n_tokens_mistral': 2709, 'n_tokens_neox': 2450, 'n_words': 450}