From d741bcfa1612e418216450b1893bb0763341f24d Mon Sep 17 00:00:00 2001
From: John Criswell <criswell@uiuc.edu>
Date: Tue, 12 Aug 2003 18:51:51 +0000
Subject: [PATCH] Merged in changes between PRE11_ROOT and LLVM_PRE111 (i.e.
 the beginning of the pre-release 1.1 branch and pre-release 1.1.1). Made the
 USE_SPEC option work. Silenced unnecessary error output from the cmp command
 when checking for updates to lex/yacc generated files.  This fixes a problem
 where we get error messages the first time the file is generated. Fixed the
 distclean option.  It is now in the Makefile (i.e. only runs in the top level
 source directory), removes more files, and plays nicely with external project
 Makefiles.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7780 91177308-0d34-0410-b5e6-96231b3b80d8
---
 Makefile        |  8 ++++++++
 Makefile.common | 14 +++++---------
 Makefile.rules  | 14 +++++---------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/Makefile b/Makefile
index 6f31665eb68..b7824d50600 100644
--- a/Makefile
+++ b/Makefile
@@ -6,3 +6,11 @@ include $(LEVEL)/Makefile.common
 
 test :: all
 	cd test; $(MAKE)
+
+distclean:: clean
+	$(VERB) $(RM) -rf $(LEVEL)/Makefile.config \
+	                  $(LEVEL)/include/Config/config.h \
+	                  $(LEVEL)/autoconf/autom4te.cache \
+	                  $(LEVEL)/config.log \
+	                  $(LEVEL)/TAGS
+
diff --git a/Makefile.common b/Makefile.common
index dbb91afade4..21d86eb17e7 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -727,7 +727,7 @@ YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
           $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
           $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
               > $@.tmp
-	$(VERB) cmp $@ $@.tmp > /dev/null || ${MV} -f $@.tmp $@
+	$(VERB) cmp -s $@ $@.tmp > /dev/null || ${MV} -f $@.tmp $@
 	@# remove the output of flex if it didn't get moved over...
 	@rm -f $@.tmp
 
@@ -737,8 +737,8 @@ YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
 %.cpp %.h : %.y
 	@echo Bison\'ing $<...
 	$(VERB) $(BISON) -v -d -p $(<:%Parser.y=%) $*.y
-	$(VERB) cmp $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp
-	$(VERB) cmp $*.tab.h $*.h > /dev/null || ${MV} -f $*.tab.h $*.h
+	$(VERB) cmp -s $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp
+	$(VERB) cmp -s $*.tab.h $*.h   > /dev/null || ${MV} -f $*.tab.h $*.h
 	@# If the files were not updated, don't leave them lying around...
 	@rm -f $*.tab.c $*.tab.h
 
@@ -762,12 +762,6 @@ clean::
 	$(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
 	$(VERB) $(RM) -f $(LEX_OUTPUT) $(YACC_OUTPUT)
 
-distclean:: clean
-	$(VERB) (cd $(LLVM_SRC_ROOT); $(RM) -rf $(LEVEL)/Makefile.config \
-	            $(LEVEL)/include/Config/config.h \
-	            $(LEVEL)/autom4te.cache \
-	            $(LEVEL)/config.log)
-
 ###########################################################################
 # C/C++ Dependencies
 #	Define variables and rules that generate header file dependencies
@@ -795,7 +789,9 @@ $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir
 # are cleaning (this example taken from the GNU Make Manual).
 #
 ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),distclean)
 ifneq ($(SourceDepend),)
 -include $(SourceDepend)
 endif
 endif
+endif
diff --git a/Makefile.rules b/Makefile.rules
index dbb91afade4..21d86eb17e7 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -727,7 +727,7 @@ YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
           $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
           $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
               > $@.tmp
-	$(VERB) cmp $@ $@.tmp > /dev/null || ${MV} -f $@.tmp $@
+	$(VERB) cmp -s $@ $@.tmp > /dev/null || ${MV} -f $@.tmp $@
 	@# remove the output of flex if it didn't get moved over...
 	@rm -f $@.tmp
 
@@ -737,8 +737,8 @@ YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
 %.cpp %.h : %.y
 	@echo Bison\'ing $<...
 	$(VERB) $(BISON) -v -d -p $(<:%Parser.y=%) $*.y
-	$(VERB) cmp $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp
-	$(VERB) cmp $*.tab.h $*.h > /dev/null || ${MV} -f $*.tab.h $*.h
+	$(VERB) cmp -s $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp
+	$(VERB) cmp -s $*.tab.h $*.h   > /dev/null || ${MV} -f $*.tab.h $*.h
 	@# If the files were not updated, don't leave them lying around...
 	@rm -f $*.tab.c $*.tab.h
 
@@ -762,12 +762,6 @@ clean::
 	$(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
 	$(VERB) $(RM) -f $(LEX_OUTPUT) $(YACC_OUTPUT)
 
-distclean:: clean
-	$(VERB) (cd $(LLVM_SRC_ROOT); $(RM) -rf $(LEVEL)/Makefile.config \
-	            $(LEVEL)/include/Config/config.h \
-	            $(LEVEL)/autom4te.cache \
-	            $(LEVEL)/config.log)
-
 ###########################################################################
 # C/C++ Dependencies
 #	Define variables and rules that generate header file dependencies
@@ -795,7 +789,9 @@ $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir
 # are cleaning (this example taken from the GNU Make Manual).
 #
 ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),distclean)
 ifneq ($(SourceDepend),)
 -include $(SourceDepend)
 endif
 endif
+endif