Blob Blame History Raw
From ece8a60f10ae4cdc96af0a795498bb89522f1d07 Mon Sep 17 00:00:00 2001
From: Fabio Valentini <decathorpe@gmail.com>
Date: Wed, 1 Mar 2023 16:57:46 +0100
Subject: [PATCH] Restore pkg-config / dynamic linking support

---
 Cargo.toml.orig |  1 +
 build.rs        | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 0e6918a..4ae5606 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -14,6 +14,7 @@ homepage = "https://github.com/PistonDevelopers/freetype-sys"
 
 [build-dependencies]
 cc = "1"
+pkg-config = "0.3.11"
 
 [dependencies]
 libc = "0.2.42"
diff --git a/build.rs b/build.rs
index e16a9f7..5a5a39a 100644
--- a/build.rs
+++ b/build.rs
@@ -1,3 +1,5 @@
+use std::env;
+
 fn add_sources(build: &mut cc::Build, root: &str, files: &[&str]) {
     let root = std::path::Path::new(root);
     build.files(files.iter().map(|src| {
@@ -10,6 +12,16 @@ fn add_sources(build: &mut cc::Build, root: &str, files: &[&str]) {
 }
 
 fn main() {
+    let target = env::var("TARGET").unwrap();
+    if !target.contains("android")
+        && pkg_config::Config::new()
+            .atleast_version("24.3.18")
+            .find("freetype2")
+            .is_ok()
+    {
+        return;
+    }
+
     let mut build = cc::Build::new();
 
     build