Files
static-php-cli/src/SPC/builder/macos/library/libpng.php

62 lines
2.0 KiB
PHP
Raw Normal View History

2023-03-18 17:32:21 +08:00
<?php
2024-12-05 11:03:16 +08:00
2023-03-18 17:32:21 +08:00
/**
* 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;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
2025-06-09 19:32:31 +08:00
use SPC\util\executor\UnixAutoconfExecutor;
2023-03-18 17:32:21 +08:00
class libpng extends MacOSLibraryBase
{
public const NAME = 'libpng';
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
2023-03-18 17:32:21 +08:00
*/
protected function build(): void
2023-03-18 17:32:21 +08:00
{
2025-06-09 19:32:31 +08:00
$arch = arch2gnu(php_uname('m'));
UnixAutoconfExecutor::create($this)
2023-04-09 12:10:09 +08:00
->exec('chmod +x ./configure')
2023-07-20 01:15:05 +08:00
->exec('chmod +x ./install-sh')
2025-06-09 19:32:31 +08:00
->appendEnv(['LDFLAGS' => "-L{$this->getLibDir()}"])
->configure(
"--host={$arch}-apple-darwin",
'--enable-hardware-optimizations',
"--with-zlib-prefix={$this->getBuildRootPath()}",
match (getenv('SPC_ARCH')) {
'x86_64' => '--enable-intel-sse',
'aarch64' => '--enable-arm-neon',
default => '',
}
2023-04-03 20:47:24 +08:00
)
2025-06-09 19:32:31 +08:00
->make('libpng16.la', 'install-libLTLIBRARIES install-data-am', after_env_vars: ['DEFAULT_INCLUDES' => "-I{$this->source_dir} -I{$this->getIncludeDir()}"]);
shell()->cd(BUILD_LIB_PATH)->exec('ln -sf libpng16.a libpng.a');
$this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX);
$this->patchLaDependencyPrefix();
2023-03-18 17:32:21 +08:00
}
}