Added some basic lint tools for C++ and generic lint tool applicable to all
[oota-llvm.git] / Makefile.rules
index 0074560ccd0d6668cec46b8fd6a755891e6574d1..49412d652d39a21c6f71d8a9cda5e0a8d5ea39d2 100644 (file)
@@ -41,7 +41,7 @@ VPATH=$(PROJ_SRC_DIR)
 # 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
+.SUFFIXES: .c .cpp .cc .h .hpp .lo .o .a .bc .td .ps .dot .ll
 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
 
 #--------------------------------------------------------------------
@@ -184,7 +184,7 @@ endif
 $(UserTargets):: $(PreConditions)
 
 all:: all-local
-clean:: clean-local 
+clean:: clean-local
 clean-all:: clean-local clean-all-local
 install:: install-local
 uninstall:: uninstall-local
@@ -274,7 +274,7 @@ endif
 # appropriate preprocessor symbols.
 ifdef ENABLE_EXPENSIVE_CHECKS
   BuildMode := $(BuildMode)+Checks
-  CPP.Defines += -D_GLIBCXX_DEBUG
+  CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
 endif
 
 ifeq ($(ENABLE_PIC),1)
@@ -309,29 +309,17 @@ endif
 #--------------------------------------------------------------------
 TargetMode :=
 ifeq ($(LLVM_CROSS_COMPILING),1)
-  ifeq ($(BUILD_COMPONENT),1)
-    TargetMode := Build
-  else
-    TargetMode := Host
-  endif
-  BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/Build/bin
+  BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
 endif
 
 ObjRootDir  := $(PROJ_OBJ_DIR)/$(BuildMode)
-# It is very important that ObjDir not have an extra trailing
-# slash. This ends up changing the rules so that dependency file (.d)
-# information is not used at all!
-ifeq ($(TargetMode),)
-  ObjDir      := $(ObjRootDir)
-else
-  ObjDir      := $(ObjRootDir)/$(TargetMode)
-endif
-LibDir      := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/lib
-ToolDir     := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/bin
-ExmplDir    := $(PROJ_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/examples
-LLVMLibDir  := $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/lib
-LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/bin
-LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/$(TargetMode)/examples
+ObjDir      := $(ObjRootDir)
+LibDir      := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
+ToolDir     := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
+ExmplDir    := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
+LLVMLibDir  := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
+LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
+LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
 CFERuntimeLibDir := $(LLVMGCCDIR)/lib
 
 #--------------------------------------------------------------------
@@ -347,7 +335,7 @@ LLVMAS   := $(LLVMToolDir)/llvm-as$(EXEEXT)
 endif
 ifndef TBLGEN
   ifeq ($(LLVM_CROSS_COMPILING),1)
-    TBLGEN   := $(BuildLLVMToolDir)/tblgen$(EXEEXT)
+    TBLGEN   := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
   else
     TBLGEN   := $(LLVMToolDir)/tblgen$(EXEEXT)
   endif
@@ -483,7 +471,7 @@ CPP.BaseFlags += -include llvm/System/Solaris.h
 endif
 
 LD.Flags      += -L$(LibDir) -L$(LLVMLibDir) 
-CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
+CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
 # All -I flags should go here, so that they don't confuse llvm-config.
 CPP.Flags     += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
                 $(patsubst %,-I%/include,\
@@ -547,14 +535,13 @@ endif
 
 ifndef SOURCES
   Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
-             $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
-             $(PROJ_SRC_DIR)/*.l))
+             $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
 else
   Sources := $(SOURCES)
 endif 
 
 ifdef BUILT_SOURCES
-Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
+Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
 endif
 
 BaseNameSources := $(sort $(basename $(Sources)))
@@ -594,16 +581,6 @@ ifdef DIRS
 SubDirs += $(DIRS)
 
 ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
-ifdef BUILD_TARGET_DIRS
-$(RecursiveTargets)::
-       $(Verb) for dir in $(BUILD_TARGET_DIRS); do \
-           if [ ! -f $$dir/Makefile ]; then \
-            $(MKDIR) $$dir; \
-              $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
-           fi; \
-            ($(MAKE) -C $$dir $@ BUILD_COMPONENT=1 NO_INSTALL=1 ) || exit 1; \
-          done
-endif
 $(RecursiveTargets)::
        $(Verb) for dir in $(DIRS); do \
          if [ ! -f $$dir/Makefile ]; then \
@@ -613,12 +590,6 @@ $(RecursiveTargets)::
          ($(MAKE) -C $$dir $@ ) || exit 1; \
        done
 else
-ifdef BUILD_TARGET_DIRS
-$(RecursiveTargets)::
-       $(Verb) for dir in $(BUILD_TARGET_DIRS); do \
-            ($(MAKE) -C $$dir $@ BUILD_COMPONENT=1 NO_INSTALL=1 ) || exit 1; \
-          done
-endif
 $(RecursiveTargets)::
        $(Verb) for dir in $(DIRS); do \
          ($(MAKE) -C $$dir $@ ) || exit 1; \
@@ -1028,7 +999,7 @@ $(LibName.A): $(ObjectsO) $(LibDir)/.dir
        $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
        -$(Verb) $(RM) -f $@
        $(Verb) $(Archive) $@ $(ObjectsO)
-       $(Verb) $(Ranlib) $@
+       -$(Verb) $(Ranlib) $@
 
 clean-local::
 ifneq ($(strip $(LibName.A)),)
@@ -1287,9 +1258,10 @@ $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
 ifdef TARGET
 
 TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
-           $(LLVM_SRC_ROOT)/lib/Target/Target.td \
-           $(LLVM_SRC_ROOT)/lib/Target/TargetCallingConv.td \
-           $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
+           $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
+           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
+           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
+           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
            $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
            $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
@@ -1302,7 +1274,7 @@ $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
 # INCFiles rule: All of the tblgen generated files are emitted to 
 # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc.  This allows
 # us to only "touch" the real file if the contents of it change.  IOW, if
-# tblgen is modified, all of the .inc.tmp files are regereated, but no
+# tblgen is modified, all of the .inc.tmp files are regenerated, but no
 # dependencies of the .inc files are, unless the contents of the .inc file
 # changes.
 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
@@ -1373,111 +1345,6 @@ clean-local::
 
 endif
 
-###############################################################################
-# LEX AND YACC: Provide rules for generating sources with lex and yacc
-###############################################################################
-
-#---------------------------------------------------------
-# Provide rules for generating a .cpp source file from 
-# (f)lex input sources. 
-#---------------------------------------------------------
-
-LexFiles  := $(filter %.l,$(Sources))
-
-ifneq ($(LexFiles),)
-
-# Cancel built-in rules for lex
-%.c: %.l
-%.cpp: %.l
-
-all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
-
-# Note the extra sed filtering here, used to cut down on the warnings emited 
-# by GCC.  The last line is a gross hack to work around flex aparently not 
-# being able to resize the buffer on a large token input.  Currently, for 
-# uninitialized string buffers in LLVM we can generate very long tokens, so 
-# this is a hack around it.
-# FIXME.  (f.e. char Buffer[10000] )
-$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
-       $(Echo) Flexing $*.l
-       $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
-       $(SED) 's/void yyunput/inline void yyunput/' | \
-       $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
-       $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
-         > $(PROJ_SRC_DIR)/$*.cpp
-
-# IFF the .l file has changed since it was last checked into SVN, copy the .l
-# file to .l.cvs and the generated .cpp file to .cpp.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.
-$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
-$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
-       $(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) : \
-$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
-
-clean-local::
-       -$(Verb) $(RM) -f $(LexOutput)
-
-endif
-
-#---------------------------------------------------------
-# Provide rules for generating a .cpp and .h source files 
-# from yacc (bison) input sources.
-#---------------------------------------------------------
-
-YaccFiles  := $(filter %.y,$(Sources))
-ifneq ($(YaccFiles),)
-
-.PRECIOUS: $(YaccOutput)
-
-all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
-
-# Cancel built-in rules for yacc
-%.c: %.y 
-%.cpp: %.y
-%.h: %.y
-
-# Rule for building the bison based parsers...
-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
-
-# IFF the .y file has changed since it was last checked into SVN, 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)
-
-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
-
-YaccOutput := $(YaccFiles:%.y=%.output)
-
-clean-local::
-       -$(Verb) $(RM) -f $(YaccOutput)
-endif
-
 ###############################################################################
 # OTHER RULES: Other rules needed
 ###############################################################################
@@ -1765,7 +1632,7 @@ install-local::
        $(Verb) $(MKDIR) $(PROJ_includedir)
        $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
          cd $(PROJ_SRC_ROOT)/include && \
-         for  hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
+         for  hdr in `find . -type f '!' '(' -name '*~' \
              -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
              grep -v .svn` ; do \
            instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
@@ -1790,7 +1657,7 @@ uninstall-local::
        $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
          cd $(PROJ_SRC_ROOT)/include && \
            $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
-             '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
+             '!' '(' -name '*~' -o -name '.#*' \
         -o -name '*.in' ')' -print ')' | \
         grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
          cd $(PROJ_SRC_ROOT)/include && \