#!/usr/bin/make -f

ifneq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
	DEB_BUILD_DOCS=0
else
	DEB_BUILD_DOCS=1
endif


build-arch:	build-arch-stamp
build-arch-stamp:
	dh build --before configure
	dh_auto_configure -- \
		--enable-full-doc \
		--with-guis="fox16 qt4 gtk2"
	dh build --after configure --before dh_auto_test
	# Skip dh_auto_test (fails without network, see http://bugs.debian.org/503181 )
	dh build --after dh_auto_test
	$(MAKE) -C debian/man
	touch build-arch-stamp

build-indep:	build-indep-stamp
build-indep-stamp:	build-arch
	if [ "$(DEB_BUILD_DOCS)" = "1" ]; then \
		find ./gwenhywfar4/gwenhywfar -name "*.h" > listdoc.h; \
		$(MAKE) srcdoc; \
	else \
		mkdir apidoc; \
	fi

	touch build-indep-stamp

build:	build-arch build-indep

override_dh_strip:
	dh_strip --dbg-package=libgwenhywfar60-dbg

clean:
	dh clean
	rm -rvf apidoc listdoc.h gwenhywfar.tag gwenhywfar3
	$(MAKE) -C debian/man clean

%:
	dh $@

override_dh_auto_install:
	dh_auto_install
	# Remove upstream's poorly maintained CA bundle and replace it by the
	# CA bundle managed by the package ca-certificates (fixes Debian bug 748955)
	rm -v debian/tmp/usr/share/gwenhywfar/ca-bundle.crt
	ln -vs /etc/ssl/certs/ca-certificates.crt \
		debian/tmp/usr/share/gwenhywfar/ca-bundle.crt

.PHONY:	clean build build-arch build-indep
