2023-10-23 00:37:28 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\linux\library;
|
|
|
|
|
|
2025-03-14 18:22:50 +08:00
|
|
|
use SPC\exception\FileSystemException;
|
2023-10-23 00:37:28 +08:00
|
|
|
use SPC\exception\RuntimeException;
|
|
|
|
|
|
|
|
|
|
class libffi extends LinuxLibraryBase
|
|
|
|
|
{
|
|
|
|
|
public const NAME = 'libffi';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws RuntimeException
|
2025-03-14 18:22:50 +08:00
|
|
|
* @throws FileSystemException
|
2023-10-23 00:37:28 +08:00
|
|
|
*/
|
|
|
|
|
public function build(): void
|
|
|
|
|
{
|
|
|
|
|
[$lib, , $destdir] = SEPARATED_PATH;
|
2025-03-14 18:22:50 +08:00
|
|
|
$arch = getenv('SPC_ARCH');
|
2023-10-23 00:37:28 +08:00
|
|
|
|
|
|
|
|
shell()->cd($this->source_dir)
|
2025-06-09 10:24:06 +08:00
|
|
|
->initLibBuildEnv($this)
|
|
|
|
|
->exec(
|
2023-10-23 00:37:28 +08:00
|
|
|
'./configure ' .
|
|
|
|
|
'--enable-static ' .
|
|
|
|
|
'--disable-shared ' .
|
2025-03-14 18:22:50 +08:00
|
|
|
"--host={$arch}-unknown-linux " .
|
|
|
|
|
"--target={$arch}-unknown-linux " .
|
2025-03-19 07:49:25 +01:00
|
|
|
'--prefix= ' .
|
2023-10-23 00:37:28 +08:00
|
|
|
"--libdir={$lib}"
|
|
|
|
|
)
|
2025-06-09 10:24:06 +08:00
|
|
|
->exec('make clean')
|
|
|
|
|
->exec("make -j{$this->builder->concurrency}")
|
|
|
|
|
->exec("make install DESTDIR={$destdir}");
|
2023-10-23 00:37:28 +08:00
|
|
|
|
|
|
|
|
if (is_file(BUILD_ROOT_PATH . '/lib64/libffi.a')) {
|
|
|
|
|
copy(BUILD_ROOT_PATH . '/lib64/libffi.a', BUILD_ROOT_PATH . '/lib/libffi.a');
|
|
|
|
|
unlink(BUILD_ROOT_PATH . '/lib64/libffi.a');
|
|
|
|
|
}
|
|
|
|
|
$this->patchPkgconfPrefix(['libffi.pc']);
|
|
|
|
|
}
|
|
|
|
|
}
|