--- a/build.rs
+++ b/build.rs
@@ -17,34 +17,9 @@
 
 //! Build script for jpegxl-sys.
 
-fn main() {
-    #[cfg(all(not(feature = "vendored"), not(feature = "docs")))]
-    {
-        use std::env;
-        let version = env!("CARGO_PKG_VERSION")
-            .split('+')
-            .nth(1)
-            .and_then(|s| s.split('-').nth(1))
-            .unwrap();
+extern crate pkg_config;
 
-        if let Ok(path) = env::var("DEP_JXL_LIB") {
-            println!("cargo:rustc-link-search=native={path}");
-            println!("cargo:rustc-link-lib=jxl");
-            println!("cargo:rustc-link-lib=jxl_threads");
-        } else {
-            pkg_config::Config::new()
-                .atleast_version(version)
-                .probe("libjxl")
-                .unwrap_or_else(|_| panic!("Cannot find `libjxl` with version >= {version}"));
-            pkg_config::Config::new()
-                .atleast_version(version)
-                .probe("libjxl_threads")
-                .unwrap_or_else(|_| {
-                    panic!("Cannot find `libjxl_threads` with version >= {version}")
-                });
-        }
-    }
+fn main() {
 
-    #[cfg(feature = "vendored")]
-    jpegxl_src::build();
+  pkg_config::probe_library("libjxl").unwrap();
 }
