#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk

FILENAME := dahdi-firmware_$(DEB_UPSTREAM_VERSION).orig.tar.gz
REAL_UPSTREAM_VER := $(shell echo $(DEB_UPSTREAM_VERSION) | sed -e 's/~rc/-rc/')
URL := http://downloads.asterisk.org/pub/telephony/dahdi-linux/releases/dahdi-linux-$(REAL_UPSTREAM_VER).tar.gz

# Beware of attempting to run a plain 'make' in the build rules here.
# If you e.g. see the package starting to download firmware, this is what
# you're doing. This package only packages some files that happen to be
# included in the tarball. The same tarball is properly built in
# dahdi-linux

install/dahdi-firmware::
	chmod +x $(CURDIR)/debian/dahdi-firmware/usr/share/dahdi/get-digium-firmware

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