1999-08-28 00:22:10 +00:00
|
|
|
# $FreeBSD$
|
1996-04-22 23:31:39 +00:00
|
|
|
#
|
1996-09-29 18:28:55 +00:00
|
|
|
# The include file <bsd.obj.mk> handles creating the 'obj' directory
|
1997-12-19 18:48:45 +00:00
|
|
|
# and cleaning up object files, etc.
|
1996-04-22 23:31:39 +00:00
|
|
|
#
|
|
|
|
# +++ variables +++
|
|
|
|
#
|
1998-02-25 02:48:28 +00:00
|
|
|
# CLEANDIRS Additional directories to remove for the clean target.
|
|
|
|
#
|
|
|
|
# CLEANFILES Additional files to remove for the clean target.
|
1996-05-27 23:05:54 +00:00
|
|
|
#
|
2005-01-06 11:12:43 +00:00
|
|
|
# MAKEOBJDIR A pathname for the directory where the targets
|
2002-07-01 07:25:02 +00:00
|
|
|
# are built. Note: MAKEOBJDIR is an *environment* variable
|
|
|
|
# and works properly only if set as an environment variable,
|
1996-09-29 18:28:55 +00:00
|
|
|
# not as a global or command line variable!
|
|
|
|
#
|
|
|
|
# E.g. use `env MAKEOBJDIR=temp-obj make'
|
|
|
|
#
|
|
|
|
# MAKEOBJDIRPREFIX Specifies somewhere other than /usr/obj to root the object
|
2002-07-01 07:25:02 +00:00
|
|
|
# tree. Note: MAKEOBJDIRPREFIX is an *environment* variable
|
|
|
|
# and works properly only if set as an environment variable,
|
1996-09-29 18:28:55 +00:00
|
|
|
# not as a global or command line variable!
|
1996-05-27 23:05:54 +00:00
|
|
|
#
|
1996-09-18 06:09:19 +00:00
|
|
|
# E.g. use `env MAKEOBJDIRPREFIX=/somewhere/obj make'
|
1996-04-22 23:31:39 +00:00
|
|
|
#
|
2004-12-21 08:47:35 +00:00
|
|
|
# NO_OBJ Do not create object directories. This should not be set
|
1996-09-29 18:28:55 +00:00
|
|
|
# if anything is built.
|
1996-04-22 23:31:39 +00:00
|
|
|
#
|
|
|
|
# +++ targets +++
|
|
|
|
#
|
|
|
|
# clean:
|
1998-02-25 02:48:28 +00:00
|
|
|
# remove ${CLEANFILES}; remove ${CLEANDIRS} and all contents.
|
1996-04-22 23:31:39 +00:00
|
|
|
#
|
|
|
|
# cleandir:
|
1996-06-24 04:26:21 +00:00
|
|
|
# remove the build directory (and all its contents) created by obj
|
1996-04-22 23:31:39 +00:00
|
|
|
#
|
|
|
|
# obj:
|
1996-06-24 04:26:21 +00:00
|
|
|
# create build directory.
|
1996-04-22 23:31:39 +00:00
|
|
|
#
|
1996-03-24 22:49:16 +00:00
|
|
|
|
2002-04-17 13:49:29 +00:00
|
|
|
.if !target(__<bsd.obj.mk>__)
|
|
|
|
__<bsd.obj.mk>__:
|
|
|
|
.include <bsd.own.mk>
|
|
|
|
|
2000-08-17 14:41:48 +00:00
|
|
|
.if defined(MAKEOBJDIRPREFIX)
|
1996-09-18 06:09:19 +00:00
|
|
|
CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
|
2012-08-22 19:25:57 +00:00
|
|
|
.elif defined(MAKEOBJDIR) && ${MAKEOBJDIR:M/*} != ""
|
|
|
|
CANONICALOBJDIR:=${MAKEOBJDIR}
|
1996-09-18 06:09:19 +00:00
|
|
|
.else
|
|
|
|
CANONICALOBJDIR:=/usr/obj${.CURDIR}
|
|
|
|
.endif
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.if defined(.PARSEDIR) && !defined(NO_OBJ) && !defined(NO_AUTO_OBJ)
|
|
|
|
.if ${MK_AUTO_OBJ} == "yes"
|
|
|
|
__objdir?= ${CANONICALOBJDIR}
|
|
|
|
# this is what auto.obj.mk wants to see
|
|
|
|
MKOBJDIRS=auto
|
|
|
|
.include "auto.obj.mk"
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
1996-09-18 06:09:19 +00:00
|
|
|
#
|
2001-05-20 12:14:17 +00:00
|
|
|
# Warn of unorthodox object directory.
|
|
|
|
#
|
|
|
|
# The following directories are tried in order for ${.OBJDIR}:
|
|
|
|
#
|
|
|
|
# 1. ${MAKEOBJDIRPREFIX}/`pwd`
|
|
|
|
# 2. ${MAKEOBJDIR}
|
|
|
|
# 3. obj.${MACHINE}
|
|
|
|
# 4. obj
|
|
|
|
# 5. /usr/obj/`pwd`
|
|
|
|
# 6. ${.CURDIR}
|
|
|
|
#
|
|
|
|
# If ${.OBJDIR} is constructed using canonical cases 1 or 5, or
|
|
|
|
# case 2 (using MAKEOBJDIR), don't issue a warning. Otherwise,
|
|
|
|
# issue a warning differentiating between cases 6 and (3 or 4).
|
1996-09-18 06:09:19 +00:00
|
|
|
#
|
|
|
|
objwarn:
|
2004-12-21 08:47:35 +00:00
|
|
|
.if !defined(NO_OBJ) && ${.OBJDIR} != ${CANONICALOBJDIR} && \
|
2001-05-20 12:14:17 +00:00
|
|
|
!(defined(MAKEOBJDIRPREFIX) && exists(${CANONICALOBJDIR}/)) && \
|
|
|
|
!(defined(MAKEOBJDIR) && exists(${MAKEOBJDIR}/))
|
1996-09-18 06:09:19 +00:00
|
|
|
.if ${.OBJDIR} == ${.CURDIR}
|
1996-09-19 06:58:26 +00:00
|
|
|
@${ECHO} "Warning: Object directory not changed from original ${.CURDIR}"
|
2001-05-20 12:14:17 +00:00
|
|
|
.elif exists(${.CURDIR}/obj.${MACHINE}/) || exists(${.CURDIR}/obj/)
|
1996-09-19 06:58:26 +00:00
|
|
|
@${ECHO} "Warning: Using ${.OBJDIR} as object directory instead of\
|
1996-09-18 06:09:19 +00:00
|
|
|
canonical ${CANONICALOBJDIR}"
|
|
|
|
.endif
|
|
|
|
.endif
|
1996-03-24 22:49:16 +00:00
|
|
|
|
2004-12-21 08:47:35 +00:00
|
|
|
.if !defined(NO_OBJ)
|
2002-06-21 07:30:51 +00:00
|
|
|
.if !target(obj)
|
2004-04-13 12:36:00 +00:00
|
|
|
obj: .PHONY
|
1997-04-30 17:04:11 +00:00
|
|
|
@if ! test -d ${CANONICALOBJDIR}/; then \
|
1996-09-18 06:09:19 +00:00
|
|
|
mkdir -p ${CANONICALOBJDIR}; \
|
1997-04-30 17:04:11 +00:00
|
|
|
if ! test -d ${CANONICALOBJDIR}/; then \
|
1996-09-18 06:09:19 +00:00
|
|
|
${ECHO} "Unable to create ${CANONICALOBJDIR}."; \
|
1996-06-24 04:26:21 +00:00
|
|
|
exit 1; \
|
|
|
|
fi; \
|
1996-09-18 06:09:19 +00:00
|
|
|
${ECHO} "${CANONICALOBJDIR} created for ${.CURDIR}"; \
|
1996-06-24 04:26:21 +00:00
|
|
|
fi
|
1996-04-22 23:31:39 +00:00
|
|
|
.endif
|
1996-06-24 04:26:21 +00:00
|
|
|
|
1999-03-21 06:43:40 +00:00
|
|
|
.if !target(objlink)
|
2002-04-23 09:03:56 +00:00
|
|
|
objlink:
|
1999-03-21 06:43:40 +00:00
|
|
|
@if test -d ${CANONICALOBJDIR}/; then \
|
|
|
|
rm -f ${.CURDIR}/obj; \
|
|
|
|
ln -s ${CANONICALOBJDIR} ${.CURDIR}/obj; \
|
|
|
|
else \
|
|
|
|
echo "No ${CANONICALOBJDIR} to link to - do a make obj."; \
|
|
|
|
fi
|
|
|
|
.endif
|
2005-04-11 07:13:29 +00:00
|
|
|
.endif # !defined(NO_OBJ)
|
1999-03-21 06:43:40 +00:00
|
|
|
|
1996-07-12 06:01:55 +00:00
|
|
|
#
|
|
|
|
# where would that obj directory be?
|
|
|
|
#
|
|
|
|
.if !target(whereobj)
|
|
|
|
whereobj:
|
1998-06-04 15:31:55 +00:00
|
|
|
@echo ${.OBJDIR}
|
1996-07-12 06:01:55 +00:00
|
|
|
.endif
|
|
|
|
|
2001-04-26 11:14:50 +00:00
|
|
|
.if ${CANONICALOBJDIR} != ${.CURDIR} && exists(${CANONICALOBJDIR}/)
|
2004-01-02 05:05:48 +00:00
|
|
|
cleanobj:
|
2001-04-26 11:14:50 +00:00
|
|
|
@rm -rf ${CANONICALOBJDIR}
|
|
|
|
.else
|
2004-01-02 05:05:48 +00:00
|
|
|
cleanobj: clean cleandepend
|
2001-04-26 11:14:50 +00:00
|
|
|
.endif
|
2002-08-31 02:22:33 +00:00
|
|
|
@if [ -L ${.CURDIR}/obj ]; then rm -f ${.CURDIR}/obj; fi
|
1996-04-09 22:43:33 +00:00
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
# Tell bmake not to look for generated files via .PATH
|
|
|
|
.if !empty(CLEANFILES)
|
|
|
|
.NOPATH: ${CLEANFILES}
|
|
|
|
.endif
|
|
|
|
|
1996-04-09 22:43:33 +00:00
|
|
|
.if !target(clean)
|
2002-04-23 09:03:56 +00:00
|
|
|
clean:
|
1997-12-19 18:48:45 +00:00
|
|
|
.if defined(CLEANFILES) && !empty(CLEANFILES)
|
2005-01-06 11:12:43 +00:00
|
|
|
rm -f ${CLEANFILES}
|
1997-12-19 18:48:45 +00:00
|
|
|
.endif
|
1998-02-25 02:48:28 +00:00
|
|
|
.if defined(CLEANDIRS) && !empty(CLEANDIRS)
|
|
|
|
rm -rf ${CLEANDIRS}
|
|
|
|
.endif
|
1996-04-09 22:43:33 +00:00
|
|
|
.endif
|
|
|
|
|
2002-04-23 09:03:56 +00:00
|
|
|
cleandir: cleanobj
|
1998-05-06 18:44:04 +00:00
|
|
|
|
2002-04-23 09:03:56 +00:00
|
|
|
.include <bsd.subdir.mk>
|
2002-04-17 13:49:29 +00:00
|
|
|
|
2014-05-02 01:39:30 +00:00
|
|
|
.if make(destroy*) && defined(OBJROOT)
|
|
|
|
# this is much faster and more reliable than cleaning.
|
|
|
|
|
|
|
|
# just in case we are playing games with these...
|
|
|
|
_OBJDIR?= ${.OBJDIR}
|
|
|
|
_CURDIR?= ${.CURDIR}
|
|
|
|
|
|
|
|
destroy-arch: .NOMETA
|
|
|
|
.if ${_OBJDIR} != ${_CURDIR}
|
|
|
|
cd ${_CURDIR} && rm -rf ${_OBJDIR}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
destroy: destroy-all
|
|
|
|
destroy-all:
|
|
|
|
|
|
|
|
.if ${_OBJDIR} != ${_CURDIR}
|
|
|
|
.for m in ${ALL_MACHINE_LIST}
|
|
|
|
destroy-all: destroy.$m
|
|
|
|
destroy.$m: .NOMETA
|
|
|
|
cd ${_CURDIR} && rm -rf ${OBJROOT}$m*/${RELDIR:N.}
|
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.endif
|
|
|
|
|
2005-04-11 07:13:29 +00:00
|
|
|
.endif # !target(__<bsd.obj.mk>__)
|