1# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 2# $Id$ 3# 4# The include file <bsd.port.subdir.mk> contains the default targets 5# for building ports subdirectories. 6# 7# 8# +++ variables +++ 9# 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] 14# 15# ECHO_MSG Used to print all the '===>' style prompts - override this 16# to turn them off [echo]. 17# 18# OPSYS Get the operating system type [`uname -s`] 19# 20# SUBDIR A list of subdirectories that should be built as well. 21# Each of the targets will execute the same target in the 22# subdirectories. 23# 24# 25# +++ targets +++ 26# 27# README.html: 28# Creating README.html for package. 29# 30# afterinstall, all, beforeinstall, build, checksum, clean, 31# configure, depend, describe, extract, fetch, fetch-list, 32# install, package, readmes, realinstall, reinstall, tags 33# 34 35 36.MAIN: all 37 38.if !defined(DEBUG_FLAGS) 39STRIP?= -s 40.endif 41 42.if !defined(OPSYS) # XXX !! 43OPSYS!= uname -s 44.endif 45 46ECHO_MSG?= echo 47 48_SUBDIRUSE: .USE 49 @for entry in ${SUBDIR}; do \ 50 OK=""; \ 51 for dud in $$DUDS; do \ 52 if [ $${dud} = $${entry} ]; then \ 53 OK="false"; \ 54 ${ECHO_MSG} "===> ${DIRPRFX}$${entry} skipped"; \ 55 fi; \ 56 done; \ 57 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ 58 edir=$${entry}.${MACHINE}; \ 59 elif test -d ${.CURDIR}/$${entry}; then \ 60 edir=$${entry}; \ 61 else \ 62 OK="false"; \ 63 ${ECHO_MSG} "===> ${DIRPRFX}$${entry} non-existent"; \ 64 fi; \ 65 if [ "$$OK" = "" ]; then \ 66 ${ECHO_MSG} "===> ${DIRPRFX}$${edir}"; \ 67 cd ${.CURDIR}/$${edir}; \ 68 ${MAKE} ${.TARGET:realinstall=install} \ 69 DIRPRFX=${DIRPRFX}$$edir/; \ 70 fi; \ 71 done 72 73${SUBDIR}:: 74 @if test -d ${.TARGET}.${MACHINE}; then \ 75 cd ${.CURDIR}/${.TARGET}.${MACHINE}; \ 76 else \ 77 cd ${.CURDIR}/${.TARGET}; \ 78 fi; \ 79 ${MAKE} all 80 81.for __target in all fetch fetch-list package extract configure \ 82 build clean depend describe reinstall tags checksum 83.if !target(__target) 84${__target}: _SUBDIRUSE 85.endif 86.endfor 87 88.if !target(install) 89.if !target(beforeinstall) 90beforeinstall: 91.endif 92.if !target(afterinstall) 93afterinstall: 94.endif 95install: afterinstall 96afterinstall: realinstall 97realinstall: beforeinstall _SUBDIRUSE 98.endif 99 100.if !target(readmes) 101readmes: readme _SUBDIRUSE 102.endif 103 104.if !target(readme) 105readme: 106 @rm -f README.html 107 @make README.html 108.endif 109 110.if (${OPSYS} == "NetBSD") 111PORTSDIR ?= /usr/opt 112.else 113PORTSDIR ?= /usr/ports 114.endif 115TEMPLATES ?= ${PORTSDIR}/templates 116.if defined(PORTSTOP) 117README= ${TEMPLATES}/README.top 118.else 119README= ${TEMPLATES}/README.category 120.endif 121 122README.html: 123 @echo "===> Creating README.html" 124 @> $@.tmp 125.for entry in ${SUBDIR} 126.if defined(PORTSTOP) 127 @echo -n '<a href="'${entry}/README.html'">${entry}</a>: ' >> $@.tmp 128.else 129 @echo -n '<a href="'${entry}/README.html'">'"`cd ${entry}; make package-name`</a>: " >> $@.tmp 130.endif 131.if exists(${entry}/pkg/COMMENT) 132 @cat ${entry}/pkg/COMMENT >> $@.tmp 133.else 134 @echo "(no description)" >> $@.tmp 135.endif 136.endfor 137 @sort -t '>' +1 -2 $@.tmp > $@.tmp2 138 @cat ${README} | \ 139 sed -e 's%%CATEGORY%%'`echo ${.CURDIR} | sed -e 's.*/\([^/]*\)$$\1'`'g' \ 140 -e '/%%DESCR%%/r${.CURDIR}/pkg/DESCR' \ 141 -e '/%%DESCR%%/d' \ 142 -e '/%%SUBDIR%%/r$@.tmp2' \ 143 -e '/%%SUBDIR%%/d' \ 144 > $@ 145 @rm -f $@.tmp $@.tmp2 146