Add unixodbc

This commit is contained in:
crazywhalecc 2026-02-06 14:20:41 +08:00
parent a5f8402703
commit b6d8bf5639
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,13 @@
unixodbc:
type: library
artifact:
source: 'https://www.unixodbc.org/unixODBC-2.3.12.tar.gz'
metadata:
license-files: [COPYING]
license: LGPL-2.1-only
depends:
- libiconv
static-libs@unix:
- libodbc.a
- libodbccr.a
- libodbcinst.a

View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Exception\WrongUsageException;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\SystemTarget;
#[Library('unixodbc')]
class unixodbc extends LibraryPackage
{
#[BuildFor('Darwin')]
#[BuildFor('Linux')]
public function buildUnix(): void
{
$sysconf_selector = match ($os = SystemTarget::getTargetOS()) {
'Darwin' => match (SystemTarget::getTargetArch()) {
'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: {$os}"),
};
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']);
$this->patchLaDependencyPrefix();
}
}