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;
|
|
|
|
|
|
2023-09-18 13:43:58 +02:00
|
|
|
trait ldap
|
|
|
|
|
{
|
2024-01-07 11:09:26 +08:00
|
|
|
public function patchBeforeBuild(): bool
|
|
|
|
|
{
|
2025-03-14 18:22:50 +08:00
|
|
|
$extra = getenv('SPC_LIBC') === 'glibc' ? '-ldl -lpthread -lm -lresolv -lutil' : '';
|
2025-03-10 00:39:20 +08:00
|
|
|
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
|
|
|
|
|
{
|
2023-10-01 01:06:11 +08:00
|
|
|
$alt = '';
|
|
|
|
|
// openssl support
|
2024-01-07 11:09:26 +08:00
|
|
|
$alt .= $this->builder->getLib('openssl') ? '--with-tls=openssl ' : '';
|
2023-10-01 01:06:11 +08:00
|
|
|
// gmp support
|
|
|
|
|
$alt .= $this->builder->getLib('gmp') ? '--with-mp=gmp ' : '';
|
|
|
|
|
// libsodium support
|
2024-01-07 11:09:26 +08:00
|
|
|
$alt .= $this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : '--enable-argon2=no ';
|
2023-11-30 13:06:36 +08:00
|
|
|
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
|
|
|
|
|
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig');
|
2025-06-09 11:12:34 +08:00
|
|
|
shell()->cd($this->source_dir)->initializeEnv($this)
|
2025-06-09 10:24:06 +08:00
|
|
|
->appendEnv(['LDFLAGS' => "-L{$this->getLibDir()}"])
|
|
|
|
|
->exec(
|
2024-04-07 15:52:24 +08:00
|
|
|
$this->builder->makeAutoconfFlags(AUTOCONF_CPPFLAGS) .
|
2023-09-18 13:43:58 +02:00
|
|
|
' ./configure ' .
|
|
|
|
|
'--enable-static ' .
|
|
|
|
|
'--disable-shared ' .
|
2025-05-31 14:21:55 +07:00
|
|
|
'--with-pic ' .
|
2023-09-18 13:43:58 +02:00
|
|
|
'--disable-slapd ' .
|
|
|
|
|
'--without-systemd ' .
|
2023-09-23 14:10:35 +08:00
|
|
|
'--without-cyrus-sasl ' .
|
2023-10-01 01:06:11 +08:00
|
|
|
$alt .
|
2023-09-18 13:43:58 +02:00
|
|
|
'--prefix='
|
|
|
|
|
)
|
|
|
|
|
->exec('make clean')
|
2023-09-23 14:10:35 +08:00
|
|
|
// remove tests and doc to prevent compile failed with error: soelim not found
|
|
|
|
|
->exec('sed -i -e "s/SUBDIRS= include libraries clients servers tests doc/SUBDIRS= include libraries clients servers/g" Makefile')
|
2023-09-18 13:43:58 +02:00
|
|
|
->exec("make -j{$this->builder->concurrency}")
|
|
|
|
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
2025-06-07 21:16:15 +07:00
|
|
|
|
|
|
|
|
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']);
|
2025-05-20 22:19:09 +07:00
|
|
|
$this->patchLaDependencyPrefix(['libldap.la', 'liblber.la']);
|
2023-09-18 13:43:58 +02:00
|
|
|
}
|
|
|
|
|
}
|