Skip to content

Commit 7456c0b

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 file(s). This adds an initial php.pc.in and php-embed.pc.in template files 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/x86_64-linux-gnu/pkgconfig/php.pc Pkgconf [1] is a more actively maintained continuation of the initial Freedesktop's pkg-config project [2]. Extensions and applications embedding the PHP Embed SAPI can then optionally use also the pkgconf command-line tool to get the required PHP CFLAGS and/or LIBS. pkgconf --libs php-embed pkgconf --modversion php-embed pkgconf --cflags php-embed pkgconf --cflags php [1]: https://github.com/pkgconf/pkgconf [2]: https://gitlab.freedesktop.org/pkg-config/pkg-config
1 parent 5bb0315 commit 7456c0b

File tree

7 files changed

+40
-2
lines changed

7 files changed

+40
-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
@@ -122,6 +123,7 @@ config.h.in
122123
# ------------------------------------------------------------------------------
123124
# Executable binaries and scripts generated during the build process
124125
# ------------------------------------------------------------------------------
126+
/build/php.pc
125127
/ext/phar/phar.phar
126128
/ext/phar/phar.php
127129
/pear/install-pear-nozlib.phar

build/php.pc.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
prefix=@prefix@
2+
exec_prefix=@exec_prefix@
3+
includedir=@prefix@/include
4+
libdir=@exec_prefix@/lib
5+
6+
Name: php
7+
Description: A general-purpose scripting language
8+
URL: https://www.php.net
9+
License: PHP
10+
Version: @PHP_VERSION@
11+
CFlags: -I${includedir} -I${includedir}/main -I${includedir}/TSRM -I${includedir}/Zend -I${includedir}/ext -I${includedir}/ext/date/lib
12+
Libs: -L${libdir} -lphp

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 $embed_install"
16701670

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

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

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+
embed_install=install-embed
3237
else
3338
AC_MSG_RESULT(no)
3439
fi

sapi/embed/php-embed.pc.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
prefix=@prefix@
2+
exec_prefix=@exec_prefix@
3+
includedir=@prefix@/include
4+
libdir=@exec_prefix@/lib
5+
6+
Name: php-embed
7+
Description: Embed PHP into application with C bindings using a lightweight SAPI
8+
URL: https://www.php.net
9+
License: PHP
10+
Version: @PHP_VERSION@
11+
CFlags: -I${includedir} -I${includedir}/main -I${includedir}/TSRM -I${includedir}/Zend -I${includedir}/ext -I${includedir}/ext/date/lib
12+
Libs: -L@libdir@ -lphp

scripts/Makefile.frag

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ install-build:
3232
(cd $(top_srcdir) && \
3333
$(INSTALL) $(BUILD_FILES_EXEC) $(INSTALL_ROOT)$(phpbuilddir) && \
3434
$(INSTALL_DATA) $(BUILD_FILES) $(INSTALL_ROOT)$(phpbuilddir))
35+
@echo "Installing pkgconf PC file: $(INSTALL_ROOT)$(libdir)/pkgconfig/php.pc"
36+
@$(mkinstalldirs) $(INSTALL_ROOT)$(libdir)/pkgconfig
37+
@$(INSTALL_DATA) $(top_builddir)/build/php.pc $(INSTALL_ROOT)$(libdir)/pkgconfig/$(program_prefix)php$(program_suffix).pc
3538

3639
install-programs: $(builddir)/phpize $(builddir)/php-config
3740
@echo "Installing helper programs: $(INSTALL_ROOT)$(bindir)/"

0 commit comments

Comments
 (0)