2007-12-11 17:06:04 +03:00
|
|
|
# $NetBSD: bsd.obj.mk,v 1.48 2007/12/11 14:06:04 lukem Exp $
|
2003-07-28 06:38:33 +04:00
|
|
|
|
|
|
|
.if !defined(_BSD_OBJ_MK_)
|
|
|
|
_BSD_OBJ_MK_=1
|
1999-02-12 07:13:26 +03:00
|
|
|
|
|
|
|
.include <bsd.own.mk>
|
1993-08-15 23:26:05 +04:00
|
|
|
|
2001-10-31 04:46:42 +03:00
|
|
|
__curdir:= ${.CURDIR}
|
|
|
|
|
1999-02-12 04:10:06 +03:00
|
|
|
.if ${MKOBJ} == "no"
|
1993-08-15 23:26:05 +04:00
|
|
|
obj:
|
|
|
|
.else
|
2000-02-18 09:09:11 +03:00
|
|
|
.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
|
2000-02-08 15:38:16 +03:00
|
|
|
.if defined(MAKEOBJDIRPREFIX)
|
2001-11-12 21:49:12 +03:00
|
|
|
__objdir:= ${MAKEOBJDIRPREFIX}${__curdir}
|
2000-02-08 15:38:16 +03:00
|
|
|
.else
|
|
|
|
__objdir:= ${MAKEOBJDIR}
|
|
|
|
.endif
|
|
|
|
# MAKEOBJDIR and MAKEOBJDIRPREFIX are env variables supported
|
|
|
|
# by make(1). We simply mkdir -p the specified path.
|
|
|
|
# If that fails - we do a mkdir to get the appropriate error message
|
|
|
|
# before bailing out.
|
|
|
|
obj:
|
2001-11-27 08:42:24 +03:00
|
|
|
.if defined(MAKEOBJDIRPREFIX)
|
|
|
|
@if [ ! -d ${MAKEOBJDIRPREFIX} ]; then \
|
|
|
|
echo "MAKEOBJDIRPREFIX ${MAKEOBJDIRPREFIX} does not exist, bailing..."; \
|
|
|
|
exit 1; \
|
2003-07-18 08:04:03 +04:00
|
|
|
fi;
|
2001-11-27 08:42:24 +03:00
|
|
|
.endif
|
2001-11-12 01:39:23 +03:00
|
|
|
@if [ ! -d ${__objdir} ]; then \
|
2000-02-08 15:38:16 +03:00
|
|
|
mkdir -p ${__objdir}; \
|
2001-11-12 01:39:23 +03:00
|
|
|
if [ ! -d ${__objdir} ]; then \
|
2000-02-08 15:38:16 +03:00
|
|
|
mkdir ${__objdir}; exit 1; \
|
|
|
|
fi; \
|
2003-11-07 01:47:22 +03:00
|
|
|
${_MKSHMSG} " objdir ${__objdir}"; \
|
2000-02-08 15:38:16 +03:00
|
|
|
fi
|
|
|
|
.else
|
2001-11-12 02:19:14 +03:00
|
|
|
PAWD?= /bin/pwd
|
|
|
|
|
|
|
|
__objdir= obj${OBJMACHINE:D.${MACHINE}}
|
1993-10-23 05:32:55 +03:00
|
|
|
|
2001-11-12 02:22:19 +03:00
|
|
|
__usrobjdir= ${BSDOBJDIR}${USR_OBJMACHINE:D.${MACHINE}}
|
2001-11-29 14:57:21 +03:00
|
|
|
__usrobjdirpf= ${USR_OBJMACHINE:D:U${OBJMACHINE:D.${MACHINE}}}
|
2001-11-12 02:19:14 +03:00
|
|
|
|
2002-03-14 21:26:32 +03:00
|
|
|
.if defined(BUILDID)
|
|
|
|
__objdir:= ${__objdir}.${BUILDID}
|
|
|
|
__usrobjdirpf:= ${__usrobjdirpf}.${BUILDID}
|
|
|
|
__need_objdir_target=yes
|
|
|
|
.endif
|
|
|
|
|
2001-11-15 01:29:23 +03:00
|
|
|
.if defined(OBJHOSTMACHINE) && (${MKHOSTOBJ:Uno} != "no")
|
2001-11-12 02:19:14 +03:00
|
|
|
# In case .CURDIR has been twiddled by a .mk file and is now relative,
|
|
|
|
# make it absolute again.
|
2001-11-12 21:49:12 +03:00
|
|
|
.if ${__curdir:M/*} == ""
|
|
|
|
__curdir!= cd ${__curdir} && ${PAWD}
|
1993-10-23 05:32:55 +03:00
|
|
|
.endif
|
|
|
|
|
2001-11-12 02:19:14 +03:00
|
|
|
__objdir:= ${__objdir}.${HOST_OSTYPE}
|
|
|
|
__usrobjdirpf:= ${__usrobjdirpf}.${HOST_OSTYPE}
|
2002-03-14 21:26:32 +03:00
|
|
|
__need_objdir_target=yes
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if defined(__need_objdir_target)
|
2007-12-11 17:06:04 +03:00
|
|
|
# Get make to change its internal definition of .OBJDIR
|
2001-11-12 02:19:14 +03:00
|
|
|
.OBJDIR: ${__objdir}
|
|
|
|
.endif
|
1999-06-08 22:28:38 +04:00
|
|
|
|
1997-05-07 21:06:16 +04:00
|
|
|
obj:
|
2001-08-14 13:30:48 +04:00
|
|
|
@cd ${__curdir}; \
|
2001-11-12 01:39:23 +03:00
|
|
|
here=`${PAWD}`/; subdir=$${here#${BSDSRCDIR}/}; \
|
2001-11-12 02:07:26 +03:00
|
|
|
if [ "$$here" != "$$subdir" ]; then \
|
2001-11-12 01:39:23 +03:00
|
|
|
if [ ! -d ${__usrobjdir} ]; then \
|
2001-06-10 17:32:21 +04:00
|
|
|
echo "BSDOBJDIR ${__usrobjdir} does not exist, bailing..."; \
|
|
|
|
exit 1; \
|
|
|
|
fi; \
|
2001-11-12 01:39:23 +03:00
|
|
|
subdir=$${subdir%/}; \
|
|
|
|
dest=${__usrobjdir}/$$subdir${__usrobjdirpf}; \
|
2003-12-04 15:15:20 +03:00
|
|
|
if [ -x ${TOOL_STAT} ] && \
|
|
|
|
ttarg=`${TOOL_STAT} -qf '%Y' $${here}${__objdir}` && \
|
2003-07-20 19:02:10 +04:00
|
|
|
[ "$$dest" = "$$ttarg" ]; then \
|
|
|
|
: ; \
|
1999-12-04 05:44:07 +03:00
|
|
|
else \
|
2003-11-07 01:47:22 +03:00
|
|
|
${_MKSHMSG} " objdir $$dest"; \
|
1999-12-04 05:44:07 +03:00
|
|
|
rm -rf ${__objdir}; \
|
|
|
|
ln -s $$dest ${__objdir}; \
|
|
|
|
fi; \
|
2001-11-12 01:39:23 +03:00
|
|
|
if [ ! -d $$dest ]; then \
|
1993-08-15 23:26:05 +04:00
|
|
|
mkdir -p $$dest; \
|
|
|
|
else \
|
|
|
|
true; \
|
|
|
|
fi; \
|
|
|
|
else \
|
|
|
|
true ; \
|
2001-11-12 02:07:26 +03:00
|
|
|
dest=$${here}${__objdir} ; \
|
2001-11-12 01:39:23 +03:00
|
|
|
if [ ! -d ${__objdir} ] || [ -h ${__objdir} ]; then \
|
2003-11-07 01:47:22 +03:00
|
|
|
${_MKSHMSG} " objdir $$dest"; \
|
1999-12-04 05:44:07 +03:00
|
|
|
rm -f ${__objdir}; \
|
1993-08-15 23:26:05 +04:00
|
|
|
mkdir $$dest; \
|
|
|
|
fi ; \
|
|
|
|
fi;
|
|
|
|
.endif
|
2000-02-08 15:38:16 +03:00
|
|
|
.endif
|
1998-08-27 20:54:59 +04:00
|
|
|
|
1998-08-28 00:33:45 +04:00
|
|
|
print-objdir:
|
1998-08-27 20:54:59 +04:00
|
|
|
@echo ${.OBJDIR}
|
2003-07-28 04:57:25 +04:00
|
|
|
|
|
|
|
.include <bsd.sys.mk>
|
2003-07-28 06:38:33 +04:00
|
|
|
|
|
|
|
.endif # !defined(_BSD_OBJ_MK_)
|