summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/sed/package.py
blob: d84c3421f683c73f542a31a948b06b4e4f797ec5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import re

from spack.package import *


class Sed(AutotoolsPackage, GNUMirrorPackage):
    """GNU implementation of the famous stream editor."""

    homepage = "https://www.gnu.org/software/sed/"
    gnu_mirror_path = "sed/sed-4.8.tar.xz"

    license("GPL-3.0-or-later")

    version("4.9", sha256="6e226b732e1cd739464ad6862bd1a1aba42d7982922da7a53519631d24975181")
    version("4.8", sha256="f79b0cfea71b37a8eeec8490db6c5f7ae7719c35587f21edb0617f370eeff633")
    version("4.2.2", sha256="f048d1838da284c8bc9753e4506b85a1e0cc1ea8999d36f6995bcb9460cddbd7")

    # Avoid symlinking GNUMakefile to GNUMakefile
    build_directory = "spack-build"

    executables = ["^sed$"]

    def url_for_version(self, version):
        if Version("4.2") <= version < Version("4.3.0"):
            self.gnu_mirror_path = "sed/sed-{0}.tar.bz2".format(version)
        elif version < Version("4.2"):
            self.gnu_mirror_path = "sed/sed-{0}.tar.gz".format(version)
        return super().url_for_version(version)

    @classmethod
    def determine_version(cls, exe):
        output = Executable(exe)("--version", output=str, error=str)
        version_regexp = r"{:s} \(GNU sed\) (\S+)".format(exe)
        match = re.search(version_regexp, output)
        return match.group(1) if match else None

    def flag_handler(self, name, flags):
        iflags = []
        if name == "cflags":
            if self.spec.satisfies("%oneapi@2023.0.0:"):
                iflags.append("-Wno-error=incompatible-function-pointer-types")
        return (iflags, None, None)