mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
use SPC\exception\WrongUsageException;
|
|
use SPC\store\FileSystem;
|
|
use SPC\util\executor\UnixAutoconfExecutor;
|
|
|
|
trait unixodbc
|
|
{
|
|
protected function build(): void
|
|
{
|
|
$sysconf_selector = match (PHP_OS_FAMILY) {
|
|
'Darwin' => match (GNU_ARCH) {
|
|
'x86_64' => '/usr/local/etc',
|
|
'aarch64' => '/opt/homebrew/etc',
|
|
default => throw new WrongUsageException('Unsupported architecture: ' . GNU_ARCH),
|
|
},
|
|
'Linux' => '/etc',
|
|
default => throw new WrongUsageException('Unsupported OS: ' . PHP_OS_FAMILY),
|
|
};
|
|
UnixAutoconfExecutor::create($this)
|
|
->configure(
|
|
'--disable-debug',
|
|
'--disable-dependency-tracking',
|
|
"--with-libiconv-prefix={$this->getBuildRootPath()}",
|
|
'--with-included-ltdl',
|
|
"--sysconfdir={$sysconf_selector}",
|
|
'--enable-gui=no',
|
|
)
|
|
->make();
|
|
$this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']);
|
|
foreach (['odbc.pc', 'odbccr.pc', 'odbcinst.pc'] as $file) {
|
|
FileSystem::replaceFileStr(
|
|
BUILD_LIB_PATH . "/pkgconfig/{$file}.pc",
|
|
'$(top_build_prefix)libltdl/libltdlc.la',
|
|
'');
|
|
}
|
|
$this->patchLaDependencyPrefix();
|
|
}
|
|
}
|