Skip to content

Commit 02114c0

Browse files
committed
fix php-config libraries for imagemagick and imap
1 parent 4efa52c commit 02114c0

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

src/SPC/builder/LibraryBase.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,15 @@ public function patchBeforeMake(): bool
332332
return false;
333333
}
334334

335+
/**
336+
* Patch php-config after embed was built
337+
* Example: imagemagick requires -lgomp, imap requires -lcrypt
338+
*/
339+
public function patchPhpConfig(): bool
340+
{
341+
return false;
342+
}
343+
335344
/**
336345
* Build this library.
337346
*

src/SPC/builder/linux/library/imagemagick.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace SPC\builder\linux\library;
66

7+
use SPC\store\FileSystem;
8+
79
/**
810
* a template library class for unix
911
*/
@@ -12,4 +14,13 @@ class imagemagick extends LinuxLibraryBase
1214
use \SPC\builder\unix\library\imagemagick;
1315

1416
public const NAME = 'imagemagick';
17+
18+
public function patchPhpConfig(): bool
19+
{
20+
if (getenv('SPC_LIBC') !== 'glibc' || !str_contains(getenv('CC'), 'devtoolset-10')) {
21+
FileSystem::replaceFileRegex(BUILD_BIN_PATH . '/php-config', '/^libs="(.*)"$/m', 'libs="$1 -lgomp"');
22+
return true;
23+
}
24+
return false;
25+
}
1526
}

src/SPC/builder/linux/library/imap.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public function patchBeforeBuild(): bool
3535
return true;
3636
}
3737

38+
public function patchPhpConfig(): bool
39+
{
40+
if (getenv('SPC_LIBC') === 'glibc') {
41+
FileSystem::replaceFileRegex(BUILD_BIN_PATH . '/php-config', '/^libs="(.*)"$/m', 'libs="$1 -lcrypt"');
42+
return true;
43+
}
44+
return false;
45+
}
46+
3847
/**
3948
* @throws RuntimeException
4049
*/

src/SPC/builder/unix/UnixBuilderBase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@ protected function patchPhpScripts(): void
293293
$php_config_str = preg_replace('/(libs=")(.*?)\s*(-lstdc\+\+)\s*(.*?)"/', '$1$2 $4 $3"', $php_config_str);
294294
FileSystem::writeFile(BUILD_BIN_PATH . '/php-config', $php_config_str);
295295
}
296+
foreach ($this->getLibs() as $lib) {
297+
if ($lib->patchPhpConfig()) {
298+
logger()->debug("Library {$lib->getName()} patched php-config");
299+
}
300+
}
296301
}
297302

298303
/**

0 commit comments

Comments
 (0)