From 652d110b2f7ab2ce50e612186ff220f8b2a7b8e0 Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 30 Oct 2021 23:08:00 +0200 Subject: [PATCH] freeswitch: add python3 support Signed-off-by: Sebastian Kemper --- net/freeswitch/Makefile | 57 +++++++++++++++++++ .../460-remove-python-configure-checks.patch | 27 +++++++++ net/freeswitch/patches/470-esl-python.patch | 43 ++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 net/freeswitch/patches/460-remove-python-configure-checks.patch create mode 100644 net/freeswitch/patches/470-esl-python.patch diff --git a/net/freeswitch/Makefile b/net/freeswitch/Makefile index 50c37e6..84fe116 100644 --- a/net/freeswitch/Makefile +++ b/net/freeswitch/Makefile @@ -151,6 +151,7 @@ FS_MOD_AVAILABLE:= \ portaudio_stream \ posix_timer \ prefix \ + python3 \ radius_cdr \ random \ raven \ @@ -224,6 +225,7 @@ PKG_CONFIG_DEPENDS:= \ CONFIG_FS_WITH_ZRTP \ CONFIG_LIBC \ CONFIG_PACKAGE_freeswitch-misc-perl-esl \ + CONFIG_PACKAGE_freeswitch-misc-python3-esl \ CONFIG_SOFT_FLOAT include $(INCLUDE_DIR)/package.mk @@ -232,6 +234,7 @@ include $(INCLUDE_DIR)/nls.mk FS_PERL_FEED:=$(TOPDIR)/feeds/packages/lang/perl +include $(TOPDIR)/feeds/packages/lang/python/python3-host.mk include $(FS_PERL_FEED)/perlver.mk PERL_SITELIB:=/usr/lib/perl$(PERL_MAJOR)/$(PERL_VERSION2) @@ -240,6 +243,8 @@ FS_PERL_LIBS:=$(shell grep "^libs=" \ $(FS_PERL_FEED)/files/base.config | \ sed "s/^libs=//;s/'//g") +FS_PYTHON3_SITE_DIR:=$(FS_LIB_DIR)/python$(PYTHON3_VERSION)/site-packages + define Download/files define Download/$(1) FILE:=$(2) @@ -412,6 +417,27 @@ define Package/freeswitch-misc-perl-esl/install $(1)$(PERL_SITELIB)/ESL endef +define Package/freeswitch-misc-python3-esl +$(call Package/freeswitch/Default) + TITLE:=Python3 ESL + DEPENDS:=freeswitch +PACKAGE_freeswitch-misc-python3-esl:python3-light +endef + +define Package/freeswitch-misc-python3-esl/description +This package contains the Python3 binding for FreeSWITCH's Event Socket +Library (ESL). +endef + +define Package/freeswitch-misc-python3-esl/install + $(INSTALL_DIR) $(1)$(FS_PYTHON3_SITE_DIR) + $(INSTALL_BIN) \ + $(PKG_INSTALL_DIR)$(FS_PYTHON3_SITE_DIR)/_ESL.so \ + $(1)$(FS_PYTHON3_SITE_DIR) + $(INSTALL_DATA) \ + $(PKG_INSTALL_DIR)$(FS_PYTHON3_SITE_DIR)/ESL.py \ + $(1)$(FS_PYTHON3_SITE_DIR) +endef + define Package/freeswitch-misc-timezones $(call Package/freeswitch/Default) TITLE:=Timezones file @@ -509,6 +535,12 @@ ifeq ($(1),perl) $(PKG_INSTALL_DIR)/usr/perl/freeswitch.pm \ $$(1)$(PERL_SITELIB) endif +ifeq ($(1),python3) + $(INSTALL_DIR) $$(1)$(FS_PYTHON3_SITE_DIR) + $(INSTALL_DATA) \ + $(PKG_INSTALL_DIR)$(FS_PYTHON3_SITE_DIR)/freeswitch.py \ + $$(1)$(FS_PYTHON3_SITE_DIR) +endif endef $$(eval $$(call BuildPackage,freeswitch-mod-$(subst _,-,$(1)))) endef @@ -556,6 +588,14 @@ CONFIGURE_ARGS+= \ $(if $(CONFIG_FS_WITH_ODBC),--with-odbc="$(STAGING_DIR)/usr") \ $(if $(CONFIG_FS_WITH_PNG),,--without-png) +ifneq ($(CONFIG_PACKAGE_freeswitch-misc-python3-esl)$(CONFIG_PACKAGE_freeswitch-mod-python3),) +CONFIGURE_ARGS+= \ + --with-python3=$(STAGING_DIR_HOST)/bin/python3 +else +CONFIGURE_ARGS+= \ + --with-python3=no +endif + ifeq ($(CONFIG_PACKAGE_freeswitch-mod-erlang-event)$(CONFIG_PACKAGE_freeswitch-mod-kazoo),) CONFIGURE_ARGS+= \ --with-erlang=no @@ -627,6 +667,15 @@ CONFIGURE_VARS+= \ ac_cv_prog_PERL=false endif +ifneq ($(CONFIG_PACKAGE_freeswitch-misc-python3-esl)$(CONFIG_PACKAGE_freeswitch-mod-python3),) +CONFIGURE_VARS+= \ + PYTHON3_CFLAGS="-I$(STAGING_DIR)/usr/include/python$(PYTHON3_VERSION)" \ + PYTHON3_LDFLAGS="-lpython$(PYTHON3_VERSION)" \ + PYTHON3_LIB="python$(PYTHON3_VERSION)" \ + PYTHON3_LIBDIR="$(FS_LIB_DIR)" \ + PYTHON3_SITE_DIR="$(FS_PYTHON3_SITE_DIR)" +endif + # mod_radius_cdr runs configure in libs/freeradius-client. Let # freeradius-client know /dev/urandom is available on target devices. MAKE_VARS+= \ @@ -753,6 +802,9 @@ endif ifneq ($(CONFIG_PACKAGE_freeswitch-misc-perl-esl),) $(call Build/Compile/Default,-C $(PKG_BUILD_DIR)/libs/esl perlmod) endif +ifneq ($(CONFIG_PACKAGE_freeswitch-misc-python3-esl),) + $(call Build/Compile/Default,-C $(PKG_BUILD_DIR)/libs/esl py3mod) +endif endef define Build/Install @@ -760,6 +812,9 @@ define Build/Install ifneq ($(CONFIG_PACKAGE_freeswitch-misc-perl-esl),) $(call Build/Compile/Default,-C $(PKG_BUILD_DIR)/libs/esl DESTDIR=$(PKG_INSTALL_DIR) perlmod-install) endif +ifneq ($(CONFIG_PACKAGE_freeswitch-misc-python3-esl),) + $(call Build/Install/Default,-C $(PKG_BUILD_DIR)/libs/esl py3mod-install) +endif endef define Build/InstallDev @@ -776,6 +831,7 @@ endef $(eval $(call BuildPackage,freeswitch)) $(eval $(call BuildPackage,freeswitch-misc-perl-esl)) +$(eval $(call BuildPackage,freeswitch-misc-python3-esl)) $(eval $(call BuildPackage,freeswitch-misc-timezones)) ################################ @@ -914,6 +970,7 @@ $(eval $(call Package/freeswitch/Module,portaudio,Portaudio,Voice through a loca $(eval $(call Package/freeswitch/Module,portaudio_stream,Portaudio streaming,Stream from an external audio source for Music on Hold.,+portaudio)) $(eval $(call Package/freeswitch/Module,posix_timer,POSIX timer,Add POSIX timer support.,)) $(eval $(call Package/freeswitch/Module,prefix,Prefix match,This module provides a data store with fast lookups by the longest\nprefix match rule.,)) +$(eval $(call Package/freeswitch/Module,python3,Python3,Python3 support module.,+python3-light)) $(eval $(call Package/freeswitch/Module,radius_cdr,Radius CDR,Radius Call Detail Record handler.,)) $(eval $(call Package/freeswitch/Module,random,Entropy,This module extracts entropy from FreeSWITCH and feeds it into\n/dev/random.,)) $(eval $(call Package/freeswitch/Module,raven,Raven logging,Adds support for logging to Raven instances.,)) diff --git a/net/freeswitch/patches/460-remove-python-configure-checks.patch b/net/freeswitch/patches/460-remove-python-configure-checks.patch new file mode 100644 index 0000000..ccbedda --- /dev/null +++ b/net/freeswitch/patches/460-remove-python-configure-checks.patch @@ -0,0 +1,27 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -1865,24 +1865,12 @@ then + if test "$python3_has_distutils" != "no" ; then + AC_MSG_CHECKING([location of python3 site-packages]) + +- PYTHON3_SITE_DIR="`$PYTHON3 -c 'from distutils import sysconfig; print(sysconfig.get_python_lib(0));'`" +- + if test -z "$PYTHON3_SITE_DIR" ; then + AC_MSG_ERROR([Unable to detect python3 site-packages path]) +- elif test ! -d "$PYTHON3_SITE_DIR" ; then +- AC_MSG_ERROR([Path $PYTHON3_SITE_DIR returned by python3 does not exist!]) + fi + AC_MSG_RESULT([$PYTHON3_SITE_DIR]) + AC_SUBST([PYTHON3_SITE_DIR], [$PYTHON3_SITE_DIR]) + +- # +- # python3 distutils found, get settings from python3 directly +- # +- PYTHON3_CFLAGS="`$PYTHON3 -c 'from distutils import sysconfig; flags = [[\"-I\" + sysconfig.get_python_inc(0), \"-I\" + sysconfig.get_python_inc(1), \" \".join(sysconfig.get_config_var(\"CFLAGS\").split())]]; print(\" \".join(flags));' | sed -e 's/-arch i386//g;s/-arch x86_64//g'`" +- PYTHON3_LDFLAGS="`$PYTHON3 -c 'from distutils import sysconfig; ldver = sysconfig.get_config_var(\"LDVERSION\"); libs = sysconfig.get_config_var(\"LIBS\").split() + sysconfig.get_config_var(\"SYSLIBS\").split(); libs.append(\"-lpython\" + [[ldver,sysconfig.get_config_var(\"VERSION\")]][[ldver==None]]); print(\" \".join(libs));'`" +- PYTHON3_LIB="`$PYTHON3 -c 'from distutils import sysconfig; ldver = sysconfig.get_config_var(\"LDVERSION\"); print(\"python\" + [[ldver,sysconfig.get_config_var(\"VERSION\")]][[ldver==None]]);'`" +- PYTHON3_LIBDIR="`$PYTHON3 -c 'from distutils import sysconfig; print(sysconfig.get_config_var(\"LIBDIR\"));'`" +- + # handle python3 being installed into /usr/local + AC_MSG_CHECKING([python3 libdir]) + if test -z "`echo $PYTHON3_LIBDIR | grep "/usr/lib"`" ; then diff --git a/net/freeswitch/patches/470-esl-python.patch b/net/freeswitch/patches/470-esl-python.patch new file mode 100644 index 0000000..a02dc09 --- /dev/null +++ b/net/freeswitch/patches/470-esl-python.patch @@ -0,0 +1,43 @@ +--- a/libs/esl/Makefile.am ++++ b/libs/esl/Makefile.am +@@ -82,7 +82,7 @@ pymod: $(MYLIB) + $(MAKE) PYTHON=$(PYTHON) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python + + py3mod: $(MYLIB) +- $(MAKE) PYTHON3=$(PYTHON3) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python3 ++ $(MAKE) PYTHON3=$(PYTHON3) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" PYTHON3_CFLAGS="$(PYTHON3_CFLAGS)" PYTHON3_LDFLAGS="$(PYTHON3_LDFLAGS)" -C python3 + + tclmod: $(MYLIB) + $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C tcl +@@ -106,7 +106,7 @@ pymod-install: pymod + $(MAKE) PYTHON=$(PYTHON) -C python install + + py3mod-install: py3mod +- $(MAKE) PYTHON3=$(PYTHON3) -C python3 install ++ $(MAKE) PYTHON3=$(PYTHON3) PYTHON3_SITE_DIR="$(PYTHON3_SITE_DIR)" -C python3 install + + rubymod-install: rubymod + $(MAKE) -C ruby install +--- a/libs/esl/python3/Makefile ++++ b/libs/esl/python3/Makefile +@@ -1,6 +1,4 @@ +-LOCAL_CFLAGS=`$(PYTHON3) ./python-config --includes` +-LOCAL_LDFLAGS=`$(PYTHON3) ./python-config --ldflags` +-SITE_DIR=$(DESTDIR)/`$(PYTHON3) -c "from distutils.sysconfig import get_python_lib; print (get_python_lib(1))"` ++SITE_DIR=$(DESTDIR)/$(PYTHON3_SITE_DIR) + + all: _ESL.so + +@@ -8,10 +6,10 @@ esl_wrap.cpp: + swig3.0 -module ESL -classic -python -c++ -DMULTIPLICITY -threads -I../src/include -o esl_wrap.cpp ../ESL.i + + esl_wrap.o: esl_wrap.cpp +- $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o ++ $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(PYTHON3_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o + + _ESL.so: esl_wrap.o +- $(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(LOCAL_LDFLAGS) -o _ESL.so -L. $(LIBS) ++ $(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(PYTHON3_LDFLAGS) -o _ESL.so -L. $(LIBS) + + install: _ESL.so + mkdir -p $(SITE_DIR) -- 2.30.2