1 # $FreeBSD: src/share/mk/bsd.obj.mk,v 1.30.2.10 2003/02/15 05:36:25 kris Exp $
2 # $DragonFly: src/share/mk/bsd.obj.mk,v 1.2 2003/06/17 04:37:02 dillon Exp $
4 # The include file <bsd.obj.mk> handles creating the 'obj' directory
5 # and cleaning up object files, etc.
9 # CLEANDIRS Additional directories to remove for the clean target.
11 # CLEANFILES Additional files to remove for the clean target.
13 # MAKEOBJDIR A pathname for the directory where the targets
14 # are built. Note: MAKEOBJDIR is an *environment* variable
15 # and works properly only if set as an environment variable,
16 # not as a global or command line variable!
18 # E.g. use `env MAKEOBJDIR=temp-obj make'
20 # MAKEOBJDIRPREFIX Specifies somewhere other than /usr/obj to root the object
21 # tree. Note: MAKEOBJDIRPREFIX is an *environment* variable
22 # and works properly only if set as an environment variable,
23 # not as a global or command line variable!
25 # E.g. use `env MAKEOBJDIRPREFIX=/somewhere/obj make'
27 # NOOBJ Do not create object directories. This should not be set
28 # if anything is built.
33 # remove ${CLEANFILES}; remove ${CLEANDIRS} and all contents.
36 # remove the build directory (and all its contents) created by obj
39 # create build directory.
42 .if !target(__<bsd.obj.mk>__)
46 .if defined(MAKEOBJDIRPREFIX)
47 CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
49 CANONICALOBJDIR:=/usr/obj${.CURDIR}
53 # Warn of unorthodox object directory.
55 # The following directories are tried in order for ${.OBJDIR}:
57 # 1. ${MAKEOBJDIRPREFIX}/`pwd`
64 # If ${.OBJDIR} is constructed using canonical cases 1 or 5, or
65 # case 2 (using MAKEOBJDIR), don't issue a warning. Otherwise,
66 # issue a warning differentiating between cases 6 and (3 or 4).
69 .if !defined(NOOBJ) && ${.OBJDIR} != ${CANONICALOBJDIR} && \
70 !(defined(MAKEOBJDIRPREFIX) && exists(${CANONICALOBJDIR}/)) && \
71 !(defined(MAKEOBJDIR) && exists(${MAKEOBJDIR}/))
72 .if ${.OBJDIR} == ${.CURDIR}
73 @${ECHO} "Warning: Object directory not changed from original ${.CURDIR}"
74 .elif exists(${.CURDIR}/obj.${MACHINE}/) || exists(${.CURDIR}/obj/)
75 @${ECHO} "Warning: Using ${.OBJDIR} as object directory instead of\
76 canonical ${CANONICALOBJDIR}"
83 @if ! test -d ${CANONICALOBJDIR}/; then \
84 mkdir -p ${CANONICALOBJDIR}; \
85 if ! test -d ${CANONICALOBJDIR}/; then \
86 ${ECHO} "Unable to create ${CANONICALOBJDIR}."; \
89 ${ECHO} "${CANONICALOBJDIR} created for ${.CURDIR}"; \
95 @if test -d ${CANONICALOBJDIR}/; then \
96 rm -f ${.CURDIR}/obj; \
97 ln -s ${CANONICALOBJDIR} ${.CURDIR}/obj; \
99 echo "No ${CANONICALOBJDIR} to link to - do a make obj."; \
102 .endif !defined(NOOBJ)
105 # where would that obj directory be?
107 .if !target(whereobj)
113 .if ${CANONICALOBJDIR} != ${.CURDIR} && exists(${CANONICALOBJDIR}/)
114 @rm -rf ${CANONICALOBJDIR}
116 @cd ${.CURDIR} && ${MAKE} clean cleandepend
118 @if [ -L ${.CURDIR}/obj ]; then rm -f ${.CURDIR}/obj; fi
122 .if defined(CLEANFILES) && !empty(CLEANFILES)
125 .if defined(CLEANDIRS) && !empty(CLEANDIRS)
132 .include <bsd.subdir.mk>
134 .endif !target(__<bsd.obj.mk>__)