#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh --with autotools-dev $@

override_dh_prep:
	dh_prep
	debconf-updatepo

override_dh_auto_configure:
	# Add here commands to configure the package.
	CPPFLAGS="$(CPPFLAGS) -D_GNU_SOURCE -Wl,-z,defs" dh_auto_configure -- --libexecdir=/usr/lib --localstatedir=/var/spool

# override_dh_build:
	#dh_build
	#docbook-to-man debian/nullmailer.sgml > nullmailer.1

PKGDIR = $(CURDIR)/debian/nullmailer
SPOOLDIR = $(CURDIR)/debian/nullmailer/var/spool/nullmailer

# remove trigger from the .deb (Policy 3.8.4 s10.6) - it must be created in initscript
override_dh_auto_install:
	dh_auto_install
	rm -f $(SPOOLDIR)/trigger

override_dh_fixperms:
	dh_fixperms
	chown mail $(PKGDIR)/usr/sbin/nullmailer-queue $(PKGDIR)/usr/bin/mailq
	chmod 4755 $(PKGDIR)/usr/sbin/nullmailer-queue $(PKGDIR)/usr/bin/mailq
	chown -R mail:root $(SPOOLDIR)
	chmod 0755 $(SPOOLDIR)
	chmod 0750 $(SPOOLDIR)/queue $(SPOOLDIR)/tmp
