#!/usr/bin/make -f

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

# Debian does not currently does multiarch so we disable it here
ifeq ($(DIST),Debian)
    MULTIARCH = --without-apt-multiarch-support
endif

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

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIGURE_FLAGS) 

override_dh_auto_install:
	dh_auto_install
	# 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.tr.8 man/synaptic.pt_BR.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:
	cp debian/patches/00list.$(DIST) debian/patches/00list
	dpatch apply-all
	dh_auto_build
	# 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
