diff --git a/config/lib.json b/config/lib.json index 78443d0d..0d4941f0 100644 --- a/config/lib.json +++ b/config/lib.json @@ -635,9 +635,6 @@ ], "lib-depends": [ "openssl" - ], - "lib-suggests": [ - "ngtcp2" ] }, "ngtcp2": { @@ -655,6 +652,10 @@ ], "lib-depends": [ "openssl" + ], + "lib-suggests": [ + "nghttp3", + "brotli" ] }, "onig": { diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 61a436eb..2cd685f6 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -81,7 +81,7 @@ class LinuxBuilder extends UnixBuilderBase foreach ($libSpecs as $libName => $arr) { $lib = $this->getLib($libName); if ($lib === null && str_starts_with($libName, 'lib')) { - $lib = $this->getExt(substr($libName, 3)); + $lib = $this->getLib(substr($libName, 3)); } $arr = $arr ?? []; diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 55a238f9..add81151 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -96,4 +96,13 @@ class openssl extends LinuxLibraryBase FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', '/Libs.private:.*/m', 'Libs.private: ${libdir}/libz.a'); FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/cmake/OpenSSL/OpenSSLConfig.cmake', '/set\(OPENSSL_LIBCRYPTO_DEPENDENCIES .*\)/m', 'set(OPENSSL_LIBCRYPTO_DEPENDENCIES "${OPENSSL_LIBRARY_DIR}/libz.a")'); } + + public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string + { + $libFiles = parent::getStaticLibFiles($style, $recursive); + if (!str_contains('-ldl -lpthread', $libFiles)) { + $libFiles .= ' -ldl -lpthread'; + } + return $libFiles; + } } diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 73bde425..b9dd5d93 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -56,7 +56,7 @@ class MacOSBuilder extends UnixBuilderBase foreach ($lib_specs as $libName => $arr) { $lib = $this->getLib($libName); if ($lib === null && str_starts_with($libName, 'lib')) { - $lib = $this->getExt(substr($libName, 3)); + $lib = $this->getLib(substr($libName, 3)); } $arr = $arr ?? []; diff --git a/src/SPC/builder/unix/library/nghttp2.php b/src/SPC/builder/unix/library/nghttp2.php index 5fe5bc9b..453f5876 100644 --- a/src/SPC/builder/unix/library/nghttp2.php +++ b/src/SPC/builder/unix/library/nghttp2.php @@ -31,6 +31,12 @@ trait nghttp2 'jemalloc' => null, 'systemd' => null, ]); + if ($brotli = $this->builder->getLib('brotli')) { + /* @phpstan-ignore-next-line */ + $args .= ' --with-libbrotlidec=yes LIBBROTLIDEC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIDEC_LIBS="' . $brotli->getStaticLibFiles() . '"'; + /* @phpstan-ignore-next-line */ + $args .= ' --with-libbrotlienc=yes LIBBROTLIENC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIENC_LIBS="' . $brotli->getStaticLibFiles() . '"'; + } [,,$destdir] = SEPARATED_PATH; diff --git a/src/SPC/builder/unix/library/nghttp3.php b/src/SPC/builder/unix/library/nghttp3.php index 2b2e0615..8eb00f5b 100644 --- a/src/SPC/builder/unix/library/nghttp3.php +++ b/src/SPC/builder/unix/library/nghttp3.php @@ -6,22 +6,15 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; trait nghttp3 { /** * @throws FileSystemException * @throws RuntimeException - * @throws WrongUsageException */ protected function build(): void { - $args = $this->builder->makeAutoconfArgs(static::NAME, [ - 'zlib' => null, - 'openssl' => null, - ]); - shell()->cd($this->source_dir) ->setEnv([ 'CFLAGS' => $this->getLibExtraCFlags(), @@ -34,7 +27,6 @@ trait nghttp3 '--disable-shared ' . '--with-pic ' . '--enable-lib-only ' . - $args . ' ' . '--prefix=' ) ->execWithEnv('make clean') diff --git a/src/SPC/builder/unix/library/ngtcp2.php b/src/SPC/builder/unix/library/ngtcp2.php index 7b075ed9..654bb8e5 100644 --- a/src/SPC/builder/unix/library/ngtcp2.php +++ b/src/SPC/builder/unix/library/ngtcp2.php @@ -18,12 +18,17 @@ trait ngtcp2 protected function build(): void { $args = $this->builder->makeAutoconfArgs(static::NAME, [ - 'zlib' => null, 'openssl' => null, - 'libxml2' => null, 'libev' => null, 'jemalloc' => null, + 'libnghttp3' => null, ]); + if ($brotli = $this->builder->getLib('brotli')) { + /* @phpstan-ignore-next-line */ + $args .= ' --with-libbrotlidec=yes LIBBROTLIDEC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIDEC_LIBS="' . $brotli->getStaticLibFiles() . '"'; + /* @phpstan-ignore-next-line */ + $args .= ' --with-libbrotlienc=yes LIBBROTLIENC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIENC_LIBS="' . $brotli->getStaticLibFiles() . '"'; + } shell()->cd($this->source_dir) ->setEnv([ @@ -43,8 +48,6 @@ trait ngtcp2 ->execWithEnv('make clean') ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); - $this->patchPkgconfPrefix(['libngtcp2.pc']); - $this->patchPkgconfPrefix(['libngtcp2_crypto_ossl.pc']); - $this->patchLaDependencyPrefix(['libngtcp2.la', 'libngtcp2_crypto_ossl.la']); + $this->patchPkgconfPrefix(['libngtcp2.pc', 'libngtcp2_crypto_ossl.pc']); } }