mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
Support -fPIC and -fPIE for most libs and PHP
This commit is contained in:
parent
4eeb48cdc2
commit
2a9cd436b6
1
.gitignore
vendored
1
.gitignore
vendored
@ -33,6 +33,7 @@ packlib_files.txt
|
||||
!/bin/setup-runtime*
|
||||
!/bin/spc-alpine-docker
|
||||
!/bin/php-cs-fixer-wrapper
|
||||
!/bin/build-static-frankenphp
|
||||
|
||||
# exclude windows build tools
|
||||
/php-sdk-binary-tools/
|
||||
|
||||
@ -76,13 +76,13 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime
|
||||
; buildconf command
|
||||
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
|
||||
; configure command
|
||||
SPC_CMD_PREFIX_PHP_CONFIGURE="${SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD} ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg"
|
||||
SPC_CMD_PREFIX_PHP_CONFIGURE="${SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD} ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic"
|
||||
; make command
|
||||
SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}"
|
||||
|
||||
; *** default build vars for building php ***
|
||||
; CFLAGS for configuring php
|
||||
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS}"
|
||||
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fPIE"
|
||||
; CPPFLAGS for configuring php
|
||||
SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}"
|
||||
; LDFLAGS for configuring php
|
||||
@ -90,7 +90,7 @@ SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
|
||||
; LIBS for configuring php
|
||||
SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm"
|
||||
; EXTRA_CFLAGS for `make` php
|
||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="${SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS} -fno-ident -fPIE"
|
||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="${SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS} -fno-ident -fPIE -fPIC"
|
||||
; EXTRA_LIBS for `make` php
|
||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS=""
|
||||
; EXTRA_LDFLAGS_PROGRAM for `make` php
|
||||
|
||||
@ -120,6 +120,7 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
|
||||
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||
$cflags = $this->arch_c_flags;
|
||||
f_putenv('CFLAGS=' . $cflags);
|
||||
|
||||
$this->emitPatchPoint('before-php-buildconf');
|
||||
SourcePatcher::patchBeforeBuildconf($this);
|
||||
|
||||
@ -14,7 +14,7 @@ class icu extends LinuxLibraryBase
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"';
|
||||
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -fPIC -fPIE -fno-ident"';
|
||||
$cxxflags = 'CXXFLAGS="-std=c++17"';
|
||||
$ldflags = $this->builder->libc !== 'glibc' ? 'LDFLAGS="-static"' : '';
|
||||
shell()->cd($this->source_dir . '/source')
|
||||
|
||||
@ -44,7 +44,7 @@ class libpng extends LinuxLibraryBase
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('chmod +x ./configure')
|
||||
->exec('chmod +x ./install-sh')
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $this->builder->arch_c_flags, 'LIBS' => $this->getLibExtraLibs()])
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' .
|
||||
'./configure ' .
|
||||
|
||||
@ -21,7 +21,7 @@ class glfw extends MacOSLibraryBase
|
||||
shell()->cd(SOURCE_PATH . '/ext-glfw/vendor/glfw')
|
||||
->exec("cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF")
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->exec('make install');
|
||||
// patch pkgconf
|
||||
$this->patchPkgconfPrefix(['glfw3.pc']);
|
||||
}
|
||||
|
||||
@ -102,7 +102,11 @@ trait UnixLibraryTrait
|
||||
|
||||
public function getLibExtraCFlags(): string
|
||||
{
|
||||
return getenv($this->getSnakeCaseName() . '_CFLAGS') ?: '';
|
||||
$env = getenv($this->getSnakeCaseName() . '_CFLAGS') ?: '';
|
||||
if (!str_contains($env, $this->builder->arch_c_flags)) {
|
||||
$env .= $this->builder->arch_c_flags;
|
||||
}
|
||||
return $env;
|
||||
}
|
||||
|
||||
public function getLibExtraLdFlags(): string
|
||||
|
||||
@ -33,11 +33,11 @@ trait UnixSystemUtilTrait
|
||||
$root = BUILD_ROOT_PATH;
|
||||
$ccLine = '';
|
||||
if ($cc) {
|
||||
$ccLine = 'SET(CMAKE_C_COMPILER ' . self::findCommand($cc) . ')';
|
||||
$ccLine = 'SET(CMAKE_C_COMPILER ' . $cc . ')';
|
||||
}
|
||||
$cxxLine = '';
|
||||
if ($cxx) {
|
||||
$cxxLine = 'SET(CMAKE_CXX_COMPILER ' . self::findCommand($cxx) . ')';
|
||||
$cxxLine = 'SET(CMAKE_CXX_COMPILER ' . $cxx . ')';
|
||||
}
|
||||
$toolchain = <<<CMAKE
|
||||
{$ccLine}
|
||||
@ -46,6 +46,8 @@ SET(CMAKE_C_FLAGS "{$cflags}")
|
||||
SET(CMAKE_CXX_FLAGS "{$cflags}")
|
||||
SET(CMAKE_FIND_ROOT_PATH "{$root}")
|
||||
SET(CMAKE_PREFIX_PATH "{$root}")
|
||||
SET(CMAKE_INSTALL_PREFIX "{$root}")
|
||||
SET(CMAKE_INSTALL_LIBDIR "lib")
|
||||
|
||||
set(PKG_CONFIG_EXECUTABLE "{$root}/bin/pkg-config")
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
@ -61,10 +61,10 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
$extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . getenv('CC') . ' ' : '';
|
||||
return $extra .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=/ ' .
|
||||
'-DCMAKE_INSTALL_BINDIR=/bin ' .
|
||||
'-DCMAKE_INSTALL_LIBDIR=/lib ' .
|
||||
'-DCMAKE_INSTALL_INCLUDEDIR=/include ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'-DCMAKE_INSTALL_BINDIR=bin ' .
|
||||
'-DCMAKE_INSTALL_LIBDIR=lib ' .
|
||||
'-DCMAKE_INSTALL_INCLUDEDIR=include ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->cmake_toolchain_file}";
|
||||
}
|
||||
|
||||
|
||||
@ -21,12 +21,16 @@ trait brotli
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'cmake ' .
|
||||
"{$this->builder->makeCmakeArgs()} " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'-DCMAKE_INSTALL_LIBDIR=lib ' .
|
||||
'-DSHARE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'..'
|
||||
)
|
||||
->execWithEnv("cmake --build . -j {$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->execWithEnv('make install');
|
||||
$this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']);
|
||||
shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a');
|
||||
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\builder\linux\library\LinuxLibraryBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
@ -53,14 +52,13 @@ trait curl
|
||||
|
||||
FileSystem::resetDir($this->source_dir . '/build');
|
||||
|
||||
$cflags = $this instanceof LinuxLibraryBase && $this->builder->libc === 'glibc' ? '-fPIC' : '';
|
||||
// compile!
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $cflags, 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt')
|
||||
->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..")
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->execWithEnv('make install');
|
||||
// patch pkgconf
|
||||
$this->patchPkgconfPrefix(['libcurl.pc']);
|
||||
shell()->cd(BUILD_LIB_PATH . '/cmake/CURL/')
|
||||
|
||||
@ -17,7 +17,7 @@ trait gettext
|
||||
$ldflags = $this->builder->getOption('enable-zts') ? '-lpthread' : '';
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $cflags, 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()])
|
||||
->setEnv(['CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--enable-static ' .
|
||||
|
||||
@ -23,6 +23,6 @@ trait gmssl
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..")
|
||||
->execWithEnv("cmake --build . -j {$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->execWithEnv('make install');
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ trait imagemagick
|
||||
}
|
||||
}
|
||||
|
||||
$ldflags = $this instanceof LinuxLibraryBase ? ('-static') : '';
|
||||
$ldflags = ($this instanceof LinuxLibraryBase) && $this->builder->libc !== 'glibc' ? ('-static -ldl') : '-ldl';
|
||||
|
||||
// libxml iconv patch
|
||||
$required_libs .= $this instanceof MacOSLibraryBase ? ('-liconv') : '';
|
||||
|
||||
@ -10,7 +10,8 @@ trait ldap
|
||||
{
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
FileSystem::replaceFileStr($this->source_dir . '/configure', '"-lssl -lcrypto', '"-lssl -lcrypto -lz');
|
||||
$extra = ($this->builder->libc ?? '') === 'glibc' ? '-ldl -lpthread -lm -lresolv -lutil' : '';
|
||||
FileSystem::replaceFileStr($this->source_dir . '/configure', '"-lssl -lcrypto', '"-lssl -lcrypto -lz ' . $extra);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ trait libavif
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DAVIF_LIBYUV=OFF ..")
|
||||
->execWithEnv("cmake --build . -j {$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->execWithEnv('make install');
|
||||
// patch pkgconfig
|
||||
$this->patchPkgconfPrefix(['libavif.pc']);
|
||||
$this->cleanLaFiles();
|
||||
|
||||
@ -11,16 +11,17 @@ trait libiconv
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
'--enable-extra-encodings ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . $destdir);
|
||||
->execWithEnv('make clean')
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . $destdir);
|
||||
|
||||
if (file_exists(BUILD_BIN_PATH . '/iconv')) {
|
||||
unlink(BUILD_BIN_PATH . '/iconv');
|
||||
|
||||
@ -29,7 +29,7 @@ trait libjpeg
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->exec('make install');
|
||||
// patch pkgconfig
|
||||
$this->patchPkgconfPrefix(['libjpeg.pc', 'libturbojpeg.pc']);
|
||||
$this->cleanLaFiles();
|
||||
|
||||
@ -18,9 +18,10 @@ trait liblz4
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec("make PREFIX='' clean")
|
||||
->exec("make -j{$this->builder->concurrency} PREFIX=''")
|
||||
->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv("make PREFIX='' clean")
|
||||
->execWithEnv("make -j{$this->builder->concurrency} PREFIX=''")
|
||||
->execWithEnv("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
|
||||
|
||||
$this->patchPkgconfPrefix(['liblz4.pc']);
|
||||
|
||||
|
||||
@ -22,7 +22,10 @@ trait libssh2
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
'cmake ' .
|
||||
"{$this->builder->makeCmakeArgs()} " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'-DCMAKE_INSTALL_LIBDIR=lib ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_EXAMPLES=OFF ' .
|
||||
'-DBUILD_TESTING=OFF ' .
|
||||
@ -30,7 +33,7 @@ trait libssh2
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->exec('make install');
|
||||
$this->patchPkgconfPrefix(['libssh2.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,8 @@ trait libtiff
|
||||
$extra_libs .= ' --disable-lzma --disable-zstd --disable-webp --disable-libdeflate';
|
||||
|
||||
$shell = shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--enable-static --disable-shared ' .
|
||||
"{$extra_libs} " .
|
||||
@ -33,12 +34,12 @@ trait libtiff
|
||||
|
||||
// TODO: Remove this check when https://gitlab.com/libtiff/libtiff/-/merge_requests/635 will be merged and released
|
||||
if (file_exists($this->source_dir . '/html')) {
|
||||
$shell->exec('make clean');
|
||||
$shell->execWithEnv('make clean');
|
||||
}
|
||||
|
||||
$shell
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['libtiff-4.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ trait libuv
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec("cmake {$this->builder->makeCmakeArgs()} -DLIBUV_BUILD_SHARED=OFF ..")
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->exec('make install');
|
||||
// patch pkgconfig
|
||||
$this->patchPkgconfPrefix(['libuv-static.pc']);
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ trait libwebp
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->exec('make install');
|
||||
// patch pkgconfig
|
||||
$this->patchPkgconfPrefix(['libsharpyuv.pc', 'libwebp.pc', 'libwebpdecoder.pc', 'libwebpdemux.pc', 'libwebpmux.pc'], PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR);
|
||||
$this->patchPkgconfPrefix(['libsharpyuv.pc'], PKGCONF_PATCH_CUSTOM, ['/^includedir=.*$/m', 'includedir=${prefix}/include/webp']);
|
||||
|
||||
@ -30,7 +30,9 @@ trait libzip
|
||||
shell()->cd($this->source_dir . '/build')
|
||||
->exec(
|
||||
'cmake ' .
|
||||
"{$this->builder->makeCmakeArgs()} " .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DENABLE_GNUTLS=OFF ' .
|
||||
'-DENABLE_MBEDTLS=OFF ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
@ -42,7 +44,7 @@ trait libzip
|
||||
'..'
|
||||
)
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->exec('make install');
|
||||
$this->patchPkgconfPrefix(['libzip.pc'], PKGCONF_PATCH_PREFIX);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,8 @@ trait ncurses
|
||||
{
|
||||
$filelist = FileSystem::scanDirFiles(BUILD_BIN_PATH, relative: true);
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
@ -32,9 +33,9 @@ trait ncurses
|
||||
'--libdir=' . BUILD_ROOT_PATH . '/lib ' .
|
||||
'--prefix=' . BUILD_ROOT_PATH
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install');
|
||||
->execWithEnv('make clean')
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make install');
|
||||
|
||||
$final = FileSystem::scanDirFiles(BUILD_BIN_PATH, relative: true);
|
||||
// Remove the new files
|
||||
|
||||
@ -36,7 +36,8 @@ trait nghttp2
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--enable-static ' .
|
||||
'--disable-shared ' .
|
||||
@ -45,9 +46,9 @@ trait nghttp2
|
||||
$args . ' ' .
|
||||
'--prefix='
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
->execWithEnv('make clean')
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv("make install DESTDIR={$destdir}");
|
||||
$this->patchPkgconfPrefix(['libnghttp2.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,11 +10,11 @@ trait pkgconfig
|
||||
{
|
||||
protected function build(): void
|
||||
{
|
||||
$cflags = PHP_OS_FAMILY !== 'Linux' ? "{$this->builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion" : '';
|
||||
$cflags = PHP_OS_FAMILY !== 'Linux' ? '-Wimplicit-function-declaration -Wno-int-conversion' : '';
|
||||
$ldflags = !($this instanceof LinuxLibraryBase) || $this->builder->libc === 'glibc' ? '' : '--static';
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $cflags, 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()])
|
||||
->setEnv(['CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", 'LDFLAGS' => "{$this->getLibExtraLdFlags()} {$ldflags}", 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--disable-shared ' .
|
||||
|
||||
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\builder\linux\library\LinuxLibraryBase;
|
||||
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
@ -42,13 +41,13 @@ trait postgresql
|
||||
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||
if (!empty($output[1][0])) {
|
||||
$cppflags = $output[1][0];
|
||||
$envs .= " CPPFLAGS=\"{$cppflags}\"";
|
||||
$envs .= " CPPFLAGS=\"{$cppflags} -fPIC -fPIE -fno-ident\"";
|
||||
}
|
||||
$output = shell()->execWithResult("pkg-config --libs-only-L --static {$packages}");
|
||||
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||
if (!empty($output[1][0])) {
|
||||
$ldflags = $output[1][0];
|
||||
$envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" ";
|
||||
$envs .= !($this instanceof LinuxLibraryBase) || $this->builder->libc === 'glibc' ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" ";
|
||||
}
|
||||
$output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}");
|
||||
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
|
||||
|
||||
@ -16,7 +16,8 @@ trait readline
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec(
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv(
|
||||
'./configure ' .
|
||||
'--enable-static=yes ' .
|
||||
'--enable-shared=no ' .
|
||||
@ -24,9 +25,9 @@ trait readline
|
||||
'--with-curses ' .
|
||||
'--enable-multibyte=yes'
|
||||
)
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->execWithEnv('make clean')
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['readline.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,13 +21,12 @@ trait snappy
|
||||
shell()->cd($this->source_dir . '/cmake/build')
|
||||
->exec(
|
||||
'cmake ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
"{$this->builder->makeCmakeArgs()} " .
|
||||
'-DSNAPPY_BUILD_TESTS=OFF ' .
|
||||
'-DSNAPPY_BUILD_BENCHMARKS=OFF ' .
|
||||
'../..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->exec('make install');
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,10 +9,11 @@ trait sqlite
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('./configure --enable-static --disable-shared --prefix=')
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv('./configure --enable-static --disable-shared --prefix=')
|
||||
->execWithEnv('make clean')
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
$this->patchPkgconfPrefix(['sqlite3.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ trait tidy
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->exec('make install');
|
||||
$this->patchPkgconfPrefix(['tidy.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,10 +18,11 @@ trait zlib
|
||||
[,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
shell()->cd($this->source_dir)
|
||||
->exec('./configure --static --prefix=')
|
||||
->exec('make clean')
|
||||
->exec("make -j{$this->builder->concurrency}")
|
||||
->exec("make install DESTDIR={$destdir}");
|
||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
||||
->execWithEnv('./configure --static --prefix=')
|
||||
->execWithEnv('make clean')
|
||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||
->execWithEnv("make install DESTDIR={$destdir}");
|
||||
$this->patchPkgconfPrefix(['zlib.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ trait zstd
|
||||
'..'
|
||||
)
|
||||
->exec("cmake --build . -j {$this->builder->concurrency}")
|
||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||
->exec('make install');
|
||||
$this->patchPkgconfPrefix(['libzstd.pc']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ class LinuxToolCheckList
|
||||
'git', 'autoconf', 'automake',
|
||||
'tar', 'unzip', 'gzip', 'gcc',
|
||||
'bzip2', 'cmake', 'patch',
|
||||
'xz',
|
||||
'xz', 'libtool',
|
||||
];
|
||||
|
||||
public const TOOLS_ARCH = [
|
||||
|
||||
@ -36,7 +36,7 @@ class SPCConfigUtil
|
||||
$libs = '-lphp -lc ' . $libs;
|
||||
$extra_env = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS');
|
||||
if (is_string($extra_env)) {
|
||||
$libs .= ' ' . $extra_env;
|
||||
$libs .= ' ' . trim($extra_env, '"');
|
||||
}
|
||||
// c++
|
||||
if ($this->builder->hasCpp()) {
|
||||
|
||||
@ -38,7 +38,7 @@ $prefer_pre_built = false;
|
||||
|
||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||
$extensions = match (PHP_OS_FAMILY) {
|
||||
'Linux', 'Darwin' => 'imap,openssl,zlib,memcache',
|
||||
'Linux', 'Darwin' => 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,gmp,gettext,iconv,igbinary,imagick,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,parallel,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,ssh2,sysvmsg,sysvsem,sysvshm,tidy,tokenizer,xlswriter,xml,xmlreader,xmlwriter,zip,zlib,yaml,zstd',
|
||||
'Windows' => 'gettext',
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user