Switch the top level pkgsrc 'readme' and 'cdrom-readme' targets to use the trunk
authordmcmahill <dmcmahill@pkgsrc.org>
Sun, 05 Jan 2003 13:37:15 +0000
branchtrunk
changeset 37427 0f7cbd2a050c
parent 37426 1291c11896e4
child 37428 308922003b27
Switch the top level pkgsrc 'readme' and 'cdrom-readme' targets to use the new and much more efficient code. Previously a 'make readme' took over 3 weeks on my SS5 and now takes < 3 hours. The number of make calls has been reduced from somewhere over 1,000,000 to one per package which is around 3,000. The mk/scripts/mkreadme script does all the work now. This script has been used in standalone form for a month or two on ftp.netbsd.org and has had no problem.
Makefile
mk/bsd.pkg.subdir.mk
--- a/Makefile	Sun Jan 05 13:26:46 2003 +0000
+++ b/Makefile	Sun Jan 05 13:37:15 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.50 2002/12/15 02:49:37 salo Exp $
+# $NetBSD: Makefile,v 1.51 2003/01/05 13:37:15 dmcmahill Exp $
 #
 
 .include "mk/bsd.prefs.mk"
@@ -51,6 +51,40 @@
 
 PKGSRCTOP=	yes
 
+
+# If PACKAGES is set to the default (${_PKGSRCDIR}/packages), the current
+# ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory
+# structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed.
+# The PKG_URL is set from FTP_PKG_URL_* or CDROM_PKG_URL_*, depending on
+# the target used to generate the README.html file.
+.PHONY: README.html
+_README_TYPE_FLAG?=	none
+README.html: .PRECIOUS
+.if ${_README_TYPE_FLAG} == "--ftp" || ${_README_TYPE_FLAG} == "--cdrom"
+	@if [ -e ${PACKAGES} ]; then					\
+		cd ${PACKAGES};						\
+		case `pwd` in						\
+			${.CURDIR}/packages)				\
+				MULTIARCH=;				\
+				;;					\
+			*)						\
+				MULTIARCH=--multi-arch;			\
+				;;					\
+		esac;							\
+		cd ${.CURDIR} ;						\
+	fi;								\
+	${ENV} TMPDIR=${TMPDIR:U/tmp}/mkreadme	 			\
+		BMAKE=${MAKE} AWK=${AWK} EXPR=${EXPR} 			\
+		./mk/scripts/mkreadme --pkgsrc ${.CURDIR} 		\
+		--packages ${PACKAGES} ${_README_TYPE_FLAG} $$MULTIARCH \
+		--prune 
+.else
+	@${ECHO} "ERROR:  please do not use the README.html target directly."
+	@${ECHO} "        Instead use either the \"readme\" or \"cdrom-readme\""
+	@${ECHO} "        target."
+	@${FALSE}
+.endif
+
 .include "mk/bsd.pkg.subdir.mk"
 
 # the bulk-cache and clean-bulk-cache targets are a global-pkgsrc
--- a/mk/bsd.pkg.subdir.mk	Sun Jan 05 13:26:46 2003 +0000
+++ b/mk/bsd.pkg.subdir.mk	Sun Jan 05 13:37:15 2003 +0000
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.pkg.subdir.mk,v 1.49 2002/10/20 22:19:22 wiz Exp $
+#	$NetBSD: bsd.pkg.subdir.mk,v 1.50 2003/01/05 13:37:16 dmcmahill Exp $
 #	Derived from: FreeBSD Id: bsd.port.subdir.mk,v 1.19 1997/03/09 23:10:56 wosch Exp 
 #	from: @(#)bsd.subdir.mk	5.9 (Berkeley) 2/1/91
 #
@@ -114,13 +114,13 @@
 .if !target(readme)
 readme:
 	@if [ -f README.html ]; then ${MV} -f README.html README.html.BAK ; fi
-	@${MAKE} ${MAKEFLAGS} README.html _README_TYPE=$@
+	@${MAKE} ${MAKEFLAGS} README.html _README_TYPE_FLAG=--ftp _README_TYPE=$@
 .endif
 
 .if !target(cdrom-readme)
 cdrom-readme:
 	@if [ -f README.html ]; then ${MV} -f README.html README.html.BAK ; fi
-	@${MAKE} ${MAKEFLAGS} README.html _README_TYPE=$@
+	@${MAKE} ${MAKEFLAGS} README.html _README_TYPE_FLAG=--cdrom README_TYPE=$@
 .endif
 
 .if defined(PKGSRCTOP)
@@ -131,6 +131,7 @@
 
 HTMLIFY=	${SED} -e 's/&/\&amp;/g' -e 's/>/\&gt;/g' -e 's/</\&lt;/g'
 
+.if !target(README.html)
 README.html: .PRECIOUS
 	@> $@.tmp
 .for entry in ${SUBDIR}
@@ -169,6 +170,7 @@
 .for subdir in ${SUBDIR}
 	@cd ${subdir} && ${MAKE} ${MAKEFLAGS} "_THISDIR_=${_THISDIR_}${.CURDIR:T}/" ${_README_TYPE}
 .endfor
+.endif
 
 show-comment:
 	@if [ "${COMMENT}" ]; then					\