]> git.lizzy.rs Git - rust.git/blob - src/libstd/build.rs
Auto merge of #57088 - euclio:non-camel-case-early-lint, r=estebank
[rust.git] / src / libstd / build.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![deny(warnings)]
12
13 extern crate cc;
14
15 use std::env;
16
17 fn main() {
18     let target = env::var("TARGET").expect("TARGET was not set");
19     if target.contains("linux") {
20         if target.contains("android") {
21             println!("cargo:rustc-link-lib=dl");
22             println!("cargo:rustc-link-lib=log");
23             println!("cargo:rustc-link-lib=gcc");
24         } else if !target.contains("musl") {
25             println!("cargo:rustc-link-lib=dl");
26             println!("cargo:rustc-link-lib=rt");
27             println!("cargo:rustc-link-lib=pthread");
28         }
29     } else if target.contains("freebsd") {
30         println!("cargo:rustc-link-lib=execinfo");
31         println!("cargo:rustc-link-lib=pthread");
32     } else if target.contains("netbsd") {
33         println!("cargo:rustc-link-lib=pthread");
34         println!("cargo:rustc-link-lib=rt");
35     } else if target.contains("dragonfly") || target.contains("bitrig") ||
36               target.contains("openbsd") {
37         println!("cargo:rustc-link-lib=pthread");
38     } else if target.contains("solaris") {
39         println!("cargo:rustc-link-lib=socket");
40         println!("cargo:rustc-link-lib=posix4");
41         println!("cargo:rustc-link-lib=pthread");
42         println!("cargo:rustc-link-lib=resolv");
43     } else if target.contains("apple-darwin") {
44         println!("cargo:rustc-link-lib=System");
45
46         // res_init and friends require -lresolv on macOS/iOS.
47         // See #41582 and http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html
48         println!("cargo:rustc-link-lib=resolv");
49     } else if target.contains("apple-ios") {
50         println!("cargo:rustc-link-lib=System");
51         println!("cargo:rustc-link-lib=objc");
52         println!("cargo:rustc-link-lib=framework=Security");
53         println!("cargo:rustc-link-lib=framework=Foundation");
54         println!("cargo:rustc-link-lib=resolv");
55     } else if target.contains("windows") {
56         println!("cargo:rustc-link-lib=advapi32");
57         println!("cargo:rustc-link-lib=ws2_32");
58         println!("cargo:rustc-link-lib=userenv");
59     } else if target.contains("fuchsia") {
60         println!("cargo:rustc-link-lib=zircon");
61         println!("cargo:rustc-link-lib=fdio");
62     } else if target.contains("cloudabi") {
63         if cfg!(feature = "backtrace") {
64             println!("cargo:rustc-link-lib=unwind");
65         }
66         println!("cargo:rustc-link-lib=c");
67         println!("cargo:rustc-link-lib=compiler_rt");
68     }
69 }