From owner-freebsd-ports@FreeBSD.ORG Mon Sep 12 00:01:30 2005 Return-Path: X-Original-To: ports@freebsd.org Delivered-To: freebsd-ports@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7B02016A41F for ; Mon, 12 Sep 2005 00:01:30 +0000 (GMT) (envelope-from mi+kde@aldan.algebra.com) Received: from mail21.sea5.speakeasy.net (mail21.sea5.speakeasy.net [69.17.117.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0873543D46 for ; Mon, 12 Sep 2005 00:01:29 +0000 (GMT) (envelope-from mi+kde@aldan.algebra.com) Received: (qmail 13074 invoked from network); 12 Sep 2005 00:01:29 -0000 Received: from aldan.algebra.com (HELO blue.virtual-estates.net) ([216.254.65.224]) (envelope-sender ) by mail21.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 12 Sep 2005 00:01:29 -0000 Received: from blue.virtual-estates.net (blue [127.0.0.1]) by blue.virtual-estates.net (8.13.3/8.13.3) with ESMTP id j8C01SIb004987 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 11 Sep 2005 20:01:28 -0400 (EDT) (envelope-from mi+kde@aldan.algebra.com) Received: from localhost (localhost [[UNIX: localhost]]) by blue.virtual-estates.net (8.13.4/8.13.3/Submit) id j8C01RLZ004983 for ports@freebsd.org; Sun, 11 Sep 2005 20:01:27 -0400 (EDT) (envelope-from mi+kde@aldan.algebra.com) X-Authentication-Warning: blue.virtual-estates.net: mi set sender to mi+kde@aldan.algebra.com using -f From: Mikhail Teterin To: ports@freebsd.org Date: Sun, 11 Sep 2005 20:01:27 -0400 User-Agent: KMail/1.8.1 X-Face: %UW#n0|w>ydeGt/b@1-.UFP=K^~-:0f#O:D7whJ5G_<5143Bb3kOIs9XpX+"V+~$adGP:J|SLieM31VIhqXeLBli" Cc: Subject: please, review the attached bsd.port.mk patch X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Sep 2005 00:01:30 -0000 --Boundary-00=_XVMJDi6UlakwZXA Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello! The attached patch aims to replace the deep recursion in the bsd.port.mk's ALL-DEPENDS-LIST script with a shallow one (not sure if that's the right term, though). The new version handles circular dependencies nicely and (being shallow) will never require more than one sub-make to do the job. The existing algorithm stacks as many make processes as there are dependency-levels and is thus prone to hitting make's recursion and the kernel's maxproc limits on occasion. The existing algoritm also passes the already visited directories on command line, running the risk of hitting the maximum number of command-line arguments. An extra bonus is the substantially smaller number of subprocesses required for every iteration (no sed, grep, cut invokations) -- everything is done by the same single shell subprocess (plus make). Portmgr is being cautious in adopting this patch, even though the current implemention's use of grep may miss some dependencies (kde3 misses print/teTeX for example). It needs more testing -- please, oblige. To test simply merge the patch into your bsd.port.mk and try various recursive targets like clean, and fetch-recursive, or simply all-depends-list. Note that the list of directories is no longer sort-ed (the current version uses "sort -u" to get rid of duplicates), so the exact order in which directories are listed/visited may be different -- that's normal. Thanks for your time! -mi --Boundary-00=_XVMJDi6UlakwZXA Content-Type: text/x-diff; charset="us-ascii"; name="bsd.port.mk.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bsd.port.mk.diff" Index: bsd.port.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v retrieving revision 1.516 diff -U2 -r1.516 bsd.port.mk --- bsd.port.mk 28 Aug 2005 18:47:56 -0000 1.516 +++ bsd.port.mk 11 Sep 2005 14:55:17 -0000 @@ -4464,23 +4464,40 @@ # Dependency lists: both build and runtime, recursive. Print out directory names. +_DEPENDS=${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS} +_DEPEND_DIRS= ${_DEPENDS:C,^[^:]*:([^:]*),\1,} ${DEPENDS:C,:.*,,} + all-depends-list: -.if defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) || defined(RUN_DEPENDS) || defined(DEPENDS) @${ALL-DEPENDS-LIST} -.endif ALL-DEPENDS-LIST= \ - checked="${PARENT_CHECKED}"; \ - for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \ - if [ -d $$dir ]; then \ - if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \ - child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" all-depends-list); \ - for d in $$child; do ${ECHO_CMD} $$d; done; \ - ${ECHO_CMD} $$dir; \ - checked="$$dir $$child $$checked"; \ - fi; \ - else \ - ${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \ - fi; \ - done | ${SORT} -u + L="${_DEPEND_DIRS}"; \ + checked=""; \ + while [ -n "$$L" ]; do \ + l=""; \ + for d in $$L; do \ + case $$checked in \ + $$d\ *|*\ $$d\ *|*\ $$d) \ + continue;; \ + esac; \ + checked="$$checked $$d"; \ + if [ ! -d $$d ]; then \ + ${ECHO_MSG} "${PKGNAME}: \"$$d\" non-existent -- dependency list incomplete" >&2; \ + continue; \ + fi; \ + ${ECHO_CMD} $$d; \ + if ! children=$$(${MAKE} -C $$d -V _DEPEND_DIRS); then\ + ${ECHO_MSG} "${PKGNAME}: \"$$d\" erroneous -- dependency list incomplete" >&2; \ + continue; \ + fi; \ + for child in $$children; do \ + case "$$checked $$l" in \ + $$child\ *|*\ $$child\ *|*\ $$child) \ + continue;; \ + esac; \ + l="$$l $$child"; \ + done; \ + done; \ + L=$$l; \ + done .if !target(clean-depends) --Boundary-00=_XVMJDi6UlakwZXA--