From cc30d9caa5d4a7b7f08c33915d8c2f438a1d8c2b Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Thu, 16 Oct 2008 14:02:29 +0000 Subject: [PATCH] Re-apply Makefile changes. Fix build with srcdir != objdir. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57636 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvmc2/Makefile | 6 ++--- tools/llvmc2/doc/LLVMC-Reference.rst | 2 +- tools/llvmc2/plugins/Base/Makefile | 1 + tools/llvmc2/plugins/Base/PluginMain.cpp | 1 + tools/llvmc2/plugins/Clang/Makefile | 1 + tools/llvmc2/plugins/Clang/PluginMain.cpp | 1 + tools/llvmc2/plugins/Makefile | 17 ++++++------ tools/llvmc2/plugins/Simple/Makefile | 13 ++++++++++ tools/llvmc2/plugins/Simple/PluginMain.cpp | 1 + tools/llvmc2/plugins/Simple/Simple.td | 30 ++++++++++++++++++++++ 10 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 tools/llvmc2/plugins/Base/PluginMain.cpp create mode 100644 tools/llvmc2/plugins/Clang/PluginMain.cpp create mode 100644 tools/llvmc2/plugins/Simple/Makefile create mode 100644 tools/llvmc2/plugins/Simple/PluginMain.cpp create mode 100644 tools/llvmc2/plugins/Simple/Simple.td diff --git a/tools/llvmc2/Makefile b/tools/llvmc2/Makefile index c5b2959b6fc..22ca29e2ed7 100644 --- a/tools/llvmc2/Makefile +++ b/tools/llvmc2/Makefile @@ -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 diff --git a/tools/llvmc2/doc/LLVMC-Reference.rst b/tools/llvmc2/doc/LLVMC-Reference.rst index 1b7e017c4ff..62e2ef41a8b 100644 --- a/tools/llvmc2/doc/LLVMC-Reference.rst +++ b/tools/llvmc2/doc/LLVMC-Reference.rst @@ -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:: diff --git a/tools/llvmc2/plugins/Base/Makefile b/tools/llvmc2/plugins/Base/Makefile index 89cdaf4a9e8..c1579d146d1 100644 --- a/tools/llvmc2/plugins/Base/Makefile +++ b/tools/llvmc2/plugins/Base/Makefile @@ -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 index 00000000000..add8acb4a57 --- /dev/null +++ b/tools/llvmc2/plugins/Base/PluginMain.cpp @@ -0,0 +1 @@ +#include "AutoGenerated.inc" diff --git a/tools/llvmc2/plugins/Clang/Makefile b/tools/llvmc2/plugins/Clang/Makefile index e48824aa952..237cc736f0f 100644 --- a/tools/llvmc2/plugins/Clang/Makefile +++ b/tools/llvmc2/plugins/Clang/Makefile @@ -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 index 00000000000..add8acb4a57 --- /dev/null +++ b/tools/llvmc2/plugins/Clang/PluginMain.cpp @@ -0,0 +1 @@ +#include "AutoGenerated.inc" diff --git a/tools/llvmc2/plugins/Makefile b/tools/llvmc2/plugins/Makefile index 568752e5784..041b045652c 100644 --- a/tools/llvmc2/plugins/Makefile +++ b/tools/llvmc2/plugins/Makefile @@ -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 index 00000000000..4a162566653 --- /dev/null +++ b/tools/llvmc2/plugins/Simple/Makefile @@ -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 index 00000000000..add8acb4a57 --- /dev/null +++ b/tools/llvmc2/plugins/Simple/PluginMain.cpp @@ -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 index 00000000000..2bc40119261 --- /dev/null +++ b/tools/llvmc2/plugins/Simple/Simple.td @@ -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]>;