43 lines
1.5 KiB
PHP
Raw Normal View History

2023-09-18 13:43:58 +02:00
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
2024-01-07 11:09:26 +08:00
use SPC\store\FileSystem;
2025-06-09 19:32:31 +08:00
use SPC\util\executor\UnixAutoconfExecutor;
2024-01-07 11:09:26 +08:00
2023-09-18 13:43:58 +02:00
trait ldap
{
2024-01-07 11:09:26 +08:00
public function patchBeforeBuild(): bool
{
$extra = getenv('SPC_LIBC') === 'glibc' ? '-ldl -lpthread -lm -lresolv -lutil' : '';
FileSystem::replaceFileStr($this->source_dir . '/configure', '"-lssl -lcrypto', '"-lssl -lcrypto -lz ' . $extra);
2024-01-07 11:09:26 +08:00
return true;
}
2023-09-18 13:43:58 +02:00
protected function build(): void
{
2025-06-09 19:32:31 +08:00
UnixAutoconfExecutor::create($this)
->optionalLib('openssl', '--with-tls=openssl')
->optionalLib('gmp', '--with-mp=gmp')
->optionalLib('libsodium', '--with-argon2=libsodium', '--enable-argon2=no')
->addConfigureArgs(
'--disable-slapd',
'--without-systemd',
'--without-cyrus-sasl',
2023-09-18 13:43:58 +02:00
)
2025-06-10 12:28:28 +08:00
->appendEnv([
'LDFLAGS' => "-L{$this->getLibDir()}",
'CPPFLAGS' => "-I{$this->getIncludeDir()}",
])
2025-06-09 19:32:31 +08:00
->configure()
->exec('sed -i -e "s/SUBDIRS= include libraries clients servers tests doc/SUBDIRS= include libraries clients servers/g" Makefile')
2025-06-09 19:32:31 +08:00
->make();
FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/ldap.pc', 'Libs: -L${libdir} -lldap', 'Libs: -L${libdir} -lldap -llber');
2023-09-18 13:43:58 +02:00
$this->patchPkgconfPrefix(['ldap.pc', 'lber.pc']);
$this->patchLaDependencyPrefix();
2023-09-18 13:43:58 +02:00
}
}