summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/gawk/package.py
blob: 2a10b412738bbdd65ddfcd4f2c7f0f871a0616f1 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright 2013-2023 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 Gawk(AutotoolsPackage, GNUMirrorPackage):
    """If you are like many computer users, you would frequently like to make
    changes in various text files wherever certain patterns appear, or
    extract data from parts of certain lines while discarding the
    rest. To write a program to do this in a language such as C or
    Pascal is a time-consuming inconvenience that may take many lines
    of code. The job is easy with awk, especially the GNU
    implementation: gawk.

    The awk utility interprets a special-purpose programming language
    that makes it possible to handle simple data-reformatting jobs
    with just a few lines of code.
    """

    homepage = "https://www.gnu.org/software/gawk/"
    gnu_mirror_path = "gawk/gawk-4.1.4.tar.xz"

    executables = ["^gawk$"]

    tags = ["build-tools", "core-packages"]

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

    version("5.2.2", sha256="3c1fce1446b4cbee1cd273bd7ec64bc87d89f61537471cd3e05e33a965a250e9")
    version("5.2.1", sha256="673553b91f9e18cc5792ed51075df8d510c9040f550a6f74e09c9add243a7e4f")
    version("5.1.1", sha256="d87629386e894bbea11a5e00515fc909dc9b7249529dad9e6a3a2c77085f7ea2")
    version("5.1.0", sha256="cf5fea4ac5665fd5171af4716baab2effc76306a9572988d5ba1078f196382bd")
    version("5.0.1", sha256="8e4e86f04ed789648b66f757329743a0d6dfb5294c3b91b756a474f1ce05a794")
    version("4.1.4", sha256="53e184e2d0f90def9207860531802456322be091c7b48f23fdc79cda65adc266")

    variant("nls", default=False, description="Enable Native Language Support")

    depends_on("gettext", when="+nls")
    depends_on("libsigsegv")
    depends_on("readline")
    depends_on("mpfr")
    depends_on("gmp")

    provides("awk")

    build_directory = "spack-build"

    @classmethod
    def determine_version(cls, exe):
        output = Executable(exe)("--version", output=str, error=str)
        match = re.search(r"GNU Awk\s+([\d\.]+)", output)
        return match.group(1) if match else None

    def configure_args(self):
        args = self.enable_or_disable("nls")

        # https://github.com/Homebrew/homebrew-core/blob/5b93511fd6b87789871e30c9fe0790949bd6634c/Formula/gawk.rb#L38,L42
        if self.spec.satisfies("platform=darwin target=aarch64:"):
            args.append("--disable-pma")

        return args