Skip to content

Add PHP pkg-config (pkgconf) .pc metadata file(s) #13755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -129,6 +130,7 @@ config.h.in
/sapi/fpm/php-fpm
/sapi/phpdbg/phpdbg
/scripts/php-config
/scripts/php.pc
/scripts/phpize
php

Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might better be pkg-config metadata file or maybe just .pc, or something like this.

├─ tests/ # Core features tests
└─ win32/ # Windows build system files
├─ cp_enc_map.c # Generated by `win32/cp_enc_map_gen.exe`
Expand Down
1 change: 1 addition & 0 deletions build/Makefile.global
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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])
Comment on lines -1470 to +1472
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what's the difference between these macros?

PHP_SUBST([INCLUDES])
PHP_SUBST([EXTRA_INCLUDES])
PHP_SUBST([INSTALL_IT])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -1804,6 +1806,7 @@ AC_CONFIG_FILES([
scripts/man1/php-config.1
scripts/man1/phpize.1
scripts/php-config
scripts/php.pc
scripts/phpize
])

Expand Down
4 changes: 4 additions & 0 deletions sapi/embed/Makefile.frag
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions sapi/embed/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
27 changes: 27 additions & 0 deletions sapi/embed/php-embed.pc.in
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions scripts/Makefile.frag
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 27 additions & 0 deletions scripts/php.pc.in
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, isn't this supposed to be the description of the package? So maybe instead

Suggested change
Description: Build extension for a PHP general-purpose scripting language
Description: A popular general-purpose scripting language that is especially suited to web development

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@
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add @PHP_LDFLAGS@ here?

Libs: