From 54f7f7dc201ec4b5996d1ce33655e4f783edcdad Mon Sep 17 00:00:00 2001 From: Matt Jordan Date: Mon, 29 Apr 2019 10:10:35 -0500 Subject: [PATCH] pjproject/Makefile: Updates for Darwin compatible builds This patch fixes three compatibility issues for Darwin compatible builds: (1) Use BSD compatible command line option for sed For some versions of BSD sed, the -r command line option is unknown. Both GNU and BSD sed support the -E command line option for enabling extended regular expressions; as such, this patch replaces the -r option with -E. (2) Look for '_' in pjproject generated symbols In Darwin comaptible systems, the symbols generated for pjproject may be prefixed with an '_'. When exporting these to a symbol file, the invocation to sed has to optionally look for a prefix of said '_' character. (3) Use -all_load/-noall_load when linking The flags -whole-archive/-no-whole-archive are not supported by the linker, and must instead be replaced with -all_load/-noall_load. Change-Id: I58121756de6a0560a6e49ca9d6bf9566a333cde3 --- third-party/pjproject/Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile index af0e9f80a4..86eb9682d8 100644 --- a/third-party/pjproject/Makefile +++ b/third-party/pjproject/Makefile @@ -66,7 +66,17 @@ ifeq ($(SPECIAL_TARGETS),) CF += -DPJPROJECT_BUNDLED_ASSERTIONS=yes endif MALLOC_DEBUG_LIBS = source/pjsip-apps/lib/libasterisk_malloc_debug.a - MALLOC_DEBUG_LDFLAGS = -L$(PJDIR)/pjsip-apps/lib -Wl,-whole-archive -lasterisk_malloc_debug -Wl,-no-whole-archive + ifneq ($(findstring darwin,$(OSARCH)),) + MALLOC_DEBUG_LDFLAGS = -L$(PJDIR)/pjsip-apps/lib -Wl,-all_load -lasterisk_malloc_debug -Wl,-noall_load + else + # These are used for all but Darwin + MALLOC_DEBUG_LDFLAGS = -L$(PJDIR)/pjsip-apps/lib -Wl,-whole-archive -lasterisk_malloc_debug -Wl,-no-whole-archive + endif + ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)),) + CF += -O3 + endif + export CFLAGS += $(CF) -g3 + export LDFLAGS += $(CC_LDFLAGS) TARGETS += pjproject.symbols else all install: @@ -155,7 +165,7 @@ $(PJSIP_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 $(ALL_LIB_FILES) | $(SED) -n -E -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 $@