From 0007043f4a483a07ccb53e45e3c8e172e833ade2 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Oct 2023 19:37:13 +0200 Subject: [PATCH] fix imagemagick and postgresql builds with different libs --- src/SPC/builder/extension/imagick.php | 7 ++-- src/SPC/builder/unix/library/imagemagick.php | 36 ++++++++++++-------- src/SPC/builder/unix/library/postgresql.php | 17 ++++++--- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index 217b7aa9..41a1c20e 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -12,11 +12,10 @@ class imagick extends Extension { public function patchBeforeBuildconf(): bool { - // linux need to link library manually, we add it to extra-libs + // imagick may call omp_pause_all which requires -lgomp $extra_libs = $this->builder->getOption('extra-libs', ''); - if (!str_contains($extra_libs, 'libMagickCore')) { - $extra_libs .= ' /usr/lib/libMagick++-7.Q16HDRI.a /usr/lib/libMagickCore-7.Q16HDRI.a /usr/lib/libMagickWand-7.Q16HDRI.a'; - } + $libf = BUILD_LIB_PATH; + $extra_libs .= " {$libf}/libMagick++-7.Q16HDRI.a {$libf}/libMagickWand-7.Q16HDRI.a {$libf}/libMagickCore-7.Q16HDRI.a -lgomp "; $this->builder->setOption('extra-libs', $extra_libs); return true; } diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index f1530b76..f33aa87d 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -16,23 +16,31 @@ trait imagemagick */ protected function build(): void { - $extra = '--without-jxl --without-xml --without-zstd --without-x --disable-openmp '; - // libzip support - $extra .= $this->builder->getLib('libzip') ? '--with-zip ' : '--without-zip '; - // jpeg support - $extra .= $this->builder->getLib('libjpeg') ? '--with-jpeg ' : ''; - // png support - $extra .= $this->builder->getLib('libpng') ? '--with-png ' : ''; - // webp support - $extra .= $this->builder->getLib('libwebp') ? '--with-webp ' : ''; - // zstd support - // $extra .= $this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd '; - // freetype support - $extra .= $this->builder->getLib('freetype') ? '--with-freetype ' : '--without-freetype '; + $extra = '--without-jxl --without-x --disable-openmp '; + $required_libs = ''; + $optional_libs = [ + 'libzip' => 'zip', + 'libjpeg' => 'jpeg', + 'libpng' => 'png', + 'libwebp' => 'webp', + 'libxml2' => 'xml', + 'zlib' => 'zlib', + 'zstd' => 'zstd', + 'freetype' => 'freetype', + ]; + foreach ($optional_libs as $lib => $option) { + $extra .= $this->builder->getLib($lib) ? "--with-{$option} " : "--without-{$option} "; + if ($this->builder->getLib($lib)) { + $required_libs .= ' ' . $this->builder->getLib($lib)->getStaticLibFiles(); + } + } shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + "{$this->builder->configure_env} " . + 'LDFLAGS="-static" ' . + "LIBS='{$required_libs}' " . + './configure ' . '--enable-static --disable-shared ' . $extra . '--prefix=' diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 758e8a87..eaf6710e 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -21,9 +21,16 @@ trait postgresql $env = $this->builder->configure_env; $envs = $env; $packages = 'openssl zlib readline libxml-2.0 zlib'; - foreach (['zstd', 'ldap', 'pam', 'libxslt'] as $lib) { + $optional_packages = [ + 'zstd' => 'libzstd', + 'ldap' => 'ldap', + 'libpam' => 'libpam', + 'libxslt' => 'libxslt', + 'icu' => 'icu-i18n', + ]; + foreach ($optional_packages as $lib => $pkg) { if ($this->getBuilder()->getLib($lib)) { - $packages .= ' ' . $lib; + $packages .= ' ' . $pkg; } } @@ -62,11 +69,11 @@ trait postgresql '--with-ssl=openssl ' . '--with-readline ' . '--with-libxml ' . - ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . - ($this->builder->getLib('pam') ? '--with-pam ' : '--without-pam ') . - ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . + ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . + ($this->builder->getLib('libpam') ? '--with-pam ' : '--without-pam ') . ($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') . + ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . '--without-lz4 ' . '--without-perl ' . '--without-python ' .