Add m[tf]vscr intrinsics.
[oota-llvm.git] / Makefile.rules
index 33432b8cb514ebc99ccb22bc05f34772eb0d6c53..0144d8dea238d53dd77f07534785264c2393d517 100644 (file)
@@ -198,12 +198,11 @@ install-bytecode:: install-bytecode-local
 # Variables derived from configuration we are building
 #--------------------------------------------------------------------
 
-
 ifdef ENABLE_PROFILING
   BuildMode := Profile
-  CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
-  C.Flags   := -O3 -DNDEBUG -pg
-  LD.Flags  := -O3 -DNDEBUG -pg 
+  CXX.Flags := -O3 -felide-constructors -finline-functions -pg
+  C.Flags   := -O3 -pg
+  LD.Flags  := -O3 -pg 
 else
   ifdef ENABLE_OPTIMIZED
     BuildMode := Release
@@ -211,30 +210,41 @@ else
     ifneq ($(OS),FreeBSD)
       OmitFramePointer := -fomit-frame-pointer
     endif
-    CXX.Flags  := -O3 -DNDEBUG -finline-functions -felide-constructors \
-                  $(OmitFramePointer)
-    C.Flags    := -O3 -DNDEBUG $(OmitFramePointer)
-    LD.Flags   := -O3 -DNDEBUG 
+    CXX.Flags := -O3 -finline-functions -felide-constructors $(OmitFramePointer)
+    C.Flags   := -O3 $(OmitFramePointer)
+    LD.Flags  := -O3
   else
     BuildMode := Debug
-    CXX.Flags := -g -D_DEBUG
-    C.Flags   := -g -D_DEBUG
-    LD.Flags  := -g -D_DEBUG 
+    CXX.Flags := -g
+    C.Flags   := -g
+    LD.Flags  := -g 
     KEEP_SYMBOLS := 1
+    # Assertions default to ON for debug builds.
+    ENABLE_ASSERTIONS := 1
   endif
 endif
 
-CXX.Flags += $(CXXFLAGS)
-C.Flags   += $(CFLAGS)
-CPP.Flags += $(CPPFLAGS)
-LD.Flags  += $(LDFLAGS)
-AR.Flags  := cru
+# If this is a debug build or if ENABLE_ASSERTIONS=1 is specified on the make
+# command line, enable assertions.
+ifdef ENABLE_ASSERTIONS
+  CXX.Flags += -D_DEBUG
+  C.Flags   += -D_DEBUG
+else
+  CXX.Flags += -DNDEBUG
+  C.Flags   += -DNDEBUG
+endif
+
+CXX.Flags     += $(CXXFLAGS)
+C.Flags       += $(CFLAGS)
+CPP.BaseFlags += $(CPPFLAGS)
+LD.Flags      += $(LDFLAGS)
+AR.Flags      := cru
 LibTool.Flags := --tag=CXX
 
 #Make Floating point ieee complient on alpha
 ifeq ($(ARCH),Alpha)
-  CXX.Flags += -mieee
-  CPP.Flags += -mieee
+  CXX.Flags     += -mieee
+  CPP.BaseFlags += -mieee
 endif
 
 #--------------------------------------------------------------------
@@ -350,13 +360,15 @@ ifeq ($(OS),HP-UX)
   CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
 endif
 
-LD.Flags  += -L$(LibDir) -L$(LLVMLibDir) 
-CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
-            -I$(PROJ_OBJ_ROOT)/include \
-            -I$(PROJ_SRC_ROOT)/include \
-            -I$(LLVM_OBJ_ROOT)/include \
-            -I$(LLVM_SRC_ROOT)/include \
-            -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
+LD.Flags      += -L$(LibDir) -L$(LLVMLibDir) 
+CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
+# All -I flags should go here, so that they don't confuse llvm-config.
+CPP.Flags     += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
+                -I$(PROJ_OBJ_ROOT)/include \
+                -I$(PROJ_SRC_ROOT)/include \
+                -I$(LLVM_OBJ_ROOT)/include \
+                -I$(LLVM_SRC_ROOT)/include \
+                $(CPP.BaseFlags)
 
 Compile.C     = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
 LTCompile.C   = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
@@ -376,9 +388,10 @@ Relink        = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
 LTInstall     = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
                $(Install.Flags)
 ProgInstall   = $(INSTALL) $(Install.StripFlag) -m 0755 
+ScriptInstall = $(INSTALL) -m 0755 
 DataInstall   = $(INSTALL) -m 0644
 Burg          = $(BURG) -I $(PROJ_SRC_DIR)
-TableGen      = $(TBLGEN) -I $(PROJ_SRC_DIR)
+TableGen      = $(TBLGEN) -I $(PROJ_SRC_DIR) -I$(PROJ_SRC_ROOT)/include
 Archive       = $(AR) $(AR.Flags)
 LArchive      = $(LLVMToolDir)/llvm-ar rcsf
 ifdef RANLIB
@@ -551,6 +564,14 @@ endif
 # 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) $(wordlist 2,9999,$(LLVMLIBS)))
+LLVMLIBS := $(patsubst $(PROJ_libdir)/%,%,$(LLVMLIBS))
+LLVMLIBS := $(patsubst %.o,%,$(LLVMLIBS))
+LLVMLIBS := $(patsubst -l%,%.a,$(LLVMLIBS))
+endif
+
 ifeq ($(LLVMLIBS),JIT)
 
 # Make sure we can get our own symbols in the tool
@@ -625,6 +646,9 @@ endif
 ifeq ($(ARCH),Alpha)
 USEDLIBS :=  $(subst LLVMCore, LLVMCore.a, $(USEDLIBS))
 LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS))
+CORE_IS_ARCHIVE := 1
+else
+CORE_IS_ARCHIVE := 0
 endif
 
 ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
@@ -928,8 +952,8 @@ endif
 
 $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
        $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
-       $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
-          $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
+       $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(LLVMLibsOptions) \
+        $(ProjLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
        $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
           $(StripWarnMsg) 
 
@@ -951,6 +975,11 @@ endif
 # Object Build Rules: Build object files based on sources 
 ###############################################################################
 
+# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
+ifeq ($(OS),HP-UX)
+  DISABLE_AUTO_DEPENDENCIES=1
+endif
+
 # Provide rule sets for when dependency generation is enabled
 ifndef DISABLE_AUTO_DEPENDENCIES
 
@@ -1091,11 +1120,11 @@ endif
 ifdef DEBUG_RUNTIME
 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
        $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
-        @$(GCCAS) $< -o $@
+       $(Verb) $(GCCAS) $< -o $@
 else
 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
        $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
-       @$(GCCAS) -strip-debug $< -o $@
+       $(Verb) $(GCCAS) -strip-debug $< -o $@
 endif
 
 
@@ -1115,7 +1144,8 @@ ifdef TARGET
 
 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
            $(LLVM_SRC_ROOT)/lib/Target/Target.td \
-           $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td)
+           $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
+           $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td)
 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
@@ -1226,7 +1256,7 @@ $(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
 # source location and building them.
 $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
 $(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
-       $(Verb) $(CMP) -s $@ $< || \
+       $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
       ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
 
 $(LexFiles:%.l=$(ObjDir)/%.o) : \
@@ -1247,6 +1277,8 @@ ifneq ($(YaccFiles),)
 
 .PRECIOUS: $(YaccOutput)
 
+all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
+
 # Cancel built-in rules for yacc
 %.c: %.y 
 %.cpp: %.y
@@ -1258,12 +1290,22 @@ $(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.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
-       $(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp and $*.h (generated files)"
 
-YaccObjs   := $(patsubst %.y,$(ObjDir)/%.o,$(YaccFiles))
-$(YaccObjs): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
+# 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
+# mechanism so that people without flex can build LLVM by copying the .cvs files
+# to the source location and building them.
+$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
+$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
+       $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
+      ($(CP) $< $@; \
+       $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
+       $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
+
+
+$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
 
-YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.output)
+YaccOutput := $(YaccFiles:%.y=%.output)
 
 clean-local::
        -$(Verb) $(RM) -f $(YaccOutput)