diff --git a/var/spack/repos/builtin/packages/udunits/package.py b/var/spack/repos/builtin/packages/udunits/package.py index 2b92c71d472c78..f63c00a9973dfd 100644 --- a/var/spack/repos/builtin/packages/udunits/package.py +++ b/var/spack/repos/builtin/packages/udunits/package.py @@ -35,10 +35,24 @@ class Udunits(AutotoolsPackage): depends_on("expat") variant("shared", default=True, description="Build shared library") + variant( + "pic", + default=True, + description="Enable position-independent code (PIC)", + when="~shared", + ) @property def libs(self): - return find_libraries(["libudunits2"], root=self.prefix, recursive=True, shared=True) + return find_libraries( + "libudunits2", + root=self.prefix, + recursive=True, + shared=self.spec.satisfies("+shared") + ) def configure_args(self): - return self.enable_or_disable("shared") + config_args = [] + config_args.extend(self.enable_or_disable("shared")) + config_args.extend(self.with_or_without("pic")) + return config_args