#!/usr/bin/make -f

# make the package build on ubuntu and debian
DIST = $(shell lsb_release -i -s)

DHFLAGS=--parallel
CONFIGURE_FLAGS= --prefix=/usr \
	      --mandir=\$${prefix}/share/man \
	      --infodir=\$${prefix}/share/info \
	      --localstatedir=/var/lib/synaptic \
	      --sysconfdir=/etc \
	      --with-pkg-hold \
	      $(MULTIARCH)

%:
	dh $@ --with autoreconf $(DHFLAGS)

override_dh_auto_configure:
	dh_auto_configure $(DHFLAGS) -- $(CONFIGURE_FLAGS) 

override_dh_auto_install:
	dh_auto_install $(DHFLAGS)
	# allow per distro supported PIXMAP, FIXME: make this part
	# of the install (e.g. package-supported.{Ubuntu,Debian} and
	# do run-time switching
	if [ -f debian/package-supported.png.$(DIST) ]; then \
		cp debian/package-supported.png.$(DIST) $(CURDIR)/debian/synaptic/usr/share/icons/hicolor/16x16/actions/package-supported.png; \
	fi

override_dh_installman:
	dh_installman -psynaptic man/synaptic.es.8 man/synaptic.fr.8 man/synaptic.hr.8 man/synaptic.ja.8 man/synaptic.pt_BR.8 man/synaptic.ru.8 man/synaptic.tr.8

# FIXME: use quilt instead - quilt has a nice concept of 
#        debian/patches/{ubuntu,debian}.series but that does not
#        work for native packages :/

# patch
override_dh_auto_build:
	# apply distro specific patches if we have them
	if [ -e debian/patches/00list.$(DIST) ]; then \
	  cp debian/patches/00list.$(DIST) debian/patches/00list;\
	  dpatch apply-all;\
	fi;
	dh_auto_build $(DHFLAGS)
	# ubuntu specific for universe langpacks but will not do any
	#  harm on debian
	make -C po synaptic.pot

# unpatch
override_dh_auto_clean:
	cp debian/patches/00list.$(DIST) debian/patches/00list
	dpatch deapply-all
	rm -rf patch-stamp debian/patched
	dh_auto_clean $(DHFLAGS)
