diff --git a/configure b/configure index 86ffdea882..294d2bb0f5 100755 --- a/configure +++ b/configure @@ -659,6 +659,7 @@ PBX_SSL_OP_NO_TLSV1_2 PBX_SSL_OP_NO_TLSV1_1 PORTAUDIO_LIBS PORTAUDIO_CFLAGS +SWIG PYTHONDEV_LIBS PYTHONDEV_CFLAGS PYTHONDEV_INCLUDE @@ -6820,8 +6821,10 @@ $as_echo "no" >&6; } fi -# Extract the first word of "python", so it can be a program name with args. -set dummy python; ac_word=$2 +for ac_prog in python python3 python2 python3.6 python3.5 python3.4 python2.7 python2.6 +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PYTHON+:} false; then : @@ -6847,7 +6850,6 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_PYTHON" && ac_cv_path_PYTHON=":" ;; esac fi @@ -6861,6 +6863,11 @@ $as_echo "no" >&6; } fi + test -n "$PYTHON" && break +done +test -n "$PYTHON" || PYTHON=":" + + # Extract the first word of "find", so it can be a program name with args. set dummy find; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -25984,6 +25991,8 @@ fi fi fi +# PYTHONDEV can only be used if dev-mode is enabled. +if test "$AST_DEVMODE" = "yes"; then @@ -25997,12 +26006,12 @@ if test -n "$PYTHONDEV_CFLAGS"; then pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python\""; } >&5 - ($PKG_CONFIG --exists --print-errors "python") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python2\""; } >&5 + ($PKG_CONFIG --exists --print-errors "python2") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python" 2>/dev/null` + pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python2" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -26014,12 +26023,12 @@ if test -n "$PYTHONDEV_LIBS"; then pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python\""; } >&5 - ($PKG_CONFIG --exists --print-errors "python") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python2\""; } >&5 + ($PKG_CONFIG --exists --print-errors "python2") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python" 2>/dev/null` + pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python2" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -26040,9 +26049,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python" 2>&1` + PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python2" 2>&1` else - PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python" 2>&1` + PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$PYTHONDEV_PKG_ERRORS" >&5 @@ -26075,6 +26084,98 @@ fi fi + if test "x${PBX_PYTHONDEV}" != "x1" -a "${USE_PYTHONDEV}" != "no"; then + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PYTHONDEV" >&5 +$as_echo_n "checking for PYTHONDEV... " >&6; } + +if test -n "$PYTHONDEV_CFLAGS"; then + pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python < 3\""; } >&5 + ($PKG_CONFIG --exists --print-errors "python < 3") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python < 3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PYTHONDEV_LIBS"; then + pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python < 3\""; } >&5 + ($PKG_CONFIG --exists --print-errors "python < 3") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python < 3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python < 3" 2>&1` + else + PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python < 3" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PYTHONDEV_PKG_ERRORS" >&5 + + + PBX_PYTHONDEV=0 + + +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + + PBX_PYTHONDEV=0 + + +else + PYTHONDEV_CFLAGS=$pkg_cv_PYTHONDEV_CFLAGS + PYTHONDEV_LIBS=$pkg_cv_PYTHONDEV_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + PBX_PYTHONDEV=1 + PYTHONDEV_INCLUDE="$PYTHONDEV_CFLAGS" + PYTHONDEV_LIB="$PYTHONDEV_LIBS" + +$as_echo "#define HAVE_PYTHONDEV 1" >>confdefs.h + + +fi + fi + + + SWIG=: + +fi + if test "x${PBX_POPT}" != "x1" -a "${USE_POPT}" != "no"; then pbxlibdir="" diff --git a/configure.ac b/configure.ac index e2af234931..c28c7b4ec6 100644 --- a/configure.ac +++ b/configure.ac @@ -261,7 +261,8 @@ AC_PATH_PROG([CAT], [cat], :) AC_PATH_PROG([CUT], [cut], :) AC_PATH_PROG([FLEX], [flex], :) AC_PATH_PROG([GREP], [grep], :) -AC_PATH_PROG([PYTHON], [python], :) +AC_PATH_PROGS([PYTHON], [python python3 python2 python3.6 python3.5 python3.4 python2.7 python2.6], :) + AC_PATH_PROG([FIND], [find], :) AC_PATH_PROG([COMPRESS], [compress], :) AC_PATH_PROG([BASENAME], [basename], :) @@ -2307,9 +2308,23 @@ if test "$USE_PJPROJECT" != "no" ; then fi fi -AC_SUBST([PYTHONDEV_LIB]) -AC_SUBST([PYTHONDEV_INCLUDE]) -AST_PKG_CONFIG_CHECK([PYTHONDEV], [python]) +# PYTHONDEV can only be used if dev-mode is enabled. +if test "$AST_DEVMODE" = "yes"; then + AC_SUBST([PYTHONDEV_LIB]) + AC_SUBST([PYTHONDEV_INCLUDE]) + AST_PKG_CONFIG_CHECK([PYTHONDEV], [python2]) + AST_PKG_CONFIG_CHECK([PYTHONDEV], [python < 3]) + +dnl Mark SWIG as missing for the Makefile + AC_SUBST([SWIG],:) +dnl This will be uncommented once we need pjsua2 for the testsuite. +dnl AC_PATH_PROG([SWIG], [swig], :) +dnl +dnl AC_SUBST([PYTHON3DEV_LIB]) +dnl AC_SUBST([PYTHON3DEV_INCLUDE]) +dnl AST_PKG_CONFIG_CHECK([PYTHON3DEV], [python3]) +dnl AST_PKG_CONFIG_CHECK([PYTHON3DEV], [python >= 3]) +fi AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h]) diff --git a/makeopts.in b/makeopts.in index 4d3cc5db63..8706685f3c 100644 --- a/makeopts.in +++ b/makeopts.in @@ -50,6 +50,7 @@ SED=@SED@ NM=@NM@ CAT=@CAT@ CUT=@CUT@ +SWIG=@SWIG@ BUILD_PLATFORM=@BUILD_PLATFORM@ BUILD_CPU=@BUILD_CPU@ @@ -262,6 +263,9 @@ PRI_LIB=@PRI_LIB@ PYTHONDEV_INCLUDE=@PYTHONDEV_INCLUDE@ PYTHONDEV_LIB=@PYTHONDEV_LIB@ +PYTHON3DEV_INCLUDE=@PYTHON3DEV_INCLUDE@ +PYTHON3DEV_LIB=@PYTHON3DEV_LIB@ + RESAMPLE_INCLUDE=@RESAMPLE_INCLUDE@ RESAMPLE_LIB=@RESAMPLE_LIB@ diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile index b95b33221b..7acb146524 100644 --- a/third-party/pjproject/Makefile +++ b/third-party/pjproject/Makefile @@ -59,6 +59,14 @@ ifeq ($(SPECIAL_TARGETS),) TARGETS += $(apps) ifneq ($(PYTHONDEV_LIB),) TARGETS += source/pjsip-apps/src/python/_pjsua.so + ifneq ($(SWIG),:) + TARGETS += source/pjsip-apps/src/swig/python/py2/_pjsua2.so + endif + endif + ifneq ($(PYTHON3DEV_LIB),) + ifneq ($(SWIG),:) + TARGETS += source/pjsip-apps/src/swig/python/py3/_pjsua2.so + endif endif endif ifeq ($(AST_DEVMODE),yes) @@ -177,6 +185,8 @@ PJLIB_UTIL_LIB_FILES = $(foreach lib,$(PJ_LIB_FILES),$(if $(findstring libpjlib- PJSIP_LIB_FILES = $(filter-out $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES) $(APP_THIRD_PARTY_LIB_FILES),$(PJ_LIB_FILES)) ALL_LIB_FILES = $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES) $(PJSIP_LIB_FILES) +PJSUA2_LIB_FILES = $(foreach lib,$(PJ_LIBXX_FILES),$(if $(findstring libpjsua2-,$(lib)),$(lib),)) + $(PJLIB_UTIL_LIB_FILES): $(PJLIB_LIB_FILES) $(PJSIP_LIB_FILES): $(PJLIB_UTIL_LIB_FILES) @@ -202,6 +212,32 @@ $(apps): $(MALLOC_DEBUG_LIBS) pjproject.symbols $(APP_THIRD_PARTY_LIB_FILES) $(ECHO_PREFIX) Compiling $(APP) $(CMD_PREFIX) +$(MAKE) -C source/pjsip-apps/build $(filter pj%,$(subst -, ,$(notdir $@))) $(REALLY_QUIET) +source/pjsip-apps/src/swig/python/_pjsua2.cpp: source/pjsip-apps/src/swig/pjsua2.i + $(ECHO_PREFIX) Generating pjsua2 python binding sources + $(CMD_PREFIX) swig -Isource/pjsip/include -c++ -w312 -python -o source/pjsip-apps/src/swig/python/_pjsua2.cpp source/pjsip-apps/src/swig/pjsua2.i $(REALLY_QUIET) + +source/pjsip-apps/src/swig/python/py2/_pjsua2.o: source/pjsip-apps/src/swig/python/_pjsua2.cpp $(app) $(PJSUA2_LIB_FILES) + $(ECHO_PREFIX) Compiling pjsua2 python2 bindings + $(CMD_PREFIX) mkdir -p source/pjsip-apps/src/swig/python/py2 + $(CMD_PREFIX) $(CC) -Wno-deprecated -o $@ -c $< $(PYTHONDEV_INCLUDE) $(CFLAGS) $(PJ_CFLAGS) + +source/pjsip-apps/src/swig/python/py2/_pjsua2.so: LDFLAGS += $(MALLOC_DEBUG_LDFLAGS) +source/pjsip-apps/src/swig/python/py2/_pjsua2.so: source/pjsip-apps/src/swig/python/py2/_pjsua2.o + $(ECHO_PREFIX) Linking pjsua2 python2 bindings $(@F) + $(CMD_PREFIX) gcc -shared -pthread -o $@ $< $(LDFLAGS) $(PJ_LDXXFLAGS) $(APP_LDXXLIBS) $(PYTHONDEV_LIB) $(REALLY_QUIET) + + +source/pjsip-apps/src/swig/python/py3/_pjsua2.o: source/pjsip-apps/src/swig/python/_pjsua2.cpp $(app) $(PJSUA2_LIB_FILES) + $(ECHO_PREFIX) Compiling pjsua2 python3 bindings + $(CMD_PREFIX) mkdir -p source/pjsip-apps/src/swig/python/py3 + $(CMD_PREFIX) $(CC) -Wno-deprecated -o $@ -c $< $(PYTHON3DEV_INCLUDE) $(CFLAGS) $(PJ_CFLAGS) + +source/pjsip-apps/src/swig/python/py3/_pjsua2.so: LDFLAGS += $(MALLOC_DEBUG_LDFLAGS) +source/pjsip-apps/src/swig/python/py3/_pjsua2.so: source/pjsip-apps/src/swig/python/py3/_pjsua2.o + $(ECHO_PREFIX) Linking pjsua2 python3 bindings $(@F) + $(CMD_PREFIX) gcc -shared -pthread -o $@ $< $(LDFLAGS) $(PJ_LDXXFLAGS) $(APP_LDXXLIBS) $(PYTHON3DEV_LIB) $(REALLY_QUIET) + + source/pjsip-apps/src/python/_pjsua.o: source/pjsip-apps/src/python/_pjsua.c $(apps) $(ECHO_PREFIX) Compiling python bindings $(CMD_PREFIX) $(CC) -o $@ -c $< $(PYTHONDEV_INCLUDE) $(CFLAGS) $(PJ_CFLAGS) @@ -220,10 +256,28 @@ ifneq ($(findstring source/pjsip-apps/bin/pjsua-$(TARGET_NAME),$(TARGETS)),) $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/bin/pjsua-$(TARGET_NAME) "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/pjsua" $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/bin/pjsystest-$(TARGET_NAME) "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/pjsystest" endif +ifneq ($(findstring _pjsua.so,$(TARGETS))$(findstring py2/_pjsua2.so,$(TARGETS)),) + @if [ ! -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/py2" ]; then \ + $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/py2"; \ + fi; +endif ifneq ($(findstring _pjsua.so,$(TARGETS)),) - $(ECHO_PREFIX) Installing python bindings - $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/src/python/_pjsua.so "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/" - $(CMD_PREFIX) $(INSTALL) -m 644 source/pjsip-apps/src/python/pjsua.py "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/" + $(ECHO_PREFIX) Installing pjsua python bindings + $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/src/python/_pjsua.so "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/py2" + $(CMD_PREFIX) $(INSTALL) -m 644 source/pjsip-apps/src/python/pjsua.py "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/py2" +endif +ifneq ($(findstring py2/_pjsua2.so,$(TARGETS)),) + $(ECHO_PREFIX) Installing pjsua2 python2 bindings + $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/src/swig/python/py2/_pjsua2.so "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/py2" + $(CMD_PREFIX) $(INSTALL) -m 644 source/pjsip-apps/src/swig/python/pjsua2.py "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/py2" +endif +ifneq ($(findstring py3/_pjsua2.so,$(TARGETS)),) + @if [ ! -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/py3" ]; then \ + $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/py3"; \ + fi; + $(ECHO_PREFIX) Installing pjsua2 python3 bindings + $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/src/swig/python/py3/_pjsua2.so "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/py3" + $(CMD_PREFIX) $(INSTALL) -m 644 source/pjsip-apps/src/swig/python/pjsua2.py "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/py3" endif uninstall: