2023-10-31 13:09:01 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
2025-07-10 12:59:27 +08:00
|
|
|
use SPC\builder\linux\SystemUtil;
|
2023-10-31 13:09:01 +01:00
|
|
|
use SPC\exception\WrongUsageException;
|
2024-07-28 14:02:17 +08:00
|
|
|
use SPC\store\FileSystem;
|
2023-10-31 13:09:01 +01:00
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('imap')]
|
|
|
|
|
class imap extends Extension
|
|
|
|
|
{
|
2024-07-28 14:02:17 +08:00
|
|
|
public function patchBeforeBuildconf(): bool
|
|
|
|
|
{
|
|
|
|
|
if ($this->builder->getLib('openssl')) {
|
|
|
|
|
// sometimes imap with openssl does not contain zlib (required by openssl)
|
|
|
|
|
// we need to add it manually
|
|
|
|
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/imap/config.m4', 'TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD"', 'TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD -lz"');
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-16 13:01:11 +08:00
|
|
|
public function validate(): void
|
2023-10-31 13:09:01 +01:00
|
|
|
{
|
|
|
|
|
if ($this->builder->getOption('enable-zts')) {
|
|
|
|
|
throw new WrongUsageException('ext-imap is not thread safe, do not build it with ZTS builds');
|
|
|
|
|
}
|
2024-05-16 13:01:11 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-27 11:12:19 +07:00
|
|
|
public function getUnixConfigureArg(bool $shared = false): string
|
2024-05-16 13:01:11 +08:00
|
|
|
{
|
2023-10-31 13:09:01 +01:00
|
|
|
$arg = '--with-imap=' . BUILD_ROOT_PATH;
|
|
|
|
|
if ($this->builder->getLib('openssl') !== null) {
|
|
|
|
|
$arg .= ' --with-imap-ssl=' . BUILD_ROOT_PATH;
|
|
|
|
|
}
|
|
|
|
|
return $arg;
|
|
|
|
|
}
|
2025-07-10 12:59:27 +08:00
|
|
|
|
|
|
|
|
public function patchBeforeMake(): bool
|
|
|
|
|
{
|
2025-07-19 15:10:42 +07:00
|
|
|
$patched = parent::patchBeforeMake();
|
2025-07-10 12:59:27 +08:00
|
|
|
if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::isMuslDist()) {
|
2025-07-19 15:10:42 +07:00
|
|
|
return $patched;
|
2025-07-10 12:59:27 +08:00
|
|
|
}
|
2025-08-01 00:09:05 +08:00
|
|
|
$extra_libs = trim((getenv('SPC_EXTRA_LIBS') ?: '') . ' -lcrypt');
|
2025-07-10 12:59:27 +08:00
|
|
|
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-10-31 13:09:01 +01:00
|
|
|
}
|