54 lines
2.1 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;
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
{
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)
->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 ' .
'--without-cyrus-sasl ' .
2023-10-01 01:06:11 +08:00
$alt .
2023-09-18 13:43:58 +02:00
'--prefix='
)
->exec('make clean')
// 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);
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(['libldap.la', 'liblber.la']);
2023-09-18 13:43:58 +02:00
}
}