-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Add PHP pkg-config (pkgconf) .pc metadata file(s) #13755
base: master
Are you sure you want to change the base?
Conversation
7456c0b
to
e0b2ae9
Compare
e0230ba
to
c8d2e55
Compare
I think we should add variables |
Yes, this list of variables needs to be expanded further. I've added |
I think it needs the |
This one is added as |
I just built from source and this one didn't get expanded:
Also, is it expected that it goes into |
Fixed in the 3rd commit. Installation now puts it to pkgconf directory in libdir. For now, I've removed this Cflags.private part. |
6586486
to
c047551
Compare
c047551
to
2538bbb
Compare
2538bbb
to
5cd2195
Compare
@morrisonlevi could you have another look to see if this behaves like you expect it? I have no knowledge about build systems/package dependency resolution for system libraries, but I think or we be good to use what seems to be industry standard. |
5cd2195
to
848e975
Compare
I've rebased the branch so it's easier to handle this PR. Here actually everything works but PHP has a bit of weird include flags handling at the moment. This pkg-config template files are (for now) done like the php-config script is done. I'll recheck all the pkg-config variables again what needs to be added. As far as the PHP-8.4 is concerned I won't touch the include flags yet in this branch. Because they aren't done correctly. Neither the main PHP include directory is done correctly. This also goes for the php-config script. They are for now hard-coded in there as part of the PHP history, but they would need to be dynamic. |
848e975
to
538f6f7
Compare
538f6f7
to
d2c4f96
Compare
I've also added a quick table for tracking options between php-config script and possible pkg-config alternatives in the PR's first post. The next appended commit adds some fixes and syncs of the .pc.in templates. |
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
When customizing the Autoconf's lib directory option with for example: ./configure --libdir=--libdir=/usr/lib/x86_64-linux-gnu This lib directory should be also inserted in the generated *.pc files.
- variables renamed and synced further to match php-config a bit - Redundant comments removed and refactored - Typos fixed - Extension directory template placeholder replaced with @EXTENSION_DIR@ so it's possible to insert variables directly `$prefix/php/...`
d2c4f96
to
33c26fb
Compare
The "Requires" inherits all Cflags, Libs and their ".private" fields and adds it to the output, which simplifies writing templates a bit.
Yes, this pkg-config stuff is complex, anyone here to test it :D? Basically it works but the main issue with this will be in scenarios where different PHP versions are installed (where also php-config is prone to errors) or when installing PHP with program prefix/sufix (like php8.4), or when in extreme case both static and shared libphp embed is installed. The PHP Embed library still probably needs one more adjustment to totally match the php-config's |
I got another idea about the --- a/scripts/php.pc.in
+++ b/scripts/php.pc.in
@@ -12,10 +12,7 @@ php_vernum=@PHP_VERSION_ID@
-# 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@
+php_features="@PHP_FEATURES@" This php_features would be a space separated list of enabled features, for example:
Then the Anyhow, I think that this won't be able to land in PHP 8.4 so, let's target next PHP version here then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, this looks like a very good (and overdue) addition (we could get rid of php-config in the long run). Thank you!
I got another idea about the
php_zts
andphp_debug
variables. Instead of these only a single pkg-config variable likephp_features
can be added:
I think this is a good idea. (I would probably go with features
only, though.)
└─ ... | ||
├─ scripts/ # php-config, phpize and internal development scripts | ||
├─ scripts/ # php-config, phpize, pkg-config, and internal development scripts |
There was a problem hiding this comment.
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.
PHP_SUBST([ZEND_EXTRA_LIBS]) | ||
PHP_SUBST_OLD([ZEND_EXTRA_LIBS]) |
There was a problem hiding this comment.
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_zts=@PHP_THREAD_SAFETY@ | ||
|
||
Name: PHP | ||
Description: Build extension for a PHP general-purpose scripting language |
There was a problem hiding this comment.
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
Description: Build extension for a PHP general-purpose scripting language | |
Description: A popular general-purpose scripting language that is especially suited to web development |
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@ |
There was a problem hiding this comment.
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?
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:
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:
Applications embedding the PHP Embed SAPI:
Mapping of php-config and pkg-config usage: