2025-12-08 16:58:42 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Package\Library;
|
|
|
|
|
|
|
|
|
|
use StaticPHP\Attribute\Package\BuildFor;
|
|
|
|
|
use StaticPHP\Attribute\Package\Library;
|
2026-02-03 10:17:13 +08:00
|
|
|
use StaticPHP\Attribute\Package\PatchBeforeBuild;
|
2025-12-08 16:58:42 +08:00
|
|
|
use StaticPHP\Package\LibraryPackage;
|
|
|
|
|
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
|
|
|
|
use StaticPHP\Util\FileSystem;
|
|
|
|
|
|
|
|
|
|
#[Library('libedit')]
|
|
|
|
|
class libedit extends LibraryPackage
|
|
|
|
|
{
|
2026-02-03 10:17:13 +08:00
|
|
|
#[PatchBeforeBuild]
|
2025-12-08 16:58:42 +08:00
|
|
|
public function patchBeforeBuild(): void
|
|
|
|
|
{
|
|
|
|
|
FileSystem::replaceFileRegex(
|
|
|
|
|
"{$this->getSourceDir()}/src/sys.h",
|
|
|
|
|
'|//#define\s+strl|',
|
|
|
|
|
'#define strl'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[BuildFor('Darwin')]
|
|
|
|
|
#[BuildFor('Linux')]
|
|
|
|
|
public function build(): void
|
|
|
|
|
{
|
|
|
|
|
UnixAutoconfExecutor::create($this)
|
|
|
|
|
->appendEnv(['CFLAGS' => '-D__STDC_ISO_10646__=201103L'])
|
|
|
|
|
->configure()
|
|
|
|
|
->make();
|
|
|
|
|
$this->patchPkgconfPrefix(['libedit.pc']);
|
|
|
|
|
}
|
|
|
|
|
}
|