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