diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index 06efa8b1..461164d7 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -25,8 +25,8 @@ class pgsql extends Extension { if ($this->builder->getPHPVersionID() >= 80400) { $libfiles = $this->getLibFilesString(); - $libfiles = str_replace(BUILD_LIB_PATH . '/lib', '-l', $libfiles); - $libfiles = str_replace('.a', '', $libfiles); + $libfiles = deduplicate_flags($libfiles); + $libfiles = clean_spaces($libfiles); return '--with-pgsql' . ($shared ? '=shared' : '') . ' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' ' . $libfiles . '"'; diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 0a4ed19a..da4bd0aa 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -56,10 +56,11 @@ class openssl extends LinuxLibraryBase // TODO: in v3 use the following: $openssl_dir ??= SystemUtil::getOSRelease()['dist'] === 'redhat' ? '/etc/pki/tls' : '/etc/ssl'; $openssl_dir ??= '/etc/ssl'; $ex_lib = trim($ex_lib); + $noShared = getenv('SPC_LINK_STATIC') ? 'no-shared' : ''; shell()->cd($this->source_dir)->initializeEnv($this) ->exec( - "./Configure {$extra} " . + "./Configure {$noShared} {$extra} " . '--prefix=' . BUILD_ROOT_PATH . ' ' . '--libdir=' . BUILD_LIB_PATH . ' ' . "--openssldir={$openssl_dir} " . diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index ec1e7c2b..4522fcdf 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -15,7 +15,7 @@ trait UnixLibraryTrait { $libs = $include_self ? [$this] : []; array_unshift($libs, ...array_values($this->getDependencies(recursive: true))); - $config = new SPCConfigUtil($this->builder, options: ['libs_only_deps' => true, 'absolute_libs' => true]); + $config = new SPCConfigUtil($this->builder, options: ['libs_only_deps' => true]); $res = $config->config(libraries: array_map(fn ($x) => $x->getName(), $libs)); return $res['libs']; } diff --git a/src/SPC/builder/unix/library/libuv.php b/src/SPC/builder/unix/library/libuv.php index 65fed734..65827fa1 100644 --- a/src/SPC/builder/unix/library/libuv.php +++ b/src/SPC/builder/unix/library/libuv.php @@ -11,7 +11,7 @@ trait libuv protected function build(): void { UnixCMakeExecutor::create($this) - ->addConfigureArgs('-DLIBUV_BUILD_SHARED=ON') + ->addConfigureArgs('-DLIBUV_BUILD_SHARED=' . (getenv('SPC_LINK_STATIC') ? 'OFF' : 'ON')) ->build(); // patch pkgconfig $this->patchPkgconfPrefix(['libuv-static.pc']); diff --git a/src/SPC/builder/unix/library/mimalloc.php b/src/SPC/builder/unix/library/mimalloc.php index d581c63b..3b86ec51 100644 --- a/src/SPC/builder/unix/library/mimalloc.php +++ b/src/SPC/builder/unix/library/mimalloc.php @@ -13,7 +13,7 @@ trait mimalloc { $cmake = UnixCMakeExecutor::create($this) ->addConfigureArgs( - '-DMI_BUILD_SHARED=ON', + '-DMI_BUILD_SHARED=' . (getenv('SPC_LINK_STATIC') ? 'OFF' : 'ON'), '-DMI_BUILD_OBJECT=OFF', '-DMI_INSTALL_TOPLEVEL=ON', ); diff --git a/src/SPC/builder/unix/library/tidy.php b/src/SPC/builder/unix/library/tidy.php index ec6ecbd3..52c39156 100644 --- a/src/SPC/builder/unix/library/tidy.php +++ b/src/SPC/builder/unix/library/tidy.php @@ -14,7 +14,7 @@ trait tidy ->setBuildDir("{$this->source_dir}/build-dir") ->addConfigureArgs( '-DSUPPORT_CONSOLE_APP=OFF', - '-DBUILD_SHARED_LIB=ON' + '-DBUILD_SHARED_LIB=' . (getenv('SPC_LINK_STATIC') ? 'OFF' : 'ON') ); if (version_compare(get_cmake_version(), '4.0.0', '>=')) { $cmake->addConfigureArgs('-DCMAKE_POLICY_VERSION_MINIMUM=3.5'); diff --git a/src/SPC/builder/unix/library/zstd.php b/src/SPC/builder/unix/library/zstd.php index 0beca14f..40091e80 100644 --- a/src/SPC/builder/unix/library/zstd.php +++ b/src/SPC/builder/unix/library/zstd.php @@ -14,7 +14,7 @@ trait zstd ->setBuildDir("{$this->source_dir}/build/cmake/build") ->addConfigureArgs( '-DZSTD_BUILD_STATIC=ON', - '-DZSTD_BUILD_SHARED=ON', + '-DZSTD_BUILD_SHARED=' . (getenv('SPC_LINK_STATIC') ? 'OFF' : 'ON'), ) ->build(); $this->patchPkgconfPrefix(); diff --git a/src/SPC/command/SPCConfigCommand.php b/src/SPC/command/SPCConfigCommand.php index 5e21c9a1..850546fd 100644 --- a/src/SPC/command/SPCConfigCommand.php +++ b/src/SPC/command/SPCConfigCommand.php @@ -39,7 +39,6 @@ class SPCConfigCommand extends BaseCommand $util = new SPCConfigUtil(options: [ 'no_php' => $this->getOption('no-php'), 'libs_only_deps' => $this->getOption('libs-only-deps'), - 'absolute_libs' => $this->getOption('absolute-libs'), ]); $config = $util->config($extensions, $libraries, $include_suggest_ext, $include_suggest_lib); diff --git a/src/SPC/util/executor/UnixAutoconfExecutor.php b/src/SPC/util/executor/UnixAutoconfExecutor.php index d5ec06c0..88943bb5 100644 --- a/src/SPC/util/executor/UnixAutoconfExecutor.php +++ b/src/SPC/util/executor/UnixAutoconfExecutor.php @@ -134,7 +134,7 @@ class UnixAutoconfExecutor extends Executor { return [ '--enable-static', - '--enable-shared', + (getenv('SPC_LINK_STATIC') ? '--disable-shared' : '--enable-shared'), "--prefix={$this->library->getBuildRootPath()}", '--with-pic', '--enable-pic', diff --git a/src/SPC/util/executor/UnixCMakeExecutor.php b/src/SPC/util/executor/UnixCMakeExecutor.php index 8da206a1..92bedbcb 100644 --- a/src/SPC/util/executor/UnixCMakeExecutor.php +++ b/src/SPC/util/executor/UnixCMakeExecutor.php @@ -151,7 +151,7 @@ class UnixCMakeExecutor extends Executor '-DCMAKE_INSTALL_LIBDIR=lib', '-DCMAKE_INSTALL_INCLUDEDIR=include', '-DPOSITION_INDEPENDENT_CODE=ON', - '-DBUILD_SHARED_LIBS=ON', + '-DBUILD_SHARED_LIBS=' . (getenv('SPC_LINK_STATIC') ? 'OFF' : 'ON'), "-DCMAKE_TOOLCHAIN_FILE={$this->makeCmakeToolchainFile()}", ]); }