+# This automatically enables optimized builds.
+#
+ifdef ENABLE_PROFILING
+ PROFILE = -pg
+endif
+
+#
+# Suffixes for library compilation rules
+#
+.SUFFIXES: .so
+
+###########################################################################
+# Library Locations:
+# These variables describe various library locations:
+#
+# DEST* = Location of where libraries that are built will be placed.
+# LLVM* = Location of LLVM libraries used for linking.
+# PROJ* = Location of previously built libraries used for linking.
+###########################################################################
+
+# Libraries that are being built
+DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug
+DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release
+DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile
+DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
+
+# LLVM libraries used for linking
+LLVMLIBDEBUGSOURCE := $(LLVM_OBJ_ROOT)/lib/Debug
+LLVMLIBRELEASESOURCE := $(LLVM_OBJ_ROOT)/lib/Release
+LLVMLIBPROFILESOURCE := $(LLVM_OBJ_ROOT)/lib/Profile
+LLVMLIBCURRENTSOURCE := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
+
+# Libraries that were built that will now be used for linking
+PROJLIBDEBUGSOURCE := $(BUILD_OBJ_ROOT)/lib/Debug
+PROJLIBRELEASESOURCE := $(BUILD_OBJ_ROOT)/lib/Release
+PROJLIBPROFILESOURCE := $(BUILD_OBJ_ROOT)/lib/Profile
+PROJLIBCURRENTSOURCE := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
+
+###########################################################################
+# Tool Locations
+# These variables describe various tool locations:
+#
+# DEST* = Location of where tools that are built will be placed.
+# LLVM* = Location of LLVM tools used for building.
+# PROJ* = Location of previously built tools used for linking.
+###########################################################################
+
+DESTTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
+DESTTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
+DESTTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
+DESTTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
+
+LLVMTOOLDEBUG := $(LLVM_OBJ_ROOT)/tools/Debug
+LLVMTOOLRELEASE := $(LLVM_OBJ_ROOT)/tools/Release
+LLVMTOOLPROFILE := $(LLVM_OBJ_ROOT)/tools/Profile
+LLVMTOOLCURRENT := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
+
+PROJTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
+PROJTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
+PROJTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
+PROJTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
+
+#
+# Libtool is found in the current directory.
+#
+ifdef VERBOSE
+LIBTOOL=$(LLVM_SRC_ROOT)/mklib
+else
+LIBTOOL=$(LLVM_SRC_ROOT)/mklib --silent
+endif
+
+#
+# Verbosity levels
+#
+ifndef VERBOSE
+VERB := @
+endif
+
+###########################################################################
+# Miscellaneous paths and commands (part deux):
+# This section defines various configuration macros, such as where
+# to find burg, tblgen, and libtool.
+###########################################################################
+
+#--------------------------------------------------------------------------
+# Special tools used while building the LLVM tree. Burg is built as part
+# of the utils directory.
+#--------------------------------------------------------------------------
+BURG := $(LLVMTOOLCURRENT)/burg
+RunBurg := $(BURG) $(BURG_OPTS)
+
+TBLGEN := $(LLVMTOOLCURRENT)/tblgen
+
+
+###########################################################################
+# Compile Time Flags
+###########################################################################
+
+#
+# Include both the project headers and the LLVM headers for compilation and
+# dependency computation.
+#
+CPPFLAGS += -I$(BUILD_SRC_ROOT)/include -I$(LLVM_SRC_ROOT)/include
+
+# By default, strip symbol information from executable
+ifndef KEEP_SYMBOLS
+STRIP = $(PLATFORMSTRIPOPTS)
+STRIP_WARN_MSG = "(without symbols)"
+endif
+
+# Allow gnu extensions...
+CPPFLAGS += -D_GNU_SOURCE
+
+# -Wno-unused-parameter
+CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
+CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
+
+#
+# Compile commands with libtool.
+#
+Compile := $(LIBTOOL) --mode=compile $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
+CompileC := $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts)
+
+#
+# Add the LLVM specific "-only-static" option so that we only compile .o files
+# once when not building a shared library.
+#
+# For shared libraries, we will end up building twice, but that doesn't happen
+# very often, so we'll let it go.
+#
+ifndef SHARED_LIBRARY
+Compile := $(Compile) -only-static
+CompileC := $(CompileC) -only-static
+endif