1 # $Id: obj.mk,v 1.15 2012/11/11 22:37:02 sjg Exp $
3 # @(#) Copyright (c) 1999-2010, Simon J. Gerraty
5 # This file is provided in the hope that it will
6 # be of use. There is absolutely NO WARRANTY.
7 # Permission to copy, redistribute or otherwise
8 # use this file is hereby granted provided that
9 # the above copyright notice and this notice are
12 # Please send copies of changes and bug-fixes to:
16 .if !target(__${.PARSEFILE:S,bsd.,,}__)
17 __${.PARSEFILE:S,bsd.,,}__:
23 .if ${MK_OBJDIRS} == "no"
29 # this has to match how make behaves
30 .if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
31 .if defined(MAKEOBJDIRPREFIX)
32 __objdir:= ${MAKEOBJDIRPREFIX}${.CURDIR}
34 __objdir:= ${MAKEOBJDIR}
37 __objdir= ${__objlink}
40 .if defined(OBJMACHINE)
41 __objlink= obj.${MACHINE}
46 .if ${MK_AUTO_OBJ} == "yes"
47 .-include "auto.obj.mk"
54 @if test ! -d ${__objdir}/.; then \
55 mkdir -p ${__objdir}; \
56 if test ! -d ${__objdir}; then \
57 mkdir ${__objdir}; exit 1; \
59 ${ECHO_TRACE} "[Creating objdir ${__objdir}...]" >&2; \
62 .if !target(_SUBDIRUSE)
63 # this just allows us to be included by ourselves
67 # so we can interact with freebsd makefiles
70 .if ${.OBJDIR} == ${.CURDIR}
71 @echo "Warning Object directory is ${.CURDIR}"
72 .elif ${.OBJDIR} != ${__objdir}
73 @echo "Warning Object directory is ${.OBJDIR} vs. ${__objdir}"
79 .if ${__objdir:T} != ${__objlink}
80 @if test -d ${__objdir}/.; then \
81 ${RM} -f ${.CURDIR}/${__objlink}; \
82 ${LN} -s ${__objdir} ${.CURDIR}/${__objlink}; \
83 echo "${__objlink} -> ${__objdir}"; \
85 echo "No ${__objdir} to link to - do a 'make obj'"; \
94 .if !target(print-objdir)
105 .if ${.CURDIR} != ${.OBJDIR}
107 (cd ${_CURDIR} && rm -rf ${_OBJDIR})