2023-05-10 02:04:08 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
|
|
|
|
use SPC\util\CustomExt;
|
2025-06-28 16:36:05 +08:00
|
|
|
use SPC\util\SPCTarget;
|
2023-05-10 02:04:08 +08:00
|
|
|
|
|
|
|
|
#[CustomExt('imagick')]
|
|
|
|
|
class imagick extends Extension
|
|
|
|
|
{
|
2023-10-17 20:16:41 +02:00
|
|
|
public function patchBeforeMake(): bool
|
2023-08-20 19:51:45 +08:00
|
|
|
{
|
2025-06-11 15:38:43 +07:00
|
|
|
if (PHP_OS_FAMILY !== 'Linux') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2025-06-28 16:36:05 +08:00
|
|
|
if (SPCTarget::isTarget(SPCTarget::GLIBC)) {
|
2025-03-30 22:07:56 +07:00
|
|
|
return false;
|
2023-11-29 00:51:05 +08:00
|
|
|
}
|
2025-06-11 15:38:43 +07:00
|
|
|
// imagick with calls omp_pause_all, which requires openmp, on non-musl we build imagick without openmp
|
|
|
|
|
$extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lgomp');
|
2024-04-26 11:00:33 +08:00
|
|
|
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
2023-08-20 19:51:45 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-27 11:12:19 +07:00
|
|
|
public function getUnixConfigureArg(bool $shared = false): string
|
2023-05-10 02:04:08 +08:00
|
|
|
{
|
2025-06-28 16:36:05 +08:00
|
|
|
$disable_omp = SPCTarget::isTarget(SPCTarget::GLIBC) ? ' ac_cv_func_omp_pause_resource_all=no' : '';
|
2025-05-22 12:28:00 +07:00
|
|
|
return '--with-imagick=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $disable_omp;
|
2023-05-10 02:04:08 +08:00
|
|
|
}
|
2025-06-17 18:03:27 +07:00
|
|
|
|
|
|
|
|
protected function getStaticAndSharedLibs(): array
|
|
|
|
|
{
|
|
|
|
|
// on centos 7, it will use the symbol _ZTINSt6thread6_StateE, which is not defined in system libstdc++.so.6
|
|
|
|
|
[$static, $shared] = parent::getStaticAndSharedLibs();
|
2025-06-28 16:36:05 +08:00
|
|
|
if (SPCTarget::isTarget(SPCTarget::GLIBC)) {
|
2025-06-17 18:03:27 +07:00
|
|
|
$static .= ' -lstdc++';
|
|
|
|
|
$shared = str_replace('-lstdc++', '', $shared);
|
|
|
|
|
}
|
|
|
|
|
return [$static, $shared];
|
|
|
|
|
}
|
2023-05-10 02:04:08 +08:00
|
|
|
}
|