Index: branches/5.2.x/tools/build/targets/common.xml
===================================================================
--- branches/5.2.x/tools/build/targets/common.xml	(revision 16820)
+++ branches/5.2.x/tools/build/targets/common.xml	(revision 16821)
@@ -1,216 +1,218 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 ### Requirements
 
 Using the template requires a range of tools packages present. They can be
 installed as follows:
 
 	Install packages:
 	composer global require sebastian/phpcpd:~2.0 phploc/phploc:~2.1 phpmd/phpmd:^2.14 phing/phing:~2.1 squizlabs/php_codesniffer:^3.0
 
 	Add following to the your ".bashrc" file:
 	export PATH="$PATH:$HOME/.composer/vendor/bin"
 -->
 <project name="inc_common" default="build">
 	<import file="targets/db.xml"/>
 	<import file="targets/deploy.xml"/>
 	<import file="targets/folders.xml"/>
 
 	<php function="ini_set">
 		<param value="memory_limit"/>
 		<param value="-1"/>
 	</php>
 
 	<!-- AutoLoader is needed to make PhpLoc (installed globally via Composer) work. -->
 	<if>
 		<available file="${env.HOME}/.composer/vendor/autoload.php" type="file"/>
 		<then>
 			<autoloader autoloaderpath="${env.HOME}/.composer/vendor/autoload.php"/>
 		</then>
 	</if>
 
 	<target name="build" description="Builds a project" depends="init,verify,analyze"/>
 
 	<target name="build-parallel" description="Builds a project (long targets executed in parallel)" depends="init,tools-parallel,phpunit"/>
 
 	<target name="tools-parallel" description="Run tools in parallel">
 		<parallel threadCount="2">
 			<sequential>
 				<phingcall target="pdepend"/>
 				<phingcall target="phpmd-ci"/>
 			</sequential>
 
 			<phingcall target="phpcpd"/>
 			<phingcall target="phpcs-ci"/>
 			<phingcall target="phploc"/>
 			<phingcall target="phpdoc"/>
 		</parallel>
 	</target>
 
 	<!-- ### Verify code consistency
 
 	Make sure that our code is clean and functional. -->
 	<target name="verify" description="Verify code consistency" depends="init"/>
 	<!--<target name="verify" description="Verify code consistency" depends="init,phpunit"/>-->
 
 	<!-- ### Analyze code
 
 	Perform static analysis of the code to generate statistics, identify potential
 	problems and opportunities for refactorings and make sure that the code
 	complies with coding standards. -->
 	<target name="analyze" description="Analyze code" depends="init,phploc,phpmd-ci,phpcpd,phpcs-ci"/>
 	<!--<target name="analyze" description="Analyze code" depends="init,phploc,pdepend,phpmd-ci,phpcpd,phpcs-ci"/>-->
 
 	<!-- ### Generate documentation
 
 	Generate HTML documentation and code browser for the project. -->
 	<target name="docs" description="Generate documentation" depends="init,phpdoc" />
 
 	<!-- ### PHP linting
 
 	Check files for syntax errors. -->
 	<target name="lint" description="Perform syntax check of sourcecode files" depends="folders-create">
 		<phplint haltonfailure="true" deprecatedAsError="false" cachefile="${build.cache.dir}/phplint.txt">
 			<fileset refid="php.files"/>
 		</phplint>
 	</target>
 
 	<!-- ### Generate code statistics
 
 	Measures the size of the project using
 	[phploc](http://sebastianbergmann.github.com/phploc/) and generates
 	statistics. -->
 	<target name="phploc" description="Measure project size using PHPLOC" depends="init">
 		<phploc reportType="csv" reportName="phploc" reportDirectory="${build.logs.dir}">
 			<fileset refid="php.files"/>
 		</phploc>
 	</target>
 
 	<target name="pdepend" description="Calculate software metrics using PHP_Depend" depends="init">
 		<exec executable="pdepend" passthru="true">
 			<arg value="--jdepend-xml=${build.logs.dir}/jdepend.xml"/>
 			<arg value="--jdepend-chart=${build.pdepend.dir}/dependencies.svg"/>
 			<arg value="--overview-pyramid=${build.pdepend.dir}/overview-pyramid.svg"/>
 			<arg value="--ignore=${pdepend.exclude}"/>
 			<arg path="${scan.dir}"/>
 		</exec>
 	</target>
 
 	<!-- ### Detect code mess
 
 	Uses [PHPMD](http://phpmd.org/) to detect code mess and look for potential
 	problems. -->
 
 	<target name="phpmd-ci" description="Perform project mess detection using PHPMD (creates a log file for the CI server)" depends="init">
 		<fail message="Please create own 'phpmd-ci' task using 'parallel' and 'phpmd-ci-inc' tasks." />
 	</target>
 
 	<target name="phpmd-ci-inc">
 		<exec executable="phpmd" passthru="true" dir="${base.dir}">
 			<arg path="${param.include}"/>
 			<arg value="xml"/>
 			<arg value="${build.config.dir}/inc/phpmd.xml"/>
 			<arg value="--reportfile"/>
 			<arg value="${build.logs.dir}/${param.report.file}"/>
 			<arg value="--suffixes"/>
 			<arg value="php"/>
 			<arg value="--exclude"/>
 			<arg value="${param.exclude}"/>
 			<arg value="--cache"/>
 			<arg value="--cache-file"/>
 			<arg value="${build.cache.dir}/${param.cache.file}"/>
 		</exec>
 	</target>
 
 	<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer (print human readable output)" depends="init">
 		<exec executable="phpcs" passthru="true">
 			<arg value="--standard=${vendor.dir}/aik099/coding-standard/CodingStandard"/>
 			<arg value="-wps"/>
 			<arg value="--cache"/>
 			<arg value="--encoding=UTF-8"/>
 			<arg value="--extensions=php"/>
 			<arg value="-d"/>
 			<arg value="memory_limit=-1"/>
 			<arg path="${scan.dir}"/>
 		</exec>
 	</target>
 
 	<target name="phpcbf" description="Fixes coding standard violations using PHP_CodeSniffer" depends="init">
 		<exec executable="phpcbf" passthru="true">
 			<arg value="--standard=${vendor.dir}/aik099/coding-standard/CodingStandard"/>
 			<arg value="-wps"/>
 			<arg value="--encoding=UTF-8"/>
 			<arg value="--extensions=php"/>
 			<arg value="-d"/>
 			<arg value="memory_limit=-1"/>
 			<arg path="${scan.dir}"/>
 		</exec>
 	</target>
 
 	<target name="phpcs-ci" description="Find coding standard violations using PHP_CodeSniffer (creates a log file for the CI server)" depends="init">
 		<exec executable="phpcs" passthru="true">
 			<arg value="--report=checkstyle"/>
 			<arg value="--report-file=${build.logs.dir}/checkstyle.xml"/>
 			<arg value="--standard=${vendor.dir}/aik099/coding-standard/CodingStandard"/>
 			<arg value="-wp"/>
 			<arg value="--cache"/>
 			<arg value="--encoding=UTF-8"/>
 			<arg value="--extensions=php"/>
 			<arg value="-d"/>
 			<arg value="memory_limit=-1"/>
 			<arg path="${scan.dir}"/>
 		</exec>
 	</target>
 
 	<!-- ### Detect potential copy/pasting
 
 	Uses [phpcpd](https://github.com/sebastianbergmann/phpcpd) to detect duplicate
 	code. This indicates potential refactorings.-->
 	<target name="phpcpd" description="Find duplicate code using PHPCPD" depends="init">
 		<exec command="which phpcpd" outputProperty="phpcpd_binary"/>
-		<exec executable="php" passthru="true">
+		<exec executable="${php.binary}" passthru="true">
 			<arg value="-d memory_limit=-1"/>
 			<arg value="${phpcpd_binary}"/>
 			<arg value="--log-pmd=${build.logs.dir}/pmd-cpd.xml"/>
 			<arg value="--progress"/>
 			<arg line="--names-exclude=*_config.php ${phpcpd.exclude}"/>
 			<arg path="${scan.dir}"/>
 		</exec>
 	</target>
 
 	<!-- ### Generate documentation -->
 	<!-- #### Generate API Documentation
 
 	Uses [phpDocumentor](http://www.phpdoc.org/) to generate documentation. -->
 	<target name="phpdoc" description="Generate API documentation using phpdoc" depends="init">
 		<phpdoc2 title="API Documentation" destdir="${build.api.dir}" template="responsive" quiet="true">
 			<fileset refid="php.files"/>
 		</phpdoc2>
 	</target>
 
 	<target name="phpunit" description="Run tests with PHPUnit" depends="init">
 		<exec executable="phpunit" logoutput="true" checkreturn="true">
 			<arg value="--configuration"/>
 			<arg path="${build.config.dir}/phpunit.xml"/>
 			<arg value="--testsuite"/>
 			<arg value="custom"/>
 		</exec>
 	</target>
 
 	<target name="init" depends="create-aliases,folders-create,deploy-ci" description="Prepare for build">
 	</target>
 
 	<target name="create-aliases" description="Creating directory aliases" hidden="true">
+		<php expression="PHP_BINARY" returnProperty="php.binary"/>
+
 		<property name="pdo.dsn.without.db" value="mysql:host=${db.host}"/>
 		<property name="pdo.dsn" value="${pdo.dsn.without.db};dbname=${db.name}"/>
 
 		<property name="build.config.dir" value="${base.dir}/tools/build"/>
 		<property name="build.dir" value="${base.dir}/build"/>
 		<!--<property name="build.api.dir" value="${build.dir}/api"/>-->
 		<!--<property name="build.coverage.dir" value="${build.dir}/coverage"/>-->
 		<property name="build.logs.dir" value="${build.dir}/logs"/>
 		<property name="build.cache.dir" value="${build.dir}/cache"/>
 		<!--<property name="build.pdepend.dir" value="${build.dir}/pdepend"/>-->
 		<property name="vendor.dir" value="${base.dir}/vendor"/>
 	</target>
 </project>
Index: branches/5.2.x/tools/build/targets/deploy.xml
===================================================================
--- branches/5.2.x/tools/build/targets/deploy.xml	(revision 16820)
+++ branches/5.2.x/tools/build/targets/deploy.xml	(revision 16821)
@@ -1,44 +1,44 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project name="inc_deploy" default="build">
 	<target name="deploy-ci" description="Deployment tasks, that are required after SVN checkout" depends="lint,create-aliases">
 		<property name="tools.dir" value="${base.dir}/tools"/>
 
 		<echo msg="Fixing shell scripts permissions under '/tools' folder"/>
 		<chmod mode="0755" verbose="true" failonerror="true">
 			<fileset dir="${tools.dir}">
 				<include name="*.sh"/>
 			</fileset>
 		</chmod>
 
 		<echo msg="Fixing '/system' folder permissions"/>
 		<exec dir="${tools.dir}" command="./fix_perms.sh" logoutput="true"/>
 
 		<echo msg="Removing compiled templates under '/system/cache' folder"/>
 		<exec dir="${tools.dir}" command="./clear_cache.sh" logoutput="true"/>
 
 		<composer command="install" composer="/usr/local/bin/composer">
 			<arg value="--working-dir"/>
 			<arg path="${base.dir}"/>
 			<arg value="--ansi"/>
 		</composer>
 
 		<if>
 			<available file="${base.dir}/system/build-schema.sql" type="file"/>
 			<then>
 				<phingcall target="db-fill-ci"/>
 				<phingcall target="inportal-deploy"/>
 			</then>
 		</if>
 	</target>
 
 	<target name="inportal-deploy" description="Runs In-Portal deployment script">
 		<echo msg="Running In-Portal Deployment Script (part of 'do_update') ..."/>
 
-		<exec executable="php" logoutput="true" checkreturn="true">
+		<exec executable="${php.binary}" logoutput="true" checkreturn="true">
 			<arg path="${base.dir}/tools/run_event.php"/>
 			<arg value="adm:OnDeploy"/>
 			<arg value="${cli.key}"/>
 			<arg value="${client.ip.address}"/>
 		</exec>
 	</target>
 </project>