X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Makefile.rules;h=d1b3a551dd13c4f845e434cb5493378187475078;hb=0e3da1def46ae4925d811406f9e67f0c45d5b597;hp=d0d83c038be1308a06fca124ab5b8ae6628db37e;hpb=ecfe67c21799891f27597455ed84c70de7769f36;p=oota-llvm.git diff --git a/Makefile.rules b/Makefile.rules index d0d83c038be..d1b3a551dd1 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -195,6 +195,11 @@ install-bytecode:: install-bytecode-local # VARIABLES: Set up various variables based on configuration data ############################################################################### +# Variable for if this make is for a "cleaning" target +ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),) + IS_CLEANING_TARGET=1 +endif + #-------------------------------------------------------------------- # Variables derived from configuration we are building #-------------------------------------------------------------------- @@ -302,13 +307,31 @@ endif #-------------------------------------------------------------------- # Directory locations #-------------------------------------------------------------------- -ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode) -LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib -ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin -ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples -LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib -LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin -LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples +TargetMode := +ifeq ($(LLVM_CROSS_COMPILING),1) + ifeq ($(BUILD_COMPONENT),1) + TargetMode := Build + else + TargetMode := Host + endif + BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/Build/bin +endif + +ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode) +# It is very important that ObjDir not have an extra trailing +# slash. This ends up changing the rules so that dependency file (.d) +# information is not used at all! +ifeq ($(TargetMode),) + ObjDir := $(ObjRootDir) +else + ObjDir := $(ObjRootDir)/$(TargetMode) +endif +LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/lib +ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/bin +ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/examples +LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/lib +LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/bin +LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/examples CFERuntimeLibDir := $(LLVMGCCDIR)/lib #-------------------------------------------------------------------- @@ -324,7 +347,7 @@ LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT) endif ifndef TBLGEN ifeq ($(LLVM_CROSS_COMPILING),1) - TBLGEN := $(LLVMToolDir)/tblgen$(BUILD_EXEEXT) + TBLGEN := $(BuildLLVMToolDir)/tblgen$(EXEEXT) else TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT) endif @@ -460,7 +483,7 @@ CPP.BaseFlags += -include llvm/System/Solaris.h endif LD.Flags += -L$(LibDir) -L$(LLVMLibDir) -CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS +CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS # All -I flags should go here, so that they don't confuse llvm-config. CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \ $(patsubst %,-I%/include,\ @@ -468,22 +491,33 @@ CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \ $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \ $(CPP.BaseFlags) -Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c + ifeq ($(BUILD_COMPONENT), 1) + Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c + Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c + Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E + Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \ + $(LD.Flags) $(Strip) + Relink = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \ + $(Relink.Flags) +else + Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c + Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c + Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E + Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \ + $(LD.Flags) $(Strip) + Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \ + $(Relink.Flags) +endif + LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C) BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -E -Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX) BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) \ $(CompileCommonOpts) -Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E -Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \ - $(LD.Flags) $(Strip) LTLink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Link) -Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \ - $(Relink.Flags) LTRelink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Relink) LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \ $(Install.Flags) @@ -560,6 +594,16 @@ ifdef DIRS SubDirs += $(DIRS) ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT)) +ifdef BUILD_TARGET_DIRS +$(RecursiveTargets):: + $(Verb) for dir in $(BUILD_TARGET_DIRS); do \ + if [ ! -f $$dir/Makefile ]; then \ + $(MKDIR) $$dir; \ + $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \ + fi; \ + ($(MAKE) -C $$dir $@ BUILD_COMPONENT=1 NO_INSTALL=1 ) || exit 1; \ + done +endif $(RecursiveTargets):: $(Verb) for dir in $(DIRS); do \ if [ ! -f $$dir/Makefile ]; then \ @@ -569,6 +613,12 @@ $(RecursiveTargets):: ($(MAKE) -C $$dir $@ ) || exit 1; \ done else +ifdef BUILD_TARGET_DIRS +$(RecursiveTargets):: + $(Verb) for dir in $(BUILD_TARGET_DIRS); do \ + ($(MAKE) -C $$dir $@ BUILD_COMPONENT=1 NO_INSTALL=1 ) || exit 1; \ + done +endif $(RecursiveTargets):: $(Verb) for dir in $(DIRS); do \ ($(MAKE) -C $$dir $@ ) || exit 1; \ @@ -701,7 +751,7 @@ LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS))) LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs)) endif -ifeq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),) +ifndef IS_CLEANING_TARGET ifdef LINK_COMPONENTS # If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make @@ -1451,8 +1501,8 @@ endif # very conservative approach ensuring that empty variables do not cause # errors or disastrous removal. clean-local:: -ifneq ($(strip $(ObjDir)),) - -$(Verb) $(RM) -rf $(ObjDir) +ifneq ($(strip $(ObjRootDir)),) + -$(Verb) $(RM) -rf $(ObjRootDir) endif -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set @@ -1469,7 +1519,7 @@ clean-all-local:: ifndef DISABLE_AUTO_DEPENDENCIES # If its not one of the cleaning targets -ifneq ($(strip $(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),) +ifndef IS_CLEANING_TARGET # Get the list of dependency files DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))