#!/usr/bin/make -f

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

DEBVERSION:=$(shell head -n 1 debian/changelog \
		    | sed -e 's/^[^(]*(\([^)]*\)).*/\1/')
ORIGTARVER:=$(shell echo $(DEBVERSION) | sed -e 's/^.*://' -e 's/-[0-9.]*$$//')# -e 's/.dfsg$$//' -e 's/~//')

UPVERSION:=$(shell echo $(ORIGTARVER) | tr -d '~')

FILENAME := spandsp_$(ORIGTARVER).orig.tar.gz
FULLNAME := spandsp-$(UPVERSION)
URL := http://www.soft-switch.org/downloads/spandsp/spandsp-$(UPVERSION).tgz

%:
	dh $@ --with-autotools-dev --parallel

override_dh_auto_configure:
	dh_auto_configure -- --enable-doc

override_dh_auto_build:
	dh_auto_build
	$(MAKE) html

override_dh_clean:
	$(RM) -rf doc/api/html/
	$(RM) -f doc/t38_manual/*.html
	dh_clean 

override_dh_changelogs:
	dh_installchangelogs ChangeLog

override_dh_link:
	$(RM) -f debian/libspandsp-doc/usr/share/doc/libspandsp-doc/api/html/jquery.js
	dh_link

get-orig-source:
	-@@dh_testdir
	@@[ -d ../tarballs/. ]||mkdir -p ../tarballs
	@@echo Downloading $(FILENAME) from $(URL) ...
	@@wget -nv -T10 -t3 -O ../tarballs/$(FILENAME) $(URL)
