#!/usr/bin/make -f

export DEB_CFLAGS_MAINT_APPEND  = -Wall -Wformat=2 -Wunused -Wundef -Wextra -Wswitch-enum -Wpointer-arith -Wnested-externs -Wbad-function-cast -Wcast-qual -Wcast-align -Wshadow

%:
	dh ${@} --with autoreconf

override_dh_autoreconf:
	dh_autotools-dev_updateconfig
	dh_autoreconf autoconf -- --verbose --include=autoconf --output=configure autoconf/configure.ac

override_dh_auto_build:
	./configure \
		--with-slrnpull=/var/spool/slrnpull \
		--with-gnutls=/usr/lib/$(DEB_HOST_MULTIARCH) \
		--enable-inews --enable-spool \
		--enable-setgid-code \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--sysconfdir=/etc/news \
		--with-server-file=/etc/news/server \
		--with-canlock \
		--without-x \
		--with-uu \
		--with-slanglib=/usr/lib/$(DEB_HOST_MULTIARCH) \
		--with-slanginc=/usr/include

	$(MAKE) -C src CONFDIR=/etc/news slrn
	$(MAKE) CANLOCK_LIB= UUDEVIEW_LIB= CONFDIR=/etc/news slrnpull

override_dh_install-arch:
	$(MAKE) install DESTDIR=debian/tmp
	chrpath --delete debian/tmp/usr/bin/slrn
	dh_install

	cp debian/tmp/usr/share/doc/slrn/help.txt \
	  debian/slrn/etc/news/slrn-help.txt

	chown news.news debian/slrn/etc/news debian/slrn//var/lib/slrn
	# The perms on these directories are set so that files in them
	# are owned by group news, but the directories are only writable
	# by user news. out.going is g+w,+t since users write there.
	chown -R news.news debian/slrnpull/var/spool/slrnpull
	chmod g+ws,+t debian/slrnpull/var/spool/slrnpull/out.going \
	  debian/slrnpull/var/spool/slrnpull/out.going/rejects
	chmod g+ws,o+w,+t debian/slrnpull/var/spool/slrnpull/requests


override_dh_autoreconf_clean:
	dh_autotools-dev_restoreconfig
	dh_autoreconf_clean
