# This file is part of LilyPond, the GNU music typesetter.
#
# Copyright (C) 2021--2023 Jonas Hahnfeld <hahnjo@hahnjo.de>
#
# LilyPond is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LilyPond is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.

"""This module defines all run-time dependencies of LilyPond."""

# Each class in this file represents a package, ignore missing docstrings.
# pylint: disable=missing-class-docstring

import logging
import os
import re
import shutil
from typing import Dict, List

from .build import Package, ConfigurePackage, MesonPackage
from .config import Config


def copy_slice(src: str, dst: str, lines: slice):
    """Copy a slice of lines from src to dst."""
    with open(src, "r", encoding="utf-8") as src_file:
        content = src_file.readlines()
    content = content[lines]
    with open(dst, "w", encoding="utf-8") as dst_file:
        dst_file.writelines(content)


class Expat(ConfigurePackage):
    @property
    def version(self) -> str:
        return "2.4.9"

    @property
    def directory(self) -> str:
        return f"expat-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        version = self.version.replace(".", "_")
        return f"https://github.com/libexpat/libexpat/releases/download/R_{version}/{self.archive}"

    def configure_args(self, c: Config) -> List[str]:
        return [
            # Disable unneeded components.
            "--without-xmlwf",
            "--without-examples",
            "--without-tests",
            "--without-docbook",
        ]

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"Expat {self.version}"


expat = Expat()


class Zlib(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.2.13"

    @property
    def directory(self) -> str:
        return f"zlib-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://www.zlib.net/fossils/{self.archive}"

    def apply_patches(self, c: Config):
        def patch_configure(content: str) -> str:
            return content.replace("leave 1", "")

        self.patch_file(c, "configure", patch_configure)

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        if c.is_mingw():
            env["CHOST"] = c.triple
        return env

    def configure_args_triples(self, c: Config) -> List[str]:
        # Cross-compilation is enabled via the CHOST environment variable.
        return []

    def configure_args_static(self, c: Config) -> List[str]:
        return ["--static"]

    def get_env_variables(self, c: Config) -> Dict[str, str]:
        """Return environment variables to make zlib available."""
        zlib_install = self.install_directory(c)
        return {
            "CPATH": os.path.join(zlib_install, "include"),
            # Cannot use LIBRARY_PATH because it is only used if GCC is built
            # as a native compiler, so it doesn't work for mingw.
            "LDFLAGS": "-L" + os.path.join(zlib_install, "lib"),
        }

    def copy_license_files(self, destination: str, c: Config):
        readme_src = os.path.join(self.src_directory(c), "README")
        readme_dst = os.path.join(destination, f"{self.directory}.README")
        copy_slice(readme_src, readme_dst, slice(-38, None))

    def __str__(self) -> str:
        return f"zlib {self.version}"


zlib = Zlib()


class FreeType(ConfigurePackage):
    @property
    def version(self) -> str:
        return "2.12.1"

    @property
    def directory(self) -> str:
        return f"freetype-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://download.savannah.gnu.org/releases/freetype/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [zlib]

    def configure_args(self, c: Config) -> List[str]:
        return [
            "--with-zlib=yes",
            "--with-bzip2=no",
            "--with-png=no",
            "--with-brotli=no",
            # Disable unused harfbuzz.
            "--with-harfbuzz=no",
        ]

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE.TXT", os.path.join("docs", "GPLv2.TXT")]

    def __str__(self) -> str:
        return f"FreeType {self.version}"


freetype = FreeType()


class Fontconfig(ConfigurePackage):
    @property
    def version(self) -> str:
        return "2.14.0"

    @property
    def directory(self) -> str:
        return f"fontconfig-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://www.freedesktop.org/software/fontconfig/release/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [expat, freetype]

    def configure_args(self, c: Config) -> List[str]:
        return ["--disable-docs"]

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"Fontconfig {self.version}"


fontconfig = Fontconfig()


class Ghostscript(ConfigurePackage):
    @property
    def version(self) -> str:
        return "9.56.1"

    @property
    def directory(self) -> str:
        return f"ghostscript-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.gz"

    @property
    def download_url(self) -> str:
        # pylint: disable=line-too-long
        url_version = self.version.replace(".", "")
        return f"https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs{url_version}/{self.archive}"

    def apply_patches(self, c: Config):
        # Remove unused bundled sources to disable their build.
        dirs = ["tesseract", "leptonica"]

        for unused in dirs:
            shutil.rmtree(os.path.join(self.src_directory(c), unused))

    def dependencies(self, c: Config) -> List[Package]:
        return [freetype]

    def configure_args_static(self, c: Config) -> List[str]:
        # Ghostscript doesn't have --disable-shared nor --enable-static.
        return []

    def configure_args(self, c: Config) -> List[str]:
        return [
            # Only enable drivers needed for LilyPond.
            "--disable-contrib",
            "--disable-dynamic",
            "--with-drivers=PNG,PS",
            # Disable unused dependencies and features.
            "--disable-cups",
            "--disable-dbus",
            "--disable-fontconfig",
            "--disable-gtk",
            "--without-cal",
            "--without-ijs",
            "--without-libidn",
            "--without-libpaper",
            "--without-libtiff",
            "--without-pdftoraster",
            "--without-urf",
            "--without-x",
        ]

    def exe_path(self, c: Config) -> str:
        """Return path to gs executable."""
        gs_exe = f"gs{c.program_suffix}"
        return os.path.join(self.install_directory(c), "bin", gs_exe)

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE", os.path.join("doc", "COPYING")]

    def __str__(self) -> str:
        return f"Ghostscript {self.version}"


ghostscript = Ghostscript()


class Gettext(ConfigurePackage):
    def enabled(self, c: Config) -> bool:
        return c.is_freebsd() or c.is_macos() or c.is_mingw()

    @property
    def version(self) -> str:
        return "0.21.1"

    @property
    def directory(self) -> str:
        return f"gettext-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://ftpmirror.gnu.org/gnu/gettext/{self.archive}"

    def apply_patches(self, c: Config):
        # localcharset.c defines locale_charset, which is also provided by
        # Guile. However, Guile has a modification to this file so we really
        # need to build that version.
        def patch_makefile(content: str) -> str:
            return content.replace("localcharset.lo", "")

        makefile = os.path.join("gettext-runtime", "intl", "Makefile.in")
        self.patch_file(c, makefile, patch_makefile)

        def patch_dcigettext(content: str) -> str:
            return content.replace("locale_charset ()", "NULL")

        dcigettext = os.path.join("gettext-runtime", "intl", "dcigettext.c")
        self.patch_file(c, dcigettext, patch_dcigettext)

    @property
    def configure_script(self) -> str:
        return os.path.join("gettext-runtime", "configure")

    def configure_args_static(self, c: Config) -> List[str]:
        if c.is_mingw():
            # On mingw, we need to build glib as shared libraries for DllMain to
            # work. This also requires a shared libintl.dll to ensure there is
            # exactly one copy of the variables and code.
            return ["--enable-shared", "--disable-static"]
        return super().configure_args_static(c)

    def configure_args(self, c: Config) -> List[str]:
        return [
            # Disable building with libiconv in case the library is installed
            # on the system (as is the case for FreeBSD and macOS).
            "am_cv_func_iconv=no",
            # Disable unused features.
            "--disable-java",
            "--disable-threads",
        ]

    @property
    def macos_ldflags(self):
        """Return additional linker flags for macOS."""
        return "-Wl,-framework -Wl,CoreFoundation"

    def get_env_variables(self, c: Config) -> Dict[str, str]:
        """Return environment variables to make libintl available."""
        gettext_install = self.install_directory(c)

        # Cannot use LIBRARY_PATH because it is only used if GCC is built
        # as a native compiler, so it doesn't work for mingw.
        ldflags = "-L" + os.path.join(gettext_install, "lib")
        if c.is_macos():
            ldflags += " " + self.macos_ldflags

        return {
            "CPATH": os.path.join(gettext_install, "include"),
            "LDFLAGS": ldflags,
        }

    @property
    def license_files(self) -> List[str]:
        return [
            os.path.join("gettext-runtime", "COPYING"),
            os.path.join("gettext-runtime", "intl", "COPYING.LIB"),
        ]

    def __str__(self) -> str:
        return f"gettext {self.version}"


gettext = Gettext()


class Libffi(ConfigurePackage):
    @property
    def version(self) -> str:
        return "3.4.3"

    @property
    def directory(self) -> str:
        return f"libffi-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://github.com/libffi/libffi/releases/download/v{self.version}/{self.archive}"

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libffi {self.version}"


libffi = Libffi()


class PCRE(ConfigurePackage):
    @property
    def version(self) -> str:
        return "8.45"

    @property
    def directory(self) -> str:
        return f"pcre-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://sourceforge.net/projects/pcre/files/pcre/{self.version}/{self.archive}"

    @property
    def license_files(self) -> List[str]:
        return ["LICENCE"]

    def configure_args(self, c: Config) -> List[str]:
        return [
            # Enable Unicode support, needed for LilyPond's GLib-based
            # regex API.  This is the default in PCRE2, but we use PCRE1.
            "--enable-utf",
            "--enable-unicode-properties",
        ]

    def __str__(self) -> str:
        return f"PCRE {self.version}"


pcre = PCRE()


class GLib(MesonPackage):
    @property
    def version(self) -> str:
        return "2.72.4"

    @property
    def directory(self) -> str:
        return f"glib-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        major_version = ".".join(self.version.split(".")[0:2])
        return f"http://ftp.gnome.org/pub/gnome/sources/glib/{major_version}/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        gettext_dep: List[Package] = []
        if c.is_freebsd() or c.is_macos() or c.is_mingw():
            gettext_dep = [gettext]
        return gettext_dep + [libffi, pcre, zlib, harfbuzz]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        if c.is_freebsd() or c.is_macos() or c.is_mingw():
            # Make meson find libintl.
            env.update(gettext.get_env_variables(c))
        return env

    def meson_args_static(self, c: Config) -> List[str]:
        if c.is_mingw():
            # The libraries rely on DllMain which doesn't work with static.
            return ["--default-library=shared"]
        return super().meson_args_static(c)

    def meson_args(self, c: Config) -> List[str]:
        return [
            # Disable unused features and tests.
            "-Dlibmount=disabled",
            "-Dtests=false",
            "-Dxattr=false",
        ]

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"GLib {self.version}"


glib = GLib()


class Bdwgc(ConfigurePackage):
    @property
    def version(self) -> str:
        return "8.2.2"

    @property
    def directory(self) -> str:
        return f"gc-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://www.hboehm.info/gc/gc_source/{self.archive}"

    def apply_patches(self, c: Config):
        # For lack of a better method for finding static data sections in shared
        # libraries, bdwgc on Windows scans all memory pages and (temporarily)
        # adds them to the root set. This leads to problems and sporadic crashes
        # if a memory page disappears while marking. Until a proper solution is
        # found, disable this entire mechanism because by design of statically
        # linking both bdwgc and libguile, we can guarantee that all root sets
        # relevant for garbage collection are in the data section of the main
        # executable, which can be conveniently located by looking at a single
        # static variable and determining the surrounding pages.
        # Upstream issue: https://github.com/ivmai/bdwgc/issues/454
        def disable_win32_dlls(content: str) -> str:
            return content.replace(
                "GC_no_win32_dlls = FALSE", "GC_no_win32_dlls = TRUE"
            )

        self.patch_file(c, "os_dep.c", disable_win32_dlls)

    def configure_args(self, c: Config) -> List[str]:
        return [
            "--disable-docs",
            # Enable large config, optimizing for heap sizes larger than a few
            # 100 MB and allowing more heap sections needed on Windows for huge
            # scores.
            "--enable-large-config",
            # Fix cross-compilation for mingw.
            "--with-libatomic-ops=none",
        ]

    def copy_license_files(self, destination: str, c: Config):
        readme_src = os.path.join(self.src_directory(c), "README.md")
        readme_dst = os.path.join(destination, f"{self.directory}.README")
        copy_slice(readme_src, readme_dst, slice(-48, None))

    def __str__(self) -> str:
        return f"bdwgc {self.version}"


bdwgc = Bdwgc()


class GMP(ConfigurePackage):
    @property
    def version(self) -> str:
        return "6.2.1"

    @property
    def directory(self) -> str:
        return f"gmp-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://gmplib.org/download/gmp/{self.archive}"

    @property
    def license_files(self) -> List[str]:
        return ["COPYING.LESSERv3"]

    def copy_license_files(self, destination: str, c: Config):
        super().copy_license_files(destination, c)

        readme_src = os.path.join(self.src_directory(c), "README")
        readme_dst = os.path.join(destination, f"{self.directory}.README")
        copy_slice(readme_src, readme_dst, slice(0, 27))

    def __str__(self) -> str:
        return f"GMP {self.version}"


gmp = GMP()


class Libiconv(ConfigurePackage):
    def enabled(self, c: Config) -> bool:
        return c.is_mingw()

    @property
    def version(self) -> str:
        return "1.17"

    @property
    def directory(self) -> str:
        return f"libiconv-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://ftpmirror.gnu.org/gnu/libiconv/{self.archive}"

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"libiconv {self.version}"


libiconv = Libiconv()


class Libtool(ConfigurePackage):
    @property
    def version(self) -> str:
        return "2.4.7"

    @property
    def directory(self) -> str:
        return f"libtool-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://ftpmirror.gnu.org/gnu/libtool/{self.archive}"

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"Libtool {self.version}"


libtool = Libtool()


class Libunistring(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.0"

    @property
    def directory(self) -> str:
        return f"libunistring-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://ftpmirror.gnu.org/gnu/libunistring/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        libiconv_dep: List[Package] = []
        if c.is_mingw():
            libiconv_dep = [libiconv]
        return libiconv_dep

    def configure_args(self, c: Config) -> List[str]:
        mingw_args = []
        if c.is_mingw():
            libiconv_install_dir = libiconv.install_directory(c)
            mingw_args = [
                f"--with-libiconv-prefix={libiconv_install_dir}",
            ]

        return ["--disable-threads"] + mingw_args

    @property
    def license_files(self) -> List[str]:
        return ["COPYING.LIB"]

    def copy_license_files(self, destination: str, c: Config):
        super().copy_license_files(destination, c)

        readme_src = os.path.join(self.src_directory(c), "README")
        readme_dst = os.path.join(destination, f"{self.directory}.README")
        copy_slice(readme_src, readme_dst, slice(47, 63))

    def __str__(self) -> str:
        return f"libunistring {self.version}"


libunistring = Libunistring()


class Guile(ConfigurePackage):
    @property
    def version(self) -> str:
        return "2.2.7"

    @property
    def major_version(self) -> str:
        """Return Guile's major version, used in the directory structure."""
        return ".".join(self.version.split(".")[0:2])

    @property
    def directory(self) -> str:
        return f"guile-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://ftpmirror.gnu.org/gnu/guile/{self.archive}"

    def _apply_patches_mingw(self, c: Config):
        # Fix the build.
        def patch_start_child(content: str) -> str:
            return content.replace("int start_child", "pid_t start_child")

        posix_w32_h = os.path.join("libguile", "posix-w32.h")
        self.patch_file(c, posix_w32_h, patch_start_child)

        # TODO: Find proper solution...
        def patch_gethostname(content: str) -> str:
            return "\n".join(
                [
                    line
                    for line in content.split("\n")
                    if "gethostname_used_without_requesting" not in line
                ]
            )

        unistd_in_h = os.path.join("lib", "unistd.in.h")
        self.patch_file(c, unistd_in_h, patch_gethostname)

        # Fix conversion of large long values.
        def patch_conversion(content: str) -> str:
            return content.replace(
                "SIZEOF_TYPE < SIZEOF_SCM_T_BITS", "SIZEOF_TYPE < SIZEOF_LONG"
            )

        for conv in ["conv-integer.i.c", "conv-uinteger.i.c"]:
            self.patch_file(c, os.path.join("libguile", conv), patch_conversion)

        # Fix headers so compilation of LilyPond works.
        def patch_iselect(content: str) -> str:
            return content.replace("sys/select.h", "winsock2.h")

        iselect_h = os.path.join("libguile", "iselect.h")
        self.patch_file(c, iselect_h, patch_iselect)

        def patch_null_threads(content: str) -> str:
            content = content.replace(" sigset_t", " _sigset_t")
            content = re.sub("return sigprocmask.*", "return 0;", content)
            return content

        null_threads_h = os.path.join("libguile", "null-threads.h")
        self.patch_file(c, null_threads_h, patch_null_threads)

        def patch_numbers(content: str) -> str:
            return "\n".join(
                [line for line in content.split("\n") if "copysign" not in line]
            )

        numbers_h = os.path.join("libguile", "numbers.h")
        self.patch_file(c, numbers_h, patch_numbers)

    def apply_patches(self, c: Config):
        # Fix configure on CentOS7 to not look in lib64.
        def patch_configure(content: str) -> str:
            return content.replace("=lib64", "=lib")

        self.patch_file(c, "configure", patch_configure)

        # Explicitly list static archive to prevent pkgconfig on CentOS7 from
        # reordering the library items.
        def patch_pkgconfig(content: str) -> str:
            return content.replace(
                "-lguile-@GUILE_EFFECTIVE_VERSION@",
                "${libdir}/libguile-@GUILE_EFFECTIVE_VERSION@.a",
            )

        pkgconfig = os.path.join("meta", f"guile-{self.major_version}.pc.in")
        self.patch_file(c, pkgconfig, patch_pkgconfig)

        # Fix non-portable invocation of inplace sed.
        def patch_inplace_sed(content: str) -> str:
            return content.replace("$(SED) -i", "$(SED)")

        libguile_makefile_in = os.path.join("libguile", "Makefile.in")
        self.patch_file(c, libguile_makefile_in, patch_inplace_sed)

        if c.is_mingw():
            self._apply_patches_mingw(c)

    def dependencies(self, c: Config) -> List[Package]:
        gettext_dep: List[Package] = []
        if c.is_freebsd() or c.is_macos() or c.is_mingw():
            gettext_dep = [gettext]
        libiconv_dep: List[Package] = []
        if c.is_mingw():
            libiconv_dep = [libiconv]
        return gettext_dep + libiconv_dep + [bdwgc, libffi, libtool, libunistring, gmp]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        if c.is_macos():
            # We don't need the full get_env_variables because we can pass
            # --with-libintl-prefix= via the arguments to configure.
            env["LDFLAGS"] = gettext.macos_ldflags
        return env

    def configure_args(self, c: Config) -> List[str]:
        gmp_install_dir = gmp.install_directory(c)
        libunistring_install_dir = libunistring.install_directory(c)
        libtool_install_dir = libtool.install_directory(c)

        libintl_args = []
        if c.is_freebsd() or c.is_macos() or c.is_mingw():
            gettext_install_dir = gettext.install_directory(c)
            libintl_args = [
                f"--with-libintl-prefix={gettext_install_dir}",
            ]

        mingw_args = []
        if c.is_mingw():
            guile_for_build = self.exe_path(c.native_config)
            libiconv_install_dir = libiconv.install_directory(c)
            mingw_args = [
                f"GUILE_FOR_BUILD={guile_for_build}",
                f"--with-libiconv-prefix={libiconv_install_dir}",
            ]

        return (
            [
                # Disable unused parts of Guile.
                "--without-threads",
                "--disable-networking",
                # Disable -Werror to enable builds with newer compilers.
                "--disable-error-on-warning",
                # Make configure find the statically built dependencies.
                f"--with-libgmp-prefix={gmp_install_dir}",
                f"--with-libltdl-prefix={libtool_install_dir}",
                f"--with-libunistring-prefix={libunistring_install_dir}",
                # Prevent that configure searches for libcrypt.
                "ac_cv_search_crypt=no",
            ]
            + libintl_args
            + mingw_args
        )

    def exe_path(self, c: Config) -> str:
        """Return path to the guile interpreter."""
        guile_exe = f"guile{c.program_suffix}"
        return os.path.join(self.install_directory(c), "bin", guile_exe)

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE", "COPYING.LESSER"]

    def __str__(self) -> str:
        return f"Guile {self.version}"


guile = Guile()


class HarfBuzz(ConfigurePackage):
    @property
    def version(self) -> str:
        return "4.4.1"

    @property
    def directory(self) -> str:
        return f"harfbuzz-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        # pylint: disable=line-too-long
        #return f"https://www.freedesktop.org/software/harfbuzz/release/{self.archive}"
        return f"https://github.com/harfbuzz/harfbuzz/releases/download/{self.version}/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [freetype]

    def meson_args(self, c: Config) -> List[str]:
        return [
            # Enable FreeType, but disable tests.
            "-Dfreetype=enabled",
            "-Dtests=disabled",
        ]

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"HarfBuzz {self.version}"


harfbuzz = HarfBuzz()


class FriBidi(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.0.12"

    @property
    def directory(self) -> str:
        return f"fribidi-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        # pylint: disable=line-too-long
        return f"https://github.com/fribidi/fribidi/releases/download/v{self.version}/{self.archive}"

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"FriBiDi {self.version}"


fribidi = FriBidi()


class Pango(MesonPackage):
    @property
    def version(self) -> str:
        return "1.50.11"

    @property
    def directory(self) -> str:
        return f"pango-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        major_version = ".".join(self.version.split(".")[0:2])
        # fmt: off
        return f"https://download.gnome.org/sources/pango/{major_version}/{self.archive}"
        # fmt: on

    def apply_patches(self, c: Config):
        # Disable tests, fail to build on FreeBSD.
        def patch_meson_build(content: str) -> str:
            # Disable unused parts (tests fail to build on FreeBSD, utils and tools on macOS)
            for subdir in ["tests", "tools", "utils"]:
                content = content.replace(f"subdir('{subdir}')", "")
            return content

        self.patch_file(c, "meson.build", patch_meson_build)

    def dependencies(self, c: Config) -> List[Package]:
        return [fontconfig, freetype, fribidi, glib, harfbuzz, cairo]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        glib_bin = os.path.join(glib.install_directory(c), "bin")
        env["PATH"] = f"{glib_bin}{os.pathsep}{os.environ['PATH']}"
        return env

    def meson_args(self, c: Config) -> List[str]:
        return [
            # Disable Cairo, which is enabled by default since 1.50.3.
            "-Dcairo=disabled",
            # Enable Fontconfig and FreeType.
            "-Dfontconfig=enabled",
            "-Dfreetype=enabled",
        ]

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"Pango {self.version}"


pango = Pango()

class Pangocairo(MesonPackage):
    @property
    def version(self) -> str:
        return "1.50.11"

    @property
    def directory(self) -> str:
        return f"pango-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        major_version = ".".join(self.version.split(".")[0:2])
        # fmt: off
        return f"https://download.gnome.org/sources/pango/{major_version}/{self.archive}"
        # fmt: on

    def apply_patches(self, c: Config):
        # Disable tests, fail to build on FreeBSD.
        def patch_meson_build(content: str) -> str:
            # Disable unused parts (tests fail to build on FreeBSD, utils and tools on macOS)
            for subdir in ["tests", "tools", "utils"]:
                content = content.replace(f"subdir('{subdir}')", "")
            return content

        self.patch_file(c, "meson.build", patch_meson_build)

    def dependencies(self, c: Config) -> List[Package]:
        return [fontconfig, freetype, fribidi, glib, harfbuzz, cairo, gettext]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        glib_bin = os.path.join(glib.install_directory(c), "bin")
        env["PATH"] = f"{glib_bin}{os.pathsep}{os.environ['PATH']}"
        return env


#    def build_env_extra(self, c: Config) -> Dict[str, str]:
#        env = super().build_env_extra(c)
#        glib_bin = os.path.join(glib.install_directory(c), "bin")
#        env["PATH"] = f"{glib_bin}{os.pathsep}{os.environ['PATH']}"
#        return env

  
    def meson_args(self, c: Config) -> List[str]:
        return [
            # Enable Cairo, which is enabled by default since 1.50.3.
            "-Dcairo=enabled",
           # "--enable-explicit-deps",
           # "--with-included-modules",
           # "--without-dynamic-modules",
            # Enable Fontconfig and FreeType.
            "-Dfontconfig=enabled",
            "-Dfreetype=enabled",
        ]
#    def configure_args(self, c: Config) -> List[str]:
#        return [
            # ordering follows Cairo's configure --help output
#            "--enable-explicit-deps",

#"--with-included-modules",
#            "--without-dynamic-modules"
            #]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        if c.is_freebsd() or c.is_macos() or c.is_mingw():
            # Make meson find libintl.
            env.update(gettext.get_env_variables(c))
        return env
                                                        #


#    def build_env_extra(self, c: Config) -> Dict[str, str]:
#        env = super().build_env_extra(c)
#        harfbuzz_include = "-I" + os.path.join(harfbuzz.install_directory(c), "include")
        #libogg_lib = "-L" + os.path.join(libogg.install_directory(c), "lib")
#        env["CFLAGS"] = harfbuzz_include #f"{libogg_include}{os.pathsep}{os.environ['CFLAGS']}"
        #env["LDFLAGS"] = libogg_lib  #FIXME append
        #env["LDFLAGS"] = f"{libogg_lib}{os.pathsep}{os.environ['LDFLAGS']}"
#        return env

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"Pangocairo {self.version}"


pangocairo = Pangocairo()


class Libpng(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.6.38"

    @property
    def directory(self) -> str:
        return f"libpng-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://downloads.sourceforge.net/libpng/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [zlib]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libpng {self.version}"


libpng = Libpng()


class Pixman(MesonPackage):
    @property
    def version(self) -> str:
        return "0.40.0"

    @property
    def directory(self) -> str:
        return f"pixman-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://www.cairographics.org/releases/{self.archive}"

    def apply_patches(self, c: Config):
        # Disable tests, they fail to build on macOS.
        def patch_meson_build(content: str) -> str:
            return content.replace("subdir('test')", "")

        self.patch_file(c, "meson.build", patch_meson_build)

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"pixman {self.version}"


pixman = Pixman()

class lzo(ConfigurePackage):
    @property
    def version(self) -> str:
        return "2.09"

    @property
    def directory(self) -> str:
        return f"lzo-{self.version}"

    @property
    def archive(self) -> str:
        return f"lzo-{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://www.oberhumer.com/opensource/lzo/download/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"lzo {self.version}"

lzo = lzo()



class Cairo(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.16.0"

    @property
    def directory(self) -> str:
        return f"cairo-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://www.cairographics.org/releases/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [zlib, freetype, fontconfig, libpng, pixman, glib, lzo]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        # Cairo sets this by default, but doesn't work on Mingw.
        env["CFLAGS"] = "-Wp,-U_FORTIFY_SOURCE"
        return env

    def configure_args(self, c: Config) -> List[str]:
        return [
            # ordering follows Cairo's configure --help output
            "--enable-xlib=no",
            "--enable-xlib-xrender=no",
            "--enable-xcb=no",
            "--enable-xcb-shm=no",
            "--enable-quartz=no",
            "--enable-quartz-font=no",
            "--enable-win32=yes",
            "--enable-win32-font=yes",
            "--enable-egl=no",
            "--enable-glx=no",
            "--enable-wgl=no",
            "--enable-script=no",
            "--enable-ft=yes",
            "--enable-fc=yes",
            "--enable-ps=yes",
            "--enable-png=yes",
            "--enable-pdf=yes",
            "--enable-svg=yes",
        ]

    @property
    def license_files(self) -> List[str]:
        return ["COPYING"]

    def __str__(self) -> str:
        return f"cairo {self.version}"


cairo = Cairo()


PYTHON_VERSION = "3.10.8"


class Python(ConfigurePackage):
    def enabled(self, c: Config) -> bool:
        # For Windows, we are using the embeddable package because it's
        # impossible to cross-compile Python without tons of patches...
        return not c.is_mingw()

    @property
    def version(self) -> str:
        return PYTHON_VERSION

    @property
    def major_version(self) -> str:
        """Return Python's major version, used in the executable name."""
        return ".".join(self.version.split(".")[0:2])

    @property
    def python_with_major_version(self) -> str:
        """Return the string 'python' with the major version."""
        return f"python{self.major_version}"

    @property
    def directory(self) -> str:
        return f"Python-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://www.python.org/ftp/python/{self.version}/{self.archive}"

    def apply_patches(self, c: Config):
        # setup.py tries to build extension based on software installed in the
        # global system directories, and there is no option to build some of
        # them selectively. Instead we empty the script and enable what we need
        # in Modules/Setup below. This has the additional advantage that the
        # modules are built statically into libpython and not dynamically loaded
        # from lib-dynload/.
        setup_py = os.path.join(self.src_directory(c), "setup.py")
        with open(setup_py, "w", encoding="utf-8"):
            pass

        def patch_setup(content: str) -> str:
            for module in [
                "array",
                "fcntl",
                "math",
                # Needed for fractions
                "_contextvars",
                # Needed for hashlib
                "_md5",
                "_sha1",
                "_sha256",
                "_sha512",
                "_sha3",
                "_blake2",
                # Needed for subprocess
                "_posixsubprocess",
                "select",
                # Needed for tempfile
                "_random",
                # Needed for xml
                "pyexpat",
                # Needed for zipfile
                "binascii",
                "_struct",
                "zlib",
            ]:
                content = content.replace("#" + module, module)
            return content

        self.patch_file(c, os.path.join("Modules", "Setup"), patch_setup)

    def dependencies(self, c: Config) -> List[Package]:
        return [zlib]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    def configure_args(self, c: Config) -> List[str]:
        return [
            "--with-ensurepip=no",
            # Prevent that configure searches for libcrypt.
            "ac_cv_search_crypt=no",
            "ac_cv_search_crypt_r=no",
        ]

    def exe_path(self, c: Config) -> str:
        """Return path to the python3 interpreter."""
        exe = self.python_with_major_version
        return os.path.join(self.install_directory(c), "bin", exe)

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"Python {self.version}"


python = Python()


class EmbeddablePython(Package):
    def enabled(self, c: Config) -> bool:
        return c.is_mingw()

    @property
    def version(self) -> str:
        return PYTHON_VERSION

    @property
    def directory(self) -> str:
        return f"python-{self.version}-embed-amd64"

    @property
    def archive(self) -> str:
        return f"{self.directory}.zip"

    @property
    def download_url(self) -> str:
        return f"https://www.python.org/ftp/python/{self.version}/{self.archive}"

    def prepare_sources(self, c: Config) -> bool:
        src_directory = self.src_directory(c)
        if os.path.exists(src_directory):
            logging.debug("'%s' already extracted", self.archive)
            return True

        archive = self.archive_path(c)
        if not os.path.exists(archive):
            logging.error("'%s' does not exist!", self.archive)
            return False

        # The archive has no directory, directly extract into src_directory.
        shutil.unpack_archive(archive, self.src_directory(c))

        return True

    def build(self, c: Config):
        src_directory = self.src_directory(c)
        install_directory = self.install_directory(c)

        os.makedirs(install_directory, exist_ok=True)

        # NB: Without a dot between the two numbers!
        major_version = "".join(self.version.split(".")[0:2])
        python_with_major_version = f"python{major_version}"

        # Copy over the needed files from the downloaded archive.
        for filename in [
            "python.exe",
            f"{python_with_major_version}.dll",
            f"{python_with_major_version}.zip",
            # For parsing (Music)XML
            "pyexpat.pyd",
        ]:
            shutil.copy(os.path.join(src_directory, filename), install_directory)

        return True

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE.txt"]

    def __str__(self) -> str:
        return f"Python {self.version} (embeddable package)"


embeddable_python = EmbeddablePython()

class shared_mime_info(MesonPackage):
    @property
    def version(self) -> str:
        return "2.2"

    @property
    def directory(self) -> str:
        return f"shared-mime-info-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.2/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [glib, libxml2]

    def meson_args(self, c: Config) -> List[str]:
#        #if c.is_mingw():
            # The libraries rely on DllMain which doesn't work with static.
        return [
                "--default-library=both",
                "--buildtype=release",
                "-Dupdate-mimedb=true"
 
                ]
        # return super().meson_args_static(c)


#    def meson_args(self, c: Config) -> List[str]:
#        return [
#            "--buildtype=release", 
#            "-Dupdate-mimedb=true",
#           ]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        xmllint_bin = os.path.join(libxml2.install_directory(c), "bin")
        #env["PATH"] = f"{xmllint_bin}{os.pathsep}{os.environ['PATH']}"
        env["PATH"] = xmllint_bin
        return env

    def get_env_variables(self, c: Config) -> Dict[str, str]:
        """Return environment variables to make libintl available."""
        shared_mime_info_install = self.install_directory(c)

        # Cannot use LIBRARY_PATH because it is only used if GCC is built
        # as a native compiler, so it doesn't work for mingw.
        ldflags = "-L" + os.path.join(shared_mime_info_install, "lib")

        return {
            "CPATH": os.path.join(shared_mime_info_install, "include"),
            "LDFLAGS": ldflags,
        }



    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"shared-mime-info {self.version}"

shared_mime_info = shared_mime_info()


class gdk_pixbuf(MesonPackage):
    @property
    def version(self) -> str:
        return "2.42.6"

    @property
    def directory(self) -> str:
        return f"gdk-pixbuf-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.42/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [glib, gettext, libpng, jasper, jpeg, libiconv]

    #def meson_args(self, c: Config) -> List[str]:
    #    return [
    #        "-Dinstalled_tests=false",
    #        "-Dintrospection=disabled",
    #        "-Dman=false",
    #        "-Dbuiltin_loaders=all",
            #"--disable-modules",
            #"--with-included-loaders",
            
    #       ]
    def meson_args_static(self, c: Config) -> List[str]:
        if c.is_mingw():
            # The libraries rely on DllMain which doesn't work with static.
            return [
                "--default-library=shared",
                "-Dinstalled_tests=false",
                "-Dintrospection=disabled",
                "-Dman=false",
                "-Dbuiltin_loaders=all"

                    ]
        return super().meson_args_static(c)

    
#./dependencies/install/shared-mime-info-2.2/share/pkgconfig/shared-mime-info.pc
#    def build_env_extra(self, c: Config) -> Dict[str, str]:
#        env = super().build_env_extra(c)
#        env.update(zlib.get_env_variables(c))
#        shared_mime_info_pkgconfig = os.path.join(shared_mime_info.install_directory(c), "share", 'pkgconfig')
#        env["PKG_CONFIG_PATH"] = shared_mime_info_pkgconfig

#        return env
 
    def get_env_variables(self, c: Config) -> Dict[str, str]:
        """Return environment variables to make libintl available."""
        gdk_pixbuf_install = self.install_directory(c)

        #ldflags = "-L" + os.path.join(gdk_pixbuf_install, "lib")

#        return {
#            "CPATH": os.path.join(gdk_pixbuf_install, "include"),
#            "LDFLAGS": ldflags,
#        }

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(gettext.get_env_variables(c))
        return env



    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"gdk-pixbuf {self.version}"

gdk_pixbuf = gdk_pixbuf()

class atk(MesonPackage):
    @property
    def version(self) -> str:
        return "2.36.0"

    @property
    def directory(self) -> str:
        return f"atk-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://download.gnome.org/sources/atk/2.36/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [glib, gettext]

    def meson_args_static(self, c: Config) -> List[str]:
        return [
            "-Dintrospection=false",
        ]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(gettext.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"atk {self.version}"

atk = atk()



class jpeg(ConfigurePackage):
    @property
    def version(self) -> str:
        return "9c"

    @property
    def directory(self) -> str:
        return f"jpeg-{self.version}"

    @property
    def archive(self) -> str:
        return f"jpegsrc.v{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"http://www.ijg.org/files/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"jpeg {self.version}"

jpeg = jpeg()


class jasper(ConfigurePackage):
    @property
    def version(self) -> str:
        return "2.0.14"

    @property
    def directory(self) -> str:
        return f"jasper-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://www.ece.uvic.ca/~mdadams/jasper/software/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [jpeg]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"jasper {self.version}"

jasper = jasper()


class xproto(ConfigurePackage):
    @property
    def version(self) -> str:
        return "7.0.23"
    #.31 is latest. https://www.x.org/archive/individual/proto/xproto-7.0.31.tar.gz
    @property
    def directory(self) -> str:
        return f"xproto-{self.version}"

    @property
    def archive(self) -> str:
        return f"xproto-{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"xproto {self.version}"

xproto = xproto()

class util_macros(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.17"

    @property
    def directory(self) -> str:
        return f"util-macros-{self.version}"

    @property
    def archive(self) -> str:
        return f"util-macros-{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"util-macros {self.version}"

util_macros = util_macros()

class libXau(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.0.7"

    @property
    def directory(self) -> str:
        return f"libXau-{self.version}"

    @property
    def archive(self) -> str:
        return f"libXau-{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [xproto]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
    #it seems to be not finding ./dependencies/install/util-macros-1.17/share/pkgconfig/xorg-macros.pc


#        util_macros_pkgconfig = os.path.join(util_macros.install_directory(c), "share", "pkgconfig")
#not a lib dir create        libxau_lib = "-L" + os.path.join(util_macros.install_directory(c), "lib")
#        libxau_cflags = "-I" + os.path.join(util_macros.install_directory(c), "include")

#        env["XAU_LIBS"] = libxau_lib  #FIXME append
#        env["XAU_CFLAGS"] = libxau_cflags  #FIXME append

        #env["LDFLAGS"] = f"{libogg_lib}{os.pathsep}{os.environ['LDFLAGS']}"

#        env["PKG_CONFIG_PATH"] = util_macros_pkgconfig

        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libXau {self.version}"

libxau = libXau()

class xcb_proto(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.7.1"

    @property
    def directory(self) -> str:
        return f"xcb-proto-{self.version}"

    @property
    def archive(self) -> str:
        return f"xcb-proto-{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [xproto, util_macros]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env
    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"xcb-proto {self.version}"

xcb_proto = xcb_proto()

class inputproto(ConfigurePackage):
    @property
    def version(self) -> str:
        return "2.2"

    @property
    def directory(self) -> str:
        return f"inputproto-{self.version}"

    @property
    def archive(self) -> str:
        return f"inputproto-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [xproto, util_macros]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env
    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"inputproto {self.version}"

inputproto = inputproto()

class kbproto(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.0.6"

    @property
    def directory(self) -> str:
        return f"kbproto-{self.version}"

    @property
    def archive(self) -> str:
        return f"kbproto-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [xproto, util_macros]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env
    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"kbproto {self.version}"

kbproto = kbproto()

class libpthread_stubs(ConfigurePackage):
    @property
    def version(self) -> str:
        return "0.3"

    @property
    def directory(self) -> str:
        return f"libpthread-stubs-{self.version}"

    @property
    def archive(self) -> str:
        return f"libpthread-stubs-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env
    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libpthread-stubs {self.version}"

libpthread_stubs = libpthread_stubs()

class xextproto(ConfigurePackage):
    @property
    def version(self) -> str:
        return "7.2.1"

    @property
    def directory(self) -> str:
        return f"xextproto-{self.version}"

    @property
    def archive(self) -> str:
        return f"xextproto-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env
    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"xextproto-stubs {self.version}"

xextproto = xextproto()




class libxcb(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.8.1"

    @property
    def directory(self) -> str:
        return f"libxcb-{self.version}"

    @property
    def archive(self) -> str:
        return f"libxcb-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [libxau, xcb_proto, libpthread_stubs]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env
    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libxcb {self.version}"

libxcb = libxcb()

class xtrans(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.2.7"

    @property
    def directory(self) -> str:
        return f"xtrans-{self.version}"

    @property
    def archive(self) -> str:
        return f"xtrans-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [xproto]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env
    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"xtrans {self.version}"

xtrans = xtrans()



class libx11(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.5.0"

    @property
    def directory(self) -> str:
        return f"libX11-{self.version}"

    @property
    def archive(self) -> str:
        return f"libX11-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [inputproto, kbproto, libxcb, xextproto, xproto, xtrans]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        xtrans_pkgconfig = os.path.join(xtrans.install_directory(c), "share", 'pkgconfig')
        env["PKG_CONFIG_PATH"] = xtrans_pkgconfig

        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libX11 {self.version}"

libx11 = libx11()

class recordproto(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.14.2"

    @property
    def directory(self) -> str:
        return f"recordproto-{self.version}"

    @property
    def archive(self) -> str:
        return f"recordproto-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        xtrans_pkgconfig = os.path.join(xtrans.install_directory(c), "share", 'pkgconfig')
        env["PKG_CONFIG_PATH"] = xtrans_pkgconfig

        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"recordproto {self.version}"

recordproto = recordproto()


class libxtst(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.2.1"

    @property
    def directory(self) -> str:
        return f"libXtst-{self.version}"

    @property
    def archive(self) -> str:
        return f"libXtst-{self.version}.tar.bz2"

    @property
    def download_url(selfi) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [libx11, libxext, libxi, recordproto, xextproto, inputproto]

#    def build_env_extra(self, c: Config) -> Dict[str, str]:
#        env = super().build_env_extra(c)
#        env.update(zlib.get_env_variables(c))
#        libxi_pkgconfig = os.path.join(linxi.install_directory(c), "share", 'pkgconfig')
#        env["PKG_CONFIG_PATH"] = libxi_pkgconfig

#        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libXtst {self.version}"

libxtst = libxtst()




class libxext(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "1.3.1"

    @property
    def directory(self) -> str:
        return f"libXext-{self.version}"

    @property
    def archive(self) -> str:
        return f"libXext-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [libx11, recordproto, xextproto]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libXext {self.version}"

libxext = libxext()

class libxi(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.6.1"

    @property
    def directory(self) -> str:
        return f"libXi-{self.version}"

    @property
    def archive(self) -> str:
        return f"libXi-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/releases/X11R7.7/src/everything/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [libx11, libxext]

#    def build_env_extra(self, c: Config) -> Dict[str, str]:
#        env = super().build_env_extra(c)
#        env.update(zlib.get_env_variables(c))
#        xtrans_pkgconfig = os.path.join(xtrans.install_directory(c), "share", 'pkgconfig')
#        env["PKG_CONFIG_PATH"] = xtrans_pkgconfig

#        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libXi {self.version}"

libxi = libxi()




class libepoxy(MesonPackage):
    @property
    def version(self) -> str:
        return "1.5.10" #TODO 1.5.1? can need upgrading

    @property
    def directory(self) -> str:
        return f"libepoxy-{self.version}"

    @property
    def archive(self) -> str:
        return f"libepoxy-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://ftp.osuosl.org/pub/blfs/conglomeration/libepoxy/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [util_macros, libx11, libxext, xproto, xextproto, inputproto]

    def meson_args(self, c: Config) -> List[str]:
        return [
            "-Dtests=false", 
            "-Ddocs=false",
           ]


    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libepoxy {self.version}"

libepoxy = libepoxy()

class libogg(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.3.2"

    @property
    def directory(self) -> str:
        return f"libogg-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://downloads.xiph.org/releases/ogg/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"ogg {self.version}"

libogg = libogg()


class libvorbis(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.3.5"

    @property
    def directory(self) -> str:
        return f"libvorbis-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://downloads.xiph.org/releases/vorbis/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [flac]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libvorbis {self.version}"

libvorbis = libvorbis()


class flac(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.3.1"

    @property
    def directory(self) -> str:
        return f"flac-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://downloads.xiph.org/releases/flac/{self.archive}"

    def configure_args(self, c: Config) -> List[str]:
        mingw_args = []
        if c.is_mingw():
            libiconv_install_dir = libiconv.install_directory(c)
            mingw_args = [
                f"--with-libiconv-prefix={libiconv_install_dir}",
           ]

#            libogg_install_dir = libogg.install_directory(c)
#            mingw_args = [
#                f"--includedir={libogg_install_dir}/include/", 
#            ]

        return [
            "--disable-doxygen-docs",
            "--disable-xmms-plugin",
            "--enable-cpplibs",
            "--enable-ogg",
            "--disable-oggtest"
            # Prevent that configure searches for libcrypt.
        ] + mingw_args
    #def configure_args(self, c: Config) -> List[str]:
    #    mingw_args = []
    #    if c.is_mingw():
    #        libiconv_install_dir = libiconv.install_directory(c)
    #        mingw_args = [
    #            f"--with-libiconv-prefix={libiconv_install_dir}",
    #        ]

    #    return ["--disable-threads"] + mingw_args



    def dependencies(self, c: Config) -> List[Package]:
        return [libogg]

#    def get_env_variables(self, c: Config) -> Dict[str, str]:
#        """Return environment variables to make libintl available."""
#        libogg_install = libogg.install_directory(c)
#        print(flac_install)
        # Cannot use LIBRARY_PATH because it is only used if GCC is built
        # as a native compiler, so it doesn't work for mingw.
#        ldflags = "-L" + os.path.join(libogg_install, "lib")
#        if c.is_mingw():
#            ldflags += " " + self.mingw_ldflags


#        return {
#            "CPATH": os.path.join(libogg_install, "include"),
#            "LDFLAGS": ldflags,
#        }

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        libogg_include = "-I" + os.path.join(libogg.install_directory(c), "include")
        libogg_lib = "-L" + os.path.join(libogg.install_directory(c), "lib")
        #libogg_lib.append(os.pathsep)
        #libogg_lib.append(os.environ['LDFLAGS'])
        env["CFLAGS"] = libogg_include #f"{libogg_include}{os.pathsep}{os.environ['CFLAGS']}"
        env["LDFLAGS"] = libogg_lib  #FIXME append
        #env["LDFLAGS"] = f"{libogg_lib}{os.pathsep}{os.environ['LDFLAGS']}"

#        env["PKG_CONFIG"] = libogg_include
        #./mingw/dependencies/build/libogg-1.3.2/ 
        return env
        #libiconv_install_dir = libiconv.install_directory(c)
        #mingw_args = [
        #f"--with-libiconv-prefix={libiconv_install_dir}",
        #]

    def get_env_variables(self, c: Config) -> Dict[str, str]:
        """Return environment variables to make libintl available."""
        flac_install = self.install_directory(c)

        # Cannot use LIBRARY_PATH because it is only used if GCC is built
        # as a native compiler, so it doesn't work for mingw.
        ldflags = "-L" + os.path.join(flac_install, "lib")
        #if c.is_macos():
        #    ldflags += " " + self.macos_ldflags

        return {
            "CPATH": os.path.join(flac_install, "include"),
            "LDFLAGS": ldflags,
        }



#    def build_env_extra(self, c: Config) -> Dict[str, str]:
#        env = super().build_env_extra(c)
#        env.update(zlib.get_env_variables(c))
#        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"flac {self.version}"

flac = flac()

class libsndfile(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.0.28"

    @property
    def directory(self) -> str:
        return f"libsndfile-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"http://www.mega-nerd.com/libsndfile/files/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libsndfile {self.version}"

libsndfile = libsndfile()

class alsa_lib(ConfigurePackage):
    @property
    def version(self) -> str:
        return "1.2.9"

    @property
    def directory(self) -> str:
        return f"alsa-lib-{self.version}"

    @property
    def archive(self) -> str:
        return f"alsa-lib-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://www.alsa-project.org/files/pub/lib/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"alsa-lib {self.version}"

alsa_lib = alsa_lib()



class portaudio(ConfigurePackage):
    @property
    def version(self) -> str:
        return "190700_20210406"

    @property
    def directory(self) -> str:
        return f"portaudio"

    @property
    def archive(self) -> str:
        return f"pa_stable_v{self.version}.tgz"

    @property
    def download_url(self) -> str:
        return f"http://files.portaudio.com/archives/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"portaudio {self.version}"

portaudio = portaudio()

class libsamplerate(ConfigurePackage):
    @property
    def version(self) -> str:
        return "0.1.9"

    @property
    def directory(self) -> str:
        return f"libsamplerate-{self.version}"

    @property
    def archive(self) -> str:
        return f"libsamplerate-{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"http://www.mega-nerd.com/SRC/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libsamplerate {self.version}"

libsamplerate = libsamplerate()

class fftw(ConfigurePackage):
    @property
    def version(self) -> str:
        return "3.3.6-pl1"

    @property
    def directory(self) -> str:
        return f"fftw-{self.version}"

    @property
    def archive(self) -> str:
        return f"fftw-{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"http://www.fftw.org/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"fftw {self.version}"

fftw = fftw()

class portmidi(ConfigurePackage):
    @property
    def version(self) -> str:
        return "217"

    @property
    def directory(self) -> str:
        return f"portmidi"

    @property
    def archive(self) -> str:
        return f"portmidi-src-{self.version}.zip"

    @property
    def download_url(self) -> str:
        return f"https://sourceforge.net/projects/portmedia/files/portmidi/{self.version}/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"portmidi {self.version}"

portmidi = portmidi()

class xz(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "5.2.3"

    @property
    def directory(self) -> str:
        return f"xz-{self.version}"

    @property
    def archive(self) -> str:
        return f"xz-{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://tukaani.org/xz/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"xz {self.version}"

xz = xz()

class libxml2(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "2.9.13"

    @property
    def directory(self) -> str:
        return f"libxml2-{self.version}"

    @property
    def archive(self) -> str:
        return f"libxml2-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://download.gnome.org/sources/libxml2/2.9/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [zlib, xz]

    def configure_args(self, c: Config) -> List[str]:
        return [
            "--without-debug",
            "--without-python",
            "--without-threads"
        ]


    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libxml2 {self.version}"

libxml2 = libxml2()

class libcroco(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "0.6.2"

    @property
    def directory(self) -> str:
        return f"libcroco-{self.version}"

    @property
    def archive(self) -> str:
        return f"libcroco-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://download.gnome.org/sources/libcroco/0.6/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [glib, libxml2]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libcroco {self.version}"

libcroco = libcroco()

class libgsf(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "1.14.30"

    @property
    def directory(self) -> str:
        return f"libgsf-{self.version}"

    @property
    def archive(self) -> str:
        return f"libgsf-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://download.gnome.org/sources/libgsf/1.14/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [glib, libxml2, zlib]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libgsf {self.version}"

libgsf = libgsf()

class librsvg(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "2.40.5"

    @property
    def directory(self) -> str:
        return f"librsvg-{self.version}"

    @property
    def archive(self) -> str:
        return f"librsvg-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://download.gnome.org/sources/librsvg/2.40/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [glib, libxml2, zlib, cairo, pangocairo, gdk_pixbuf, libcroco, libgsf, libepoxy]

    def configure_args(self, c: Config) -> List[str]:
        return [
            "--disable-pixbuf-loader",
            "--disable-gtk-doc",
            "--enable-introspection=no"
        ]


    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"librsvg {self.version}"

librsvg = librsvg()

class rubberband(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "1.8.1"

    @property
    def directory(self) -> str:
        return f"rubberband-{self.version}"

    @property
    def archive(self) -> str:
        return f"rubberband-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f" https://code.breakfastquay.com/attachments/download/34/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [fftw, libsamplerate, libsndfile, vamp_plugin_sdk]

    def configure_args(self, c: Config) -> List[str]:
        return [
            "--disable-pixbuf-loader",
            "--disable-gtk-doc",
            "--enable-introspection=no"
        ]


    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"librsvg {self.version}"

rubberband = rubberband()


class vamp_plugin_sdk(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "2.5"

    @property
    def directory(self) -> str:
        return f"vamp-plugin-sdk-{self.version}"

    @property
    def archive(self) -> str:
        return f"vamp-plugin-sdk-{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://code.soundsoftware.ac.uk/attachments/download/690/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [zlib, libsndfile]

    def configure_args_static(self, c: Config) -> List[str]:
        # Vamp doesn't have --disable-shared nor --enable-static.
        return []


    def configure_args(self, c: Config) -> List[str]:
        return [
            "--disable-programs"
        ]
 
    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"librsvg {self.version}"

vamp_plugin_sdk = vamp_plugin_sdk()


class libgpg_error(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "1.42"

    @property
    def directory(self) -> str:
        return f"libgpg-error-{self.version}"

    @property
    def archive(self) -> str:
        return f"libgpg-error-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://gnupg.org/ftp/gcrypt/libgpg-error/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [gettext]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libgpg-error {self.version}"

libgpg_error = libgpg_error()



class libgcrypt(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "1.8.2"

    @property
    def directory(self) -> str:
        return f"libgcrypt-{self.version}"

    @property
    def archive(self) -> str:
        return f"libgcrypt-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://gnupg.org/ftp/gcrypt/libgcrypt/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [libgpg_error]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libgcrypt {self.version}"

libgcrypt = libgcrypt()







class gtk3(ConfigurePackage):
    @property
    def version(self) -> str:
        return "3.24.32"

    @property
    def directory(self) -> str:
        return f"gtk+-{self.version}"

    @property
    def archive(self) -> str:
        return f"{self.directory}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://download.gnome.org/sources/gtk+/3.24/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [glib, atk, gdk_pixbuf, pangocairo, cairo, jpeg, libpng, gettext, jasper, libepoxy]


    def configure_args_static(self, c: Config) -> List[str]:
        return [
            "--enable-shared",
            "--disable-static",
            "--disable-introspection",
            "--disable-glibtest",
            "--disable-cups",
            "--disable-test-print-backend",
            "--disable-gtk-doc",
            "--disable-man",
            "--disable-modules",
            "--disable-x11-backend",
            "--disable-xinerama",
            "--disable-xinput",
            "--disable-installed-tests",
            "--disable-gtk-doc",
            "--disable-papi",
            "--disable-xkb",
            "--disable-explicit-deps",
            "--disable-debug",
            "--disable-packagekit",
            "--enable-win32-backend",
            "--disable-wayland-backend"
        ]

#    def configure_args_static(self, c: Config) -> List[str]:
#        if c.is_mingw():
#            return ["--enable-shared", "--disable-static"]
#        return super().configure_args_static(c)


    def get_env_variables(self, c: Config) -> Dict[str, str]:
        """Return environment variables to make libintl available."""
        #gtk3_install = self.install_directory(c)

        # Cannot use LIBRARY_PATH because it is only used if GCC is built
        # as a native compiler, so it doesn't work for mingw.
        #ldflags = "-L" + os.path.join(gtk3_install, "lib")
        #if c.is_macos():
        #    ldflags += " " + self.macos_ldflags

        #return {
        #    "CPATH": os.path.join(gtk3_install, "include"),
        #    "LDFLAGS": ldflags,
        #a}
        #env = super().build_env_extra(c)
        #env.update(zlib.get_env_variables(c))
        #libepoxy_libs = "-L" + os.path.join(libepoxy.install_directory(c), "lib") + "-lepoxy -ldl -lX11"
        #libepoxy_cflags = "-I" + os.path.join(libepoxy.install_directory(c), "include")
        #env["GDK_DEP_CFLAGS"] = libepoxy_cflags
        #env["GDK_DEP_LIBS"] = libepoxy_libs
        #-I/media/jbenham/Sandisk/lilypond/release/binaries/dependencies/install/atk-2.36.0/include/atk-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
        #libatk_cflags = "-I" + os.path.join(libepoxy.install_directory(c), "include", "atk-1.0/") + "-I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include"
        #env["ATK_CFLAGS"] = libatk_cflags
        
        #-L/media/jbenham/Sandisk/lilypond/release/binaries/dependencies/install/atk-2.36.0/lib -latk-1.0 -lgobject-2.0 -lglib-2.0
        libatk_libs = "-L" + os.path.join(libepoxy.install_directory(c), "lib") + "-latk-1.0 -lgobject-2.0 -lglib-2.0" 
        env["ATK_LIBS"] = libatk_libs
        
        
        #-L/media/jbenham/Sandisk/lilypond/release/binaries/dependencies/install/libepoxy-1.5.10/lib -lepoxy -ldl -lX11
        #-I/media/jbenham/Sandisk/lilypond/release/binaries/dependencies/install/libepoxy-1.5.10/include
        return env




#    def build_env_extra(self, c: Config) -> Dict[str, str]:
#        env = super().build_env_extra(c)
#        env.update(shared_mime_info.get_env_variables(c))
#        wayland_protocols =  os.path.join(wayland_protocols.install_directory(c), "share", 'pkgconfig')
        #shared_mime_info_pkgconfig = os.path.join(shared_mime_info.install_directory(c), "share", 'pkgconfig')
        #env["PKG_CONFIG_PATH"] = shared_mime_info_pkgconfig
        
#        return env


    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"gtk {self.version}"

gtk3 = gtk3()



class gtksourceview(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "3.24.3"

    @property
    def directory(self) -> str:
        return f"gtksourceview-{self.version}"

    @property
    def archive(self) -> str:
        return f"gtksourceview-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://download.gnome.org/sources/gtksourceview/3.24/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [libgpg_error]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"gtksourceview {self.version}"

gtksourceview = gtksourceview()


class poppler(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "0.51.0"

    @property
    def directory(self) -> str:
        return f"poppler-{self.version}"

    @property
    def archive(self) -> str:
        return f"poppler-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://poppler.freedesktop.org/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [cairo, freetype, glib, jpeg, libpng, zlib]
    #add curl, lcms, tiff? 
    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"poppler {self.version}"

poppler = poppler()

class evince(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "3.24.0"

    @property
    def directory(self) -> str:
        return f"evince-{self.version}"

    @property
    def archive(self) -> str:
        return f"evince-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"http://ftp.gnome.org/pub/GNOME/sources/evince/3.24/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [gtk3, poppler, libxml2]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"evince {self.version}"

evince = evince()

class aubio(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "0.4.2"

    @property
    def directory(self) -> str:
        return f"aubio-{self.version}"

    @property
    def archive(self) -> str:
        return f"aubio-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://aubio.freedesktop.org/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [ffmpeg, fftw, jack, libsamplerate, libsndfile]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"aubio {self.version}"

aubio = aubio()


class jack(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "1.9.16"

    @property
    def directory(self) -> str:
        return f"jack-{self.version}"

    @property
    def archive(self) -> str:
        return f"jack-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://jack.freedesktop.org/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [libsamplerate, libsndfile, portaudio]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"jack {self.version}"

jack = jack()



class ffmpeg(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "3.4.2."

    @property
    def directory(self) -> str:
        return f"ffmpeg-{self.version}"

    @property
    def archive(self) -> str:
        return f"ffmpeg-{self.version}.tar.bz2"

    @property
    def download_url(self) -> str:
        return f"https://ffmpeg.org/releases/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"ffmpeg {self.version}"

ffmpeg = ffmpeg()

class expat(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "2.5.0"

    @property
    def directory(self) -> str:
        return f"expat-{self.version}"

    @property
    def archive(self) -> str:
        return f"expat-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://github.com/libexpat/libexpat/releases/download/R_2_5_0/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return []

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"expat {self.version}"

expat = expat()

class systemd(MesonPackage):
    @property
    def version(self) -> str:
        
        return "244"

    @property
    def directory(self) -> str:
        return f"systemd-{self.version}"

    @property
    def archive(self) -> str:
        return f"v{self.version}.tar.gz"

    @property
    def download_url(self) -> str:
        return f"https://github.com/systemd/systemd/archive/refs/tags/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [expat]

#    def meson_args_static(self, c: Config) -> List[str]:
#        if c.is_mingw():
            # The libraries rely on DllMain which doesn't work with static.
#            return ["--default-library=shared"]
#        return super().meson_args_static(c)

    def meson_args(self, c: Config) -> List[str]:
        return [
            # Disable unused features and tests.
            "-Dblkid=true",
            "-Ddefault-dnssec=no",
            "-Dfirstboot=false",
            "-Dinstall-tests=false",
            "-Dldconfig=false",
            "-Db_lto=false",
            "-Drpmmacrosdir=no"
        ]


    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"systemd {self.version}"

systemd = systemd()



class dbus(ConfigurePackage):
    @property
    def version(self) -> str:
        
        return "1.15.6"

    @property
    def directory(self) -> str:
        return f"dbus-{self.version}"

    @property
    def archive(self) -> str:
        return f"dbus-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://dbus.freedesktop.org/releases/dbus/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [expat]

    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"dbus {self.version}"

dbus = dbus()

class xkeyboard_config(MesonPackage):
    @property
    def version(self) -> str:
        
        return "2.39"

    @property
    def directory(self) -> str:
        return f"xkeyboard-config-{self.version}"

    @property
    def archive(self) -> str:
        return f"xkeyboard-config-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://www.x.org/pub/individual/data/xkeyboard-config/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [libx11]

#    def meson_args_static(self, c: Config) -> List[str]:
#        if c.is_mingw():
            # The libraries rely on DllMain which doesn't work with static.
#            return ["--default-library=shared"]
#        return super().meson_args_static(c)

    def meson_args(self, c: Config) -> List[str]:
        return [
            # Disable unused features and tests.
            "--buildtype=release"
        ]


    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"xkeyboard-config {self.version}"

xkeyboard_config = xkeyboard_config()

class libxkbcommon(MesonPackage):
    @property
    def version(self) -> str:
        
        return "1.5.0"

    @property
    def directory(self) -> str:
        return f"libxkbcommon-{self.version}"

    @property
    def archive(self) -> str:
        return f"libxkbcommon-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://xkbcommon.org/download/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [xkeyboard_config, libxml2]

#    def meson_args_static(self, c: Config) -> List[str]:
#        if c.is_mingw():
            # The libraries rely on DllMain which doesn't work with static.
#            return ["--default-library=shared"]
#        return super().meson_args_static(c)

    def meson_args(self, c: Config) -> List[str]:
        return [
            # Disable unused features and tests.
            "--buildtype=release",
            "-Denable-x11=false",
            "-Denable-wayland=false",
            "-Denable-docs=false"
        ]


    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"libxkbcommon {self.version}"

libxkbcommon = libxkbcommon()



class wayland(MesonPackage):
    @property
    def version(self) -> str:
        
        return "1.22.0"

    @property
    def directory(self) -> str:
        return f"wayland-{self.version}"

    @property
    def archive(self) -> str:
        return f"wayland-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://gitlab.freedesktop.org/wayland/wayland/-/releases/1.22.0/downloads/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [libxml2, libffi]

#    def meson_args_static(self, c: Config) -> List[str]:
#        if c.is_mingw():
            # The libraries rely on DllMain which doesn't work with static.
#            return ["--default-library=shared"]
#        return super().meson_args_static(c)

    def meson_args(self, c: Config) -> List[str]:
        return [
            # Disable unused features and tests.
            "-Ddocumentation=false",
            "--buildtype=release"
        ]


    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"wayland {self.version}"

wayland = wayland()


class wayland_protocols(MesonPackage):
    @property
    def version(self) -> str:
        
        return "1.31"

    @property
    def directory(self) -> str:
        return f"wayland-protocols-{self.version}"

    @property
    def archive(self) -> str:
        return f"wayland-protocols-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://gitlab.freedesktop.org/wayland/wayland-protocols/-/releases/1.31/downloads/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [wayland]

#    def meson_args_static(self, c: Config) -> List[str]:
#        if c.is_mingw():
            # The libraries rely on DllMain which doesn't work with static.
#            return ["--default-library=shared"]
#        return super().meson_args_static(c)

    def meson_args(self, c: Config) -> List[str]:
        return [
            # Disable unused features and tests.
            #"-Ddocumentation=false",
            "--buildtype=release"
        ]


    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"wayland-protocols {self.version}"

wayland_protocols = wayland_protocols()



class gobject_introspection(MesonPackage):
    @property
    def version(self) -> str:
        
        return "2.38.0"

    @property
    def directory(self) -> str:
        return f"at-spi2-atk-{self.version}"

    @property
    def archive(self) -> str:
        return f"at-spi2-atk-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"ftp://ftp.acc.umu.se/pub/gnome/sources/at-spi2-atk/2.38/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [at_spi2_core, atk]

 #   def meson_args(self, c: Config) -> List[str]:
 #       return [
            # Enable FreeType, but disable tests.
 #           "-Dfreetype=enabled",
 #           "-Dtests=disabled",
 #       ]


    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"at-spi2-atk {self.version}"

gobject_introspection = gobject_introspection()


class gobject_introspection(MesonPackage):
    @property
    def version(self) -> str:
        
        return "1.76.1"

    @property
    def directory(self) -> str:
        return f"gobject-introspection-{self.version}"

    @property
    def archive(self) -> str:
        return f"gobject-introspection-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"https://download.gnome.org/sources/gobject-introspection/1.76/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [glib, python]

    def meson_args(self, c: Config) -> List[str]:
        return [
            # Enable FreeType, but disable tests.
            "--buildtype=release",
        ]


    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"gobject-introspection {self.version}"

gobject_introspection = gobject_introspection()



class at_spi2_core(MesonPackage):
    @property
    def version(self) -> str:
        
        return "2.40.0"

    @property
    def directory(self) -> str:
        return f"at-spi2-core-{self.version}"

    @property
    def archive(self) -> str:
        return f"at-spi2-core-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"ftp://ftp.acc.umu.se/pub/gnome/sources/at-spi2-core/2.40/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [glib, libx11, dbus, libxtst]

    def meson_args(self, c: Config) -> List[str]:
        return [
            "--buildtype=release",
            "-Dsystemd_user_dir=/tmp"
        ]


    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"at_spi2_core {self.version}"

at_spi2_core = at_spi2_core()

class at_spi2_atk(MesonPackage):
    @property
    def version(self) -> str:
        
        return "2.38.0"

    @property
    def directory(self) -> str:
        return f"at-spi2-atk-{self.version}"

    @property
    def archive(self) -> str:
        return f"at-spi2-atk-{self.version}.tar.xz"

    @property
    def download_url(self) -> str:
        return f"ftp://ftp.acc.umu.se/pub/gnome/sources/at-spi2-atk/2.38/{self.archive}"

    def dependencies(self, c: Config) -> List[Package]:
        return [at_spi2_core, atk]

 #   def meson_args(self, c: Config) -> List[str]:
 #       return [
            # Enable FreeType, but disable tests.
 #           "-Dfreetype=enabled",
 #           "-Dtests=disabled",
 #       ]


    def build_env_extra(self, c: Config) -> Dict[str, str]:
        env = super().build_env_extra(c)
        env.update(zlib.get_env_variables(c))
        return env

    @property
    def license_files(self) -> List[str]:
        return ["LICENSE"]

    def __str__(self) -> str:
        return f"at-spi2-atk {self.version}"

at_spi2_atk = at_spi2_atk()



all_dependencies: List[Package] = [
#    expat,
#    zlib,
    xz,
    libxml2,
#    libogg,
#    flac,
#    libvorbis,
   # libsndfile,
#     portaudio, #not compiling on linux
#     alsa_lib
     #libsamplerate,
   # fftw,
#   portmidi, #not compiling in linux needs cmake
    freetype,
    fontconfig,
#    ghostscript,
    gettext,
   # libgpg_error,
#    libgcrypt,#not compiling
#
    libffi,
    pcre,
    glib,
    #bdwgc,
    gmp,
    libiconv,
    libtool,
    libunistring,
    #guile,
    harfbuzz,
    fribidi,
    pango,
    libpng,
    pixman,
    lzo,
    cairo,
    python,
    embeddable_python,
    #shared_mime_info,
    gdk_pixbuf,
    atk,
    jpeg,
    #xproto,
    #util_macros,
    #libxau,
    #xcb_proto,
    #inputproto,
    #kbproto,
    #libpthread_stubs,
    #libxcb,
    #xextproto,
    #xtrans,
    #libx11,
    #recordproto,
    #libxext,
    #libxi,
    #libxtst,
    pangocairo,
    libepoxy,
#    libcroco,
#    expat,
#    dbus,
#     libgsf,
#     librsvg, #not compiling on linux
   # vamp_plugin_sdk, #not compiling in linux
   # rubberband,
    #gobject_introspection,
    #systemd,
    #at_spi2_core,
    #at_spi2_atk,
    #wayland,
    #wayland_protocols,
    #xkeyboard_config,
#    libxkbcommon,
    gtk3,
    gtksourceview,
    poppler,
    evince
]

#https://www.linuxfromscratch.org/blfs/view/11.0/x/gtk3.html
