dahdi-tools: Update to version 2.10.2

* libpcap is no longer a dependence.

* libusb is needed for building fpga_load, needed for firmware loading
  of the Xorcom Astribank.

* do_configure, do_compile and do_install were removed to use functions
  provided by autotools class.

Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br>
diff --git a/recipes-isdn/dahdi-tools/dahdi-tools_2.10.2.bb b/recipes-isdn/dahdi-tools/dahdi-tools_2.10.2.bb
new file mode 100644
index 0000000..337186d
--- /dev/null
+++ b/recipes-isdn/dahdi-tools/dahdi-tools_2.10.2.bb
@@ -0,0 +1,44 @@
+DESCRITOPN = "Utilities for the DAHDI Asterisk Linux kernel drivers"
+HOMEPAGE = "http://www.asterisk.org"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "\
+    file://LICENSE;md5=ea5bed2f60d357618ca161ad539f7c0a \
+    file://LICENSE.LGPL;md5=fb504b67c50331fc78734fed90fb0e09 \
+"
+
+DEPENDS = "dahdi-linux libnewt libusb"
+
+SRC_URI = "\
+    http://downloads.asterisk.org/pub/telephony/dahdi-tools/releases/dahdi-tools-${PV}.tar.gz \
+    file://0001-Set-perllibdir.patch \
+    file://0002-Use-sh-not-bash.patch \
+    file://0003-Remove-Werror-from-Makefile.patch \
+    file://dahdi.init.d \
+"
+
+SRC_URI[md5sum] = "6928cdf6f7710299ecbcacbac20d5c92"
+SRC_URI[sha256sum] = "9e904815dedab231084c542d2d7d5dcc832ebec4b5d5d999a5d757df8b2d571a"
+
+S = "${WORKDIR}/${PN}-${PV}"
+
+inherit autotools-brokensep pkgconfig perlnative cpan-base update-rc.d
+
+export DAHDI_PERLLIBDIR="${PERLLIBDIRS}/${@get_perl_version(d)}"
+
+INITSCRIPT_NAME = "dahdi"
+INITSCRIPT_PARAMS = "defaults"
+
+do_install_append(){
+    oe_runmake DESTDIR=${D} config
+    install -Dm 0755 ${WORKDIR}/dahdi.init.d ${D}${sysconfdir}/init.d/dahdi
+    chown -R root:root ${D}${datadir}/dahdi/
+}
+
+FILES_${PN} += "${datadir}/dahdi"
+
+RDEPENDS_${PN} += "\
+    perl perl-module-strict perl-module-file-basename perl-module-config \
+    perl-module-warnings perl-module-getopt-std perl-module-file-glob \
+    perl-module-xsloader perl-module-dynaloader perl-module-carp \
+    perl-module-errno perl-module-file-basename dahdi-linux \
+"
diff --git a/recipes-isdn/dahdi-tools/dahdi-tools_2.6.0.bb b/recipes-isdn/dahdi-tools/dahdi-tools_2.6.0.bb
deleted file mode 100644
index 2b26b27..0000000
--- a/recipes-isdn/dahdi-tools/dahdi-tools_2.6.0.bb
+++ /dev/null
@@ -1,41 +0,0 @@
-DESCRITOPN = "Utilities for the DAHDI Asterisk Linux kernel drivers"
-HOMEPAGE = "http://www.asterisk.org"
-LICENSE = "GPLv2"
-LIC_FILES_CHKSUM = "\
-    file://LICENSE;md5=ea5bed2f60d357618ca161ad539f7c0a \
-    file://LICENSE.LGPL;md5=fb504b67c50331fc78734fed90fb0e09 \
-"
-
-DEPENDS = "dahdi-linux libnewt libpcap"
-
-SRC_URI = "\
-    http://downloads.asterisk.org/pub/telephony/dahdi-tools/releases/dahdi-tools-${PV}.tar.gz \
-    file://perl_install.patch \
-"
-
-inherit autotools_stage pkgconfig perlnative cpan-base
-
-export DAHDI_PERLLIBDIR="${PERLLIBDIRS}/${@get_perl_version(d)}"
-
-do_configure() {
-    oe_runconf
-}
-
-do_compile() {
-    base_do_compile
-    oe_runmake dahdi_pcap
-}
-
-do_install() {
-    autotools_do_install
-    install -m 755 ${S}/dahdi_pcap ${D}${sbindir}/
-}
-
-FILES_${PN} += "${datadir}/dahdi"
-
-RDEPENDS_${PN} += "\
-    perl perl-module-strict perl-module-file-basename perl-module-config \
-    perl-module-warnings perl-module-getopt perl-module-getopt-std \
-    perl-module-file perl-module-file-glob perl-module-xsloader \
-    perl-module-dynaloader perl-module-carp perl-module-errno \
-"
diff --git a/recipes-isdn/dahdi-tools/files/0001-Set-perllibdir.patch b/recipes-isdn/dahdi-tools/files/0001-Set-perllibdir.patch
new file mode 100644
index 0000000..6bf46af
--- /dev/null
+++ b/recipes-isdn/dahdi-tools/files/0001-Set-perllibdir.patch
@@ -0,0 +1,26 @@
+Upstream-Status: Inappropriate [configuration]
+
+Subject: [PATCH 1/3] Set perllibdir
+Organization: O.S. Systems Software LTDA.
+
+Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br>
+---
+ xpp/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/xpp/Makefile b/xpp/Makefile
+index 12909f2..8e8b6c9 100644
+--- a/xpp/Makefile
++++ b/xpp/Makefile
+@@ -30,7 +30,7 @@ SBINDIR		= $(prefix)/sbin
+ DATADIR		= $(datadir)/dahdi
+ MANDIR		= $(mandir)/man8
+ HOTPLUG_USB_DIR	= $(sysconfdir)/hotplug/usb
+-PERLLIBDIR	:= $(shell eval `perl -V:sitelib`; echo "$$sitelib")
++PERLLIBDIR	= $(DAHDI_PERLLIBDIR)
+ PERL_DIRS	:= $(shell cd perl_modules; find * -name '[A-Z]*' -type d| xargs)
+ PERL_MODS_PAT	:= *.pm $(PERL_DIRS:%=%/*.pm)
+ PERL_MODS	:= $(shell cd perl_modules; echo $(PERL_MODS_PAT))
+-- 
+2.1.4
+
diff --git a/recipes-isdn/dahdi-tools/files/0002-Use-sh-not-bash.patch b/recipes-isdn/dahdi-tools/files/0002-Use-sh-not-bash.patch
new file mode 100644
index 0000000..e6d15b5
--- /dev/null
+++ b/recipes-isdn/dahdi-tools/files/0002-Use-sh-not-bash.patch
@@ -0,0 +1,23 @@
+Upstream-Status: Inappropriate [configuration]
+
+Subject: [PATCH 2/3] Use sh not bash
+Organization: O.S. Systems Software LTDA.
+
+Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br>
+---
+ xpp/xpp_fxloader | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/xpp/xpp_fxloader b/xpp/xpp_fxloader
+index 5135ebf..8598004 100644
+--- a/xpp/xpp_fxloader
++++ b/xpp/xpp_fxloader
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/sh
+ 
+ # xpp_fxloader: load Xorcom Astribank (XPP) firmware
+ # $Id$
+-- 
+2.1.4
+
diff --git a/recipes-isdn/dahdi-tools/files/0003-Remove-Werror-from-Makefile.patch b/recipes-isdn/dahdi-tools/files/0003-Remove-Werror-from-Makefile.patch
new file mode 100644
index 0000000..9c1f9fa
--- /dev/null
+++ b/recipes-isdn/dahdi-tools/files/0003-Remove-Werror-from-Makefile.patch
@@ -0,0 +1,42 @@
+Upstream-Status: Pending
+
+Fix error: "cc1: all warnings being treated as errors"
+
+Subject: [PATCH 3/3] Remove Werror from Makefile
+Organization: O.S. Systems Software LTDA.
+
+Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br>
+---
+ Makefile     | 2 +-
+ xpp/Makefile | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 69741e6..1a5eefc 100644
+--- a/Makefile
++++ b/Makefile
+@@ -27,7 +27,7 @@ CFLAGS+=-m64
+ endif
+ 
+ ifeq ($(DAHDI_DEVMODE),yes)
+-  CFLAGS+=-Werror -Wunused -Wundef $(DAHDI_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2
++  CFLAGS+= -Wunused -Wundef $(DAHDI_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2
+ endif
+ 
+ ROOT_PREFIX=
+diff --git a/xpp/Makefile b/xpp/Makefile
+index 8e8b6c9..001e476 100644
+--- a/xpp/Makefile
++++ b/xpp/Makefile
+@@ -146,7 +146,7 @@ ifneq	(,$(PERLLIBDIR))
+ 	done
+ endif
+ 
+-CFLAGS		+= -I. -Ixtalk -Wall -Werror
++CFLAGS		+= -I. -Ixtalk -Wall
+ 
+ astribank_hexload: $(ABHEXLOAD_OBJS)
+ astribank_hexload: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
+-- 
+2.1.4
+
diff --git a/recipes-isdn/dahdi-tools/files/dahdi.init.d b/recipes-isdn/dahdi-tools/files/dahdi.init.d
new file mode 100644
index 0000000..87b57d5
--- /dev/null
+++ b/recipes-isdn/dahdi-tools/files/dahdi.init.d
@@ -0,0 +1,343 @@
+#!/bin/sh
+#
+# dahdi         This shell script takes care of loading and unloading \
+#               DAHDI Telephony interfaces
+# chkconfig: 2345 9 92
+# description: The DAHDI drivers allow you to use your linux \
+# computer to accept incoming data and voice interfaces
+#
+# config: /etc/dahdi/init.conf
+
+### BEGIN INIT INFO
+# Provides:        dahdi
+# Required-Start:  $local_fs $remote_fs
+# Required-Stop:   $local_fs $remote_fs
+# Should-Start:    $network $syslog
+# Should-Stop:     $network $syslog
+# Default-Start:   2 3 4 5
+# Default-Stop:    0 1 6
+# Short-Description: DAHDI kernel modules
+# Description:     dahdi - load and configure DAHDI modules
+### END INIT INFO
+
+initdir=/etc/init.d
+
+# Don't edit the following values. Edit /etc/dahdi/init.conf instead.
+
+DAHDI_CFG=/usr/sbin/dahdi_cfg
+DAHDI_CFG_CMD=${DAHDI_CFG_CMD:-"$DAHDI_CFG"} # e.g: for a custom system.conf location
+
+FXOTUNE=/usr/sbin/fxotune
+
+# The default syncer Astribank. Usually set automatically to a sane
+# value by xpp_sync(1) if you have an Astribank. You can set this to an
+# explicit Astribank (e.g: 01).
+XPP_SYNC=auto
+
+# The maximal timeout (seconds) to wait for udevd to finish generating
+# device nodes after the modules have loaded and before running dahdi_cfg.
+DAHDI_DEV_TIMEOUT=20
+
+# A list of modules to unload when stopping.
+# All of their dependencies will be unloaded as well.
+DAHDI_UNLOAD_MODULES="dahdi"
+
+#
+# Determine which kind of configuration we're using
+#
+system=debian # assume debian
+if [ -f /etc/debian_version ]; then
+    system=debian
+fi
+
+if [ -f /etc/gentoo-release ]; then
+    system=debian
+fi
+
+if [ -f /etc/SuSE-release -o -f /etc/novell-release ]
+then
+    system=debian
+fi
+
+# Source function library.
+if [ $system = debian ]; then
+    . $initdir/functions || exit 0
+fi
+
+DAHDI_MODULES_FILE="/etc/dahdi/modules"
+
+[ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
+
+if [ $system = redhat ]; then
+	LOCKFILE=/var/lock/subsys/dahdi
+fi
+
+# recursively unload a module and its dependencies, if possible.
+# where's modprobe -r when you need it?
+# inputs: module to unload.
+# returns: the result from
+unload_module() {
+	module="$1"
+	line=`lsmod 2>/dev/null | grep "^$1 "`
+	if [ "$line" = '' ]; then return; fi # module was not loaded
+
+	set -- $line
+	# $1: the original module, $2: size, $3: refcount, $4: deps list
+	mods=`echo $4 | tr , ' '`
+	ec_modules=""
+	# xpp_usb keeps the xpds below busy if an xpp hardware is
+	# connected. Hence must be removed before them:
+	case "$module" in xpd_*) mods="xpp_usb $mods";; esac
+
+	for mod in $mods; do
+		case "$mod" in
+		dahdi_echocan_*)
+			ec_modules="$mod $ec_modules"
+			;;
+		*)
+			# run in a subshell, so it won't step over our vars:
+			(unload_module $mod)
+			;;
+		esac
+	done
+	# Now that all the other dependencies are unloaded, we can unload the
+	# dahdi_echocan modules.  The drivers that register spans may keep
+	# references on the echocan modules before they are unloaded.
+	for mod in $ec_modules; do
+		(unload_module $mod)
+	done
+	rmmod $module
+}
+
+unload_modules() {
+	for module in $DAHDI_UNLOAD_MODULES; do
+		unload_module $module
+	done
+}
+
+# In (xpp) hotplug mode, the init script is also executed from the
+# hotplug hook. In that case it should not attempt to loade modules.
+#
+# This function only retunrs false (1) if we're in hotplug mode and
+# coming from the hotplug hook script.
+hotplug_should_load_modules() {
+	if [ "$XPP_HOTPLUG_DAHDI" = yes -a "$CALLED_FROM_ATRIBANK_HOOK" != '' ]
+	then
+		return 1
+	fi
+	return 0
+}
+
+# In (xpp) hotplug mode: quit after we loaded modules.
+#
+# In hotplug mode, the main run should end here, whereas the rest of the
+# script should be finished by the instance running from the hook.
+# Note that we only get here if there are actually Astribanks on the
+# system (otherwise noone will trigger the run of the hotplug hook
+# script).
+hotplug_exit_after_load() {
+	if [ "$XPP_HOTPLUG_DAHDI" = yes -a "$CALLED_FROM_ATRIBANK_HOOK" = '' ]
+	then
+		exit 0
+	fi
+}
+
+# Initialize the Xorcom Astribank (xpp/) using perl utiliites:
+xpp_startup() {
+	if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = yes ]; then
+		aas_param='/sys/module/dahdi/parameters/auto_assign_spans'
+		aas=`cat "$aas_param" 2>/dev/null`
+		if [ "$aas" = 0 ]; then
+			echo 1>&2 "Don't wait for Astribanks (use Asterisk hotplug-support)"
+			return 0
+		fi
+	fi
+	# do nothing if there are no astribank devices:
+	if ! /usr/share/dahdi/waitfor_xpds; then return 0; fi
+
+	hotplug_exit_after_load
+}
+
+
+hpec_start() {
+	# HPEC license found
+	if ! echo /var/lib/digium/licenses/HPEC-*.lic | grep -v '\*' | grep -q .; then
+		return
+	fi
+
+	# dahdihpec_enable not installed in /usr/sbin
+	if [ ! -f /usr/sbin/dahdihpec_enable ]; then
+		echo -n "Running dahdihpec_enable: Failed"
+		echo -n "."
+		echo "  The dahdihpec_enable binary is not installed in /usr/sbin."
+		return
+	fi
+
+	# dahdihpec_enable not set executable
+	if [ ! -x /usr/sbin/dahdihpec_enable ]; then
+		echo -n "Running dahdihpec_enable: Failed"
+		echo -n "."
+		echo "  /usr/sbin/dahdihpec_enable is not set as executable."
+		return
+	fi
+
+	# dahdihpec_enable properly installed
+	if [ $system = debian ]; then
+		echo -n "Running dahdihpec_enable: "
+		/usr/sbin/dahdihpec_enable 2> /dev/null
+	elif [ $system = redhat ]; then
+		action "Running dahdihpec_enable: " /usr/sbin/dahdihpec_enable
+	fi
+	if [ $? = 0 ]; then
+		echo -n "done"
+		echo "."
+	else
+		echo -n "Failed"
+		echo -n "."
+		echo "  This can be caused if you had already run dahdihpec_enable, or if your HPEC license is no longer valid."
+	fi
+}
+
+shutdown_dynamic() {
+	if ! grep -q ' DYN/' /proc/dahdi/* 2>/dev/null; then return; fi
+
+	# we should only get here if we have dynamic spans. Right?
+	$DAHDI_CFG_CMD -s
+}
+
+load_modules() {
+  	# Some systems, e.g. Debian Lenny, add here -b, which will break
+	# loading of modules blacklisted in modprobe.d/*
+	unset MODPROBE_OPTIONS
+  	modules=`sed -e 's/#.*$//' $DAHDI_MODULES_FILE 2>/dev/null`
+	#if [ "$modules" = '' ]; then
+		# what?
+	#fi
+	echo "Loading DAHDI hardware modules:"
+	modprobe dahdi
+	for line in $modules; do
+		if [ $system = debian ]; then
+			echo -n "   ${line}: "
+			if modprobe $line 2> /dev/null; then
+				echo -n "done"
+			else
+				echo -n "error"
+			fi
+		elif [ $system = redhat ]; then
+			action "  ${line}: " modprobe $line
+		fi
+	done
+	echo ""
+}
+
+# Make sure that either dahdi is loaded or modprobe-able
+dahdi_modules_loadable() {
+	modinfo dahdi >/dev/null 2>&1 || lsmod | grep -q -w ^dahdi
+}
+
+if [ ! -x "$DAHDI_CFG" ]; then
+       echo "dahdi_cfg not executable"
+       exit 0
+fi
+
+RETVAL=0
+
+# See how we were called.
+case "$1" in
+  start)
+	if ! dahdi_modules_loadable; then
+		echo "No DAHDI modules on the system. Not starting"
+		exit 0
+	fi
+  	if hotplug_should_load_modules; then
+		load_modules
+	fi
+
+	TMOUT=$DAHDI_DEV_TIMEOUT # max secs to wait
+
+	while [ ! -d /dev/dahdi ] ; do
+ 		sleep 1
+		TMOUT=`expr $TMOUT - 1`
+		if [ $TMOUT -eq 0 ] ; then
+			echo "Error: missing /dev/dahdi!"
+			exit 1
+		fi
+	done
+
+	xpp_startup
+
+	# Assign all spans that weren't handled via udev + /etc/dahdi/assigned-spans.conf
+	/usr/share/dahdi/dahdi_auto_assign_compat
+
+	if [ $system = debian ]; then
+	    echo -n "Running dahdi_cfg: "
+	    $DAHDI_CFG_CMD 2> /dev/null && echo -n "done"
+	    echo "."
+	elif [ $system = redhat ]; then
+	    action "Running dahdi_cfg: " $DAHDI_CFG_CMD
+	fi
+	RETVAL=$?
+
+	if [ "$LOCKFILE" != '' ]; then
+		[ $RETVAL -eq 0 ] && touch $LOCKFILE
+	fi
+
+	if [ -x "$FXOTUNE" ] && [ -r /etc/fxotune.conf ]; then
+		# Allowed to fail if e.g. Asterisk already uses channels:
+		$FXOTUNE -s || :
+	fi
+
+	# Do not try to call xpp_sync if there are no Astribank devices
+	# installed.
+	if test -e /sys/bus/astribanks; then 
+		# Set the right Astribanks ticker:
+		LC_ALL=C xpp_sync "$XPP_SYNC"
+	fi
+
+	hpec_start
+	;;
+  stop)
+	# Unload drivers
+	#shutdown_dynamic # FIXME: needs test from someone with dynamic spans
+	echo -n "Unloading DAHDI hardware modules: "
+	if unload_modules; then
+		echo "done"
+	else
+		echo "error"
+	fi
+	if [ "$LOCKFILE" != '' ]; then
+		[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
+	fi
+	;;
+  unload)
+	unload_modules
+	;;
+  restart|force-reload)
+	$0 stop
+	$0 start
+	;;
+  reload)
+	if [ $system = debian ]; then
+	    echo -n "Rerunning dahdi_cfg: "
+	    $DAHDI_CFG_CMD 2> /dev/null && echo -n "done"
+	    echo "."
+	elif [ $system = redhat ]; then
+	    action "Rerunning dahdi_cfg: " $DAHDI_CFG_CMD
+	fi
+	RETVAL=$?
+	;;
+  status)
+	if [ -d /proc/dahdi ]; then
+		/usr/sbin/lsdahdi
+		RETVAL=0
+	else
+		RETVAL=3
+	fi
+	;;
+  *)
+	echo "Usage: dahdi {start|stop|restart|status|reload|unload}"
+	exit 1
+esac
+
+exit $RETVAL
+
diff --git a/recipes-isdn/dahdi-tools/files/perl_install.patch b/recipes-isdn/dahdi-tools/files/perl_install.patch
deleted file mode 100755
index adcda2b..0000000
--- a/recipes-isdn/dahdi-tools/files/perl_install.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: dahdi-tools-2.6.0/xpp/Makefile
-===================================================================
---- dahdi-tools-2.6.0.orig/xpp/Makefile	2011-07-11 00:25:18.000000000 +0800
-+++ dahdi-tools-2.6.0/xpp/Makefile	2012-07-21 23:30:58.244897984 +0800
-@@ -28,7 +28,7 @@
- DATADIR		= $(datadir)/dahdi
- MANDIR		= $(mandir)/man8
- HOTPLUG_USB_DIR	= $(sysconfdir)/hotplug/usb
--PERLLIBDIR	:= $(shell eval `perl -V:sitelib`; echo "$$sitelib")
-+PERLLIBDIR	= $(DAHDI_PERLLIBDIR)
- PERL_DIRS	:= $(shell cd perl_modules; find * -name '[A-Z]*' -type d| xargs)
- PERL_MODS_PAT	:= *.pm $(PERL_DIRS:%=%/*.pm)
- PERL_MODS	:= $(shell cd perl_modules; echo $(PERL_MODS_PAT))