Re-apply Makefile changes. Fix build with srcdir != objdir.
authorMikhail Glushenkov <foldr@codedgers.com>
Thu, 16 Oct 2008 14:02:29 +0000 (14:02 +0000)
committerMikhail Glushenkov <foldr@codedgers.com>
Thu, 16 Oct 2008 14:02:29 +0000 (14:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57636 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvmc2/Makefile
tools/llvmc2/doc/LLVMC-Reference.rst
tools/llvmc2/plugins/Base/Makefile
tools/llvmc2/plugins/Base/PluginMain.cpp [new file with mode: 0644]
tools/llvmc2/plugins/Clang/Makefile
tools/llvmc2/plugins/Clang/PluginMain.cpp [new file with mode: 0644]
tools/llvmc2/plugins/Makefile
tools/llvmc2/plugins/Simple/Makefile [new file with mode: 0644]
tools/llvmc2/plugins/Simple/PluginMain.cpp [new file with mode: 0644]
tools/llvmc2/plugins/Simple/Simple.td [new file with mode: 0644]

index c5b2959b6fc3cb24e2f2df26f403a579f74a3195..22ca29e2ed70889dcb45fe685be05ca499e75d56 100644 (file)
@@ -9,11 +9,9 @@
 
 LEVEL = ../..
 
-##### FIXME: Does not work when objdir != srcdir
-#####BUILTIN_PLUGINS = Base
-
+BUILTIN_PLUGINS = Base
 DRIVER_NAME = llvmc2
-DIRS = plugins driver 
+DIRS = plugins driver
 
 export BUILTIN_PLUGINS
 export DRIVER_NAME
index 1b7e017c4ffec190ad054ef09f1ee7d92468ac45..62e2ef41a8bc338ba22fc2a2b50dd28547d3413f 100644 (file)
@@ -121,7 +121,7 @@ generic::
 
    $ mv Simple.td MyPlugin.td
 
-Note that the plugin source directory should be placed into
+Note that the plugin source directory should be placed under
 ``$LLVMC_DIR/plugins`` to make use of the existing build
 infrastructure. To build a version of the LLVMC executable called
 ``mydriver`` with your plugin compiled in, use the following command::
index 89cdaf4a9e811f2e98fab9477651c10854fa0356..c1579d146d1fbad853a726f71f847286c4a95a57 100644 (file)
@@ -8,5 +8,6 @@
 ##===----------------------------------------------------------------------===##
 
 LLVMC_PLUGIN = Base
+BUILT_SOURCES = AutoGenerated.inc
 
 include ../Makefile
diff --git a/tools/llvmc2/plugins/Base/PluginMain.cpp b/tools/llvmc2/plugins/Base/PluginMain.cpp
new file mode 100644 (file)
index 0000000..add8acb
--- /dev/null
@@ -0,0 +1 @@
+#include "AutoGenerated.inc"
index e48824aa9523352e1ecc8a2c710940d3fe7aafaf..237cc736f0f4c92fc98d42cdf917a018664e0caa 100644 (file)
@@ -8,6 +8,7 @@
 ##===----------------------------------------------------------------------===##
 
 LLVMC_PLUGIN = Clang
+BUILT_SOURCES = AutoGenerated.inc
 
 include ../Makefile
 
diff --git a/tools/llvmc2/plugins/Clang/PluginMain.cpp b/tools/llvmc2/plugins/Clang/PluginMain.cpp
new file mode 100644 (file)
index 0000000..add8acb
--- /dev/null
@@ -0,0 +1 @@
+#include "AutoGenerated.inc"
index 568752e5784edebd7e9459dd2f39a78609189254..041b045652cb09b84bdaa7dfea723fdecbab5844 100644 (file)
@@ -12,8 +12,7 @@ ifndef LLVMC_PLUGIN
 LEVEL = ../../..
 DIRS = $(BUILTIN_PLUGINS)
 
-# TOFIX: DSO versions of plugins are not built
-
+# TOFIX: Should we also build DSO versions of plugins?
 export BUILTIN_LLVMC_PLUGIN=1
 
 include $(LEVEL)/Makefile.common
@@ -22,25 +21,27 @@ else # LLVMC_PLUGIN
 
 LEVEL = ../../../..
 
-LIBRARYNAME = $(patsubst %,LLVMC%,$(LLVMC_PLUGIN))
-TOOLS_SOURCE = $(wildcard $(PROJ_SRC_DIR)/*.td)
+LIBRARYNAME := $(patsubst %,LLVMC%,$(LLVMC_PLUGIN))
 REQUIRES_EH = 1
 
 ifndef BUILTIN_LLVMC_PLUGIN
 LOADABLE_MODULE = 1
 endif
 
-ifneq ($(TOOLS_SOURCE),"")
+ifneq ($(BUILT_SOURCES),)
 BUILD_AUTOGENERATED_INC=1
-BUILT_SOURCES = AutoGenerated.inc
 endif
 
 include $(LEVEL)/Makefile.common
 
-# TOFIX: This should go into Makefile.rules
+# TOFIX: This probably should go into Makefile.rules
 
 ifdef BUILD_AUTOGENERATED_INC
-TD_COMMON = $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td)
+
+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)
diff --git a/tools/llvmc2/plugins/Simple/Makefile b/tools/llvmc2/plugins/Simple/Makefile
new file mode 100644 (file)
index 0000000..4a16256
--- /dev/null
@@ -0,0 +1,13 @@
+##===- tools/llvmc2/plugins/Simple/Makefile ------------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLVMC_PLUGIN = Simple
+BUILT_SOURCES = AutoGenerated.inc
+
+include ../Makefile
diff --git a/tools/llvmc2/plugins/Simple/PluginMain.cpp b/tools/llvmc2/plugins/Simple/PluginMain.cpp
new file mode 100644 (file)
index 0000000..add8acb
--- /dev/null
@@ -0,0 +1 @@
+#include "AutoGenerated.inc"
diff --git a/tools/llvmc2/plugins/Simple/Simple.td b/tools/llvmc2/plugins/Simple/Simple.td
new file mode 100644 (file)
index 0000000..2bc4011
--- /dev/null
@@ -0,0 +1,30 @@
+// A simple wrapper for gcc.
+// To compile, use this command:
+//
+//      $ cd $LLVMC2_DIR
+//      $ make DRIVER_NAME=mygcc BUILTIN_PLUGINS=Simple
+//
+// To build this plugin as a dynamic library:
+//
+//      $ cd $LLVMC2_DIR
+//      $ make BUILTIN_PLUGINS=""
+//      $ cd plugins/Simple
+//      $ make
+//
+// Run as:
+//
+//      $ llvmc2 -load $LLVM_DIR/Release/lib/LLVMCSimple.so
+
+include "llvm/CompilerDriver/Common.td"
+
+def gcc : Tool<
+[(in_language "c"),
+ (out_language "executable"),
+ (output_suffix "out"),
+ (cmd_line "gcc $INFILE -o $OUTFILE"),
+ (sink)
+]>;
+
+def LanguageMap : LanguageMap<[LangToSuffixes<"c", ["c"]>]>;
+
+def CompilationGraph : CompilationGraph<[Edge<root, gcc>]>;