from conan import ConanFile
from conan.tools.files import export_conandata_patches, apply_conandata_patches, get
from conan.tools.gnu import AutotoolsToolchain, Autotools
from conan.tools.layout import basic_layout

class tkrzwRecipe(ConanFile):
    name = "tkrzw"
    package_type = "library"
    user = "aurora"

    # Optional metadata
    license = "Apache License 2.0"
    author = "Vladislav Larionov <vladislav.larionov@fruct.org>"
    url = "https://gitverse.ru/auroraos/mirror_tkrzw"
    description = "A set of implementations of DBM"
    topics = ("DBM")

    # Binary configuration
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True]}

    def source(self):
        get(self, **self.conan_data["sources"][self.version], strip_root=True)

    def export_sources(self):
        export_conandata_patches(self)

    def layout(self):
        basic_layout(self)

    def generate(self):
        at_toolchain = AutotoolsToolchain(self)
        at_toolchain.generate()

    def build(self):
        apply_conandata_patches(self)
        autotools = Autotools(self)
        autotools.autoreconf()
        autotools.configure()
        autotools.make()

    def package(self):
        autotools = Autotools(self)
        autotools.install()

    def package_info(self):
        self.cpp_info.libs = ["tkrzw"]
