Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / bsd.pkg.subdir.mk
blob15c0fc70d6d1757a90e7c6aa200931a6dd39d97e
1 # $NetBSD: bsd.pkg.subdir.mk,v 1.69 2007/10/13 11:04:16 dsl 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.
9 # +++ variables +++
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
15 # subdirectories.
18 # +++ targets +++
20 # README.html:
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 .include "misc/common.mk"
31 AWK?= /usr/bin/awk
32 CAT?= /bin/cat
33 BASENAME?= /usr/bin/basename
34 ECHO?= echo
35 ECHO_MSG?= ${ECHO}
36 MV?= /bin/mv
37 RM?= /bin/rm
38 SED?= /usr/bin/sed
39 SORT?= /usr/bin/sort
41 _SUBDIRUSE: .USE
42 @for entry in "" ${SUBDIR}; do \
43 if [ "X$$entry" = "X" ]; then continue; fi; \
44 OK=""; \
45 for dud in "" ${DUDS}; do \
46 if [ "X$$dud" = "X" ]; then continue; fi; \
47 if [ $${dud} = $${entry} ]; then \
48 OK="false"; \
49 ${ECHO_MSG} "===> ${_THISDIR_}$${entry} skipped"; \
50 fi; \
51 done; \
52 if [ -d ${.CURDIR}/$${entry}.${MACHINE} ]; then \
53 edir=$${entry}.${MACHINE}; \
54 elif [ -d ${.CURDIR}/$${entry} ]; then \
55 edir=$${entry}; \
56 else \
57 OK="false"; \
58 ${ECHO_MSG} "===> ${_THISDIR_}$${entry} non-existent"; \
59 fi; \
60 if [ "$$OK" = "" ]; then \
61 cd ${.CURDIR}/$${edir}; \
62 ${ECHO_MSG} "===> ${_THISDIR_}$${edir}"; \
63 ${RECURSIVE_MAKE} ${MAKEFLAGS} "_THISDIR_=${_THISDIR_}$${edir}/" \
64 ${.TARGET:realinstall=install} || true; \
65 fi; \
66 done
68 .for __target in all fetch package extract configure build clean \
69 cleandir distclean depend describe reinstall tags checksum \
70 makedistinfo makepatchsum makesum mirror-distfiles deinstall \
71 show-downlevel show-pkgsrc-dir show-var show-vars \
72 bulk-install bulk-package fetch-list-one-pkg \
73 fetch-list-recursive update clean-update lint \
74 check-vulnerable pbulk-index \
75 ${PKG_MISC_TARGETS}
76 .if !target(__target)
77 .PHONY: ${__target}
78 ${__target}: _SUBDIRUSE
79 .endif
80 .endfor
82 .if !target(install)
83 .if !target(beforeinstall)
84 beforeinstall:
85 .endif
86 .if !target(afterinstall)
87 afterinstall:
88 .endif
89 install: afterinstall
90 afterinstall: realinstall
91 realinstall: beforeinstall _SUBDIRUSE
92 .endif
94 .if !target(readmes)
95 readmes: readme _SUBDIRUSE
96 .endif
98 .if !target(readme)
99 readme:
100 @${RECURSIVE_MAKE} ${MAKEFLAGS} README.html _README_TYPE_FLAG=--ftp _README_TYPE=$@
101 .endif
103 .if !target(cdrom-readme)
104 cdrom-readme:
105 @${RECURSIVE_MAKE} ${MAKEFLAGS} README.html _README_TYPE_FLAG=--cdrom README_TYPE=$@
106 .endif
108 .if defined(PKGSRCTOP)
109 README= templates/README.top
110 .else
111 README= ../templates/README.category
112 .endif
114 HTMLIFY= ${SED} -e 's/&/\&amp;/g' -e 's/>/\&gt;/g' -e 's/</\&lt;/g'
116 show-comment:
117 @if [ ${COMMENT:Q}"" ]; then \
118 ${ECHO} ${COMMENT:Q}; \
119 elif [ -f COMMENT ] ; then \
120 ${CAT} COMMENT; \
121 else \
122 ${ECHO} '(no description)'; \
125 .if !target(show-distfiles)
126 show-distfiles:
127 @for entry in ${SUBDIR}; do \
128 if [ -d ${.CURDIR}/$${entry}.${MACHINE} ]; then \
129 edir=$${entry}.${MACHINE}; \
130 elif [ -d ${.CURDIR}/$${entry} ]; then \
131 edir=$${entry}; \
132 else \
133 OK="false"; \
134 ${ECHO_MSG} "===> ${_THISDIR_}$${entry} non-existent"; \
135 fi; \
136 if [ "$$OK" = "" ]; then \
137 cd ${.CURDIR}/$${edir} && ${RECURSIVE_MAKE} ${MAKEFLAGS} show-distfiles; \
138 fi; \
139 done
140 .endif
142 .PHONY: show-subdir-var
143 show-subdir-var:
144 @${ECHO} ${${VARNAME}:Q}
146 # Print out a script to fetch all needed files (no checksumming).
148 # When invoked at the top or category level, this target needs to be
149 # handled specially, to elide the "===>" messages that would otherwise
150 # ruin the script.
152 .if !target(fetch-list)
153 .PHONY: fetch-list
155 fetch-list:
156 @${ECHO} '#!/bin/sh'
157 @${ECHO} '#'
158 @${ECHO} '# This is an auto-generated script, the result of running'
159 @${ECHO} '# `make fetch-list'"'"' in directory "'"`${PWD_CMD}`"'"'
160 @${ECHO} '# on host "'"`${UNAME} -n`"'" on "'"`date`"'".'
161 @${ECHO} '#'
162 .if defined(PKGSRCTOP) && !defined(SPECIFIC_PKGS)
163 # Recursing over dependencies would be pointless, in this case.
164 @${RECURSIVE_MAKE} ${MAKEFLAGS} fetch-list-one-pkg \
165 | ${AWK} ' \
166 function do_block () { \
167 if (FoundSomething) { \
168 for (line = 0; line < c; line++) \
169 print block[line]; \
170 FoundSomething = 0 \
172 c = 0 \
174 /^[^#=]/ { FoundSomething = 1 } \
175 /^unsorted/ { gsub(/[[:space:]]+/, " \\\n\t") } \
176 /^echo/ { gsub(/;[[:space:]]+/, "\n") } \
177 !/^=/ { block[c++] = $$0 } \
178 /^=/ { do_block() } \
179 END { do_block() } \
181 .else
182 @${RECURSIVE_MAKE} ${MAKEFLAGS} fetch-list-recursive \
183 | ${SED} '/^=/d'
184 .endif
185 .endif # !target(fetch-list)