2025-03-05 11:35:03 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
2025-03-10 11:25:38 +01:00
|
|
|
use SPC\exception\FileSystemException;
|
2025-03-05 11:35:03 +01:00
|
|
|
use SPC\exception\RuntimeException;
|
2025-03-10 10:25:35 +01:00
|
|
|
use SPC\store\FileSystem;
|
2025-03-05 11:35:03 +01:00
|
|
|
|
|
|
|
|
trait libacl
|
|
|
|
|
{
|
2025-03-10 11:25:38 +01:00
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
*/
|
|
|
|
|
public function patchBeforeMake(): bool
|
2025-03-10 10:25:35 +01:00
|
|
|
{
|
2025-03-10 11:25:38 +01:00
|
|
|
$file_path = SOURCE_PATH . '/php-src/Makefile';
|
|
|
|
|
$file_content = FileSystem::readFile($file_path);
|
|
|
|
|
if (!preg_match('/FPM_EXTRA_LIBS =(.*)-lacl/', $file_content)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/Makefile', '/FPM_EXTRA_LIBS =(.*)-lacl ?(.*)/', 'FPM_EXTRA_LIBS =$1$2');
|
2025-03-10 10:25:35 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-05 11:35:03 +01:00
|
|
|
/**
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
|
|
|
|
protected function build(): void
|
|
|
|
|
{
|
2025-06-09 10:24:06 +08:00
|
|
|
shell()->cd($this->source_dir)->initLibBuildEnv($this)
|
|
|
|
|
->appendEnv(['CFLAGS' => "-I{$this->getIncludeDir()}", 'LDFLAGS' => "-L{$this->getLibDir()}"])
|
|
|
|
|
->exec('libtoolize --force --copy')
|
|
|
|
|
->exec('./autogen.sh || autoreconf -if')
|
|
|
|
|
->exec('./configure --prefix= --enable-static --disable-shared --disable-tests --disable-nls')
|
|
|
|
|
->exec("make -j {$this->builder->concurrency}")
|
2025-03-05 11:35:03 +01:00
|
|
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
|
|
|
|
|
|
|
|
|
$this->patchPkgconfPrefix(['libacl.pc'], PKGCONF_PATCH_PREFIX);
|
|
|
|
|
}
|
|
|
|
|
}
|