Add a HAVE_MACH_MACH_H #define to detect the presence of the mach/mach.h
[oota-llvm.git] / Makefile.rules
index 055baa08dc55ef637f39853df098db3f6d24f210..b6ad1b56ad4aa14b7cff5be6010c340dfcb1eab8 100644 (file)
@@ -73,6 +73,7 @@ PreConditions      := $(ConfigStatusScript) $(ObjMakefiles)
 ifneq ($(MakefileCommonIn),)
 PreConditions      += $(MakefileCommon)
 endif
+
 ifneq ($(MakefileConfigIn),)
 PreConditions      += $(MakefileConfig)
 endif
@@ -238,6 +239,11 @@ else
   endif
 endif
 
+# IF REQUIRES_EH=1 is specified then don't disable exceptions
+ifndef REQUIRES_EH
+  CXX.Flags += -fno-exceptions
+endif
+
 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
 # then disable assertions by defining the appropriate preprocessor symbols.
 ifdef DISABLE_ASSERTIONS
@@ -249,12 +255,7 @@ else
   C.Flags   += -D_DEBUG
 endif
 
-# IF REQUIRES_EH=1 is specified then don't disable exceptions
-ifndef REQUIRES_EH
-  CXX.Flags += -fno-exceptions
-endif
-
-CXX.Flags     += $(CXXFLAGS)
+CXX.Flags     += $(CXXFLAGS) -Woverloaded-virtual
 C.Flags       += $(CFLAGS)
 CPP.BaseFlags += $(CPPFLAGS)
 LD.Flags      += $(LDFLAGS)
@@ -297,13 +298,14 @@ ifndef TBLGEN
     TBLGEN   := $(LLVMToolDir)/tblgen$(EXEEXT)
   endif
 endif
+LLVM_CONFIG := $(LLVMToolDir)/llvm-config 
 ifndef GCCAS
 GCCAS    := $(LLVMToolDir)/gccas$(EXEEXT)
 endif
 ifndef GCCLD
 GCCLD    := $(LLVMToolDir)/gccld$(EXEEXT)
 endif
-ifndef LDIS
+ifndef LLVMDIS
 LLVMDIS  := $(LLVMToolDir)/llvm-dis$(EXEEXT)
 endif
 ifndef LLI
@@ -623,83 +625,43 @@ endif
 # Set up variables for building libararies
 ###############################################################################
 
-#---------------------------------------------------------
-# Handle the special "JIT" value for LLVM_LIBS which is a
-# shorthand for a bunch of libraries that get the correct
-# JIT support for a library or a tool that runs JIT.
-#---------------------------------------------------------
-ifeq ($(firstword $(LLVMLIBS)),config)
-LLVM_CONFIG := $(LLVM_SRC_ROOT)/utils/llvm-config/llvm-config 
-LLVMLIBS := $(shell $(LLVM_CONFIG) --libnames $(wordlist 2,9999,$(LLVMLIBS)))
-LLVMLIBS := $(patsubst lib%.a,%.a,$(LLVMLIBS))
-LLVMLIBS := $(patsubst %.o,%,$(LLVMLIBS))
-endif
-
-ifeq ($(LLVMLIBS),JIT)
-
-# Make sure we can get our own symbols in the tool
-Link += -dlopen self
-
-# Generic JIT libraries
-JIT_LIBS := LLVMInterpreter LLVMJIT LLVMSelectionDAG.a LLVMCodeGen.a \
-            LLVMExecutionEngine
-
-# You can enable the X86 JIT on a non-X86 host by setting the flag
-# ENABLE_X86_JIT on the make command line. If not, it will still be
-# enabled automagically on an X86 host.
-ifeq ($(ARCH), x86)
-  ENABLE_X86_JIT = 1
-endif
-
-# What the X86 JIT requires
-ifdef ENABLE_X86_JIT
-  JIT_LIBS += LLVMX86 
-endif
-
-# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
-# ENABLE_PPC_JIT on the make command line. If not, it will still be
-# enabled automagically on an PowerPC host.
-ifeq ($(ARCH), PowerPC)
-  ENABLE_PPC_JIT = 1
-endif
-
-# What the PowerPC JIT requires
-ifdef ENABLE_PPC_JIT
-  JIT_LIBS += LLVMPowerPC 
-endif
-
-# You can enable the Alpha JIT on a non-Alpha host by setting the flag
-# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
-# enabled automagically on an Alpha host.
-ifeq ($(ARCH), Alpha)
-  ENABLE_ALPHA_JIT = 1
-endif
-
-# What the Alpha JIT requires
-ifdef ENABLE_ALPHA_JIT
-  JIT_LIBS += LLVMAlpha 
-endif
-
-LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
-            LLVMBCReader.a LLVMTarget.a LLVMCore.a LLVMSupport.a LLVMbzip2.a \
-            LLVMSystem.a $(PLATFORMLIBDL)
-endif
-
 #---------------------------------------------------------
 # Define various command line options pertaining to the
 # libraries needed when linking. There are "Proj" libs 
 # (defined by the user's project) and "LLVM" libs (defined 
-# by the LLVM project).
+# by the LLVM project).
 #---------------------------------------------------------
 
+ifdef USEDLIBS
 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
 ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o,  $(ProjLibsOptions))
+ProjUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
+ProjLibsPaths   := $(addprefix $(LibDir)/,$(ProjUsedLibs))
+endif
+
+ifdef LLVMLIBS
 LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
 LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
-ProjUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
 LLVMUsedLibs    := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
-ProjLibsPaths   := $(addprefix $(LibDir)/,$(ProjUsedLibs))
 LLVMLibsPaths   := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
+endif
+
+ifeq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
+ifdef LINK_COMPONENTS
+
+# If LLVM_CONFIG doesn't exist, build it.  This can happen if you do a make
+# clean in tools, then do a make in tools (instead of at the top level).
+$(LLVM_CONFIG):
+       @echo "*** llvm-config doesn't exist - rebuilding it."
+       @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
+        
+$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
+
+ProjLibsOptions = $(shell $(LLVM_CONFIG) --libs     $(LINK_COMPONENTS))
+ProjLibsPaths   = $(LLVM_CONFIG) \
+                  $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
+endif
+endif
 
 ###############################################################################
 # Library Build Rules: Four ways to build a library
@@ -976,13 +938,6 @@ else
 ToolBuildPath   := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
 endif
 
-#---------------------------------------------------------
-# Tell make that we need to rebuild subdirectories before 
-# we can link the tool. This affects things like LLI which 
-# has library subdirectories.
-#---------------------------------------------------------
-$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
-
 #---------------------------------------------------------
 # Provide targets for building the tools
 #---------------------------------------------------------
@@ -1315,10 +1270,14 @@ all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
 
 # Rule for building the bison based parsers...
 $(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
+ifneq ($(BISON),)
        $(Echo) "Bisoning $*.y"
        $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
        $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
        $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
+else
+       $(Echo) "Bison of $*.y SKIPPED -- bison not found"
+endif
 
 # IFF the .y file has changed since it was last checked into CVS, copy the .y
 # file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs.  We use this
@@ -1400,7 +1359,7 @@ CTAGS:
 ifndef DISABLE_AUTO_DEPENDENCIES
 
 # If its not one of the cleaning targets
-ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
+ifneq ($(strip $(filter-out clean clean-local dist-clean,$(MAKECMDGOALS)))),)
 
 # Get the list of dependency files
 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))