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