Remove duplication in Makefile.rules.
authorMikhail Glushenkov <foldr@codedgers.com>
Mon, 2 Mar 2009 09:42:59 +0000 (09:42 +0000)
committerMikhail Glushenkov <foldr@codedgers.com>
Mon, 2 Mar 2009 09:42:59 +0000 (09:42 +0000)
Merge common bits from the LLVMC and TABLEGEN sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65834 91177308-0d34-0410-b5e6-96231b3b80d8

Makefile.rules

index fdad178ea2563bb84d5e71afb8709cfbb4881d23..9f0e58c42841ff84c9705af41b60144758a0df01 100644 (file)
@@ -208,7 +208,7 @@ endif
 
 # TableGen stuff...
 ifneq ($(BUILT_SOURCES),)
-BUILD_AUTOGENERATED_INC=1
+LLVMC_BUILD_AUTOGENERATED_INC=1
 endif
 
 endif # LLVMC_PLUGIN
@@ -1304,19 +1304,19 @@ $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
        $(Verb) $(LLVMAS) $< -f -o $@
 
 ###############################################################################
-# LLVMC: Provide rules for compiling llvmc plugins, pt. 2
+# TABLEGEN: Provide rules for running tblgen to produce *.inc files
 ###############################################################################
 
-ifdef BUILD_AUTOGENERATED_INC
+ifdef TARGET
+TABLEGEN_INC_FILES_COMMON = 1
+endif
 
-# This needs to be in a separate section, otherwise we get an infinite loop:)
+ifdef LLVMC_BUILD_AUTOGENERATED_INC
+TABLEGEN_INC_FILES_COMMON = 1
+endif
 
-# This stuff is mostly copied from the TABLEGEN section below
-# TODO: merge
+ifdef TABLEGEN_INC_FILES_COMMON
 
-LLVMCPluginSrc := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
-TDFiles := $(LLVMCPluginSrc) \
-       $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
@@ -1324,19 +1324,16 @@ INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
 # All of these files depend on tblgen and the .td files.
 $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
 
+# INCFiles rule: All of the tblgen generated files are emitted to
+# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc.  This allows
+# us to only "touch" the real file if the contents of it change.  IOW, if
+# tblgen is modified, all of the .inc.tmp files are regenerated, but no
+# dependencies of the .inc files are, unless the contents of the .inc file
+# changes.
 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
        $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
 
-$(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
-                               $(TBLGEN) $(TD_COMMON)
-       $(Echo) "Building LLVMC configuration library with tblgen"
-       $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
-
-endif # BUILD_AUTOGENERATED_INC
-
-###############################################################################
-# TABLEGEN: Provide rules for running tblgen to produce *.inc files
-###############################################################################
+endif # TABLEGEN_INC_FILES_COMMON
 
 ifdef TARGET
 
@@ -1347,21 +1344,6 @@ TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
            $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
            $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
            $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
-INCFiles := $(filter %.inc,$(BUILT_SOURCES))
-INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
-.PRECIOUS: $(INCTMPFiles) $(INCFiles)
-
-# All of these files depend on tblgen and the .td files.
-$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
-
-# INCFiles rule: All of the tblgen generated files are emitted to
-# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc.  This allows
-# us to only "touch" the real file if the contents of it change.  IOW, if
-# tblgen is modified, all of the .inc.tmp files are regenerated, but no
-# dependencies of the .inc files are, unless the contents of the .inc file
-# changes.
-$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
-       $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
 
 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
@@ -1431,7 +1413,22 @@ $(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
 clean-local::
        -$(Verb) $(RM) -f $(INCFiles)
 
-endif
+endif # TARGET
+
+ifdef LLVMC_BUILD_AUTOGENERATED_INC
+
+LLVMCPluginSrc := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
+
+TDFiles := $(LLVMCPluginSrc) \
+       $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
+
+$(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
+                               $(TBLGEN) $(TD_COMMON)
+       $(Echo) "Building LLVMC configuration library with tblgen"
+       $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
+
+endif # LLVMC_BUILD_AUTOGENERATED_INC
+
 
 ###############################################################################
 # OTHER RULES: Other rules needed