bundled_pjproject: Add tests for programs used by the Makefile, et al.

Added tests for bzip2, tar, patch, sed and nm to configure.ac.

Set DOWNLOAD_TO_STDOUT to a working command line regardless of
whether the download program is wget, curl or fetch.

Added a 'configure.m4' file to the third-party directory which takes
care of calling any third-party project setup.  Had to move some
pjproject_bundled stuff up in configure.ac so it was called before
the third-party configure macro.

The pjproject tarball is now downloaded to the externals_cache_dir if
it was specified on the ./configure command line

Removed regeneration of the pjproject aconfigure file.  It was only
needed for an old patch that no longer applies.

Converted the tests for symbols to explicit tests since we know that
they're now available in the bundled version.  Saves a little time
during configure.

ASTERISK-26416 #close
Reported-by: Corey Farrell

Change-Id: Id1d94251c0155f8dd41b7de7067f35cfbaafbb9b
This commit is contained in:
George Joseph
2016-10-03 10:30:43 -06:00
parent 0dc0356e39
commit e6b0053d75
10 changed files with 490 additions and 399 deletions

View File

@@ -7,8 +7,6 @@ SPECIAL_TARGETS :=
ifneq ($(findstring configure,$(MAKECMDGOALS))$(findstring echo_cflags,$(MAKECMDGOALS)),)
# Run from $(ASTTOPDIR)/configure
SPECIAL_TARGETS += configure
include ../Makefile.rules
include Makefile.rules
endif
ifeq ($(findstring echo_cflags,$(MAKECMDGOALS)),echo_cflags)
@@ -19,8 +17,10 @@ endif
ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
# clean or distclean
SPECIAL_TARGETS += clean
include ../Makefile.rules
include Makefile.rules
endif
ifneq ($(wildcard ../../makeopts),)
include ../../makeopts
endif
ifeq ($(SPECIAL_TARGETS),)
@@ -28,17 +28,17 @@ ifeq ($(SPECIAL_TARGETS),)
ifeq ($(wildcard ../../makeopts),)
$(error ASTTOPDIR/configure hasn't been run)
endif
include ../../makeopts
ifeq ($(PJPROJECT_BUNDLED),yes)
-include ../../menuselect.makeopts
include ../Makefile.rules
ifneq ($(wildcard ../../menuselect.makeopts),)
include ../../menuselect.makeopts
else
$(warning ASTTOPDIR/menuselect hasn't been run yet. Can't find debug options.)
endif
all: _all
install: _install
include ../../Makefile.rules
include Makefile.rules
include source/user.mak
include source/build.mak
CF := $(filter-out -W%,$(CC_CFLAGS))
@@ -66,25 +66,25 @@ ifeq ($(SPECIAL_TARGETS),)
endif
endif
include ../../Makefile.rules
include ../Makefile.rules
include Makefile.rules
ECHO_PREFIX := $(ECHO_PREFIX) echo '[pjproject] '
ifndef $(TMPDIR)
ifneq ($(wildcard /tmp),)
TMPDIR=/tmp
else
TMPDIR=.
endif
endif
_all: $(TARGETS)
TMPDIR ?= $(or $(EXTERNALS_CACHE_DIR),$(wildcard /tmp),.)
$(TMPDIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2 : ../versions.mak
$(ECHO_PREFIX) Downloading $@ with $(DOWNLOAD)
$(CMD_PREFIX) $(DOWNLOAD) $(PJPROJECT_URL)/$(@F) > $@
$(ECHO_PREFIX) Downloading $(PJPROJECT_URL)/$(@F) to $@
$(CMD_PREFIX) $(DOWNLOAD_TO_STDOUT) $(PJPROJECT_URL)/$(@F) > $@
source/.unpacked: $(TMPDIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2
$(ECHO_PREFIX) Unpacking $<
-@rm -rf source >/dev/null 2>&1
-@mkdir source >/dev/null 2>&1
$(CMD_PREFIX) tar --strip-components=1 -C source -xjf $<
$(CMD_PREFIX) $(TAR) --strip-components=1 -C source -xjf $<
$(ECHO_PREFIX) Applying patches
$(CMD_PREFIX) ./apply_patches $(QUIET_CONFIGURE) ./patches ./source
-@touch source/.unpacked
@@ -99,8 +99,8 @@ source/pjlib/include/pj/%.h : ./patches/%.h
build.mak: source/.unpacked $(addprefix source/pjlib/include/pj/,$(notdir $(wildcard ./patches/*.h))) source/user.mak Makefile.rules
$(ECHO_PREFIX) Configuring with $(PJPROJECT_CONFIG_OPTS)
$(CMD_PREFIX) (cd source ; autoconf aconfigure.ac > aconfigure && ./aconfigure $(QUIET_CONFIGURE) $(PJPROJECT_CONFIG_OPTS))
@sed -r -e "/prefix|export PJ_SHARED_LIBRARIES|MACHINE_NAME|OS_NAME|HOST_NAME|CC_NAME|CROSS_COMPILE|LINUX_POLL/d" source/build.mak > build.mak
$(CMD_PREFIX) (cd source ; ./aconfigure $(QUIET_CONFIGURE) $(PJPROJECT_CONFIG_OPTS))
$(SED) -r -e "/prefix|export PJ_SHARED_LIBRARIES|MACHINE_NAME|OS_NAME|HOST_NAME|CC_NAME|CROSS_COMPILE|LINUX_POLL/d" source/build.mak > build.mak
configure: build.mak
@@ -128,7 +128,7 @@ $(LIB_FILES): $(PJLIB_UTIL_LIB_FILES)
pjproject.symbols: $(ALL_LIB_FILES)
$(ECHO_PREFIX) Generating symbols
$(CMD_PREFIX) nm -Pog $(ALL_LIB_FILES) | sed -n -r -e "s/.+: ([pP][jJ][^ ]+) .+/\1/gp" | sort -u > pjproject.symbols
$(CMD_PREFIX) $(NM) -Pog $(PJ_LIB_FILES) | $(SED) -n -r -e "s/.+: ([pP][jJ][^ ]+) .+/\1/gp" | sort -u > pjproject.symbols
source/pjsip-apps/src/asterisk_malloc_debug.c: patches/asterisk_malloc_debug.c
$(ECHO_PREFIX) Copying $< to $@
@@ -155,8 +155,6 @@ source/pjsip-apps/src/python/_pjsua.so: source/pjsip-apps/src/python/_pjsua.o
$(ECHO_PREFIX) Linking python bindings $(@F)
$(CMD_PREFIX) gcc -shared -pthread -o $@ $< $(LDFLAGS) $(PJ_LDFLAGS) $(APP_LDLIBS) $(PYTHONDEV_LIB) $(REALLY_QUIET)
_all: $(TARGETS)
_install: _all
@if [ ! -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject" ]; then \
$(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject"; \
@@ -188,4 +186,3 @@ clean:
distclean:
$(ECHO_PREFIX) Distcleaning
-$(CMD_PREFIX) rm -rf source pjproject.symbols pjproject-*.tar.bz2 build.mak .rebuild_needed

View File

@@ -5,6 +5,8 @@ if [ "$1" = "-q" ] ; then
shift
fi
PATCH=${PATCH:-patch}
patchdir=${1:?You must supply a patches directory}
sourcedir=${2?:You must supply a source directory}
@@ -27,12 +29,12 @@ 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
[ -z $quiet ] && echo "Applying patch $(basename $patchfile)"
patch -d "$sourcedir" -p1 -s -i "$patchfile" || exit 1
${PATCH} -d "$sourcedir" -p1 -s -i "$patchfile" || exit 1
done
exit 0

View File

@@ -1,49 +1,73 @@
AC_DEFUN([PJPROJECT_SYMBOL_CHECK],
AC_DEFUN([_PJPROJECT_CONFIGURE],
[
$1_INCLUDE="$PJPROJECT_INCLUDE"
AC_MSG_CHECKING([for $2 declared in $3])
if test "${ac_mandatory_list#*PJPROJECT*}" != "$ac_mandatory_list" ; then
AC_MSG_ERROR(--with-pjproject and --with-pjproject-bundled can't both be specified)
fi
saved_cpp="$CPPFLAGS"
CPPFLAGS="$PJPROJECT_INCLUDE"
AC_EGREP_HEADER($2, $3, [
AC_MSG_RESULT(yes)
PBX_$1=1
AC_DEFINE([HAVE_$1], 1, [Define if your system has $2 declared.])
], [
AC_MSG_RESULT(no)
])
ac_mandatory_list="$ac_mandatory_list PJPROJECT"
PJPROJECT_DIR="${ac_top_build_prefix}third-party/pjproject"
CPPGLAGS="$saved_cpp"
$1_INCLUDE="$PJPROJECT_INCLUDE"
AC_MSG_CHECKING(for embedded pjproject (may have to download))
AC_MSG_RESULT(configuring)
if test "x${DOWNLOAD_TO_STDOUT}" = "x" ; then
AC_MSG_ERROR(A download utility (wget, curl or fetch) is required to download bundled pjproject)
fi
if test "${BZIP2}" = ":" ; then
AC_MSG_ERROR(bzip2 is required to extract the pjproject tar file)
fi
if test "${TAR}" = ":" ; then
AC_MSG_ERROR(tar is required to extract the pjproject tar file)
fi
if test "${PATCH}" = ":" ; then
AC_MSG_ERROR(patch is required to configure bundled pjproject)
fi
if test "${SED}" = ":" ; then
AC_MSG_ERROR(sed is required to configure bundled pjproject)
fi
if test "${NM}" = ":" ; then
AC_MSG_ERROR(nm is required to build bundled pjproject)
fi
export TAR PATCH SED NM EXTERNALS_CACHE_DIR DOWNLOAD_TO_STDOUT
${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} configure
if test $? -ne 0 ; then
AC_MSG_RESULT(failed)
AC_MSG_NOTICE(Unable to configure ${PJPROJECT_DIR})
AC_MSG_ERROR(Run "${GNU_MAKE} -C ${PJPROJECT_DIR} NOISY_BUILD=yes configure" to see error details.)
fi
AC_MSG_CHECKING(for bundled pjproject)
PJPROJECT_INCLUDE=$(${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} echo_cflags)
PJPROJECT_CFLAGS="$PJPROJECT_INCLUDE"
PBX_PJPROJECT=1
AC_DEFINE([HAVE_PJPROJECT], 1, [Define if your system has PJPROJECT])
AC_DEFINE([HAVE_PJPROJECT_BUNDLED], 1, [Define if your system has PJPROJECT_BUNDLED])
AC_DEFINE([HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK], 1, [Define if your system has pjsip_dlg_create_uas_and_inc_lock declared.])
AC_DEFINE([HAVE_PJ_TRANSACTION_GRP_LOCK], 1, [Define if your system has pjsip_tsx_create_uac2 declared.])
AC_DEFINE([HAVE_PJSIP_REPLACE_MEDIA_STREAM], 1, [Define if your system has PJSIP_REPLACE_MEDIA_STREAM declared])
AC_DEFINE([HAVE_PJSIP_GET_DEST_INFO], 1, [Define if your system has pjsip_get_dest_info declared.])
AC_DEFINE([HAVE_PJ_SSL_CERT_LOAD_FROM_FILES2], 1, [Define if your system has pj_ssl_cert_load_from_files2 declared.])
AC_DEFINE([HAVE_PJSIP_EXTERNAL_RESOLVER], 1, [Define if your system has pjsip_endpt_set_ext_resolver declared.])
AC_DEFINE([HAVE_PJSIP_TLS_TRANSPORT_PROTO], 1, [Define if your system has PJSIP_TLS_TRANSPORT_PROTO])
AC_DEFINE([HAVE_PJSIP_EVSUB_GRP_LOCK], 1, [Define if your system has PJSIP_EVSUB_GRP_LOCK])
AC_DEFINE([HAVE_PJSIP_INV_SESSION_REF], 1, [Define if your system has PJSIP_INV_SESSION_REF])
AC_SUBST([PJPROJECT_BUNDLED])
AC_SUBST([PJPROJECT_DIR])
AC_SUBST([PBX_PJPROJECT])
AC_SUBST([PJPROJECT_LIB])
AC_SUBST([PJPROJECT_INCLUDE])
AC_MSG_RESULT(yes)
])
AC_DEFUN([PJPROJECT_CONFIGURE],
[
AC_MSG_CHECKING(for embedded pjproject (may have to download))
AC_MSG_RESULT(configuring)
${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 "${GNU_MAKE} -C $1 NOISY_BUILD=yes configure" to see error details.)
if test "$PJPROJECT_BUNDLED" = "yes" ; then
_PJPROJECT_CONFIGURE()
fi
PJPROJECT_INCLUDE=$(${GNU_MAKE} --quiet --no-print-directory -C $1 echo_cflags)
PJPROJECT_CFLAGS="$PJPROJECT_INCLUDE"
PBX_PJPROJECT=1
PJPROJECT_BUNDLED=yes
AC_DEFINE([HAVE_PJPROJECT], 1, [Define if your system has PJPROJECT])
AC_DEFINE([HAVE_PJPROJECT_BUNDLED], 1, [Define if your system has PJPROJECT_BUNDLED])
AC_MSG_CHECKING(for embedded pjproject)
AC_MSG_RESULT(yes)
PJPROJECT_SYMBOL_CHECK([PJSIP_DLG_CREATE_UAS_AND_INC_LOCK], [pjsip_dlg_create_uas_and_inc_lock], [pjsip.h])
PJPROJECT_SYMBOL_CHECK([PJ_TRANSACTION_GRP_LOCK], [pjsip_tsx_create_uac2], [pjsip.h])
PJPROJECT_SYMBOL_CHECK([PJSIP_REPLACE_MEDIA_STREAM], [PJMEDIA_SDP_NEG_ALLOW_MEDIA_CHANGE], [pjmedia.h])
PJPROJECT_SYMBOL_CHECK([PJSIP_GET_DEST_INFO], [pjsip_get_dest_info], [pjsip.h])
PJPROJECT_SYMBOL_CHECK([PJ_SSL_CERT_LOAD_FROM_FILES2], [pj_ssl_cert_load_from_files2], [pjlib.h])
PJPROJECT_SYMBOL_CHECK([PJSIP_EXTERNAL_RESOLVER], [pjsip_endpt_set_ext_resolver], [pjsip.h])
AC_DEFINE([HAVE_PJSIP_TLS_TRANSPORT_PROTO], 1, [Define if your system has PJSIP_TLS_TRANSPORT_PROTO])
AC_DEFINE([HAVE_PJSIP_EVSUB_GRP_LOCK], 1, [Define if your system has PJSIP_EVSUB_GRP_LOCK])
AC_DEFINE([HAVE_PJSIP_INV_SESSION_REF], 1, [Define if your system has PJSIP_INV_SESSION_REF])
])