+
+# Figure out which directory to build stuff into. We want to build into the
+# /shared directory by default because it is guaranteed to be local to the
+# current machine.
+#
+ifdef BUILD_ROOT
+BUILD_ROOT_TOP := $(LEVEL)
+else
+
+LOGIN_NAME := $(shell whoami)
+CUR_DIRECTORY := $(shell pwd)
+BUILD_ROOT := /shared/$(LOGIN_NAME)$(patsubst $(HOME)%,%,$(CUR_DIRECTORY))
+
+# Calculate the BUILD_ROOT_TOP variable, which is the top of the llvm/ tree.
+# Note that although this is just equal to $(BUILD_ROOT)/$(LEVEL), we cannot use
+# this expression because some of the directories on the source tree may not
+# exist in the build tree (for example the test/ heirarchy). Thus we evaluate
+# the directory to eliminate the ../'s
+#
+TOP_DIRECTORY := $(shell cd $(LEVEL); pwd)
+BUILD_ROOT_TOP := /shared/$(LOGIN_NAME)$(patsubst $(HOME)%,%,$(TOP_DIRECTORY))
+endif
+