Description: Fix PRI regressions
 Autoconf breakage resulted in all of the "extra" libpri features to be
 compiled-out. This e.g. resulted in inbanddisconnect=yes not having effect
 etc. This was noticed and fixed by upstream post 1.8.7, from where this commit
 has been cherry-picked.
Author: Faidon Liambotis <paravoid@debian.org>
Origin: backport, commit:339719
Forwarded: not-needed
Last-Update: 2011-11-26

--- asterisk-1.8.7.1~dfsg.orig/configure.ac
+++ asterisk-1.8.7.1~dfsg/configure.ac
@@ -408,6 +408,26 @@ AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL],
 AST_EXT_LIB_SETUP([POPT], [popt], [popt])
 AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio])
 AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_L2_PERSISTENCE], [ISDN Layer 2 persistence option], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_MWI], [ISDN PRI Message Waiting Indication], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_MCID], [ISDN PRI Malicious Call ID], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_CALL_WAITING], [ISDN PRI call waiting supplementary service], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_AOC_EVENTS], [ISDN PRI advice of charge supplementary service events], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_TRANSFER], [ISDN PRI call transfer supplementary service], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_CCSS], [ISDN PRI call completion supplementary service], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_HANGUP_FIX], [ISDN PRI hangup fix], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_SUBADDR], [ISDN PRI subaddressing], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_CALL_HOLD], [ISDN PRI call hold], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_CALL_REROUTING], [ISDN PRI call rerouting and call deflection], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_SETUP_KEYPAD], [ISDN PRI keypad facility in SETUP], [PRI], [pri])
+# ------------------------------------v
+# TODO: The code can be changed to always include these features now.
+# These features will always be present if pri_connected_line_update is available.
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_INBANDDISCONNECT], [ISDN PRI set_inbanddisconnect], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_PROG_W_CAUSE], [ISDN progress with cause], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_SERVICE_MESSAGES], [ISDN service messages], [PRI], [pri])
+AST_EXT_LIB_SETUP_OPTIONAL([PRI_REVERSE_CHARGE], [ISDN reverse charge], [PRI], [pri])
+# ------------------------------------^
 AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
 AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
 AST_EXT_LIB_SETUP([RESAMPLE], [LIBRESAMPLE], [resample])
--- asterisk-1.8.7.1~dfsg.orig/include/asterisk/autoconfig.h.in
+++ asterisk-1.8.7.1~dfsg/include/asterisk/autoconfig.h.in
@@ -557,6 +557,59 @@
 /* Define to 1 if you have the ISDN PRI library. */
 #undef HAVE_PRI
 
+/* Define to 1 if PRI has the ISDN PRI advice of charge supplementary service
+   events feature. */
+#undef HAVE_PRI_AOC_EVENTS
+
+/* Define to 1 if PRI has the ISDN PRI call hold feature. */
+#undef HAVE_PRI_CALL_HOLD
+
+/* Define to 1 if PRI has the ISDN PRI call rerouting and call deflection
+   feature. */
+#undef HAVE_PRI_CALL_REROUTING
+
+/* Define to 1 if PRI has the ISDN PRI call waiting supplementary service
+   feature. */
+#undef HAVE_PRI_CALL_WAITING
+
+/* Define to 1 if PRI has the ISDN PRI call completion supplementary service
+   feature. */
+#undef HAVE_PRI_CCSS
+
+/* Define to 1 if PRI has the ISDN PRI hangup fix feature. */
+#undef HAVE_PRI_HANGUP_FIX
+
+/* Define to 1 if PRI has the ISDN PRI set_inbanddisconnect feature. */
+#undef HAVE_PRI_INBANDDISCONNECT
+
+/* Define to 1 if PRI has the ISDN Layer 2 persistence option feature. */
+#undef HAVE_PRI_L2_PERSISTENCE
+
+/* Define to 1 if PRI has the ISDN PRI Malicious Call ID feature. */
+#undef HAVE_PRI_MCID
+
+/* Define to 1 if PRI has the ISDN PRI Message Waiting Indication feature. */
+#undef HAVE_PRI_MWI
+
+/* Define to 1 if PRI has the ISDN progress with cause feature. */
+#undef HAVE_PRI_PROG_W_CAUSE
+
+/* Define to 1 if PRI has the ISDN reverse charge feature. */
+#undef HAVE_PRI_REVERSE_CHARGE
+
+/* Define to 1 if PRI has the ISDN service messages feature. */
+#undef HAVE_PRI_SERVICE_MESSAGES
+
+/* Define to 1 if PRI has the ISDN PRI keypad facility in SETUP feature. */
+#undef HAVE_PRI_SETUP_KEYPAD
+
+/* Define to 1 if PRI has the ISDN PRI subaddressing feature. */
+#undef HAVE_PRI_SUBADDR
+
+/* Define to 1 if PRI has the ISDN PRI call transfer supplementary service
+   feature. */
+#undef HAVE_PRI_TRANSFER
+
 /* Define if you have POSIX threads libraries and header files. */
 #undef HAVE_PTHREAD
 
--- asterisk-1.8.7.1~dfsg.orig/autoconf/ast_ext_lib.m4
+++ asterisk-1.8.7.1~dfsg/autoconf/ast_ext_lib.m4
@@ -58,7 +58,8 @@ AC_ARG_WITH([$1], AC_HELP_STRING([--with
 AC_SUBST($2)
 ])
 
-# AST_EXT_LIB_SETUP_DEPENDENT([package symbol name], [package friendly name], [master package symbol name], [master package option name])
+# Setup required dependent package
+# AST_EXT_LIB_SETUP_DEPENDENT([dependent package symbol name], [dependent package friendly name], [master package symbol name], [master package name])
 
 AC_DEFUN([AST_EXT_LIB_SETUP_DEPENDENT],
 [
@@ -78,6 +79,23 @@ AH_TEMPLATE(m4_bpatsubst([[HAVE_$1]], [(
 AC_SUBST([$1_LIB])
 AC_SUBST([$1_INCLUDE])
 AC_SUBST([$1_DIR])
+AC_SUBST([PBX_$1])
+])
+
+# Setup optional dependent package
+# AST_EXT_LIB_SETUP_OPTIONAL([optional package symbol name], [optional package friendly name], [master package symbol name], [master package name])
+
+AC_DEFUN([AST_EXT_LIB_SETUP_OPTIONAL],
+[
+$1_DESCRIP="$2"
+m4_ifval([$4], [$1_OPTION=$4])
+m4_ifval([$3], [$1_DIR=${$3_DIR}
+])
+PBX_$1=0
+AH_TEMPLATE(m4_bpatsubst([[HAVE_$1]], [(.*)]), [Define to 1 if $3 has the $2 feature.])
+AC_SUBST([$1_LIB])
+AC_SUBST([$1_INCLUDE])
+AC_SUBST([$1_DIR])
 AC_SUBST([PBX_$1])
 ])
 
