<commit_before># Copyright 2013-2019 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)

from spack import *
import os


class Lua(Package):
    """The Lua programming language interpreter and library."""

    homepage = "http://www.lua.org"
    url = "http://www.lua.org/ftp/lua-5.3.4.tar.gz"

    version('5.3.4', '53a9c68bcc0eda58bdc2095ad5cdfc63')
    version('5.3.2', '33278c2ab5ee3c1a875be8d55c1ca2a1')
    version('5.3.1', '797adacada8d85761c079390ff1d9961')
    version('5.3.0', 'a1b0a7e92d0c85bbff7a8d27bf29f8af')
    version('5.2.4', '913fdb32207046b273fdb17aad70be13')
    version('5.2.3', 'dc7f94ec6ff15c985d2d6ad0f1b35654')
    version('5.2.2', 'efbb645e897eae37cad4344ce8b0a614')
    version('5.2.1', 'ae08f641b45d737d12d30291a5e5f6e3')
    version('5.2.0', 'f1ea831f397214bae8a265995ab1a93e')
    version('5.1.5', '2e115fe26e435e33b0d5c022e4490567')
    version('5.1.4', 'd0870f2de55d59c1c8419f36e8fac150')
    version('5.1.3', 'a70a8dfaa150e047866dc01a46272599')

    extendable = True

    depends_on('ncurses')
    depends_on('readline')
    # luarocks needs unzip for some packages (e.g. lua-luaposix)
    depends_on('unzip', type='run')

    resource(
        name="luarocks",
        url="https://keplerproject.github.io/luarocks/releases/"
        "luarocks-2.3.0.tar.gz",
        md5="a38126684cf42b7d0e7a3c7cf485defb",
        destination="luarocks",
        placement='luarocks')

    def install(self, spec, prefix):
        if spec.satisfies("platform=darwin"):
            target = 'macosx'
        else:
            target = 'linux'
        make('INSTALL_TOP=%s' % prefix,
             'MYLDFLAGS=-L%s -L%s' % (
                 spec['readline'].prefix.lib,
                 spec['ncurses'].prefix.lib),
             'MYLIBS=-lncursesw',
             'CC=%s -std=gnu99 %s' % (spack_cc,
                                      self.compiler.pic_flag),
             target)
        make('INSTALL_TOP=%s' % prefix,
             'install')

        static_to_shared_library(join_path(prefix.lib, 'liblua.a'),
                                 arguments=['-lm'], version=self.version,
                                 compat_version=self.version.up_to(2))

        # compatibility with ax_lua.m4 from autoconf-archive
        # https://www.gnu.org/software/autoconf-archive/ax_lua.html
        with working_dir(prefix.lib):
            # e.g., liblua.so.5.1.5
            src_path = 'liblua.{0}.{1}'.format(dso_suffix,
                                               str(self.version.up_to(3)))

            # For lua version 5.1.X, the symlinks should be:
            # liblua5.1.so
            # liblua51.so<commit_msg>Lua: Fix unresolved symbols in shared library by linking with libdl.so (#11260)<commit_after># Copyright 2013-2019 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)

from spack import *
import os


class Lua(Package):
    """The Lua programming language interpreter and library."""

    homepage = "http://www.lua.org"
    url = "http://www.lua.org/ftp/lua-5.3.4.tar.gz"

    version('5.3.4', '53a9c68bcc0eda58bdc2095ad5cdfc63')
    version('5.3.2', '33278c2ab5ee3c1a875be8d55c1ca2a1')
    version('5.3.1', '797adacada8d85761c079390ff1d9961')
    version('5.3.0', 'a1b0a7e92d0c85bbff7a8d27bf29f8af')
    version('5.2.4', '913fdb32207046b273fdb17aad70be13')
    version('5.2.3', 'dc7f94ec6ff15c985d2d6ad0f1b35654')
    version('5.2.2', 'efbb645e897eae37cad4344ce8b0a614')
    version('5.2.1', 'ae08f641b45d737d12d30291a5e5f6e3')
    version('5.2.0', 'f1ea831f397214bae8a265995ab1a93e')
    version('5.1.5', '2e115fe26e435e33b0d5c022e4490567')
    version('5.1.4', 'd0870f2de55d59c1c8419f36e8fac150')
    version('5.1.3', 'a70a8dfaa150e047866dc01a46272599')

    extendable = True

    depends_on('ncurses')
    depends_on('readline')
    # luarocks needs unzip for some packages (e.g. lua-luaposix)
    depends_on('unzip', type='run')

    resource(
        name="luarocks",
        url="https://keplerproject.github.io/luarocks/releases/"
        "luarocks-2.3.0.tar.gz",
        md5="a38126684cf42b7d0e7a3c7cf485defb",
        destination="luarocks",
        placement='luarocks')

    def install(self, spec, prefix):
        if spec.satisfies("platform=darwin"):
            target = 'macosx'
        else:
            target = 'linux'
        make('INSTALL_TOP=%s' % prefix,
             'MYLDFLAGS=-L%s -L%s' % (
                 spec['readline'].prefix.lib,
                 spec['ncurses'].prefix.lib),
             'MYLIBS=-lncursesw',
             'CC=%s -std=gnu99 %s' % (spack_cc,
                                      self.compiler.pic_flag),
             target)
        make('INSTALL_TOP=%s' % prefix,
             'install')

        static_to_shared_library(join_path(prefix.lib, 'liblua.a'),
                                 arguments=['-lm', '-ldl'],
                                 version=self.version,
                                 compat_version=self.version.up_to(2))

        # compatibility with ax_lua.m4 from autoconf-archive
        # https://www.gnu.org/software/autoconf-archive/ax_lua.html
        with working_dir(prefix.lib):
            # e.g., liblua.so.5.1.5
            src_path = 'liblua.{0}.{1}'.format(dso_suffix,
                                               str(self.version.up_to(3)))

            # For lua version 5.1.X, the symlinks should be:
            # liblua5.1.so
            # liblua51.so
{'fraction_non_alphanumeric': 0.1364200816036899, 'fraction_numerical': 0.11300337058719177, 'mean_word_length': 2.351961950059453, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2551656', 'n_tokens_mistral': 2371, 'n_tokens_neox': 2089, 'n_words': 295}