|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace SPC\builder\unix\library; |
| 6 | + |
| 7 | +use SPC\store\FileSystem; |
| 8 | +use SPC\util\executor\UnixAutoconfExecutor; |
| 9 | + |
| 10 | +trait net_snmp |
| 11 | +{ |
| 12 | + public function patchBeforeBuild(): bool |
| 13 | + { |
| 14 | + if (PHP_OS_FAMILY === 'Linux') { |
| 15 | + FileSystem::replaceFileStr("{$this->source_dir}/configure", 'LIBS="-lssl ${OPENSSL_LIBS}"', 'LIBS="-lssl ${OPENSSL_LIBS} -lpthread -ldl"'); |
| 16 | + return true; |
| 17 | + } |
| 18 | + return false; |
| 19 | + } |
| 20 | + |
| 21 | + protected function build(): void |
| 22 | + { |
| 23 | + // use --static for PKG_CONFIG |
| 24 | + UnixAutoconfExecutor::create($this) |
| 25 | + ->setEnv(['PKG_CONFIG' => getenv('PKG_CONFIG') . ' --static']) |
| 26 | + ->configure( |
| 27 | + '--disable-mibs', |
| 28 | + '--without-nl', |
| 29 | + '--disable-agent', |
| 30 | + '--disable-applications', |
| 31 | + '--disable-manuals', |
| 32 | + '--disable-scripts', |
| 33 | + '--disable-embedded-perl', |
| 34 | + '--without-perl-modules', |
| 35 | + '--with-out-mib-modules="if-mib host disman/event-mib ucd-snmp/diskio mibII"', |
| 36 | + '--with-out-transports="Unix"', |
| 37 | + '--with-mib-modules=""', |
| 38 | + '--enable-mini-agent', |
| 39 | + '--with-default-snmp-version="3"', |
| 40 | + '--with-sys-contact="@@no.where"', |
| 41 | + '--with-sys-location="Unknown"', |
| 42 | + '--with-logfile="/var/log/snmpd.log"', |
| 43 | + '--with-persistent-directory="/var/lib/net-snmp"', |
| 44 | + '--with-openssl=' . BUILD_ROOT_PATH, |
| 45 | + '--with-zlib=' . BUILD_ROOT_PATH, |
| 46 | + )->make(with_install: 'installheaders installlibs install_pkgconfig'); |
| 47 | + $this->patchPkgconfPrefix(); |
| 48 | + } |
| 49 | +} |
0 commit comments