2024-03-01 19:19:47 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
|
|
|
|
use SPC\exception\FileSystemException;
|
|
|
|
|
use SPC\exception\RuntimeException;
|
|
|
|
|
|
|
|
|
|
trait libtiff
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
|
|
|
|
protected function build(): void
|
|
|
|
|
{
|
2025-01-25 17:15:53 +09:00
|
|
|
// zlib
|
|
|
|
|
$extra_libs = '--enable-zlib --with-zlib-include-dir=' . BUILD_ROOT_PATH . '/include --with-zlib-lib-dir=' . BUILD_ROOT_PATH . '/lib';
|
|
|
|
|
// libjpeg
|
|
|
|
|
$extra_libs .= ' --enable-jpeg --disable-old-jpeg --disable-jpeg12 --with-jpeg-include-dir=' . BUILD_ROOT_PATH . '/include --with-jpeg-lib-dir=' . BUILD_ROOT_PATH . '/lib';
|
|
|
|
|
// We disabled lzma, zstd, webp, libdeflate by default to reduce the size of the binary
|
|
|
|
|
$extra_libs .= ' --disable-lzma --disable-zstd --disable-webp --disable-libdeflate';
|
|
|
|
|
|
2025-06-09 10:24:06 +08:00
|
|
|
$shell = shell()->cd($this->source_dir)->initLibBuildEnv($this)
|
|
|
|
|
->exec(
|
2024-03-01 19:19:47 +08:00
|
|
|
'./configure ' .
|
|
|
|
|
'--enable-static --disable-shared ' .
|
2025-01-25 17:15:53 +09:00
|
|
|
"{$extra_libs} " .
|
2024-03-01 19:19:47 +08:00
|
|
|
'--disable-cxx ' .
|
|
|
|
|
'--prefix='
|
2024-06-25 06:38:38 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// TODO: Remove this check when https://gitlab.com/libtiff/libtiff/-/merge_requests/635 will be merged and released
|
|
|
|
|
if (file_exists($this->source_dir . '/html')) {
|
2025-06-09 10:24:06 +08:00
|
|
|
$shell->exec('make clean');
|
2024-06-25 06:38:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$shell
|
2025-06-09 10:24:06 +08:00
|
|
|
->exec("make -j{$this->builder->concurrency}")
|
|
|
|
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
2024-03-01 19:19:47 +08:00
|
|
|
$this->patchPkgconfPrefix(['libtiff-4.pc']);
|
|
|
|
|
}
|
|
|
|
|
}
|