1# $OpenBSD: bsd.obj.mk,v 1.13 2007/05/01 08:31:13 espie Exp $ 2# $NetBSD: bsd.obj.mk,v 1.9 1996/04/10 21:08:05 thorpej Exp $ 3 4.if !target(obj) 5. if defined(NOOBJ) 6obj: 7. else 8 9. if defined(MAKEOBJDIR) 10__baseobjdir= ${MAKEOBJDIR} 11. else 12__baseobjdir= obj 13. endif 14 15. if defined(OBJMACHINE) 16__objdir= ${__baseobjdir}.${MACHINE} 17. else 18__objdir= ${__baseobjdir} 19. endif 20 21. if defined(USR_OBJMACHINE) 22__usrobjdir= ${BSDOBJDIR}.${MACHINE} 23__usrobjdirpf= 24. else 25__usrobjdir= ${BSDOBJDIR} 26. if defined(OBJMACHINE) 27__usrobjdirpf= .${MACHINE} 28. else 29__usrobjdirpf= 30. endif 31. endif 32 33_SUBDIRUSE: 34 35obj! _SUBDIRUSE 36 @cd ${.CURDIR}; \ 37 here=`/bin/pwd`; bsdsrcdir=`cd ${BSDSRCDIR}; /bin/pwd`; \ 38 subdir=$${here#$${bsdsrcdir}/}; \ 39 if test $$here != $$subdir ; then \ 40 dest=${__usrobjdir}/$$subdir${__usrobjdirpf} ; \ 41 echo "$$here/${__objdir} -> $$dest"; \ 42 if test ! -L ${__objdir} -o \ 43 X`readlink ${__objdir}` != X$$dest; \ 44 then \ 45 if test -e ${__objdir}; then rm -rf ${__objdir}; fi; \ 46 ln -sf $$dest ${__objdir}; \ 47 fi; \ 48 if test -d ${__usrobjdir}; then \ 49 test -d $$dest || mkdir -p $$dest; \ 50 else \ 51 if test -e ${__usrobjdir}; then \ 52 echo "${__usrobjdir} is not a directory"; \ 53 else \ 54 echo "${__usrobjdir} does not exist"; \ 55 fi; \ 56 fi; \ 57 else \ 58 true ; \ 59 dest=$$here/${__objdir} ; \ 60 if test ! -d ${__objdir} ; then \ 61 echo "making $$dest" ; \ 62 mkdir $$dest; \ 63 fi ; \ 64 fi; 65. endif 66.endif 67