#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

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

DEB_BUILD_MAINT_OPTIONS = hardening=+all
DEB_CFLAGS_MAINT_PREPEND = -Wall -std=gnu89

include /usr/share/dpkg/default.mk

ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
	confflags += --build=$(DEB_HOST_GNU_TYPE)
else
	confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
endif

configure: configure.ac
	dh_testdir
	dh_autoreconf

config.status: configure
	dh_testdir

	./configure \
		CPPFLAGS="$(CPPFLAGS)" \
		CFLAGS="$(CFLAGS)" \
		LDFLAGS="$(LDFLAGS)" \
		$(confflags) \
		--prefix=/usr \
		--mandir=\$${prefix}/share/man \
		--infodir=\$${prefix}/share/info \
		--disable-raw-support \
		$(nil)

build-indep:
build-arch: config.status
	dh_testdir

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) VERBOSE=1 check
else
	$(MAKE)
endif

build: build-indep build-arch

clean:
	dh_testdir
	dh_testroot

	[ ! -f Makefile ] || $(MAKE) distclean

	dh_autoreconf_clean
	dh_clean

.PHONY: build-indep build-arch build clean

install-arch: build-arch
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	$(MAKE) install DESTDIR=$(CURDIR)/debian/sipsak

binary-indep: build-indep
# We have nothing to do by default.

binary-arch: install-arch
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installexamples
#	dh_install
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch

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