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';
|
|
|
|
|
|
2024-06-25 06:38:38 +02:00
|
|
|
$shell = shell()->cd($this->source_dir)
|
2025-05-15 14:45:51 +07:00
|
|
|
->setEnv([
|
|
|
|
|
'CFLAGS' => $this->getLibExtraCFlags(),
|
|
|
|
|
'LDFLAGS' => $this->getLibExtraLdFlags(),
|
|
|
|
|
'LIBS' => $this->getLibExtraLibs(),
|
|
|
|
|
])
|
2025-03-10 00:39:20 +08:00
|
|
|
->execWithEnv(
|
2024-03-01 19:19:47 +08:00
|
|
|
'./configure ' .
|
2025-05-31 14:35:59 +07:00
|
|
|
'--enable-static --disable-shared --with-pic ' .
|
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-03-10 00:39:20 +08:00
|
|
|
$shell->execWithEnv('make clean');
|
2024-06-25 06:38:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$shell
|
2025-03-10 00:39:20 +08:00
|
|
|
->execWithEnv("make -j{$this->builder->concurrency}")
|
|
|
|
|
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
2024-03-01 19:19:47 +08:00
|
|
|
$this->patchPkgconfPrefix(['libtiff-4.pc']);
|
|
|
|
|
}
|
|
|
|
|
}
|