The installation prefix is the path where the built files are copied to on the system, when doing the installation phase. In Autotools it can be set at the configure phase only. For example:
./configure --prefix=/usr
In the installation phase there is also INSTALL_ROOT to be able to temporary install the built files to a staging directory (this is in practice used on some systems where some additional pre-installation stuff is done):
make INSTALL_ROOT=/package/stage install
Here the /package/stage will then include all the built files together with the installation prefix:
/package/stage/usr/bin/php
/package/stage/usr/include/php/main/php_config.h
...
The PHP's INSTALL_ROOT is more commonly named DESTDIR in other Autotools and C-based projects.
In CMake, the install prefix can be set at the configure phase using the CMAKE_INSTALL_PREFIX variable, or the --install-prefix option:
cmake -B <build-dir> -S <source-dir> -DCMAKE_INSTALL_PREFIX=/usr
# or
cmake -B <build-dir> -S <source-dir> --install-prefix=/usr
Or in the CMake presets file with the installDir field. For example, the CMakePresets.json:
{
"version": 3,
"configurePresets": [
{
"name": "default",
"displayName": "PHP configuration",
"description": "Configuration with the commonly used PHP extensions enabled",
"installDir": "/usr",
"binaryDir": "${sourceDir}/php-build/default"
}
]
}
Or it can be also overridden at the installation phase. For example:
cmake --install <build-dir> --prefix /usr
There is also the DESTDIR environment variable, which acts like the INSTALL_ROOT in PHP:
DESTDIR=/package/stage cmake --install <build-dir> --prefix /usr
Therefore it is a common-practice to use the generator expression in CMake files $<INSTALL_PREFIX> that gets properly replaced based on the different phase and its value (either in the configuration and generation phase or in the installation phase).
PHP, however, uses the prefix value also in the C header files at the build phase. For example, in main/build-defs.h or in main/php_config.h. So the prefix defined in the installation phase won't match the prefix from the configure
phase in these header files. Meaning, the cmake --install <build-dir> --prefix <prefix> is at the time of writing not handled properly in this build system yet unless some heavy refactoring is done in PHP.
Where prefix is used in PHP or in this repository files:
The installation prefix is the path where the built files are copied to on the system, when doing the installation phase. In Autotools it can be set at the configure phase only. For example:
In the installation phase there is also
INSTALL_ROOTto be able to temporary install the built files to a staging directory (this is in practice used on some systems where some additional pre-installation stuff is done):Here the
/package/stagewill then include all the built files together with the installation prefix:The PHP's
INSTALL_ROOTis more commonly namedDESTDIRin other Autotools and C-based projects.In CMake, the install prefix can be set at the configure phase using the
CMAKE_INSTALL_PREFIXvariable, or the--install-prefixoption:Or in the CMake presets file with the
installDirfield. For example, theCMakePresets.json:{ "version": 3, "configurePresets": [ { "name": "default", "displayName": "PHP configuration", "description": "Configuration with the commonly used PHP extensions enabled", "installDir": "/usr", "binaryDir": "${sourceDir}/php-build/default" } ] }Or it can be also overridden at the installation phase. For example:
There is also the
DESTDIRenvironment variable, which acts like theINSTALL_ROOTin PHP:Therefore it is a common-practice to use the generator expression in CMake files
$<INSTALL_PREFIX>that gets properly replaced based on the different phase and its value (either in the configuration and generation phase or in the installation phase).PHP, however, uses the prefix value also in the C header files at the build phase. For example, in
main/build-defs.hor inmain/php_config.h. So the prefix defined in the installation phase won't match the prefix from the configurephase in these header files. Meaning, the
cmake --install <build-dir> --prefix <prefix>is at the time of writing not handled properly in this build system yet unless some heavy refactoring is done in PHP.Where prefix is used in PHP or in this repository files:
$<INTALL_PREFIX>at the install stepconfigure_file())