aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.rules55
-rw-r--r--tools/llvmc/Makefile42
-rw-r--r--tools/llvmc/plugins/Base/Makefile4
-rw-r--r--tools/llvmc/plugins/Clang/Makefile4
-rw-r--r--tools/llvmc/plugins/Hello/Makefile4
-rw-r--r--tools/llvmc/plugins/Simple/Makefile4
6 files changed, 62 insertions, 51 deletions
diff --git a/Makefile.rules b/Makefile.rules
index 56d3a8739e..fdad178ea2 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -192,6 +192,28 @@ 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
###############################################################################
@@ -1282,6 +1304,37 @@ $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
$(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 $*)))
diff --git a/tools/llvmc/Makefile b/tools/llvmc/Makefile
index f70c4b5e11..60961769d1 100644
--- a/tools/llvmc/Makefile
+++ b/tools/llvmc/Makefile
@@ -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
diff --git a/tools/llvmc/plugins/Base/Makefile b/tools/llvmc/plugins/Base/Makefile
index 017dcebc02..ebc4335054 100644
--- a/tools/llvmc/plugins/Base/Makefile
+++ b/tools/llvmc/plugins/Base/Makefile
@@ -7,9 +7,9 @@
#
##===----------------------------------------------------------------------===##
-LEVEL = ../..
+LEVEL = ../../../..
LLVMC_PLUGIN = Base
BUILT_SOURCES = AutoGenerated.inc
-include $(LEVEL)/Makefile
+include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/plugins/Clang/Makefile b/tools/llvmc/plugins/Clang/Makefile
index bf5429c16a..5e5b88a44b 100644
--- a/tools/llvmc/plugins/Clang/Makefile
+++ b/tools/llvmc/plugins/Clang/Makefile
@@ -7,9 +7,9 @@
#
##===----------------------------------------------------------------------===##
-LEVEL = ../..
+LEVEL = ../../../..
LLVMC_PLUGIN = Clang
BUILT_SOURCES = AutoGenerated.inc
-include $(LEVEL)/Makefile
+include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/plugins/Hello/Makefile b/tools/llvmc/plugins/Hello/Makefile
index b309bff662..10325e6a6d 100644
--- a/tools/llvmc/plugins/Hello/Makefile
+++ b/tools/llvmc/plugins/Hello/Makefile
@@ -7,8 +7,8 @@
#
##===----------------------------------------------------------------------===##
-LEVEL = ../..
+LEVEL = ../../../..
LLVMC_PLUGIN = Hello
-include $(LEVEL)/Makefile
+include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/plugins/Simple/Makefile b/tools/llvmc/plugins/Simple/Makefile
index b108e7018d..d7adb5d851 100644
--- a/tools/llvmc/plugins/Simple/Makefile
+++ b/tools/llvmc/plugins/Simple/Makefile
@@ -7,9 +7,9 @@
#
##===----------------------------------------------------------------------===##
-LEVEL = ../..
+LEVEL = ../../../..
LLVMC_PLUGIN = Simple
BUILT_SOURCES = AutoGenerated.inc
-include $(LEVEL)/Makefile
+include $(LEVEL)/Makefile.common