51 lines
1.8 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-07-18 13:51:33 +07:00
use SPC\store\FileSystem;
2025-06-09 19:32:31 +08:00
use SPC\util\executor\UnixAutoconfExecutor;
2025-07-18 14:39:17 +07:00
use SPC\util\SPCTarget;
trait libtiff
{
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void
{
2025-07-18 14:39:17 +07:00
$libcpp = SPCTarget::getTargetOS() === 'Darwin' ? '-lc++' : '-lstdc++';
2025-07-18 13:51:33 +07:00
FileSystem::replaceFileStr($this->source_dir . '/configure', '-lwebp', '-lwebp -lsharpyuv');
2025-07-18 14:39:17 +07:00
FileSystem::replaceFileStr($this->source_dir . '/configure', '-l"$lerc_lib_name"', '-l"$lerc_lib_name" ' . $libcpp);
2025-06-09 19:32:31 +08:00
UnixAutoconfExecutor::create($this)
->configure(
// zlib deps
'--enable-zlib',
"--with-zlib-include-dir={$this->getIncludeDir()}",
"--with-zlib-lib-dir={$this->getLibDir()}",
// libjpeg deps
'--enable-jpeg',
"--with-jpeg-include-dir={$this->getIncludeDir()}",
"--with-jpeg-lib-dir={$this->getLibDir()}",
2025-07-18 13:51:33 +07:00
'--disable-old-jpeg',
'--disable-jpeg12',
2025-06-09 19:32:31 +08:00
'--disable-libdeflate',
2025-07-18 14:39:17 +07:00
'--disable-tools',
'--disable-contrib',
2025-06-09 19:32:31 +08:00
'--disable-cxx',
2025-07-18 13:51:33 +07:00
'--without-x',
)
2025-07-18 13:51:33 +07:00
->optionalLib('lerc', '--enable-lerc', '--disable-lerc')
->optionalLib('zstd', '--enable-zstd', '--disable-zstd')
->optionalLib('webp', '--enable-webp', '--disable-webp')
->optionalLib('xz', '--enable-lzma', '--disable-lzma')
2025-07-18 14:04:55 +07:00
->optionalLib('jbig', '--enable-jbig', '--disable-jbig')
2025-06-09 19:32:31 +08:00
->make();
$this->patchPkgconfPrefix(['libtiff-4.pc']);
}
}