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.
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 \
20 .
/mk
/scripts
/mkreadme
--pkgsrc
${.CURDIR
} \
21 --packages
${PACKAGES} ${_README_TYPE_FLAG} \
24 @
${ECHO} "ERROR: please do not use the README.html target directly."
25 @
${ECHO} " Instead use either the \"readme\" or \"cdrom-readme\""
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
35 .if make
(bulk-cache
) || make
(clean-bulk-cache
)
36 .
include "../bulk/bsd.bulk-pkg.mk"
39 .PHONY
: ${.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
} ; \
46 list
=`${GREP} '^[[:space:]]*'SUBDIR */Makefile | ${SED} 's,/Makefile.*=[[:space:]]*,/,'` ; \
47 for pkgdir in
$$list ; do \
48 if
[ ! -d
$$pkgdir ]; then \
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
; \
55 l
=`${MAKE} print-summary-data` ; \
56 if
[ $$?
!= 0 ]; then \
57 echo
"WARNING (printdepends): the package in $$pkgdir had problem with" \
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
; \
64 echo
"$$l" >> $$DB ; \
68 if
[ `${EXPR} $$npkg % 100 = 0` -eq
1 ]; then \
72 npkg
=`${EXPR} $$npkg + 1` ; \
78 @
${RM} -f
${.CURDIR
}/INDEX
79 @
${MAKE} ${.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
92 @
${ECHO} "The search target requires a keyword parameter,"
93 @
${ECHO} "e.g.: \"${MAKE} search key=somekeyword\""
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); }'
99 # Generate list of all packages by extracting information from
100 # the category/README.html pages
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
; \
110 ${RM} -f README-all.html.BAK
; \
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>|' \
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."; \
134 @
${SORT} -f
-t
'">' +2 <$@.new
>$@.newsorted
135 @
${WC} -l
$@.newsorted |
${AWK} '{ print $$1 }' >$@.npkgs
136 @
${CAT} templates
/README.
all \
138 -e
'/%%NPKGS%%/r$@.npkgs' \
140 -e
'/%%PKGS%%/r$@.newsorted' \
145 @
${RM} -f
$@.newsorted
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
; \
155 ${RM} -f README-IPv6.html.BAK
; \
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 \
165 -e
'/%%TRS%%/r$@.trs' \
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) }'; \
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
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}