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

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

NO_DISTRIB:=LICENSE.txt
NO_DISTRIB_FIND_EXPR:=$(patsubst %,-not -name '%',$(NO_DISTRIB))
PKG_NAME:=asterisk-prompt-fr-armelle
LNG:=fr

build: build-indep

build-indep:

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp debian/links

	dh_clean

binary-indep: build-indep install
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	dh_installchangelogs
	dh_installdocs

	cp -R $(LNG) debian/$(PKG_NAME)/usr/share/asterisk/sounds/
	set -e; find . -mindepth 1 -maxdepth 1 -type d -not -name debian -not -name .pc $(NO_DISTRIB_FIND_EXPR) -not -name $(LNG) | while read d; do cp -R $${d}/$(LNG) debian/$(PKG_NAME)/usr/share/asterisk/sounds/$(LNG)/$${d}; done

	set -e; \
	( cd debian/$(PKG_NAME)/usr/share/asterisk/sounds/$(LNG)/; \
	  for d in $$(find . -mindepth 1 -type d -printf '%P\n'); do \
	    mkdir -p ../$${d}; \
	    echo usr/share/asterisk/sounds/$(LNG)/$${d} usr/share/asterisk/sounds/$${d}/$(LNG); \
	  done ) > debian/links
	dh_link

	dh_compress
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

#Only "arch: any", so nothing to do, but that target is mandatory.
binary-arch:

binary: binary-indep binary-arch
build-arch: build

.PHONY: clean binary-indep binary-arch binary install build build-arch build-indep
