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
|
|
|
#
|
1996-09-29 18:28:55 +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
|
|
|
#
|
1996-09-29 18:28:55 +00:00
|
|
|
# NOOBJ Do not create object directories. This should not be set
|
|
|
|
# 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}
|
|
|
|
.else
|
|
|
|
CANONICALOBJDIR:=/usr/obj${.CURDIR}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
#
|
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:
|
2001-05-20 12:14:17 +00:00
|
|
|
.if !defined(NOOBJ) && ${.OBJDIR} != ${CANONICALOBJDIR} && \
|
|
|
|
!(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
|
|
|
|
2002-06-21 07:30:51 +00:00
|
|
|
.if !defined(NOOBJ)
|
|
|
|
.if !target(obj)
|
1996-03-24 22:49:16 +00:00
|
|
|
obj:
|
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
|
2002-06-21 07:30:51 +00:00
|
|
|
.endif !defined(NOOBJ)
|
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
|
|
|
|
|
1996-06-24 04:26:21 +00:00
|
|
|
cleanobj:
|
2001-04-26 11:14:50 +00:00
|
|
|
.if ${CANONICALOBJDIR} != ${.CURDIR} && exists(${CANONICALOBJDIR}/)
|
|
|
|
@rm -rf ${CANONICALOBJDIR}
|
|
|
|
.else
|
|
|
|
@cd ${.CURDIR} && ${MAKE} clean cleandepend
|
|
|
|
.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
|
|
|
|
|
|
|
.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)
|
|
|
|
rm -f ${CLEANFILES}
|
|
|
|
.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
|
|
|
|
|
|
|
.endif !target(__<bsd.obj.mk>__)
|