Skip to content

Commit a71edb6

Browse files
committed
Add PHP pkg-config .pc metadata files
Since PHP *nix Autotools build system already extensively relies on pkgconf (pkg-config) command-line tool to find dependencies it should also provide its .pc metadata file(s). [1] This adds an initial php.pc.in and php-embed.pc.in templates that are created during the configuration and build phase. They are installed in the provided system pkgconfig directory. For example: /usr/lib/pkgconfig/php.pc /usr/lib/pkgconfig/php-embed.pc /usr/lib/pkgconfig/php-embed8.pc /usr/lib/pkgconfig/php-embed8.4.pc /usr/lib/x86_64-linux-gnu/pkgconfig/php.pc Pkgconf [2] is a maintained continuation of the initial Freedesktop's pkg-config project [3]. Extensions and applications embedding the PHP Embed SAPI can then use also pkgconf to get the required PHP CFLAGS and/or LIBS. For PHP extensions: pkgconf --cflags php pkgconf --libs php pkgconf --modversion php pkgconf --cflags php8.4 Applications embedding the PHP Embed SAPI: pkgconf --libs php-embed pkgconf --cflags php-embed pkgconf --modversion php-embed pkgconf --cflags php-embed8.4 [1]: https://people.freedesktop.org/~dbn/pkg-config-guide.html [2]: https://github.com/pkgconf/pkgconf [3]: https://gitlab.freedesktop.org/pkg-config/pkg-config
1 parent 0064c42 commit a71edb6

File tree

8 files changed

+92
-2
lines changed

8 files changed

+92
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ config.h.in
112112
# SAPIs specific ignores
113113
# ------------------------------------------------------------------------------
114114
/sapi/apache2handler/libphp.module
115+
/sapi/embed/php-embed.pc
115116
/sapi/fpm/fpm/php-cgi
116117
/sapi/fpm/init.d.php-fpm
117118
/sapi/fpm/php-fpm.conf
@@ -129,6 +130,7 @@ config.h.in
129130
/sapi/fpm/php-fpm
130131
/sapi/phpdbg/phpdbg
131132
/scripts/php-config
133+
/scripts/php.pc
132134
/scripts/phpize
133135
php
134136

build/Makefile.global

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ distclean: clean
131131
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
132132
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
133133
rm -f ext/phar/phar.phar ext/phar/phar.php
134+
rm -f scripts/php.pc sapi/embed/php-embed.pc
134135
if test "$(srcdir)" != "$(builddir)"; then \
135136
rm -f ext/phar/phar/phar.inc; \
136137
fi

configure.ac

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,8 @@ AC_SUBST([SAPI_LIBNAME_STATIC])
13891389
AC_SUBST([PHP_VERSION])
13901390
AC_SUBST([PHP_VERSION_ID])
13911391
AC_SUBST([PHP_LDFLAGS])
1392+
AC_SUBST([PHP_THREAD_SAFETY])
1393+
AC_SUBST([ZEND_DEBUG])
13921394

13931395
PHP_UTILIZE_RPATHS
13941396

@@ -1455,7 +1457,7 @@ PHP_SUBST_OLD([EXTENSION_DIR])
14551457
PHP_SUBST([EXTRA_LDFLAGS])
14561458
PHP_SUBST([EXTRA_LDFLAGS_PROGRAM])
14571459
PHP_SUBST_OLD([EXTRA_LIBS])
1458-
PHP_SUBST([ZEND_EXTRA_LIBS])
1460+
PHP_SUBST_OLD([ZEND_EXTRA_LIBS])
14591461
PHP_SUBST([INCLUDES])
14601462
PHP_SUBST([EXTRA_INCLUDES])
14611463
PHP_SUBST([INSTALL_IT])
@@ -1596,7 +1598,7 @@ else
15961598
fi;
15971599

15981600
all_targets="\$(OVERALL_TARGET) \$(PHP_MODULES) \$(PHP_ZEND_EX) \$(PHP_BINARIES) $pharcmd"
1599-
install_targets="$install_sapi $install_modules $install_binaries install-build install-headers install-programs $install_pear $pharcmd_install"
1601+
install_targets="$install_sapi $install_modules $install_binaries install-build install-headers install-programs $install_pear $pharcmd_install $install_embed"
16001602

16011603
PHP_SUBST([all_targets])
16021604
PHP_SUBST([install_targets])
@@ -1795,6 +1797,7 @@ AC_CONFIG_FILES([
17951797
scripts/man1/php-config.1
17961798
scripts/man1/phpize.1
17971799
scripts/php-config
1800+
scripts/php.pc
17981801
scripts/phpize
17991802
])
18001803

sapi/embed/Makefile.frag

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
install-embed:
2+
@echo "Installing PHP Embed .pc file: $(INSTALL_ROOT)$(orig_libdir)/pkgconfig/"
3+
@$(mkinstalldirs) $(INSTALL_ROOT)$(orig_libdir)/pkgconfig
4+
@$(INSTALL_DATA) sapi/embed/php-embed.pc $(INSTALL_ROOT)$(orig_libdir)/pkgconfig/$(program_prefix)php-embed$(program_suffix).pc

sapi/embed/config.m4

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ if test "$PHP_EMBED" != "no"; then
3030
[php_embed.c],
3131
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
3232
PHP_INSTALL_HEADERS([sapi/embed], [php_embed.h])
33+
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/embed/Makefile.frag],
34+
[$abs_srcdir/sapi/embed],
35+
[sapi/embed])
36+
AC_CONFIG_FILES([sapi/embed/php-embed.pc])
37+
install_embed=install-embed
3338
])
3439
else
3540
AC_MSG_RESULT([no])

sapi/embed/php-embed.pc.in

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# The .pc file for the pkg-config command-line utility.
2+
# https://en.wikipedia.org/wiki/Pkg-config
3+
#
4+
# Usage:
5+
# pkg-config --cflags php-embed
6+
# pkg-config --cflags-only-I php-embed
7+
# pkg-config --libs php-embed
8+
# pkg-config --mod-version php-embed
9+
# pkg-config --print-variables php-embed
10+
# pkg-config --variable=php_vernum php-embed
11+
12+
prefix=@prefix@
13+
exec_prefix=@exec_prefix@
14+
includedir=@includedir@/php
15+
libdir=@exec_prefix@/lib
16+
# The extension_dir PHP INI directive absolute path.
17+
extensiondir=@EXPANDED_EXTENSION_DIR@
18+
# PHP version as integer.
19+
php_vernum=@PHP_VERSION_ID@
20+
# The path where to scan for additional INI configuration files.
21+
php_inidir=@EXPANDED_PHP_CONFIG_FILE_SCAN_DIR@
22+
# The path in which to look for php.ini.
23+
php_inipath=@EXPANDED_PHP_CONFIG_FILE_PATH@
24+
# Whether PHP is built in debug mode (yes) or not (no).
25+
php_debug=@ZEND_DEBUG@
26+
# Whether PHP is built with thread safety (yes) or not (no).
27+
php_zts=@PHP_THREAD_SAFETY@
28+
29+
Name: PHP Embed SAPI
30+
Description: A lightweight SAPI to embed PHP into application using C bindings
31+
URL: https://www.php.net
32+
License: PHP
33+
Version: @PHP_VERSION@
34+
Cflags: -I${includedir} -I${includedir}/main -I${includedir}/TSRM -I${includedir}/Zend -I${includedir}/ext -I${includedir}/ext/date/lib
35+
Libs.private: @EXTRA_LIBS@ @ZEND_EXTRA_LIBS@
36+
Libs: -L${libdir} -lphp

scripts/Makefile.frag

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ install-programs:
4646
echo " page: $(program_prefix)$${page}$(program_suffix).1"; \
4747
$(INSTALL_DATA) $(builddir)/man1/$${page}.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)$${page}$(program_suffix).1; \
4848
done
49+
@echo "Installing PHP .pc file: $(INSTALL_ROOT)$(orig_libdir)/pkgconfig/"
50+
@$(mkinstalldirs) $(INSTALL_ROOT)$(orig_libdir)/pkgconfig
51+
@$(INSTALL_DATA) $(builddir)/php.pc $(INSTALL_ROOT)$(orig_libdir)/pkgconfig/$(program_prefix)php$(program_suffix).pc

scripts/php.pc.in

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# The .pc file for the pkg-config command-line utility.
2+
# https://en.wikipedia.org/wiki/Pkg-config
3+
#
4+
# Usage:
5+
# pkg-config --cflags php
6+
# pkg-config --cflags-only-I php
7+
# pkg-config --libs php
8+
# pkg-config --mod-version php
9+
# pkg-config --print-variables php
10+
# pkg-config --variable=php_vernum php
11+
12+
prefix=@prefix@
13+
exec_prefix=@exec_prefix@
14+
includedir=@includedir@/php
15+
libdir=@exec_prefix@/lib
16+
# The extension_dir PHP INI directive absolute path.
17+
extensiondir=@EXPANDED_EXTENSION_DIR@
18+
# PHP version as integer.
19+
php_vernum=@PHP_VERSION_ID@
20+
# The path where to scan for additional INI configuration files.
21+
php_inidir=@EXPANDED_PHP_CONFIG_FILE_SCAN_DIR@
22+
# The path in which to look for php.ini.
23+
php_inipath=@EXPANDED_PHP_CONFIG_FILE_PATH@
24+
# Whether PHP is built in debug mode (yes) or not (no).
25+
php_debug=@ZEND_DEBUG@
26+
# Whether PHP is built with thread safety (yes) or not (no).
27+
php_zts=@PHP_THREAD_SAFETY@
28+
29+
Name: PHP
30+
Description: Build extension for a PHP general-purpose scripting language
31+
URL: https://www.php.net
32+
License: PHP
33+
Version: @PHP_VERSION@
34+
CFlags: -I${includedir} -I${includedir}/main -I${includedir}/TSRM -I${includedir}/Zend -I${includedir}/ext -I${includedir}/ext/date/lib
35+
Libs.private: @EXTRA_LIBS@ @ZEND_EXTRA_LIBS@
36+
Libs:

0 commit comments

Comments
 (0)