[PHP-DEV] Support for pkg-config .pc files

Hello,

There is another pull request in preparation that I’d like to squeeze in the PHP-8.4 branch if it will possible to wrap it up until the feature freeze milestone:
https://github.com/php/php-src/pull/13755

In short, pkg-config is *nix command line utility to query installed libraries on the system:
https://en.wikipedia.org/wiki/Pkg-config
https://people.freedesktop.org/~dbn/pkg-config-guide.html

And pkgconf is a compatible maintained continuation/fork that many distributions might also use.

Each library creates a so-called .pc file, for example, php.pc which is installed to the pkgconfig subdirectory. For example, /usr/lib/x86_64-linux-gnu/pkgconfig/php.pc

.pc file is created from a template .pc.in and gets some placeholders replaced during the configuration phase of building to get the library name, include flags etc.

PHP already extensively relies on pkg-config’s interface for finding certain dependencies during the build (libxml2, SQLite, OpenSSL, curl…) but so far never implemented its own .pc file(s).

PHP could have two such .pc files. One for a global PHP installation as a whole that PHP extensions can use (php.pc) and one for the embed SAPI to embed PHP into an application (php-embed.pc)

Its usage is very similar to php-config script, i.e. getting build details.

See PR for details, I’ll update it on the way what can be done.

Let me know if that’s fine or is there some concern.

Having pkg-config support would allow us to simplify the build process of FrankenPHP.
Cgo (as many other tools) has native support for pkg-config. We’ll remove many hardcoded paths that are difficult to override for end users.

FrankenPHP doesn’t use the embed SAPI, but does rely on libphp to provide its own SAPI.

It would be nice to have it in 8.4 (it could even be nicer to backport this patch in older supported branches).

Thanks for having contributed to this Peter!