Move the rules for building plugins to Makefile.rules.
authorMikhail Glushenkov <foldr@codedgers.com>
Mon, 2 Mar 2009 09:04:13 +0000 (09:04 +0000)
committerMikhail Glushenkov <foldr@codedgers.com>
Mon, 2 Mar 2009 09:04:13 +0000 (09:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65827 91177308-0d34-0410-b5e6-96231b3b80d8

Makefile.rules
tools/llvmc/Makefile
tools/llvmc/plugins/Base/Makefile
tools/llvmc/plugins/Clang/Makefile
tools/llvmc/plugins/Hello/Makefile
tools/llvmc/plugins/Simple/Makefile

index 56d3a8739edefb302cc6c641d73dcb36a7aaa32f..fdad178ea2563bb84d5e71afb8709cfbb4881d23 100644 (file)
@@ -191,6 +191,28 @@ uninstall:: uninstall-local
 install-local:: all-local
 install-bytecode:: install-bytecode-local
 
+###############################################################################
+# LLVMC: Provide rules for compiling llvmc plugins
+###############################################################################
+
+ifdef LLVMC_PLUGIN
+
+LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
+REQUIRES_EH := 1
+
+# Build a dynamic library if the user runs `make` directly from the plugin
+# directory.
+ifndef LLVMC_BUILTIN_PLUGIN
+LOADABLE_MODULE = 1
+endif
+
+# TableGen stuff...
+ifneq ($(BUILT_SOURCES),)
+BUILD_AUTOGENERATED_INC=1
+endif
+
+endif # LLVMC_PLUGIN
+
 ###############################################################################
 # VARIABLES: Set up various variables based on configuration data
 ###############################################################################
@@ -1281,6 +1303,37 @@ $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
        $(Echo) "Compiling $*.ll for $(BuildMode) build"
        $(Verb) $(LLVMAS) $< -f -o $@
 
+###############################################################################
+# LLVMC: Provide rules for compiling llvmc plugins, pt. 2
+###############################################################################
+
+ifdef BUILD_AUTOGENERATED_INC
+
+# This needs to be in a separate section, otherwise we get an infinite loop:)
+
+# This stuff is mostly copied from the TABLEGEN section below
+# TODO: merge
+
+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)
+
+# All of these files depend on tblgen and the .td files.
+$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
+
+$(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
 ###############################################################################
@@ -1784,5 +1837,5 @@ printvars::
 
 # General debugging rule, use 'make print-XXX' to print the
 # definition, value and origin of XXX.
-print-%: 
+print-%:
        $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))
index f70c4b5e11c81eeacad7a05d3e71d6f5c15d136f..60961769d19754f956cd916433ee74fa929c7031 100644 (file)
@@ -9,8 +9,6 @@
 
 LEVEL = ../..
 
-#ifndef LLVMC_PLUGIN
-
 # The current plan is to make the user copy the skeleton project and change only
 # this file (and plugins/UserPlugin, of course).
 
@@ -20,43 +18,3 @@ export LLVMC_BUILTIN_PLUGINS = Base Clang
 DIRS = plugins driver
 
 include $(LEVEL)/Makefile.common
-
-else # LLVMC_PLUGIN
-
-# We are included from plugins/PluginName/Makefile...
-# TODO: This part must be merged into Makefile.rules.
-
-LEVEL = ../../../..
-
-LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
-REQUIRES_EH := 1
-
-# Build a dynamic library if the user runs `make` from plugins/PluginName
-ifndef LLVMC_BUILTIN_PLUGIN
-LOADABLE_MODULE = 1
-endif
-
-# TableGen stuff...
-ifneq ($(BUILT_SOURCES),)
-BUILD_AUTOGENERATED_INC=1
-endif
-
-include $(LEVEL)/Makefile.common
-
-ifdef BUILD_AUTOGENERATED_INC
-
-TOOLS_SOURCE := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
-
-TD_COMMON :=$(strip $(wildcard \
-               $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
-
-$(ObjDir)/AutoGenerated.inc.tmp: $(TOOLS_SOURCE) $(ObjDir)/.dir \
-                               $(TBLGEN) $(TD_COMMON)
-       $(Echo) "Building LLVMC configuration library with tblgen"
-       $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
-
-AutoGenerated.inc : $(ObjDir)/AutoGenerated.inc.tmp
-       $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
-endif # BUILD_AUTOGENERATED_INC
-
-endif # LLVMC_PLUGIN
index 017dcebc022c4bfbae562e87e90adcb7460830b2..ebc433505422f0fdb88da399c1ade2398584f46a 100644 (file)
@@ -7,9 +7,9 @@
 #
 ##===----------------------------------------------------------------------===##
 
-LEVEL = ../..
+LEVEL = ../../../..
 
 LLVMC_PLUGIN = Base
 BUILT_SOURCES = AutoGenerated.inc
 
-include $(LEVEL)/Makefile
+include $(LEVEL)/Makefile.common
index bf5429c16a39420fda63b399ebb9e821c375144e..5e5b88a44b226b778e784271e034ed01b9da0d41 100644 (file)
@@ -7,9 +7,9 @@
 #
 ##===----------------------------------------------------------------------===##
 
-LEVEL = ../..
+LEVEL = ../../../..
 
 LLVMC_PLUGIN = Clang
 BUILT_SOURCES = AutoGenerated.inc
 
-include $(LEVEL)/Makefile
+include $(LEVEL)/Makefile.common
index b309bff6626d85b583441f51d2ab76efb6d1bf44..10325e6a6d5f89415c6a1acc402bb5113bcc547e 100644 (file)
@@ -7,8 +7,8 @@
 #
 ##===----------------------------------------------------------------------===##
 
-LEVEL = ../..
+LEVEL = ../../../..
 
 LLVMC_PLUGIN = Hello
 
-include $(LEVEL)/Makefile
+include $(LEVEL)/Makefile.common
index b108e7018d51068ba0666f4d0afe84913a6d36bf..d7adb5d851e5842ecfed4d4b7d1db2dfa0faab0e 100644 (file)
@@ -7,9 +7,9 @@
 #
 ##===----------------------------------------------------------------------===##
 
-LEVEL = ../..
+LEVEL = ../../../..
 
 LLVMC_PLUGIN = Simple
 BUILT_SOURCES = AutoGenerated.inc
 
-include $(LEVEL)/Makefile
+include $(LEVEL)/Makefile.common