summaryrefslogtreecommitdiff
path: root/Makefile.cross
blob: fd2c238872865fa36c3374ff7381a6606e00d9f2 (plain)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# $OpenBSD: Makefile.cross,v 1.78 2015/06/05 21:48:35 tobiasu Exp $

cross-tools:	cross-includes cross-binutils cross-gcc cross-lib
cross-distrib:	cross-tools cross-bin cross-share cross-sys cross-etc-root-var
# cross-gnu \

# Have to compute TARGET_ARCH directly in the Makefile, for .if tests involving
# this variable to work.
.if	(${TARGET} == "armish" || ${TARGET} == "armv7" || \
	 ${TARGET} == "zaurus")
TARGET_ARCH=	arm
.elif	(${TARGET} == "aviion" || ${TARGET} == "luna88k")
TARGET_ARCH=	m88k
.elif	(${TARGET} == "sgi" || ${TARGET} == "octeon")
TARGET_ARCH=	mips64
.elif	(${TARGET} == "loongson")
TARGET_ARCH=	mips64el
TARGET_CPU=	mips64
.elif	(${TARGET} == "solbourne")
TARGET_ARCH=	sparc
.elif	(${TARGET} == "macppc" || ${TARGET} == "socppc")
TARGET_ARCH=	powerpc
.elif	(${TARGET} == "landisk")
TARGET_ARCH=	sh
.else
TARGET_ARCH=	${TARGET}
.endif
TARGET_CPU?=	${TARGET_ARCH}

# List of LP64 archs
# XXX move to bsd.*.mk?
LP64_ARCH = amd64 alpha hppa64 ia64 mips64 sparc64 vax64

TARGET_IS_LP64 =
MACHINE_IS_LP64 =
.for _ in ${LP64_ARCH}
. if !empty(TARGET_ARCH:M$_)
    TARGET_IS_LP64 = yes
. endif
. if !empty(MACHINE_ARCH:M$_)
    MACHINE_IS_LP64 = yes
. endif
.endfor

#CROSSCPPFLAGS?=	-nostdinc -I${CROSSDIR}/usr/include
#CROSSLDFLAGS?=	-nostdlib -L${CROSSDIR}/usr/lib -static
CROSSCFLAGS?=	${CROSSCPPFLAGS} -O2 ${PIPE} ${DEBUG}
CROSSCXXFLAGS?=	${CROSSCPPFLAGS}
#LDSTATIC?=	-static

CROSSDIR=	${DESTDIR}/usr/cross/${TARGET}
CROSSENV=	AR=${CROSSDIR}/usr/${TARGET_CANON}/bin/ar \
		AS=${CROSSDIR}/usr/${TARGET_CANON}/bin/as \
		CC=${CROSSDIR}/usr/${TARGET_CANON}/bin/cc \
		CPP=${CROSSDIR}/usr/${TARGET_CANON}/bin/cpp \
		CXX=${CROSSDIR}/usr/${TARGET_CANON}/bin/c++ \
		LD=${CROSSDIR}/usr/${TARGET_CANON}/bin/ld \
		OBJCOPY=${CROSSDIR}/usr/${TARGET_CANON}/bin/objcopy \
		LORDER=/usr/bin/lorder RANLIB=${CROSSDIR}/usr/${TARGET_CANON}/bin/ranlib \
		STRIP=${CROSSDIR}/usr/${TARGET_CANON}/bin/strip \
		HOSTCC=\"${CC}\" HOSTCXX=\"${CXX}\" NOMAN= \
		HOSTCFLAGS=\"${CFLAGS}\" HOSTCXXFLAGS=\"${CXXFLAGS}\" \
		HOSTLDFLAGS=\"${LDFLAGS}\" \
		CFLAGS=\"${CROSSCFLAGS}\" CPPFLAGS=\"${CROSSCPPFLAGS}\" \
		CXXFLAGS=\"${CROSSCXXFLAGS}\" \
		LDFLAGS=\"${CROSSLDFLAGS}\"
CROSSADDPATH=:${CROSSDIR}/usr/${TARGET_CANON}/bin
CROSSPATH=	/usr/bin:/bin:/usr/sbin:/sbin${CROSSADDPATH}
CROSSLANGS?=	c c++

TARGET_CANON=`cat ${CROSSDIR}/TARGET_CANON`

CROSSDIRS=	${CROSSDIR}/.dirs_done
CROSSOBJ=	${CROSSDIR}/.obj_done
CROSSINCLUDES=	${CROSSDIR}/.includes_done
CROSSBINUTILS=	${CROSSDIR}/.binutils_done
CROSSGCC=	${CROSSDIR}/.gcc_done
#NO_CROSS=	isakmpd keynote ssh

.include <bsd.own.mk>

.for _arch in ${TARGET_ARCH}
.if !empty(GCC3_ARCH:M${_arch})
COMPILER_VERSION=gcc3
.else
COMPILER_VERSION=gcc4
.endif

.if !empty(PIE_ARCH:M${_arch})
NOPIE_FLAGS=-fno-pie
NOPIE_LDFLAGS=-nopie
PIE_DEFAULT=${DEFAULT_PIE_DEF}
.else
NOPIE_FLAGS=
PIE_DEFAULT=
.endif

BINUTILS=	ar as gasp ld nm objcopy objdump ranlib readelf size \
		strings strip
BINUTILS_DIR=gnu/usr.bin/binutils-2.17
.endfor

# no libcrypto.... these won't build
#NO_CROSS+=	dc passwd ppp tcpdump telnet ftp sasyncd vnconfig
		
# explicit cross-compile
NO_CROSS+=microcode
NO_CROSS+=groff binutils binutils-2.17 perl texinfo gcc cvs
NO_CROSS+=nsd
NO_CROSS+=sqlite3
NO_CROSS+=bind
NO_CROSS+=unbound

cross-dirs:	${CROSSDIRS}
cross-obj:	${CROSSOBJ}
cross-includes:	${CROSSINCLUDES}
cross-binutils:	${CROSSBINUTILS}
cross-gcc:	${CROSSGCC}

cross-env:
	@echo ${CROSSENV} MACHINE=${TARGET} \
	    MACHINE_ARCH=`cat ${CROSSDIR}/TARGET_ARCH` \
	    MACHINE_CPU=`cat ${CROSSDIR}/TARGET_CPU` \
	    BSDOBJDIR=${CROSSDIR}/usr/obj \
	    BSDSRCDIR=${.CURDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET}

${CROSSDIRS}:
.if ${TARGET_ARCH} == "arm" &&  ${MACHINE_IS_LP64} == "yes"
	# this config is allowed
.elif ${TARGET_IS_LP64} != ${MACHINE_IS_LP64}
	@echo "host and target have different size longs"
	@echo "cross compiler generates bad code; aborting"; exit 1
.endif
	@-mkdir -p ${CROSSDIR}
	@echo ${TARGET_ARCH} > ${CROSSDIR}/TARGET_ARCH
	@echo TARGET_ARCH is `cat ${CROSSDIR}/TARGET_ARCH`
	@echo ${TARGET_CPU} > ${CROSSDIR}/TARGET_CPU
	@echo TARGET_CPU is `cat ${CROSSDIR}/TARGET_CPU`
	@eval `grep '^osr=' sys/conf/newvers.sh`; \
	   echo ${TARGET_ARCH}-unknown-openbsd$$osr > \
	   ${CROSSDIR}/TARGET_CANON
	@-mkdir -p ${CROSSDIR}
	@-mkdir -p ${CROSSDIR}/usr/${TARGET_CANON}
	@ln -sf ${CROSSDIR}/usr/include \
	    ${CROSSDIR}/usr/${TARGET_CANON}/include
	@ln -sf ${CROSSDIR}/usr/lib \
	    ${CROSSDIR}/usr/${TARGET_CANON}/lib
	@-mkdir -p ${CROSSDIR}/usr/${TARGET_CANON}/bin
	@(cd ${.CURDIR}/etc && DESTDIR=${CROSSDIR} ${MAKE} distrib-dirs)
	@touch ${CROSSDIRS}

${CROSSOBJ}:	${CROSSDIRS}
	@-mkdir -p ${CROSSDIR}/usr/obj
	@(cd ${.CURDIR} && \
	    BSDOBJDIR=${CROSSDIR}/usr/obj \
	    COMPILER_VERSION=${COMPILER_VERSION} \
	    MACHINE=${TARGET} \
	    MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU} \
	    BSDSRCDIR=${.CURDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    ${MAKE} obj)
	@touch ${CROSSOBJ}

${CROSSINCLUDES}:	${CROSSOBJ}
	@-mkdir -p ${CROSSDIR}/usr/include
	@(cd ${.CURDIR}/include && \
	    COMPILER_VERSION=${COMPILER_VERSION} \
	    MACHINE=${TARGET} \
	    MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU} \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
	    ${MAKE} prereq && \
	    COMPILER_VERSION=${COMPILER_VERSION} \
	    MACHINE=${TARGET} \
	    MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU} \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
	    ${MAKE} DESTDIR=${CROSSDIR} includes)
	@touch ${CROSSINCLUDES}

${CROSSBINUTILS}:	${CROSSINCLUDES}
	(cd ${.CURDIR}/${BINUTILS_DIR}; \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    PIE_DEFAULT=${PIE_DEFAULT} \
	    TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
	    PATH=${CROSSPATH} \
	    ${MAKE} -f Makefile.bsd-wrapper depend && \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    PIE_DEFAULT=${PIE_DEFAULT} \
	    TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
	    ${MAKE} -f Makefile.bsd-wrapper all && \
	    DESTDIR=${CROSSDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    COMPILER_VERSION=${COMPILER_VERSION} \
	    PIE_DEFAULT=${PIE_DEFAULT} \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
	    ${MAKE} -f Makefile.bsd-wrapper install)
	@for cmd in ${BINUTILS}; do \
	 if [ -e ${CROSSDIR}/usr/bin/${TARGET_CANON}-$$cmd ] ; then \
	    cp -f ${CROSSDIR}/usr/bin/${TARGET_CANON}-$$cmd \
	        ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-$$cmd ; \
	    ln -sf ${TARGET_CANON}-$$cmd \
		${CROSSDIR}/usr/${TARGET_CANON}/bin/$$cmd ;\
	   if [ -e ${CROSSDIR}/usr/bin/$$cmd ] ; then \
	    rm -f ${CROSSDIR}/usr/bin/$$cmd ;\
	   fi ;\
	 elif [ -e ${CROSSDIR}/usr/bin/$$cmd ] ; then \
	    cp -f ${CROSSDIR}/usr/bin/$$cmd \
	        ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-$$cmd ; \
	    ln -sf ${TARGET_CANON}-$$cmd \
		${CROSSDIR}/usr/${TARGET_CANON}/bin/$$cmd ;\
	    mv ${CROSSDIR}/usr/bin/$$cmd \
		${CROSSDIR}/usr/bin/${TARGET_CANON}-$$cmd ;\
	 fi ;\
	done
	@touch ${CROSSBINUTILS}


${CROSSGCC}:		${CROSSBINUTILS}
.if ${COMPILER_VERSION:L} == "gcc3"
	(cd ${.CURDIR}/gnu/usr.bin/gcc; \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
	    CROSSDIR=${CROSSDIR} \
	    PATH=${CROSSPATH} ${MAKE} -f Makefile.bsd-wrapper depend && \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
	    CROSSDIR=${CROSSDIR} \
	    ${MAKE} -f Makefile.bsd-wrapper all && \
	    env CROSSDIR=${CROSSDIR} DESTDIR=${CROSSDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    PATH=${CROSSPATH} ${MAKE} -f Makefile.bsd-wrapper install)
	cp -f ${CROSSDIR}/usr/bin/${TARGET_CANON}-g++ ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-c++
	cp -f ${CROSSDIR}/usr/bin/gcc ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
	cp -f ${CROSSDIR}/usr/libexec/cpp ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-libexeccpp
	rm -f ${CROSSDIR}/usr/bin/gcc  ${CROSSDIR}/usr/bin/cc ${CROSSDIR}/usr/libexec/cpp 
	ln -sf ${TARGET_CANON}-cc ${CROSSDIR}/usr/${TARGET_CANON}/bin/cc
	ln -sf ${TARGET_CANON}-c++ ${CROSSDIR}/usr/${TARGET_CANON}/bin/c++
	rm -f ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cpp 
	sed -e 's#/usr/libexec/cpp#${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-libexeccpp#' \
	    -e 's/@GNUC@/-D__GNUC__/' \
	    -e 's#/usr/include#${CROSSDIR}/usr/include#' \
	    -e 's/@dollaropt@//' \
	    ${.CURDIR}/usr.bin/cpp/cpp.sh > ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cpp 
	chmod ${BINMODE} ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cpp 
	chown ${BINOWN}:${BINGRP} ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cpp 
	ln -sf ${TARGET_CANON}-cpp ${CROSSDIR}/usr/${TARGET_CANON}/bin/cpp
.else
	(cd ${.CURDIR}/gnu/usr.bin/cc; \
	    PIE_DEFAULT=${PIE_DEFAULT} \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
	    CROSSDIR=${CROSSDIR} \
	    MACHINE=${TARGET} \
	    PATH=${CROSSPATH} ${MAKE} depend  )
	(cd ${.CURDIR}/gnu/usr.bin/cc; \
	    PIE_DEFAULT=${PIE_DEFAULT} \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
	    CROSSDIR=${CROSSDIR} \
	    MACHINE=${TARGET} \
	    ${MAKE} all )
	(cd ${.CURDIR}/gnu/usr.bin/cc; \
	    env CROSSDIR=${CROSSDIR} DESTDIR=${CROSSDIR} \
	    PIE_DEFAULT=${PIE_DEFAULT} \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
	    MACHINE=${TARGET} \
	    PATH=${CROSSPATH} ${MAKE} install)
	cp -f ${CROSSDIR}/usr/bin/g++  ${CROSSDIR}/usr/bin/${TARGET_CANON}-g++ 
	cp -f ${CROSSDIR}/usr/bin/${TARGET_CANON}-g++ ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-c++
	cp -f ${CROSSDIR}/usr/libexec/cpp ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-libexeccpp
	cp -f ${CROSSDIR}/usr/bin/gcc ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
	ln -sf ${TARGET_CANON}-cc ${CROSSDIR}/usr/${TARGET_CANON}/bin/cc

	cp -f ${CROSSDIR}/usr/bin/gcc ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
	rm -f ${CROSSDIR}/usr/bin/gcc  ${CROSSDIR}/usr/bin/g++  ${CROSSDIR}/usr/bin/cc ${CROSSDIR}/usr/libexec/cpp 
	# fix links
	rm -f ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cpp 
	sed -e 's#/usr/libexec/cpp#${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-libexeccpp#' \
	    -e 's/@GNUC@//' \
	    -e 's#/usr/include#${CROSSDIR}/usr/include#' \
	    -e 's/@dollaropt@//' \
	    ${.CURDIR}/usr.bin/cpp/cpp.sh > ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cpp 
	chmod ${BINMODE} ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cpp 
	chown ${BINOWN}:${BINGRP} ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cpp 
	ln -sf ${TARGET_CANON}-cpp ${CROSSDIR}/usr/${TARGET_CANON}/bin/cpp
.endif
	@touch ${CROSSGCC}

# XXX MAKEOBJDIR maybe should be obj.${TARGET} here, revisit later
cross-lib:	${CROSSGCC}
	MACHINE=${TARGET} \
	    MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU} \
	    BSDOBJDIR=${CROSSDIR}/usr/obj; \
	export MACHINE MACHINE_ARCH MACHINE_CPU BSDOBJDIR; \
	(cd ${.CURDIR}/lib; \
	    for lib in csu libc; do \
	    (cd $$lib; \
	        eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
		    ${MAKE} depend all ;\
	        eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
		    ${MAKE} install); \
	    done; \
	    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	        SKIPDIR=\"${NO_CROSS} libocurses/PSD.doc\" \
	        ${MAKE} depend all ; \
	    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
	        SKIPDIR=\"${NO_CROSS} libocurses/PSD.doc\" \
	        ${MAKE} install)

cross-bin:	${CROSSOBJ}
	MACHINE=${TARGET} \
	    MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU}; \
	export MACHINE MACHINE_ARCH MACHINE_CPU; \
	for i in libexec bin sbin usr.bin usr.sbin; do \
	(cd ${.CURDIR}/$$i; \
	    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	        SKIPDIR=\"${BINUTILS} ${NO_CROSS}\" \
	        ${MAKE} depend all ; \
	    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
	        SKIPDIR=\"${BINUTILS} ${NO_CROSS}\" \
	        ${MAKE} install); \
	done

cross-gnu:	${CROSSOBJ}
	MACHINE=${TARGET} \
	    MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU}; \
	export MACHINE MACHINE_ARCH MACHINE_CPU; \
	for i in gnu/lib gnu/usr.sbin gnu/usr.bin ; do \
	(cd ${.CURDIR}/$$i; \
	    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	        SKIPDIR=\"${NO_CROSS}\" \
	        ${MAKE} depend all ; \
	    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
	        SKIPDIR=\"${NO_CROSS}\" \
	        ${MAKE} install); \
	done

cross-share:   ${CROSSOBJ}
	MACHINE=${TARGET} \
	    MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU}; \
	export MACHINE MACHINE_ARCH MACHINE_CPU; \
	for i in share; do \
	    (cd ${.CURDIR}/$$i; \
	        eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
		SKIPDIR=\"${NO_CROSS}\" \
		${MAKE} depend all install); \
	done

cross-sys:   ${CROSSOBJ}
	MACHINE=${TARGET} \
	    MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU}; \
	export MACHINE MACHINE_ARCH MACHINE_CPU; \
	for i in sys; do \
	    (cd ${.CURDIR}/$$i; \
	        eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
		SKIPDIR=\"${NO_CROSS}\" \
		${MAKE} depend all install); \
	done

cross-etc-root-var:	${CROSSOBJ}
	(cd ${.CURDIR}/etc && \
	    MACHINE=${TARGET} \
	    MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU} \
	    DESTDIR=${CROSSDIR} \
	    ${MAKE} distribution-etc-root-var)

cross-depend:
	@(cd ${.CURDIR} && \
	    BSDOBJDIR=${CROSSDIR}/usr/obj \
	    BSDSRCDIR=${.CURDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    SKIPDIR="${NO_CROSS}" \
	    ${MAKE} depend)

cross-clean:
	@(cd ${.CURDIR} && \
	    BSDOBJDIR=${CROSSDIR}/usr/obj \
	    BSDSRCDIR=${.CURDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    SKIPDIR="${NO_CROSS}" \
	    ${MAKE} clean)

cross-cleandir:
	@(cd ${.CURDIR} && \
	    BSDOBJDIR=${CROSSDIR}/usr/obj \
	    BSDSRCDIR=${.CURDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    SKIPDIR="${NO_CROSS}" \
	    ${MAKE} cleandir)