pjproject_bundled: Various fixes discovered during testing of OSes
authorGeorge Joseph <gjoseph@digium.com>
Sat, 30 Apr 2016 22:52:47 +0000 (16:52 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Tue, 3 May 2016 12:56:18 +0000 (07:56 -0500)
For all OSes:
* Disabled third-party codecs in pjproject and added
  '--disable-speex-codec --disable-speex-aec --disable-gsm-codec' to the
  configure options since we don't use the pjsip codec capability.

FreeBSD:
* Added FreeBSD support to install_prereq.
* Changed pjproject/configure.m4 to use $GNU_MAKE instead of hardcoding "make".
* Added __progname and environ to asterisk.exports.in.
* Reverted the use of ldconfig to create shared library symlinks to ln.
* Only enable epoll in pjproject if `uname -s` is Linux.
* Added a patch to pjproject to take the name of the 'make' command from
  an environment variable if supplied.  This is needed for the python bindings.
  (merged by Teluu into pjproject trunk 5/3/2016)
FreeBSD support isn't complete.  Still some general issues regarding
make/gmake having nothing to do with pjproject.  With some handholding it DOES
build successfully.

CentOS:
Added 'patch' and 'bzip2' to install_prereq PACKAGES_RH.
CentOS 6/7 32/64 build and run the pjsip testsuite successfully.

Ubuntu:
No changes required.
Ubuntu 15/16 32/64 build and run the pjsip testsuite successfully.

Debian:
No changes required.
Debian 6/7/8 32/64 build and run the pjsip testsuite successfully.

There will utimately be a follow-up patch to create an install_prereq for
the testsuite as I've discovered a few missing requirements.

ASTERISK-25968 #close

Change-Id: I5756a07facfc63798115a5e73a8709382fe9259c

configure
contrib/scripts/install_prereq
main/Makefile
main/asterisk.exports.in
third-party/pjproject/Makefile
third-party/pjproject/Makefile.rules
third-party/pjproject/apply_patches
third-party/pjproject/configure.m4
third-party/pjproject/patches/0001-pjsip-apps-src-python-setup.py-Take-make-from-the-en.patch [new file with mode: 0644]

index 579678b..171693a 100755 (executable)
--- a/configure
+++ b/configure
@@ -24493,16 +24493,16 @@ if test "$USE_PJPROJECT" != "no" ; then
 $as_echo_n "checking for embedded pjproject (may have to download)... " >&6; }
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: configuring" >&5
 $as_echo "configuring" >&6; }
-       make --quiet --no-print-directory -C $PJPROJECT_DIR configure
+       ${GNU_MAKE} --quiet --no-print-directory -C $PJPROJECT_DIR configure
        if test $? -ne 0 ; then
                { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
 $as_echo "failed" >&6; }
                { $as_echo "$as_me:${as_lineno-$LINENO}: Unable to configure $PJPROJECT_DIR" >&5
 $as_echo "$as_me: Unable to configure $PJPROJECT_DIR" >&6;}
-               as_fn_error $? "Run \"make -C $PJPROJECT_DIR NOISY_BUILD=yes configure\" to see error details." "$LINENO" 5
+               as_fn_error $? "Run \"${GNU_MAKE} -C $PJPROJECT_DIR NOISY_BUILD=yes configure\" to see error details." "$LINENO" 5
        fi
 
-       PJPROJECT_INCLUDE=$(make --quiet --no-print-directory -C $PJPROJECT_DIR echo_cflags)
+       PJPROJECT_INCLUDE=$(${GNU_MAKE} --quiet --no-print-directory -C $PJPROJECT_DIR echo_cflags)
        PJPROJECT_CFLAGS="$PJPROJECT_INCLUDE"
        PBX_PJPROJECT=1
        PJPROJECT_BUNDLED=yes
index 1682558..bda28e9 100755 (executable)
@@ -29,13 +29,15 @@ PACKAGES_DEBIAN="$PACKAGES_DEBIAN libopenh323-dev libvpb-dev libgtk2.0-dev libmy
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev libcorosync-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev libjack-dev"
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample-dev libc-client-dev binutils-dev libsrtp-dev libgsm1-dev libedit-dev doxygen libjansson-dev libldap-dev"
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN subversion git libxslt1-dev automake libsrtp-dev libncurses5-dev python-dev"
-PACKAGES_RH="automake gcc gcc-c++ ncurses-devel openssl-devel libxml2-devel unixODBC-devel libcurl-devel libogg-devel libvorbis-devel speex-devel"
+PACKAGES_RH="automake bzip2 gcc gcc-c++ patch ncurses-devel openssl-devel libxml2-devel unixODBC-devel libcurl-devel libogg-devel libvorbis-devel speex-devel"
 PACKAGES_RH="$PACKAGES_RH spandsp-devel freetds-devel net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libtool-ltdl-devel lua-devel"
 PACKAGES_RH="$PACKAGES_RH sqlite-devel libsqlite3x-devel radiusclient-ng-devel portaudio-devel postgresql-devel libresample-devel neon-devel libical-devel"
 PACKAGES_RH="$PACKAGES_RH openldap-devel gmime22-devel sqlite2-devel mysql-devel bluez-libs-devel jack-audio-connection-kit-devel gsm-devel libedit-devel libuuid-devel"
 PACKAGES_RH="$PACKAGES_RH jansson-devel libsrtp-devel pjproject-devel subversion git libxslt-devel python-devel"
 
 PACKAGES_OBSD="popt gmake wget libxml libogg libvorbis curl iksemel spandsp speex iodbc freetds-0.63p1-msdblib mysql-client gmime sqlite sqlite3 jack libxslt"
+PACKAGES_FBSD="autoconf gcc binutils popt gmake wget libxml2 libogg libvorbis curl iksemel spandsp speex unixODBC freetds-devel mysql55-client gmime2 sqlite"
+PACKAGES_FBSD="$PACKAGES_FBSD sqlite3 libxslt jansson e2fsprogs-libuuid gsm libsrtp libsamplerate"
 
 KVERS=`uname -r`
 
@@ -95,23 +97,45 @@ check_installed_pkgs() {
        done
 }
 
+check_installed_fpkgs() {
+       for pack in "$@"
+       do
+               if [ `pkg info -a | grep $pack | wc -l` = 0 ]; then
+               echo $pack
+               fi
+       done
+}
+
 handle_debian() {
        if ! [ -x "$(command -v aptitude)" ]; then
                apt-get install aptitude
        fi
        extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
        $testcmd aptitude update
-       $testcmd aptitude install -y $extra_packs
+       if [ x"$extra_packs" != "x" ] ; then
+               $testcmd aptitude install -y $extra_packs
+       fi
 }
 
 handle_rh() {
        extra_packs=`check_installed_rpms $PACKAGES_RH`
-       $testcmd yum install -y $extra_packs
+       if [ x"$extra_packs" != "x" ] ; then
+               $testcmd yum install -y $extra_packs
+       fi
 }
 
 handle_obsd() {
        extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
-       $testcmd pkg_add $extra_packs
+       if [ x"$extra_packs" != "x" ] ; then
+               $testcmd pkg_add $extra_packs
+       fi
+}
+
+handle_fbsd() {
+       extra_packs=`check_installed_fpkgs $PACKAGES_FBSD`
+       if [ x"$extra_packs" != "x" ] ; then
+               $testcmd pkg install -y $extra_packs
+       fi
 }
 
 install_unpackaged() {
@@ -188,7 +212,7 @@ OS=`uname -s`
 unsupported_distro=''
 
 # A number of distributions we don't (yet?) support.
-if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' ]; then
+if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' -a "$OS" != 'FreeBSD' ]; then
        echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting."
        exit 1
 fi
@@ -221,6 +245,8 @@ elif [ -r /etc/redhat-release ]; then
        handle_rh
 elif [ "$OS" = 'OpenBSD' ]; then
        handle_obsd
+elif [ "$OS" = 'FreeBSD' ]; then
+       handle_fbsd
 fi
 
 if ! in_test_mode; then
index d52c3f0..3863978 100644 (file)
@@ -225,11 +225,7 @@ endif
 
 $(ASTSSL_LIB): $(ASTSSL_LIB).$(ASTSSL_SO_VERSION)
        $(ECHO_PREFIX) echo "   [LN] $< -> $@"
-       $(CMD_PREFIX) if [ -x "$(LDCONFIG)" ] ; then \
-               $(LDCONFIG) $(LDCONFIG_FLAGS) . 2>/dev/null ;\
-       else \
-               $(LN) -sf $< $@ ;\
-       fi
+       $(LN) -sf $< $@ ;\
 
 else # Darwin
 ASTSSL_LIB:=libasteriskssl.dylib
@@ -305,11 +301,7 @@ $(ASTPJ_LIB).$(ASTPJ_SO_VERSION): libasteriskpj.o libasteriskpj.exports
 
 $(ASTPJ_LIB): $(ASTPJ_LIB).$(ASTPJ_SO_VERSION)
        $(ECHO_PREFIX) echo "   [LN] $< -> $@"
-       $(CMD_PREFIX) if [ -x "$(LDCONFIG)" ] ; then \
-               $(LDCONFIG) $(LDCONFIG_FLAGS) . 2>/dev/null ;\
-       else \
-               $(LN) -sf $< $@ ;\
-       fi
+       $(LN) -sf $< $@ ;\
 
 else # Darwin
 ASTPJ_LIB:=libasteriskpj.dylib
index 364b3b0..f997587 100644 (file)
@@ -49,6 +49,8 @@
                LINKER_SYMBOL_PREFIXres_srtp;
                LINKER_SYMBOL_PREFIXres_srtp_policy;
                LINKER_SYMBOL_PREFIXsecure_call_info;
+               LINKER_SYMBOL_PREFIX__progname;
+               LINKER_SYMBOL_PREFIXenviron;
                /*
 
                If _IO_stdin_used is not exported, stdout/stderr may not get
index 5810a65..7fa3902 100644 (file)
@@ -115,8 +115,7 @@ source/pjsip-apps/bin/pjsua-$(TARGET_NAME): source/pjlib/lib/libpj-$(TARGET_NAME
 
 source/pjsip-apps/src/python/build/_pjsua.so: source/pjlib/lib/libpj-$(TARGET_NAME).a
        $(ECHO_PREFIX) Compiling python bindings
-       $(CMD_PREFIX) (cd source/pjsip-apps/src/python ; python setup.py build --build-platlib=./build $(REALLY_QUIET))
-
+       $(CMD_PREFIX) (cd source/pjsip-apps/src/python ; MAKE=$(MAKE) python setup.py build --build-platlib=./build $(REALLY_QUIET))
 
 _all: pjproject.symbols source/pjsip-apps/bin/pjsua-$(TARGET_NAME) source/pjsip-apps/src/python/build/_pjsua.so
 
index 062793f..6b51c2f 100644 (file)
@@ -1,7 +1,10 @@
 PJPROJECT_URL = http://www.pjsip.org/release/$(PJPROJECT_VERSION)
 
 # Even though we're not installing pjproject, we're setting prefix to /opt/pjproject to be safe
-PJPROJECT_CONFIG_OPTS = --prefix=/opt/pjproject --with-external-speex --with-external-gsm --with-external-srtp \
-       --disable-video --disable-v4l2 --disable-sound --disable-opencore-amr --disable-ilbc-codec \
-       --without-libyuv --disable-g7221-codec \
-       --enable-epoll
+PJPROJECT_CONFIG_OPTS = --prefix=/opt/pjproject --disable-speex-codec --disable-speex-aec \
+       --disable-gsm-codec --disable-video --disable-v4l2 --disable-sound --disable-opencore-amr \
+       --disable-ilbc-codec --without-libyuv --disable-g7221-codec
+
+ifeq ($(shell uname -s),Linux)
+   PJPROJECT_CONFIG_OPTS +=  --enable-epoll
+endif
index 1b72d14..5dfdd2a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 if [ "$1" = "-q" ] ; then
        quiet=1
@@ -27,7 +27,7 @@ if [ ! "$(ls -A $patchdir/*.patch 2>/dev/null)" ] ; then
 fi
 
 for patchfile in $patchdir/*.patch ; do
-       patch -d $sourcedir -p1 -s -r- -f -N --dry-run -i "$patchfile" || (echo "Patchfile $(basename $patchfile) failed to apply >&2" ; exit 1) || exit 1
+       patch -d $sourcedir -p1 -s -r- -f -N --dry-run -i "$patchfile" || (echo "Patchfile $(basename $patchfile) failed to apply" >&2 ; exit 1) || exit 1
 done
 
 for patchfile in "$patchdir"/*.patch ; do
index 7432227..2cc18bf 100644 (file)
@@ -21,14 +21,14 @@ AC_DEFUN([PJPROJECT_CONFIGURE],
 [
        AC_MSG_CHECKING(for embedded pjproject (may have to download))
        AC_MSG_RESULT(configuring)
-       make --quiet --no-print-directory -C $1 configure
+       ${GNU_MAKE} --quiet --no-print-directory -C $1 configure
        if test $? -ne 0 ; then
                AC_MSG_RESULT(failed)
                AC_MSG_NOTICE(Unable to configure $1)
-               AC_MSG_ERROR(Run "make -C $1 NOISY_BUILD=yes configure" to see error details.)
+               AC_MSG_ERROR(Run "${GNU_MAKE} -C $1 NOISY_BUILD=yes configure" to see error details.)
        fi
 
-       PJPROJECT_INCLUDE=$(make --quiet --no-print-directory -C $1 echo_cflags)
+       PJPROJECT_INCLUDE=$(${GNU_MAKE} --quiet --no-print-directory -C $1 echo_cflags)
        PJPROJECT_CFLAGS="$PJPROJECT_INCLUDE"
        PBX_PJPROJECT=1
        PJPROJECT_BUNDLED=yes
diff --git a/third-party/pjproject/patches/0001-pjsip-apps-src-python-setup.py-Take-make-from-the-en.patch b/third-party/pjproject/patches/0001-pjsip-apps-src-python-setup.py-Take-make-from-the-en.patch
new file mode 100644 (file)
index 0000000..80f8bc0
--- /dev/null
@@ -0,0 +1,51 @@
+From 61668b8fcaa0f2a8a05100097284c0c427600033 Mon Sep 17 00:00:00 2001
+From: George Joseph <george.joseph@fairview5.com>
+Date: Mon, 2 May 2016 17:08:15 -0600
+Subject: [PATCH] pjsip-apps/src/python/setup.py:  Take "make" from the
+ environment
+
+With "make" hard coded in setup.py, it chokes on FreeBSD because the system
+make command isn't GNU compatibile.  This patch allows setup.py to take the
+name of the make command from the MAKE environment variable if it exists.
+If it doesn't, it defaults to "make".
+---
+ pjsip-apps/src/python/setup.py | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/pjsip-apps/src/python/setup.py b/pjsip-apps/src/python/setup.py
+index 69a9859..ea1427d 100644
+--- a/pjsip-apps/src/python/setup.py
++++ b/pjsip-apps/src/python/setup.py
+@@ -60,25 +60,25 @@ if pj_version_suffix:
+       pj_version += "-" + pj_version_suffix
+ #print 'PJ_VERSION = "'+ pj_version + '"'
+-
++MAKE = os.environ.get('MAKE') or "make"
+ # Fill in pj_inc_dirs
+ pj_inc_dirs = []
+-f = os.popen("make -f helper.mak inc_dir")
++f = os.popen("%s -f helper.mak inc_dir" % MAKE)
+ for line in f:
+     pj_inc_dirs.append(line.rstrip("\r\n"))
+ f.close()
+ # Fill in pj_lib_dirs
+ pj_lib_dirs = []
+-f = os.popen("make -f helper.mak lib_dir")
++f = os.popen("%s -f helper.mak lib_dir" % MAKE)
+ for line in f:
+     pj_lib_dirs.append(line.rstrip("\r\n"))
+ f.close()
+ # Fill in pj_libs
+ pj_libs = []
+-f = os.popen("make -f helper.mak libs")
++f = os.popen("%s -f helper.mak libs" % MAKE)
+ for line in f:
+     pj_libs.append(line.rstrip("\r\n"))
+ f.close()
+-- 
+2.5.5
+