diff --git a/.gitignore b/.gitignore index d54334f599a57..34c1deae0c313 100644 --- a/.gitignore +++ b/.gitignore @@ -112,6 +112,7 @@ config.h.in # SAPIs specific ignores # ------------------------------------------------------------------------------ /sapi/apache2handler/libphp.module +/sapi/embed/php-embed.pc /sapi/fpm/fpm/php-cgi /sapi/fpm/init.d.php-fpm /sapi/fpm/php-fpm.conf @@ -129,6 +130,7 @@ config.h.in /sapi/fpm/php-fpm /sapi/phpdbg/phpdbg /scripts/php-config +/scripts/php.pc /scripts/phpize php diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2318f896b7a9b..30cd60e932e57 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -235,8 +235,11 @@ locations. └─ cli/ ├─ mime_type_map.h # Generated by `sapi/cli/generate_mime_type_map.php` └─ ... + └─ embed/ + ├─ php-embed.pc.in # pkg-config metadata file + └─ ... └─ ... - ├─ scripts/ # php-config, phpize and internal development scripts + ├─ scripts/ # php-config, phpize, pkg-config, and internal development scripts ├─ tests/ # Core features tests └─ win32/ # Windows build system files ├─ cp_enc_map.c # Generated by `win32/cp_enc_map_gen.exe` diff --git a/build/Makefile.global b/build/Makefile.global index 37b48ba2980ea..618ad0368cc80 100644 --- a/build/Makefile.global +++ b/build/Makefile.global @@ -131,6 +131,7 @@ distclean: clean rm -f scripts/man1/phpize.1 scripts/php-config scripts/man1/php-config.1 sapi/cli/php.1 sapi/cgi/php-cgi.1 sapi/phpdbg/phpdbg.1 ext/phar/phar.1 ext/phar/phar.phar.1 rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html rm -f ext/phar/phar.phar ext/phar/phar.php + rm -f scripts/php.pc sapi/embed/php-embed.pc if test "$(srcdir)" != "$(builddir)"; then \ rm -f ext/phar/phar/phar.inc; \ fi diff --git a/configure.ac b/configure.ac index c7e36ca70c9fe..8ad99c7cbb4a4 100644 --- a/configure.ac +++ b/configure.ac @@ -1392,6 +1392,8 @@ AC_SUBST([SAPI_LIBNAME_STATIC]) AC_SUBST([PHP_VERSION]) AC_SUBST([PHP_VERSION_ID]) AC_SUBST([PHP_LDFLAGS]) +AC_SUBST([PHP_THREAD_SAFETY]) +AC_SUBST([ZEND_DEBUG]) PHP_UTILIZE_RPATHS @@ -1467,7 +1469,7 @@ PHP_SUBST_OLD([EXTENSION_DIR]) PHP_SUBST([EXTRA_LDFLAGS]) PHP_SUBST([EXTRA_LDFLAGS_PROGRAM]) PHP_SUBST_OLD([EXTRA_LIBS]) -PHP_SUBST([ZEND_EXTRA_LIBS]) +PHP_SUBST_OLD([ZEND_EXTRA_LIBS]) PHP_SUBST([INCLUDES]) PHP_SUBST([EXTRA_INCLUDES]) PHP_SUBST([INSTALL_IT]) @@ -1604,7 +1606,7 @@ else fi; all_targets="\$(OVERALL_TARGET) \$(PHP_MODULES) \$(PHP_ZEND_EX) \$(PHP_BINARIES) $pharcmd" -install_targets="$install_sapi $install_modules $install_binaries install-build install-headers install-programs $install_pear $pharcmd_install" +install_targets="$install_sapi $install_modules $install_binaries install-build install-headers install-programs $install_pear $pharcmd_install $install_embed" PHP_SUBST([all_targets]) PHP_SUBST([install_targets]) @@ -1804,6 +1806,7 @@ AC_CONFIG_FILES([ scripts/man1/php-config.1 scripts/man1/phpize.1 scripts/php-config + scripts/php.pc scripts/phpize ]) diff --git a/sapi/embed/Makefile.frag b/sapi/embed/Makefile.frag new file mode 100644 index 0000000000000..8547166135813 --- /dev/null +++ b/sapi/embed/Makefile.frag @@ -0,0 +1,4 @@ +install-embed: + @echo "Installing PHP Embed .pc file: $(INSTALL_ROOT)$(orig_libdir)/pkgconfig/" + @$(mkinstalldirs) $(INSTALL_ROOT)$(orig_libdir)/pkgconfig + @$(INSTALL_DATA) sapi/embed/php-embed.pc $(INSTALL_ROOT)$(orig_libdir)/pkgconfig/$(program_prefix)php-embed$(program_suffix).pc diff --git a/sapi/embed/config.m4 b/sapi/embed/config.m4 index c385e289a70ee..4f84d9138ea9f 100644 --- a/sapi/embed/config.m4 +++ b/sapi/embed/config.m4 @@ -30,6 +30,11 @@ if test "$PHP_EMBED" != "no"; then [php_embed.c], [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) PHP_INSTALL_HEADERS([sapi/embed], [php_embed.h]) + PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/embed/Makefile.frag], + [$abs_srcdir/sapi/embed], + [sapi/embed]) + AC_CONFIG_FILES([sapi/embed/php-embed.pc]) + install_embed=install-embed ]) else AC_MSG_RESULT([no]) diff --git a/sapi/embed/php-embed.pc.in b/sapi/embed/php-embed.pc.in new file mode 100644 index 0000000000000..102f582ca2b53 --- /dev/null +++ b/sapi/embed/php-embed.pc.in @@ -0,0 +1,27 @@ +# The pkg-config .pc file for PHP Embed SAPI. + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +includedir=@includedir@/php +libdir=@orig_libdir@ +# PHP extension directory containing dynamically loadable PHP extensions. +php_extension_dir=@EXTENSION_DIR@ +# PHP version as integer. +php_vernum=@PHP_VERSION_ID@ +# The path where to scan for additional INI configuration files. +php_ini_dir=@EXPANDED_PHP_CONFIG_FILE_SCAN_DIR@ +# The path in which to look for php.ini. +php_ini_path=@EXPANDED_PHP_CONFIG_FILE_PATH@ +# Whether PHP is built in debug mode (yes) or not (no). +php_debug=@ZEND_DEBUG@ +# Whether PHP is built with thread safety (yes) or not (no). +php_zts=@PHP_THREAD_SAFETY@ + +Name: PHP Embed SAPI +Description: A lightweight SAPI to embed PHP into application using C bindings +URL: https://www.php.net +License: PHP +Version: @PHP_VERSION@ +Cflags: -I${includedir} -I${includedir}/main -I${includedir}/TSRM -I${includedir}/Zend -I${includedir}/ext -I${includedir}/ext/date/lib +Libs.private: @EXTRA_LIBS@ @ZEND_EXTRA_LIBS@ +Libs: -L${libdir} -lphp diff --git a/scripts/Makefile.frag b/scripts/Makefile.frag index cf56852c2b113..8dce5a4153bf8 100644 --- a/scripts/Makefile.frag +++ b/scripts/Makefile.frag @@ -46,3 +46,6 @@ install-programs: echo " page: $(program_prefix)$${page}$(program_suffix).1"; \ $(INSTALL_DATA) $(builddir)/man1/$${page}.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)$${page}$(program_suffix).1; \ done + @echo "Installing PHP .pc file: $(INSTALL_ROOT)$(orig_libdir)/pkgconfig/" + @$(mkinstalldirs) $(INSTALL_ROOT)$(orig_libdir)/pkgconfig + @$(INSTALL_DATA) $(builddir)/php.pc $(INSTALL_ROOT)$(orig_libdir)/pkgconfig/$(program_prefix)php$(program_suffix).pc diff --git a/scripts/php.pc.in b/scripts/php.pc.in new file mode 100644 index 0000000000000..d61f2f939605d --- /dev/null +++ b/scripts/php.pc.in @@ -0,0 +1,27 @@ +# The pkg-config .pc file for PHP. + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +includedir=@includedir@/php +libdir=@orig_libdir@ +# PHP extension directory containing dynamically loadable PHP extensions. +php_extension_dir=@EXTENSION_DIR@ +# PHP version as integer. +php_vernum=@PHP_VERSION_ID@ +# The path where to scan for additional INI configuration files. +php_ini_dir=@EXPANDED_PHP_CONFIG_FILE_SCAN_DIR@ +# The path in which to look for php.ini. +php_ini_path=@EXPANDED_PHP_CONFIG_FILE_PATH@ +# Whether PHP is built in debug mode (yes) or not (no). +php_debug=@ZEND_DEBUG@ +# Whether PHP is built with thread safety (yes) or not (no). +php_zts=@PHP_THREAD_SAFETY@ + +Name: PHP +Description: Build extension for a PHP general-purpose scripting language +URL: https://www.php.net +License: PHP +Version: @PHP_VERSION@ +Cflags: -I${includedir} -I${includedir}/main -I${includedir}/TSRM -I${includedir}/Zend -I${includedir}/ext -I${includedir}/ext/date/lib +Libs.private: @EXTRA_LIBS@ @ZEND_EXTRA_LIBS@ +Libs: