From 0a25e8ed81e9dac780cbfde4358ceec78f7e243c Mon Sep 17 00:00:00 2001
From: "slamm%netscape.com" <slamm%netscape.com>
Date: Fri, 23 Apr 1999 20:46:22 +0000
Subject: [PATCH] Improve recovering from conflicting objdir/srcdir builds. Add
 cleansrcdir target to client.mk. Update the objdir vs. srcdir build
 instructions in configure.

---
 build/autoconf/clean-config.sh | 15 +++++++++---
 client.mk                      | 17 +++++++++++++-
 configure.in                   | 42 ++++++++++++++++++----------------
 3 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/build/autoconf/clean-config.sh b/build/autoconf/clean-config.sh
index 9dd0c76440851..20f8138f0db94 100755
--- a/build/autoconf/clean-config.sh
+++ b/build/autoconf/clean-config.sh
@@ -35,12 +35,21 @@ if [ ! -f configure.in ]; then
   exit 1
 fi
 
-MOZ_EDITOR=1 MOZ_MAILNEWS=1 . allmakefiles.sh
+if [ -f mailnews/makefiles ]; then
+  MOZ_MAIL_NEWS=1
+  export MOZ_MAIL_NEWS
+fi
+
+if [ -d editor ]; then
+  MOZ_EDITOR=1
+  export MOZ_EDITOR
+fi
+
+. allmakefiles.sh
+
 rm -fr $MAKEFILES \
     config-defs.h \
     config.cache \
     config.log \
     config.status \
     $NULL
-
-echo "Removed all files generated by configure." 2>&1
diff --git a/client.mk b/client.mk
index 7817736fc4003..55706ee62634d 100644
--- a/client.mk
+++ b/client.mk
@@ -265,7 +265,22 @@ clean realclean:
 	cd $(OBJDIR); $(MAKE) $@
 	rm -fr $(ALL_TRASH)
 
+cleansrcdir:
+	@cd $(TOPSRCDIR); \
+	if [ -f Makefile ]; then \
+	  $(MAKE) realclean && _skip_find=1; \
+	fi; \
+	if [ ! "$$_skip_find" ]; then \
+	  echo "Removing object files from srcdir..."; \
+	  rm -fr `find . -type d \( -name .deps -print -o -name CVS \
+	          -o -exec test ! -d {}/CVS \; \) -prune \
+	          -o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
+	fi; \
+	echo "Removing files generated by configure..."; \
+	build/autoconf/clean-config.sh;
+
+
 # (! IS_FIRST_CHECKOUT)
 endif
 
-.PHONY: checkout depend build clean realclean pull_all build_all clobber clobber_all pull_and_build_all
+.PHONY: checkout depend build clean realclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all
diff --git a/configure.in b/configure.in
index 5dbc8f989bd03..9ea342e973a44 100644
--- a/configure.in
+++ b/configure.in
@@ -67,35 +67,37 @@ MISSING_X=
 MISSING_MOTIF=
 MISSING_GTK=
 
-dnl Check for invalid object directory setup.
-dnl    If the tree has already been built in topsrcdir,
-dnl    do not allow it to be built in a separate object 
-dnl    directory unless the src tree is cleaned up.
-dnl ========================================================
+dnl Do not allow a separate objdir build if a srcdir build exists.
+dnl ==============================================================
 _topsrcdir=`cd \`dirname $0\`; pwd`
 _objdir=`pwd`
 if test "$_topsrcdir" != "$_objdir"
 then
   # Check for a couple representative files in the source tree
+  _conflict_files=
   for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
     if test -f $file; then
-      cat 1>&2 <<-EOF
-	Error: Your source tree contains the file,
-	          $file
-	
-	       This is an indication that you previously built in the source
-	       tree. Files built in the source tree can confuse the separate
-	       objdir build.
-	
-	       You can clean up the source tree with the following steps:
-	         1. cd $_topsrcdir
-	         2. gmake realclean; build/autoconf/clean-config.sh
-	
-	EOF
-      exit 1
-      break
+      _conflict_files="$_conflict_files $file"
     fi
   done
+  if test "$_conflict_files"; then
+    echo "***"
+    echo "*   Your source tree contains these files:"
+    for file in $_conflict_files; do
+      echo "*         $file"
+    done
+    cat 1>&2 <<-EOF
+	*   This indicates that you previously built in the source tree.
+	*   A source tree build can confuse the separate objdir build.
+	*
+	*   To clean up the source tree:
+	*     1. cd $_topsrcdir
+	*     2. gmake -f client.mk cleansrcdir
+	***
+	EOF
+    exit 1
+    break
+  fi
 fi
 
 dnl Checks for programs.
-- 
GitLab