From 9a700ec7a58557e046b0089197f8b50172aa08c5 Mon Sep 17 00:00:00 2001 From: espie Date: Sat, 2 Aug 2003 09:53:27 +0000 Subject: [PATCH] put _flavor_fragment into a separate file, that's included from both bsd.port.mk and bsd.port.subdir.mk. Make sure flavors are properly separated. Change the way bsd.port.subdir.mk works, slightly: always set full directories. - SKIPDIR with full paths will work. - all dirs are displayed as full package specs. Generate complete html files. --- infrastructure/mk/bsd.port.mk | 69 +++++--------- infrastructure/mk/bsd.port.subdir.mk | 132 ++++++++------------------- infrastructure/mk/pkgpath.mk | 59 ++++++++++++ infrastructure/templates/README.port | 2 + 4 files changed, 120 insertions(+), 142 deletions(-) create mode 100644 infrastructure/mk/pkgpath.mk diff --git a/infrastructure/mk/bsd.port.mk b/infrastructure/mk/bsd.port.mk index abe46474524..fa78d42cbf3 100644 --- a/infrastructure/mk/bsd.port.mk +++ b/infrastructure/mk/bsd.port.mk @@ -1,6 +1,6 @@ #-*- mode: Makefile; tab-width: 4; -*- # ex:ts=4 sw=4 filetype=make: -# $OpenBSD: bsd.port.mk,v 1.574 2003/08/01 09:07:06 espie Exp $ +# $OpenBSD: bsd.port.mk,v 1.575 2003/08/02 09:53:27 espie Exp $ # $FreeBSD: bsd.port.mk,v 1.264 1996/12/25 02:27:44 imp Exp $ # $NetBSD: bsd.port.mk,v 1.62 1998/04/09 12:47:02 hubertf Exp $ # @@ -538,13 +538,8 @@ ${_PACKAGE_COOKIE${_s}}: ${_PACKAGE_COOKIE_DEPS} .PRECIOUS: ${_PACKAGE_COOKIES} ${_INSTALL_COOKIE} -.if !defined(PKGPATH) -_PORTSDIR!= cd ${PORTSDIR} && pwd -P -_CURDIR!= cd ${.CURDIR} && pwd -P -PKGPATH=${_CURDIR:S,${_PORTSDIR}/,,} -.endif +.include "${PORTSDIR}/infrastructure/mk/pkgpath.mk" -PKGDEPTH=${PKGPATH:C|[^./][^/]*|..|g} .if empty(SUBPACKAGE) FULLPKGPATH=${PKGPATH}${_FLAVOR_EXT2:S/-/,/g} .else @@ -1073,44 +1068,6 @@ addsum: fetch-all # Dependency checking ################################################################ -# Code to invoke to split dir,-multi,flavor - -_flavor_fragment= \ - multi=''; flavor=''; sawflavor=false; \ - case "$$dir" in \ - *,*) \ - IFS=,; first=true; for i in $$dir; do \ - if $$first; then \ - dir=$$i; first=false; \ - else \ - case X"$$i" in \ - X-*) \ - multi="$$i";; \ - *) \ - sawflavor=true; \ - flavor="$$flavor $$i";; \ - esac \ - fi; \ - done; unset IFS;; \ - esac; \ - toset="PKGPATH=$$dir"; \ - case X$$multi in "X");; *) \ - toset="$$toset SUBPACKAGE=\"$$multi\"";; \ - esac; \ - if $$sawflavor; then \ - toset="$$toset FLAVOR=\"$$flavor\""; \ - fi; \ - cd ${PORTSDIR}; \ - if [ -L $$dir ]; then \ - echo 1>&2 ">> Broken dependency: $$dir is a symbolic link"; \ - exit 1; \ - fi; \ - if cd $$dir 2>/dev/null || cd mystuff/$$dir 2>/dev/null; then \ - :; \ - else \ - echo 1>&2 ">> Broken dependency: $$dir non existent"; \ - exit 1; \ - fi # Various dependency styles @@ -2119,8 +2076,6 @@ readme readmes: .endif -HTMLIFY= sed -e 's/&/\&/g' -e 's/>/\>/g' -e 's/$@.tmp-comment @echo ${FULLPKGNAME${SUBPACKAGE}} | ${HTMLIFY} > $@.tmp3 @@ -2129,12 +2084,29 @@ ${FULLPKGNAME${SUBPACKAGE}}.html: .else @echo "" >$@.tmp4 .endif +.if defined(MULTI_PACKAGES) +. if empty(SUBPACKAGE) + @echo "

Subpackages

" >$@.tmp-subpackages + @echo "" >>$@.tmp-subpackages +. else + @name=`unset SUBPACKAGE; ${MAKE} _print-packagename _FULL_PACKAGE_NAME=No`; \ + echo "

Subpackage of $$name

" >$@.tmp-subpackages +. endif +.else + @>$@.tmp-subpackages +.endif .for _I in build run . if !empty(_ALWAYS_DEP) || !empty(_${_I:U}_DEP) @cd ${.CURDIR} && ${MAKE} full-${_I}-depends _FULL_PACKAGE_NAME=Yes| \ while read n; do \ j=`dirname $$n|${HTMLIFY}`; k=`basename $$n|${HTMLIFY}`; \ - echo "
  • $$k"; \ + echo "
  • $$k"; \ done >$@.tmp-${_I} . else @echo "
  • none" >$@.tmp-${_I} @@ -2148,6 +2120,7 @@ ${FULLPKGNAME${SUBPACKAGE}}.html: -e '/%%HOMEPAGE%%/r$@.tmp4' -e '//d' \ -e '/%%BUILD_DEPENDS%%/r$@.tmp-build' -e '//d' \ -e '/%%RUN_DEPENDS%%/r$@.tmp-run' -e '//d' \ + -e '/%%SUBPACKAGES%%/r$@.tmp-subpackages' -e '//d' \ >> $@ @rm -f $@.tmp* diff --git a/infrastructure/mk/bsd.port.subdir.mk b/infrastructure/mk/bsd.port.subdir.mk index d12e76ecea0..eb9032febad 100644 --- a/infrastructure/mk/bsd.port.subdir.mk +++ b/infrastructure/mk/bsd.port.subdir.mk @@ -1,5 +1,7 @@ +#-*- mode: Makefile; tab-width: 4; -*- +# ex:ts=4 sw=4 filetype=make: # from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 -# $OpenBSD: bsd.port.subdir.mk,v 1.51 2003/07/29 22:27:09 espie Exp $ +# $OpenBSD: bsd.port.subdir.mk,v 1.52 2003/08/02 09:53:27 espie Exp $ # FreeBSD Id: bsd.port.subdir.mk,v 1.20 1997/08/22 11:16:15 asami Exp # # The include file contains the default targets @@ -38,6 +40,7 @@ .if !defined(BSD_OWN_MK) . include .endif +PORTSDIR ?= /usr/ports .if defined(show) .MAIN: show @@ -55,95 +58,37 @@ STRIP?= -s OPSYS= OpenBSD .endif -.if !defined(PKGPATH) -_PORTSDIR!= cd ${PORTSDIR} && pwd -P -_CURDIR!= cd ${.CURDIR} && pwd -P -. if ${_PORTSDIR} == ${_CURDIR} -PKGPATH= -. else -PKGPATH=${_CURDIR:S,${_PORTSDIR}/,,} -. endif -.endif -.if empty(PKGPATH) -_SEP= -.else -_SEP=/ -.endif +.include "${PORTSDIR}/infrastructure/mk/pkgpath.mk" ECHO_MSG?= echo -RECURSIVE_FETCH_LIST?= No - REPORT_PROBLEM?=exit 1 -# Need an actual list of all subdirs to complete SKIPPED -_ALL_SUBDIR:=${SUBDIR} -SKIPPED= -.if defined(SKIPDIR) -. for i in ${SKIPDIR:S/:/,/} -SKIPPED+=${_ALL_SUBDIR:M$i} -SUBDIR:=${SUBDIR:N$i} -. endfor +# create a full list of SUBDIRS... +.if empty(PKGPATH) +FULLSUBDIR:=${SUBDIR} +.else +FULLSUBDIR:=${SUBDIR:S@^@${PKGPATH}/@g} .endif +SKIPPED= +.for i in ${SKIPDIR} +SKIPPED+=${FULLSUBDIR:M$i} +SUBDIR:=${FULLSUBDIR:N$i} +.endfor + + _SUBDIRUSE: .USE . for i in ${SKIPPED} - @echo "===> ${PKGPATH}${_SEP}$i skipped" + @echo "===> $i skipped" . endfor - @for dir in ${SUBDIR}; do \ - multi=''; flavor=''; sawflavor=false; toset=''; \ - case "$$dir" in \ - *[,:]*) \ - IFS=',:'; first=true; insert=''; for i in $$dir; do \ - if $$first; then \ - dir=$$i; first=false; \ - else \ - case X"$$i" in \ - X-*) \ - multi="$$i";; \ - *) \ - sawflavor=true; \ - flavor="$$flavor$$insert$$i"; \ - insert=' ';; \ - esac \ - fi; \ - done; unset IFS; \ - case X$$multi in "X");; *) \ - toset="$$toset SUBPACKAGE=\"$$multi\"";; \ - esac; \ - esac; \ - if $$sawflavor; then \ - toset="$$toset FLAVOR=\"$$flavor\""; \ - display=" ($$flavor)"; \ - else \ - display=''; \ - fi; \ - if cd ${.CURDIR}/$${dir}.${MACHINE} 2>/dev/null; then \ - edir=$${dir}.${MACHINE}; \ - elif cd ${.CURDIR}/$${dir} 2>/dev/null; then \ - edir=$${dir}; \ - else \ - ${ECHO_MSG} "===> ${PKGPATH}${_SEP}$${dir} non-existent"; \ - ${REPORT_PROBLEM}; \ - continue; \ - fi; \ - ${ECHO_MSG} "===> ${PKGPATH}${_SEP}$${edir}$$display"; \ - set +e; \ - if eval $$toset \ - PKGPATH=${PKGPATH}${_SEP}$$edir \ - RECURSIVE_FETCH_LIST=${RECURSIVE_FETCH_LIST} \ - ${MAKE} ${.TARGET}; \ - then :; else ${REPORT_PROBLEM}; fi; \ - set -e; \ - done - -${SUBDIR}:: - @if test -d ${.TARGET}.${MACHINE}; then \ - cd ${.CURDIR}/${.TARGET}.${MACHINE}; \ - else \ - cd ${.CURDIR}/${.TARGET}; \ - fi; \ - ${MAKE} all +. for d in ${FULLSUBDIR} + @dir=$d; ${_flavor_fragment}; \ + ${ECHO_MSG} "===> $d"; \ + set +e; \ + if eval $$toset ${MAKE} ${.TARGET}; then :; \ + else ${REPORT_PROBLEM}; fi +.endfor .for __target in all fetch fetch-list package fake extract configure \ build clean describe distclean deinstall install \ @@ -163,7 +108,6 @@ readme: @rm -f README.html @${MAKE} README.html -PORTSDIR ?= /usr/ports TEMPLATES ?= ${PORTSDIR}/infrastructure/templates .if defined(PORTSTOP) README= ${TEMPLATES}/README.top @@ -172,26 +116,26 @@ README= ${TEMPLATES}/README.category .endif README.html: - @> $@.tmp -.for entry in ${SUBDIR} - @echo -n '
    '"`cd ${entry} && make package-name 2>/dev/null||echo ${entry}`
    " >> $@.tmp -. if exists(${entry}/pkg/COMMENT) - @cat ${entry}/pkg/COMMENT >> $@.tmp -. else - @echo "(no description)" >> $@.tmp -. endif + @>$@.tmp +.for entry in ${FULLSUBDIR} + @dir=${entry}; ${_flavor_fragment}; \ + name=`eval $$toset ${MAKE} _print-packagename`; \ + case $$name in \ + README) comment='';; \ + *) comment=`eval $$toset ${MAKE} show=_COMMENT|sed -e 's,^",,' -e 's,"$$,,' |${HTMLIFY}`;; \ + esac; \ + cd ${.CURDIR}; \ + echo "
    ${entry}
    $$comment" >>$@.tmp .endfor - @sort -t '>' +1 -2 $@.tmp > $@.tmp2 @cat ${README} | \ sed -e 's%%CATEGORY%%'`echo ${.CURDIR} | sed -e 's.*/\([^/]*\)$$\1'`'g' \ -e '/%%DESCR%%/r${.CURDIR}/pkg/DESCR' -e '//d' \ - -e '/%%SUBDIR%%/r$@.tmp2' -e '//d' \ + -e '/%%SUBDIR%%/r$@.tmp' -e '//d' \ > $@ - @rm -f $@.tmp $@.tmp2 + @rm $@.tmp _print-packagename: - @echo 1>&2 "Error in dependency: ${PKGPATH} is not a package location" - @exit 1 + @echo "README" .PHONY: all fetch fetch-list package extract configure build clean \ describe distclean deinstall reinstall checksum mirror-distfiles \ diff --git a/infrastructure/mk/pkgpath.mk b/infrastructure/mk/pkgpath.mk new file mode 100644 index 00000000000..a3b5b04cbc5 --- /dev/null +++ b/infrastructure/mk/pkgpath.mk @@ -0,0 +1,59 @@ +# $OpenBSD: pkgpath.mk,v 1.1 2003/08/02 09:53:27 espie Exp $ +# pkgpath.mk - 2003 Marc Espie +# This file is in the public domain. + +# definitions common to bsd.port.mk and bsd.port.subdir.mk + +.if !defined(PKGPATH) +_PORTSDIR!= cd ${PORTSDIR} && pwd -P +_CURDIR!= cd ${.CURDIR} && pwd -P +PKGPATH=${_CURDIR:S,${_PORTSDIR}/,,} +.endif +.if empty(PKGPATH) +PKGDEPTH= +.else +PKGDEPTH=${PKGPATH:C|[^./][^/]*|..|g}/ +.endif + +# Code to invoke to split dir,-multi,flavor + +_flavor_fragment= \ + multi=''; flavor=''; space=''; sawflavor=false; \ + case "$$dir" in \ + *,*) \ + IFS=,; first=true; for i in $$dir; do \ + if $$first; then \ + dir=$$i; first=false; \ + else \ + case X"$$i" in \ + X-*) \ + multi="$$i";; \ + *) \ + sawflavor=true; \ + flavor="$$flavor$$space$$i"; \ + space=' ';; \ + esac \ + fi; \ + done; unset IFS;; \ + esac; \ + toset="PKGPATH=$$dir"; \ + case X$$multi in "X");; *) \ + toset="$$toset SUBPACKAGE=\"$$multi\"";; \ + esac; \ + if $$sawflavor; then \ + toset="$$toset FLAVOR=\"$$flavor\""; \ + fi; \ + cd ${PORTSDIR}; \ + if [ -L $$dir ]; then \ + echo 1>&2 ">> Broken dependency: $$dir is a symbolic link"; \ + exit 1; \ + fi; \ + if cd $$dir 2>/dev/null || cd mystuff/$$dir 2>/dev/null; then \ + :; \ + else \ + echo 1>&2 ">> Broken dependency: $$dir non existent"; \ + exit 1; \ + fi + +HTMLIFY= sed -e 's/&/\&/g' -e 's/>/\>/g' -e 's/ + +%%SUBPACKAGES%%

    Description