mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 00:05:42 +08:00
bzip2, fastlz, jbig, qdbm: thread SPC_DEFAULT_CFLAGS into the
hand-rolled Makefile patches and shell compile commands. Backward
compatible when the env var is empty.
icu: append SPC_DEFAULT_CXXFLAGS/LDFLAGS to runConfigureICU's CXXFLAGS
and LDFLAGS so user flags reach the bundled cxx invocation.
openssl: append user CFLAGS/LDFLAGS after the target name on Configure
so options like -flto and -fprofile-* reach the openssl build.
libheif: rewrite libheif 1.22+'s C-incompatible
`struct heif_bad_pixel { uint32_t row; uint32_t column; };` as a
typedef so C consumers compile.
ncurses: filter the clang/zig-cc "N warning(s) generated." stdout line
out of MKlib_gen.sh's preprocessor pipe before sed turns it into
invalid C in lib_gen.c.
libaom: detect target CPU from SystemTarget instead of hard-coding
generic, fall back to generic only when neither nasm nor yasm is
available, and turn off examples/tests/tools/docs.
49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Package\Library;
|
|
|
|
use StaticPHP\Attribute\Package\BuildFor;
|
|
use StaticPHP\Attribute\Package\Library;
|
|
use StaticPHP\Attribute\Package\PatchBeforeBuild;
|
|
use StaticPHP\Package\LibraryPackage;
|
|
use StaticPHP\Package\PackageBuilder;
|
|
use StaticPHP\Util\FileSystem;
|
|
|
|
#[Library('jbig')]
|
|
class jbig
|
|
{
|
|
#[PatchBeforeBuild]
|
|
public function patchBeforeBuild(LibraryPackage $lib): void
|
|
{
|
|
$extra = trim((string) getenv('SPC_DEFAULT_CFLAGS'));
|
|
$cflags = ($extra !== '' ? $extra : '-O2') . ' -W -Wno-unused-result -fPIC';
|
|
FileSystem::replaceFileStr($lib->getSourceDir() . '/Makefile', 'CFLAGS = -O2 -W -Wno-unused-result', "CFLAGS = {$cflags}");
|
|
}
|
|
|
|
#[BuildFor('Darwin')]
|
|
#[BuildFor('Linux')]
|
|
public function buildUnix(LibraryPackage $lib, PackageBuilder $builder): void
|
|
{
|
|
$ccenv = [
|
|
'CC' => getenv('CC'),
|
|
'CXX' => getenv('CXX'),
|
|
'AR' => getenv('AR'),
|
|
'LD' => getenv('LD'),
|
|
];
|
|
$env = [];
|
|
foreach ($ccenv as $k => $v) {
|
|
$env[] = "{$k}={$v}";
|
|
}
|
|
$env_str = implode(' ', $env);
|
|
shell()->cd($lib->getSourceDir())->initializeEnv($lib)
|
|
->exec("make -j{$builder->concurrency} {$env_str} lib")
|
|
->exec("cp libjbig/libjbig.a {$lib->getLibDir()}")
|
|
->exec("cp libjbig/libjbig85.a {$lib->getLibDir()}")
|
|
->exec("cp libjbig/jbig.h {$lib->getIncludeDir()}")
|
|
->exec("cp libjbig/jbig85.h {$lib->getIncludeDir()}")
|
|
->exec("cp libjbig/jbig_ar.h {$lib->getIncludeDir()}");
|
|
}
|
|
}
|