diff --git a/doc/Makefile b/doc/Makefile
index 89b79880d12772..3d0773342fc1d4 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -20,7 +20,7 @@ help:
 	@echo "To fix outdated doctests, use 'make <target> doctest=fix'"
 
 
-DOCUMENTER_OPTIONS := linkcheck=$(linkcheck) doctest=$(doctest)
+DOCUMENTER_OPTIONS := linkcheck=$(linkcheck) doctest=$(doctest) buildroot=$(call cygpath_w,$(BUILDROOT))
 
 UnicodeData.txt:
 	$(JLDOWNLOAD) http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt
diff --git a/doc/make.jl b/doc/make.jl
index 6b99bb030fcb0e..f58c7a80b9a257 100644
--- a/doc/make.jl
+++ b/doc/make.jl
@@ -147,8 +147,12 @@ for stdlib in STDLIB_DOCS
 end
 
 const render_pdf = "pdf" in ARGS
+let r = r"buildroot=(.+)", i = findfirst(x -> occursin(r, x), ARGS)
+    global const buildroot = i === nothing ? (@__DIR__) : first(match(r, ARGS[i]).captures)
+end
+
 makedocs(
-    build     = joinpath(@__DIR__, "_build", (render_pdf ? "pdf" : "html"), "en"),
+    build     = joinpath(buildroot, "doc", "_build", (render_pdf ? "pdf" : "html"), "en"),
     modules   = [Base, Core, BuildSysImg, [Base.root_module(Base, stdlib.stdlib) for stdlib in STDLIB_DOCS]...],
     clean     = true,
     doctest   = ("doctest=fix" in ARGS) ? (:fix) : ("doctest=true" in ARGS) ? true : false,
@@ -171,7 +175,7 @@ makedocs(
 if "deploy" in ARGS && Sys.ARCH === :x86_64 && Sys.KERNEL === :Linux
     deploydocs(
         repo = "github.com/JuliaLang/julia.git",
-        target = "_build/html/en",
+        target = joinpath(buildroot, "doc", "_build", "html", "en"),
         dirname = "en",
         devurl = "v1.1-dev",
         versions = ["v#.#", "v1.1-dev" => "v1.1-dev"]