diff --git a/repos/spack_repo/builtin/packages/libfuse/package.py b/repos/spack_repo/builtin/packages/libfuse/package.py index c6f3743350c..9f1dcb431c6 100644 --- a/repos/spack_repo/builtin/packages/libfuse/package.py +++ b/repos/spack_repo/builtin/packages/libfuse/package.py @@ -2,15 +2,14 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import os import re -from spack_repo.builtin.build_systems.meson import MesonPackage +from spack_repo.builtin.build_systems import autotools, meson from spack.package import * -class Libfuse(MesonPackage): +class Libfuse(autotools.AutotoolsPackage, meson.MesonPackage): """The reference implementation of the Linux FUSE (Filesystem in Userspace) interface""" @@ -59,14 +58,19 @@ def url_for_version(self, version): ) variant("utils", default=True, description="Build and install helper and example programs.") + build_system( + conditional("meson", when="@3:"), conditional("autotools", when="@:2"), default="meson" + ) + depends_on("c", type="build") # generated depends_on("cxx", type="build") # generated - depends_on("autoconf", type="build", when="@:2") - depends_on("automake", type="build", when="@:2") - depends_on("libtool", type="build", when="@:2") - depends_on("gettext", type="build", when="@:2") - depends_on("gmake", type="build") + with when("build_system=autotools"): + depends_on("autoconf", type="build") + depends_on("automake", type="build") + depends_on("libtool", type="build") + depends_on("gettext", type="build") + depends_on("gmake", type="build") provides("fuse") conflicts("+useroot", when="~system_install", msg="useroot requires system_install") @@ -112,6 +116,8 @@ def determine_version(cls, exe): match = re.search(r"^fusermount.*version: (\S+)", output) return match.group(1) if match else None + +class MesonBuilder(meson.MesonBuilder): def meson_args(self): args = [] @@ -139,39 +145,13 @@ def meson_args(self): return args - # Before libfuse 3.x this was an autotools package - @when("@:2") - def meson(self, spec, prefix): - ar_args = ["-ivf"] - for dep in self.spec.dependencies(deptype="build"): - if os.path.exists(dep.prefix.share.aclocal): - ar_args.extend(["-I", dep.prefix.share.aclocal]) - autoreconf(*ar_args) +class AutotoolsBuilder(autotools.AutotoolsBuilder): + def configure_args(self): args = [ - "--prefix={0}".format(prefix), "MOUNT_FUSE_PATH={0}".format(self.prefix.sbin), "UDEV_RULES_PATH={0}".format(self.prefix.etc), "INIT_D_PATH={0}".format(self.prefix.etc), ] - args.append( - "--enable-static" - if self.spec.satisfies("default_library=static") - else "--disable-static" - ) - args.append( - "--enable-shared" - if self.spec.satisfies("default_library=shared") - else "--disable-shared" - ) - - configure(*args) - - @when("@:2") - def build(self, spec, prefix): - make() - - @when("@:2") - def install(self, spec, prefix): - make("install") + return args