37 lines
1.3 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
2025-01-28 19:37:50 +08:00
use SPC\builder\linux\library\LinuxLibraryBase;
trait pkgconfig
{
protected function build(): void
{
$cflags = PHP_OS_FAMILY !== 'Linux' ? '-Wimplicit-function-declaration -Wno-int-conversion' : '';
2025-01-28 19:37:50 +08:00
$ldflags = !($this instanceof LinuxLibraryBase) || $this->builder->libc === 'glibc' ? '' : '--static';
shell()->cd($this->source_dir)
->setEnv(['CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", 'LDFLAGS' => "{$this->getLibExtraLdFlags()} {$ldflags}", 'LIBS' => $this->getLibExtraLibs()])
2024-04-07 15:52:24 +08:00
->execWithEnv(
'./configure ' .
'--disable-shared ' .
'--enable-static ' .
'--with-internal-glib ' .
2024-02-20 14:03:44 +08:00
'--disable-host-tool ' .
'--with-pic ' .
'--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');
}
}