NAME

Alien::Libgit2 - Find or build libgit2, the linkable Git library

VERSION

version 0.002

SYNOPSIS

use Alien::Libgit2;

# For XS consumers
my $cflags = Alien::Libgit2->cflags;
my $libs   = Alien::Libgit2->libs;

# For FFI consumers (FFI::Platypus, Git::Libgit2)
my @libs = Alien::Libgit2->dynamic_libs;

DESCRIPTION

Alien::Libgit2 provides the C library libgit2 for use by other CPAN modules that need to link against it.

It first checks whether a system libgit2 (>= 1.9.3) is available via pkg-config. If not, it builds libgit2 from a bundled source tarball using CMake. No network access is required during install.

The 1.9.3 floor is a bug fix, not an API requirement: below it, libgit2's ssh transport loops forever on LIBSSH2_ERROR_TIMEOUT, so a peer that accepts the connection and then goes silent parks the caller indefinitely. A system lib below the fix falls through to the bundled share build.

INSTALLATION

cpanm Alien::Libgit2

If pkg-config reports a system libgit2 of 1.9.3 or newer, that one is used. Otherwise the module builds from the bundled libgit2-1.9.3 tarball using CMake. No network access is needed either way, so the install works on air-gapped hosts.

Build dependencies (share install)

  • cmake

  • a C compiler

  • pkg-config

  • OpenSSL headers (HTTPS backend)

  • libssh2 headers (SSH transport)

Forcing an install path

Set ALIEN_INSTALL_TYPE before installing to skip the probe decision: system uses only a system libgit2 and fails if none meets the floor, share always builds the bundled tarball.

ALIEN_INSTALL_TYPE=share cpanm Alien::Libgit2

USED BY

SEE ALSO

Git::Libgit2, Git::Native, Alien::Build, Alien::Base

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-alien-libgit2/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.