1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
# $Id: obj.mk,v 1.15 2012/11/11 22:37:02 sjg Exp $
#
# @(#) Copyright (c) 1999-2010, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
.if !target(__${.PARSEFILE:S,bsd.,,}__)
__${.PARSEFILE:S,bsd.,,}__:
.include <init.mk>
ECHO_TRACE ?= echo
.if ${MK_OBJDIRS} == "no"
obj:
objlink:
objwarn:
.else
# this has to match how make behaves
.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
.if defined(MAKEOBJDIRPREFIX)
__objdir:= ${MAKEOBJDIRPREFIX}${.CURDIR}
.else
__objdir:= ${MAKEOBJDIR}
.endif
.else
__objdir= ${__objlink}
.endif
.if defined(OBJMACHINE)
__objlink= obj.${MACHINE}
.else
__objlink= obj
.endif
.if ${MK_AUTO_OBJ} == "yes"
.-include "auto.obj.mk"
.endif
.NOPATH: ${__objdir}
.PHONY: obj
obj: _SUBDIRUSE
@if test ! -d ${__objdir}/.; then \
mkdir -p ${__objdir}; \
if test ! -d ${__objdir}; then \
mkdir ${__objdir}; exit 1; \
fi; \
${ECHO_TRACE} "[Creating objdir ${__objdir}...]" >&2; \
fi
.if !target(_SUBDIRUSE)
# this just allows us to be included by ourselves
_SUBDIRUSE:
.endif
# so we can interact with freebsd makefiles
.if !target(objwarn)
objwarn:
.if ${.OBJDIR} == ${.CURDIR}
@echo "Warning Object directory is ${.CURDIR}"
.elif ${.OBJDIR} != ${__objdir}
@echo "Warning Object directory is ${.OBJDIR} vs. ${__objdir}"
.endif
.endif
.if !target(objlink)
objlink:
.if ${__objdir:T} != ${__objlink}
@if test -d ${__objdir}/.; then \
${RM} -f ${.CURDIR}/${__objlink}; \
${LN} -s ${__objdir} ${.CURDIR}/${__objlink}; \
echo "${__objlink} -> ${__objdir}"; \
else \
echo "No ${__objdir} to link to - do a 'make obj'"; \
fi
.endif
.endif
.endif
_CURDIR?= ${.CURDIR}
_OBJDIR?= ${.OBJDIR}
.if !target(print-objdir)
print-objdir:
@echo ${_OBJDIR}
.endif
.if !target(whereobj)
whereobj:
@echo ${_OBJDIR}
.endif
.if !target(destroy)
.if ${.CURDIR} != ${.OBJDIR}
destroy:
(cd ${_CURDIR} && rm -rf ${_OBJDIR})
.else
destroy: clean
.endif
.endif
.endif
|