Reset PKGREVISION by updating Ruby 1.8.3.
[pkgsrcv2.git] / Makefile
1 # $NetBSD: Makefile,v 1.75 2005/09/01 22:02:34 rillig Exp $
2 #
3
4 # tools used by this Makefile
5 USE_TOOLS+=     [ awk cat cmp echo env expr false fgrep grep mv rm sed  \
6                 sort wc
7
8 # additional tools used by bsd.pkg.subdir.mk
9 USE_TOOLS+=     basename touch
10
11 # additional tools used by bsd.bulk-pkg.mk
12 USE_TOOLS+=     egrep find ls sh tee true tsort
13
14 .include "mk/bsd.prefs.mk"
15
16 .ifdef SPECIFIC_PKGS
17 SUBDIR+=        ${SITE_SPECIFIC_PKGS}
18 SUBDIR+=        ${HOST_SPECIFIC_PKGS}
19 SUBDIR+=        ${GROUP_SPECIFIC_PKGS}
20 SUBDIR+=        ${USER_SPECIFIC_PKGS}
21 .else
22 SUBDIR+=        archivers
23 SUBDIR+=        audio
24 SUBDIR+=        benchmarks
25 SUBDIR+=        biology
26 SUBDIR+=        cad
27 SUBDIR+=        chat
28 SUBDIR+=        comms
29 SUBDIR+=        converters
30 SUBDIR+=        cross
31 SUBDIR+=        crosspkgtools
32 SUBDIR+=        databases
33 SUBDIR+=        devel
34 SUBDIR+=        editors
35 SUBDIR+=        emulators
36 SUBDIR+=        finance
37 SUBDIR+=        fonts
38 SUBDIR+=        games
39 SUBDIR+=        geography
40 SUBDIR+=        graphics
41 SUBDIR+=        ham
42 SUBDIR+=        inputmethod
43 SUBDIR+=        lang
44 SUBDIR+=        mail
45 SUBDIR+=        math
46 SUBDIR+=        mbone
47 SUBDIR+=        meta-pkgs
48 SUBDIR+=        misc
49 SUBDIR+=        multimedia
50 SUBDIR+=        net
51 SUBDIR+=        news
52 SUBDIR+=        parallel
53 SUBDIR+=        pkgtools
54 SUBDIR+=        print
55 #SUBDIR+=       regress         # regression tests must be started manually
56 SUBDIR+=        security
57 SUBDIR+=        shells
58 SUBDIR+=        sysutils
59 SUBDIR+=        textproc
60 SUBDIR+=        time
61 SUBDIR+=        wm
62 SUBDIR+=        www
63 SUBDIR+=        x11
64 .endif
65
66 .ifdef USER_ADDITIONAL_PKGS
67 SUBDIR+=        ${USER_ADDITIONAL_PKGS}
68 .endif
69
70 PKGSRCTOP=      yes
71
72
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.
78 .PHONY: README.html
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                       \
83                 BMAKE=${MAKE}                                           \
84                 ./mk/scripts/mkreadme --pkgsrc ${.CURDIR}               \
85                 --packages ${PACKAGES} ${_README_TYPE_FLAG}             \
86                 --prune
87 .else
88         @${ECHO} "ERROR:  please do not use the README.html target directly."
89         @${ECHO} "        Instead use either the \"readme\" or \"cdrom-readme\""
90         @${ECHO} "        target."
91         @${FALSE}
92 .endif
93
94 .include "mk/bsd.pkg.subdir.mk"
95
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
98 # directory.
99 .if make(bulk-cache) || make(clean-bulk-cache)
100 .include "${.CURDIR}/mk/bulk/bsd.bulk-pkg.mk"
101 .endif
102
103 .PHONY: ${.CURDIR}/PKGDB
104 ${.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} ; \
109         npkg=1; \
110         list=`${GREP} '^[[:space:]]*'SUBDIR */Makefile | ${SED} 's,/Makefile.*=[[:space:]]*,/,'` ; \
111         for pkgdir in $$list ; do \
112                 if [ ! -d $$pkgdir ]; then  \
113                         echo " " ; \
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 ; \
117                 else \
118                         cd $$pkgdir ; \
119                         l=`${MAKE} print-summary-data`  ; \
120                         if [ $$? != 0 ]; then \
121                                 echo "WARNING (printdepends):  the package in $$pkgdir had problem with" \
122                                         > /dev/stderr ; \
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 ; \
127                         else \
128                                 echo "$$l" >> $$DB ; \
129                         fi ; \
130                 fi ; \
131                 echo -n "." ; \
132                 if [ `${EXPR} $$npkg % 100 = 0` -eq 1 ]; then \
133                         echo " " ; \
134                         echo "$$npkg" ; \
135                 fi ; \
136                 npkg=`${EXPR} $$npkg + 1` ; \
137                 cd $$PKGSRCDIR  ; \
138         done
139
140 .PHONY: index
141 index: ${.CURDIR}/INDEX
142
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
147
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
150
151 search: ${.CURDIR}/INDEX
152 .if !defined(key)
153         @${ECHO} "The search target requires a keyword parameter,"
154         @${ECHO} "e.g.: \"${MAKE} search key=somekeyword\""
155 .else
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); }'
157 .endif
158
159 #
160 # Generate list of all packages by extracting information from
161 # the category/README.html pages
162 #
163 readme-all:
164         @if [ -f README-all.html ]; then \
165                 ${MV} README-all.html README-all.html.BAK ; \
166         fi
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 ; \
170         else \
171                 ${RM} -f README-all.html.BAK ; \
172         fi
173
174 README-all.html:
175         @${RM} -f $@.new
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>|' \
186                 >> $@.new ; \
187         fi
188 .endfor
189         @${ECHO} "."
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."; \
193                 ${FALSE}; \
194         fi
195         @${SORT} -f -t '">' +2 <$@.new >$@.newsorted
196         @${WC} -l $@.newsorted | ${AWK} '{ print $$1 }'  >$@.npkgs
197         @${CAT} templates/README.all \
198         | ${SED} \
199                 -e '/%%NPKGS%%/r$@.npkgs' \
200                 -e '/%%NPKGS%%/d' \
201                 -e '/%%PKGS%%/r$@.newsorted' \
202                 -e '/%%PKGS%%/d' \
203                 > $@
204         @${RM} -f $@.npkgs
205         @${RM} -f $@.new
206         @${RM} -f $@.newsorted
207
208 readme-ipv6:
209         @if [ -f README-IPv6.html ]; then \
210                 ${MV} README-IPv6.html README-IPv6.html.BAK ; \
211         fi
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 ; \
215         else \
216                 ${RM} -f README-IPv6.html.BAK ; \
217         fi
218
219 README-IPv6.html:
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 \
225         | ${SED} \
226                 -e '/%%TRS%%/r$@.trs' \
227                 -e '/%%TRS%%/d' \
228                 >$@
229         @${RM} $@.pkgs $@.trs
230
231 show-host-specific-pkgs:
232         @${ECHO} "HOST_SPECIFIC_PKGS= \\";                                      \
233         ${MAKE} show-pkgsrc-dir | ${AWK} '/^===/ { next; } { printf("%s \\\n", $$1) }'; \
234         ${ECHO} ""
235
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
239 show-deps:
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}