2023-05-10 02:04:08 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
2025-01-28 19:37:50 +08:00
|
|
|
use SPC\builder\linux\library\LinuxLibraryBase;
|
|
|
|
|
|
2023-05-10 02:04:08 +08:00
|
|
|
trait pkgconfig
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
protected function build(): void
|
2023-05-10 02:04:08 +08:00
|
|
|
{
|
2025-01-28 19:37:50 +08:00
|
|
|
$cflags = PHP_OS_FAMILY !== 'Linux' ? "{$this->builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion" : '';
|
2025-03-14 18:22:50 +08:00
|
|
|
$ldflags = !($this instanceof LinuxLibraryBase) || getenv('SPC_LIBC') === 'glibc' ? '' : '--static';
|
2023-05-10 02:04:08 +08:00
|
|
|
|
|
|
|
|
shell()->cd($this->source_dir)
|
2025-03-10 00:39:20 +08:00
|
|
|
->setEnv(['CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", 'LDFLAGS' => "{$this->getLibExtraLdFlags()} {$ldflags}", 'LIBS' => $this->getLibExtraLibs()])
|
2024-04-07 15:52:24 +08:00
|
|
|
->execWithEnv(
|
2023-05-10 02:04:08 +08:00
|
|
|
'./configure ' .
|
|
|
|
|
'--disable-shared ' .
|
|
|
|
|
'--enable-static ' .
|
2023-08-20 19:51:45 +08:00
|
|
|
'--with-internal-glib ' .
|
2024-02-20 14:03:44 +08:00
|
|
|
'--disable-host-tool ' .
|
|
|
|
|
'--with-pic ' .
|
2023-05-10 02:04:08 +08:00
|
|
|
'--prefix=' . BUILD_ROOT_PATH . ' ' .
|
|
|
|
|
'--without-sysroot ' .
|
|
|
|
|
'--without-system-include-path ' .
|
|
|
|
|
'--without-system-library-path ' .
|
|
|
|
|
'--without-pc-path'
|
|
|
|
|
)
|
|
|
|
|
->exec('make clean')
|
2024-04-07 15:52:24 +08:00
|
|
|
->execWithEnv("make -j{$this->builder->concurrency}")
|
|
|
|
|
->execWithEnv('make install-exec');
|
2024-02-20 14:03:44 +08:00
|
|
|
shell()->exec('strip ' . BUILD_ROOT_PATH . '/bin/pkg-config');
|
2023-05-10 02:04:08 +08:00
|
|
|
}
|
|
|
|
|
}
|