diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index e0500cbe..4cb62811 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -294,6 +294,11 @@ abstract class LibraryBase // do something before pack, default do nothing. overwrite this method to do something (e.g. modify pkg-config file) } + public function patchBeforeConfigure(): bool + { + return false; + } + /** * Build this library. * diff --git a/src/SPC/builder/unix/library/libacl.php b/src/SPC/builder/unix/library/libacl.php index 27aa802b..8fbe1610 100644 --- a/src/SPC/builder/unix/library/libacl.php +++ b/src/SPC/builder/unix/library/libacl.php @@ -4,19 +4,29 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\builder\linux\library\LinuxLibraryBase; use SPC\exception\RuntimeException; +use SPC\store\FileSystem; trait libacl { + public function patchBeforeConfigure(): bool + { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/sapi/fpm/config.m4', '[AS_VAR_APPEND([FPM_EXTRA_LIBS],', ','); + return true; + } + /** * @throws RuntimeException */ protected function build(): void { + $cflags = PHP_OS_FAMILY !== 'Linux' ? '-Wimplicit-function-declaration -Wno-int-conversion' : ''; + $ldflags = !($this instanceof LinuxLibraryBase) ? '' : '--static'; shell()->cd($this->source_dir) ->setEnv([ - 'CFLAGS' => trim('-I' . BUILD_INCLUDE_PATH . ' ' . $this->getLibExtraCFlags()), - 'LDFLAGS' => trim('-L' . BUILD_LIB_PATH . ' ' . $this->getLibExtraLdFlags()), + 'CFLAGS' => trim('-I' . BUILD_INCLUDE_PATH . ' ' . $this->getLibExtraCFlags() . ' ' . $cflags), + 'LDFLAGS' => trim('-L' . BUILD_LIB_PATH . ' ' . $this->getLibExtraLdFlags() . ' ' . $ldflags), 'LIBS' => $this->getLibExtraLibs(), ]) ->execWithEnv('./autogen.sh') diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 93703ce2..047c33cf 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -85,6 +85,11 @@ class SourcePatcher logger()->info('Extension [' . $ext->getName() . '] patched before configure'); } } + foreach ($builder->getLibs() as $lib) { + if ($lib->patchBeforeConfigure() === true) { + logger()->info('Library [' . $lib->getName() . '] patched before configure'); + } + } // patch capstone FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"'); if ($builder instanceof LinuxBuilder && $builder->libc === 'glibc') {