Add gettext

This commit is contained in:
crazywhalecc 2026-02-03 10:05:39 +08:00
parent e732543bd7
commit e4d6723b01
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,19 @@
gettext:
type: library
artifact:
source:
type: filelist
url: 'https://ftp.gnu.org/pub/gnu/gettext/'
regex: '/href="(?<file>gettext-(?<version>[^"]+)\.tar\.xz)"/'
metadata:
license-files: [gettext-runtime/intl/COPYING.LIB]
license: LGPL-2.1-or-later
static-libs@unix:
- libintl.a
depends:
- libiconv
suggests:
- ncurses
- libxml2
frameworks:
- CoreFoundation

View File

@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
#[Library('gettext')]
class gettext
{
#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $pkg, PackageBuilder $builder): void
{
$autoconf = UnixAutoconfExecutor::create($pkg)
->optionalPackage('ncurses', "--with-libncurses-prefix={$pkg->getBuildRootPath()}")
->optionalPackage('libxml2', "--with-libxml2-prefix={$pkg->getBuildRootPath()}")
->addConfigureArgs(
'--disable-java',
'--disable-c++',
'--disable-d',
'--disable-rpath',
'--disable-modula2',
'--disable-libasprintf',
'--with-included-libintl',
"--with-iconv-prefix={$pkg->getBuildRootPath()}",
);
// zts
if ($builder->getOption('enable-zts')) {
$autoconf->addConfigureArgs('--enable-threads=isoc+posix')
->appendEnv([
'CFLAGS' => '-lpthread -D_REENTRANT',
'LDFLGAS' => '-lpthread',
]);
} else {
$autoconf->addConfigureArgs('--disable-threads');
}
$autoconf->configure()->make(dir: "{$pkg->getSourceDir()}/gettext-runtime/intl");
$pkg->patchLaDependencyPrefix();
}
}