1 # $NetBSD: bsd.pkg.subdir.mk,v 1.54 2003/09/06 11:28:13 cjep Exp $
2 # Derived from: FreeBSD Id: bsd.port.subdir.mk,v 1.19 1997/03/09 23:10:56 wosch Exp
3 # from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
5 # The include file <bsd.pkg.subdir.mk> contains the default targets
6 # for building ports subdirectories.
11 # OPSYS Get the operating system type [`uname -s`]
13 # SUBDIR A list of subdirectories that should be built as well.
14 # Each of the targets will execute the same target in the
21 # Creating README.html for package.
23 # afterinstall, all, beforeinstall, build, checksum, clean,
24 # configure, deinstall, depend, describe, extract, fetch, fetch-list,
25 # install, package, readmes, realinstall, reinstall, tags,
26 # mirror-distfiles, bulk-install, bulk-package, ${PKG_MISC_TARGETS}
29 # Pull in stuff from mk.conf - need to check two places as this may be
30 # called from pkgsrc or from pkgsrc/category.
31 .if exists(${.CURDIR}/mk/bsd.prefs.mk)
32 .include "${.CURDIR}/mk/bsd.prefs.mk"
34 .if exists(${.CURDIR}/../mk/bsd.prefs.mk)
35 .include "${.CURDIR}/../mk/bsd.prefs.mk"
36 .endif # exists(${.CURDIR}/../mk/bsd.prefs.mk)
37 .endif # exists(${.CURDIR}/mk/bsd.prefs.mk)
44 BASENAME?= /usr/bin/basename
53 @for entry in "" ${SUBDIR}; do \
54 if [ "X$$entry" = "X" ]; then continue; fi; \
56 for dud in "" ${DUDS}; do \
57 if [ "X$$dud" = "X" ]; then continue; fi; \
58 if [ $${dud} = $${entry} ]; then \
60 ${ECHO_MSG} "===> ${_THISDIR_}$${entry} skipped"; \
63 if [ -d ${.CURDIR}/$${entry}.${MACHINE} ]; then \
64 edir=$${entry}.${MACHINE}; \
65 elif [ -d ${.CURDIR}/$${entry} ]; then \
69 ${ECHO_MSG} "===> ${_THISDIR_}$${entry} non-existent"; \
71 if [ "$$OK" = "" ]; then \
72 cd ${.CURDIR}/$${edir}; \
73 ${ECHO_MSG} "===> ${_THISDIR_}$${edir}"; \
74 ${MAKE} ${MAKEFLAGS} "_THISDIR_=${_THISDIR_}$${edir}/" \
75 ${.TARGET:realinstall=install} || true; \
80 @if [ -d ${.TARGET}.${MACHINE} ]; then \
81 cd ${.CURDIR}/${.TARGET}.${MACHINE}; \
83 cd ${.CURDIR}/${.TARGET}; \
85 ${MAKE} ${MAKEFLAGS} all
87 .for __target in all fetch package extract configure build clean \
88 cleandir distclean depend describe reinstall tags checksum \
89 makepatchsum mirror-distfiles deinstall show-downlevel \
90 show-pkgsrc-dir show-var show-vars bulk-install bulk-package \
91 fetch-list-one-pkg fetch-list-recursive \
96 ${__target}: _SUBDIRUSE
101 .if !target(beforeinstall)
104 .if !target(afterinstall)
107 install: afterinstall
108 afterinstall: realinstall
109 realinstall: beforeinstall _SUBDIRUSE
113 readmes: readme _SUBDIRUSE
118 @${MAKE} ${MAKEFLAGS} README.html _README_TYPE_FLAG=--ftp _README_TYPE=$@
121 .if !target(cdrom-readme)
123 @${MAKE} ${MAKEFLAGS} README.html _README_TYPE_FLAG=--cdrom README_TYPE=$@
126 .if defined(PKGSRCTOP)
127 README= templates/README.top
129 README= ../templates/README.category
132 HTMLIFY= ${SED} -e 's/&/\&/g' -e 's/>/\>/g' -e 's/</\</g'
134 .if !target(README.html)
136 README.html: .PRECIOUS
138 .for entry in ${SUBDIR}
139 .if defined(PKGSRCTOP)
140 @${ECHO} '<TR><TD VALIGN=TOP><a href="'${entry}/README.html'">'"`${ECHO} ${entry} | ${HTMLIFY}`"'</a>: <TD>' >> $@.tmp
141 @${ECHO} `cd ${entry} && ${MAKE} ${MAKEFLAGS} show-comment | ${HTMLIFY}` >> $@.tmp
143 @${ECHO} '<TR><TD VALIGN=TOP><a href="'${entry}/README.html'">'"`cd ${entry}; ${MAKE} ${MAKEFLAGS} make-readme-html-help`" >> $@.tmp
146 @${SORT} -t '>' +3 -4 $@.tmp > $@.tmp2
147 @${AWK} '{ ++n } END { print n }' < $@.tmp2 > $@.tmp4
148 .if exists(${.CURDIR}/DESCR)
149 @${HTMLIFY} ${.CURDIR}/DESCR > $@.tmp3
153 @${CAT} ${README} | \
154 ${SED} -e 's/%%CATEGORY%%/'"`${BASENAME} ${.CURDIR}`"'/g' \
155 -e '/%%NUMITEMS%%/r$@.tmp4' \
156 -e '/%%NUMITEMS%%/d' \
157 -e '/%%DESCR%%/r$@.tmp3' \
159 -e '/%%SUBDIR%%/r$@.tmp2' \
162 @if [ ! -f $@ ]; then ${TOUCH} $@ ; fi
163 @if ${CMP} -s $@.tmp5 $@ ; then \
166 ${ECHO_MSG} "===> Creating README.html for ${_THISDIR_}${.CURDIR:T}" ; \
169 @${RM} -f $@.tmp $@.tmp2 $@.tmp3 $@.tmp4
170 .for subdir in ${SUBDIR}
171 @cd ${subdir} && ${MAKE} ${MAKEFLAGS} "_THISDIR_=${_THISDIR_}${.CURDIR:T}/" ${_README_TYPE}
176 @if [ "${COMMENT}" ]; then \
177 ${ECHO} "${COMMENT:Q}"; \
178 elif [ -f COMMENT ] ; then \
181 ${ECHO} '(no description)'; \
184 .if !target(show-distfiles)
186 @for entry in ${SUBDIR}; do \
187 if [ -d ${.CURDIR}/$${entry}.${MACHINE} ]; then \
188 edir=$${entry}.${MACHINE}; \
189 elif [ -d ${.CURDIR}/$${entry} ]; then \
193 ${ECHO_MSG} "===> ${_THISDIR_}$${entry} non-existent"; \
195 if [ "$$OK" = "" ]; then \
196 cd ${.CURDIR}/$${edir} && ${MAKE} ${MAKEFLAGS} show-distfiles; \
202 # Print out a script to fetch all needed files (no checksumming).
204 # When invoked at the top or category level, this target needs to be
205 # handled specially, to elide the "===>" messages that would otherwise
208 .if !target(fetch-list)
214 @${ECHO} '# This is an auto-generated script, the result of running'
215 @${ECHO} '# `make fetch-list'"'"' in directory "'"`${PWD_CMD}`"'"'
216 @${ECHO} '# on host "'"`${UNAME} -n`"'" on "'"`date`"'".'
218 .if defined(PKGSRCTOP) && !defined(SPECIFIC_PKGS)
219 # Recursing over dependencies would be pointless, in this case.
220 @${MAKE} ${MAKEFLAGS} fetch-list-one-pkg \
222 function do_block () { \
223 if (FoundSomething) { \
224 for (line = 0; line < c; line++) \
230 /^[^#=]/ { FoundSomething = 1 } \
231 /^unsorted/ { gsub(/[[:space:]]+/, " \\\n\t") } \
232 /^echo/ { gsub(/;[[:space:]]+/, "\n") } \
233 !/^=/ { block[c++] = $$0 } \
234 /^=/ { do_block() } \
238 @${MAKE} ${MAKEFLAGS} fetch-list-recursive \
241 .endif # !target(fetch-list)