#!/usr/bin/make -f

#export DH_VERBOSE=1


DEBDIR=`pwd`/debian/nginx


build: build-stamp

build-stamp:
	dh_testdir
	
	./configure \
		--prefix=/opt/nginx \
		--sbin-path=/opt/nginx/nginx \
		--conf-path=/opt/nginx/nginx.conf \
		--error-log-path=/opt/nginx/logs/error.log \
		--http-log-path=/opt/nginx/logs/access.log \
		--pid-path=/opt/nginx/logs/nginx.pid \
		--lock-path=/opt/nginx/logs/nginx.lock \
		--http-client-body-temp-path=/opt/nginx/optified/client_temp \
		--http-proxy-temp-path=/opt/nginx/optified/proxy_temp \
		--http-fastcgi-temp-path=/opt/nginx/optified/fastcgi_temp \
		--http-uwsgi-temp-path=/opt/nginx/optified/uwsgi_temp \
		--http-scgi-temp-path=/opt/nginx/optified/scgi_temp \
		--user=user \
		--group=users \
		--with-http_ssl_module \
		--with-http_realip_module \
		--with-http_addition_module \
		--with-http_sub_module \
		--with-http_dav_module \
		--with-http_flv_module \
		--with-http_mp4_module \
		--with-http_gzip_static_module \
		--with-http_random_index_module \
		--with-http_secure_link_module \
		--with-http_stub_status_module \
		--with-mail \
		--with-mail_ssl_module \
		--with-ipv6
		#--with-file-aio GENERATES A COMPILATION ERROR UNDER SCRATCHBOX
		
	$(MAKE)

	touch build-stamp
	

clean: 
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp


install: build-stamp
	dh_testdir
	dh_testroot
	$(MAKE) DESTDIR=$(DEBDIR) install
	install -d -m 755 $(DEBDIR)/opt/nginx/optified


# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.


# Build architecture-dependent files here.
binary-arch: build-stamp install
	dh_testdir
	dh_testroot
#	dh_installdebconf	
#	dh_installdocs -XCVS
#	dh_installexamples
#	dh_installmenu
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
#	dh_installcron
#	dh_installman
#	dh_installinfo
#	dh_undocumented
#	dh_installchangelogs ChangeLog
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb
	

binary: install binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

