2023-10-31 13:09:01 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-31 13:09:01 +01:00
|
|
|
/**
|
|
|
|
|
* @throws WrongUsageException
|
|
|
|
|
*/
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getUnixConfigureArg(): string
|
|
|
|
|
{
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|