2023-05-17 22:08:13 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
|
|
|
|
use SPC\store\FileSystem;
|
2025-06-09 19:32:31 +08:00
|
|
|
use SPC\util\executor\UnixAutoconfExecutor;
|
2025-06-28 16:36:05 +08:00
|
|
|
use SPC\util\SPCTarget;
|
2023-05-17 22:08:13 +08:00
|
|
|
|
|
|
|
|
trait imagemagick
|
|
|
|
|
{
|
|
|
|
|
protected function build(): void
|
|
|
|
|
{
|
2025-06-09 19:32:31 +08:00
|
|
|
$ac = UnixAutoconfExecutor::create($this)
|
|
|
|
|
->optionalLib('libzip', ...ac_with_args('zip'))
|
|
|
|
|
->optionalLib('libjpeg', ...ac_with_args('jpeg'))
|
|
|
|
|
->optionalLib('libpng', ...ac_with_args('png'))
|
|
|
|
|
->optionalLib('libwebp', ...ac_with_args('webp'))
|
|
|
|
|
->optionalLib('libxml2', ...ac_with_args('xml'))
|
|
|
|
|
->optionalLib('libheif', ...ac_with_args('heic'))
|
|
|
|
|
->optionalLib('zlib', ...ac_with_args('zlib'))
|
|
|
|
|
->optionalLib('xz', ...ac_with_args('lzma'))
|
|
|
|
|
->optionalLib('zstd', ...ac_with_args('zstd'))
|
|
|
|
|
->optionalLib('freetype', ...ac_with_args('freetype'))
|
|
|
|
|
->optionalLib('bzip2', ...ac_with_args('bzlib'))
|
2025-07-20 00:10:30 +07:00
|
|
|
->optionalLib('libjxl', ...ac_with_args('jxl'))
|
2025-07-22 12:49:42 +07:00
|
|
|
->optionalLib('jbig', ...ac_with_args('jbig'))
|
2025-06-09 19:32:31 +08:00
|
|
|
->addConfigureArgs(
|
2025-06-28 23:08:17 +08:00
|
|
|
'--disable-openmp',
|
2025-06-09 19:32:31 +08:00
|
|
|
'--without-x',
|
|
|
|
|
);
|
2023-05-17 22:08:13 +08:00
|
|
|
|
2025-06-29 16:00:17 +08:00
|
|
|
// special: linux-static target needs `-static`
|
2025-06-29 22:49:48 +08:00
|
|
|
$ldflags = SPCTarget::isStatic() ? ('-static -ldl') : '-ldl';
|
2023-11-29 00:51:05 +08:00
|
|
|
|
2025-06-09 19:32:31 +08:00
|
|
|
// special: macOS needs -iconv
|
2025-06-29 16:00:17 +08:00
|
|
|
$libs = SPCTarget::getTargetOS() === 'Darwin' ? '-liconv' : '';
|
2025-06-09 19:32:31 +08:00
|
|
|
|
|
|
|
|
$ac->appendEnv([
|
|
|
|
|
'LDFLAGS' => $ldflags,
|
|
|
|
|
'LIBS' => $libs,
|
|
|
|
|
'PKG_CONFIG' => '$PKG_CONFIG --static',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$ac->configure()->make();
|
|
|
|
|
|
2023-05-17 22:08:13 +08:00
|
|
|
$filelist = [
|
|
|
|
|
'ImageMagick.pc',
|
|
|
|
|
'ImageMagick-7.Q16HDRI.pc',
|
|
|
|
|
'Magick++.pc',
|
|
|
|
|
'Magick++-7.Q16HDRI.pc',
|
|
|
|
|
'MagickCore.pc',
|
|
|
|
|
'MagickCore-7.Q16HDRI.pc',
|
|
|
|
|
'MagickWand.pc',
|
|
|
|
|
'MagickWand-7.Q16HDRI.pc',
|
|
|
|
|
];
|
|
|
|
|
$this->patchPkgconfPrefix($filelist);
|
|
|
|
|
foreach ($filelist as $file) {
|
2023-08-20 19:51:45 +08:00
|
|
|
FileSystem::replaceFileRegex(
|
2023-05-17 22:08:13 +08:00
|
|
|
BUILD_LIB_PATH . '/pkgconfig/' . $file,
|
|
|
|
|
'#includearchdir=/include/ImageMagick-7#m',
|
|
|
|
|
'includearchdir=${prefix}/include/ImageMagick-7'
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-06-10 19:46:55 +07:00
|
|
|
$this->patchLaDependencyPrefix();
|
2023-05-17 22:08:13 +08:00
|
|
|
}
|
|
|
|
|
}
|