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 # Ensure .CURDIR contains an absolute path without a trailing slash. Failed
51 # builds can occur when PORTSDIR is a symbolic link, or with something like
52 # make -C /usr/ports/category/port/.
53 .CURDIR:= ${.CURDIR:tA}
55 .include "${PORTSDIR}/Mk/bsd.commands.mk"
59 .if !defined(DEBUG_FLAGS)
63 # These are variables that are invariant for the lifetime of a recursive port traversal
64 # (index build, etc), so it is more efficient to precompute them here and pass them in
65 # to child makes explicitly, instead of recomputing them tens of thousands of times.
67 .if !defined(NOPRECIOUSMAKEVARS)
73 .if !defined(OSVERSION)
77 .if !defined(DFLYVERSION)
78 . if defined(.MAKE.DF.VERSION)
79 DFLYVERSION= ${.MAKE.DF.VERSION}
81 . if exists(/usr/include/sys/param.h)
82 DFLYVERSION!= ${AWK} '/^\#define[[:blank:]]__DragonFly_version/ {print $$3}' < /usr/include/sys/param.h
83 . elif exists(${SRC_BASE}/sys/sys/param.h)
84 DFLYVERSION!= ${AWK} '/^\#define[[:blank:]]__DragonFly_version/ {print $$3}' < ${SRC_BASE}/sys/sys/param.h
86 DFLYVERSION!= ${SYSCTL} -n kern.osreldate
90 _EXPORTED_VARS+= OSVERSION DFLYVERSION
95 .if !defined(_OSRELEASE)
96 . if defined(.MAKE.DF.OSREL)
97 _OSRELEASE= ${.MAKE.DF.OSREL}-DPORTS
99 _OSRELEASE!= ${UNAME} -r
102 _EXPORTED_VARS+= _OSRELEASE
104 OSREL= ${_OSRELEASE:C/[-(].*//}
106 _EXPORTED_VARS+= OSREL
111 _EXPORTED_VARS+= OPSYS
113 .if !defined(CONFIGURE_MAX_CMD_LEN)
114 CONFIGURE_MAX_CMD_LEN= 262144
116 _EXPORTED_VARS+= CONFIGURE_MAX_CMD_LEN
118 .if defined(USE_JAVA)
119 .if !defined(_JAVA_VERSION_LIST_REGEXP)
120 _JAVA_VERSION_LIST_REGEXP!= ${MAKE} -V _JAVA_VERSION_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
122 _EXPORTED_VARS+= _JAVA_VERSION_LIST_REGEXP
124 .if !defined(_JAVA_VENDOR_LIST_REGEXP)
125 _JAVA_VENDOR_LIST_REGEXP!= ${MAKE} -V _JAVA_VENDOR_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
127 _EXPORTED_VARS+= _JAVA_VENDOR_LIST_REGEXP
129 .if !defined(_JAVA_OS_LIST_REGEXP)
130 _JAVA_OS_LIST_REGEXP!= ${MAKE} -V _JAVA_OS_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
132 _EXPORTED_VARS+= _JAVA_OS_LIST_REGEXP
134 .if !defined(_JAVA_PORTS_INSTALLED)
135 _JAVA_PORTS_INSTALLED!= ${MAKE} -V _JAVA_PORTS_INSTALLED USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
137 _EXPORTED_VARS+= _JAVA_PORTS_INSTALLED
139 # export empty variables
140 _EXPORTED_VARS+= _JAVA_VERSION_LIST_REGEXP \
141 _JAVA_VENDOR_LIST_REGEXP \
142 _JAVA_OS_LIST_REGEXP \
143 _JAVA_PORTS_INSTALLED
153 INDEXDIR?= ${PORTSDIR}
156 # local customization of the ports tree
157 .sinclude "${.CURDIR}/Makefile.local"
163 TARGETS+= clean-for-cdrom
164 TARGETS+= clean-for-cdrom-list
165 TARGETS+= clean-restricted
166 TARGETS+= clean-restricted-list
176 TARGETS+= ignorelist-verbose
180 TARGETS+= package-recursive
181 TARGETS+= realinstall
185 .for __target in ${TARGETS}
186 .if !target(${__target})
187 .if defined(SUBDIR) && !empty(SUBDIR)
188 ${__target}: ${SUBDIR:S/^/_/:S/$/.${__target}/}
195 .if defined(SUBDIR) && !empty(SUBDIR)
197 .for __target in ${TARGETS} checksubdirs describe readmes
198 ${SUBDIR:S/^/_/:S/$/.${__target}/}: _SUBDIRUSE
202 @OK=""; sub=${.TARGET:S/^_//:R}; \
203 for dud in $$DUDS; do \
204 if [ $${dud} = $$sub ]; then \
206 ${ECHO_MSG} "===> ${DIRPRFX}$$sub skipped"; \
209 if test -d ${.CURDIR}/$${sub}.${MACHINE_ARCH}; then \
210 edir=$${sub}.${MACHINE_ARCH}; \
211 elif test -d ${.CURDIR}/$${sub}; then \
215 ${ECHO_MSG} "===> ${DIRPRFX}$${sub} non-existent"; \
217 if [ "$$OK" = "" ]; then \
218 ${ECHO_MSG} "===> ${DIRPRFX}$${edir}"; \
219 cd ${.CURDIR}/$${edir}; \
220 ${MAKE} -B ${.TARGET:E:realinstall=install} \
221 DIRPRFX=${DIRPRFX}$$edir/; \
224 .for _subdir in ${SUBDIR:S/^/_/}
225 ${_subdir}:: ${_subdir:S/$/.all/}
231 .if !target(beforeinstall)
234 .if !target(afterinstall)
237 install: afterinstall
238 afterinstall: realinstall
239 realinstall: beforeinstall ${SUBDIR:S/^/_/:S/$/.realinstall/}
242 IGNOREDIR= Mk Templates Tools distfiles packages pkg Keywords
244 .if !target(checksubdirs)
245 .if defined(PORTSTOP)
246 checksubdirs: checksubdir ${SUBDIR:S/^/_/:S/$/.checksubdirs/}
248 checksubdirs: checksubdir
252 .if !target(checksubdir)
255 if [ -d "$$d" ]; then \
257 for s in ${SUBDIR} ${IGNOREDIR}; do \
258 if [ "x$$s" = "x$$d" ]; then \
263 if [ $$found = 0 ]; then \
264 ${ECHO_MSG} "Warning: directory $$d not in SUBDIR"; \
268 @for s in ${SUBDIR}; do \
269 if ! [ -d ${.CURDIR}/$$s ]; then \
270 ${ECHO_MSG} "Warning: directory $$s in SUBDIR does not exist"; \
275 .if !target(describe)
276 .if defined(PORTSTOP)
277 # This is a bit convoluted to deal with the fact that make will overlap I/O from child make processes
278 # if they write more than 2k: this will corrupt the INDEX file. make -P does not do this, but it adds
279 # extraneous output and redirects stderr, so we lose error reporting from child makes. Instead we have
280 # to roll our own implementation of make -P and make sure that each child make writes to their own file,
281 # which we will combine at the end. This gives substantial performance benefits over doing a make -j1
283 .if defined(BUILDING_INDEX)
284 describe: ${SUBDIR:S/^/describe./}
288 @cd ${.CURDIR}; ${MAKE} -B ${i:S/^/_/:S/$/.describe/} > ${INDEX_TMPDIR}/${INDEXFILE}.desc.${i}
291 describe: ${SUBDIR:S/^/_/:S/$/.describe/}
295 @for sub in ${SUBDIR}; do \
296 if ${TEST} -d ${.CURDIR}/$${sub}; then \
297 ${ECHO_MSG} "===> ${DIRPRFX}$${sub}"; \
298 cd ${.CURDIR}/$${sub}; \
299 ${MAKE} -B describe || \
300 (${ECHO_CMD} "===> ${DIRPRFX}$${sub} failed" >&2; \
303 ${ECHO_MSG} "===> ${DIRPRFX}$${sub} non-existent"; \
310 .if defined(PORTSTOP)
311 readmes: readme ${SUBDIR:S/^/_/:S/$/.readmes/}
312 @${ECHO_MSG} "===> Creating README.html for all ports"
313 @perl ${PORTSDIR}/Tools/make_readmes < ${INDEXDIR}/${INDEXFILE}
325 HTMLIFY= ${SED} -e 's/&/\&/g' -e 's/>/\>/g' -e 's/</\</g'
328 @${ECHO_CMD} ${.CURDIR} | ${SED} -e 's^.*/^^'
331 @${ECHO_CMD} "===> Creating README.html"
333 .for entry in ${SUBDIR}
335 .if defined(PORTSTOP)
336 @${ECHO_CMD} -n '<a href="'${entry}/README.html'">'"`${ECHO_CMD} ${entry} | ${HTMLIFY}`"'</a>: ' >> $@.tmp
338 @${ECHO_CMD} -n '<a href="'${entry}/README.html'">'"`cd ${entry}; ${MAKE} package-name | ${HTMLIFY}`</a>: " >> $@.tmp
340 @${ECHO_CMD} `cd ${entry}; ${MAKE} -V COMMENT` | ${HTMLIFY} >> $@.tmp
343 @${SORT} -t '>' +1 -2 $@.tmp > $@.tmp2
345 @${HTMLIFY} ${DESCR} > $@.tmp3
350 @${ECHO_CMD} "${COMMENT}" | ${HTMLIFY} > $@.tmp4
354 @${CAT} ${README} | \
355 ${SED} -e 's/%%CATEGORY%%/'"`basename ${.CURDIR}`"'/g' \
356 -e '/%%COMMENT%%/r$@.tmp4' \
357 -e '/%%COMMENT%%/d' \
358 -e '/%%DESCR%%/r$@.tmp3' \
360 -e '/%%SUBDIR%%/r$@.tmp2' \
363 @${RM} $@.tmp $@.tmp2 $@.tmp3 $@.tmp4
365 # Pass in the cached invariant variables to child makes.
366 .if !defined(NOPRECIOUSMAKEVARS)
367 .for var in ${_EXPORTED_VARS}
368 .if empty(.MAKEFLAGS:M${var}=*) && !empty(${var})
369 .MAKEFLAGS: ${var}=${${var}:Q}
374 PORTSEARCH_DISPLAY_FIELDS?=name,path,info,maint,index,bdeps,rdeps,www
376 PORTSEARCH_XKEYLIM?=0
377 PORTSEARCH_IGNORECASE?=1
382 if [ ! -r ${INDEXDIR}/${INDEXFILE} ] ; then \
383 ${ECHO_MSG} "The ${.TARGET} target requires ${INDEXFILE}. Please run make index or make fetchindex."; \
386 if [ -z "$$key" -a -z "$$xkey" -a \
387 -z "$$name" -a -z "$$xname" -a \
388 -z "$$path" -a -z "$$xpath" -a \
389 -z "$$info" -a -z "$$xinfo" -a \
390 -z "$$maint" -a -z "$$xmaint" -a \
391 -z "$$cat" -a -z "$$xcat" -a \
392 -z "$$bdeps" -a -z "$$xbdeps" -a \
393 -z "$$rdeps" -a -z "$$xrdeps" -a \
394 -z "$$www" -a -z "$$xwww" ]; \
396 ${ECHO_MSG} "The ${.TARGET} target requires a keyword parameter or name parameter,"; \
397 ${ECHO_MSG} "e.g.: \"make ${.TARGET} key=somekeyword\""; \
398 ${ECHO_MSG} "or \"make ${.TARGET} name=somekeyword\""; \
401 ${AWK} -F\| -v there="$$here/" -v top="$$(pwd -P)" \
402 -v key="$$key" -v xkey="$$xkey" \
403 -v name="$$name" -v xname="$$xname" \
404 -v path="$$path" -v xpath="$$xpath" \
405 -v info="$$info" -v xinfo="$$xinfo" \
406 -v maint="$$maint" -v xmaint="$$xmaint" \
407 -v cat="$$cat" -v xcat="$$xcat" \
408 -v bdeps="$$bdeps" -v xbdeps="$$xbdeps" \
409 -v rdeps="$$rdeps" -v xrdeps="$$xrdeps" \
410 -v www="$$www" -v xwww="$$xwww" \
411 -v icase="$${icase:-${PORTSEARCH_IGNORECASE}}" \
412 -v keylim="$${keylim:-${PORTSEARCH_KEYLIM}}" \
413 -v xkeylim="$${xkeylim:-${PORTSEARCH_XKEYLIM}}" \
414 -v display="$${display:-${PORTSEARCH_DISPLAY_FIELDS}}" \
415 -v xdisplay="$$xdisplay" \
417 gsub(/\+/,"\\+",name); \
418 if (substr(there, 1, length(top)) == top) \
419 there = "${PORTSDIR}" substr(there, 1 + length(top)); \
420 therelen = length(there); \
421 keylen = length(key); keylim = keylim && keylen; \
422 if (!keylim && keylen) \
423 parms[0] = (icase ? tolower(key) : key); \
424 xkeylen = length(xkey); xkeylim = xkeylim && xkeylen; \
425 if (!xkeylim && xkeylen) \
426 xparms[0] = (icase ? tolower(xkey) : xkey); \
428 if (length(name)) parms[1] = tolower(name); if (length(xname)) xparms[1] = tolower(xname); \
429 if (length(path)) parms[2] = tolower(path); if (length(xpath)) xparms[2] = tolower(xpath); \
430 if (length(info)) parms[4] = tolower(info); if (length(xinfo)) xparms[4] = tolower(xinfo); \
431 if (length(maint)) parms[6] = tolower(maint); if (length(xmaint)) xparms[6] = tolower(xmaint); \
432 if (length(cat)) parms[7] = tolower(cat); if (length(xcat)) xparms[7] = tolower(xcat); \
433 if (length(bdeps)) parms[8] = tolower(bdeps); if (length(xbdeps)) xparms[8] = tolower(xbdeps); \
434 if (length(rdeps)) parms[9] = tolower(rdeps); if (length(xrdeps)) xparms[9] = tolower(xrdeps); \
435 if (length(www)) parms[10] = tolower(www); if (length(xwww)) xparms[10] = tolower(xwww); \
437 if (length(name)) parms[1] = name; if (length(xname)) xparms[1] = xname; \
438 if (length(path)) parms[2] = path; if (length(xpath)) xparms[2] = xpath; \
439 if (length(info)) parms[4] = info; if (length(xinfo)) xparms[4] = xinfo; \
440 if (length(maint)) parms[6] = maint; if (length(xmaint)) xparms[6] = xmaint; \
441 if (length(cat)) parms[7] = cat; if (length(xcat)) xparms[7] = xcat; \
442 if (length(bdeps)) parms[8] = bdeps; if (length(xbdeps)) xparms[8] = xbdeps; \
443 if (length(rdeps)) parms[9] = rdeps; if (length(xrdeps)) xparms[9] = xrdeps; \
444 if (length(www)) parms[10] = www; if (length(xwww)) xparms[10] = xwww; \
446 fields["name"] = 1; names[1] = "Port"; \
447 fields["path"] = 2; names[2] = "Path"; \
448 fields["info"] = 4; names[4] = "Info"; \
449 fields["maint"] = 6; names[6] = "Maint"; \
450 fields["cat"] = 7; names[7] = "Index"; \
451 fields["bdeps"] = 8; names[8] = "B-deps"; \
452 fields["rdeps"] = 9; names[9] = "R-deps"; \
453 fields["www"] = 10; names[10] = "WWW"; \
454 split(display, d, /,[ \t]*/); \
455 split(xdisplay, xd, /,[ \t]*/); \
459 if (d[i] == xd[j] ) { \
464 if (toprint == 1 ) disp[fields[d[i]]] = 1; \
468 if (match($$2, "^/usr/ports/[^/]*/[^/]*$$") > 0) \
469 sub("^/usr/ports", "${PORTSDIR}", $$2); \
470 if (substr($$2, 1, therelen) != there) \
473 if ((icase ? tolower($$i) : $$i) !~ parms[i]) \
476 if ((icase ? tolower($$i) : $$i) ~ xparms[i]) \
479 for (i = 1; i < 11; i++) \
481 if (xkeylim && (icase ? tolower($$i) : $$i) ~ xkey) \
483 if (!found && keylim && (icase ? tolower($$i) : $$i) ~ key) \
486 if (keylim && !found) \
488 for (i = 1; i < 11; i++) \
490 printf("%s:\t%s\n", names[i], $$i); \
492 }' ${INDEXDIR}/${INDEXFILE}; \
493 if [ "$$name" -o "$$xname" ] && [ ${PORTSEARCH_MOVED} -gt 0 ]; \
495 ${AWK} -F\| -v name="$$name" -v xname="$$xname" \
496 -v icase="$${icase:-${PORTSEARCH_IGNORECASE}}" \
499 if (length(name)) name = tolower(name); if (length(xname)) xname = tolower(xname); \
501 fields["name"] = 1; names[1] = "Port"; \
502 fields["destination"] = 2; names[2] = "Moved"; \
503 fields["date"] = 3; names[3] = "Date"; \
504 fileds["reason"] = 4; names[4] = "Reason"; \
507 oldname = $$1; newname = $$2; \
508 if (oldname ~ /^\#/) next; \
509 sub(".*\/", "", oldname); newname = sub(".*\/", "", newname); \
510 if (((icase ? tolower(oldname) : oldname) ~ name) || \
511 ((icase ? tolower(newname) : newname) ~ name)) { \
512 for (i = 1; i <= 4; i++) { \
513 printf("%s:\t%s\n", names[i], $$i); \
517 }' ${MOVEDDIR}/${MOVEDFILE}; \
525 @export display="name,path,info" ; \