48 lines
1.6 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
2025-03-10 10:25:35 +01:00
use SPC\store\FileSystem;
trait libacl
{
/**
* @throws FileSystemException
*/
public function patchBeforeMake(): bool
2025-03-10 10:25:35 +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;
}
/**
* @throws RuntimeException
*/
protected function build(): void
{
2025-03-10 10:25:35 +01:00
$cflags = PHP_OS_FAMILY !== 'Linux' ? '-Wimplicit-function-declaration -Wno-int-conversion' : '';
2025-03-10 11:42:44 +01:00
$ldflags = '--static';
shell()->cd($this->source_dir)
->setEnv([
2025-03-10 10:25:35 +01:00
'CFLAGS' => trim('-I' . BUILD_INCLUDE_PATH . ' ' . $this->getLibExtraCFlags() . ' ' . $cflags),
'LDFLAGS' => trim('-L' . BUILD_LIB_PATH . ' ' . $this->getLibExtraLdFlags() . ' ' . $ldflags),
'LIBS' => $this->getLibExtraLibs(),
])
->execWithEnv('./autogen.sh')
->execWithEnv('./configure --prefix= --enable-static --disable-shared --disable-tests --disable-nls')
->execWithEnv("make -j {$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['libacl.pc'], PKGCONF_PATCH_PREFIX);
}
}