From 914a1ba213fc35d9bdd5d38455cb6b86c8f1a2f7 Mon Sep 17 00:00:00 2001
From: Toshiki Teramura <toshiki.teramura@gmail.com>
Date: Sun, 21 Aug 2022 22:56:43 +0900
Subject: [PATCH 1/3] Use intel-mkl-tool 0.4.1 in intel-mkl-src

---
 intel-mkl-src/Cargo.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/intel-mkl-src/Cargo.toml b/intel-mkl-src/Cargo.toml
index b15848b1..123e8067 100644
--- a/intel-mkl-src/Cargo.toml
+++ b/intel-mkl-src/Cargo.toml
@@ -32,4 +32,4 @@ mkl-dynamic-ilp64-seq  = []
 [build-dependencies]
 anyhow = "1.0.58"
 ocipkg = "0.2.3"
-intel-mkl-tool = { version = "0.4.0-alpha.0", path = "../intel-mkl-tool", default-features = false }
+intel-mkl-tool = { version = "0.4.1", path = "../intel-mkl-tool", default-features = false }

From 325f0484d32e35b454efc1aa101ce624d704ac94 Mon Sep 17 00:00:00 2001
From: Toshiki Teramura <toshiki.teramura@gmail.com>
Date: Mon, 22 Aug 2022 01:15:00 +0900
Subject: [PATCH 2/3] Remove default feature, use `mkl-static-ilp64-iomp` if no
 features

---
 intel-mkl-src/Cargo.toml |  2 +-
 intel-mkl-src/build.rs   | 42 ++++++++++++++++++++++++++--------------
 intel-mkl-sys/Cargo.toml |  2 +-
 3 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/intel-mkl-src/Cargo.toml b/intel-mkl-src/Cargo.toml
index 123e8067..26b85689 100644
--- a/intel-mkl-src/Cargo.toml
+++ b/intel-mkl-src/Cargo.toml
@@ -16,7 +16,7 @@ build = "build.rs"
 links = "mkl_core"
 
 [features]
-default = ["mkl-static-ilp64-seq"]
+default = []
 
 # MKL config
 # https://software.intel.com/content/www/us/en/develop/articles/intel-math-kernel-library-intel-mkl-and-pkg-config-tool.html
diff --git a/intel-mkl-src/build.rs b/intel-mkl-src/build.rs
index 145bef58..93aff639 100644
--- a/intel-mkl-src/build.rs
+++ b/intel-mkl-src/build.rs
@@ -24,22 +24,34 @@ use anyhow::{bail, Result};
 use intel_mkl_tool::*;
 use std::str::FromStr;
 
-#[cfg(feature = "mkl-static-lp64-iomp")]
-const MKL_CONFIG: &str = "mkl-static-lp64-iomp";
-#[cfg(feature = "mkl-static-lp64-seq")]
-const MKL_CONFIG: &str = "mkl-static-lp64-seq";
-#[cfg(feature = "mkl-static-ilp64-iomp")]
+macro_rules! def_mkl_config {
+    ($cfg:literal) => {
+        #[cfg(feature = $cfg)]
+        const MKL_CONFIG: &str = $cfg;
+    };
+}
+
+def_mkl_config!("mkl-static-lp64-iomp");
+def_mkl_config!("mkl-static-lp64-seq");
+def_mkl_config!("mkl-static-ilp64-iomp");
+def_mkl_config!("mkl-static-ilp64-seq");
+def_mkl_config!("mkl-dynamic-lp64-iomp");
+def_mkl_config!("mkl-dynamic-lp64-seq");
+def_mkl_config!("mkl-dynamic-ilp64-iomp");
+def_mkl_config!("mkl-dynamic-ilp64-seq");
+
+// Default value
+#[cfg(all(
+    not(feature = "mkl-static-lp64-iomp"),
+    not(feature = "mkl-static-lp64-seq"),
+    not(feature = "mkl-static-ilp64-iomp"),
+    not(feature = "mkl-static-ilp64-seq"),
+    not(feature = "mkl-dynamic-lp64-iomp"),
+    not(feature = "mkl-dynamic-lp64-seq"),
+    not(feature = "mkl-dynamic-ilp64-iomp"),
+    not(feature = "mkl-dynamic-ilp64-seq"),
+))]
 const MKL_CONFIG: &str = "mkl-static-ilp64-iomp";
-#[cfg(feature = "mkl-static-ilp64-seq")]
-const MKL_CONFIG: &str = "mkl-static-ilp64-seq";
-#[cfg(feature = "mkl-dynamic-lp64-iomp")]
-const MKL_CONFIG: &str = "mkl-dynamic-lp64-iomp";
-#[cfg(feature = "mkl-dynamic-lp64-seq")]
-const MKL_CONFIG: &str = "mkl-dynamic-lp64-seq";
-#[cfg(feature = "mkl-dynamic-ilp64-iomp")]
-const MKL_CONFIG: &str = "mkl-dynamic-ilp64-iomp";
-#[cfg(feature = "mkl-dynamic-ilp64-seq")]
-const MKL_CONFIG: &str = "mkl-dynamic-ilp64-seq";
 
 fn main() -> Result<()> {
     let cfg = Config::from_str(MKL_CONFIG).unwrap();
diff --git a/intel-mkl-sys/Cargo.toml b/intel-mkl-sys/Cargo.toml
index 750538ed..314691ed 100644
--- a/intel-mkl-sys/Cargo.toml
+++ b/intel-mkl-sys/Cargo.toml
@@ -12,7 +12,7 @@ keywords    = ["ffi"]
 license     = "MIT"
 
 [features]
-default = ["mkl-static-ilp64-seq"]
+default = []
 
 # MKL config
 # https://software.intel.com/content/www/us/en/develop/articles/intel-math-kernel-library-intel-mkl-and-pkg-config-tool.html

From f4ea9ae0644f65f5b5d9ad900f22e50653ca0ff0 Mon Sep 17 00:00:00 2001
From: Toshiki Teramura <toshiki.teramura@gmail.com>
Date: Mon, 22 Aug 2022 18:27:36 +0900
Subject: [PATCH 3/3] Add test with no-feature

---
 .github/workflows/intel-mkl-sys.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/intel-mkl-sys.yml b/.github/workflows/intel-mkl-sys.yml
index 8c3932e5..4e6ecc00 100644
--- a/.github/workflows/intel-mkl-sys.yml
+++ b/.github/workflows/intel-mkl-sys.yml
@@ -15,6 +15,7 @@ jobs:
           - ghcr.io/rust-math/rust-mkl:1.62.1-2020.1
           - rust:1.62.1
         feature:
+          - ""
           - mkl-static-lp64-iomp
           - mkl-static-lp64-seq
           - mkl-static-ilp64-iomp
@@ -49,7 +50,6 @@ jobs:
           command: test
           args: >
             --manifest-path=intel-mkl-sys/Cargo.toml
-            --no-default-features
             --features=${{ matrix.feature }}
 
   windows: