Deleted Added
full compact
bsd.obj.mk (18373) bsd.obj.mk (18426)
1# $Id: bsd.obj.mk,v 1.9 1996/09/18 06:09:17 swallace Exp $
1# $Id: bsd.obj.mk,v 1.10 1996/09/19 06:58:26 peter Exp $
2#
3# The include file <bsd.obj.mk> handles creating 'obj' directory
4# and cleaning up object files, log files etc.
5#
6#
7# +++ variables +++
8#
9# CLEANFILES Additional files to remove for the clean and cleandir targets.
10#
11# MAKEOBJDIRPREFIX Specify somewhere other than /usr/obj to root the object
12# tree. Note: MAKEOBJDIRPREFIX is an *enviroment* variable
13# and does work proper only if set as enviroment variable,
14# not as global or command line variable! [obj]
15#
16# E.g. use `env MAKEOBJDIRPREFIX=/somewhere/obj make'
17#
18# NOOBJ Do not create build directory in object tree.
19#
20# OBJLINK Create a symbolic link from ${CANONICALOBJDIR} to ${.CURDIR}/obj
21# Note: This BREAKS the read-only src tree rule!
22#
23# +++ targets +++
24#
25# clean:
26# remove a.out Errs errs mklog ${CLEANFILES}
27#
28# cleandir:
29# remove the build directory (and all its contents) created by obj
30#
31# obj:
32# create build directory.
33#
34
35.if defined(MAKEOBJDIRPREFIX)
36CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
37.else
38CANONICALOBJDIR:=/usr/obj${.CURDIR}
39.endif
40
41#
42# Warn of unorthodox object directory
43#
44objwarn:
45.if !defined(NOOBJ)
46.if ${.OBJDIR} == ${.CURDIR}
47 @${ECHO} "Warning: Object directory not changed from original ${.CURDIR}"
48.elif !defined(MAKEOBJDIRPREFIX) && ${.OBJDIR} != ${CANONICALOBJDIR}
49.if !defined(MAKEOBJDIR)
50 @${ECHO} "Warning: Using ${.OBJDIR} as object directory instead of\
51 canonical ${CANONICALOBJDIR}"
52.endif
53.endif
54.endif
55
56
57
58.if !target(obj)
59.if defined(NOOBJ)
60obj:
61.else
62.if !defined(OBJLINK)
63obj: _SUBDIR
64 @if ! test -d ${CANONICALOBJDIR}; then \
65 mkdir -p ${CANONICALOBJDIR}; \
66 if ! test -d ${CANONICALOBJDIR}; then \
67 ${ECHO} "Unable to create ${CANONICALOBJDIR}."; \
68 exit 1; \
69 fi; \
70 ${ECHO} "${CANONICALOBJDIR} created for ${.CURDIR}"; \
71 fi
72.else
73obj: _SUBDIR
74 @if ! test -d ${CANONICALOBJDIR}; then \
75 mkdir -p ${CANONICALOBJDIR}; \
76 if ! test -d ${CANONICALOBJDIR}; then \
77 ${ECHO} "Unable to create ${CANONICALOBJDIR}."; \
78 exit 1; \
79 fi; \
80 rm -f ${.CURDIR}/obj; \
81 ln -s ${CANONICALOBJDIR} ${.CURDIR}/obj; \
82 ${ECHO} "${.CURDIR} -> ${CANONICALOBJDIR}"; \
83 fi
84.endif
85.endif
86.endif
87
88.if !target(objlink)
89objlink: _SUBDIR
90 @if test -d ${CANONICALOBJDIR}; then \
91 rm -f ${.CURDIR}/obj; \
92 ln -s ${CANONICALOBJDIR} ${.CURDIR}/obj; \
93 else \
94 echo "No ${CANONICALOBJDIR} to link to - do a make obj."; \
95 fi
96.endif
97
98#
99# where would that obj directory be?
100#
101.if !target(whereobj)
102whereobj:
2#
3# The include file <bsd.obj.mk> handles creating 'obj' directory
4# and cleaning up object files, log files etc.
5#
6#
7# +++ variables +++
8#
9# CLEANFILES Additional files to remove for the clean and cleandir targets.
10#
11# MAKEOBJDIRPREFIX Specify somewhere other than /usr/obj to root the object
12# tree. Note: MAKEOBJDIRPREFIX is an *enviroment* variable
13# and does work proper only if set as enviroment variable,
14# not as global or command line variable! [obj]
15#
16# E.g. use `env MAKEOBJDIRPREFIX=/somewhere/obj make'
17#
18# NOOBJ Do not create build directory in object tree.
19#
20# OBJLINK Create a symbolic link from ${CANONICALOBJDIR} to ${.CURDIR}/obj
21# Note: This BREAKS the read-only src tree rule!
22#
23# +++ targets +++
24#
25# clean:
26# remove a.out Errs errs mklog ${CLEANFILES}
27#
28# cleandir:
29# remove the build directory (and all its contents) created by obj
30#
31# obj:
32# create build directory.
33#
34
35.if defined(MAKEOBJDIRPREFIX)
36CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
37.else
38CANONICALOBJDIR:=/usr/obj${.CURDIR}
39.endif
40
41#
42# Warn of unorthodox object directory
43#
44objwarn:
45.if !defined(NOOBJ)
46.if ${.OBJDIR} == ${.CURDIR}
47 @${ECHO} "Warning: Object directory not changed from original ${.CURDIR}"
48.elif !defined(MAKEOBJDIRPREFIX) && ${.OBJDIR} != ${CANONICALOBJDIR}
49.if !defined(MAKEOBJDIR)
50 @${ECHO} "Warning: Using ${.OBJDIR} as object directory instead of\
51 canonical ${CANONICALOBJDIR}"
52.endif
53.endif
54.endif
55
56
57
58.if !target(obj)
59.if defined(NOOBJ)
60obj:
61.else
62.if !defined(OBJLINK)
63obj: _SUBDIR
64 @if ! test -d ${CANONICALOBJDIR}; then \
65 mkdir -p ${CANONICALOBJDIR}; \
66 if ! test -d ${CANONICALOBJDIR}; then \
67 ${ECHO} "Unable to create ${CANONICALOBJDIR}."; \
68 exit 1; \
69 fi; \
70 ${ECHO} "${CANONICALOBJDIR} created for ${.CURDIR}"; \
71 fi
72.else
73obj: _SUBDIR
74 @if ! test -d ${CANONICALOBJDIR}; then \
75 mkdir -p ${CANONICALOBJDIR}; \
76 if ! test -d ${CANONICALOBJDIR}; then \
77 ${ECHO} "Unable to create ${CANONICALOBJDIR}."; \
78 exit 1; \
79 fi; \
80 rm -f ${.CURDIR}/obj; \
81 ln -s ${CANONICALOBJDIR} ${.CURDIR}/obj; \
82 ${ECHO} "${.CURDIR} -> ${CANONICALOBJDIR}"; \
83 fi
84.endif
85.endif
86.endif
87
88.if !target(objlink)
89objlink: _SUBDIR
90 @if test -d ${CANONICALOBJDIR}; then \
91 rm -f ${.CURDIR}/obj; \
92 ln -s ${CANONICALOBJDIR} ${.CURDIR}/obj; \
93 else \
94 echo "No ${CANONICALOBJDIR} to link to - do a make obj."; \
95 fi
96.endif
97
98#
99# where would that obj directory be?
100#
101.if !target(whereobj)
102whereobj:
103.if defined(NOOBJ)
104 @echo ${.CURDIR}
105.else
106 @if ! test -d ${CANONICALOBJDIR}; then \
107 echo ${.CURDIR}; \
108 else \
109 echo ${CANONICALOBJDIR}; \
110 fi
103 @cd ${.CURDIR}; ${MAKE} -V .OBJDIR
111.endif
104.endif
112.endif
113
114#
115# cleanup
116#
117cleanobj:
118 @if [ -d ${CANONICALOBJDIR} ]; then \
119 rm -rf ${CANONICALOBJDIR}; \
120 else \
121 cd ${.CURDIR} && ${MAKE} clean cleandepend; \
122 fi
123.if defined(OBJLINK)
124 @if [ -h ${.CURDIR}/obj ]; then rm -f ${.CURDIR}/obj; fi
125.endif
126
127.if !target(cleanfiles)
128cleanfiles:
129 rm -f a.out Errs errs mklog ${CLEANFILES}
130.endif
131
132# see bsd.dep.mk
133.if !target(cleandepend)
134cleandepend:
135 @rm -f .depend
136.endif
137
138.if !target(clean)
139clean: cleanfiles _SUBDIR
140.endif
141
142cleandir: cleanobj _SUBDIR
105
106#
107# cleanup
108#
109cleanobj:
110 @if [ -d ${CANONICALOBJDIR} ]; then \
111 rm -rf ${CANONICALOBJDIR}; \
112 else \
113 cd ${.CURDIR} && ${MAKE} clean cleandepend; \
114 fi
115.if defined(OBJLINK)
116 @if [ -h ${.CURDIR}/obj ]; then rm -f ${.CURDIR}/obj; fi
117.endif
118
119.if !target(cleanfiles)
120cleanfiles:
121 rm -f a.out Errs errs mklog ${CLEANFILES}
122.endif
123
124# see bsd.dep.mk
125.if !target(cleandepend)
126cleandepend:
127 @rm -f .depend
128.endif
129
130.if !target(clean)
131clean: cleanfiles _SUBDIR
132.endif
133
134cleandir: cleanobj _SUBDIR