-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
52 lines (46 loc) · 1.54 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#![allow(unused)]
use std::{path::PathBuf, process::Command};
macro_rules! p {
($($tokens: tt)*) => {
println!("cargo:warning={}", format!($($tokens)*))
}
}
#[cfg(not(doc))]
pub fn main() {
let res = Command::new("gfortran")
.arg("-print-file-name=libgfortran.a")
.output()
.unwrap()
.stdout;
if res.is_empty() {
p!("gfortran -print-file-name=libgfortran.a returned an empty string!\n make sure you have gfortran13 installed");
println!("cargo:rustc-link-search=libgfortran.a");
} else {
let path = String::from_utf8(res).unwrap();
let path = PathBuf::from(path);
let path = path.parent().unwrap();
if !path.to_string_lossy().is_empty() {
println!("cargo:rustc-link-search={}", path.display());
}
}
println!("cargo:rustc-link-lib=gfortran");
cc::Build::new()
.files([
"amos/amos_iso_c_fortran_wrapper.f90",
"amos/machine.for",
"amos/zbesh.for",
])
.compiler("gfortran")
// .flag("-std=legacy")
// .flag("-fdefault-real-8") // use 8 bytes for all floats
.flag("-Wno-maybe-uninitialized") // suppress the maybe-unitialized warnings
.flag("-O3") // opitmize level 3
.flag("-Wno-compare-reals")
.flag("-Wno-intrinsic-shadow")
.flag("-Wno-do-subscript")
.flag("-Wno-unused-dummy-argument")
.cpp_link_stdlib(None)
// .flag("-lgfortran")
.static_flag(true)
.compile("amos");
}