aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-12 13:54:09 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-12 14:57:05 +0100
commit15d818928ed8bc953237808f20adc763d915db49 (patch)
treebc9d65ceb1d33078f94436252f003e8a2ea3eca5
parent6a8186e8ded7eab799580711d8d6357459f972cc (diff)
downloadnitrokey-sys-rs-15d818928ed8bc953237808f20adc763d915db49.tar.gz
nitrokey-sys-rs-15d818928ed8bc953237808f20adc763d915db49.tar.bz2
Check the USE_SYSTEM_LIBNITROKEY environment variable
This patch introduces the USE_SYSTEM_LIBNITROKEY environment variable. If it is set when compiling, the nitrokey-sys crate will not try to build libnitrokey from source but instead uses the system libnitrokey version.
-rw-r--r--CHANGELOG.md4
-rw-r--r--README.md5
-rw-r--r--build.rs5
3 files changed, 14 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf03817..cbe0b65 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# Unreleased
+- Link directly against `libnitrokey` if the `USE_SYSTEM_LIBNITROKEY`
+ environment variable is set.
+
# v3.4.2 (2019-01-01)
- Use the -std=c++14 compiler flag.
- Change the build script to link to `-lhidapi` on non-Linux operating systems
diff --git a/README.md b/README.md
index 94cbc1e..343b7b5 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,11 @@ in the library search path:
- `libhidapi-libusb0` (on Linux)
- `libhidapi` (on non-Linux systems)
+If you set the `USE_SYSTEM_LIBNITROKEY` environment variable when building this
+crate, it links directly against `libnitrokey` instead of building it from
+source. In this case, `libnitrokey` must be available in the library search
+path.
+
## Versioning
The major and minor version of the `nitrokey-sys` crate map to the major and
diff --git a/build.rs b/build.rs
index af64a69..defce72 100644
--- a/build.rs
+++ b/build.rs
@@ -54,6 +54,11 @@ fn prepare_version_source(
}
fn main() {
+ if env::var("USE_SYSTEM_LIBNITROKEY").is_ok() {
+ println!("cargo:rustc-link-lib=nitrokey");
+ return;
+ }
+
let out_dir = env::var("OUT_DIR").expect("Environment variable OUT_DIR is not set");
let out_path = path::PathBuf::from(out_dir);