#! /usr/bin/make -f
#
#	Build script for the KVIrc 3 debian packages.
#	Using Common Debian Build System (CDBS).
#

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

#
#	Specify extra configure options:
#
DEB_CONFIGURE_EXTRA_FLAGS := --with-fno-rtti --with-aa-fonts --with-big-channels --with-system-memmove
DEB_CONFIGURE_EXTRA_FLAGS += --mandir=$(DEB_CONFIGURE_MANDIR)/man1
#
#	If debug is specified, turn it on
#
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	DEB_CONFIGURE_EXTRA_FLAGS += --enable-debug  --with-memory-profile --with-memory-checks
else
	DEB_CONFIGURE_EXTRA_FLAGS += --enable-optimisation=3
	ifneq (,$(findstring 86,$(DEB_BUILD_GNU_CPU)))
		DEB_CONFIGURE_EXTRA_FLAGS +=--with-ix86-asm
	endif
endif

#
#   Don't compress these files
#
DEB_COMPRESS_EXCLUDE := scriptexamples

#
#	Run dh_shlibdeps with the correct options
#
DEB_SHLIBDEPS_INCLUDE_kvirc3 := debian/kvirc3$(DEB_CONFIGURE_PREFIX)/lib
DEB_SHLIBDEPS_LIBRARY_kvirc3 := kvirc3

#
#	Documentation to include for each package
#
DEB_INSTALL_DOCS_kvirc3     := FAQ README TODO changelog TODO.Events
DEB_INSTALL_DOCS_kvirc3-doc := doc/scriptexamples
DEB_INSTALL_DOCS_ALL        += -XCVS

#
#	Facilitate building separate arch and indep packages
#
DEB_MAKE_INSTALL_TARGET :=
common-install-arch::
	make DESTDIR=$(DEB_DESTDIR) install
	#
	#	Change the name of the COPYING file to appease lintian
	#
	mv $(CURDIR)/debian/tmp/$(DEB_CONFIGURE_PREFIX)/share/kvirc/3.0.0/license/{COPYING,EULA}
	#
	#	Fix manpage section for the scripts
	#
	mkdir -p $(CURDIR)/debian/tmp/$(DEB_CONFIGURE_PREFIX)/share/man/man1
	set -e; for M in kvi3_run_netscape.sh kvi3_search_help.sh kvirc3-config; do \
		ln -s kvirc3.1.gz $(CURDIR)/debian/tmp/$(DEB_CONFIGURE_PREFIX)/share/man/man1/$$M.1.gz; \
	done
common-install-indep::
	make DESTDIR=$(DEB_DESTDIR) docs
