1 # $NetBSD: bsd.obj.mk,v 1.49 2010/01/25 00:43:00 christos Exp $
3 .if
!defined
(_BSD_OBJ_MK_
)
13 .if defined
(MAKEOBJDIRPREFIX
) || defined
(MAKEOBJDIR
)
14 .if defined
(MAKEOBJDIRPREFIX
)
15 __objdir
:= ${MAKEOBJDIRPREFIX}${__curdir}
17 __objdir
:= ${MAKEOBJDIR}
19 # MAKEOBJDIR and MAKEOBJDIRPREFIX are env variables supported
20 # by make(1). We simply mkdir -p the specified path.
21 # If that fails - we do a mkdir to get the appropriate error message
24 .if defined
(MAKEOBJDIRPREFIX
)
25 @if
[ ! -d
${MAKEOBJDIRPREFIX} ]; then \
26 echo
"MAKEOBJDIRPREFIX ${MAKEOBJDIRPREFIX} does not exist, bailing..."; \
30 @if
[ ! -d
${__objdir} ]; then \
31 mkdir
-p
${__objdir}; \
32 if
[ ! -d
${__objdir} ]; then \
33 mkdir
${__objdir}; exit
1; \
35 ${_MKSHMSG} " objdir ${__objdir}"; \
40 __objdir
= obj
${OBJMACHINE
:D.
${MACHINE}}
42 __usrobjdir
= ${BSDOBJDIR}${USR_OBJMACHINE
:D.
${MACHINE}}
43 __usrobjdirpf
= ${USR_OBJMACHINE
:D
:U
${OBJMACHINE
:D.
${MACHINE}}}
46 __objdir
:= ${__objdir}.
${BUILDID}
47 __usrobjdirpf
:= ${__usrobjdirpf}.
${BUILDID}
48 __need_objdir_target
=yes
51 .if defined
(OBJHOSTMACHINE
) && (${MKHOSTOBJ
:Uno
} != "no")
52 # In case .CURDIR has been twiddled by a .mk file and is now relative,
53 # make it absolute again.
54 .if
${__curdir
:M
/*} == ""
55 __curdir
!= cd
"${__curdir}" && ${PAWD}
58 __objdir
:= ${__objdir}.
${HOST_OSTYPE}
59 __usrobjdirpf
:= ${__usrobjdirpf}.
${HOST_OSTYPE}
60 __need_objdir_target
=yes
63 .if defined
(__need_objdir_target
)
64 # Get make to change its internal definition of .OBJDIR
70 here
=`${PAWD}`/; subdir
=$${here
#${BSDSRCDIR}/}; \
71 if
[ "$$here" != "$$subdir" ]; then \
72 if
[ ! -d
${__usrobjdir} ]; then \
73 echo
"BSDOBJDIR ${__usrobjdir} does not exist, bailing..."; \
76 subdir
=$${subdir
%/}; \
77 dest
=${__usrobjdir}/$$subdir${__usrobjdirpf}; \
78 if
[ -x
${TOOL_STAT} ] && \
79 ttarg
=`${TOOL_STAT} -qf '%Y' $${here}${__objdir}` && \
80 [ "$$dest" = "$$ttarg" ]; then \
83 ${_MKSHMSG} " objdir $$dest"; \
85 ln
-s
$$dest ${__objdir}; \
87 if
[ ! -d
$$dest ]; then \
94 dest
=$${here}${__objdir} ; \
95 if
[ ! -d
${__objdir} ] ||
[ -h
${__objdir} ]; then \
96 ${_MKSHMSG} " objdir $$dest"; \
107 .
include <bsd.sys.mk
>
109 .
endif # !defined(_BSD_OBJ_MK_)