2023-03-26 22:27:51 +08:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2022 Yun Dou <dixyes@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* lwmbs is licensed under Mulan PSL v2. You can use this
|
|
|
|
|
* 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\linux\library;
|
|
|
|
|
|
|
|
|
|
use SPC\exception\FileSystemException;
|
|
|
|
|
use SPC\exception\RuntimeException;
|
2023-08-20 19:51:45 +08:00
|
|
|
use SPC\exception\WrongUsageException;
|
2023-03-26 22:27:51 +08:00
|
|
|
|
|
|
|
|
class libpng extends LinuxLibraryBase
|
|
|
|
|
{
|
|
|
|
|
public const NAME = 'libpng';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
2023-08-20 19:51:45 +08:00
|
|
|
* @throws RuntimeException
|
|
|
|
|
* @throws WrongUsageException
|
2023-03-26 22:27:51 +08:00
|
|
|
*/
|
2023-08-20 19:51:45 +08:00
|
|
|
public function build(): void
|
2023-03-26 22:27:51 +08:00
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
$optimizations = match ($this->builder->getOption('arch')) {
|
2023-03-26 22:27:51 +08:00
|
|
|
'x86_64' => '--enable-intel-sse ',
|
|
|
|
|
'arm64' => '--enable-arm-neon ',
|
|
|
|
|
default => '',
|
|
|
|
|
};
|
|
|
|
|
shell()->cd($this->source_dir)
|
2023-04-09 12:10:09 +08:00
|
|
|
->exec('chmod +x ./configure')
|
2023-07-27 18:11:08 +08:00
|
|
|
->exec('chmod +x ./install-sh')
|
2023-03-26 22:27:51 +08:00
|
|
|
->exec(
|
2023-10-27 17:34:55 +02:00
|
|
|
'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' .
|
2023-10-23 00:37:28 +08:00
|
|
|
'./configure ' .
|
2023-03-26 22:27:51 +08:00
|
|
|
'--disable-shared ' .
|
|
|
|
|
'--enable-static ' .
|
|
|
|
|
'--enable-hardware-optimizations ' .
|
2023-04-29 18:59:47 +08:00
|
|
|
'--with-zlib-prefix="' . BUILD_ROOT_PATH . '" ' .
|
2023-03-26 22:27:51 +08:00
|
|
|
$optimizations .
|
|
|
|
|
'--prefix='
|
|
|
|
|
)
|
|
|
|
|
->exec('make clean')
|
2023-10-27 17:34:55 +02:00
|
|
|
->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la")
|
2023-10-17 19:43:54 +02:00
|
|
|
->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH);
|
2023-04-29 18:59:47 +08:00
|
|
|
$this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX);
|
2023-05-10 02:04:08 +08:00
|
|
|
$this->cleanLaFiles();
|
2023-03-26 22:27:51 +08:00
|
|
|
}
|
|
|
|
|
}
|