54 lines
1.9 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
{
2024-01-07 11:37:06 +08:00
FileSystem::replaceFileStr($this->source_dir . '/configure', '"-lssl -lcrypto', '"-lssl -lcrypto -lz');
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');
2024-04-07 15:52:24 +08:00
$ldflags = '-L' . BUILD_LIB_PATH;
2023-09-18 13:43:58 +02:00
shell()->cd($this->source_dir)
2024-04-07 15:52:24 +08:00
->setEnv([
'CFLAGS' => $this->getLibExtraCFlags(),
'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags,
'LIBS' => $this->getLibExtraLibs(),
])
->execWithEnv(
$this->builder->makeAutoconfFlags(AUTOCONF_CPPFLAGS) .
2023-09-18 13:43:58 +02:00
' ./configure ' .
'--enable-static ' .
'--disable-shared ' .
'--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);
$this->patchPkgconfPrefix(['ldap.pc', 'lber.pc']);
}
}