[Asterisk-code-review] pjproject bundled: Fixed various build issues (asterisk[master])

Joshua Colp asteriskteam at digium.com
Tue Oct 25 05:28:49 CDT 2016


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/4167 )

Change subject: pjproject_bundled:  Fixed various build issues
......................................................................


pjproject_bundled:  Fixed various build issues

* CFLAGS is now properly set when using older gcc.
* All third-party pjproject targets have been removed.  This fixes
  an issue with older libsrtp in some distros.
* Manually removing the source directory now causes a rebuild.
* EXTERNALS_CACHE_DIR is now properly checked.
* Whitespace fixes.

Change-Id: I98fec6847efc5602a9f41cb95096fd660a49fa60
---
M configure
M third-party/pjproject/Makefile
M third-party/pjproject/Makefile.rules
M third-party/pjproject/apply_patches
M third-party/pjproject/configure.m4
A third-party/pjproject/patches/0000-remove-third-party.patch
M third-party/pjproject/patches/user.mak
7 files changed, 190 insertions(+), 28 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/configure b/configure
index 1c7526f..af102b4 100755
--- a/configure
+++ b/configure
@@ -9241,7 +9241,7 @@
 	fi
 
 	export TAR PATCH SED NM EXTERNALS_CACHE_DIR DOWNLOAD_TO_STDOUT
-	${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} configure
+	${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} EXTERNALS_CACHE_DIR=${EXTERNALS_CACHE_DIR} configure
 	if test $? -ne 0 ; then
 		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
 $as_echo "failed" >&6; }
@@ -9253,7 +9253,7 @@
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bundled pjproject" >&5
 $as_echo_n "checking for bundled pjproject... " >&6; }
 
-	PJPROJECT_INCLUDE=$(${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} echo_cflags)
+	PJPROJECT_INCLUDE=$(${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} EXTERNALS_CACHE_DIR=${EXTERNALS_CACHE_DIR} echo_cflags)
 	PJPROJECT_CFLAGS="$PJPROJECT_INCLUDE"
 	PBX_PJPROJECT=1
 
diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile
index 6587522..aaf69bf 100644
--- a/third-party/pjproject/Makefile
+++ b/third-party/pjproject/Makefile
@@ -23,6 +23,8 @@
     include ../../makeopts
 endif
 
+TARGETS = build.mak
+
 ifeq ($(SPECIAL_TARGETS),)
 # Run locally or from $(ASTTOPDIR)/Makefile.  All include files should be present
     ifeq ($(wildcard ../../makeopts),)
@@ -40,6 +42,7 @@
         install: _install
 
         include source/user.mak
+        include source/version.mak
         include source/build.mak
         CF := $(filter-out -W%,$(CC_CFLAGS))
         CF := $(filter-out -I%,$(CF))
@@ -74,67 +77,72 @@
 
 _all: $(TARGETS)
 
-EXTERNALS_CACHE_DIR ?= $(or $(TMPDIR),$(wildcard /tmp),.)
+DOWNLOAD_DIR := $(or $(EXTERNALS_CACHE_DIR),$(TMPDIR),$(wildcard /tmp),.)
 
-$(EXTERNALS_CACHE_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2 : ../versions.mak
+$(DOWNLOAD_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2: ../versions.mak
 	$(ECHO_PREFIX) Downloading $(PJPROJECT_URL)/$(@F) to $@
 	$(CMD_PREFIX) $(DOWNLOAD_TO_STDOUT) $(PJPROJECT_URL)/$(@F) > $@
 
-source/.unpacked: $(EXTERNALS_CACHE_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2
+source/.unpacked: $(DOWNLOAD_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2
 	$(ECHO_PREFIX) Unpacking $<
 	- at rm -rf source >/dev/null 2>&1
 	- at mkdir source >/dev/null 2>&1
 	$(CMD_PREFIX) $(TAR) --strip-components=1 -C source -xjf $<
 	$(ECHO_PREFIX) Applying patches
-	$(CMD_PREFIX) ./apply_patches $(QUIET_CONFIGURE) ./patches ./source
+	$(CMD_PREFIX) ./apply_patches $(QUIET_CONFIGURE) patches source
 	- at touch source/.unpacked
 
-source/user.mak: source/.unpacked ./patches/user.mak
+source/version.mak: source/.unpacked
+
+source/user.mak: source/.unpacked patches/user.mak
 	$(ECHO_PREFIX) Applying user.mak
-	$(CMD_PREFIX) cp -f ./patches/user.mak ./source/
+	$(CMD_PREFIX) cp -f patches/user.mak source/
 
-source/pjlib/include/pj/%.h : ./patches/%.h
+source/pjlib/include/pj/%.h: patches/%.h
 	$(ECHO_PREFIX) Applying custom include file $<
-	$(CMD_PREFIX) cp -f $< ./source/pjlib/include/pj/
+	$(CMD_PREFIX) cp -f $< source/pjlib/include/pj/
 
-build.mak: source/.unpacked $(addprefix source/pjlib/include/pj/,$(notdir $(wildcard ./patches/*.h))) source/user.mak Makefile.rules
+source/build.mak: Makefile.rules source/version.mak source/user.mak $(addprefix source/pjlib/include/pj/,$(notdir $(wildcard patches/*.h)))
 	$(ECHO_PREFIX) Configuring with $(PJPROJECT_CONFIG_OPTS)
 	$(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
+build.mak: source/build.mak
+	$(CMD_PREFIX) $(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
 
-echo_cflags: build.mak
+configure: source/build.mak
+
+echo_cflags: source/build.mak
 	@echo $(PJ_CFLAGS)
 
-.rebuild_needed: ../../menuselect.makeopts
+.rebuild_needed: ../../makeopts ../../menuselect.makeopts
 	$(ECHO_PREFIX) Rebuilding
-	$(CMD_PREFIX)$(MAKE) clean $(REALLY_QUIET)
+	$(CMD_PREFIX) $(MAKE) clean $(REALLY_QUIET)
 	@touch  .rebuild_needed
 
-libpj%.a:  .rebuild_needed  build.mak
+libpj%.a: .rebuild_needed source/build.mak
 	$(ECHO_PREFIX) Compiling lib $(@F)
-	$(CMD_PREFIX)$(MAKE) -C $(dir $(shell dirname $@))/build $(@F) $(REALLY_QUIET)
+	$(CMD_PREFIX) $(MAKE) -C $(dir $(shell dirname $@))/build $(@F) $(REALLY_QUIET)
+	- at rm -rf .rebuild_needed
 
 # We need to compile pjlib, then pjlib-util, then the rest
 # so we separate them out and create the dependencies
 PJLIB_LIB_FILES = $(foreach lib,$(PJ_LIB_FILES),$(if $(findstring libpj-,$(lib)),$(lib),))
 PJLIB_UTIL_LIB_FILES = $(foreach lib,$(PJ_LIB_FILES),$(if $(findstring libpjlib-util,$(lib)),$(lib),))
-LIB_FILES = $(filter-out $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES),$(PJ_LIB_FILES))
-ALL_LIB_FILES = $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES) $(LIB_FILES)
+PJSIP_LIB_FILES = $(filter-out $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES),$(PJ_LIB_FILES))
+ALL_LIB_FILES = $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES) $(PJSIP_LIB_FILES)
 
 $(PJLIB_UTIL_LIB_FILES): $(PJLIB_LIB_FILES)
-$(LIB_FILES): $(PJLIB_UTIL_LIB_FILES)
+$(PJSIP_LIB_FILES): $(PJLIB_UTIL_LIB_FILES)
 
 pjproject.symbols: $(ALL_LIB_FILES)
 	$(ECHO_PREFIX) Generating symbols
-	$(CMD_PREFIX) $(NM) -Pog $(PJ_LIB_FILES) | $(SED) -n -r -e "s/.+: ([pP][jJ][^ ]+) .+/\1/gp" | sort -u > pjproject.symbols
+	$(CMD_PREFIX) $(NM) -Pog $(ALL_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 $@
 	$(CMD_PREFIX) cp -f $< $@
 
-source/pjsip-apps/lib/asterisk_malloc_debug.o: source/pjsip-apps/src/asterisk_malloc_debug.c  .rebuild_needed
+source/pjsip-apps/lib/asterisk_malloc_debug.o: source/pjsip-apps/src/asterisk_malloc_debug.c .rebuild_needed
 	$(ECHO_PREFIX) Compiling asterisk debug malloc stubs
 	$(CMD_PREFIX) $(CC) -fPIC  $(PJ_CFLAGS) -c $< -o $@
 
diff --git a/third-party/pjproject/Makefile.rules b/third-party/pjproject/Makefile.rules
index 739193a..62d5a46 100644
--- a/third-party/pjproject/Makefile.rules
+++ b/third-party/pjproject/Makefile.rules
@@ -28,7 +28,7 @@
 	--disable-openh264 \
 	--disable-ipp \
 	--without-external-pa \
-	--with-external-srtp
+	--without-external-srtp
 
 ifeq ($(shell uname -s),Linux)
    PJPROJECT_CONFIG_OPTS +=  --enable-epoll
diff --git a/third-party/pjproject/apply_patches b/third-party/pjproject/apply_patches
index c28f403..69a0ad0 100755
--- a/third-party/pjproject/apply_patches
+++ b/third-party/pjproject/apply_patches
@@ -28,8 +28,14 @@
 	exit 0
 fi
 
+if patch --dry-run </dev/null >/dev/null 2>&1 ; then
+	DRY_RUN=--dry-run
+else
+	DRY_RUN=-C
+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
diff --git a/third-party/pjproject/configure.m4 b/third-party/pjproject/configure.m4
index 7b62c0f..8704682 100644
--- a/third-party/pjproject/configure.m4
+++ b/third-party/pjproject/configure.m4
@@ -30,7 +30,7 @@
 	fi
 
 	export TAR PATCH SED NM EXTERNALS_CACHE_DIR DOWNLOAD_TO_STDOUT
-	${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} configure
+	${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} EXTERNALS_CACHE_DIR=${EXTERNALS_CACHE_DIR} configure
 	if test $? -ne 0 ; then
 		AC_MSG_RESULT(failed)
 		AC_MSG_NOTICE(Unable to configure ${PJPROJECT_DIR})
@@ -39,7 +39,7 @@
 
 	AC_MSG_CHECKING(for bundled pjproject)
 
-	PJPROJECT_INCLUDE=$(${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} echo_cflags)
+	PJPROJECT_INCLUDE=$(${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} EXTERNALS_CACHE_DIR=${EXTERNALS_CACHE_DIR} echo_cflags)
 	PJPROJECT_CFLAGS="$PJPROJECT_INCLUDE"
 	PBX_PJPROJECT=1
 
diff --git a/third-party/pjproject/patches/0000-remove-third-party.patch b/third-party/pjproject/patches/0000-remove-third-party.patch
new file mode 100644
index 0000000..1317751
--- /dev/null
+++ b/third-party/pjproject/patches/0000-remove-third-party.patch
@@ -0,0 +1,146 @@
+diff --git a/build.mak.in b/build.mak.in
+index 802211c..006d887 100644
+--- a/build.mak.in
++++ b/build.mak.in
+@@ -9,7 +9,7 @@ export HOST_NAME := unix
+ export CC_NAME := gcc
+ export TARGET_NAME := @target@
+ export CROSS_COMPILE := @ac_cross_compile@
+-export LINUX_POLL := @ac_linux_poll@ 
++export LINUX_POLL := @ac_linux_poll@
+ export SHLIB_SUFFIX := @ac_shlib_suffix@
+ 
+ export prefix := @prefix@
+@@ -28,114 +28,6 @@ export APP_THIRD_PARTY_EXT :=
+ export APP_THIRD_PARTY_LIBS :=
+ export APP_THIRD_PARTY_LIB_FILES :=
+ 
+-ifeq (@ac_external_srtp@,1)
+-# External SRTP library
+-APP_THIRD_PARTY_EXT += -lsrtp
+-else
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libsrtp-$(LIB_SUFFIX)
+-ifeq ($(PJ_SHARED_LIBRARIES),)
+-APP_THIRD_PARTY_LIBS += -lsrtp-$(TARGET_NAME)
+-else
+-APP_THIRD_PARTY_LIBS += -lsrtp
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libsrtp.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libsrtp.$(SHLIB_SUFFIX)
+-endif
+-endif
+-
+-ifeq (@ac_pjmedia_resample@,libresample)
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libresample-$(LIB_SUFFIX)
+-ifeq ($(PJ_SHARED_LIBRARIES),)
+-ifeq (@ac_resample_dll@,1)
+-export PJ_RESAMPLE_DLL := 1
+-APP_THIRD_PARTY_LIBS += -lresample
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFIX)
+-else
+-APP_THIRD_PARTY_LIBS += -lresample-$(TARGET_NAME)
+-endif
+-else
+-APP_THIRD_PARTY_LIBS += -lresample
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFIX)
+-endif
+-endif
+-
+-ifneq (@ac_no_gsm_codec@,1)
+-ifeq (@ac_external_gsm@,1)
+-# External GSM library
+-APP_THIRD_PARTY_EXT += -lgsm
+-else
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libgsmcodec-$(LIB_SUFFIX)
+-ifeq ($(PJ_SHARED_LIBRARIES),)
+-APP_THIRD_PARTY_LIBS += -lgsmcodec-$(TARGET_NAME)
+-else
+-APP_THIRD_PARTY_LIBS += -lgsmcodec
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libgsmcodec.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libgsmcodec.$(SHLIB_SUFFIX)
+-endif
+-endif
+-endif
+-
+-ifneq (@ac_no_speex_codec@,1)
+-ifeq (@ac_external_speex@,1)
+-APP_THIRD_PARTY_EXT += -lspeex -lspeexdsp
+-else
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libspeex-$(LIB_SUFFIX)
+-ifeq ($(PJ_SHARED_LIBRARIES),)
+-APP_THIRD_PARTY_LIBS += -lspeex-$(TARGET_NAME)
+-else
+-APP_THIRD_PARTY_LIBS += -lspeex
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libspeex.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libspeex.$(SHLIB_SUFFIX)
+-endif
+-endif
+-endif
+-
+-ifneq (@ac_no_ilbc_codec@,1)
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libilbccodec-$(LIB_SUFFIX)
+-ifeq ($(PJ_SHARED_LIBRARIES),)
+-APP_THIRD_PARTY_LIBS += -lilbccodec-$(TARGET_NAME)
+-else
+-APP_THIRD_PARTY_LIBS += -lilbccodec
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libilbccodec.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libilbccodec.$(SHLIB_SUFFIX)
+-endif
+-endif
+-
+-ifneq (@ac_no_g7221_codec@,1)
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libg7221codec-$(LIB_SUFFIX)
+-ifeq ($(PJ_SHARED_LIBRARIES),)
+-APP_THIRD_PARTY_LIBS += -lg7221codec-$(TARGET_NAME)
+-else
+-APP_THIRD_PARTY_LIBS += -lg7221codec
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libg7221codec.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libg7221codec.$(SHLIB_SUFFIX)
+-endif
+-endif
+-
+-ifneq ($(findstring pa, at ac_pjmedia_snd@),)
+-ifeq (@ac_external_pa@,1)
+-# External PA
+-APP_THIRD_PARTY_EXT += -lportaudio
+-else
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libportaudio-$(LIB_SUFFIX)
+-ifeq ($(PJ_SHARED_LIBRARIES),)
+-APP_THIRD_PARTY_LIBS += -lportaudio-$(TARGET_NAME)
+-else
+-APP_THIRD_PARTY_LIBS += -lportaudio
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libportaudio.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libportaudio.$(SHLIB_SUFFIX)
+-endif
+-endif
+-endif
+-
+-ifneq (@ac_no_yuv@,1)
+-ifeq (@ac_external_yuv@,1)
+-APP_THIRD_PARTY_EXT += -lyuv
+-else
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libyuv-$(LIB_SUFFIX)
+-ifeq ($(PJ_SHARED_LIBRARIES),)
+-APP_THIRD_PARTY_LIBS += -lyuv-$(TARGET_NAME)
+-else
+-APP_THIRD_PARTY_LIBS += -lyuv
+-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libyuv.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libyuv.$(SHLIB_SUFFIX)
+-endif
+-endif
+-endif
+-
+-
+ # Additional flags
+ @ac_build_mak_vars@
+ 
+@@ -149,7 +41,7 @@ SDL_CFLAGS = @ac_sdl_cflags@
+ SDL_LDFLAGS = @ac_sdl_ldflags@
+ 
+ # FFMPEG flags
+-FFMPEG_CFLAGS = @ac_ffmpeg_cflags@ 
++FFMPEG_CFLAGS = @ac_ffmpeg_cflags@
+ FFMPEG_LDFLAGS =  @ac_ffmpeg_ldflags@
+ 
+ # Video4Linux2
+@@ -157,7 +49,7 @@ V4L2_CFLAGS = @ac_v4l2_cflags@
+ V4L2_LDFLAGS = @ac_v4l2_ldflags@
+ 
+ # OPENH264 flags
+-OPENH264_CFLAGS = @ac_openh264_cflags@ 
++OPENH264_CFLAGS = @ac_openh264_cflags@
+ OPENH264_LDFLAGS =  @ac_openh264_ldflags@
+ 
+ # QT
diff --git a/third-party/pjproject/patches/user.mak b/third-party/pjproject/patches/user.mak
index 31579d1..dafb259 100644
--- a/third-party/pjproject/patches/user.mak
+++ b/third-party/pjproject/patches/user.mak
@@ -1,2 +1,4 @@
 
-CFLAGS += -fPIC -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-label -Wno-unused-function -Wno-strict-aliasing
+NUBSV := $(shell gcc -Wno-unused-but-set-variable -o /dev/null -xc -c - </dev/null 2>/dev/null && echo -Wno-unused-but-set-variable)
+
+CFLAGS += -fPIC $(NUBSV) -Wno-unused-variable -Wno-unused-label -Wno-unused-function -Wno-strict-aliasing

-- 
To view, visit https://gerrit.asterisk.org/4167
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I98fec6847efc5602a9f41cb95096fd660a49fa60
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list