Files
static-php-cli/src/SPC/builder/unix/library/krb5.php

67 lines
2.3 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
2026-04-16 14:29:07 +07:00
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\executor\UnixAutoconfExecutor;
2025-11-18 17:22:27 +01:00
use SPC\util\SPCConfigUtil;
trait krb5
{
protected function build(): void
{
$origin_source_dir = $this->source_dir;
$this->source_dir .= '/src';
2026-04-10 12:49:10 +08:00
shell()->cd($this->source_dir)->exec('ls -lah');
2026-04-10 12:24:25 +08:00
if (!file_exists($this->source_dir . '/configure')) {
shell()->cd($this->source_dir)->exec('autoreconf -if');
}
2025-11-18 17:22:27 +01:00
$libs = array_map(fn ($x) => $x->getName(), $this->getDependencies(true));
$spc = new SPCConfigUtil($this->builder, ['no_php' => true, 'libs_only_deps' => true]);
$config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs', false));
2025-11-19 14:48:10 +01:00
$extraEnv = [
'CFLAGS' => '-fcommon',
'LIBS' => $config['libs'],
];
if (getenv('SPC_LD_LIBRARY_PATH') && getenv('SPC_LIBRARY_PATH')) {
2025-11-19 14:48:10 +01:00
$extraEnv = [...$extraEnv, ...[
'LD_LIBRARY_PATH' => getenv('SPC_LD_LIBRARY_PATH'),
'LIBRARY_PATH' => getenv('SPC_LIBRARY_PATH'),
2025-11-19 14:48:10 +01:00
]];
}
2025-11-19 13:54:17 +01:00
$args = [
'--disable-nls',
'--disable-rpath',
2025-11-19 13:54:45 +01:00
'--without-system-verto',
];
2025-11-19 13:54:17 +01:00
if (PHP_OS_FAMILY === 'Darwin') {
2025-11-19 15:20:05 +01:00
$extraEnv['LDFLAGS'] = '-framework Kerberos';
2025-11-19 13:54:17 +01:00
$args[] = 'ac_cv_func_secure_getenv=no';
}
2026-04-16 14:29:07 +07:00
$make = UnixAutoconfExecutor::create($this)
2025-11-19 14:48:10 +01:00
->appendEnv($extraEnv)
2025-11-18 14:35:58 +01:00
->optionalLib('ldap', '--with-ldap', '--without-ldap')
2025-11-18 17:50:49 +01:00
->optionalLib('libedit', '--with-libedit', '--without-libedit')
2026-04-16 14:29:07 +07:00
->configure(...$args);
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
$make->exec('find . -name Makefile -exec sed -i "s/-Werror=incompatible-pointer-types//g" {} +');
}
$make->make();
$this->patchPkgconfPrefix([
'krb5-gssapi.pc',
'krb5.pc',
'kadm-server.pc',
'kadm-client.pc',
'kdb.pc',
'mit-krb5-gssapi.pc',
'mit-krb5.pc',
'gssrpc.pc',
]);
$this->source_dir = $origin_source_dir;
}
}