diff options
author | dmcmahill <dmcmahill@pkgsrc.org> | 2000-06-28 16:05:44 +0000 |
---|---|---|
committer | dmcmahill <dmcmahill@pkgsrc.org> | 2000-06-28 16:05:44 +0000 |
commit | fb223bab1697ad6018f5828230398f4df0382cc7 (patch) | |
tree | 728cb0f284c1151fe0cedd86e2b620bd18eed25b /mk | |
parent | df85410ce6c7fb872c6f88d3bac41044e1c2cf2f (diff) | |
download | pkgsrc-fb223bab1697ad6018f5828230398f4df0382cc7.tar.gz |
rework how the DEPENDS tree is traversed in the 'clean-depends' target.
now, each branch is only traversed once instead of possibly multiple times.
depending on the size of the DEPENDS list, the speedup is _huge_. For example
make clean CLEANDEPENDS=yes
in x11/gnome now takes around 12 minutes instead of 4 hours on a DECstation
5000/240.
Thanks to Hubert for help and suggestions on this. Look for more changes to
come as this same problem exists in other areas.
Diffstat (limited to 'mk')
-rw-r--r-- | mk/bsd.pkg.mk | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk index f69c9ba2f81..7abaaabcd00 100644 --- a/mk/bsd.pkg.mk +++ b/mk/bsd.pkg.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkg.mk,v 1.489 2000/06/28 15:02:31 agc Exp $ \ +# $NetBSD: bsd.pkg.mk,v 1.490 2000/06/28 16:05:44 dmcmahill Exp $ \ # # This file is in the public domain. # @@ -2027,19 +2027,44 @@ clean: pre-clean .if !target(clean-depends) clean-depends: -.if defined(BUILD_DEPENDS) || defined(DEPENDS) || defined(RUN_DEPENDS) ${_PKG_SILENT}${_PKG_DEBUG} \ - for dir in `${ECHO} ${BUILD_DEPENDS:C/^[^:]*://:C/:.*//} \ - ${DEPENDS:C/^[^:]*://:C/:.*//} \ - ${RUN_DEPENDS:C/^[^:]*://:C/:.*//} | \ - ${TR} '\040' '\012' | sort -u`; do \ - cd ${.CURDIR}/$$dir && \ - ${MAKE} ${MAKEFLAGS} CLEANDEPENDS=${CLEANDEPENDS} clean;\ + for i in `${MAKE} ${MAKEFLAGS} clean-depends-list | ${SED} -e 's;\.\./[^ ]*; ;g' | ${TR} -s "[:space:]" "\n" | sort -u` ;\ + do \ + cd ${.CURDIR}/../../$$i && \ + ${MAKE} ${MAKEFLAGS} CLEANDEPENDS=NO clean; \ done .endif -.endif +# The clean-depends-list target will produce a list of all +# BUILD_DEPENDS, RUN_DEPENDS, and DEPENDS packages. +# As each *DEPENDS package is visited, it is added to the +# CLEAN_DEPENDS_LIST_SEEN variable. Once a pkg is in the list +# it will not be visited again. This prevents traversing the same +# part of the dependency tree multiple times. Each depending package +# ends up in the list twice. Once as the relative path from the depending +# package and once as the path from pkgsrc. Eg, "../../foo/bar foo/bar" +# The "../../foo/bar" version is later removed from the list in the +# clean-depends target. The remaining bit of redundancy is that some +# packages list their depends as "../bar" instead of "../../foo/bar" +# In this case its possible for a dependency to be visited twice. + +.if !target(clean-depends-list) +clean-depends-list: + @for dir in `${ECHO} ${BUILD_DEPENDS:C/^[^:]*://:C/:.*//} \ + ${DEPENDS:C/^[^:]*://:C/:.*//} \ + ${RUN_DEPENDS:C/^[^:]*://:C/:.*//} | \ + ${TR} '\040' '\012' `; do \ + case "$$CLEAN_DEPENDS_LIST_SEEN" in \ + *" "$$dir" "*) ;; \ + *) \ + CLEAN_DEPENDS_LIST_SEEN=" $$dir `cd ${.CURDIR} ; cd $$dir && ${MAKE} ${MAKEFLAGS} CLEAN_DEPENDS_LIST_SEEN="$$CLEAN_DEPENDS_LIST_SEEN" clean-depends-list)`";\ + ;; \ + esac \ + done ; \ + echo " ${PKGPATH} $$CLEAN_DEPENDS_LIST_SEEN" +.endif + .if !target(pre-distclean) pre-distclean: @${DO_NADA} @@ -2761,7 +2786,7 @@ COMMON_DIRS!= ${AWK} 'BEGIN { \ .if !target(print-PLIST) print-PLIST: - @${ECHO} '@comment $$NetBSD: bsd.pkg.mk,v 1.489 2000/06/28 15:02:31 agc Exp $$' + @${ECHO} '@comment $$NetBSD: bsd.pkg.mk,v 1.490 2000/06/28 16:05:44 dmcmahill Exp $$' @${FIND} ${PREFIX}/. -newer ${EXTRACT_COOKIE} \! -type d \ | ${SED} s@${PREFIX}/./@@ \ | sort \ |