From cc1e83397b38d23b4c9b0128993e1a3820f02998 Mon Sep 17 00:00:00 2001
From: Stefan Knoblich <s.knoblich@axsentis.de>
Date: Mon, 1 Nov 2010 02:13:27 +0100
Subject: [PATCH 2/2] FreeTDM: Buildsystem cleanup

- Use tabs instead of spaces for indentation

- Proper m4 quoting of parameters

- Fix broken AC_ARG_* handling:
  --without-foo/--disable-foo set withval="no"/enableval="no"
  and the third parameter of the AC_ARG_* macros is always
  "user provided an --with*-foo/--*able-foo option" _NOT_ "yes",
  while the fourth parameter is "user didn't provide this option"
  (= the default if neither --with-foo/--enable-foo nor --without-foo/--disable-foo
     has been set)

- Drop FTDM_CFLAGS in MY_CFLAGS (what was that used for anyway?)

- Drop MYLIB

- Drop SOLINK (unused)

- Rename MY_CFLAGS to FTDM_CFLAGS

- Rename all AM_CONDITION variables to HAVE_* for (optional) dependencies
  and WANT_* for features

- Reorder mod_LTLIBRARIES lines

- Move some things in configure.ac around to group them

- Add -shared to modules LDFLAGS (we don't need "ftmod_foo.a" static modules, do we?)

- Import ax_compiler_vendor.m4, drop the macro definition from configure.ac

- Add AUTOMAKE_OPTS to Makefile.am and define FreeTDM as a foreign (= non-GNU) project

- Add ACLOCAL_FLAGS to Makefile.am and set AC_CONFIG_MACRO_DIR in configure.ac
  custom m4 macros are kept in the build subdirectory

- Enable silent rules for automake-1.11 and newer (use make V=1 to get verbose output)

- configure option --with-modinstdir requires a value now and quits with an error message
  if called without one (e.g. "./configure --without-modinstdir" or "./configure --with-modinstdir")

- Add configuration summary screen and category headers for modules in configure output
---
 libs/freetdm/Makefile.am                 |  296 ++++++++++++--------------
 libs/freetdm/build/ax_compiler_vendor.m4 |   15 ++
 libs/freetdm/configure.ac                |  341 +++++++++++++++++-------------
 3 files changed, 348 insertions(+), 304 deletions(-)
 create mode 100644 libs/freetdm/build/ax_compiler_vendor.m4

diff --git a/libs/freetdm/Makefile.am b/libs/freetdm/Makefile.am
index 33e287f..2177a96 100644
--- a/libs/freetdm/Makefile.am
+++ b/libs/freetdm/Makefile.am
@@ -29,29 +29,33 @@
 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-PREFIX = $(prefix)
-SRC    = src
+ACLOCAL_AMFLAGS  = -I build
+AUTOMAKE_OPTIONS = foreign
+
+SRC = src
 
 moddir = @modinstdir@
 libdir = @libdir@
-library_includedir = $(PREFIX)/include
+library_includedir = $(prefix)/include
+
+INCS  = -I$(FT_SRCDIR)/$(SRC)/include -I$(FT_SRCDIR)/$(SRC)/include/private
+INCS += -I$(FT_SRCDIR)/$(SRC)/ftmod/ftmod_sangoma_boost
 
-INCS      = -I$(FT_SRCDIR)/$(SRC)/include -I$(FT_SRCDIR)/$(SRC)/isdn/include -I$(FT_SRCDIR)/$(SRC)/include/private
-INCS +=   -I$(FT_SRCDIR)/$(SRC)/ftmod/ftmod_sangoma_boost
-if SNGSS7
-INCS += -I/usr/include/sng_ss7/
+if HAVE_SNG_SS7
+INCS += -I/usr/include/sng_ss7
 endif 
-if SNGISDN
-INCS += -I/usr/include/sng_isdn/
+
+if HAVE_SNG_ISDN
+INCS += -I/usr/include/sng_isdn
 endif 
 
-MY_CFLAGS = $(INCS) $(FTDM_CFLAGS) -DFTDM_CONFIG_DIR=\"@confdir@\" -DFTDM_MOD_DIR=\"$(moddir)\" @COMP_VENDOR_CFLAGS@ @DEFS@
-COMPILE   = $(CC) $(MY_CFLAGS) $(INCS)
+FTDM_CFLAGS = $(INCS) -DFTDM_CONFIG_DIR=\"@confdir@\" -DFTDM_MOD_DIR=\"$(moddir)\" @COMP_VENDOR_CFLAGS@ @DEFS@
+COMPILE   = $(CC) $(FTDM_CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(COMPILE)
-LINK      = $(LIBTOOL) --mode=link --tag=CC $(CC) $(MY_CFLAGS) $(LDFLAGS) -o $@
+LINK      = $(LIBTOOL) --mode=link --tag=CC $(CC) $(FTDM_CFLAGS) $(LDFLAGS) -o $@
 
-if DEBUGDTMF
-MY_CFLAGS += -DFTDM_DEBUG_DTMF
+if WANT_DEBUGDTMF
+FTDM_CFLAGS += -DFTDM_DEBUG_DTMF
 endif
 
 
@@ -68,246 +72,224 @@ pkgconfig_DATA = freetdm.pc
 # libfreetdm
 #
 libfreetdm_la_SOURCES = \
-$(SRC)/hashtable.c \
-$(SRC)/hashtable_itr.c \
-$(SRC)/ftdm_io.c \
-$(SRC)/ftdm_queue.c \
-$(SRC)/ftdm_sched.c \
-$(SRC)/ftdm_call_utils.c \
-$(SRC)/ftdm_config.c \
-$(SRC)/ftdm_callerid.c \
-$(SRC)/fsk.c \
-$(SRC)/uart.c \
-$(SRC)/g711.c \
-$(SRC)/libteletone_detect.c \
-$(SRC)/libteletone_generate.c \
-$(SRC)/ftdm_buffer.c \
-$(SRC)/ftdm_threadmutex.c \
-$(SRC)/ftdm_dso.c \
-$(SRC)/ftdm_cpu_monitor.c
+	$(SRC)/hashtable.c \
+	$(SRC)/hashtable_itr.c \
+	$(SRC)/ftdm_io.c \
+	$(SRC)/ftdm_queue.c \
+	$(SRC)/ftdm_sched.c \
+	$(SRC)/ftdm_call_utils.c \
+	$(SRC)/ftdm_config.c \
+	$(SRC)/ftdm_callerid.c \
+	$(SRC)/fsk.c \
+	$(SRC)/uart.c \
+	$(SRC)/g711.c \
+	$(SRC)/libteletone_detect.c \
+	$(SRC)/libteletone_generate.c \
+	$(SRC)/ftdm_buffer.c \
+	$(SRC)/ftdm_threadmutex.c \
+	$(SRC)/ftdm_dso.c \
+	$(SRC)/ftdm_cpu_monitor.c
 
 library_include_HEADERS = \
-$(SRC)/include/freetdm.h \
-$(SRC)/include/ftdm_declare.h \
-$(SRC)/include/ftdm_threadmutex.h \
-$(SRC)/include/ftdm_os.h \
-$(SRC)/include/ftdm_dso.h 
+	$(SRC)/include/freetdm.h \
+	$(SRC)/include/ftdm_declare.h \
+	$(SRC)/include/ftdm_threadmutex.h \
+	$(SRC)/include/ftdm_os.h \
+	$(SRC)/include/ftdm_dso.h 
 
 lib_LTLIBRARIES	       = libfreetdm.la
-libfreetdm_la_CFLAGS   = $(AM_CFLAGS) $(MY_CFLAGS)
+libfreetdm_la_CFLAGS   = $(AM_CFLAGS) $(FTDM_CFLAGS)
 libfreetdm_la_LDFLAGS  = -version-info 1:0:0 $(AM_LDFLAGS)
 libfreetdm_la_LIBADD   = $(LIBS)
 
-MYLIB = libfreetdm.la
-
 core: libfreetdm.la 
 core-install: install-libLTLIBRARIES
 
 #
 # tools & test programs
 #
-noinst_PROGRAMS = testtones detect_tones detect_dtmf testpri testr2 testanalog testapp testcid #testisdn
-if HAVE_SCTP
-noinst_PROGRAMS += testboost
-endif
+noinst_PROGRAMS  = testtones detect_tones detect_dtmf testpri testr2 testanalog testapp testcid
 noinst_PROGRAMS += testsangomaboost
 
 testapp_SOURCES = $(SRC)/testapp.c
 testapp_LDADD   = libfreetdm.la
-testapp_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+testapp_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 
 testcid_SOURCES = $(SRC)/testcid.c
 testcid_LDADD   = libfreetdm.la
-testcid_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+testcid_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 
 testtones_SOURCES = $(SRC)/testtones.c
 testtones_LDADD   = libfreetdm.la
-testtones_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+testtones_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 
 detect_tones_SOURCES = $(SRC)/detect_tones.c
 detect_tones_LDADD   = libfreetdm.la
-detect_tones_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+detect_tones_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 
 detect_dtmf_SOURCES = $(SRC)/detect_dtmf.c
 detect_dtmf_LDADD   = libfreetdm.la
-detect_dtmf_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+detect_dtmf_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 
 #testisdn_SOURCES = $(SRC)/testisdn.c
 #testisdn_LDADD   = libfreetdm.la
-#testisdn_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+#testisdn_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 
 testpri_SOURCES = $(SRC)/testpri.c
 testpri_LDADD   = libfreetdm.la
-testpri_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+testpri_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 
 testr2_SOURCES = $(SRC)/testr2.c
 testr2_LDADD   = libfreetdm.la
-testr2_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+testr2_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 
 if HAVE_SCTP
+noinst_PROGRAMS  += testboost
 testboost_SOURCES = $(SRC)/testboost.c
 testboost_LDADD   = libfreetdm.la
-testboost_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+testboost_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 endif
 
 testsangomaboost_SOURCES = $(SRC)/testsangomaboost.c
 testsangomaboost_LDADD   = libfreetdm.la
-testsangomaboost_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+testsangomaboost_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 
 testanalog_SOURCES = $(SRC)/testanalog.c
 testanalog_LDADD   = libfreetdm.la
-testanalog_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+testanalog_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 
 #
 # ftmod modules
 #
 mod_LTLIBRARIES = ftmod_zt.la ftmod_skel.la ftmod_analog.la ftmod_analog_em.la
 
-
-if HAVE_SCTP 
-mod_LTLIBRARIES += ftmod_sangoma_boost.la
-endif
-
-if LIBSANGOMA
-mod_LTLIBRARIES += ftmod_wanpipe.la
-endif
-
-if LIBPRI
-mod_LTLIBRARIES += ftmod_libpri.la
-endif
-
-if PRITAP
-mod_LTLIBRARIES += ftmod_pritap.la
-endif
-
-if SNGSS7
-mod_LTLIBRARIES += ftmod_sangoma_ss7.la
-endif
-
-if SNGISDN
-mod_LTLIBRARIES += ftmod_sangoma_isdn.la
-endif
-
-if OPENR2
-mod_LTLIBRARIES += ftmod_r2.la
-endif
-
 ftmod_zt_la_SOURCES = $(SRC)/ftmod/ftmod_zt/ftmod_zt.c
-ftmod_zt_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
-ftmod_zt_la_LDFLAGS = -module -avoid-version
-ftmod_zt_la_LIBADD  = $(MYLIB)
+ftmod_zt_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
+ftmod_zt_la_LDFLAGS = -shared -module -avoid-version
+ftmod_zt_la_LIBADD  = libfreetdm.la
 
 ftmod_skel_la_SOURCES = $(SRC)/ftmod/ftmod_skel/ftmod_skel.c
-ftmod_skel_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
+ftmod_skel_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
 ftmod_skel_la_LDFLAGS = -module -avoid-version
-ftmod_skel_la_LIBADD  = $(MYLIB)
+ftmod_skel_la_LIBADD  = libfreetdm.la
 
-if LIBSANGOMA
+ftmod_analog_la_SOURCES = $(SRC)/ftmod/ftmod_analog/ftmod_analog.c
+ftmod_analog_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
+ftmod_analog_la_LDFLAGS = -shared -module -avoid-version
+ftmod_analog_la_LIBADD  = libfreetdm.la
+
+ftmod_analog_em_la_SOURCES = $(SRC)/ftmod/ftmod_analog_em/ftmod_analog_em.c
+ftmod_analog_em_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
+ftmod_analog_em_la_LDFLAGS = -shared -module -avoid-version
+ftmod_analog_em_la_LIBADD  = libfreetdm.la
+
+if HAVE_LIBSANGOMA
+mod_LTLIBRARIES += ftmod_wanpipe.la
 ftmod_wanpipe_la_SOURCES = $(SRC)/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
-ftmod_wanpipe_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS) -D__LINUX__ -I/usr/include/wanpipe
-ftmod_wanpipe_la_LDFLAGS = -module -avoid-version -lsangoma
-ftmod_wanpipe_la_LIBADD  = $(MYLIB)
+ftmod_wanpipe_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS) -D__LINUX__ -I/usr/include/wanpipe
+ftmod_wanpipe_la_LDFLAGS = -shared -module -avoid-version -lsangoma
+ftmod_wanpipe_la_LIBADD  = libfreetdm.la
 endif
 
 if HAVE_LIBISDN
 mod_LTLIBRARIES += ftmod_isdn.la
 ftmod_isdn_la_SOURCES  = $(SRC)/ftmod/ftmod_isdn/ftmod_isdn.c
-ftmod_isdn_la_CFLAGS   = $(AM_CFLAGS) $(MY_CFLAGS) -D_GNU_SOURCE $(LIBISDN_CPPFLAGS) $(PCAP_CPPFLAGS)
+ftmod_isdn_la_CFLAGS   = $(AM_CFLAGS) $(FTDM_CFLAGS) -D_GNU_SOURCE $(LIBISDN_CPPFLAGS) $(PCAP_CPPFLAGS)
 ftmod_isdn_la_LDFLAGS  = -shared -module -avoid-version $(LIBISDN_LDFLAGS) $(PCAP_LDFLAGS)
-ftmod_isdn_la_LIBADD   = $(MYLIB) $(LIBISDN_LIBS) $(PCAP_LIBS)
+ftmod_isdn_la_LIBADD   = libfreetdm.la $(LIBISDN_LIBS) $(PCAP_LIBS)
 endif
 
-ftmod_analog_la_SOURCES = $(SRC)/ftmod/ftmod_analog/ftmod_analog.c
-ftmod_analog_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
-ftmod_analog_la_LDFLAGS = -module -avoid-version
-ftmod_analog_la_LIBADD  = $(MYLIB)
-
-ftmod_analog_em_la_SOURCES = $(SRC)/ftmod/ftmod_analog_em/ftmod_analog_em.c
-ftmod_analog_em_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
-ftmod_analog_em_la_LDFLAGS = -module -avoid-version
-ftmod_analog_em_la_LIBADD  = $(MYLIB)
-
 if HAVE_SCTP
+mod_LTLIBRARIES += ftmod_sangoma_boost.la
 ftmod_sangoma_boost_la_SOURCES = $(SRC)/ftmod/ftmod_sangoma_boost/sangoma_boost_client.c $(SRC)/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c
-ftmod_sangoma_boost_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
-ftmod_sangoma_boost_la_LDFLAGS = -module -avoid-version
-ftmod_sangoma_boost_la_LIBADD  = $(MYLIB)
+ftmod_sangoma_boost_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
+ftmod_sangoma_boost_la_LDFLAGS = -shared -module -avoid-version
+ftmod_sangoma_boost_la_LIBADD  = libfreetdm.la
 endif
 
-if LIBPRI
+if HAVE_LIBPRI
+mod_LTLIBRARIES += ftmod_libpri.la
 ftmod_libpri_la_SOURCES = $(SRC)/ftmod/ftmod_libpri/ftmod_libpri.c $(SRC)/ftmod/ftmod_libpri/lpwrap_pri.c
-ftmod_libpri_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
-ftmod_libpri_la_LDFLAGS = -module  -avoid-version -lpri
-ftmod_libpri_la_LIBADD  = $(MYLIB)
+ftmod_libpri_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
+ftmod_libpri_la_LDFLAGS = -shared -module -avoid-version -lpri
+ftmod_libpri_la_LIBADD  = libfreetdm.la
 endif
 
-if PRITAP
+if HAVE_PRITAP
+mod_LTLIBRARIES += ftmod_pritap.la
 ftmod_pritap_la_SOURCES = $(SRC)/ftmod/ftmod_pritap/ftmod_pritap.c 
-ftmod_pritap_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
-ftmod_pritap_la_LDFLAGS = -module  -avoid-version -lpri
-ftmod_pritap_la_LIBADD  = $(MYLIB)
+ftmod_pritap_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
+ftmod_pritap_la_LDFLAGS = -shared -module -avoid-version -lpri
+ftmod_pritap_la_LIBADD  = libfreetdm.la
 endif
 
-if SNGSS7
-ftmod_sangoma_ss7_la_SOURCES =	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sts.c \
-								$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
-ftmod_sangoma_ss7_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS) -D_GNU_SOURCE
-ftmod_sangoma_ss7_la_LDFLAGS = -module  -avoid-version -lsng_ss7
-ftmod_sangoma_ss7_la_LIBADD  = $(MYLIB)
+if HAVE_SNG_SS7
+mod_LTLIBRARIES += ftmod_sangoma_ss7.la
+ftmod_sangoma_ss7_la_SOURCES = \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sts.c \
+	$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
+
+ftmod_sangoma_ss7_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS) -D_GNU_SOURCE
+ftmod_sangoma_ss7_la_LDFLAGS = -shared -module -avoid-version -lsng_ss7
+ftmod_sangoma_ss7_la_LIBADD  = libfreetdm.la
 endif
 
-if SNGISDN
-ftmod_sangoma_isdn_la_SOURCES = $(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c \
-				$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c \
-				$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c \
-				$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c \
-				$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c \
-				$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c \
-				$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c \
-				$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c \
-				$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c \
-				$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c
-
-
-ftmod_sangoma_isdn_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS) -D_GNU_SOURCE
-ftmod_sangoma_isdn_la_LDFLAGS = -module -avoid-version -lsng_isdn
-ftmod_sangoma_isdn_la_LIBADD  = $(MYLIB)
+if HAVE_SNG_ISDN
+mod_LTLIBRARIES += ftmod_sangoma_isdn.la
+ftmod_sangoma_isdn_la_SOURCES = \
+	$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c \
+	$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c \
+	$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c \
+	$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c \
+	$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c \
+	$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c \
+	$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c \
+	$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c \
+	$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c \
+	$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c
+
+ftmod_sangoma_isdn_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS) -D_GNU_SOURCE
+ftmod_sangoma_isdn_la_LDFLAGS = -shared -module -avoid-version -lsng_isdn
+ftmod_sangoma_isdn_la_LIBADD  = libfreetdm.la
 endif
 
-if OPENR2
+if HAVE_OPENR2
+mod_LTLIBRARIES += ftmod_r2.la
 ftmod_r2_la_SOURCES = $(SRC)/ftmod/ftmod_r2/ftmod_r2.c 
-ftmod_r2_la_CFLAGS  = $(AM_CFLAGS) $(MY_CFLAGS)
-ftmod_r2_la_LDFLAGS = -module  -avoid-version -lopenr2
-ftmod_r2_la_LIBADD  = $(MYLIB)
+ftmod_r2_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS)
+ftmod_r2_la_LDFLAGS = -shared -module -avoid-version -lopenr2
+ftmod_r2_la_LIBADD  = libfreetdm.la
 endif
 
 dox doxygen:
 	doxygen $(FT_SRCDIR)/docs/Doxygen.conf
 
-mod_freetdm/mod_freetdm.$(DYNAMIC_LIB_EXTEN): $(MYLIB) mod_freetdm/mod_freetdm.c
-	cd mod_freetdm && make
+mod_freetdm/mod_freetdm.$(DYNAMIC_LIB_EXTEN): libfreetdm.la mod_freetdm/mod_freetdm.c
+	$(MAKE) -C mod_freetdm
 
 mod_freetdm: mod_freetdm/mod_freetdm.$(DYNAMIC_LIB_EXTEN)
 
 mod_freetdm-install: mod_freetdm
-	cd mod_freetdm && make install
+	$(MAKE) -C mod_freetdm install
 
 mod_freetdm-clean:
-	@if [ -f mod_freetdm/mod_freetdm.$(DYNAMIC_LIB_EXTEN) ] ; then cd mod_freetdm && make clean ; fi
+	@if [ -f mod_freetdm/mod_freetdm.$(DYNAMIC_LIB_EXTEN) ] ; then \
+		$(MAKE) -C mod_freetdm clean ; \
+	fi
 
 install-data-local:
-	$(mkinstalldirs) $(DESTDIR)$(PREFIX)
+	$(mkinstalldirs) $(DESTDIR)$(prefix)
 	$(mkinstalldirs) $(DESTDIR)@confdir@
 	@[ -f "$(DESTDIR)@confdir@/freetdm.conf" ] || ( cp conf/*.conf $(DESTDIR)@confdir@)
 	@echo FreeTDM Installed
diff --git a/libs/freetdm/build/ax_compiler_vendor.m4 b/libs/freetdm/build/ax_compiler_vendor.m4
new file mode 100644
index 0000000..a24a58d
--- /dev/null
+++ b/libs/freetdm/build/ax_compiler_vendor.m4
@@ -0,0 +1,15 @@
+AC_DEFUN([AX_COMPILER_VENDOR],
+[
+AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
+ [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
+  # note: don't check for gcc first since some other compilers define __GNUC__
+  for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
+    vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
+#if !($vencpp)
+      thisisanerror;
+#endif
+])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
+  done
+ ])
+])
diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac
index 457e525..9f74d94 100644
--- a/libs/freetdm/configure.ac
+++ b/libs/freetdm/configure.ac
@@ -1,120 +1,117 @@
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 
-AC_PREREQ(2.59)
-AC_INIT([freetdm],[pre-alpha],[bugs@freeswitch.org])
+AC_PREREQ([2.59])
+AC_INIT([freetdm], [pre-alpha], [bugs@freeswitch.org])
 AC_CONFIG_SRCDIR([src/ftdm_io.c])
 
-AC_CONFIG_AUX_DIR(build)
-AM_INIT_AUTOMAKE(libfreetdm,0.1)
+AC_CONFIG_AUX_DIR([build])
+AC_CONFIG_MACRO_DIR([build])
+AM_INIT_AUTOMAKE([libfreetdm], [0.1])
+
+# >=automake-1.11
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+# override some default libtool behavior and invoke AC_PROG_LIBTOOL
+# (see http://lists.gnu.org/archive/html/libtool/2007-03/msg00000.html)
+m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
+m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:])
+m4_defun([_LT_AC_LANG_RC_CONFIG], [:])
 
 # Checks for programs.
 AC_PROG_CC
 AC_PROG_MAKE_SET
 AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+AC_PROG_INSTALL
 PKG_PROG_PKG_CONFIG
 
-AC_PREFIX_DEFAULT(/usr/local/freetdm)
-# AC_PREFIX_DEFAULT does not get expanded until too late so we need to do this to use prefix in this script                                                     
-if test "x$prefix" = "xNONE" ; then
-    prefix='/usr/local/freetdm'
+AX_COMPILER_VENDOR
+
+# AC_PREFIX_DEFAULT does not get expanded until too late so we need
+# to do this to use prefix in this script
+AC_PREFIX_DEFAULT([/usr/local/freetdm])
+if test "x${prefix}" = "xNONE" ; then
+	prefix='/usr/local/freetdm'
 fi
 
 # Absolute source/build directory
 FT_SRCDIR=`(cd $srcdir && pwd)`
 ft_builddir=`pwd`
-AC_SUBST(FT_SRCDIR)
-AC_SUBST(ft_builddir)
+AC_SUBST([FT_SRCDIR])
+AC_SUBST([ft_builddir])
 
 if test "$sysconfdir" = "\${prefix}/etc" ; then
-    confdir="$prefix/conf"
+	confdir="$prefix/conf"
 else
-    confdir="$sysconfdir"
+	confdir="$sysconfdir"
 fi
 
-AC_SUBST(confdir)
-
-#override some default libtool behavior and invoke AC_PROG_LIBTOOL (see http://lists.gnu.org/archive/html/libtool/2007-03/msg00000.html)
-m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
-m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:])
-m4_defun([_LT_AC_LANG_RC_CONFIG], [:])
-#AM_PROG_CC_C_O
-AC_PROG_LIBTOOL
-AC_PROG_INSTALL
+AC_SUBST([confdir])
 
-# Check for com;iler type
-AC_DEFUN([AX_COMPILER_VENDOR],
-[
-AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
- [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
-  # note: don't check for GCC first, since some other compilers define __GNUC__
-  for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
-	vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
-#if !($vencpp)
-      thisisanerror;
-#endif
-])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
-  done
- ])
-])
-AC_ARG_ENABLE([enable_64], [AS_HELP_STRING([--enable-64], [Enable 64bit compilation])], [enable_64="$enableval"], [enable_64="no"])
+# Where to install the modules
+AC_ARG_WITH([modinstdir],
+	[AS_HELP_STRING([--with-modinstdir=DIR], [Install modules into this location (default: ${prefix}/mod)])],
+	[case "${withval}" in
+	 no|yes) AC_MSG_ERROR([Invalid value \"${withval}\", option requires a valid path]) ;;
+	 *)	 modinstdir="${withval}" ;;
+	 esac],
+	[modinstdir="${prefix}/mod"]
+)
+AC_SUBST([modinstdir])
 
-AX_COMPILER_VENDOR
+AC_ARG_ENABLE([enable_64],
+	[AS_HELP_STRING([--enable-64], [Enable 64bit compilation])],
+	[enable_64="${enableval}"],
+	[enable_64="no"]
+)
 
 case "${ax_cv_c_compiler_vendor}" in
 gnu)
-    COMP_VENDOR_CFLAGS="-ffast-math -Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -O0"
-    ;;
+	COMP_VENDOR_CFLAGS="-ffast-math -Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -O0"
+	;;
 sun)
-    COMP_VENDOR_CFLAGS="-xc99=all -mt -xCC -D__FUNCTION__=__func__ -xvpara"
-    if test "$enable_64" = "yes" ; then
-        COMP_VENDOR_CFLAGS="-m64 $COMP_VENDOR_CFLAGS"
-    fi
-    ;;
+	COMP_VENDOR_CFLAGS="-xc99=all -mt -xCC -D__FUNCTION__=__func__ -xvpara"
+	if test "$enable_64" != "no" ; then
+		COMP_VENDOR_CFLAGS="-m64 $COMP_VENDOR_CFLAGS"
+	fi
+	;;
 *)
-    COMP_VENDOR_CFLAGS="-std=c99 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
-    ;;
+	COMP_VENDOR_CFLAGS="-std=c99 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
+	;;
 esac
+AC_SUBST([COMP_VENDOR_CFLAGS])
 
+#  Enable debugging
+AC_ARG_ENABLE([debug],
+	[AC_HELP_STRING([--enable-debug], [build with debug information])],
+	[enable_debug="${enableval}"],
+	[enable_debug="yes"]
+)
+if test "${enable_debug}" != "no"; then
+        AC_DEFINE([DEBUG], [], [Enable extra debugging.])
 
-#set SOLINK variable based on compiler and host
-if test "x${ax_cv_c_compiler_vendor}"  =  "xsun" ; then
-    SOLINK="-Bdynamic -dy -G"
-elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
-    case "$host" in
-        *darwin*)
-            SOLINK="-dynamic -bundle -force-flat-namespace"
-        ;;
-        *-solaris2*)
-            SOLINK="-shared -Xlinker"
-        ;;
-        *)
-            SOLINK="-shared -Xlinker -x"
-        ;;
-    esac
-else
-    AC_ERROR([Please update configure.in with SOLINK values for your compiler])
+	if test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
+		COMP_VENDOR_CFLAGS="$COMP_VENDOR_CFLAGS -g -ggdb"
+	fi
 fi
+AC_SUBST([COMP_VENDOR_CFLAGS])
 
 # set DYNAMIC_LIB_EXTEN
 # we should really be using libtool so we don't need to do this
 case "$host" in
-    *cygwin* | *mingw*)
-        DYNAMIC_LIB_EXTEN="dll"
-    ;;
-    *)
-        DYNAMIC_LIB_EXTEN="so"
-    ;;
+*cygwin* | *mingw*)
+	DYNAMIC_LIB_EXTEN="dll"
+	;;
+*)
+	DYNAMIC_LIB_EXTEN="so"
+	;;
 esac
-
-AC_SUBST(SOLINK)
-AC_SUBST(DYNAMIC_LIB_EXTEN)
+AC_SUBST([DYNAMIC_LIB_EXTEN])
 
 AC_CHECK_LIB([dl], [dlopen])
 AC_CHECK_LIB([pthread], [pthread_create])
 AC_CHECK_LIB([m], [cos])
-AX_LIB_PCAP
 
 AC_CHECK_HEADERS([netinet/sctp.h netdb.h sys/select.h])
 AM_CONDITIONAL([HAVE_SCTP],[test "${ac_cv_header_netinet_sctp_h}" = "yes"])
@@ -122,98 +119,127 @@ AM_CONDITIONAL([HAVE_SCTP],[test "${ac_cv_header_netinet_sctp_h}" = "yes"])
 AC_CHECK_FUNC([gethostbyname_r],
 	[], [AC_CHECK_LIB([nsl], [gethostbyname_r])]
 )
-if test "$ac_cv_func_gethostbyname_r" = "yes" -o "$ac_cv_lib_nsl_gethostbyname_r" = "yes" ; then
-
-AC_MSG_CHECKING([whether gethostbyname_r requires five arguments])
-
-ac_cv_func_gethostbyname_r_five_args="no"
-
-AC_TRY_COMPILE([#include <netdb.h>],
-	[char *name;
-	 struct hostent *he, *res;
-	 char buffer[2048];
-	 int buflen = 2048;
-	 (void)gethostbyname_r(name, he, buffer, buflen, &res)],
-	[ac_cv_func_gethostbyname_r_five_args="yes"
-         AC_DEFINE([HAVE_GETHOSTBYNAME_R_FIVE], [1], [gethostbyname_r has five arguments])]
-)
-
-    AC_MSG_RESULT([$ac_cv_func_gethostbyname_r_five_args])
-    AC_DEFINE([HAVE_GETHOSTBYNAME_R],[1],[threadsafe gethostbyname])
-fi
-
-#  Enable debugging
-AC_ARG_ENABLE(debug,
-[AC_HELP_STRING([--enable-debug],[build with debug information])],[enable_debug="$enableval"],[enable_debug="yes"])
-
-if test "${enable_debug}" = "yes"; then
-        AC_DEFINE([DEBUG],[],[Enable extra debugging.])
+if test "$ac_cv_func_gethostbyname_r" = "yes" -o "$ac_cv_lib_nsl_gethostbyname_r" = "yes"
+then
+	AC_MSG_CHECKING([whether gethostbyname_r requires five arguments])
+
+	ac_cv_func_gethostbyname_r_five_args="no"
+
+	AC_TRY_COMPILE([#include <netdb.h>],
+		[char *name;
+		 struct hostent *he, *res;
+		 char buffer[2048];
+		 int buflen = 2048;
+		 (void)gethostbyname_r(name, he, buffer, buflen, &res)],
+		[ac_cv_func_gethostbyname_r_five_args="yes"
+	         AC_DEFINE([HAVE_GETHOSTBYNAME_R_FIVE], [1], [gethostbyname_r has five arguments])]
+	)
 
-	if test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
-	   COMP_VENDOR_CFLAGS="$COMP_VENDOR_CFLAGS -g -ggdb"
-	fi
+	AC_MSG_RESULT([$ac_cv_func_gethostbyname_r_five_args])
+	AC_DEFINE([HAVE_GETHOSTBYNAME_R], [1], [threadsafe gethostbyname])
 fi
 
-# Where to install the modules
-AC_ARG_WITH([modinstdir],
- [AS_HELP_STRING([--with-modinstdir=DIR], [Install modules into this location (default: $prefix/mod)])], [modinstdir="$withval"], [modinstdir="${prefix}/mod"])
-
-AC_SUBST(modinstdir)
-
+##
+## Modules and optional features
+##
+AC_MSG_RESULT([${as_nl}<<>> Modules and optional features])
 
-# libpri?
+##
+# libpri (TODO: add checks)
+#
+HAVE_LIBPRI="no"
 AC_ARG_WITH([libpri],
- [AS_HELP_STRING([--with-libpri], [Install ftmod_libpri])], [enable_libpri="yes"], [enable_libpri="no"])
-AC_SUBST(enable_libpri)
+	[AS_HELP_STRING([--with-libpri], [Install ftmod_libpri])],
+	[case "${withval}" in
+	 no)	enable_libpri="no" ;;
+	 *)	enable_libpri="yes" ;;
+	 esac],
+	[enable_libpri="no"]
+)
+HAVE_LIBPRI="${enable_libpri}"
+AM_CONDITIONAL([HAVE_LIBPRI],[test "${enable_libpri}" = "yes"])
 
-# pritap?
+##
+# pritap (TODO: add checks)
+#
+HAVE_PRITAP="no"
 AC_ARG_WITH([pritap],
- [AS_HELP_STRING([--with-pritap], [Install ftmod_pritap])], [enable_pritap="yes"], [enable_pritap="no"])
-AC_SUBST(enable_pritap)
+	[AS_HELP_STRING([--with-pritap], [Install ftmod_pritap])],
+	[case "${withval}" in
+	 no)	enable_pritap="no" ;;
+	 *)	enable_pritab="yes" ;;
+	 esac],
+	[enable_pritap="no"]
+)
+HAVE_PRITAP="${enable_pritap}"
+AM_CONDITIONAL([HAVE_PRITAP],[test "${enable_pritap}" = "yes"])
 
 # debug dtmf?
 AC_ARG_WITH([debugdtmf],
- [AS_HELP_STRING([--with-debugdtmf], [Debug DTMF])], [enable_debugdtmf="yes"], [enable_debugdtmf="no"])
-AC_SUBST(enable_debugdtmf)
-
-AC_CHECK_LIB([sangoma], [sangoma_span_chan_toif], [have_libsangoma="yes"])
-AM_CONDITIONAL([LIBSANGOMA],[test "${have_libsangoma}" = "yes"])
-
-AM_CONDITIONAL([LIBPRI],[test "${enable_libpri}" = "yes"])
-
-AM_CONDITIONAL([PRITAP],[test "${enable_pritap}" = "yes"])
-
-AM_CONDITIONAL([DEBUGDTMF],[test "${enable_debugdtmf}" = "yes"])
+	[AS_HELP_STRING([--with-debugdtmf], [Debug DTMF])],
+	[case "${withval}" in
+	 no)	enable_debugdtmf="no" ;;
+	 *)	enable_debugdtmf="yes" ;;
+	 esac],
+	[enable_debugdtmf="no"]
+)
+AM_CONDITIONAL([WANT_DEBUGDTMF], [test "${enable_debugdtmf}" = "yes"])
 
-AC_CHECK_LIB([sng_ss7], [sng_isup_init], [have_sng_ss7="yes"])
-AM_CONDITIONAL([SNGSS7],[test "${have_sng_ss7}" = "yes"])
+##
+# OpenR2 stack
+#
+HAVE_OPENR2="no"
+AC_CHECK_LIB([openr2], [openr2_context_set_io_type], [HAVE_OPENR2="yes"])
+AC_MSG_RESULT([checking whether to build ftmod_r2... ${HAVE_OPENR2}])
+AM_CONDITIONAL([HAVE_OPENR2], [test "${HAVE_OPENR2}" = "yes"])
 
-AC_CHECK_LIB([sng_isdn], [sng_isdn_init], [have_sng_isdn="yes"])
-AM_CONDITIONAL([SNGISDN],[test "${have_sng_isdn}" = "yes"])
+##
+# Sangoma Wanpipe
+#
+HAVE_LIBSANGOMA="no"
+AC_MSG_RESULT([${as_nl}<<>> Sangoma Wanpipe])
+AC_CHECK_LIB([sangoma], [sangoma_span_chan_toif], [HAVE_LIBSANGOMA="yes"])
+AC_MSG_RESULT([checking whether to build ftmod_wanpipe... ${HAVE_LIBSANGOMA}])
+AM_CONDITIONAL([HAVE_LIBSANGOMA], [test "${HAVE_LIBSANGOMA}" = "yes"])
 
-AC_CHECK_LIB([openr2], [openr2_context_set_io_type], [have_openr2="yes"])
-AM_CONDITIONAL([OPENR2],[test "${have_openr2}" = "yes"])
+##
+# Sangoma ISDN stack
+#
+HAVE_SNG_ISDN="no"
+AC_MSG_RESULT([${as_nl}<<>> Sangoma ISDN stack])
+AC_CHECK_LIB([sng_isdn], [sng_isdn_init], [HAVE_SNG_ISDN="yes"])
+AC_MSG_RESULT([checking whether to build ftmod_sangoma_isdn... ${HAVE_SNG_ISDN}])
+AM_CONDITIONAL([HAVE_SNG_ISDN], [test "${HAVE_SNG_ISDN}" = "yes"])
 
-if test "${have_sng_isdn}" = "yes"; then
+if test "${HAVE_SNG_ISDN}" = "yes"; then
 	if test "${build}" == "${host}"
 	then
 		case "${host}" in
 		x86_64-*)
-		# X86_64 machines need additional flags when compiling against libsng_isdn
-		CFLAGS="$CFLAGS -DBIT_64 -DALIGN_64BIT"
-		;;
+			# X86_64 machines need additional flags when compiling against libsng_isdn
+			CFLAGS="$CFLAGS -DBIT_64 -DALIGN_64BIT"
+			;;
 		esac
 	fi
 fi
 
-if test "${have_sng_ss7}" = "yes"; then
+##
+# Sangoma SS7 stack
+#
+HAVE_SNG_SS7="no"
+AC_MSG_RESULT([${as_nl}<<>> Sangoma SS7 stack])
+AC_CHECK_LIB([sng_ss7], [sng_isup_init], [HAVE_SNG_SS7="yes"])
+AC_MSG_RESULT([checking whether to build ftmod_sangoma_ss7... ${HAVE_SNG_SS7}])
+AM_CONDITIONAL([HAVE_SNG_SS7], [test "${HAVE_SNG_SS7}" = "yes"])
+
+if test "${HAVE_SNG_SS7}" = "yes"; then
 	if test "${build}" == "${host}"
 	then
 		case "${host}" in
 		x86_64-*)
-		# X86_64 machines need additional flags when compiling against libsng_isdn
-		CFLAGS="$CFLAGS -DBIT_64 -DALIGN_64BIT"
-		;;
+			# X86_64 machines need additional flags when compiling against libsng_isdn
+			CFLAGS="$CFLAGS -DBIT_64 -DALIGN_64BIT"
+			;;
 		esac
 	fi
 fi
@@ -268,14 +294,35 @@ then
 		],
 		[AC_MSG_ERROR([Need libisdn-0.0.1 or higher])]
 	)
+	AX_LIB_PCAP
 fi
 AM_CONDITIONAL([HAVE_LIBISDN], [test "${HAVE_LIBISDN}" = "yes"])
 
-COMP_VENDOR_CFLAGS="$COMP_VENDOR_CFLAGS"
-AC_SUBST(COMP_VENDOR_CFLAGS)
-
 AC_MSG_RESULT([${as_nl}<<>> Creating output files])
-AC_CONFIG_FILES([Makefile
-		freetdm.pc
-		mod_freetdm/Makefile])
+AC_CONFIG_FILES([
+	Makefile
+	freetdm.pc
+	mod_freetdm/Makefile
+])
 AC_OUTPUT
+
+#
+# summary screen
+#
+AC_MSG_RESULT([
+============================ FreeTDM configuration ============================
+
++ Modules
+
+  Signalling:
+	ftmod_isdn......................... ${HAVE_LIBISDN}
+	ftmod_libpri....................... ${HAVE_LIBPRI}
+	ftmod_sangoma_isdn................. ${HAVE_SNG_ISDN}
+	ftmod_sangoma_ss7.................. ${HAVE_SNG_SS7}
+	ftmod_r2........................... ${HAVE_OPENR2}
+	ftmod_pritap....................... ${HAVE_PRITAP}
+  I/O:
+	ftmod_wanpipe...................... ${HAVE_LIBSANGOMA}
+
+===============================================================================
+])
-- 
1.7.2.2

