From: Michael R. Crusoe <crusoe@debian.org>
subject: Use pkg-config to find the prebuild rocksdb library
Forwarded: not-needed

--- librocksdb-sys.orig/build.rs
+++ librocksdb-sys/build.rs
@@ -1,3 +1,4 @@
+use pkg_config;
 use std::path::Path;
 use std::{env, fs, path::PathBuf, process::Command};
 
@@ -310,8 +311,23 @@
 }
 
 fn main() {
-    if !Path::new("rocksdb/AUTHORS").exists() {
-        update_submodules();
+    let rocksdb_library = pkg_config::Config::new()
+        .atleast_version("8.1.1")
+        .probe("rocksdb");
+    if rocksdb_library.is_ok() {
+        let lib = rocksdb_library.unwrap();
+        let include_dir_key = "ROCKSDB_INCLUDE_DIR";
+        let include_dir_value = lib.include_paths[0].clone();
+        let lib_dir_key = "ROCKSDB_LIB_DIR";
+        let lib_dir_value = lib.link_paths[0].clone();
+        unsafe {
+            env::set_var(include_dir_key, include_dir_value);
+            env::set_var(lib_dir_key, lib_dir_value);
+        }
+    } else {
+        if !Path::new("rocksdb/AUTHORS").exists() {
+            update_submodules();
+        }
     }
     bindgen_rocksdb();
 
--- librocksdb-sys.orig/Cargo.toml
+++ librocksdb-sys/Cargo.toml
@@ -82,11 +82,10 @@
 
 [build-dependencies.pkg-config]
 version = "0.3"
-optional = true
 
 [features]
 bzip2 = ["bzip2-sys"]
-io-uring = ["pkg-config"]
+io-uring = []
 jemalloc = ["tikv-jemalloc-sys"]
 lz4 = ["lz4-sys"]
 rtti = []
--- librocksdb-sys.orig/Cargo.toml.orig
+++ librocksdb-sys/Cargo.toml.orig
@@ -16,7 +16,7 @@
 default = [ "static" ]
 jemalloc = ["tikv-jemalloc-sys"]
 static = ["libz-sys?/static", "bzip2-sys?/static"]
-io-uring = ["pkg-config"]
+io-uring = []
 snappy = []
 lz4 = ["lz4-sys"]
 zstd = ["zstd-sys"]
@@ -40,4 +40,4 @@
 cc = { version = "1.0", features = ["parallel"] }
 bindgen = { version = "0.69", default-features = false, features = ["runtime"] }
 glob = "0.3"
-pkg-config = { version = "0.3", optional = true }
+pkg-config = { version = "0.3" }
