Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / misc / toplevel.mk
blobbdc9c3413bf03b48a58842676b899a771d213a93
1 # $NetBSD: toplevel.mk,v 1.4 2007/10/13 11:04:19 dsl Exp $
3 # This file contains the make targets that can be used from the
4 # top-level Makefile. They are in this separate file to keep the
5 # top-level file short and clean.
9 # If PACKAGES is set to the default (${PKGSRCDIR}/packages), the current
10 # ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory
11 # structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed.
12 # The PKG_URL is set from FTP_PKG_URL_* or CDROM_PKG_URL_*, depending on
13 # the target used to generate the README.html file.
14 .PHONY: README.html
15 _README_TYPE_FLAG?= none
16 README.html: .PRECIOUS
17 .if ${_README_TYPE_FLAG} == "--ftp" || ${_README_TYPE_FLAG} == "--cdrom"
18 ${PKGSRC_SETENV} TMPDIR=${TMPDIR:U/tmp}/mkreadme \
19 BMAKE=${MAKE} \
20 ./mk/scripts/mkreadme --pkgsrc ${.CURDIR} \
21 --packages ${PACKAGES} ${_README_TYPE_FLAG} \
22 --prune
23 .else
24 @${ECHO} "ERROR: please do not use the README.html target directly."
25 @${ECHO} " Instead use either the \"readme\" or \"cdrom-readme\""
26 @${ECHO} " target."
27 @${FALSE}
28 .endif
30 .include "../bsd.pkg.subdir.mk"
32 # the bulk-cache and clean-bulk-cache targets are a global-pkgsrc
33 # thing and thus it makes sense to run it from the top level pkgsrc
34 # directory.
35 .if make(bulk-cache) || make(clean-bulk-cache)
36 .include "../bulk/bsd.bulk-pkg.mk"
37 .endif
39 .PHONY: ${.CURDIR}/PKGDB
40 ${.CURDIR}/PKGDB:
41 @${RM} -f ${.CURDIR}/PKGDB
42 @${ECHO_MSG} "Extracting complete dependency database. This may take a while..."
43 @DB=${.CURDIR}/PKGDB ; \
44 PKGSRCDIR=${.CURDIR} ; \
45 npkg=1; \
46 list=`${GREP} '^[[:space:]]*'SUBDIR */Makefile | ${SED} 's,/Makefile.*=[[:space:]]*,/,'` ; \
47 for pkgdir in $$list ; do \
48 if [ ! -d $$pkgdir ]; then \
49 echo " " ; \
50 echo "WARNING: the package directory $$pkgdir is listed in" > /dev/stderr ; \
51 echo $$pkgdir | ${SED} 's;/.*;/Makefile;g' > /dev/stderr ; \
52 echo "but the directory does not exist. Please fix this!" > /dev/stderr ; \
53 else \
54 cd $$pkgdir ; \
55 l=`${MAKE} print-summary-data` ; \
56 if [ $$? != 0 ]; then \
57 echo "WARNING (printdepends): the package in $$pkgdir had problem with" \
58 > /dev/stderr ; \
59 echo " ${MAKE} print-summary-data" > /dev/stderr ; \
60 echo " database information for this package" > /dev/stderr ; \
61 echo " will be dropped." > /dev/stderr ; \
62 ${MAKE} print-summary-data 2>&1 > /dev/stderr ; \
63 else \
64 echo "$$l" >> $$DB ; \
65 fi ; \
66 fi ; \
67 ${ECHO_N} "."; \
68 if [ `${EXPR} $$npkg % 100 = 0` -eq 1 ]; then \
69 echo " " ; \
70 echo "$$npkg" ; \
71 fi ; \
72 npkg=`${EXPR} $$npkg + 1` ; \
73 cd $$PKGSRCDIR ; \
74 done
76 .PHONY: index
77 index:
78 @${RM} -f ${.CURDIR}/INDEX
79 @${MAKE} ${.CURDIR}/INDEX
81 ${.CURDIR}/INDEX:
82 @${MAKE} ${.CURDIR}/PKGDB
83 @${RM} -f ${.CURDIR}/INDEX
84 @${AWK} -f ./mk/scripts/genindex.awk PKGSRCDIR=${.CURDIR} SORT=${SORT} ${.CURDIR}/PKGDB
85 @${RM} -f ${.CURDIR}/PKGDB
87 print-index: ${.CURDIR}/INDEX
88 @${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
90 search: ${.CURDIR}/INDEX
91 .if !defined(key)
92 @${ECHO} "The search target requires a keyword parameter,"
93 @${ECHO} "e.g.: \"${MAKE} search key=somekeyword\""
94 .else
95 @${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); }'
96 .endif
99 # Generate list of all packages by extracting information from
100 # the category/README.html pages
102 readme-all:
103 @if [ -f README-all.html ]; then \
104 ${MV} README-all.html README-all.html.BAK ; \
106 @${MAKE} README-all.html
107 @if ${CMP} -s README-all.html README-all.html.BAK ; then \
108 ${MV} README-all.html.BAK README-all.html ; \
109 else \
110 ${RM} -f README-all.html.BAK ; \
113 README-all.html:
114 @${RM} -f $@.new
115 @${RM} -f $@.newsorted
116 @${ECHO_N} "Processing categories for $@:"
117 .for category in ${SUBDIR}
118 @if [ -f ${category}/README.html ]; then \
119 ${ECHO_N} ' ${category}' ; \
120 ${GREP} '^<TR>' ${category}/README.html \
121 | ${SED} -e 's|"|"${category}/|' \
122 -e 's| <TD>| <TD>(<A HREF="${category}/README.html">${category}</A>) <TD>|' \
123 -e 's|<TR>|<TR VALIGN=TOP>|' \
124 -e 's|<TD VALIGN=TOP>|<TD>|' \
125 >> $@.new ; \
127 .endfor
128 @${ECHO} "."
129 @if [ ! -f $@.new ]; then \
130 ${ECHO} "There are no categories with README.html files available."; \
131 ${ECHO} "You need to run \`${MAKE} readme' to generate them before running this target."; \
132 ${FALSE}; \
134 @${SORT} -f -t '">' +2 <$@.new >$@.newsorted
135 @${WC} -l $@.newsorted | ${AWK} '{ print $$1 }' >$@.npkgs
136 @${CAT} templates/README.all \
137 | ${SED} \
138 -e '/%%NPKGS%%/r$@.npkgs' \
139 -e '/%%NPKGS%%/d' \
140 -e '/%%PKGS%%/r$@.newsorted' \
141 -e '/%%PKGS%%/d' \
142 > $@
143 @${RM} -f $@.npkgs
144 @${RM} -f $@.new
145 @${RM} -f $@.newsorted
147 readme-ipv6:
148 @if [ -f README-IPv6.html ]; then \
149 ${MV} README-IPv6.html README-IPv6.html.BAK ; \
151 @${MAKE} README-IPv6.html
152 @if ${CMP} -s README-IPv6.html README-IPv6.html.BAK ; then \
153 ${MV} README-IPv6.html.BAK README-IPv6.html ; \
154 else \
155 ${RM} -f README-IPv6.html.BAK ; \
158 README-IPv6.html:
159 @${GREP} -l -e '^BUILD_DEFS.*=.*IPV6_READY' -e '^PKG_SUPPORTED_OPTIONS.*=.*inet6' -e '^USE_FEATURES.*=.*inet6' \
160 */*/Makefile */*/options.mk \
161 | ${SED} -e s,Makefile,, -e s,options.mk,, >$@.pkgs
162 @${FGREP} -f $@.pkgs README-all.html | ${SORT} -t/ +1 >$@.trs
163 @${CAT} templates/README.ipv6 \
164 | ${SED} \
165 -e '/%%TRS%%/r$@.trs' \
166 -e '/%%TRS%%/d' \
168 @${RM} $@.pkgs $@.trs
170 show-host-specific-pkgs:
171 @${ECHO} "HOST_SPECIFIC_PKGS= \\"; \
172 ${MAKE} show-pkgsrc-dir | ${AWK} '/^===/ { next; } { printf("%s \\\n", $$1) }'; \
173 ${ECHO} ""
175 # list all packages that depend on a particular package; needs the INDEX file
176 # usage: 'make show-deps PKG=openssl'
177 # PKG: name of the package
178 show-deps:
179 @if [ ! -f "${.CURDIR}/INDEX" ]; then ${ECHO} "No index available -- please build it with 'make index'" >&2; ${FALSE}; fi
180 @if [ -z "${PKG}" ]; then ${ECHO} "PKG variable not set" >&2; ${FALSE}; fi
181 @${GREP} -E "^([^|]*\|){7}([^|]* |)${PKG}>=" ${.CURDIR}/INDEX | ${SED} -n 's/^[^|]*|\([^|]*\)|.*/\1/p' | ${SORT}