No empty .Rs/.Re
[netbsd-mini2440.git] / share / mk / bsd.obj.mk
blobeff4dbbaa2c96493784f86b98a8dbeeeb420deed
1 # $NetBSD: bsd.obj.mk,v 1.47 2006/11/26 20:09:57 dsl Exp $
3 .if !defined(_BSD_OBJ_MK_)
4 _BSD_OBJ_MK_=1
6 .include <bsd.own.mk>
8 __curdir:= ${.CURDIR}
10 .if ${MKOBJ} == "no"
11 obj:
12 .else
13 .if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
14 .if defined(MAKEOBJDIRPREFIX)
15 __objdir:= ${MAKEOBJDIRPREFIX}${__curdir}
16 .else
17 __objdir:= ${MAKEOBJDIR}
18 .endif
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
22 # before bailing out.
23 obj:
24 .if defined(MAKEOBJDIRPREFIX)
25 @if [ ! -d ${MAKEOBJDIRPREFIX} ]; then \
26 echo "MAKEOBJDIRPREFIX ${MAKEOBJDIRPREFIX} does not exist, bailing..."; \
27 exit 1; \
28 fi;
29 .endif
30 @if [ ! -d ${__objdir} ]; then \
31 mkdir -p ${__objdir}; \
32 if [ ! -d ${__objdir} ]; then \
33 mkdir ${__objdir}; exit 1; \
34 fi; \
35 ${_MKSHMSG} " objdir ${__objdir}"; \
37 .else
38 PAWD?= /bin/pwd
40 __objdir= obj${OBJMACHINE:D.${MACHINE}}
42 __usrobjdir= ${BSDOBJDIR}${USR_OBJMACHINE:D.${MACHINE}}
43 __usrobjdirpf= ${USR_OBJMACHINE:D:U${OBJMACHINE:D.${MACHINE}}}
45 .if defined(BUILDID)
46 __objdir:= ${__objdir}.${BUILDID}
47 __usrobjdirpf:= ${__usrobjdirpf}.${BUILDID}
48 __need_objdir_target=yes
49 .endif
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}
56 .endif
58 __objdir:= ${__objdir}.${HOST_OSTYPE}
59 __usrobjdirpf:= ${__usrobjdirpf}.${HOST_OSTYPE}
60 __need_objdir_target=yes
61 .endif
63 .if defined(__need_objdir_target)
64 # Get make to change its internal definition of .OBJDIR
65 .OBJDIR: ${__objdir}
66 .endif
68 obj:
69 @cd ${__curdir}; \
70 here=`${PAWD}`/; subdir=$${here#${BSDSRCDIR}/}; \
71 if [ "$$here" != "$$subdir" ]; then \
72 if [ ! -d ${__usrobjdir} ]; then \
73 echo "BSDOBJDIR ${__usrobjdir} does not exist, bailing..."; \
74 exit 1; \
75 fi; \
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 \
81 : ; \
82 else \
83 ${_MKSHMSG} " objdir $$dest"; \
84 rm -rf ${__objdir}; \
85 ln -s $$dest ${__objdir}; \
86 fi; \
87 if [ ! -d $$dest ]; then \
88 mkdir -p $$dest; \
89 else \
90 true; \
91 fi; \
92 else \
93 true ; \
94 dest=$${here}${__objdir} ; \
95 if [ ! -d ${__objdir} ] || [ -h ${__objdir} ]; then \
96 ${_MKSHMSG} " objdir $$dest"; \
97 rm -f ${__objdir}; \
98 mkdir $$dest; \
99 fi ; \
101 .endif
102 .endif
104 print-objdir:
105 @echo ${.OBJDIR}
107 .include <bsd.sys.mk>
109 .endif # !defined(_BSD_OBJ_MK_)