via: a3b18e5b7cf33bf9de36cb12c953a5b527549a9f (commit)
from: 39ff78bfae112b2095dd0b8aea1ff46c1d1f5b01 (commit)
= COMMIT LOG ===========================================================
committer: Stefan Knoblich
comments:
[SDK] Import autotools version of fs-mod-sdk.
This is a autotools (autoconf/automake/libtool) based skeleton framework for developing
external (= out-of-tree) modules for FreeSWITCH.
Variants of this framework have been used to develop modules like mod_openais, mod_ssh and others.
NOTE: This version of the SDK relies on pkg-config to detect FreeSWITCH
installations.
Other SDKs for external modules should be added in: "src/mod/sdk/<build-system-name>/"
e.g. a scons-based SDK should be put in: "src/mod/sdk/scons/"
Signed-off-by: Stefan Knoblich <s.knoblich@axsentis.de>
Requested-by: Michal Bielicki - cypromis <michal.bielicki@seventhsignal.de>
diff --git a/src/mod/sdk/autotools/.gitignore b/src/mod/sdk/autotools/.gitignore
new file mode 100644
index 0000000..57b51ac
--- /dev/null
+++ b/src/mod/sdk/autotools/.gitignore
@@ -0,0 +1,35 @@
+*.o
+*.lo
+*.so
+*.a
+*.orig
+*.rej
+*.log
+*.la
+
+.deps
+.libs
+
+stamp-h1
+samples*
+Makefile
+Makefile.in
+config.log
+config.sub
+config.guess
+config.status
+configure
+libtool
+aclocal.m4
+autom4te.cache
+depcomp
+install-sh
+compile
+missing
+ltmain.sh
+doxygen
+m4/libtool.m4
+m4/ltsugar.m4
+m4/ltoptions.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
diff --git a/src/mod/sdk/autotools/Makefile.am b/src/mod/sdk/autotools/Makefile.am
new file mode 100644
index 0000000..8f8a25a
--- /dev/null
+++ b/src/mod/sdk/autotools/Makefile.am
@@ -0,0 +1,4 @@
+ACLOCAL_AMFLAGS = -I m4
+AUTOMAKE_OPTIONS = foreign no-dist subdir-objects
+
+SUBDIRS = src
diff --git a/src/mod/sdk/autotools/autogen.sh b/src/mod/sdk/autotools/autogen.sh
new file mode 100755
index 0000000..08240fd
--- /dev/null
+++ b/src/mod/sdk/autotools/autogen.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+autoreconf -i -f
diff --git a/src/mod/sdk/autotools/configure.ac b/src/mod/sdk/autotools/configure.ac
new file mode 100644
index 0000000..d4f29f4
--- /dev/null
+++ b/src/mod/sdk/autotools/configure.ac
@@ -0,0 +1,252 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+# website url
+m4_define([AC_PACKAGE_URL], [http://www.example.com/])
+
+AC_PREREQ([2.61])
+AC_INIT([mod_example], [0.0.0], [contact@example.com])
+AC_CONFIG_SRCDIR([src/mod_example.c])
+AC_CONFIG_MACRO_DIR([m4])
+
+AM_INIT_AUTOMAKE([foreign no-dist subdir-objects])
+AC_DISABLE_STATIC
+
+# disable libtool fortran and c++ checks
+m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
+m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
+
+# >=automake-1.11
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+# Checks for programs.
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+
+# pkgconfig
+AC_PATH_PROG([PKG_CONFIG], [pkg-config], ["no"])
+if test "x${PKG_CONFIG}" = "xno"
+then
+ AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed in your PATH])
+fi
+PKG_PROG_PKG_CONFIG
+
+# Checks for cflags
+AC_MSG_RESULT([${as_nl}<<>> Compiler vendor and features])
+
+##
+## Compiler vendor and flag checks
+##
+HAVE_VISIBILITY="no"
+AC_ARG_ENABLE([visibility],
+ [AS_HELP_STRING([--disable-visibility], [Disable symbol visibility support (default: enabled, if available)])],
+ [case "${enableval}" in
+ yes) enable_visibility="yes" ;;
+ no) enable_visibility="no" ;;
+ *) AC_MSG_ERROR([Invalid value ${enableval} for parameter --disable-visibility]) ;;
+ esac],
+ [enable_visibility="yes"]
+)
+
+AX_COMPILER_VENDOR
+
+case "${ax_cv_c_compiler_vendor}" in
+gnu)
+ AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden])
+ AS_IF([test "x${enable_visibility}" != "xno"],
+ [save_CFLAGS="${CFLAGS}"
+ CFLAGS="${CFLAGS} -fvisibility=hidden"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [int foo __attribute__ ((visibility("default")));],
+ [;]
+ )],
+
+ [AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_VISIBILITY],[1],[GCC visibility support])
+ HAVE_VISIBILITY="yes"],
+
+ [AC_MSG_RESULT([no])
+ HAVE_VISIBILITY="no"]
+ )
+ CFLAGS="${save_CFLAGS}"],
+ [AC_MSG_RESULT([disabled by user])]
+ )
+
+ AS_IF([test "x${HAVE_VISIBILITY}" != "xno"],
+ [save_CFLAGS="${CFLAGS}"
+ CFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
+ AC_MSG_CHECKING([whether the compiler supports -fvisibility-inlines-hidden])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [;], [;]
+ )],
+
+ [AC_MSG_RESULT([yes])
+ HAVE_VISIBILITY_INLINES_HIDDEN="yes"],
+
+ [AC_MSG_RESULT([no])
+ HAVE_VISIBILITY_INLINES_HIDDEN="no"]
+ )
+ CFLAGS="${save_CFLAGS}"],
+ [:]
+ )
+ AC_DEFINE([COMPILER_GCC], [1], [Compiler is GCC])
+ ;;
+sun)
+ AC_MSG_CHECKING([whether the compiler supports -xldscope=hidden])
+ AS_IF([test "x${enable_visibility}" != "xno"],
+ [save_CFLAGS="${CFLAGS}"
+ CFLAGS="${CFLAGS} -xldscope=hidden"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [int foo __attribute__ ((visibility("default")));],
+ [;]
+ )],
+
+ [AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_VISIBILITY],[1],[SUNCC visibility support])
+ HAVE_VISIBILITY="yes"],
+
+ [AC_MSG_RESULT([no])
+ HAVE_VISIBILITY="no"]
+ )
+ CFLAGS="${save_CFLAGS}"],
+ [AC_MSG_RESULT([disabled by user])]
+ )
+ AC_DEFINE([COMPILER_SUNCC], [1], [Compiler is SunCC])
+ ;;
+*)
+ AC_MSG_WARN([No visibility checks for this compiler defined])
+ ;;
+esac
+
+AM_CONDITIONAL([COMPILER_GCC], [test "x${ax_cv_c_compiler_vendor}" = "xgnu"])
+AM_CONDITIONAL([COMPILER_SUNCC], [test "x${ax_cv_c_compiler_vendor}" = "xsun"])
+
+AM_CONDITIONAL([HAVE_VISIBILITY], [test "x${HAVE_VISIBILITY}" = "xyes"])
+AM_CONDITIONAL([HAVE_VISIBILITY_INLINES_HIDDEN], [test "x${HAVE_VISIBILITY_INLINES_HIDDEN}" = "xyes"])
+
+##
+## pkgconfig based freeswitch detection code
+##
+AC_MSG_RESULT([${as_nl}<<>> FreeSWITCH environment])
+
+PKG_CHECK_MODULES([freeswitch], [freeswitch],
+ [save_LIBS="${LIBS}"
+ save_CFLAGS="${CFLAGS}"
+ save_CPPFLAGS="${CPPFLAGS}"
+
+ AC_MSG_CHECKING([FreeSWITCH version])
+
+ FREESWITCH_VERSION="`${PKG_CONFIG} --modversion freeswitch 2>/dev/null`"
+ AS_IF([test "x${FREESWITCH_VERSION}" = "x"],
+ [AC_MSG_ERROR([failed to get FreeSWITCH version])],
+ [AC_MSG_RESULT([$FREESWITCH_VERSION])]
+ )
+
+ AC_MSG_CHECKING([whether FreeSWITCH ${FREESWITCH_VERSION} is usable])
+ CFLAGS="${freeswitch_CFLAGS}"
+ CPPFLAGS="${freeswitch_CPPFLAGS}"
+ LIBS="${freeswitch_LIBS}"
+ AC_TRY_LINK([#include <switch.h>],
+ [switch_core_init(0, 0, NULL);],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])
+ AC_MSG_ERROR([libfreeswitch is unusable, please check config.log for details])]
+ )
+ LIBS="${save_LIBS}"
+ CFLAGS="${save_CFLAGS}"
+ CPPFLAGS="${save_CPPFLAGS}"
+
+ # get locations, critical first
+ AC_MSG_CHECKING([for installation prefix])
+ FREESWITCH_PREFIX_DIR="`${PKG_CONFIG} --variable=prefix freeswitch 2>/dev/null`"
+ AS_IF(
+ [test "x${FREESWITCH_PREFIX_DIR}" = "x"], [AC_MSG_ERROR([unable to get FreeSWITCH prefix directory])],
+ [test ! -e "${FREESWITCH_PREFIX_DIR}"], [AC_MSG_ERROR([FreeSWITCH prefix directory ${FREESWITCH_PREFIX_DIR} does not exist])]
+ )
+ AC_MSG_RESULT([${FREESWITCH_PREFIX_DIR}])
+
+ AC_MSG_CHECKING([for modules directory])
+ FREESWITCH_MODULES_DIR="`${PKG_CONFIG} --variable=modulesdir freeswitch 2>/dev/null`"
+ AS_IF(
+ [test "x${FREESWITCH_MODULES_DIR}" = "x"], [AC_MSG_ERROR([unable to get FreeSWITCH modules directory])],
+ [test ! -e "${FREESWITCH_MODULES_DIR}"], [AC_MSG_ERROR([FreeSWITCH modules directory ${FREESWITCH_MODULES_DIR} does not exist])]
+ )
+ AC_MSG_RESULT([${FREESWITCH_MODULES_DIR}])
+
+ AC_MSG_CHECKING([for configuration directory])
+ FREESWITCH_CONFIG_DIR="`${PKG_CONFIG} --variable=sysconfdir freeswitch 2>/dev/null`"
+ AS_IF(
+ [test "x${FREESWITCH_CONFIG_DIR}" = "x"], [AC_MSG_ERROR([unable to get FreeSWITCH configuration directory])],
+ [test ! -e "${FREESWITCH_CONFIG_DIR}"], [AC_MSG_ERROR([FreeSWITCH configuration directory ${FREESWITCH_CONFIG_DIR} does not exist])]
+ )
+ AC_MSG_RESULT([${FREESWITCH_CONFIG_DIR}])
+
+ # non-critical paths
+ FREESWITCH_HTDOCS_DIR="`${PKG_CONFIG} --variable=htdocsdir freeswitch 2>/dev/null`"
+
+ FREESWITCH_RUNTIME_DIR="`${PKG_CONFIG} --variable=runtimedir freeswitch 2>/dev/null`"
+ FREESWITCH_SCRIPTS_DIR="`${PKG_CONFIG} --variable=scriptsdir freeswitch 2>/dev/null`"
+
+ # cflags, libs
+ AC_SUBST([FREESWITCH_CFLAGS], [${freeswitch_CFLAGS}])
+ AC_SUBST([FREESWITCH_CPPFLAGS], [${freeswitch_CPPFLAGS}])
+ AC_SUBST([FREESWITCH_LIBS], [${freeswitch_LIBS}])
+
+ # version
+ AC_SUBST([FREESWITCH_VERSION])
+
+ # locations
+ AC_SUBST([FREESWITCH_PREFIX_DIR])
+ AC_SUBST([FREESWITCH_HTDOCS_DIR])
+ AC_SUBST([FREESWITCH_CONFIG_DIR])
+ AC_SUBST([FREESWITCH_MODULES_DIR])
+ AC_SUBST([FREESWITCH_SCRIPTS_DIR])
+ AC_SUBST([FREESWITCH_RUNTIME_DIR])
+ ],
+ [AC_MSG_ERROR([FreeSWITCH not found])]
+)
+
+##
+## Add your other dependency checks here
+##
+AC_MSG_RESULT([${as_nl}<<>> Other dependencies])
+
+# Checks for header files.
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+
+AC_MSG_RESULT([${as_nl}<<>> Create output files])
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_OUTPUT
+
+AC_MSG_RESULT([
+====================== Configuration Summary =====================
++ Package
+ Name:...................... ${PACKAGE_NAME}
+ Version:................... ${PACKAGE_VERSION}
+ Bugreports:................ ${PACKAGE_BUGREPORT}
+ Website:................... ${PACKAGE_URL}
+
++ Compiler
+ Vendor:.................... ${ax_cv_c_compiler_vendor}
+ Symbol visibility:......... ${HAVE_VISIBILITY}
+
++ FreeSWITCH
+ Version:................... ${FREESWITCH_VERSION}
+ Prefix:.................... ${FREESWITCH_PREFIX_DIR}
+ Modules directory:......... ${FREESWITCH_MODULES_DIR}
+ Configuration directory:... ${FREESWITCH_CONFIG_DIR}
+
+ Cflags/CPPflags/CXXflags:.. ${FREESWITCH_CFLAGS} ${FREESWITCH_CPPFLAGS}
+ LDflags/Libs:.............. ${FREESWITCH_LIBS} ${FREESWITCH_LDFLAGS}
+
++ Other
+ N/A
+==================================================================
+])
diff --git a/src/mod/sdk/autotools/m4/ax_compiler_vendor.m4 b/src/mod/sdk/autotools/m4/ax_compiler_vendor.m4
new file mode 100644
index 0000000..a24a58d
--- /dev/null
+++ b/src/mod/sdk/autotools/m4/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/src/mod/sdk/autotools/src/Makefile.am b/src/mod/sdk/autotools/src/Makefile.am
new file mode 100644
index 0000000..d2bad5b
--- /dev/null
+++ b/src/mod/sdk/autotools/src/Makefile.am
@@ -0,0 +1,66 @@
+moddir = @FREESWITCH_MODULES_DIR@
+sysconfdir = @FREESWITCH_CONFIG_DIR@
+
+###
+# Flags
+#
+AM_CFLAGS =
+AM_CXXFLAGS=
+AM_CPPFLAGS= -I. -I$(includedir)
+AM_LDFLAGS = -L. -L$(libdir) -avoid-version -module -no-undefined -shared
+
+###
+# GCC specific flags
+#
+if COMPILER_GCC
+AM_CFLAGS += -Wall
+# symbol visibility support
+if HAVE_VISIBILITY
+AM_CFLAGS += -fvisibility=hidden
+AM_CXXFLAGS+= -fvisibility=hidden
+AM_CPPFLAGS+= -DSWITCH_API_VISIBILITY=1
+endif
+if HAVE_VISIBILITY_INLINES_HIDDEN
+AM_CXXFLAGS += -fvisibility-inlines-hidden
+endif
+endif
+
+###
+# SunCC specific flags
+#
+if COMPILER_SUNCC
+AM_CFLAGS +=
+# symbol visibility support
+if HAVE_VISIBILITY
+AM_CFLAGS += -xldscope=hidden
+AM_CXXFLAGS += -xldscope=hidden
+AM_CPPFLAGS += -DSWITCH_API_VISIBILITY=1
+endif
+endif
+
+
+###
+# add module(s) here, with suffix '.la'
+#
+mod_LTLIBRARIES = mod_example.la
+
+###
+# mod_example
+#
+mod_example_la_SOURCES = mod_example.c
+mod_example_la_CFLAGS = $(AM_CFLAGS) $(FREESWITCH_CFLAGS)
+mod_example_la_CPPFLAGS= $(AM_CPPFLAGS) $(FREESWITCH_CPPFLAGS)
+mod_example_la_LDFLAGS = $(AM_LDFLAGS)
+mod_example_la_LIBADD = $(FREESWITCH_LIBS)
+
+# configuration file
+#sysconf_DATA = example.conf.xml
+
+#
+# install configuration
+#
+#install-sysconfDATA:
+# $(INSTALL) -d $(DESTDIR)/$(sysconfdir)
+# for x in $(sysconf_DATA); do \
+# test -e $(DESTDIR)$(sysconfdir)/$$x || $(INSTALL) -m644 $$x $(DESTDIR)$(sysconfdir)/$$x ; \
+# done
diff --git a/src/mod/sdk/autotools/src/mod_example.c b/src/mod/sdk/autotools/src/mod_example.c
new file mode 100644
index 0000000..5e7755c
--- /dev/null
+++ b/src/mod/sdk/autotools/src/mod_example.c
@@ -0,0 +1,84 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthmct@yahoo.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Anthony Minessale II <anthmct@yahoo.com>
+ * Neal Horman <neal at wanlink dot com>
+ *
+ *
+ * mod_example.c -- Framework Demo Module
+ *
+ */
+#include <switch.h>
+
+/*
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_example_shutdown);
+SWITCH_MODULE_RUNTIME_FUNCTION(mod_example_runtime);
+*/
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_example_load);
+SWITCH_MODULE_DEFINITION(mod_example, mod_example_load, NULL, NULL);
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_example_load)
+{
+ /* connect my internal structure to the blank pointer passed to me */
+ *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
+
+ /* indicate that the module should continue to be loaded */
+ return SWITCH_STATUS_SUCCESS;
+}
+
+/*
+ Called when the system shuts down
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_example_shutdown);
+{
+ return SWITCH_STATUS_SUCCESS;
+}
+*/
+
+/*
+ If it exists, this is called in it's own thread when the module-load completes
+ If it returns anything but SWITCH_STATUS_TERM it will be called again automaticly
+SWITCH_MODULE_RUNTIME_FUNCTION(mod_example_runtime);
+{
+ while(looping)
+ {
+ switch_yield(1000);
+ }
+ return SWITCH_STATUS_TERM;
+}
+*/
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:nil
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
Summary of changes:
src/mod/sdk/autotools/.gitignore | 35 +++
src/mod/sdk/autotools/Makefile.am | 4 +
src/mod/sdk/autotools/autogen.sh | 2 +
src/mod/sdk/autotools/configure.ac | 252 ++++++++++++++++++++
.../mod/sdk/autotools/m4}/ax_compiler_vendor.m4 | 0
src/mod/sdk/autotools/src/Makefile.am | 66 +++++
src/mod/sdk/autotools/src/mod_example.c | 84 +++++++
7 files changed, 443 insertions(+), 0 deletions(-)
create mode 100644 src/mod/sdk/autotools/.gitignore
create mode 100644 src/mod/sdk/autotools/Makefile.am
create mode 100755 src/mod/sdk/autotools/autogen.sh
create mode 100644 src/mod/sdk/autotools/configure.ac
copy {build/config => src/mod/sdk/autotools/m4}/ax_compiler_vendor.m4 (100%)
create mode 100644 src/mod/sdk/autotools/src/Makefile.am
create mode 100644 src/mod/sdk/autotools/src/mod_example.c
this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email
For more info, see http://blog.chomperstomp.com/?p=630
--
FreeSWITCH Source