Fix PR456:\
authorReid Spencer <rspencer@reidspencer.com>
Thu, 18 Nov 2004 10:03:46 +0000 (10:03 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Thu, 18 Nov 2004 10:03:46 +0000 (10:03 +0000)
Tools and libraries will be built into $(BUILD_OBJ_ROOT)/$(BuildMode)/bin and \
$(BUILD_OBJ_ROOT)/$(BuildMode)/lib, respectively. Furthermore, the example \
programs will go in $(BUILD_OBJ_ROOT)/$(BuildMode)/examples to keep them \
separate from the tools and hopefully out of the PATH. Install targets \
have not changed.

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

Makefile.rules
examples/BFtoLLVM/Makefile
examples/Fibonacci/Makefile
examples/HowToUseJIT/Makefile
examples/ModuleMaker/Makefile

index 93b77886db0ce370504dd0bcd384abb12913c6a2..d929ae8974f84d9bf9d504cdcc6fff66a77c2c99 100644 (file)
@@ -176,10 +176,12 @@ LibTool.Flags := --tag=CXX
 # Directory locations
 #--------------------------------------------------------------------
 ObjDir      := $(BUILD_OBJ_DIR)/$(BuildMode)
-LibDir      := $(BUILD_OBJ_ROOT)/lib/$(BuildMode)
-ToolDir     := $(BUILD_OBJ_ROOT)/tools/$(BuildMode)
-LLVMLibDir  := $(LLVM_OBJ_ROOT)/lib/$(BuildMode)
-LLVMToolDir := $(LLVM_OBJ_ROOT)/tools/$(BuildMode)
+LibDir      := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
+ToolDir     := $(BUILD_OBJ_ROOT)/$(BuildMode)/tools
+ExmplDir    := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
+LLVMLibDir  := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
+LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/tools
+LExmplDir   := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
 
 #--------------------------------------------------------------------
 # Full Paths To Compiled Tools and Utilities
@@ -248,8 +250,12 @@ endif
 
 # Adjust linker flags for building an executable
 ifdef TOOLNAME
+ifdef EXAMPLE_TOOL
+  LD.Flags += -rpath $(ExmplDir) -export-dynamic
+else
   LD.Flags += -rpath $(ToolDir) -export-dynamic
 endif
+endif
 
 #----------------------------------------------------------
 # Options To Invoke Tools
@@ -337,8 +343,8 @@ $(sysconfdir):
        $(Verb) $(MKDIR) $* > /dev/null
        @$(DATE) > $@
 
-.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(LLVMLibDir)/.dir
-.PRECIOUS: $(LLVMToolDir)/.dir
+.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
+.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
 
 #---------------------------------------------------------
 # Handle the DIRS options for sequential construction
@@ -609,7 +615,11 @@ ifdef TOOLNAME
 #---------------------------------------------------------
 # Set up variables for building a tool.
 #---------------------------------------------------------
+ifdef EXAMPLE_TOOL
+ToolBuildPath   := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
+else
 ToolBuildPath   := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
+endif
 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o,  $(ProjLibsOptions))
 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
@@ -647,8 +657,13 @@ ifneq ($(strip $(ToolBuildPath)),)
        -$(Verb) $(RM) -f $(ToolBuildPath)
 endif
 
-$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)\
-                  $(ToolDir)/.dir
+ifdef EXAMPLE_TOOL
+$(ToolBuildPath): $(ExmplDir)/.dir
+else
+$(ToolBuildPath): $(ToolDir)/.dir
+endif
+
+$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
        $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
        $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
           $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
@@ -1194,6 +1209,7 @@ printvars::
        $(Echo) "ObjDir         : " '$(ObjDir)'
        $(Echo) "LibDir         : " '$(LibDir)'
        $(Echo) "ToolDir        : " '$(ToolDir)'
+       $(Echo) "ExmplDir       : " '$(ExmplDir)'
        $(Echo) "TDFiles        : " '$(TDFiles)'
        $(Echo) "INCFiles       : " '$(INCFiles)'
        $(Echo) "Compile.CXX    : " '$(Compile.CXX)'
index e3074cc683a5de7029d3fd59b27017713260b129..0b4c429a39e6d69ceef068efe4b174b5db1996f9 100644 (file)
@@ -9,4 +9,5 @@
 
 LEVEL = ../..
 TOOLNAME = BFtoLLVM
+EXAMPLE_TOOL = 1
 include $(LEVEL)/Makefile.common
index 2c9a53149c6898833f3991c6c8eb299c492fd8f0..a6d378591f949ae3868ab007130075a2ba0ea84a 100644 (file)
@@ -9,6 +9,7 @@
 
 LEVEL = ../..
 TOOLNAME = Fibonacci
+EXAMPLE_TOOL = 1
 
 # Enable JIT support
 include $(LEVEL)/tools/Makefile.JIT
index 3312eb82093549a7f3e7f7ecb2565ab15495aa99..0f5e26b5ca3ac2d07c4bb6faa71f80459ad44556 100644 (file)
@@ -8,6 +8,7 @@
 ##===----------------------------------------------------------------------===##
 LEVEL = ../..
 TOOLNAME = HowToUseJIT
+EXAMPLE_TOOL = 1
 
 # Enable JIT support
 include $(LEVEL)/tools/Makefile.JIT
index 2bd8a38b7e2f955964777c0ff846557555cef11c..91635d48f9ca490edc1d6af8b5f7d5008b452892 100644 (file)
@@ -8,6 +8,7 @@
 ##===----------------------------------------------------------------------===##
 LEVEL=../..
 TOOLNAME=ModuleMaker
+EXAMPLE_TOOL = 1
 USEDLIBS= LLVMBCWriter LLVMCore LLVMSupport.a LLVMSystem.a
 
 include $(LEVEL)/Makefile.common