1 # from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
4 # The include file <bsd.port.subdir.mk> contains the default targets
5 # for building ports subdirectories.
10 # STRIP - The flag passed to the install program to cause the binary
11 # to be stripped. This is to be used when building your
12 # own install script so that the entire system can be made
13 # stripped/not-stripped using a single knob. [-s]
15 # OPSYS - Get the operating system type [`uname -s`]
17 # SUBDIR - A list of subdirectories that should be built as well.
18 # Each of the targets will execute the same target in the
25 # Creating README.html for package.
27 # afterinstall, all, beforeinstall, build, checksum, clean,
28 # clean-for-cdrom, clean-restricted,
29 # clean-for-cdrom-list, clean-restricted-list,
30 # configure, deinstall,
31 # depend, depends, describe, extract, fetch, fetch-list,
32 # ignorelist, ignorelist-verbose,
33 # install, maintainer, makesum, package, readmes, realinstall, reinstall,
37 # Search for ports using either 'make search key=<keyword>'
38 # or 'make search name=<keyword>'.
41 TEMPLATES?= ${PORTSDIR}/Templates
43 README= ${TEMPLATES}/README.top
45 README= ${TEMPLATES}/README.category
47 MOVEDDIR?= ${PORTSDIR}
50 .include "${PORTSDIR}/Mk/bsd.commands.mk"
54 .if !defined(DEBUG_FLAGS)
58 # These are variables that are invariant for the lifetime of a recursive port traversal
59 # (index build, etc), so it is more efficient to precompute them here and pass them in
60 # to child makes explicitly, instead of recomputing them tens of thousands of times.
62 .if !defined(NOPRECIOUSMAKEVARS)
67 .if !defined(OSVERSION)
71 .if !defined(DFLYVERSION)
72 . if exists(/usr/include/sys/param.h)
73 DFLYVERSION!= ${AWK} '/^\#define[[:blank:]]__DragonFly_version/ {print $$3}' < /usr/include/sys/param.h
74 . elif exists(${SRC_BASE}/sys/sys/param.h)
75 DFLYVERSION!= ${AWK} '/^\#define[[:blank:]]__DragonFly_version/ {print $$3}' < ${SRC_BASE}/sys/sys/param.h
77 DFLYVERSION!= ${SYSCTL} -n kern.osreldate
84 .if !defined(_OSRELEASE)
85 _OSRELEASE!= ${UNAME} -r
88 OSREL= ${_OSRELEASE:C/[-(].*//}
95 .if ${ARCH} == "amd64" || ${ARCH} =="ia64"
96 .if !defined(HAVE_COMPAT_IA32_KERN)
97 HAVE_COMPAT_IA32_KERN!= if ${SYSCTL} -n compat.ia32.maxvmem >/dev/null 2>&1; then echo YES; fi; echo
98 .if empty(HAVE_COMPAT_IA32_KERN)
99 .undef HAVE_COMPAT_IA32_KERN
104 .if !defined(CONFIGURE_MAX_CMD_LEN)
105 CONFIGURE_MAX_CMD_LEN!= ${SYSCTL} -n kern.argmax
108 .if !defined(_JAVA_VERSION_LIST_REGEXP)
109 _JAVA_VERSION_LIST_REGEXP!= ${MAKE} -V _JAVA_VERSION_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
112 .if !defined(_JAVA_VENDOR_LIST_REGEXP)
113 _JAVA_VENDOR_LIST_REGEXP!= ${MAKE} -V _JAVA_VENDOR_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
116 .if !defined(_JAVA_OS_LIST_REGEXP)
117 _JAVA_OS_LIST_REGEXP!= ${MAKE} -V _JAVA_OS_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
120 .if !defined(_JAVA_PORTS_INSTALLED)
121 _JAVA_PORTS_INSTALLED!= ${MAKE} -V _JAVA_PORTS_INSTALLED USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
130 INDEXDIR?= ${PORTSDIR}
131 INDEXFILE?= INDEX-${DFLYVERSION:C/([0-9]*)[0-9]{5}/\1/}
133 # local customization of the ports tree
134 .if exists(${.CURDIR}/Makefile.local)
135 .include "${.CURDIR}/Makefile.local"
142 TARGETS+= clean-for-cdrom
143 TARGETS+= clean-for-cdrom-list
144 TARGETS+= clean-restricted
145 TARGETS+= clean-restricted-list
155 TARGETS+= ignorelist-verbose
159 TARGETS+= package-recursive
160 TARGETS+= realinstall
164 .for __target in ${TARGETS}
165 .if !target(${__target})
166 .if defined(SUBDIR) && !empty(SUBDIR)
167 ${__target}: ${SUBDIR:S/^/_/:S/$/.${__target}/}
174 .if defined(SUBDIR) && !empty(SUBDIR)
176 .for __target in ${TARGETS} checksubdirs describe readmes
177 ${SUBDIR:S/^/_/:S/$/.${__target}/}: _SUBDIRUSE
181 @OK=""; sub=${.TARGET:S/^_//:R}; \
182 for dud in $$DUDS; do \
183 if [ $${dud} = $$sub ]; then \
185 ${ECHO_MSG} "===> ${DIRPRFX}$$sub skipped"; \
188 if test -d ${.CURDIR}/$${sub}.${MACHINE_ARCH}; then \
189 edir=$${sub}.${MACHINE_ARCH}; \
190 elif test -d ${.CURDIR}/$${sub}; then \
194 ${ECHO_MSG} "===> ${DIRPRFX}$${sub} non-existent"; \
196 if [ "$$OK" = "" ]; then \
197 ${ECHO_MSG} "===> ${DIRPRFX}$${edir}"; \
198 cd ${.CURDIR}/$${edir}; \
199 ${MAKE} -B ${.TARGET:E:realinstall=install} \
200 DIRPRFX=${DIRPRFX}$$edir/; \
203 .for _subdir in ${SUBDIR:S/^/_/}
204 ${_subdir}:: ${_subdir:S/$/.all/}
210 .if !target(beforeinstall)
213 .if !target(afterinstall)
216 install: afterinstall
217 afterinstall: realinstall
218 realinstall: beforeinstall ${SUBDIR:S/^/_/:S/$/.realinstall/}
221 IGNOREDIR= Mk Templates Tools distfiles packages pkg Keywords
223 .if !target(checksubdirs)
224 .if defined(PORTSTOP)
225 checksubdirs: checksubdir ${SUBDIR:S/^/_/:S/$/.checksubdirs/}
227 checksubdirs: checksubdir
231 .if !target(checksubdir)
234 if [ -d "$$d" ]; then \
236 for s in ${SUBDIR} ${IGNOREDIR}; do \
237 if [ "x$$s" = "x$$d" ]; then \
242 if [ $$found = 0 ]; then \
243 ${ECHO_MSG} "Warning: directory $$d not in SUBDIR"; \
247 @for s in ${SUBDIR}; do \
248 if ! [ -d ${.CURDIR}/$$s ]; then \
249 ${ECHO_MSG} "Warning: directory $$s in SUBDIR does not exist"; \
254 .if !target(describe)
255 .if defined(PORTSTOP)
256 # This is a bit convoluted to deal with the fact that make will overlap I/O from child make processes
257 # if they write more than 2k: this will corrupt the INDEX file. make -P does not do this, but it adds
258 # extraneous output and redirects stderr, so we lose error reporting from child makes. Instead we have
259 # to roll our own implementation of make -P and make sure that each child make writes to their own file,
260 # which we will combine at the end. This gives substantial performance benefits over doing a make -j1
262 .if defined(BUILDING_INDEX)
263 describe: ${SUBDIR:S/^/describe./}
267 @cd ${.CURDIR}; ${MAKE} -B ${i:S/^/_/:S/$/.describe/} > ${INDEX_TMPDIR}/${INDEXFILE}.desc.${i}
270 describe: ${SUBDIR:S/^/_/:S/$/.describe/}
274 @for sub in ${SUBDIR}; do \
275 if ${TEST} -d ${.CURDIR}/$${sub}; then \
276 ${ECHO_MSG} "===> ${DIRPRFX}$${sub}"; \
277 cd ${.CURDIR}/$${sub}; \
278 ${MAKE} -B describe || \
279 (${ECHO_CMD} "===> ${DIRPRFX}$${sub} failed" >&2; \
282 ${ECHO_MSG} "===> ${DIRPRFX}$${sub} non-existent"; \
289 .if defined(PORTSTOP)
290 readmes: readme ${SUBDIR:S/^/_/:S/$/.readmes/}
291 @${ECHO_MSG} "===> Creating README.html for all ports"
292 @perl ${PORTSDIR}/Tools/make_readmes < ${INDEXDIR}/${INDEXFILE}
300 @${RM} -f README.html
304 HTMLIFY= ${SED} -e 's/&/\&/g' -e 's/>/\>/g' -e 's/</\</g'
307 @${ECHO_CMD} ${.CURDIR} | ${SED} -e 's^.*/^^'
310 @${ECHO_CMD} "===> Creating README.html"
312 .for entry in ${SUBDIR}
314 .if defined(PORTSTOP)
315 @${ECHO_CMD} -n '<a href="'${entry}/README.html'">'"`${ECHO_CMD} ${entry} | ${HTMLIFY}`"'</a>: ' >> $@.tmp
317 @${ECHO_CMD} -n '<a href="'${entry}/README.html'">'"`cd ${entry}; ${MAKE} package-name | ${HTMLIFY}`</a>: " >> $@.tmp
319 @${ECHO_CMD} `cd ${entry}; ${MAKE} -V COMMENT` | ${HTMLIFY} >> $@.tmp
322 @${SORT} -t '>' +1 -2 $@.tmp > $@.tmp2
324 @${HTMLIFY} ${DESCR} > $@.tmp3
329 @${ECHO_CMD} "${COMMENT}" | ${HTMLIFY} > $@.tmp4
333 @${CAT} ${README} | \
334 ${SED} -e 's/%%CATEGORY%%/'"`basename ${.CURDIR}`"'/g' \
335 -e '/%%COMMENT%%/r$@.tmp4' \
336 -e '/%%COMMENT%%/d' \
337 -e '/%%DESCR%%/r$@.tmp3' \
339 -e '/%%SUBDIR%%/r$@.tmp2' \
342 @${RM} -f $@.tmp $@.tmp2 $@.tmp3 $@.tmp4
344 # Pass in the cached invariant variables to child makes.
345 # XXX Why are we trying to escape these characters using regexps and not using ':Q'?
346 .if !defined(NOPRECIOUSMAKEVARS)
348 ARCH="${ARCH:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
349 OPSYS="${OPSYS:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
350 OSREL="${OSREL:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
351 OSVERSION="${OSVERSION:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
352 DFLYVERSION="${DFLYVERSION:Q}" \
353 UID="${UID:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
354 HAVE_COMPAT_IA32_KERN="${HAVE_COMPAT_IA32_KERN}" \
355 CONFIGURE_MAX_CMD_LEN="${CONFIGURE_MAX_CMD_LEN}" \
356 _JAVA_VERSION_LIST_REGEXP="${_JAVA_VERSION_LIST_REGEXP:Q}" \
357 _JAVA_VENDOR_LIST_REGEXP="${_JAVA_VENDOR_LIST_REGEXP:Q}" \
358 _JAVA_OS_LIST_REGEXP="${_JAVA_OS_LIST_REGEXP:Q}" \
359 _JAVA_PORTS_INSTALLED="${_JAVA_PORTS_INSTALLED}"
362 PORTSEARCH_DISPLAY_FIELDS?=name,path,info,maint,index,bdeps,rdeps,www
364 PORTSEARCH_XKEYLIM?=0
365 PORTSEARCH_IGNORECASE?=1
370 if [ ! -r ${INDEXDIR}/${INDEXFILE} ] ; then \
371 ${ECHO_MSG} "The ${.TARGET} target requires ${INDEXFILE}. Please run make index or make fetchindex."; \
374 if [ -z "$$key" -a -z "$$xkey" -a \
375 -z "$$name" -a -z "$$xname" -a \
376 -z "$$path" -a -z "$$xpath" -a \
377 -z "$$info" -a -z "$$xinfo" -a \
378 -z "$$maint" -a -z "$$xmaint" -a \
379 -z "$$cat" -a -z "$$xcat" -a \
380 -z "$$bdeps" -a -z "$$xbdeps" -a \
381 -z "$$rdeps" -a -z "$$xrdeps" -a \
382 -z "$$www" -a -z "$$xwww" ]; \
384 ${ECHO_MSG} "The ${.TARGET} target requires a keyword parameter or name parameter,"; \
385 ${ECHO_MSG} "e.g.: \"make ${.TARGET} key=somekeyword\""; \
386 ${ECHO_MSG} "or \"make ${.TARGET} name=somekeyword\""; \
389 ${AWK} -F\| -v there="$$here/" -v top="$$(pwd -P)" \
390 -v key="$$key" -v xkey="$$xkey" \
391 -v name="$$name" -v xname="$$xname" \
392 -v path="$$path" -v xpath="$$xpath" \
393 -v info="$$info" -v xinfo="$$xinfo" \
394 -v maint="$$maint" -v xmaint="$$xmaint" \
395 -v cat="$$cat" -v xcat="$$xcat" \
396 -v bdeps="$$bdeps" -v xbdeps="$$xbdeps" \
397 -v rdeps="$$rdeps" -v xrdeps="$$xrdeps" \
398 -v www="$$www" -v xwww="$$xwww" \
399 -v icase="$${icase:-${PORTSEARCH_IGNORECASE}}" \
400 -v keylim="$${keylim:-${PORTSEARCH_KEYLIM}}" \
401 -v xkeylim="$${xkeylim:-${PORTSEARCH_XKEYLIM}}" \
402 -v display="$${display:-${PORTSEARCH_DISPLAY_FIELDS}}" \
403 -v xdisplay="$$xdisplay" \
405 gsub(/\+/,"\\+",name); \
406 if (substr(there, 1, length(top)) == top) \
407 there = "${PORTSDIR}" substr(there, 1 + length(top)); \
408 therelen = length(there); \
409 keylen = length(key); keylim = keylim && keylen; \
410 if (!keylim && keylen) \
411 parms[0] = (icase ? tolower(key) : key); \
412 xkeylen = length(xkey); xkeylim = xkeylim && xkeylen; \
413 if (!xkeylim && xkeylen) \
414 xparms[0] = (icase ? tolower(xkey) : xkey); \
416 if (length(name)) parms[1] = tolower(name); if (length(xname)) xparms[1] = tolower(xname); \
417 if (length(path)) parms[2] = tolower(path); if (length(xpath)) xparms[2] = tolower(xpath); \
418 if (length(info)) parms[4] = tolower(info); if (length(xinfo)) xparms[4] = tolower(xinfo); \
419 if (length(maint)) parms[6] = tolower(maint); if (length(xmaint)) xparms[6] = tolower(xmaint); \
420 if (length(cat)) parms[7] = tolower(cat); if (length(xcat)) xparms[7] = tolower(xcat); \
421 if (length(bdeps)) parms[8] = tolower(bdeps); if (length(xbdeps)) xparms[8] = tolower(xbdeps); \
422 if (length(rdeps)) parms[9] = tolower(rdeps); if (length(xrdeps)) xparms[9] = tolower(xrdeps); \
423 if (length(www)) parms[10] = tolower(www); if (length(xwww)) xparms[10] = tolower(xwww); \
425 if (length(name)) parms[1] = name; if (length(xname)) xparms[1] = xname; \
426 if (length(path)) parms[2] = path; if (length(xpath)) xparms[2] = xpath; \
427 if (length(info)) parms[4] = info; if (length(xinfo)) xparms[4] = xinfo; \
428 if (length(maint)) parms[6] = maint; if (length(xmaint)) xparms[6] = xmaint; \
429 if (length(cat)) parms[7] = cat; if (length(xcat)) xparms[7] = xcat; \
430 if (length(bdeps)) parms[8] = bdeps; if (length(xbdeps)) xparms[8] = xbdeps; \
431 if (length(rdeps)) parms[9] = rdeps; if (length(xrdeps)) xparms[9] = xrdeps; \
432 if (length(www)) parms[10] = www; if (length(xwww)) xparms[10] = xwww; \
434 fields["name"] = 1; names[1] = "Port"; \
435 fields["path"] = 2; names[2] = "Path"; \
436 fields["info"] = 4; names[4] = "Info"; \
437 fields["maint"] = 6; names[6] = "Maint"; \
438 fields["cat"] = 7; names[7] = "Index"; \
439 fields["bdeps"] = 8; names[8] = "B-deps"; \
440 fields["rdeps"] = 9; names[9] = "R-deps"; \
441 fields["www"] = 10; names[10] = "WWW"; \
442 split(display, d, /,[ \t]*/); \
443 split(xdisplay, xd, /,[ \t]*/); \
447 if (d[i] == xd[j] ) { \
452 if (toprint == 1 ) disp[fields[d[i]]] = 1; \
456 if (match($$2, "^/usr/ports/[^/]*/[^/]*$$") > 0) \
457 sub("^/usr/ports", "${PORTSDIR}", $$2); \
458 if (substr($$2, 1, therelen) != there) \
461 if ((icase ? tolower($$i) : $$i) !~ parms[i]) \
464 if ((icase ? tolower($$i) : $$i) ~ xparms[i]) \
467 for (i = 1; i < 11; i++) \
469 if (xkeylim && (icase ? tolower($$i) : $$i) ~ xkey) \
471 if (!found && keylim && (icase ? tolower($$i) : $$i) ~ key) \
474 if (keylim && !found) \
476 for (i = 1; i < 11; i++) \
478 printf("%s:\t%s\n", names[i], $$i); \
480 }' ${INDEXDIR}/${INDEXFILE}; \
481 if [ "$$name" -o "$$xname" ] && [ ${PORTSEARCH_MOVED} -gt 0 ]; \
483 ${AWK} -F\| -v name="$$name" -v xname="$$xname" \
484 -v icase="$${icase:-${PORTSEARCH_IGNORECASE}}" \
487 if (length(name)) name = tolower(name); if (length(xname)) xname = tolower(xname); \
489 fields["name"] = 1; names[1] = "Port"; \
490 fields["destination"] = 2; names[2] = "Moved"; \
491 fields["date"] = 3; names[3] = "Date"; \
492 fileds["reason"] = 4; names[4] = "Reason"; \
495 oldname = $$1; newname = $$2; \
496 if (oldname ~ /^\#/) next; \
497 sub(".*\/", "", oldname); newname = sub(".*\/", "", newname); \
498 if (((icase ? tolower(oldname) : oldname) ~ name) || \
499 ((icase ? tolower(newname) : newname) ~ name)) { \
500 for (i = 1; i <= 4; i++) { \
501 printf("%s:\t%s\n", names[i], $$i); \
505 }' ${MOVEDDIR}/${MOVEDFILE}; \
513 @export display="name,path,info" ; \