mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	bundled_pjproject: Make it easier to hack
There are times when you need to troubleshoot issues with bundled pjproject or add new features that need to be pushed upstream but... * The source directory created by extracting the pjproject tarball is not scanned for code changes so you have to keep forcing rebuilds. * The source directory isn't a git repo so you can't easily create patches, do git bisects, etc. * Accidentally doing a make distclean will ruin your day by wiping out the source directory, and your changes. * etc. This commit makes that easier. See third-party/pjproject/README-hacking.md for the details. ASTERISK-29824 Change-Id: Idb1251040affdab31d27cd272dda68676da9b268
This commit is contained in:
		
							
								
								
									
										3
									
								
								third-party/pjproject/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								third-party/pjproject/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,5 +1,6 @@ | ||||
| source/ | ||||
| source | ||||
| **.bz2 | ||||
| build.mak | ||||
| pjproject.symbols | ||||
| .rebuild_needed | ||||
| .makedeps | ||||
|   | ||||
							
								
								
									
										154
									
								
								third-party/pjproject/Makefile
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										154
									
								
								third-party/pjproject/Makefile
									
									
									
									
										vendored
									
									
								
							| @@ -3,6 +3,7 @@ | ||||
| .NOTPARALLEL: | ||||
|  | ||||
| include ../versions.mak | ||||
|  | ||||
| export PJDIR := $(shell pwd -P)/source | ||||
|  | ||||
| SPECIAL_TARGETS := | ||||
| @@ -40,21 +41,21 @@ ifeq ($(SPECIAL_TARGETS),) | ||||
|     endif | ||||
|  | ||||
|     ifeq ($(PJPROJECT_BUNDLED),yes) | ||||
|         all: _all | ||||
|         install: _install | ||||
|  | ||||
|         ifneq ($(wildcard ../../menuselect.makeopts),) | ||||
|             include ../../menuselect.makeopts | ||||
|         else | ||||
|             $(warning ASTTOPDIR/menuselect hasn't been run yet.  Can't find debug options.) | ||||
|         endif | ||||
| 		include ../../Makefile.rules | ||||
| 		include ../Makefile.rules | ||||
|         include ../Makefile.rules | ||||
| 		include Makefile.rules | ||||
|  | ||||
|         all: _all | ||||
|         install: _install | ||||
|  | ||||
|         include source/user.mak | ||||
|         include source/version.mak | ||||
|         include source/build.mak | ||||
|         -include source/user.mak | ||||
|         -include source/version.mak | ||||
|         -include source/build.mak | ||||
|         CF := $(filter-out -W%,$(CC_CFLAGS)) | ||||
|         CF := $(filter-out -I%,$(CF)) | ||||
|         ifeq ($(AST_DEVMODE),yes) | ||||
| @@ -92,31 +93,28 @@ export CFLAGS += $(CF) $(OPENSSL_INCLUDE) | ||||
| export LDFLAGS += $(CC_LDFLAGS) $(OPENSSL_LIB) | ||||
|  | ||||
| ECHO_PREFIX := $(ECHO_PREFIX) echo '[pjproject] ' | ||||
| ECHO_PREFIX_NONL := $(ECHO_PREFIX) echo -n '[pjproject] ' | ||||
| SHELL_ECHO_PREFIX := echo '[pjproject] ' | ||||
|  | ||||
| _all: $(TARGETS) | ||||
|  | ||||
| .DELETE_ON_ERROR: | ||||
|  | ||||
| $(DOWNLOAD_DIR)/$(TARBALL_FILE): ../versions.mak | ||||
| 	$(CMD_PREFIX) ($(TARBALL_EXISTS) && $(TARBALL_VERIFY) && touch $@) || (rm -rf $@ ;\ | ||||
| 	$(TARBALL_DOWNLOAD)) || (rm -rf $@ ;\ | ||||
| 	$(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD)) | ||||
|  | ||||
| source/.unpacked: $(DOWNLOAD_DIR)/$(TARBALL_FILE) | ||||
| 	$(CMD_PREFIX) $(TARBALL_VERIFY) || (rm -rf $@ ;\ | ||||
| 	$(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD)) | ||||
| 	$(ECHO_PREFIX) Unpacking $< | ||||
| 	-@rm -rf source pjproject-*/ >/dev/null 2>&1 | ||||
| 	$(CMD_PREFIX) $(TAR) -xjf $< | ||||
| 	@mv pjproject-$(PJPROJECT_VERSION) source | ||||
| 	$(CMD_PREFIX) \ | ||||
| 		$(TARBALL_VERIFY) || (rm -rf $@ ; $(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD)) ;\ | ||||
| 		$(SHELL_ECHO_PREFIX) Unpacking $< ;\ | ||||
| 		rm -rf source pjproject-*/ $(REALLY_QUIET) || : ;\ | ||||
| 		$(TAR) -xjf $< ;\ | ||||
| 		mv pjproject-$(PJPROJECT_VERSION) source | ||||
| 	$(ECHO_PREFIX) Applying patches "$(realpath patches)" "$(realpath .)/source" | ||||
| 	$(CMD_PREFIX) ../apply_patches $(QUIET_CONFIGURE) "$(realpath patches)" "$(realpath .)/source" | ||||
| 	-@touch source/.unpacked | ||||
|  | ||||
| source/version.mak: source/.unpacked | ||||
|  | ||||
| source/user.mak: source/.unpacked patches/user.mak | ||||
| source/user.mak: $(if $(PJPROJECT_BUNDLED_OOT),,source/.unpacked) patches/user.mak | ||||
| 	$(ECHO_PREFIX) Applying user.mak | ||||
| 	$(CMD_PREFIX) cp -f patches/user.mak source/ | ||||
|  | ||||
| @@ -128,7 +126,7 @@ source/pjlib/include/pj/%.h: patches/%.h | ||||
| 	$(ECHO_PREFIX) Rebuilding | ||||
| 	$(CMD_PREFIX) $(MAKE) clean $(REALLY_QUIET) | ||||
|  | ||||
| source/build.mak: Makefile.rules source/version.mak source/user.mak $(addprefix source/pjlib/include/pj/,$(notdir $(wildcard patches/*.h))) .rebuild_needed | ||||
| source/build.mak: Makefile.rules source/user.mak $(if $(PJPROJECT_BUNDLED_OOT),,.rebuild_needed) | ||||
| 	$(ECHO_PREFIX) Configuring with $(PJPROJECT_CONFIG_OPTS)  | ||||
| 	$(CMD_PREFIX) (cd source ; ./aconfigure $(QUIET_CONFIGURE) $(PJPROJECT_CONFIG_OPTS)) | ||||
|  | ||||
| @@ -144,25 +142,74 @@ configure: source/build.mak | ||||
| echo_cflags: source/build.mak | ||||
| 	@echo $(filter-out -O% -g%,$(PJ_CFLAGS)) | ||||
|  | ||||
| libpj%.a: source/build.mak | ||||
| 	$(ECHO_PREFIX) Compiling lib $(@F) | ||||
| 	$(CMD_PREFIX) $(MAKE) -C $(dir $(shell dirname $@))/build $(@F) $(REALLY_QUIET) | ||||
| # The dependency_utils script needs TARGET_NAME in the environment | ||||
| export TARGET_NAME | ||||
|  | ||||
| # pjsua needs resample and g711 to successfully run the testsuite | ||||
| libresample%.a: source/build.mak | ||||
| 	$(ECHO_PREFIX) Compiling lib $(@F) | ||||
| 	$(CMD_PREFIX) $(MAKE) -C $(dir $(shell dirname $@))/build/resample all $(REALLY_QUIET) | ||||
|  | ||||
| # 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),)) | ||||
| PJSIP_LIB_FILES = $(filter-out $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES) $(APP_THIRD_PARTY_LIB_FILES),$(PJ_LIB_FILES)) | ||||
| ALL_LIB_FILES = $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES) $(PJSIP_LIB_FILES) | ||||
| # PJ_LIB_FILES is set by the pjproject build.mak and contains the libs we | ||||
| # need, but not in the order they need to be built.  We need to compile | ||||
| # pjlib, then pjlib-util, then the rest so we separate them out and create | ||||
| # the dependencies.  First though, we shorten all file paths by making them | ||||
| # relative to the current directory. | ||||
| SHORTENED_PJ_LIB_FILES = $(subst $(CURDIR)/,,$(PJ_LIB_FILES)) | ||||
| # Now separate them | ||||
| PJLIB_LIB_FILES = $(filter %/libpj-$(TARGET_NAME).a,$(SHORTENED_PJ_LIB_FILES)) | ||||
| PJLIB_UTIL_LIB_FILES = $(filter %/libpjlib-util-$(TARGET_NAME).a,$(SHORTENED_PJ_LIB_FILES)) | ||||
| RESAMPLE_LIB_FILE = $(filter %/libresample-$(TARGET_NAME).a,$(SHORTENED_PJ_LIB_FILES)) | ||||
| # The rest. | ||||
| PJSIP_LIB_FILES = $(filter-out $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES) $(RESAMPLE_LIB_FILE),$(SHORTENED_PJ_LIB_FILES)) | ||||
|  | ||||
| # Create the dependency order we need | ||||
| $(PJLIB_UTIL_LIB_FILES): $(PJLIB_LIB_FILES) | ||||
| $(PJSIP_LIB_FILES): $(PJLIB_UTIL_LIB_FILES) | ||||
|  | ||||
| # and here's the full list | ||||
| ALL_LIB_FILES = $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES) $(PJSIP_LIB_FILES) $(RESAMPLE_LIB_FILE) | ||||
|  | ||||
| # Assuming that since you're doing an out-of-tree build you're modifying | ||||
| # the pjproject source files, we need to create dependencies between | ||||
| # the libraries and their respective source files.  Pjproject does | ||||
| # create dependency files if you run 'make dep' but those files include | ||||
| # the system include files and the paths are relative to the lib's | ||||
| # "build" directory.  Neither really works for us. | ||||
| # So... | ||||
| # We create our own "astdep" files with dependency paths relative | ||||
| # to "this" directory and strip out all the system includes. | ||||
| # The dependency_utils script does all the heavy lifting. | ||||
| # | ||||
| # REMINDER: None of this gets invoked unless you're doing an out-of-tree | ||||
| # pjproject build. | ||||
|  | ||||
| ifdef PJPROJECT_BUNDLED_OOT | ||||
|     ALL_PJDEP_FILES = $(shell TARGET_NAME=$(TARGET_NAME) ./dependency_utils getpjdepname $(ALL_LIB_FILES)) | ||||
|     ALL_ASTDEP_FILES = $(ALL_PJDEP_FILES:.depend=.astdep) | ||||
|  | ||||
|     $(ALL_PJDEP_FILES): build.mak | ||||
| 		$(ECHO_PREFIX) Generating pjproject dependency file $(@F) | ||||
| 		$(CMD_PREFIX) $(MAKE) -C $(@D) dep $(REALLY_QUIET) | ||||
|  | ||||
|     $(ALL_ASTDEP_FILES): %.astdep: %.depend | ||||
| 		$(ECHO_PREFIX) Generating asterisk dependency file $(@F) | ||||
| 		$(CMD_PREFIX) ./dependency_utils gendepfile $< | ||||
|     ifeq ($(SPECIAL_TARGETS),) | ||||
|         ifneq ($(ALL_ASTDEP_FILES),) | ||||
|             include $(ALL_ASTDEP_FILES) | ||||
|             depends: $(ALL_ASTDEP_FILES) | ||||
|         endif | ||||
|     endif | ||||
| endif | ||||
|  | ||||
| # resample's a little odd in that it's build directory is one directory | ||||
| # level down from the other libraries.  We set the RESAMPLE_OPTS | ||||
| # variable for it then let the ALL_LIB_FILE build rules take over. | ||||
| $(RESAMPLE_LIB_FILE): RESAMPLE_OPTS=/resample all | ||||
|  | ||||
| .PRECIOUS: $(ALL_LIB_FILES) | ||||
|  | ||||
| $(ALL_LIB_FILES): BUILD_DIR=$(dir $(@D)) | ||||
| $(ALL_LIB_FILES): source/build.mak source/pjlib/include/pj/config_site.h | ||||
| 	$(ECHO_PREFIX) Compiling $(@F) | ||||
| 	$(CMD_PREFIX) ( $(MAKE) -C $(BUILD_DIR)build$(if $(RESAMPLE_OPTS),$(RESAMPLE_OPTS), $(@F)) >/dev/null ) $(if $(PJPROJECT_BUNDLED_OOT),2>&1 | ($(GREP) -E -v "^(r - output|ar:)" || : ),$(REALLY_QUIET)) | ||||
|  | ||||
| pjproject.symbols: $(ALL_LIB_FILES) | ||||
| 	$(ECHO_PREFIX) Generating symbols | ||||
| 	$(CMD_PREFIX) $(NM) -Pog $(ALL_LIB_FILES) | $(SED) -n -E -e "s/.+: ([_]?[pP][jJ][^ ]+) .+/\1/gp" | sort -u > pjproject.symbols | ||||
| @@ -170,21 +217,22 @@ pjproject.symbols: $(ALL_LIB_FILES) | ||||
| source/pjsip-apps/src/asterisk_malloc_debug.c: patches/asterisk_malloc_debug.c | ||||
| 	$(ECHO_PREFIX) Copying $< to $@ | ||||
| 	$(CMD_PREFIX) cp -f $< $@ | ||||
| 	$(CMD_PREFIX) mkdir source/pjsip-apps/lib/ | ||||
| 	-$(CMD_PREFIX) mkdir source/pjsip-apps/lib/ $(REALLY_QUIET) | ||||
|  | ||||
| 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 | source/pjlib/include/pj/config_site.h source/pjlib/include/pj/asterisk_malloc_debug.h | ||||
| 	$(ECHO_PREFIX) Compiling asterisk debug malloc stubs | ||||
| 	$(CMD_PREFIX) $(CC) -fPIC  $(PJ_CFLAGS) -c $< -o $@ | ||||
|  | ||||
| source/pjsip-apps/lib/libasterisk_malloc_debug.a: source/pjsip-apps/lib/asterisk_malloc_debug.o | ||||
| 	$(ECHO_PREFIX) Creating archive $(@F) | ||||
| 	$(CMD_PREFIX) ar qs $@ $< >/dev/null 2>&1 | ||||
| 	$(CMD_PREFIX) ar qs $@ $< $(REALLY_QUIET) | ||||
|  | ||||
| $(apps): APP = $(filter pj%,$(subst -, ,$(notdir $@))) | ||||
| $(apps): LDFLAGS += $(MALLOC_DEBUG_LDFLAGS) | ||||
| $(apps): $(MALLOC_DEBUG_LIBS) pjproject.symbols $(APP_THIRD_PARTY_LIB_FILES) | ||||
| $(apps): $(MALLOC_DEBUG_LIBS) pjproject.symbols | ||||
| 	$(ECHO_PREFIX) Compiling $(APP) | ||||
| 	$(CMD_PREFIX) +$(MAKE) -C source/pjsip-apps/build $(filter pj%,$(subst -, ,$(notdir $@))) $(REALLY_QUIET) | ||||
| 	$(CMD_PREFIX) +$(MAKE) -C source/pjsip-apps/build $(APP) $(REALLY_QUIET) | ||||
| 	$(CMD_PREFIX) touch $@ | ||||
|  | ||||
| source/pjsip-apps/src/python/_pjsua.o: source/pjsip-apps/src/python/_pjsua.c $(apps) | ||||
| 	$(ECHO_PREFIX) Compiling python bindings | ||||
| @@ -210,19 +258,33 @@ ifneq ($(findstring _pjsua.so,$(TARGETS)),) | ||||
| 	$(CMD_PREFIX) $(INSTALL) -m 644 source/pjsip-apps/src/python/pjsua.py "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/" | ||||
| endif | ||||
|  | ||||
| all: _all | ||||
|  | ||||
| uninstall: | ||||
| 	$(ECHO_PREFIX) Uninstalling apps and python bindings | ||||
| 	$(CMD_PREFIX) rm -rf "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject" | ||||
|  | ||||
| clean: | ||||
| 	$(ECHO_PREFIX) Cleaning | ||||
| 	+-$(CMD_PREFIX) test -d source && ($(SUBMAKE) -C source clean || : ;\ | ||||
| 		rm -rf source/pjsip-apps/bin/* || : ;\ | ||||
| 		find source -name *.a | xargs rm -rf  ;\ | ||||
| 		find source -name *.o | xargs rm -rf  ;\ | ||||
| 		find source -name *.so  | xargs rm -rf ; ) || : | ||||
| 	-$(CMD_PREFIX) rm -rf pjproject.symbols | ||||
| 	+-$(CMD_PREFIX) {\ | ||||
| 		if [ -d source ] ; then  \ | ||||
| 			$(SUBMAKE) -C source clean ;\ | ||||
| 			rm -rf source/pjsip-apps/bin/* ;\ | ||||
| 			$(FIND) source/ '(' -name *.a -or -name *.o -or -name *.so ')' -delete ;\ | ||||
| 		fi ;\ | ||||
| 		rm -rf pjproject.symbols ;\ | ||||
| 		} $(REALLY_QUIET) || : | ||||
|  | ||||
| distclean: | ||||
| distclean: clean | ||||
| 	$(ECHO_PREFIX) Distcleaning | ||||
| 	-$(CMD_PREFIX) rm -rf source pjproject.symbols pjproject-*.tar.bz2 build.mak .rebuild_needed | ||||
| 	+-$(CMD_PREFIX) {\ | ||||
| 		rm -rf build.mak .rebuild_needed ;\ | ||||
| 		if [ "x$(PJPROJECT_BUNDLED_OOT)" = "x" -a ! -d source/.git ] ; then \ | ||||
| 			rm -rf source pjproject-*.tar.bz2 ;\ | ||||
| 		else \ | ||||
| 			$(SUBMAKE) -C source distclean ;\ | ||||
| 			rm -rf source/build.mak source/user.mak ;\ | ||||
| 			$(FIND) source/ -name '*asterisk_malloc_debug*' -delete ;\ | ||||
| 			$(FIND) source/ '(' -name '.*.depend' -or -name '.*.astdep' ')' -delete ;\ | ||||
| 		fi \ | ||||
| 		} $(REALLY_QUIET) || : | ||||
|   | ||||
							
								
								
									
										2
									
								
								third-party/pjproject/Makefile.rules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								third-party/pjproject/Makefile.rules
									
									
									
									
										vendored
									
									
								
							| @@ -37,7 +37,7 @@ PJPROJECT_CONFIG_OPTS = $(PJPROJECT_CONFIGURE_OPTS) --prefix=/opt/pjproject \ | ||||
| 	--disable-ipp \ | ||||
| 	--disable-libwebrtc \ | ||||
| 	--without-external-pa \ | ||||
| 	--without-external-srtp | ||||
| 	--with-external-srtp | ||||
|  | ||||
| ifneq ($(AST_DEVMODE),yes) | ||||
|     PJPROJECT_CONFIG_OPTS += --disable-resample --disable-g711-codec | ||||
|   | ||||
							
								
								
									
										213
									
								
								third-party/pjproject/README-hacking.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										213
									
								
								third-party/pjproject/README-hacking.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,213 @@ | ||||
| # Hacking on PJProject | ||||
|  | ||||
| ## Intro | ||||
| There are times when you need to troubleshoot issues with bundled pjproject | ||||
| or add new features that need to be pushed upstream but... | ||||
|  | ||||
| * The source directory created by extracting the pjproject tarball is not | ||||
| scanned for code changes so you have to keep forcing rebuilds. | ||||
| * The source directory isn't a git repo so you can't easily create patches, | ||||
| do git bisects, etc. | ||||
| * Accidentally doing a make distclean will ruin your day by wiping out the | ||||
| source directory, and your changes. | ||||
| * etc. | ||||
|  | ||||
| Well No More! | ||||
|  | ||||
| You can now replace the `source` directory that's normally created | ||||
| by the Makefile extracting the tarball, with a symlink to a "real" pjproject | ||||
| git clone.  The Makefile will now detect that `source` is a real pjproject | ||||
| repo and enable some advanced behaviors (and disable others). | ||||
|  | ||||
| ## Setup | ||||
|  | ||||
| Let's assume you have an Asterisk development environment like so: | ||||
|  | ||||
| ```plain | ||||
| ~/dev/asterisk/ | ||||
|   asterisk/ | ||||
|     .git/ | ||||
|     addons/ | ||||
|     ... | ||||
|     third-party/ | ||||
|       jansson/ | ||||
|       pjproject/ | ||||
| ``` | ||||
|  | ||||
| ### Cloning pjproject | ||||
|  | ||||
| Start by cloning a pjproject repository next to your asterisk repository. | ||||
| The source of the clone depends on whether you anticipate pushing changes | ||||
| back upstream or not.  If you already have a good pjproject repository clone, | ||||
| read this section anyway but you probably won't have to do anything. | ||||
|  | ||||
| * For pushing upstream: (Community Contributors) | ||||
|     * Make sure you have the proper ssh keys added to your github account | ||||
|     so you can push changes. | ||||
|     * Navigate to https://github.com/pjsip/pjproject | ||||
|     * Click the "Fork" button to create a fork under your own username. | ||||
|  | ||||
| Back on your own machine... | ||||
|  | ||||
| ```plain | ||||
| $ cd ~/dev/asterisk | ||||
| $ git clone git@github.com:<yourusername>/pjproject | ||||
| ``` | ||||
|  | ||||
| * For pushing upstream: (Asterisk Core Team Developers) | ||||
| Asterisk Core Team Developers should clone the fork we have in our own | ||||
| Asterisk github organization. | ||||
|  | ||||
| ```plain | ||||
| $ cd ~/dev/asterisk | ||||
| $ git clone git@github.com:asterisk/pjproject | ||||
| ``` | ||||
|  | ||||
| Regardless of how you got your repo, you'll need to create an "upstream" | ||||
| remote that points to the original pjproject repo. | ||||
|  | ||||
| ```plain | ||||
| $ cd pjproject | ||||
| $ git remote add upstream https://github.com/pjsip/pjproject | ||||
| ``` | ||||
|  | ||||
| If you're just troubleshooting and don't plan on pushing changes upstream, | ||||
| you can just clone directly from the upstream pjproject repo. | ||||
|  | ||||
| ```plain | ||||
| $ cd ~/dev/asterisk | ||||
| $ git clone https://github.com/pjsip/pjproject | ||||
| ``` | ||||
|  | ||||
| Your directory structure should now look something like: | ||||
|  | ||||
| ```plain | ||||
| ~/dev/asterisk/ | ||||
|   asterisk/ | ||||
|     .git/ | ||||
|     addons/ | ||||
|     ... | ||||
|     third-party/ | ||||
|       jansson/ | ||||
|       pjproject/ | ||||
|   pjproject/ | ||||
|     .git | ||||
|     pjlib/ | ||||
|     ... | ||||
| ``` | ||||
|  | ||||
| ### Adjusting Asterisk | ||||
| Start with a "distcleaned" asterisk work tree then in the | ||||
| asterisk/third-party/pjproject directory, create a symlink to the pjproject | ||||
| clone you just created. | ||||
|  | ||||
| ```plain | ||||
| $ cd ~/dev/asterisk/asterisk/ | ||||
| $ make distclean | ||||
| $ cd third-party/pjproject | ||||
| $ ln -s ../../../pjproject source | ||||
| ``` | ||||
| The "source" directory is now a relative symlink to your pjproject | ||||
| clone so your directory structure should now look something like: | ||||
|  | ||||
| ```plain | ||||
| ~/dev/asterisk/ | ||||
|   asterisk/ | ||||
|     .git/ | ||||
|     addons/ | ||||
|     ... | ||||
|     third-party/ | ||||
|       jansson/ | ||||
|       pjproject/ | ||||
|         source -> ../../../pjproject | ||||
|   pjproject/ | ||||
|     .git | ||||
|     pjlib/ | ||||
|     ... | ||||
| ``` | ||||
|  | ||||
| ### Adjust pjproject git ignores. | ||||
| One final step is required to keep your pjproject repo from being dirtied | ||||
| by the build process.  Add the following lines to your pjproject (not asterisk) | ||||
| repo's .git/info/exclude file... | ||||
|  | ||||
| ```plain | ||||
| **/*.astdep | ||||
| **/*asterisk_malloc_debug* | ||||
| **/_pjsua.o | ||||
| **/_pjsua.so | ||||
| ``` | ||||
| Don't add these to the top-level .gitignore file!  If you do, they'll become | ||||
| part of any change you submit upstream. | ||||
|  | ||||
| ## Usage | ||||
|  | ||||
| Just run `./configure` and `make` as you would for any other asterisk build. | ||||
| When you make changes to pjproject source files, they'll be automatically | ||||
| recompiled the next time you build asterisk. | ||||
|  | ||||
| You can do git operations in the pjproject repo while it's still symlinked | ||||
| into the asterisk source.  Assuming you made the proper changes to | ||||
| pjproject's .git/info/exclude file, a commit in the pjproject repo _should_ contain | ||||
| only the changes you made. | ||||
|  | ||||
| You can run `make` commands directly in third-party/pjproject  The only | ||||
| requirement is that an asterisk top-level `configure` had to have been | ||||
| run at least once. | ||||
|  | ||||
| You can always revert to standard bundled pjproject by running an asterisk | ||||
| top-level `make distclean`, removing the third-party/pjproject/source | ||||
| symlink, and re-running a top-level `configure`.  That will download and | ||||
| extract the pjproject tarball to the `third-party/pjproject/source` | ||||
| directory as usual. | ||||
|  | ||||
| ### Notes | ||||
|  | ||||
| While your pjproject repo is symlinked into the asterisk source tree, | ||||
| you should not run `configure` directly in the pjproject repo.  You won't get | ||||
| the proper options applied to be compatible with Asterisk.  You can run | ||||
| `make` though. | ||||
|  | ||||
| Although asterisk_malloc_debug and site_config.h are applied to the pjproject | ||||
| repo, No patches from the `third-party/pjproject/patches` directory are | ||||
| applied.  Since you're probably working off the pjproject master branch, | ||||
| the patches aren't needed.  Also, applying the patches would contaminate | ||||
| the pjproject repo and you wouldn't be able to do a clean commit there. | ||||
|  | ||||
| You'll see compile and/or link warnings you wouldn't see with a normal | ||||
| bundled build. | ||||
|  | ||||
|  | ||||
| ## How it works | ||||
|  | ||||
| When an asterisk top-level `configure` is run, `third-party/pjproject/configure.m4 ` | ||||
| checks whether `third-party/pjproject/source` is a symlink or is a git | ||||
| repository.  If neither are true, the build isn't considered "out-of-tree" | ||||
| and the normal pjproject bundled process occurs. | ||||
| If either is true, it sets `PJPROJECT_BUNDLED_OOT=yes` for the Makefiles. | ||||
|  | ||||
| When a `make` is done, either from top-level asterisk or from the | ||||
| third-party/pjproject directory, it checks `PJPROJECT_BUNDLED_OOT` | ||||
| and if set to yes it... | ||||
|  | ||||
|     * Alters the behavior of `clean` and `distclean` to just run | ||||
|     pjproject's `clean` or `distclean` targets and to NOT remove the | ||||
|     `source` directory or symlink as it would normally do. | ||||
|  | ||||
|     * Generates `astdep` dependency files in the pjproject source tree | ||||
|     if they don't already exist.  These are git-ignored by the edit | ||||
|     to pjproject's `.git/info/exclude` done above.  You'll | ||||
|     see new progress messages during the make as the astdep files are | ||||
|     built. | ||||
|  | ||||
|     * Copies asterisk_malloc_debug.c, asterisk_malloc_debug.h and | ||||
|     config_site.h from the patches directory into the pjproject source | ||||
|     tree.  These are also git-ignored by the edit to pjproject's | ||||
|     `.git/info/exclude` file. | ||||
|  | ||||
|     * Compiles only the out-of-date source files into their respective | ||||
|     libpj libraries.  That in turn triggers the asterisk top-level | ||||
|     make to re-link main/libasteriskpj.so. | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										25
									
								
								third-party/pjproject/configure.m4
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										25
									
								
								third-party/pjproject/configure.m4
									
									
									
									
										vendored
									
									
								
							| @@ -47,6 +47,14 @@ AC_DEFUN([_PJPROJECT_CONFIGURE], | ||||
| 		if test "${GREP}" = ":" ; then | ||||
| 			AC_MSG_ERROR(grep is required to build bundled pjproject) | ||||
| 		fi | ||||
| 		if test "${FIND}" = ":" ; then | ||||
| 			AC_MSG_ERROR(find is required to build bundled pjproject) | ||||
| 		fi | ||||
| 		if test "x${AST_DEVMODE}" != "x" ; then | ||||
| 			if test "${REALPATH}" = ":" ; then | ||||
| 				AC_MSG_ERROR(realpath is required to build bundled pjproject in dev mode) | ||||
| 			fi | ||||
| 		fi | ||||
|  | ||||
| 		AC_ARG_VAR([PJPROJECT_CONFIGURE_OPTS],[Additional configure options to pass to bundled pjproject]) | ||||
| 		this_host=$(./config.sub $(./config.guess)) | ||||
| @@ -74,11 +82,19 @@ AC_DEFUN([_PJPROJECT_CONFIGURE], | ||||
| 			esac | ||||
| 		fi | ||||
|  | ||||
| 		export TAR PATCH SED NM EXTERNALS_CACHE_DIR AST_DOWNLOAD_CACHE DOWNLOAD_TO_STDOUT DOWNLOAD_TIMEOUT DOWNLOAD MD5 CAT CUT GREP | ||||
| 		# Determine if we're doing an out-of-tree build... | ||||
| 		AH_TEMPLATE(m4_bpatsubst([[HAVE_PJPROJECT_BUNDLED_OOT]], [(.*)]), [Define if doing a bundled pjproject out-of-tree build.]) | ||||
| 		if test -L ${PJPROJECT_DIR}/source -o -d ${PJPROJECT_DIR}/source/.git ; then | ||||
| 			AC_DEFINE([HAVE_PJPROJECT_BUNDLED_OOT], 1) | ||||
| 			PJPROJECT_BUNDLED_OOT=yes | ||||
| 		fi | ||||
|  | ||||
| 		export TAR PATCH SED NM EXTERNALS_CACHE_DIR AST_DOWNLOAD_CACHE DOWNLOAD_TO_STDOUT DOWNLOAD_TIMEOUT DOWNLOAD MD5 CAT CUT GREP FIND REALPATH | ||||
| 		export NOISY_BUILD AST_DEVMODE | ||||
| 		${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} \ | ||||
| 			PJPROJECT_CONFIGURE_OPTS="$PJPROJECT_CONFIGURE_OPTS" \ | ||||
| 			EXTERNALS_CACHE_DIR="${EXTERNALS_CACHE_DIR:-${AST_DOWNLOAD_CACHE}}" \ | ||||
| 			PJPROJECT_BUNDLED_OOT="${PJPROJECT_BUNDLED_OOT}" \ | ||||
| 			configure | ||||
| 		if test $? -ne 0 ; then | ||||
| 			AC_MSG_RESULT(failed) | ||||
| @@ -88,7 +104,11 @@ AC_DEFUN([_PJPROJECT_CONFIGURE], | ||||
|  | ||||
| 		AC_MSG_CHECKING(for bundled pjproject) | ||||
|  | ||||
| 		PJPROJECT_INCLUDE=$(${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} PJPROJECT_CONFIGURE_OPTS="$PJPROJECT_CONFIGURE_OPTS" EXTERNALS_CACHE_DIR="${EXTERNALS_CACHE_DIR:-${AST_DOWNLOAD_CACHE}}" echo_cflags) | ||||
| 		PJPROJECT_INCLUDE=$(${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} \ | ||||
| 			PJPROJECT_CONFIGURE_OPTS="$PJPROJECT_CONFIGURE_OPTS" \ | ||||
| 			EXTERNALS_CACHE_DIR="${EXTERNALS_CACHE_DIR:-${AST_DOWNLOAD_CACHE}}" \ | ||||
| 			PJPROJECT_BUNDLED_OOT="${PJPROJECT_BUNDLED_OOT}" \ | ||||
| 			echo_cflags) | ||||
| 		PJPROJECT_CFLAGS="$PJPROJECT_INCLUDE" | ||||
| 		PBX_PJPROJECT=1 | ||||
|  | ||||
| @@ -113,6 +133,7 @@ AC_DEFUN([_PJPROJECT_CONFIGURE], | ||||
| 		AC_DEFINE([HAVE_PJPROJECT_ON_VALID_ICE_PAIR_CALLBACK], 1, [Define if your system has the on_valid_pair pjnath callback.]) | ||||
|  | ||||
| 		AC_SUBST([PJPROJECT_BUNDLED]) | ||||
| 		AC_SUBST([PJPROJECT_BUNDLED_OOT]) | ||||
| 		AC_SUBST([PJPROJECT_DIR]) | ||||
| 		AC_SUBST([PBX_PJPROJECT]) | ||||
| 		AC_SUBST([PJPROJECT_LIB]) | ||||
|   | ||||
							
								
								
									
										96
									
								
								third-party/pjproject/dependency_utils
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										96
									
								
								third-party/pjproject/dependency_utils
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,96 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| [ "x${SED}" = "x" ] && SED=sed | ||||
| [ "x${GREP}" = "x" ] && GREP=grep | ||||
| [ "x${REALPATH}" = "x" ] && REALPATH=realpath | ||||
| [ "x${DIRNAME}" = "x" ] && DIRNAME=dirname | ||||
| [ "x${BASENAME}" = "x" ] && BASENAME=basename | ||||
| [ "x${GREP}" = "x" ] && GREP=grep | ||||
| if [ "x${TARGET_NAME}" = "x" ] ; then | ||||
| 	if [ ! -f build.mak ] ; then | ||||
| 		exit 0; | ||||
| 	fi | ||||
| 	TARGET_NAME=$(${SED} -n -r -e "s/export\s+TARGET_NAME\s*:=\s*(.*)/\1/gp" build.mak) | ||||
| fi | ||||
|  | ||||
| getlibname() { | ||||
| 	dep="$1" | ||||
| 	libdir=$(${DIRNAME} $(${DIRNAME} "${dep}"))/lib | ||||
| 	depname=$(${BASENAME} "${dep}") | ||||
| 	depprefix="${depname%%-${TARGET_NAME}.depend}" | ||||
| 	case ${depprefix} in | ||||
| 		.pjlib) | ||||
| 			libfile=libpj | ||||
| 			;; | ||||
| 		.pjsua-lib) | ||||
| 			libfile=libpjsua | ||||
| 			;; | ||||
| 		.*) | ||||
| 			libfile=lib${depprefix#.*} | ||||
| 			;; | ||||
| 	esac | ||||
| 	echo "${libdir}/${libfile}-${TARGET_NAME}.a" | ||||
| } | ||||
|  | ||||
| gendepfile() { | ||||
| 	pjdf="$1" | ||||
| 	astdf="${pjdf%*.depend}.astdep" | ||||
| 	dirname=$(${DIRNAME} "${astdf}") | ||||
| 	lines=$(grep -E -o -- "[.][.]/[^ ]+" "${pjdf}" | sort -u | wc -l) | ||||
| 	libname=$(getlibname "${pjdf}") | ||||
| 	backslash="\\" | ||||
| 	echo "${libname}: ${backslash}" >"${astdf}" | ||||
| 	for dep in $(grep -E -o -- "[.][.]/[^ ]+" "${pjdf}" | sort -u) ; do | ||||
| 		( echo "${dep}" | grep -Eq "(test|/bin/)" ; ) && continue | ||||
| 		newdep=$( cd "${dirname}" ; ${REALPATH} -L --relative-to=../../ "${dep}" ; ) | ||||
| 		lines=$(( ${lines} - 1 )) | ||||
| 		if [ ${lines} -eq 0 ] ; then | ||||
| 			echo "source/${newdep}" >>"${astdf}" | ||||
| 		else | ||||
| 			echo "source/${newdep} ${backslash}" >>"${astdf}" | ||||
| 		fi | ||||
| 	done | ||||
| 	echo >>"${astdf}" | ||||
| } | ||||
|  | ||||
| getpjdepname () { | ||||
| 	lib="$1" | ||||
| 	builddir=$(${DIRNAME} $(${DIRNAME} "${lib}"))/build | ||||
| 	libname=$(${BASENAME} "${lib}") | ||||
| 	libprefix="${libname%%-${TARGET_NAME}.a}" | ||||
| 	nolib=$(echo "${libprefix}" | ${SED} -r -e "s@^lib@@g") | ||||
| 	case ${nolib} in | ||||
| 		pj) | ||||
| 			depfile=.pjlib | ||||
| 			;; | ||||
| 		pjsua) | ||||
| 			depfile=.pjsua-lib | ||||
| 			;; | ||||
| 		resample) | ||||
| 			depfile=resample/.libresample | ||||
| 			;; | ||||
| 		*) | ||||
| 			depfile=.${nolib} | ||||
| 			;; | ||||
| 	esac | ||||
| 	echo "${builddir}/${depfile}-${TARGET_NAME}.depend" | ||||
| } | ||||
|  | ||||
| case $1 in | ||||
| 	getpjdepname) | ||||
| 		shift | ||||
| 		for lib in $@ ; do getpjdepname "${lib}" ; done | ||||
| 		;; | ||||
| 	gendepfile) | ||||
| 		shift | ||||
| 		for dep in $@ ; do gendepfile "${dep}" ; done | ||||
| 		;; | ||||
| 	getlibname) | ||||
| 		shift | ||||
| 		for dep in $@ ; do getlibname "${dep}" ; done | ||||
| 		;; | ||||
| 	*) | ||||
| 		echo Invalid command | ||||
| 		exit 1 | ||||
| 		;; | ||||
| esac | ||||
		Reference in New Issue
	
	Block a user