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)
68 .if !defined(OSVERSION)
72 .if !defined(DFLYVERSION)
73 . if defined(.MAKE.DF.VERSION)
74 DFLYVERSION= ${.MAKE.DF.VERSION}
76 . if exists(/usr/include/sys/param.h)
77 DFLYVERSION!= ${AWK} '/^\#define[[:blank:]]__DragonFly_version/ {print $$3}' < /usr/include/sys/param.h
78 . elif exists(${SRC_BASE}/sys/sys/param.h)
79 DFLYVERSION!= ${AWK} '/^\#define[[:blank:]]__DragonFly_version/ {print $$3}' < ${SRC_BASE}/sys/sys/param.h
81 DFLYVERSION!= ${SYSCTL} -n kern.osreldate
85 _EXPORTED_VARS+= OSVERSION DFLYVERSION
90 .if !defined(_OSRELEASE)
91 . if defined(.MAKE.DF.OSREL)
92 _OSRELEASE= ${.MAKE.DF.OSREL}-DPORTS
94 _OSRELEASE!= ${UNAME} -r
97 _EXPORTED_VARS+= _OSRELEASE
99 OSREL= ${_OSRELEASE:C/[-(].*//}
101 _EXPORTED_VARS+= OSREL
106 _EXPORTED_VARS+= OPSYS
108 .if !defined(CONFIGURE_MAX_CMD_LEN)
109 CONFIGURE_MAX_CMD_LEN= 262144
111 _EXPORTED_VARS+= CONFIGURE_MAX_CMD_LEN
113 .if defined(USE_JAVA)
114 .if !defined(_JAVA_VERSION_LIST_REGEXP)
115 _JAVA_VERSION_LIST_REGEXP!= ${MAKE} -V _JAVA_VERSION_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
117 _EXPORTED_VARS+= _JAVA_VERSION_LIST_REGEXP
119 .if !defined(_JAVA_VENDOR_LIST_REGEXP)
120 _JAVA_VENDOR_LIST_REGEXP!= ${MAKE} -V _JAVA_VENDOR_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
122 _EXPORTED_VARS+= _JAVA_VENDOR_LIST_REGEXP
124 .if !defined(_JAVA_OS_LIST_REGEXP)
125 _JAVA_OS_LIST_REGEXP!= ${MAKE} -V _JAVA_OS_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
127 _EXPORTED_VARS+= _JAVA_OS_LIST_REGEXP
129 .if !defined(_JAVA_PORTS_INSTALLED)
130 _JAVA_PORTS_INSTALLED!= ${MAKE} -V _JAVA_PORTS_INSTALLED USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
132 _EXPORTED_VARS+= _JAVA_PORTS_INSTALLED
134 # export empty variables
135 _EXPORTED_VARS+= _JAVA_VERSION_LIST_REGEXP \
136 _JAVA_VENDOR_LIST_REGEXP \
137 _JAVA_OS_LIST_REGEXP \
138 _JAVA_PORTS_INSTALLED
148 INDEXDIR?= ${PORTSDIR}
149 INDEXFILE?= INDEX-${DFLYVERSION:C/([0-9]*)[0-9]{5}/\1/}
151 # local customization of the ports tree
152 .sinclude "${.CURDIR}/Makefile.local"
158 TARGETS+= clean-for-cdrom
159 TARGETS+= clean-for-cdrom-list
160 TARGETS+= clean-restricted
161 TARGETS+= clean-restricted-list
171 TARGETS+= ignorelist-verbose
175 TARGETS+= package-recursive
176 TARGETS+= realinstall
180 .for __target in ${TARGETS}
181 .if !target(${__target})
182 .if defined(SUBDIR) && !empty(SUBDIR)
183 ${__target}: ${SUBDIR:S/^/_/:S/$/.${__target}/}
190 .if defined(SUBDIR) && !empty(SUBDIR)
192 .for __target in ${TARGETS} checksubdirs describe readmes
193 ${SUBDIR:S/^/_/:S/$/.${__target}/}: _SUBDIRUSE
197 @OK=""; sub=${.TARGET:S/^_//:R}; \
198 for dud in $$DUDS; do \
199 if [ $${dud} = $$sub ]; then \
201 ${ECHO_MSG} "===> ${DIRPRFX}$$sub skipped"; \
204 if test -d ${.CURDIR}/$${sub}.${MACHINE_ARCH}; then \
205 edir=$${sub}.${MACHINE_ARCH}; \
206 elif test -d ${.CURDIR}/$${sub}; then \
210 ${ECHO_MSG} "===> ${DIRPRFX}$${sub} non-existent"; \
212 if [ "$$OK" = "" ]; then \
213 ${ECHO_MSG} "===> ${DIRPRFX}$${edir}"; \
214 cd ${.CURDIR}/$${edir}; \
215 ${MAKE} -B ${.TARGET:E:realinstall=install} \
216 DIRPRFX=${DIRPRFX}$$edir/; \
219 .for _subdir in ${SUBDIR:S/^/_/}
220 ${_subdir}:: ${_subdir:S/$/.all/}
226 .if !target(beforeinstall)
229 .if !target(afterinstall)
232 install: afterinstall
233 afterinstall: realinstall
234 realinstall: beforeinstall ${SUBDIR:S/^/_/:S/$/.realinstall/}
237 IGNOREDIR= Mk Templates Tools distfiles packages pkg Keywords
239 .if !target(checksubdirs)
240 .if defined(PORTSTOP)
241 checksubdirs: checksubdir ${SUBDIR:S/^/_/:S/$/.checksubdirs/}
243 checksubdirs: checksubdir
247 .if !target(checksubdir)
250 if [ -d "$$d" ]; then \
252 for s in ${SUBDIR} ${IGNOREDIR}; do \
253 if [ "x$$s" = "x$$d" ]; then \
258 if [ $$found = 0 ]; then \
259 ${ECHO_MSG} "Warning: directory $$d not in SUBDIR"; \
263 @for s in ${SUBDIR}; do \
264 if ! [ -d ${.CURDIR}/$$s ]; then \
265 ${ECHO_MSG} "Warning: directory $$s in SUBDIR does not exist"; \
270 .if !target(describe)
271 .if defined(PORTSTOP)
272 # This is a bit convoluted to deal with the fact that make will overlap I/O from child make processes
273 # if they write more than 2k: this will corrupt the INDEX file. make -P does not do this, but it adds
274 # extraneous output and redirects stderr, so we lose error reporting from child makes. Instead we have
275 # to roll our own implementation of make -P and make sure that each child make writes to their own file,
276 # which we will combine at the end. This gives substantial performance benefits over doing a make -j1
278 .if defined(BUILDING_INDEX)
279 describe: ${SUBDIR:S/^/describe./}
283 @cd ${.CURDIR}; ${MAKE} -B ${i:S/^/_/:S/$/.describe/} > ${INDEX_TMPDIR}/${INDEXFILE}.desc.${i}
286 describe: ${SUBDIR:S/^/_/:S/$/.describe/}
290 @for sub in ${SUBDIR}; do \
291 if ${TEST} -d ${.CURDIR}/$${sub}; then \
292 ${ECHO_MSG} "===> ${DIRPRFX}$${sub}"; \
293 cd ${.CURDIR}/$${sub}; \
294 ${MAKE} -B describe || \
295 (${ECHO_CMD} "===> ${DIRPRFX}$${sub} failed" >&2; \
298 ${ECHO_MSG} "===> ${DIRPRFX}$${sub} non-existent"; \
305 .if defined(PORTSTOP)
306 readmes: readme ${SUBDIR:S/^/_/:S/$/.readmes/}
307 @${ECHO_MSG} "===> Creating README.html for all ports"
308 @perl ${PORTSDIR}/Tools/make_readmes < ${INDEXDIR}/${INDEXFILE}
316 @${RM} -f README.html
320 HTMLIFY= ${SED} -e 's/&/\&/g' -e 's/>/\>/g' -e 's/</\</g'
323 @${ECHO_CMD} ${.CURDIR} | ${SED} -e 's^.*/^^'
326 @${ECHO_CMD} "===> Creating README.html"
328 .for entry in ${SUBDIR}
330 .if defined(PORTSTOP)
331 @${ECHO_CMD} -n '<a href="'${entry}/README.html'">'"`${ECHO_CMD} ${entry} | ${HTMLIFY}`"'</a>: ' >> $@.tmp
333 @${ECHO_CMD} -n '<a href="'${entry}/README.html'">'"`cd ${entry}; ${MAKE} package-name | ${HTMLIFY}`</a>: " >> $@.tmp
335 @${ECHO_CMD} `cd ${entry}; ${MAKE} -V COMMENT` | ${HTMLIFY} >> $@.tmp
338 @${SORT} -t '>' +1 -2 $@.tmp > $@.tmp2
340 @${HTMLIFY} ${DESCR} > $@.tmp3
345 @${ECHO_CMD} "${COMMENT}" | ${HTMLIFY} > $@.tmp4
349 @${CAT} ${README} | \
350 ${SED} -e 's/%%CATEGORY%%/'"`basename ${.CURDIR}`"'/g' \
351 -e '/%%COMMENT%%/r$@.tmp4' \
352 -e '/%%COMMENT%%/d' \
353 -e '/%%DESCR%%/r$@.tmp3' \
355 -e '/%%SUBDIR%%/r$@.tmp2' \
358 @${RM} -f $@.tmp $@.tmp2 $@.tmp3 $@.tmp4
360 # Pass in the cached invariant variables to child makes.
361 .if !defined(NOPRECIOUSMAKEVARS)
362 .for var in ${_EXPORTED_VARS}
363 .if empty(.MAKEFLAGS:M${var}=*) && !empty(${var})
364 .MAKEFLAGS: ${var}=${${var}:Q}
369 PORTSEARCH_DISPLAY_FIELDS?=name,path,info,maint,index,bdeps,rdeps,www
371 PORTSEARCH_XKEYLIM?=0
372 PORTSEARCH_IGNORECASE?=1
377 if [ ! -r ${INDEXDIR}/${INDEXFILE} ] ; then \
378 ${ECHO_MSG} "The ${.TARGET} target requires ${INDEXFILE}. Please run make index or make fetchindex."; \
381 if [ -z "$$key" -a -z "$$xkey" -a \
382 -z "$$name" -a -z "$$xname" -a \
383 -z "$$path" -a -z "$$xpath" -a \
384 -z "$$info" -a -z "$$xinfo" -a \
385 -z "$$maint" -a -z "$$xmaint" -a \
386 -z "$$cat" -a -z "$$xcat" -a \
387 -z "$$bdeps" -a -z "$$xbdeps" -a \
388 -z "$$rdeps" -a -z "$$xrdeps" -a \
389 -z "$$www" -a -z "$$xwww" ]; \
391 ${ECHO_MSG} "The ${.TARGET} target requires a keyword parameter or name parameter,"; \
392 ${ECHO_MSG} "e.g.: \"make ${.TARGET} key=somekeyword\""; \
393 ${ECHO_MSG} "or \"make ${.TARGET} name=somekeyword\""; \
396 ${AWK} -F\| -v there="$$here/" -v top="$$(pwd -P)" \
397 -v key="$$key" -v xkey="$$xkey" \
398 -v name="$$name" -v xname="$$xname" \
399 -v path="$$path" -v xpath="$$xpath" \
400 -v info="$$info" -v xinfo="$$xinfo" \
401 -v maint="$$maint" -v xmaint="$$xmaint" \
402 -v cat="$$cat" -v xcat="$$xcat" \
403 -v bdeps="$$bdeps" -v xbdeps="$$xbdeps" \
404 -v rdeps="$$rdeps" -v xrdeps="$$xrdeps" \
405 -v www="$$www" -v xwww="$$xwww" \
406 -v icase="$${icase:-${PORTSEARCH_IGNORECASE}}" \
407 -v keylim="$${keylim:-${PORTSEARCH_KEYLIM}}" \
408 -v xkeylim="$${xkeylim:-${PORTSEARCH_XKEYLIM}}" \
409 -v display="$${display:-${PORTSEARCH_DISPLAY_FIELDS}}" \
410 -v xdisplay="$$xdisplay" \
412 gsub(/\+/,"\\+",name); \
413 if (substr(there, 1, length(top)) == top) \
414 there = "${PORTSDIR}" substr(there, 1 + length(top)); \
415 therelen = length(there); \
416 keylen = length(key); keylim = keylim && keylen; \
417 if (!keylim && keylen) \
418 parms[0] = (icase ? tolower(key) : key); \
419 xkeylen = length(xkey); xkeylim = xkeylim && xkeylen; \
420 if (!xkeylim && xkeylen) \
421 xparms[0] = (icase ? tolower(xkey) : xkey); \
423 if (length(name)) parms[1] = tolower(name); if (length(xname)) xparms[1] = tolower(xname); \
424 if (length(path)) parms[2] = tolower(path); if (length(xpath)) xparms[2] = tolower(xpath); \
425 if (length(info)) parms[4] = tolower(info); if (length(xinfo)) xparms[4] = tolower(xinfo); \
426 if (length(maint)) parms[6] = tolower(maint); if (length(xmaint)) xparms[6] = tolower(xmaint); \
427 if (length(cat)) parms[7] = tolower(cat); if (length(xcat)) xparms[7] = tolower(xcat); \
428 if (length(bdeps)) parms[8] = tolower(bdeps); if (length(xbdeps)) xparms[8] = tolower(xbdeps); \
429 if (length(rdeps)) parms[9] = tolower(rdeps); if (length(xrdeps)) xparms[9] = tolower(xrdeps); \
430 if (length(www)) parms[10] = tolower(www); if (length(xwww)) xparms[10] = tolower(xwww); \
432 if (length(name)) parms[1] = name; if (length(xname)) xparms[1] = xname; \
433 if (length(path)) parms[2] = path; if (length(xpath)) xparms[2] = xpath; \
434 if (length(info)) parms[4] = info; if (length(xinfo)) xparms[4] = xinfo; \
435 if (length(maint)) parms[6] = maint; if (length(xmaint)) xparms[6] = xmaint; \
436 if (length(cat)) parms[7] = cat; if (length(xcat)) xparms[7] = xcat; \
437 if (length(bdeps)) parms[8] = bdeps; if (length(xbdeps)) xparms[8] = xbdeps; \
438 if (length(rdeps)) parms[9] = rdeps; if (length(xrdeps)) xparms[9] = xrdeps; \
439 if (length(www)) parms[10] = www; if (length(xwww)) xparms[10] = xwww; \
441 fields["name"] = 1; names[1] = "Port"; \
442 fields["path"] = 2; names[2] = "Path"; \
443 fields["info"] = 4; names[4] = "Info"; \
444 fields["maint"] = 6; names[6] = "Maint"; \
445 fields["cat"] = 7; names[7] = "Index"; \
446 fields["bdeps"] = 8; names[8] = "B-deps"; \
447 fields["rdeps"] = 9; names[9] = "R-deps"; \
448 fields["www"] = 10; names[10] = "WWW"; \
449 split(display, d, /,[ \t]*/); \
450 split(xdisplay, xd, /,[ \t]*/); \
454 if (d[i] == xd[j] ) { \
459 if (toprint == 1 ) disp[fields[d[i]]] = 1; \
463 if (match($$2, "^/usr/ports/[^/]*/[^/]*$$") > 0) \
464 sub("^/usr/ports", "${PORTSDIR}", $$2); \
465 if (substr($$2, 1, therelen) != there) \
468 if ((icase ? tolower($$i) : $$i) !~ parms[i]) \
471 if ((icase ? tolower($$i) : $$i) ~ xparms[i]) \
474 for (i = 1; i < 11; i++) \
476 if (xkeylim && (icase ? tolower($$i) : $$i) ~ xkey) \
478 if (!found && keylim && (icase ? tolower($$i) : $$i) ~ key) \
481 if (keylim && !found) \
483 for (i = 1; i < 11; i++) \
485 printf("%s:\t%s\n", names[i], $$i); \
487 }' ${INDEXDIR}/${INDEXFILE}; \
488 if [ "$$name" -o "$$xname" ] && [ ${PORTSEARCH_MOVED} -gt 0 ]; \
490 ${AWK} -F\| -v name="$$name" -v xname="$$xname" \
491 -v icase="$${icase:-${PORTSEARCH_IGNORECASE}}" \
494 if (length(name)) name = tolower(name); if (length(xname)) xname = tolower(xname); \
496 fields["name"] = 1; names[1] = "Port"; \
497 fields["destination"] = 2; names[2] = "Moved"; \
498 fields["date"] = 3; names[3] = "Date"; \
499 fileds["reason"] = 4; names[4] = "Reason"; \
502 oldname = $$1; newname = $$2; \
503 if (oldname ~ /^\#/) next; \
504 sub(".*\/", "", oldname); newname = sub(".*\/", "", newname); \
505 if (((icase ? tolower(oldname) : oldname) ~ name) || \
506 ((icase ? tolower(newname) : newname) ~ name)) { \
507 for (i = 1; i <= 4; i++) { \
508 printf("%s:\t%s\n", names[i], $$i); \
512 }' ${MOVEDDIR}/${MOVEDFILE}; \
520 @export display="name,path,info" ; \