2023-03-18 17:32:21 +08:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
|
|
|
|
*
|
2023-03-18 17:34:08 +08:00
|
|
|
* lwmbs is licensed under Mulan PSL v2. You can use this
|
2023-03-18 17:32:21 +08:00
|
|
|
* software according to the terms and conditions of the
|
|
|
|
|
* Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
|
|
|
|
*
|
|
|
|
|
* http://license.coscl.org.cn/MulanPSL2
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
|
|
|
|
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
|
|
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
|
|
|
*
|
|
|
|
|
* See the Mulan PSL v2 for more details.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\macos\library;
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
use SPC\exception\FileSystemException;
|
|
|
|
|
use SPC\exception\RuntimeException;
|
|
|
|
|
use SPC\exception\WrongUsageException;
|
2024-04-12 00:49:15 +08:00
|
|
|
use SPC\store\FileSystem;
|
2023-08-20 19:51:45 +08:00
|
|
|
|
2023-03-18 17:32:21 +08:00
|
|
|
class openssl extends MacOSLibraryBase
|
|
|
|
|
{
|
|
|
|
|
public const NAME = 'openssl';
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
* @throws WrongUsageException
|
|
|
|
|
*/
|
|
|
|
|
protected function build(): void
|
2023-03-18 17:32:21 +08:00
|
|
|
{
|
|
|
|
|
[$lib,,$destdir] = SEPARATED_PATH;
|
|
|
|
|
|
|
|
|
|
// lib:zlib
|
|
|
|
|
$extra = '';
|
|
|
|
|
$ex_lib = '';
|
|
|
|
|
$zlib = $this->builder->getLib('zlib');
|
|
|
|
|
if ($zlib instanceof MacOSLibraryBase) {
|
|
|
|
|
$extra = 'zlib';
|
|
|
|
|
$ex_lib = trim($zlib->getStaticLibFiles() . ' ' . $ex_lib);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 20:47:24 +08:00
|
|
|
shell()->cd($this->source_dir)
|
|
|
|
|
->exec(
|
2023-10-23 00:37:28 +08:00
|
|
|
"./Configure no-shared {$extra} " .
|
2023-04-03 20:47:24 +08:00
|
|
|
'--prefix=/ ' . // use prefix=/
|
|
|
|
|
"--libdir={$lib} " .
|
2023-07-25 00:31:12 +08:00
|
|
|
'--openssldir=/System/Library/OpenSSL ' .
|
2023-08-20 19:51:45 +08:00
|
|
|
"darwin64-{$this->builder->getOption('arch')}-cc"
|
2023-04-03 20:47:24 +08:00
|
|
|
)
|
|
|
|
|
->exec('make clean')
|
|
|
|
|
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
|
|
|
|
->exec("make install_sw DESTDIR={$destdir}");
|
2023-04-29 18:59:47 +08:00
|
|
|
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
|
2024-04-12 00:49:15 +08:00
|
|
|
// patch for openssl 3.3.0+
|
|
|
|
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc'), 'prefix=')) {
|
|
|
|
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
|
|
|
|
}
|
|
|
|
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc'), 'prefix=')) {
|
|
|
|
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
|
|
|
|
}
|
|
|
|
|
if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) {
|
|
|
|
|
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file);
|
|
|
|
|
}
|
2023-03-18 17:32:21 +08:00
|
|
|
}
|
|
|
|
|
}
|