Skip to content

Commit e0b2ae9

Browse files
committed
[WIP] Add PHP pkgconf .pc metadata file(s)
Since PHP *nix Autotools build system already extensively relies on pkgconf (pkg-config) command-line tool to find dependencies it should also provide its own .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 more actively maintained continuation of the initial Freedesktop's pkg-config project [3]. Extensions and applications embedding the PHP Embed SAPI can then optionally use also the pkgconf utility to get the required PHP CFLAGS and/or LIBS. Extensions can use: 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 2e7c6e1 commit e0b2ae9

File tree

7 files changed

+50
-2
lines changed

7 files changed

+50
-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

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ else
16661666
fi;
16671667

16681668
all_targets="\$(OVERALL_TARGET) \$(PHP_MODULES) \$(PHP_ZEND_EX) \$(PHP_BINARIES) $pharcmd"
1669-
install_targets="$install_sapi $install_modules $install_binaries install-build install-headers install-programs $install_pear $pharcmd_install"
1669+
install_targets="$install_sapi $install_modules $install_binaries install-build install-headers install-programs $install_pear $pharcmd_install $install_embed"
16701670

16711671
PHP_SUBST(all_targets)
16721672
PHP_SUBST(install_targets)
@@ -1761,7 +1761,7 @@ $php_shtool mkdir -p scripts
17611761
$php_shtool mkdir -p scripts/man1
17621762

17631763
ALL_OUTPUT_FILES="main/build-defs.h \
1764-
scripts/phpize scripts/man1/phpize.1 \
1764+
scripts/php.pc scripts/phpize scripts/man1/phpize.1 \
17651765
scripts/php-config scripts/man1/php-config.1 \
17661766
$PHP_OUTPUT_FILES"
17671767

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 SAPI: $(INSTALL_ROOT)$(libdir)"
3+
@$(mkinstalldirs) $(INSTALL_ROOT)$(libdir)/pkgconfig
4+
@$(INSTALL_DATA) sapi/embed/php-embed.pc $(INSTALL_ROOT)$(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
@@ -29,6 +29,11 @@ if test "$PHP_EMBED" != "no"; then
2929
PHP_INSTALL_HEADERS([sapi/embed], [php_embed.h])
3030
fi
3131
AC_MSG_RESULT([$PHP_EMBED_TYPE])
32+
33+
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/embed/Makefile.frag], [$abs_srcdir/sapi/embed], [$abs_builddir/sapi/embed])
34+
PHP_OUTPUT([sapi/embed/php-embed.pc])
35+
36+
install_embed=install-embed
3237
else
3338
AC_MSG_RESULT(no)
3439
fi

sapi/embed/php-embed.pc.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# The .pc file for pkgconf (pkg-config) utility.
2+
# https://github.com/pkgconf/pkgconf
3+
# https://people.freedesktop.org/~dbn/pkg-config-guide.html
4+
5+
prefix=@prefix@
6+
exec_prefix=@exec_prefix@
7+
includedir=@prefix@/include
8+
libdir=@exec_prefix@/lib
9+
10+
Name: PHP Embed SAPI
11+
Description: Embed PHP into application with C bindings using a lightweight SAPI
12+
URL: https://www.php.net
13+
License: PHP
14+
Version: @PHP_VERSION@
15+
Cflags.private: @PHP_CFLAGS_PRIVATE@
16+
Cflags: -I${includedir} -I${includedir}/main -I${includedir}/TSRM -I${includedir}/Zend -I${includedir}/ext -I${includedir}/ext/date/lib
17+
Libs.private: @PHP_LIBS_PRIVATE@
18+
Libs: -L${libdir} -lphp

scripts/Makefile.frag

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ install-programs: $(builddir)/phpize $(builddir)/php-config
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 pkgconf .pc file: $(INSTALL_ROOT)$(libdir)/pkgconfig/php.pc"
50+
@$(mkinstalldirs) $(INSTALL_ROOT)$(libdir)/pkgconfig
51+
@$(INSTALL_DATA) $(builddir)/php.pc $(INSTALL_ROOT)$(libdir)/pkgconfig/$(program_prefix)php$(program_suffix).pc
4952

5053
$(builddir)/phpize: $(srcdir)/phpize.in $(top_builddir)/config.status
5154
(CONFIG_FILES=$@ CONFIG_HEADERS= $(top_builddir)/config.status)

scripts/php.pc.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The .pc file for pkgconf (pkg-config) utility.
2+
# https://github.com/pkgconf/pkgconf
3+
# https://people.freedesktop.org/~dbn/pkg-config-guide.html
4+
5+
prefix=@prefix@
6+
exec_prefix=@exec_prefix@
7+
includedir=@prefix@/include
8+
libdir=@exec_prefix@/lib
9+
10+
Name: PHP
11+
Description: A general-purpose scripting language
12+
URL: https://www.php.net
13+
License: PHP
14+
Version: @PHP_VERSION@
15+
CFlags: -I${includedir} -I${includedir}/main -I${includedir}/TSRM -I${includedir}/Zend -I${includedir}/ext -I${includedir}/ext/date/lib
16+
Libs: -L${libdir} -lphp

0 commit comments

Comments
 (0)