freeswitch-stable: add Perl support
authorSebastian Kemper <sebastian_ml@gmx.net>
Sat, 24 Jun 2017 20:23:13 +0000 (22:23 +0200)
committerSebastian Kemper <sebastian_ml@gmx.net>
Sat, 24 Jun 2017 20:25:36 +0000 (22:25 +0200)
- add mod_perl and perl-esl.
- some patching is required to make this work.
- for the modules to find libperl, an rpath is needed, which currently
  doesn't work because of an rstrip.sh/patchelf issue. Patch sent to
  OpenWrt/LEDE devs (https://patchwork.ozlabs.org/patch/780008/)
- fix some more copts issues that became apparent with Perl enabled.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
net/freeswitch-stable/Makefile
net/freeswitch-stable/patches/030-fix-configure-ac.patch
net/freeswitch-stable/patches/180-mod_perl.patch [new file with mode: 0644]
net/freeswitch-stable/patches/200-mod_verto-fix-copts.patch [new file with mode: 0644]
net/freeswitch-stable/patches/210-esl-perl-fix-copts.patch [new file with mode: 0644]

index 533f188706c8d6324dc24beefd97e31c9fedc8d7..1a2c83b7409f9f7ddab1ca9914cbf1348a689760 100644 (file)
@@ -141,6 +141,7 @@ FS_STABLE_MOD_AVAILABLE:= \
        odbc_cdr \
        opus \
        oreka \
+       perl \
        png \
        pocketsphinx \
        posix_timer \
@@ -353,6 +354,33 @@ fi
 exit 0
 endef
 
+define Package/$(PKG_NAME)-misc-perl-esl
+$(call Package/$(PKG_NAME)/Default)
+  TITLE:=Perl ESL
+  DEPENDS:=$(PKG_NAME) +PACKAGE_$(PKG_NAME)-misc-perl-esl:perl
+endef
+
+define Package/$(PKG_NAME)-misc-perl-esl/description
+This package contains the Perl binding for FreeSWITCH's Event Socket
+Library (ESL).
+endef
+
+define Package/$(PKG_NAME)-misc-perl-esl/install
+       $(INSTALL_DIR) $(1)$$(PERL_SITELIB)/ESL
+       $(INSTALL_DATA) \
+               $(PKG_INSTALL_DIR)$$(PERL_SITELIB)/ESL.pm \
+                                       $(1)$$(PERL_SITELIB)
+       $(INSTALL_BIN) \
+               $(PKG_INSTALL_DIR)$$(PERL_SITELIB)/ESL.so \
+                                       $(1)$$(PERL_SITELIB)
+       $(INSTALL_DATA) \
+               $(PKG_INSTALL_DIR)$$(PERL_SITELIB)/ESL/Dispatch.pm \
+                                       $(1)$$(PERL_SITELIB)/ESL
+       $(INSTALL_DATA) \
+               $(PKG_INSTALL_DIR)$$(PERL_SITELIB)/ESL/IVR.pm \
+                                       $(1)$$(PERL_SITELIB)/ESL
+endef
+
 define Package/$(PKG_NAME)-misc-python-esl
 $(call Package/$(PKG_NAME)/Default)
   TITLE:=Python ESL
@@ -468,6 +496,15 @@ $(call Package/$(PKG_NAME)/install/mod,$$(1),$(1))
 ifeq ($(CONFIG_FS_STABLE_WITH_MODCONF),y)
 $(call Package/$(PKG_NAME)/install/dir,$$(1)$(FS_STABLE_EXAMPLES_DIR)/mod_$(1),$(PKG_BUILD_DIR)/src/mod/*/mod_$(1)/conf)
 endif
+ifeq ($(1),perl)
+       $(INSTALL_DIR) $$(1)$$(PERL_SITELIB)/auto
+       $(INSTALL_DATA) \
+               $(PKG_INSTALL_DIR)$(FS_STABLE_PREFIX_DIR)/perl/$(PRG_NAME).pm \
+                                                       $$(1)$$(PERL_SITELIB)
+       $(INSTALL_BIN) \
+               $(PKG_INSTALL_DIR)$(FS_STABLE_PREFIX_DIR)/perl/$(PRG_NAME).so \
+                                                       $$(1)$$(PERL_SITELIB)/auto
+endif
 ifeq ($(1),python)
        $(INSTALL_DIR) $$(1)$(PYTHON_PKG_DIR)
        $(INSTALL_DATA) \
@@ -517,10 +554,8 @@ endif
 $$(eval $$(call BuildPackage,$(PKG_NAME)-util-$(1)))
 endef
 
-# we neither need host-perl nor host-php
+# don't want host-php
 CONFIGURE_VARS+= \
-       ac_cv_prog_PERL=false \
-       ac_cv_have_perl=no \
        ac_cv_prog_PHP=false \
        ac_cv_have_php=no \
        ac_cv_prog_PHP_CONFIG=false \
@@ -563,6 +598,38 @@ endif
 CONFIGURE_VARS+= \
        disable_cc=yes
 
+# Perl setup start
+ifneq ($(CONFIG_PACKAGE_$(PKG_NAME)-misc-perl-esl)$(CONFIG_PACKAGE_$(PKG_NAME)-mod-perl),)
+
+FS_STABLE_PERL_FEED:=$(TOPDIR)/feeds/packages/lang/perl
+
+FS_STABLE_PERL_LIBS:=$(shell grep "^libs=" \
+       $(FS_STABLE_PERL_FEED)/files/base.config | \
+                       sed "s/^libs=//;s/'//g")
+
+include $(FS_STABLE_PERL_FEED)/perlmod.mk
+
+CONFIGURE_VARS+= \
+       ac_cv_lib_perl_perl_alloc=yes
+
+CONFIGURE_VARS+= \
+       PERL="$(PERL_CMD)" \
+       PERL_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_GNU_SOURCE -I$(STAGING_DIR)$(PERL_SITELIB)/CORE" \
+       PERL_INC="-I$(STAGING_DIR)$(PERL_SITELIB)/CORE" \
+       PERL_LDFLAGS="-fPIC -Wl,-rpath,$(PERL_SITELIB)/CORE -L$(STAGING_DIR)$(PERL_SITELIB)/CORE -lperl" \
+       PERL_LIBDIR="-L$(PERL_SITELIB)/CORE" \
+       PERL_LIBS="-lpthread $(FS_STABLE_PERL_LIBS) $(EXTRA_LIBDIRS:%=-L%) $(EXTRA_LIBS:%=-l%)" \
+       PERL_SITEDIR="$(PERL_SITELIB)"
+
+else
+
+CONFIGURE_VARS+= \
+       ac_cv_prog_PERL=false \
+       ac_cv_have_perl=no
+
+endif
+# Perl setup end
+
 # Python setup start
 ifneq ($(CONFIG_PACKAGE_$(PKG_NAME)-misc-python-esl)$(CONFIG_PACKAGE_$(PKG_NAME)-mod-python),)
 
@@ -738,6 +805,9 @@ endef
 
 define Build/Compile
        $(call Build/Compile/Default)
+ifneq ($(CONFIG_PACKAGE_$(PKG_NAME)-misc-perl-esl),)
+       $(call Build/Compile/Default,-C $(PKG_BUILD_DIR)/libs/esl perlmod)
+endif
 ifneq ($(CONFIG_PACKAGE_$(PKG_NAME)-misc-python-esl),)
        $(call Build/Compile/Default,-C $(PKG_BUILD_DIR)/libs/esl pymod)
 endif
@@ -745,6 +815,9 @@ endef
 
 define Build/Install
        $(call Build/Install/Default)
+ifneq ($(CONFIG_PACKAGE_$(PKG_NAME)-misc-perl-esl),)
+       $(call Build/Compile/Default,-C $(PKG_BUILD_DIR)/libs/esl DESTDIR=$(PKG_INSTALL_DIR) perlmod-install)
+endif
 ifneq ($(CONFIG_PACKAGE_$(PKG_NAME)-misc-python-esl),)
        $(call Build/Install/Default,-C $(PKG_BUILD_DIR)/libs/esl pymod-install)
 endif
@@ -752,6 +825,7 @@ endef
 
 $(eval $(call BuildPackage,$(PKG_NAME)))
 $(eval $(call BuildPackage,$(PKG_NAME)-misc-hotplug))
+$(eval $(call BuildPackage,$(PKG_NAME)-misc-perl-esl))
 $(eval $(call BuildPackage,$(PKG_NAME)-misc-python-esl))
 $(eval $(call BuildPackage,$(PKG_NAME)-misc-timezones))
 
@@ -881,6 +955,7 @@ $(eval $(call Package/$(PKG_NAME)/Module,nibblebill,Nibblebill,This module allow
 $(eval $(call Package/$(PKG_NAME)/Module,odbc_cdr,ODBC CDR,ODBC Call Detail Record handler.,))
 $(eval $(call Package/$(PKG_NAME)/Module,opus,Opus,Opus codec support.,+libopus))
 $(eval $(call Package/$(PKG_NAME)/Module,oreka,Oreka,This module provides media recording with the Oreka cross-platform\naudio stream recording and retrieval system.,))
+$(eval $(call Package/$(PKG_NAME)/Module,perl,Perl,This package contains mod_perl for FreeSWITCH.,@PERL_THREADS PACKAGE_$(PKG_NAME)-mod-perl:perl +libdb47 +libgdbm))
 $(eval $(call Package/$(PKG_NAME)/Module,png,PNG,Allows playback of video using PNG files.,))
 $(eval $(call Package/$(PKG_NAME)/Module,pocketsphinx,Pocketsphinx,This module allows speech recognition. You might want to install\n$(PKG_NAME)-misc-grammar as well.,))
 $(eval $(call Package/$(PKG_NAME)/Module,posix_timer,POSIX timer,Add POSIX timer support.,))
index 4e73092923e8595ab58e0115d517f34b8d3d744d..ce9aaa02285fbb835746ddf630127f05b4be5439 100644 (file)
    AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no])
      if test "$PKG_CONFIG" = "no" \
         || test x"$enable_core_pgsql_pkgconfig" = x"no" \
+@@ -1555,13 +1531,7 @@ AC_CHECK_PROG(PERL,perl,[ac_cv_have_perl
+ # -a "x$ac_cv_have_EXTERN_h" != "xno"
+ if test "x$ac_cv_have_perl" != "xno"; then
+-   PERL=perl
+-   PERL_SITEDIR="`$PERL -MConfig -e 'print $Config{archlib}'`"
+-   PERL_LIBDIR="-L`$PERL -MConfig -e 'print $Config{archlib}'`/CORE"
+-   PERL_LIBS="`$PERL -MConfig -e 'print $Config{libs}'`"
+-   PERL_CFLAGS="-w -DMULTIPLICITY `$PERL -MExtUtils::Embed -e ccopts | sed -e 's|-arch x86_64 -arch i386||'` -DEMBED_PERL"
+-   PERL_LDFLAGS="`$PERL -MExtUtils::Embed -e ldopts| sed -e 's|-arch x86_64 -arch i386||'`"
+-   PERL_INC="`$PERL -MExtUtils::Embed -e perl_inc`"
++   PERL_CFLAGS="-w -DMULTIPLICITY ${PERL_CFLAGS} -DEMBED_PERL"
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$PERL_CFLAGS"
diff --git a/net/freeswitch-stable/patches/180-mod_perl.patch b/net/freeswitch-stable/patches/180-mod_perl.patch
new file mode 100644 (file)
index 0000000..cc036ea
--- /dev/null
@@ -0,0 +1,37 @@
+--- a/src/mod/languages/mod_perl/Makefile.am
++++ b/src/mod/languages/mod_perl/Makefile.am
+@@ -1,8 +1,5 @@
+ include $(top_srcdir)/build/modmake.rulesam
+ MODNAME=mod_perl
+-PERL        = perl
+-PERL_LIBDIR =-L`perl -MConfig -e 'print $$Config{archlib}'`/CORE
+-PERL_LIBS   =`perl -MConfig -e 'print $$Config{libs}'`
+ perldir=$(prefix)/perl
+ mod_LTLIBRARIES = mod_perl.la
+@@ -10,13 +7,13 @@ perl_LTLIBRARIES = freeswitch.la
+ mod_perl_la_SOURCES  = mod_perl.c freeswitch_perl.cpp mod_perl_wrap.cpp perlxsi.c
+ mod_perl_la_CFLAGS   = $(SWITCH_AM_CFLAGS)
+ mod_perl_la_CXXFLAGS = $(SWITCH_AM_CXXFLAGS)
+-mod_perl_la_CPPFLAGS = -w -DMULTIPLICITY `$(PERL) -MExtUtils::Embed -e ccopts` -DEMBED_PERL -I$(switch_srcdir)/libs/libteletone/src/ 
++mod_perl_la_CPPFLAGS = @PERL_CFLAGS@ -I$(switch_srcdir)/libs/libteletone/src/
+ mod_perl_la_LIBADD   = $(switch_builddir)/libfreeswitch.la
+-mod_perl_la_LDFLAGS  = -avoid-version -module -no-undefined -shared `$(PERL) -MExtUtils::Embed -e ldopts` `$(PERL) -MConfig -e 'print $$Config{libs}'`
++mod_perl_la_LDFLAGS  = -avoid-version -module -no-undefined -shared @PERL_LDFLAGS@ @PERL_LIBS@
+ freeswitch_la_SOURCES = freeswitch_perl.cpp mod_perl_wrap.cpp perlxsi.c
+ freeswitch_la_LDFLAGS = -avoid-version -module -no-undefined -shared $(LDFLAGS)
+-freeswitch_la_CPPFLAGS = $(SWITCH_AM_CPPFLAGS) -w -DMULTIPLICITY `$(PERL) -MExtUtils::Embed -e ccopts` -DEMBED_PERL -I$(switch_srcdir)/libs/libteletone/src/ 
++freeswitch_la_CPPFLAGS = $(SWITCH_AM_CPPFLAGS) @PERL_CFLAGS@ -I$(switch_srcdir)/libs/libteletone/src/
+ reswig:       swigclean mod_perl_wrap.cpp
+ swigclean: clean
+@@ -31,7 +28,7 @@ orig: mod_perl_wrap.cpp
+       patch -R -s -p0 -i hack.diff
+ .perlok:
+-      @(${PERL} -V | grep -i usemultiplicity=define >/dev/null && echo Phew, You have the right perl.) \
++      @(@PERL@ -V | grep -i usemultiplicity=define >/dev/null && echo Phew, You have the right perl.) \
+       || ((echo Sorry, you need to compile perl with threads and multiplicity.&& exit 1))
+       @touch .perlok
diff --git a/net/freeswitch-stable/patches/200-mod_verto-fix-copts.patch b/net/freeswitch-stable/patches/200-mod_verto-fix-copts.patch
new file mode 100644 (file)
index 0000000..bb8f48d
--- /dev/null
@@ -0,0 +1,13 @@
+--- a/src/mod/endpoints/mod_verto/Makefile.am
++++ b/src/mod/endpoints/mod_verto/Makefile.am
+@@ -12,8 +12,8 @@ if HAVE_PERL
+ #perldir = $(PERL_SITEDIR)
+ noinst_LTLIBRARIES = MCAST.la
+ MCAST_la_SOURCES   = mcast/mcast_wrap.cpp mcast/perlxsi.c mcast/mcast.c mcast/mcast_cpp.cpp
+-MCAST_la_CFLAGS    = $(CC_CFLAGS) $(CFLAGS) $(SWITCH_AM_CFLAGS) $(PERL_CFLAGS)
+-MCAST_la_CXXFLAGS  = $(SWITCH_AM_CXXFLAGS) $(CXXFLAGS) -w $(PERL_INC)
++MCAST_la_CFLAGS    = $(CC_CFLAGS) $(SWITCH_AM_CFLAGS) $(PERL_CFLAGS)
++MCAST_la_CXXFLAGS  = $(SWITCH_AM_CXXFLAGS) -w $(PERL_INC)
+ MCAST_la_CPPFLAGS  = -I$(switch_srcdir)/src/mod/endpoints/mod_verto/mcast
+ MCAST_la_LDFLAGS   = -avoid-version -module -no-undefined -shared $(PERL_LDFLAGS)
diff --git a/net/freeswitch-stable/patches/210-esl-perl-fix-copts.patch b/net/freeswitch-stable/patches/210-esl-perl-fix-copts.patch
new file mode 100644 (file)
index 0000000..d9f71d8
--- /dev/null
@@ -0,0 +1,13 @@
+--- a/libs/esl/perl/Makefile.am
++++ b/libs/esl/perl/Makefile.am
+@@ -2,8 +2,8 @@ if HAVE_PERL
+ perldir = $(PERL_SITEDIR)
+ perl_LTLIBRARIES = ESL.la
+ ESL_la_SOURCES   = esl_wrap.cpp perlxsi.c
+-ESL_la_CFLAGS    = $(CC_CFLAGS) $(CFLAGS) -I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS) $(PERL_CFLAGS)
+-ESL_la_CXXFLAGS  = -I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS) $(CXXFLAGS) -w $(PERL_INC)
++ESL_la_CFLAGS    = $(CC_CFLAGS) -I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS) $(PERL_CFLAGS)
++ESL_la_CXXFLAGS  = -I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS) -w $(PERL_INC)
+ ESL_la_LDFLAGS   = -avoid-version -module -no-undefined -shared $(PERL_LDFLAGS)
+ ESL_la_LIBADD    = ../libesl.la