Subtarget feature can now set any variable to any value
[oota-llvm.git] / Makefile.rules
index 8a0ff5bb0a7f72ef5bd55b7555773d58b093bbfa..39c741a8838c196a294dbe5529bf000c352fe815 100644 (file)
@@ -108,6 +108,9 @@ spotless:
        else \
          $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
        fi
+else
+spotless:
+       $(EchoCmd) "spotless target not supported for objdir == srcdir"
 endif
 
 $(BUILT_SOURCES) : $(ObjMakefiles)
@@ -359,10 +362,13 @@ Compile.C     = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
 LTCompile.C   = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
 BCCompile.C   = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
                 $(C.Flags) -c
+Preprocess.C  = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
+
 Compile.CXX   = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
                 $(CXX.Flags) -c
+Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
 Link          = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
                $(CompileCommonOpts) $(LD.Flags) $(Strip)
 Relink        = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
@@ -472,9 +478,9 @@ $(RecursiveTargets)::
        done
 endif
 
-#---------------------------------------------------------
+#-----------------------------------------------------------
 # Handle the PARALLEL_DIRS options for parallel construction
-#---------------------------------------------------------
+#-----------------------------------------------------------
 ifdef PARALLEL_DIRS
 
 SubDirs += $(PARALLEL_DIRS)
@@ -585,9 +591,9 @@ endif
 # What the Sparc JIT requires
 ifdef ENABLE_SPARCV9_JIT
   JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
-              LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
+              LLVMSparcV9LiveVar LLVMInstrumentation.a \
               LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
-              LLVMDataStructure.a LLVMSparcV9RegAlloc
+              LLVMDataStructure LLVMSparcV9RegAlloc
 endif
 
 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
@@ -614,7 +620,7 @@ ifdef ENABLE_ALPHA_JIT
   JIT_LIBS += LLVMAlpha LLVMSelectionDAG
 endif
 
-LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
+LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
             LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
             LLVMSystem.a $(PLATFORMLIBDL)
 endif
@@ -766,8 +772,10 @@ $(warning Bytecode libraries require llvm-gcc which could not be found ****)
 else
 
 # make the C and C++ compilers strip debug info out of bytecode libraries.
+ifndef DEBUG_RUNTIME
 BCCompile.C += -Wa,-strip-debug
 BCCompile.CXX += -Wa,-strip-debug
+endif
 
 all-local:: $(LibName.BCA)
 
@@ -821,10 +829,18 @@ endif
 
 #---------------------------------------------------------
 # ReLinked Library Targets:
-#   If the user didn't explicitly forbid building a 
-#   relinked then we provide targets for building them.
+#   If the user explicitly requests a relinked library with
+#   BUILD_RELINKED, provide it.  Otherwise, if they specify
+#   neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
+#   them one.
 #---------------------------------------------------------
+ifndef BUILD_ARCHIVE
 ifndef DONT_BUILD_RELINKED
+BUILD_RELINKED = 1
+endif
+endif
+
+ifdef BUILD_RELINKED
 
 all-local:: $(LibName.O)
 
@@ -1002,6 +1018,20 @@ $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
 
 endif
 
+## Rules for building preprocessed (.i/.ii) outputs.
+$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
+       $(Verb) $(Preprocess.CXX) $< -o $@
+
+$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
+       $(Verb) $(Preprocess.CXX) $< -o $@
+
+ $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
+       $(Verb) $(Preprocess.C) $< -o $@
+
+
 #---------------------------------------------------------
 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
 #---------------------------------------------------------
@@ -1083,7 +1113,7 @@ $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
 
 ifdef TARGET
 
-TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
+TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td)
 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
@@ -1140,6 +1170,16 @@ $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
        $(Echo) "Building $(<F) code emitter with tblgen"
        $(Verb) $(TableGen) -gen-emitter -o $@ $<
 
+$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
+$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
+       $(Echo) "Building $(<F) instruction selector implementation with tblgen"
+       $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
+
+$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
+$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
+       $(Echo) "Building $(<F) subtarget information with tblgen"
+       $(Verb) $(TableGen) -gen-subtarget -o $@ $<
+
 clean-local::
        -$(Verb) $(RM) -f $(INCFiles)
 
@@ -1182,7 +1222,6 @@ $(LexObjs): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
 
 clean-local::
        -$(Verb) $(RM) -f $(LexOutput)
-       $(Verb) $(RM) -f $(LexOutput)
 
 endif
 
@@ -1193,7 +1232,6 @@ endif
 
 YaccFiles  := $(filter %.y,$(Sources))
 ifneq ($(YaccFiles),)
-YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.output)
 
 .PRECIOUS: $(YaccOutput)
 
@@ -1202,7 +1240,7 @@ YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.output)
 %.cpp: %.y
 %.h: %.y
 
-# Rule for building the bison parsers...
+# Rule for building the bison based parsers...
 $(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
        $(Echo) "Bisoning $*.y"
        $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
@@ -1210,8 +1248,13 @@ $(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
        $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
        $(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp and $*.h (generated files)"
 
+YaccObjs   := $(patsubst %.y,$(ObjDir)/%.o,$(YaccFiles))
+$(YaccObjs): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
+
+YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.output)
+
 clean-local::
-       $(Verb) $(RM) -f $(YaccOutput)
+       -$(Verb) $(RM) -f $(YaccOutput)
 endif
 
 ###############################################################################
@@ -1525,12 +1568,14 @@ install-local::
            $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
          done ; \
        fi
+ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
        $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
          cd $(PROJ_OBJ_ROOT)/include && \
-         for hdr in `find . -type f -print` ; do \
+         for hdr in `find . -type f -print | grep -v CVS` ; do \
            $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
          done ; \
        fi
+endif
 
 uninstall-local::
        $(Echo) Uninstalling include files