r66870 missed this out.
[oota-llvm.git] / Makefile.rules
index 66d90f12094ca883416b8dd5311c49547174105f..351a3450601bf7c6f3c558ea3fc239907f98e8aa 100644 (file)
@@ -282,6 +282,14 @@ ifndef REQUIRES_RTTI
 #  CXX.Flags += -fno-rtti
 endif
 
+ifdef ENABLE_COVERAGE
+  BuildMode := $(BuildMode)+Coverage
+  # These only go to .NoRelink because otherwise we will end up
+  # linking -lgcov into the .o libraries that get built.
+  CXX.Flags.NoRelink += -ftest-coverage -fprofile-arcs
+  C.Flags.NoRelink   += -ftest-coverage -fprofile-arcs
+endif
+
 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
 # then disable assertions by defining the appropriate preprocessor symbols.
 ifdef DISABLE_ASSERTIONS
@@ -420,6 +428,26 @@ endif
 # Adjust to user's request
 #--------------------------------------------------------------------
 
+ifeq ($(OS),Darwin)
+  DARWIN_VERSION := `sw_vers -productVersion`
+  # Strip a number like 10.4.7 to 10.4
+  DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
+  # Get "4" out of 10.4 for later pieces in the makefile.
+  DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
+     
+  SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress -bundle \
+                    -mmacosx-version-min=$(DARWIN_VERSION)
+  CompileCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
+else
+  ifeq ($(OS),Cygwin)
+    SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
+                      -Wl,--enable-auto-import -Wl,--enable-auto-image-base \
+                      -Wl,--enable-runtime-pseudo-relocs
+  else
+    SharedLinkOptions=-shared
+  endif
+endif
+
 # Adjust LD.Flags depending on the kind of library that is to be built. Note
 # that if LOADABLE_MODULE is specified then the resulting shared library can
 # be opened with dlopen.
@@ -428,8 +456,10 @@ ifdef LOADABLE_MODULE
 endif
 
 ifdef SHARED_LIBRARY
+ifneq ($(DARWIN_MAJVERS),4)
   LD.Flags += $(RPATH) -Wl,$(LibDir)
 endif
+endif
 
 ifdef TOOL_VERBOSE
   C.Flags += -v
@@ -456,6 +486,7 @@ endif
 
 # Adjust linker flags for building an executable
 ifneq ($(OS),Darwin)
+ifneq ($(DARWIN_MAJVERS),4)
 ifdef TOOLNAME
 ifdef EXAMPLE_TOOL
   LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
@@ -464,25 +495,6 @@ else
 endif
 endif
 endif
-
-ifeq ($(OS),Darwin)
-  DARWIN_VERSION := `sw_vers -productVersion`
-  # Strip a number like 10.4.7 to 10.4
-  DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
-  # Get "4" out of 10.4 for later pieces in the makefile.
-  DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
-     
-  SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress -bundle \
-                    -mmacosx-version-min=$(DARWIN_VERSION)
-  CompileCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
-else
-  ifeq ($(OS),Cygwin)
-    SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
-                      -Wl,--enable-auto-import -Wl,--enable-auto-image-base \
-                      -Wl,--enable-runtime-pseudo-relocs
-  else
-    SharedLinkOptions=-shared
-  endif
 endif
 
 #----------------------------------------------------------
@@ -546,20 +558,26 @@ CPP.Flags     += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
                 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
                 $(CPP.BaseFlags)
 
- ifeq ($(BUILD_COMPONENT), 1)
-  Compile.C     = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c
-  Compile.CXX   = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c
-  Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
-  Link          = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
-                  $(LD.Flags) $(Strip)
+ifeq ($(BUILD_COMPONENT), 1)
+  Compile.C     = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
+                  $(CompileCommonOpts) -c
+  Compile.CXX   = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
+                  $(CompileCommonOpts) -c
+  Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) \
+                  $(CXX.Flags.NoRelink) -E
+  Link          = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
+                  $(CompileCommonOpts) $(LD.Flags) $(Strip)
   Relink        = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
                  $(Relink.Flags)
 else
-  Compile.C     = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c
-  Compile.CXX   = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c
-  Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
-  Link          = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
-                  $(LD.Flags) $(Strip)
+  Compile.C     = $(CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
+                  $(CompileCommonOpts) -c
+  Compile.CXX   = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
+                  $(CompileCommonOpts) -c
+  Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) \
+                  $(CXX.Flags.NoRelink) -E
+  Link          = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
+                  $(CompileCommonOpts) $(LD.Flags) $(Strip)
   Relink        = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
                  $(Relink.Flags)
 endif
@@ -1340,6 +1358,10 @@ ifdef LLVMC_BUILD_AUTOGENERATED_INC
 TABLEGEN_INC_FILES_COMMON = 1
 endif
 
+ifdef CLANG_BUILD_DIAGNOSTICS_INC
+TABLEGEN_INC_FILES_COMMON = 1
+endif
+
 ifdef TABLEGEN_INC_FILES_COMMON
 
 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
@@ -1454,6 +1476,14 @@ $(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
 
 endif # LLVMC_BUILD_AUTOGENERATED_INC
 
+ifdef CLANG_BUILD_DIAGNOSTICS_INC
+
+$(ObjDir)/Diagnostic%Kinds.inc.tmp : Diagnostic.td Diagnostic%Kinds.td $(TBLGEN)
+       $(Echo) "Building Clang $(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) diagnostic tables with tblgen"
+       $(Verb) $(MKDIR) $(@D)
+       $(Verb) $(TableGen) -gen-clang-diags-defs -clang-component=$(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) -o $(call SYSPATH, $@) $<
+
+endif
 
 ###############################################################################
 # OTHER RULES: Other rules needed