#!/usr/bin/make -f

NEWSDIR=/var/lib/sysnews

CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp:
	dh --before dh_auto_build build
	dh_auto_build -- NEWSDIR=$(NEWSDIR) LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS) $(CPPFLAGS)"
	dh --after dh_auto_build build
	touch $@

clean:
	dh $@

install: install-stamp
install-stamp: build-stamp
	dh --before dh_auto_install install
	dh_auto_install -- PREFIX=debian/sysnews/usr NEWSDIR=$(NEWSDIR)
	dh --before dh_fixperms --after dh_auto_install install
	chown root.staff debian/sysnews/var/lib/sysnews
	chmod g+ws debian/sysnews/var/lib/sysnews
	dh --after dh_fixperms install
	touch $@

binary-indep: build install

binary-arch: build install
	dh $@


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