Trying that again.
[oota-llvm.git] / Makefile.rules
index 13efb39ffa216c2cf9294389183ebd69263fda97..e3a1009b862bc5c4fcae94120ae43a5108335d24 100644 (file)
@@ -2,8 +2,8 @@
 #
 #                     The LLVM Compiler Infrastructure
 #
-# This file was developed by the LLVM research group and is distributed under
-# the University of Illinois Open Source License. See LICENSE.TXT for details.
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
 # 
 #===------------------------------------------------------------------------===#
 #
@@ -23,7 +23,7 @@ RecursiveTargets := all clean clean-all install uninstall install-bytecode
 LocalTargets     := all-local clean-local clean-all-local check-local \
                     install-local printvars uninstall-local \
                    install-bytecode-local
-TopLevelTargets  := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
+TopLevelTargets  := check dist dist-check dist-clean dist-gzip dist-bzip2 \
                     dist-zip
 UserTargets      := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
 InternalTargets  := preconditions distdir dist-hook
@@ -38,7 +38,7 @@ InternalTargets  := preconditions distdir dist-hook
 VPATH=$(PROJ_SRC_DIR)
 
 #--------------------------------------------------------------------
-# Reset the list of suffixes we know how to build
+# Reset the list of suffixes we know how to build.
 #--------------------------------------------------------------------
 .SUFFIXES:
 .SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot .ll
@@ -199,6 +199,7 @@ install-bytecode:: install-bytecode-local
 # Variables derived from configuration we are building
 #--------------------------------------------------------------------
 
+CPP.Defines :=
 # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
 # this can be overridden on the make command line.
 ifneq ($(OS),MingW)
@@ -212,6 +213,7 @@ ifdef ENABLE_PROFILING
   CXX.Flags := $(OPTIMIZE_OPTION) -pg -g
   C.Flags   := $(OPTIMIZE_OPTION) -pg -g
   LD.Flags  := $(OPTIMIZE_OPTION) -pg -g
+  KEEP_SYMBOLS := 1
 else
   ifeq ($(ENABLE_OPTIMIZED),1)
     BuildMode := Release
@@ -244,15 +246,26 @@ ifndef REQUIRES_EH
   CXX.Flags += -fno-exceptions
 endif
 
+# IF REQUIRES_RTTI=1 is specified then don't disable run-time type id
+ifndef REQUIRES_RTTI
+#  CXX.Flags += -fno-rtti
+endif
+
 # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
 # then disable assertions by defining the appropriate preprocessor symbols.
 ifdef DISABLE_ASSERTIONS
   BuildMode := $(BuildMode)-Asserts
-  CXX.Flags += -DNDEBUG
-  C.Flags   += -DNDEBUG
+  CPP.Defines += -DNDEBUG
 else
-  CXX.Flags += -D_DEBUG
-  C.Flags   += -D_DEBUG
+  CPP.Defines += -D_DEBUG
+endif
+
+# If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or 
+# configured), then enable expensive checks by defining the 
+# appropriate preprocessor symbols.
+ifdef ENABLE_EXPENSIVE_CHECKS
+  BuildMode := $(BuildMode)+Checks
+  CPP.Defines += -D_GLIBCXX_DEBUG
 endif
 
 ifeq ($(ENABLE_PIC),1)
@@ -262,7 +275,8 @@ endif
 
 CXX.Flags     += $(CXXFLAGS) -Woverloaded-virtual
 C.Flags       += $(CFLAGS)
-CPP.BaseFlags += $(CPPFLAGS)
+CPP.Defines   += $(CPPFLAGS)
+CPP.BaseFlags += $(CPP.Defines)
 LD.Flags      += $(LDFLAGS)
 AR.Flags      := cru
 LibTool.Flags := --tag=CXX
@@ -1065,23 +1079,28 @@ ifndef DISABLE_AUTO_DEPENDENCIES
 # Create .lo files in the ObjDir directory from the .cpp and .c files...
 #---------------------------------------------------------
 
+DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
+         -MT "$(ObjDir)/$*.lo" -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
+         
+# If the build succeeded, move the dependency file over.  If it failed, put an
+# empty file there.
+DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
+                  else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
+
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
        $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
-       $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
-         then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
-         else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
+       $(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
+               $(DEPEND_MOVEFILE)
 
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
        $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
-       $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
-       then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
-       else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
+       $(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
+               $(DEPEND_MOVEFILE)
 
 $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
        $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
-       $(Verb) if $(MAYBE_PIC_Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
-       then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
-       else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
+       $(Verb) if $(MAYBE_PIC_Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
+               $(DEPEND_MOVEFILE)
 
 #---------------------------------------------------------
 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
@@ -1354,15 +1373,12 @@ all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
 %.h: %.y
 
 # Rule for building the bison based parsers...
-$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
 ifneq ($(BISON),)
+$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
        $(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
@@ -1375,6 +1391,16 @@ $(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
        $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
        $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
 
+else
+$(PROJ_SRC_DIR)/%.cpp : $(PROJ_SRC_DIR)/%.cpp.cvs
+       $(Echo) "Bison of $*.y SKIPPED, bison not found -- copying .cpp.cvs"
+       $(Verb)$(CP) $(PROJ_SRC_DIR)/$*.cpp.cvs $(PROJ_SRC_DIR)/$*.cpp
+
+$(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.h.cvs
+       $(Echo) "Bison of $*.y SKIPPED, bison not found -- copying .h.cvs"
+       $(Verb)$(CP) $(PROJ_SRC_DIR)/$*.h.cvs $(PROJ_SRC_DIR)/$*.h
+endif
+
 
 $(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
 
@@ -1418,25 +1444,6 @@ endif
 clean-all-local::
        -$(Verb) $(RM) -rf Debug Release Profile
 
-# Build tags database for Emacs/Xemacs:
-tags:: TAGS CTAGS
-
-TAGS: 
-       find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
-          $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
-          $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
-          $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
-        -name '*.cpp' -o -name '*.h' | \
-        $(ETAGS) $(ETAGSFLAGS) -
-
-CTAGS:
-       find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
-          $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
-          $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
-          $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
-          \( -name '*.cpp' -o -name '*.h' \) -print | \
-          ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
-
 
 ###############################################################################
 # DEPENDENCIES: Include the dependency files if we should
@@ -1450,7 +1457,7 @@ ifneq ($(strip $(filter-out clean clean-local dist-clean,$(MAKECMDGOALS)))),)
 DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
 DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
 
--include /dev/null $(DependFiles)
+-include $(DependFiles) ""
 
 endif
 
@@ -1691,7 +1698,8 @@ install-local::
        $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
          cd $(PROJ_SRC_ROOT)/include && \
          for  hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
-             -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
+             -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
+             grep -v .svn` ; do \
            instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
            if test \! -d "$$instdir" ; then \
              $(EchoCmd) Making install directory $$instdir ; \
@@ -1724,6 +1732,20 @@ uninstall-local::
 endif
 endif
 
+check-line-length:
+       @egrep -n '.{81}' $(Sources)
+
+check-for-tabs:
+       @egrep -n '     ' $(Sources)
+check-footprint:
+       @ls -l $(LibDir) | awk '\
+         BEGIN { sum = 0; } \
+               { sum += $$5; } \
+         END   { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
+       @ls -l $(ToolDir) | awk '\
+         BEGIN { sum = 0; } \
+               { sum += $$5; } \
+         END   { printf("Programs:  %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
 #------------------------------------------------------------------------
 # Print out the directories used for building
 #------------------------------------------------------------------------