allow building and linking with shared instead of static libs

This commit is contained in:
henderkes
2026-02-19 21:26:18 +07:00
parent 8c4e3d58a3
commit cf69c02624
15 changed files with 35 additions and 55 deletions

View File

@@ -61,8 +61,9 @@ class PkgConfigUtil
*/
public static function getCflags(string $pkg_config_str): string
{
$static = getenv('SPC_STATIC_LIBS') ? '--static' : '';
// get other things
$result = self::execWithResult("pkg-config --static --cflags-only-other {$pkg_config_str}");
$result = self::execWithResult("pkg-config $static --cflags-only-other {$pkg_config_str}");
return trim($result);
}
@@ -78,11 +79,12 @@ class PkgConfigUtil
public static function getLibsArray(string $pkg_config_str): array
{
// Use this instead of shell() to avoid unnecessary outputs
$result = self::execWithResult("pkg-config --static --libs-only-l {$pkg_config_str}");
$static = getenv('SPC_STATIC_LIBS') ? '--static' : '';
$result = self::execWithResult("pkg-config $static --libs-only-l {$pkg_config_str}");
$libs = explode(' ', trim($result));
// get other things
$result = self::execWithResult("pkg-config --static --libs-only-other {$pkg_config_str}");
$result = self::execWithResult("pkg-config $static --libs-only-other {$pkg_config_str}");
// convert libxxx.a to -L{path} -lxxx
$exp = explode(' ', trim($result));
foreach ($exp as $item) {