#!/usr/bin/make -f
# -*- makefile -*-

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

tmpList:=$(wildcard po/daisy-player.*.po)
sLocales:=$(patsubst po/daisy-player.%.po,%,$(tmpList))
cTestAndMakeDir  = mkdir -p usr/share/locale/$(locale)/LC_MESSAGES ;
cMakeLocale      = msgfmt po/daisy-player.$(locale).po -o usr/share/locale/$(locale)/LC_MESSAGES/daisy-player.mo ;
PREFIX=/usr/
CFLAGS=-Wall $(shell xml2-config --cflags) $(shell dpkg-buildflags --get CFLAGS)

export DEB_BUILD_HARDENING=1

%:
	dh  $@ --with-autoconf

override_dh_auto_configure:
	# Upstream uses hardcodes the -D to /usr/local in src/Makefile.am, so overwriting here
	dh_auto_configure -- --prefix=$(PREFIX) CFLAGS="$(CFLAGS) -DPREFIX=\\\"$(PREFIX)\\\""

override_dh_clean:
	rm -rf usr
	dh_clean

override_dh_auto_build:
	txt2man -t daisy-player -s 1 -v "Unix user's manual" doc/daisy-player.txt > man/daisy-player.1
	$(foreach locale,$(sLocales),$(cTestAndMakeDir))
	$(foreach locale,$(sLocales),$(cMakeLocale))

	dh_auto_build

override_dh_strip:
	dh_strip --dbg-package=daisy-player-dbg

override_dh_auto_install:
