borgbackup/setup_crypto.py
Thomas Waldmann 5173b9f407 add pkg-config support, fixes #1925
1. BORG_*_PREFIX is checked (avoids lib detection via pkg-config).
2. pkg-config is tried
3. fallback to bundled C code (or failure in case of OpenSSL)

also:
- simplified code again
- removed (c) headers, nothing left of original code
2019-03-13 18:26:47 +01:00

20 lines
691 B
Python

# Support code for building a C extension with crypto from OpenSSL / LibreSSL
import os
def crypto_ext_kwargs():
system_prefix = os.environ.get('BORG_OPENSSL_PREFIX')
if system_prefix:
print('Detected OpenSSL [via BORG_OPENSSL_PREFIX]')
return dict(include_dirs=[os.path.join(system_prefix, 'include')],
library_dirs=[os.path.join(system_prefix, 'lib')],
libraries=['crypto'])
import pkgconfig
if pkgconfig.exists('libcrypto'):
print('Detected OpenSSL [via pkg-config]')
return pkgconfig.parse('libcrypto')
raise Exception('Could not find OpenSSL lib/headers, please set BORG_OPENSSL_PREFIX')