1 # $NetBSD: Makefile,v 1.75 2005/09/01 22:02:34 rillig Exp $
4 # tools used by this Makefile
5 USE_TOOLS+= [ awk cat cmp echo env expr false fgrep grep mv rm sed \
8 # additional tools used by bsd.pkg.subdir.mk
9 USE_TOOLS+= basename touch
11 # additional tools used by bsd.bulk-pkg.mk
12 USE_TOOLS+= egrep find ls sh tee true tsort
14 .include "mk/bsd.prefs.mk"
17 SUBDIR+= ${SITE_SPECIFIC_PKGS}
18 SUBDIR+= ${HOST_SPECIFIC_PKGS}
19 SUBDIR+= ${GROUP_SPECIFIC_PKGS}
20 SUBDIR+= ${USER_SPECIFIC_PKGS}
31 SUBDIR+= crosspkgtools
55 #SUBDIR+= regress # regression tests must be started manually
66 .ifdef USER_ADDITIONAL_PKGS
67 SUBDIR+= ${USER_ADDITIONAL_PKGS}
73 # If PACKAGES is set to the default (${PKGSRCDIR}/packages), the current
74 # ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory
75 # structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed.
76 # The PKG_URL is set from FTP_PKG_URL_* or CDROM_PKG_URL_*, depending on
77 # the target used to generate the README.html file.
79 _README_TYPE_FLAG?= none
80 README.html: .PRECIOUS
81 .if ${_README_TYPE_FLAG} == "--ftp" || ${_README_TYPE_FLAG} == "--cdrom"
82 ${SETENV} TMPDIR=${TMPDIR:U/tmp}/mkreadme \
84 ./mk/scripts/mkreadme --pkgsrc ${.CURDIR} \
85 --packages ${PACKAGES} ${_README_TYPE_FLAG} \
88 @${ECHO} "ERROR: please do not use the README.html target directly."
89 @${ECHO} " Instead use either the \"readme\" or \"cdrom-readme\""
94 .include "mk/bsd.pkg.subdir.mk"
96 # the bulk-cache and clean-bulk-cache targets are a global-pkgsrc
97 # thing and thus it makes sense to run it from the top level pkgsrc
99 .if make(bulk-cache) || make(clean-bulk-cache)
100 .include "${.CURDIR}/mk/bulk/bsd.bulk-pkg.mk"
103 .PHONY: ${.CURDIR}/PKGDB
105 @${RM} -f ${.CURDIR}/PKGDB
106 @${ECHO_MSG} "Extracting complete dependency database. This may take a while..."
107 @DB=${.CURDIR}/PKGDB ; \
108 PKGSRCDIR=${.CURDIR} ; \
110 list=`${GREP} '^[[:space:]]*'SUBDIR */Makefile | ${SED} 's,/Makefile.*=[[:space:]]*,/,'` ; \
111 for pkgdir in $$list ; do \
112 if [ ! -d $$pkgdir ]; then \
114 echo "WARNING: the package directory $$pkgdir is listed in" > /dev/stderr ; \
115 echo $$pkgdir | ${SED} 's;/.*;/Makefile;g' > /dev/stderr ; \
116 echo "but the directory does not exist. Please fix this!" > /dev/stderr ; \
119 l=`${MAKE} print-summary-data` ; \
120 if [ $$? != 0 ]; then \
121 echo "WARNING (printdepends): the package in $$pkgdir had problem with" \
123 echo " ${MAKE} print-summary-data" > /dev/stderr ; \
124 echo " database information for this package" > /dev/stderr ; \
125 echo " will be dropped." > /dev/stderr ; \
126 ${MAKE} print-summary-data 2>&1 > /dev/stderr ; \
128 echo "$$l" >> $$DB ; \
132 if [ `${EXPR} $$npkg % 100 = 0` -eq 1 ]; then \
136 npkg=`${EXPR} $$npkg + 1` ; \
141 index: ${.CURDIR}/INDEX
143 ${.CURDIR}/INDEX: ${.CURDIR}/PKGDB
144 @${RM} -f ${.CURDIR}/INDEX
145 @${AWK} -f ./mk/scripts/genindex.awk PKGSRCDIR=${.CURDIR} SORT=${SORT} ${.CURDIR}/PKGDB
146 @${RM} -f ${.CURDIR}/PKGDB
148 print-index: ${.CURDIR}/INDEX
149 @${AWK} -F\| '{ printf("Pkg:\t%s\nPath:\t%s\nInfo:\t%s\nMaint:\t%s\nIndex:\t%s\nB-deps:\t%s\nR-deps:\t%s\nArch:\t%s\n\n", $$1, $$2, $$4, $$6, $$7, $$8, $$9, $$10); }' < ${.CURDIR}/INDEX
151 search: ${.CURDIR}/INDEX
153 @${ECHO} "The search target requires a keyword parameter,"
154 @${ECHO} "e.g.: \"${MAKE} search key=somekeyword\""
156 @${GREP} ${key} ${.CURDIR}/INDEX | ${AWK} -F\| '{ printf("Pkg:\t%s\nPath:\t%s\nInfo:\t%s\nMaint:\t%s\nIndex:\t%s\nB-deps:\t%s\nR-deps:\t%s\nArch:\t%s\n\n", $$1, $$2, $$4, $$6, $$7, $$8, $$9, $$10); }'
160 # Generate list of all packages by extracting information from
161 # the category/README.html pages
164 @if [ -f README-all.html ]; then \
165 ${MV} README-all.html README-all.html.BAK ; \
167 @${MAKE} README-all.html
168 @if ${CMP} -s README-all.html README-all.html.BAK ; then \
169 ${MV} README-all.html.BAK README-all.html ; \
171 ${RM} -f README-all.html.BAK ; \
176 @${RM} -f $@.newsorted
177 @${ECHO} -n "Processing categories for $@:"
178 .for category in ${SUBDIR}
179 @if [ -f ${category}/README.html ]; then \
180 ${ECHO} -n ' ${category}' ; \
181 ${GREP} '^<TR>' ${category}/README.html \
182 | ${SED} -e 's|"|"${category}/|' \
183 -e 's| <TD>| <TD>(<A HREF="${category}/README.html">${category}</A>) <TD>|' \
184 -e 's|<TR>|<TR VALIGN=TOP>|' \
185 -e 's|<TD VALIGN=TOP>|<TD>|' \
190 @if [ ! -f $@.new ]; then \
191 ${ECHO} "There are no categories with README.html files available."; \
192 ${ECHO} "You need to run \`${MAKE} readme' to generate them before running this target."; \
195 @${SORT} -f -t '">' +2 <$@.new >$@.newsorted
196 @${WC} -l $@.newsorted | ${AWK} '{ print $$1 }' >$@.npkgs
197 @${CAT} templates/README.all \
199 -e '/%%NPKGS%%/r$@.npkgs' \
201 -e '/%%PKGS%%/r$@.newsorted' \
206 @${RM} -f $@.newsorted
209 @if [ -f README-IPv6.html ]; then \
210 ${MV} README-IPv6.html README-IPv6.html.BAK ; \
212 @${MAKE} README-IPv6.html
213 @if ${CMP} -s README-IPv6.html README-IPv6.html.BAK ; then \
214 ${MV} README-IPv6.html.BAK README-IPv6.html ; \
216 ${RM} -f README-IPv6.html.BAK ; \
220 @${GREP} -l -e '^BUILD_DEFS.*=.*USE_INET6' -e '^PKG_SUPPORTED_OPTIONS.*=.*inet6' \
221 */*/Makefile */*/options.mk \
222 | ${SED} -e s,Makefile,, -e s,options.mk,, >$@.pkgs
223 @${FGREP} -f $@.pkgs README-all.html | ${SORT} -t/ +1 >$@.trs
224 @${CAT} templates/README.ipv6 \
226 -e '/%%TRS%%/r$@.trs' \
229 @${RM} $@.pkgs $@.trs
231 show-host-specific-pkgs:
232 @${ECHO} "HOST_SPECIFIC_PKGS= \\"; \
233 ${MAKE} show-pkgsrc-dir | ${AWK} '/^===/ { next; } { printf("%s \\\n", $$1) }'; \
236 # list all packages that depend on a particular package; needs the INDEX file
237 # usage: 'make show-deps PKG=openssl'
238 # PKG: name of the package
240 @if [ ! -f "${.CURDIR}/INDEX" ]; then ${ECHO} "No index available -- please build it with 'make index'" >&2; ${FALSE}; fi
241 @if [ -z "${PKG}" ]; then ${ECHO} "PKG variable not set" >&2; ${FALSE}; fi
242 @${GREP} -E "^([^|]*\|){7}([^|]* |)${PKG}>=" ${.CURDIR}/INDEX | ${SED} -n "s/^[^|]*|\([^|]*\)|.*/\1/p" | ${SORT}