about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAhmed Charles <acharles@outlook.com>2016-10-05 22:42:19 -0700
committerAhmed Charles <acharles@outlook.com>2016-10-05 22:42:40 -0700
commitfa230825c1da8605d51a2ef8d6b672b60baeb692 (patch)
tree695021331fd2b5bbe35ff05503a3f911554762a8 /src
parenta580f8f80d0563dc849529cb5908c4c618f272df (diff)
downloadrust-fa230825c1da8605d51a2ef8d6b672b60baeb692.tar.gz
rust-fa230825c1da8605d51a2ef8d6b672b60baeb692.zip
Add support for docdir, libdir and mandir.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/config.rs12
-rw-r--r--src/bootstrap/install.rs23
2 files changed, 30 insertions, 5 deletions
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index a8434c3efb3..e441d8d5ca7 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -79,6 +79,9 @@ pub struct Config {
     // Fallback musl-root for all targets
     pub musl_root: Option<PathBuf>,
     pub prefix: Option<String>,
+    pub docdir: Option<String>,
+    pub libdir: Option<String>,
+    pub mandir: Option<String>,
     pub codegen_tests: bool,
     pub nodejs: Option<PathBuf>,
 }
@@ -357,6 +360,15 @@ impl Config {
                 "CFG_PREFIX" => {
                     self.prefix = Some(value.to_string());
                 }
+                "CFG_DOCDIR" => {
+                    self.docdir = Some(value.to_string());
+                }
+                "CFG_LIBDIR" => {
+                    self.libdir = Some(value.to_string());
+                }
+                "CFG_MANDIR" => {
+                    self.mandir = Some(value.to_string());
+                }
                 "CFG_LLVM_ROOT" if value.len() > 0 => {
                     let target = self.target_config.entry(self.build.clone())
                                      .or_insert(Target::default());
diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
index 1c714620a01..9bc5a7c00ab 100644
--- a/src/bootstrap/install.rs
+++ b/src/bootstrap/install.rs
@@ -14,6 +14,7 @@
 //! compiler, and documentation.
 
 use std::fs;
+use std::borrow::Cow;
 use std::path::Path;
 use std::process::Command;
 
@@ -24,25 +25,37 @@ use dist::{package_vers, sanitize_sh, tmpdir};
 pub fn install(build: &Build, stage: u32, host: &str) {
     let prefix = build.config.prefix.as_ref().clone().map(|x| Path::new(x))
         .unwrap_or(Path::new("/usr/local"));
+    let docdir = build.config.docdir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x)))
+        .unwrap_or(Cow::Owned(prefix.join("share/doc/rust")));
+    let libdir = build.config.libdir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x)))
+        .unwrap_or(Cow::Owned(prefix.join("lib")));
+    let mandir = build.config.mandir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x)))
+        .unwrap_or(Cow::Owned(prefix.join("share/man")));
     let empty_dir = build.out.join("tmp/empty_dir");
     t!(fs::create_dir_all(&empty_dir));
     if build.config.docs {
-        install_sh(&build, "docs", "rust-docs", stage, host, prefix, &empty_dir);
+        install_sh(&build, "docs", "rust-docs", stage, host, prefix,
+                   &docdir, &libdir, &mandir, &empty_dir);
     }
-    install_sh(&build, "std", "rust-std", stage, host, prefix, &empty_dir);
-    install_sh(&build, "rustc", "rustc", stage, host, prefix, &empty_dir);
+    install_sh(&build, "std", "rust-std", stage, host, prefix,
+               &docdir, &libdir, &mandir, &empty_dir);
+    install_sh(&build, "rustc", "rustc", stage, host, prefix,
+               &docdir, &libdir, &mandir, &empty_dir);
     t!(fs::remove_dir_all(&empty_dir));
 }
 
 fn install_sh(build: &Build, package: &str, name: &str, stage: u32, host: &str,
-              prefix: &Path, empty_dir: &Path) {
+              prefix: &Path, docdir: &Path, libdir: &Path, mandir: &Path, empty_dir: &Path) {
     println!("Install {} stage{} ({})", package, stage, host);
     let package_name = format!("{}-{}-{}", name, package_vers(build), host);
 
     let mut cmd = Command::new("sh");
     cmd.current_dir(empty_dir)
        .arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh")))
-       .arg(format!("--prefix={}", sanitize_sh(&prefix)))
+       .arg(format!("--prefix={}", sanitize_sh(prefix)))
+       .arg(format!("--docdir={}", sanitize_sh(docdir)))
+       .arg(format!("--libdir={}", sanitize_sh(libdir)))
+       .arg(format!("--mandir={}", sanitize_sh(mandir)))
        .arg("--disable-ldconfig");
     build.run(&mut cmd);
 }