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
This commit is contained in:
Matt Jordan 2019-04-29 10:10:35 -05:00
parent 12cad5ec1a
commit 54f7f7dc20
1 changed files with 12 additions and 2 deletions

View File

@ -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 $@