#!/usr/bin/make -f

CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS  = $(shell dpkg-buildflags --get CFLAGS) -Wall -Wextra
LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
export CPPFLAGS CFLAGS LDFLAGS

builddir = debian/webfs
installdir = $(CURDIR)/$(builddir)

clean:
	dh $@

build-arch: build
build-indep: build

build:
	[ -f Make.config ] || cp debian/Make.config ./
	dh --before dh_auto_build $@
	$(MAKE) verbose=yes prefix=/usr
	dh --remaining $@

install: build
	$(MAKE) install  \
			prefix=$(installdir)/usr \
			mandir=$(installdir)/usr/share/man
	install -d $(installdir)/usr/share/webfs
	install -m 0644 debian/webfsd.conf \
		$(installdir)/usr/share/webfs/webfsd.conf.auto

binary-arch: install
	dh_testroot -a
	dh_installdirs -a
	#dh --before dh_auto_install $@
	dh_install --sourcedir=$(builddir)
	dh_installchangelogs -a -k README
	dh --after dh_auto_install $@

binary-indep:

binary: binary-arch

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