+
+#------------------------------------------------------------------------
+# Prevent attempt to run dist targets from anywhere but the top level
+#------------------------------------------------------------------------
+ifneq ($(LEVEL),.)
+
+dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
+ $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
+
+else
+
+#------------------------------------------------------------------------
+# Provide the top level targets
+#------------------------------------------------------------------------
+
+dist-gzip:: $(DistTarGZip)
+
+$(DistTarGZip) : $(TopDistDir)/.makedistdir
+ $(Echo) Packing gzipped distribution tar file.
+ $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
+ $(GZIP) -c > "$(DistTarGZip)"
+
+dist-bzip2:: $(DistTarBZ2)
+
+$(DistTarBZ2) : $(TopDistDir)/.makedistdir
+ $(Echo) Packing bzipped distribution tar file.
+ $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
+ $(BZIP2) -c >$(DistTarBZ2)
+
+dist-zip:: $(DistZip)
+
+$(DistZip) : $(TopDistDir)/.makedistdir
+ $(Echo) Packing zipped distribution file.
+ $(Verb) rm -f $(DistZip)
+ $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
+
+dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
+ $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
+
+DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
+
+dist-check:: $(DistTarGZip)
+ $(Echo) Checking distribution tar file.
+ $(Verb) if test -d $(DistCheckDir) ; then \
+ $(RM) -rf $(DistCheckDir) ; \
+ fi
+ $(Verb) $(MKDIR) $(DistCheckDir)
+ $(Verb) cd $(DistCheckDir) && \
+ $(MKDIR) $(DistCheckDir)/build && \
+ $(MKDIR) $(DistCheckDir)/install && \
+ gunzip -c $(DistTarGZip) | $(TAR) xf - && \
+ cd build && \
+ ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
+ --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
+ $(MAKE) all && \
+ $(MAKE) check && \
+ $(MAKE) install && \
+ $(MAKE) uninstall && \
+ $(MAKE) dist && \
+ $(MAKE) clean && \
+ $(MAKE) dist-clean && \
+ $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
+
+dist-clean::
+ $(Echo) Cleaning distribution files
+ -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
+ $(DistCheckDir)
+
+endif
+
+#------------------------------------------------------------------------
+# Provide the recursive distdir target for building the distribution directory
+#------------------------------------------------------------------------
+distdir: $(DistDir)/.makedistdir
+$(DistDir)/.makedistdir: $(DistSources)
+ $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
+ if test -d "$(DistDir)" ; then \
+ find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
+ exit 1 ; \
+ fi ; \
+ $(EchoCmd) Removing old $(DistDir) ; \
+ $(RM) -rf $(DistDir); \
+ $(EchoCmd) Making 'all' to be sure. ; \
+ $(MAKE) all ; \
+ fi
+ $(Echo) Building Distribution Directory $(DistDir)
+ $(Verb) $(MKDIR) $(DistDir)
+ $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
+ srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
+ for file in $(DistFiles) ; do \
+ case "$$file" in \
+ $(BUILD_SRC_DIR)/*) \
+ file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
+ ;; \
+ $(BUILD_SRC_ROOT)/*) \
+ file=`echo "$$file" | \
+ sed "s#^$$srcrootstrip/##"` \
+ ;; \
+ esac; \
+ if test -f "$(BUILD_SRC_DIR)/$$file" || \
+ test -d "$(BUILD_SRC_DIR)/$$file" ; then \
+ from_dir="$(BUILD_SRC_DIR)" ; \
+ elif test -f "$$file" || test -d "$$file" ; then \
+ from_dir=. ; \
+ fi ; \
+ to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
+ if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
+ to_dir="$(DistDir)/$$dir"; \
+ $(MKDIR) "$$to_dir" ; \
+ else \
+ to_dir="$(DistDir)"; \
+ fi; \
+ mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
+ if test -n "$$mid_dir" ; then \
+ $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
+ fi ; \
+ if test -d "$$from_dir/$$file"; then \
+ if test -d "$(BUILD_SRC_DIR)/$$file" && \
+ test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
+ cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
+ fi; \
+ cp -pR $$from_dir/$$file $$to_dir || exit 1; \
+ elif test -f "$$from_dir/$$file" ; then \
+ cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
+ elif test -L "$$from_dir/$$file" ; then \
+ cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
+ elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
+ $(EchoCmd) "===== WARNING: Distribution Source " \
+ "$$from_dir/$$file Not Found!" ; \
+ elif test "$(Verb)" != '@' ; then \
+ $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
+ fi; \
+ done
+ $(Verb) for subdir in $(DistSubDirs) ; do \
+ if test "$$subdir" \!= "." ; then \
+ new_distdir="$(DistDir)/$$subdir" ; \
+ test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
+ ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
+ exit 1; \
+ fi; \
+ done
+ $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
+ $(EchoCmd) Eliminating CVS directories from distribution ; \
+ $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
+ $(MAKE) dist-hook ; \
+ $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
+ -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
+ -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
+ -o ! -type d ! -perm -444 -exec \
+ $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
+ || chmod -R a+r $(DistDir) ; \
+ fi
+
+# This is invoked by distdir target, define it as a no-op to avoid errors if not
+# defined by user.
+dist-hook::
+