Subversion Repositories tendra.SVN

Rev

Rev 6 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 7u83 1
# $Id$
2
#
3
# Taken from:
4
# $FreeBSD: doc/share/mk/doc.subdir.mk,v 1.10 2003/05/21 21:16:10 trhodes Exp $
5
#
6
# This include file <doc.subdir.mk> contains the default targets
7
# for building subdirectories in the TenDRA Documentation Project.
8
#
9
# For all of the directories listed in the variable SUBDIR, the
10
# specified directory will be visited and the target made. There is
11
# also a default target which allows the command "make subdir" where
12
# subdir is any directory listed in the variable SUBDIR.
13
#
14
 
15
# ------------------------------------------------------------------------
16
#
17
# Document-specific variables:
18
#
19
#	SUBDIR			A list of subdirectories that should be
20
#				built as well.  Each of the targets will
21
#				execute the same target in the
22
#				subdirectories.
23
#
24
 
25
# ------------------------------------------------------------------------
26
#
27
# Provided targets:
28
#
29
#	clean:
30
#			Remove files created by the build process (using
31
#			defaults specified by environment)
32
#
33
#	cleandir:
34
#			Remove the object directory, if any.
35
#
36
#	cleanall:
37
#			Remove all possible generated files (all predictable
38
#			combinations of ${FORMAT} values)
39
#
40
 
41
.if !target(__initialized__)
42
__initialized__:
43
.endif
44
 
45
_SUBDIRUSE: .USE
46
.for entry in ${SUBDIR}
47
	@${ECHODIR} "===> ${DIRPRFX}${entry}"
48
	@cd ${.CURDIR}/${entry} && \
49
	${MAKE} ${.TARGET} DIRPRFX=${DIRPRFX}${entry}/
50
.endfor
51
 
52
.MAIN: all
53
 
54
${SUBDIR}::
55
	@cd ${.CURDIR}/${.TARGET} && ${MAKE} all
56
 
57
.for __target in all cleandir lint objlink
58
.if !target(${__target})
59
${__target}: _SUBDIRUSE
60
.endif
61
.endfor
62
 
63
.if !target(obj)
64
obj:	_SUBDIRUSE
65
	@if ! [ -d ${CANONICALOBJDIR}/ ]; then \
66
		${MKDIR} -p ${CANONICALOBJDIR}; \
67
		if ! [ -d ${CANONICALOBJDIR}/ ]; then \
68
			${ECHO_CMD} "Unable to create ${CANONICALOBJDIR}."; \
69
			exit 1; \
70
		fi; \
71
		${ECHO} "${CANONICALOBJDIR} created ${.CURDIR}"; \
72
	fi
73
.endif
74
 
75
.if !target(objlink)
76
objlink: _SUBDIRUSE
77
	@if [ -d ${CANONICALOBJDIR}/ ]; then \
78
		${RM} -f ${.CURDIR}/obj; \
79
		${LN} -s ${CANONICALOBJDIR} ${.CURDIR}/obj; \
80
	else \
81
		${ECHO_CMD} "No ${CANONICALOBJDIR} to link to - do a make obj."; \
82
	fi
83
.endif
84
 
85
.if !target(whereobj)
86
whereobj:
87
	@${ECHO_CMD} ${.OBJDIR}
88
.endif
89
 
90
cleanobj:
91
	@if [ -d ${CANONICALOBJDIR}/ ]; then \
92
		${RM} -rf ${CANONICALOBJDIR}; \
93
	else \
94
		cd ${.CURDIR} && ${MAKE} clean cleandepend; \
95
	fi
96
	@if [ -h ${.CURDIR}/obj ]; then ${RM} -f ${.CURDIR}/obj; fi
97
 
98
.if !target(clean)
99
clean: _SUBDIRUSE
100
.if defined(CLEANFILES) && !empty(CLEANFILES)
101
	${RM} -f ${CLEANFILES}
102
.endif
103
.if defined(CLEANDIRS) && !empty(CLEANDIRS)
104
	${RM} -rf ${CLEANDIRS}
105
.endif
106
.if defined(IMAGES_LIB) && !empty(LOCAL_IMAGES_LIB_DIR)
107
	${RM} -rf ${LOCAL_IMAGES_LIB_DIR}
108
.endif
109
.endif
110
 
111
cleandir: cleanobj _SUBDIRUSE
112
 
113
#
114
# Create /usr/obj image subdirs when ${IMAGES} contains subdir/image.xxx
115
#
116
 
117
_imagesubdir=
118
.for _imagedir in ${IMAGES:H}
119
.if ${_imagesubdir:M${_imagedir}} == ""
120
_imagesubdir+= ${_imagedir}
121
.endif
122
.endfor
123
 
124
.if ${_imagesubdir} != ""
125
_IMAGESUBDIR: .USE
126
.for dir in ${_imagesubdir}
127
	@if ! [ -d ${CANONICALOBJDIR}/${dir}/ ]; then \
128
		${MKDIR} -p ${CANONICALOBJDIR}/${dir}; \
129
		if ! [ -d ${CANONICALOBJDIR}/${dir}/ ]; then \
130
			${ECHO_CMD} "Unable to create ${CANONICALOBJDIR}/${dir}/."; \
131
			exit 1; \
132
		fi; \
133
		${ECHO} "${CANONICALOBJDIR}/${dir}/ created for ${.CURDIR}"; \
134
	fi
135
.endfor
136
 
137
obj: _IMAGESUBDIR
138
.endif
139
 
140
cleanall:
141
	${MAKE} FORMATS="${ALL_FORMATS}" clean