Added a hack that takes the path relative to the home directory into account
[oota-llvm.git] / Makefile.common
index c13ca250b0e6e896377c2f088aff075bbd1c2bf6..8d4913d95a23e6b7341030a7e39247f4b0a5badd 100644 (file)
 #    LEVEL should be set to the top of LLVM source tree
 #    LLVM_LIB_DIR should be set to the top of the LLVM build tree
 #
-#    
 #===-----------------------------------------------------------------------====
 
 # Configuration file to set paths specific to local installation of LLVM
 # 
 include $(LEVEL)/Makefile.config
 
-# Figure out how to do platform specific stuff on this platform.  This is really
-# gross and should be autoconfiscated (automake actually), but should hopefully
-# work on Linux and solaris (SunOS).
+###########################################################################
+# Directory Configuration
+#      This section of the Makefile determines what is where.  To be
+#      specific, there are several locations that need to be defined:
 #
-UNAME := $(shell uname)
-include $(LEVEL)/Makefile.$(UNAME)
+#      o LLVM_SRC_ROOT  : The root directory of the LLVM source code.
+#      o LLVM_OBJ_ROOT  : The root directory containing the built LLVM code.
+#
+#      o BUILD_SRC_DIR  : The directory containing the code to build.
+#      o BUILD_SRC_ROOT : The root directory of the code to build.
+#
+#      o BUILD_OBJ_DIR  : The directory in which compiled code will be placed.
+#      o BUILD_OBJ_ROOT : The root directory in which compiled code is placed.
+#
+###########################################################################
 
-ifdef SHARED_LIBRARY
-# if SHARED_LIBRARY is specified, the default is to build the dynamic lib
-dynamic ::
+#
+# Set the source build directory.  That is almost always the current directory.
+#
+ifndef BUILD_SRC_DIR
+BUILD_SRC_DIR = $(shell pwd)
 endif
 
-# Default Rule:  Make sure it's also a :: rule
-all ::
-
-# Default for install is to at least build everything...
-install ::
-
-
-# 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.
 #
+# Set the source root directory.
+#
+ifndef BUILD_SRC_ROOT
+BUILD_SRC_ROOT = $(shell cd $(BUILD_SRC_DIR)/$(LEVEL); pwd)
+endif
 
-ifeq ($(LLVM_OBJ_DIR),.)
-BUILD_ROOT     = $(LLVM_OBJ_DIR)
+#
+# Now for a hack:
+#      If we have a home directory, append our offset from it to OBJ_ROOT.
+#      This will "emulate" the previous behavior while not breaking builds
+#      in which there is no home directory.
+#
+ifdef HOME
+OBJ_ROOT := $(OBJ_ROOT)$(patsubst $(HOME)%,%,$(BUILD_SRC_ROOT))
+else
+OBJ_ROOT := $(OBJ_ROOT)/$(shell basename $(BUILD_SRC_ROOT))
+endif
 
-ifdef PROJ_COMPILE
-BUILD_ROOT_TOP = $(PROJLEVEL)
+#
+# Set the object build directory.  Its location depends upon the source path
+# and where object files should go.
+#
+ifndef BUILD_OBJ_DIR
+ifeq ($(OBJ_ROOT),.)
+BUILD_OBJ_DIR = $(shell pwd)
 else
-BUILD_ROOT_TOP = $(LEVEL)
-endif 
+BUILD_OBJ_DIR := $(OBJ_ROOT)$(patsubst $(BUILD_SRC_ROOT)%,%,$(shell cd $(BUILD_SRC_DIR); pwd))
+endif
+endif
 
+#
+# Set the root of the object directory.
+#
+ifndef BUILD_OBJ_ROOT
+ifeq ($(OBJ_ROOT),.)
+BUILD_OBJ_ROOT = $(shell cd $(LEVEL); pwd)
 else
+BUILD_OBJ_ROOT := $(OBJ_ROOT)$(patsubst $(BUILD_SRC_ROOT)%,%,$(shell cd $(BUILD_SRC_ROOT); pwd))
+endif
+endif
 
-BUILD_ROOT := $(LLVM_OBJ_DIR)$(patsubst $(HOME)%,%,$(shell pwd))
+#
+# Set the LLVM source directory.
+# It is typically the root directory of what we're compiling now.
+#
+ifndef LLVM_SRC_ROOT
+LLVM_SRC_ROOT = $(BUILD_SRC_ROOT)
+endif
 
-# 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
 #
-ifdef PROJ_COMPILE
-TOP_DIRECTORY := $(shell cd $(PROJLEVEL); pwd)
-else 
-TOP_DIRECTORY := $(shell cd $(LEVEL); pwd)
+# Set the LLVM object directory.
+#
+ifndef LLVM_OBJ_ROOT
+LLVM_OBJ_ROOT = $(BUILD_OBJ_ROOT)
 endif
 
-BUILD_ROOT_TOP := $(LLVM_OBJ_DIR)$(patsubst $(HOME)%,%,$(TOP_DIRECTORY))
+# Figure out how to do platform specific stuff on this platform.  This is really
+# gross and should be autoconfiscated (automake actually), but should hopefully
+# work on Linux and solaris (SunOS).
+#
+UNAME := $(shell uname)
+include $(LLVM_SRC_ROOT)/Makefile.$(UNAME)
+
+ifdef SHARED_LIBRARY
+# if SHARED_LIBRARY is specified, the default is to build the dynamic lib
+dynamic ::
 endif
 
+# Default Rule:  Make sure it's also a :: rule
+all ::
+
+# Default for install is to at least build everything...
+install ::
 
+# Default rule for test.  It ensures everything has a test rule
+test::
 
+prdirs::
+       echo "LLVM Source Root       : $(LLVM_SRC_ROOT)"; \
+       echo "LLVM Object Root       : $(LLVM_OBJ_ROOT)"; \
+       echo "Build Source Root      : $(BUILD_SRC_ROOT)"; \
+       echo "Build Source Directory : $(BUILD_SRC_DIR)"; \
+       echo "Build Object Root      : $(BUILD_OBJ_ROOT)"; \
+       echo "Build Object Directory : $(BUILD_OBJ_DIR)";
 
 #--------------------------------------------------------------------
 # Variables derived from configuration options... 
@@ -110,7 +163,7 @@ endif
 
 BURG_OPTS = -I
 
-PURIFY := $(PURIFY) -cache-dir="$(BUILD_ROOT_TOP)/../purifycache" -chain-length="30" -messages=all 
+PURIFY := $(PURIFY) -cache-dir="$(BUILD_OBJ_ROOT)/../purifycache" -chain-length="30" -messages=all 
 
 ifdef ENABLE_PROFILING
   ENABLE_OPTIMIZED = 1
@@ -123,38 +176,56 @@ else
   endif
 endif
 
-# Shorthand for commonly accessed directories
-# DESTLIBXYZ indicates destination for the libraries built
-DESTLIBDEBUG    := $(BUILD_ROOT_TOP)/lib/Debug
-DESTLIBRELEASE  := $(BUILD_ROOT_TOP)/lib/Release
-DESTLIBPROFILE  := $(BUILD_ROOT_TOP)/lib/Profile
-DESTLIBCURRENT  := $(BUILD_ROOT_TOP)/lib/$(CONFIGURATION)
-
-ifdef PROJ_COMPILE
-#get the llvm libraries from LLVM_LIB_DIR
-LLVMLIBDEBUGSOURCE    := $(LLVM_LIB_DIR)/lib/Debug
-LLVMLIBRELEASESOURCE  := $(LLVM_LIB_DIR)/lib/Release
-LLVMLIBPROFILESOURCE  := $(LLVM_LIB_DIR)/lib/Profile
-LLVMLIBCURRENTSOURCE  := $(LLVM_LIB_DIR)/lib/$(CONFIGURATION)
-
-PROJLIBDEBUGSOURCE    := $(BUILD_ROOT_TOP)/lib/Debug
-PROJLIBRELEASESOURCE  := $(BUILD_ROOT_TOP)/lib/Release
-PROJLIBPROFILESOURCE  := $(BUILD_ROOT_TOP)/lib/Profile
-PROJLIBCURRENTSOURCE  := $(BUILD_ROOT_TOP)/lib/$(CONFIGURATION)
-
-else 
-#when we are building llvm, destination is same as source
-LLVMLIBDEBUGSOURCE    := $(BUILD_ROOT_TOP)/lib/Debug
-LLVMLIBRELEASESOURCE  := $(BUILD_ROOT_TOP)/lib/Release
-LLVMLIBPROFILESOURCE  := $(BUILD_ROOT_TOP)/lib/Profile
-LLVMLIBCURRENTSOURCE  := $(BUILD_ROOT_TOP)/lib/$(CONFIGURATION)
-endif
-
-
-TOOLDEBUG   := $(BUILD_ROOT_TOP)/tools/Debug
-TOOLRELEASE := $(BUILD_ROOT_TOP)/tools/Release
-TOOLPROFILE := $(BUILD_ROOT_TOP)/tools/Profile
-TOOLCURRENT := $(BUILD_ROOT_TOP)/tools/$(CONFIGURATION)
+###########################################################################
+# 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)
 
 # Verbosity levels
 ifndef VERBOSE
@@ -165,13 +236,14 @@ endif
 # Compilation options...
 #---------------------------------------------------------
 
+###########################################################################
 # Special tools used while building the LLVM tree.  Burg is built as part of the
 # utils directory.
-#
-BURG    := $(TOOLCURRENT)/burg
+###########################################################################
+BURG    := $(LLVMTOOLCURRENT)/burg
 RunBurg := $(BURG) $(BURG_OPTS)
 
-TBLGEN  := $(TOOLCURRENT)/tblgen
+TBLGEN  := $(LLVMTOOLCURRENT)/tblgen
 
 # Enable this for profiling support with 'gprof'
 # This automatically enables optimized builds.
@@ -179,12 +251,14 @@ ifdef ENABLE_PROFILING
   PROFILE = -pg
 endif
 
-#if PROJDIR is defined then we include project include directory
-ifndef PROJ_COMPILE
-PROJ_INCLUDE = .
-else
-PROJ_INCLUDE = $(TOP_DIRECTORY)/include
-endif 
+###########################################################################
+# Compile Time Flags
+###########################################################################
+
+#
+# Include both the project headers and the LLVM headers for compilation
+#
+CPPFLAGS += -I$(BUILD_SRC_ROOT)/include -I$(LLVM_SRC_ROOT)/include
 
 # By default, strip symbol information from executable
 ifndef KEEP_SYMBOLS
@@ -196,7 +270,7 @@ endif
 CPPFLAGS += -D_GNU_SOURCE
 
 # -Wno-unused-parameter
-CompileCommonOpts := -Wall -W  -Wwrite-strings -Wno-unused -I$(LEVEL)/include -I$(PROJ_INCLUDE)
+CompileCommonOpts := -Wall -W  -Wwrite-strings -Wno-unused -I$(LEVEL)/include
 CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
 
 # Compile a cpp file, don't link...
@@ -234,7 +308,7 @@ endif
 
 
 # Create one .o file from a bunch of .o files...
-Relink = ld -r
+Relink = ${LD} -r
 
 # MakeSO - Create a .so file from a .o files...
 MakeSO   := $(CXX) $(MakeSharedObjectOption)
@@ -242,11 +316,11 @@ MakeSOO  := $(MakeSO) -O3
 MakeSOP  := $(MakeSOO) $(PROFILE)
 
 # Create dependancy file from CPP file, send to stdout.
-Depend   := $(CXX) -MM -I$(LEVEL)/include -I$(PROJ_INCLUDE) $(CPPFLAGS) 
-DependC  := $(CC)  -MM -I$(LEVEL)/include -I$(PROJ_INCLUDE) $(CPPFLAGS) 
+Depend   := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS) 
+DependC  := $(CC)  -MM -I$(LEVEL)/include $(CPPFLAGS) 
 
 # Archive a bunch of .o files into a .a file...
-AR       = ar cq 
+AR       = ${AR_PATH} cq 
 
 #----------------------------------------------------------
 
@@ -259,9 +333,9 @@ Source  := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l)
 endif
 
 Objs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(notdir $(basename $(Source))))))
-ObjectsO := $(addprefix $(BUILD_ROOT)/Release/,$(Objs))
-ObjectsP := $(addprefix $(BUILD_ROOT)/Profile/,$(Objs))
-ObjectsG := $(addprefix $(BUILD_ROOT)/Debug/,$(Objs))
+ObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(Objs))
+ObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(Objs))
+ObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(Objs))
 
 
 #---------------------------------------------------------
@@ -394,14 +468,12 @@ endif
 ifdef TOOLNAME
 
 # TOOLEXENAME* - These compute the output filenames to generate...
-TOOLEXENAME_G := $(BUILD_ROOT_TOP)/tools/Debug/$(TOOLNAME)
-TOOLEXENAME_O := $(BUILD_ROOT_TOP)/tools/Release/$(TOOLNAME)
-TOOLEXENAME_P := $(BUILD_ROOT_TOP)/tools/Profile/$(TOOLNAME)
-TOOLEXENAMES  := $(BUILD_ROOT_TOP)/tools/$(CONFIGURATION)/$(TOOLNAME)
+TOOLEXENAME_G := $(DESTTOOLDEBUG)/$(TOOLNAME)
+TOOLEXENAME_O := $(DESTTOOLRELEASE)/$(TOOLNAME)
+TOOLEXENAME_P := $(DESTTOOLPROFILE)/$(TOOLNAME)
+TOOLEXENAMES  := $(DESTTOOLCURRENT)/$(TOOLNAME)
 
 # USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc.
-ifdef PROJ_COMPILE
-
 PROJ_LIBS_OPTIONS   := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
 PROJ_LIBS_OPTIONS_G := $(patsubst %.o, $(PROJLIBDEBUGSOURCE)/%.o,  $(PROJ_LIBS_OPTIONS))
 PROJ_LIBS_OPTIONS_O := $(patsubst %.o, $(PROJLIBRELEASESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
@@ -413,26 +485,9 @@ LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_O
 LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
 
 LIB_OPTS_G :=  $(LLVM_LIBS_OPTIONS_G) $(PROJ_LIBS_OPTIONS_G)
-LIB_OPTS_O :=  $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_P)
+LIB_OPTS_O :=  $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_O)
 LIB_OPTS_P :=  $(LLVM_LIBS_OPTIONS_P) $(PROJ_LIBS_OPTIONS_P)
 
-else
-
-LLVM_LIBS_OPTIONS   := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
-LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o,  $(LLVM_LIBS_OPTIONS))
-LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
-LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
-
-LIB_OPTS_G :=  $(LLVM_LIBS_OPTIONS_G) 
-LIB_OPTS_O :=  $(LLVM_LIBS_OPTIONS_O) 
-LIB_OPTS_P :=  $(LLVM_LIBS_OPTIONS_P)
-endif
-
-
-
-
-
-
 # USED_LIB_PATHS - Compute the path of the libraries used so that tools are
 # rebuilt if libraries change.  This has to make sure to handle .a/.so and .o
 # files seperately.
@@ -457,15 +512,15 @@ all::   $(TOOLEXENAMES)
 clean::
        $(VERB) rm -f $(TOOLEXENAMES)
 
-$(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(TOOLDEBUG)/.dir
+$(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(DESTTOOLDEBUG)/.dir
        @echo ======= Linking $(TOOLNAME) debug executable $(STRIP_WARN_MSG)=======
        $(VERB) $(LinkG) -o $@ $(ObjectsG) $(LIB_OPTS_G) $(LINK_OPTS)
 
-$(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(TOOLRELEASE)/.dir
+$(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(DESTTOOLRELEASE)/.dir
        @echo ======= Linking $(TOOLNAME) release executable =======
        $(VERB) $(LinkO) -o $@ $(ObjectsO) $(LIB_OPTS_O) $(LINK_OPTS)
 
-$(TOOLEXENAME_P): $(ObjectsP) $(USED_LIB_PATHS_P) $(TOOLPROFILE)/.dir
+$(TOOLEXENAME_P): $(ObjectsP) $(USED_LIB_PATHS_P) $(DESTTOOLPROFILE)/.dir
        @echo ======= Linking $(TOOLNAME) profile executable =======
        $(VERB) $(LinkP) -o $@ $(ObjectsP) $(LIB_OPTS_P) $(LINK_OPTS)
 
@@ -474,30 +529,30 @@ endif
 
 
 #---------------------------------------------------------
-.PRECIOUS: $(BUILD_ROOT)/Depend/.dir
-.PRECIOUS: $(BUILD_ROOT)/Debug/.dir $(BUILD_ROOT)/Release/.dir
+.PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir
+.PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir
 
 # Create .o files in the ObjectFiles directory from the .cpp and .c files...
-$(BUILD_ROOT)/Release/%.o: $(SourceDir)%.cpp $(BUILD_ROOT)/Release/.dir
+$(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir
        @echo "Compiling $<"
        $(VERB) $(CompileO) $< -o $@
 
-$(BUILD_ROOT)/Release/%.o: $(SourceDir)%.c $(BUILD_ROOT)/Release/.dir
+$(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir
        $(VERB) $(CompileCO) $< -o $@
 
-$(BUILD_ROOT)/Profile/%.o: $(SourceDir)%.cpp $(BUILD_ROOT)/Profile/.dir
+$(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir
        @echo "Compiling $<"
        $(VERB) $(CompileP) $< -o $@
 
-$(BUILD_ROOT)/Profile/%.o: $(SourceDir)%.c $(BUILD_ROOT)/Profile/.dir
+$(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir
        @echo "Compiling $<"
        $(VERB) $(CompileCP) $< -o $@
 
-$(BUILD_ROOT)/Debug/%.o: $(SourceDir)%.cpp $(BUILD_ROOT)/Debug/.dir
+$(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir
        @echo "Compiling $<"
        $(VERB) $(CompileG) $< -o $@
 
-$(BUILD_ROOT)/Debug/%.o: $(SourceDir)%.c $(BUILD_ROOT)/Debug/.dir 
+$(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir 
        $(VERB) $(CompileCG) $< -o $@
 
 #
@@ -543,7 +598,7 @@ YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
 
 # 'make clean' nukes the tree
 clean::
-       $(VERB) rm -rf $(BUILD_ROOT)/Debug $(BUILD_ROOT)/Release $(BUILD_ROOT)/Profile $(BUILD_ROOT)/Depend
+       $(VERB) rm -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
        $(VERB) rm -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
        $(VERB) rm -f $(LEX_OUTPUT) $(YACC_OUTPUT)
 
@@ -551,16 +606,16 @@ clean::
 # include the dependancies now...
 #
 SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source))))
-SourceDepend := $(SourceBaseNames:%=$(BUILD_ROOT)/Depend/%.d)
+SourceDepend := $(SourceBaseNames:%=$(BUILD_OBJ_DIR)/Depend/%.d)
 
 # Create dependencies for the *.cpp files...
 #$(SourceDepend): \x
-$(BUILD_ROOT)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_ROOT)/Depend/.dir
-       $(VERB) $(Depend) $< | sed 's|$*\.o *|$(BUILD_ROOT)/Release/& $(BUILD_ROOT)/Profile/& $(BUILD_ROOT)/Debug/& $(BUILD_ROOT)/Depend/$(@F)|g' > $@
+$(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Depend/.dir
+       $(VERB) $(Depend) $< | sed 's|$*\.o *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
 
 # Create dependencies for the *.c files...
 #$(SourceDepend): \x
-$(BUILD_ROOT)/Depend/%.d: $(SourceDir)%.c $(BUILD_ROOT)/Depend/.dir
+$(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir
        $(VERB) $(DependC) $< | sed 's|$*\.o *|Release/& Profile/& Debug/& Depend/$(@F)|g' > $@
 
 ifneq ($(SourceDepend),)