zlib-ng: New variants: +shared and +pic (#42796)
This commit is contained in:
parent
cd5bef6780
commit
e036cd9ef6
1 changed files with 17 additions and 1 deletions
|
@ -36,6 +36,11 @@ class ZlibNg(AutotoolsPackage, CMakePackage):
|
|||
|
||||
variant("compat", default=True, description="Enable compatibility API")
|
||||
variant("opt", default=True, description="Enable optimizations")
|
||||
variant("shared", default=True, description="Build shared library")
|
||||
variant("pic", default=True, description="Enable position-independent code (PIC)")
|
||||
|
||||
conflicts("+shared~pic")
|
||||
|
||||
variant("new_strategies", default=True, description="Enable new deflate strategies")
|
||||
|
||||
provides("zlib-api", when="+compat")
|
||||
|
@ -58,7 +63,14 @@ class ZlibNg(AutotoolsPackage, CMakePackage):
|
|||
@property
|
||||
def libs(self):
|
||||
name = "libz" if self.spec.satisfies("+compat") else "libz-ng"
|
||||
return find_libraries(name, root=self.prefix, recursive=True, shared=True)
|
||||
return find_libraries(
|
||||
name, root=self.prefix, recursive=True, shared=self.spec.satisfies("+shared")
|
||||
)
|
||||
|
||||
def flag_handler(self, name, flags):
|
||||
if name == "cflags" and self.spec.satisfies("+pic build_system=autotools"):
|
||||
flags.append(self.compiler.cc_pic_flag)
|
||||
return (flags, None, None)
|
||||
|
||||
|
||||
class AutotoolsBuilder(autotools.AutotoolsBuilder):
|
||||
|
@ -68,6 +80,8 @@ def configure_args(self):
|
|||
args.append("--zlib-compat")
|
||||
if self.spec.satisfies("~opt"):
|
||||
args.append("--without-optimizations")
|
||||
if self.spec.satisfies("~shared"):
|
||||
args.append("--static")
|
||||
if self.spec.satisfies("~new_strategies"):
|
||||
args.append("--without-new-strategies")
|
||||
return args
|
||||
|
@ -78,5 +92,7 @@ def cmake_args(self):
|
|||
return [
|
||||
self.define_from_variant("ZLIB_COMPAT", "compat"),
|
||||
self.define_from_variant("WITH_OPTIM", "opt"),
|
||||
self.define("BUILD_SHARED_LIBS", self.spec.satisfies("+shared")),
|
||||
self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"),
|
||||
self.define_from_variant("WITH_NEW_STRATEGIES", "new_strategies"),
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue