MFC: Support cross-building by just specifying TARGET.

Requested by:	sam
This commit is contained in:
ru 2006-12-04 18:44:07 +00:00
parent 49c80d186a
commit 37e9a17bcd
2 changed files with 47 additions and 26 deletions

View File

@ -55,8 +55,8 @@
#
# See src/UPDATING `COMMON ITEMS' for more complete information.
#
# If TARGET_ARCH=arch (e.g. ia64, sparc64, ...) is specified you can
# cross build world for other architectures using the buildworld target,
# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
# cross build world for other machine types using the buildworld target,
# and once the world is built you can cross build a kernel using the
# buildkernel target.
#
@ -265,36 +265,32 @@ universe_prologue:
@echo "--------------------------------------------------------------"
@echo ">>> make universe started on ${STARTTIME}"
@echo "--------------------------------------------------------------"
.for target in i386 i386:pc98 sparc64 alpha ia64 amd64
.for arch in ${target:C/:.*$//}
.for mach in ${target:C/^.*://}
KERNCONFS!= cd ${.CURDIR}/sys/${mach}/conf && \
.for target in alpha amd64 i386 ia64 pc98 sparc64
KERNCONFS!= cd ${.CURDIR}/sys/${target}/conf && \
find [A-Z]*[A-Z] -type f -maxdepth 0 \
! -name DEFAULTS ! -name LINT
KERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/}
universe: universe_${mach}
.ORDER: universe_prologue universe_${mach} universe_epilogue
universe_${mach}:
@echo ">> ${mach} started on `LC_ALL=C date`"
universe: universe_${target}
.ORDER: universe_prologue universe_${target} universe_epilogue
universe_${target}:
@echo ">> ${target} started on `LC_ALL=C date`"
-cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \
TARGET_ARCH=${arch} TARGET=${mach} \
TARGET=${target} \
__MAKE_CONF=/dev/null \
> _.${mach}.buildworld 2>&1
@echo ">> ${mach} buildworld completed on `LC_ALL=C date`"
.if exists(${.CURDIR}/sys/${mach}/conf/NOTES)
-cd ${.CURDIR}/sys/${mach}/conf && ${MAKE} LINT \
> ${.CURDIR}/_.${mach}.makeLINT 2>&1
> _.${target}.buildworld 2>&1
@echo ">> ${target} buildworld completed on `LC_ALL=C date`"
.if exists(${.CURDIR}/sys/${target}/conf/NOTES)
-cd ${.CURDIR}/sys/${target}/conf && ${MAKE} LINT \
> ${.CURDIR}/_.${target}.makeLINT 2>&1
.endif
.for kernel in ${KERNCONFS}
-cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \
TARGET_ARCH=${arch} TARGET=${mach} \
TARGET=${target} \
KERNCONF=${kernel} \
__MAKE_CONF=/dev/null \
> _.${mach}.${kernel} 2>&1
.endfor
@echo ">> ${mach} completed on `LC_ALL=C date`"
.endfor
> _.${target}.${kernel} 2>&1
.endfor
@echo ">> ${target} completed on `LC_ALL=C date`"
.endfor
universe: universe_epilogue
universe_epilogue:

View File

@ -22,7 +22,7 @@
# -DNO_PORTSUPDATE do not update ports in ${MAKE} update
# -DNO_DOCUPDATE do not update doc in ${MAKE} update
# LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
# TARGET_ARCH="arch" to crossbuild world to a different arch
# TARGET="machine" to crossbuild world for a different machine type
#
# The intended user-driven targets are:
@ -103,14 +103,36 @@ OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
OSRELDATE= 0
.endif
.endif
TARGET_ARCH?= ${MACHINE_ARCH}
.if ${TARGET_ARCH} == ${MACHINE_ARCH}
# Guess machine architecture from machine type, and vice versa.
.if !defined(TARGET_ARCH) && defined(TARGET)
TARGET_ARCH= ${TARGET:S/pc98/i386/}
.elif !defined(TARGET) && defined(TARGET_ARCH) && \
${TARGET_ARCH} != ${MACHINE_ARCH}
TARGET= ${TARGET_ARCH}
.endif
# Otherwise, default to current machine type and architecture.
TARGET?= ${MACHINE}
TARGET_ARCH?= ${MACHINE_ARCH}
KNOWN_ARCHES?= amd64 arm i386 i386/pc98 ia64 powerpc sparc64
.if ${TARGET} == ${TARGET_ARCH}
_t= ${TARGET}
.else
_t= ${TARGET_ARCH}/${TARGET}
.endif
.for _t in ${_t}
.if empty(KNOWN_ARCHES:M${_t})
.error Unknown target ${TARGET_ARCH}:${TARGET}.
.endif
.endfor
.if ${TARGET} == ${MACHINE}
TARGET_CPUTYPE?=${CPUTYPE}
.else
TARGET?= ${TARGET_ARCH}
TARGET_CPUTYPE?=
.endif
.if !empty(TARGET_CPUTYPE)
_TARGET_CPUTYPE=${TARGET_CPUTYPE}
.else
@ -192,11 +214,14 @@ BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
# build-tools stage
TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
${BMAKEENV} ${MAKE} -f Makefile.inc1 \
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
DESTDIR= \
BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS
# cross-tools stage
XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
-DNO_FORTRAN -DNO_GDB
# world stage
WMAKEENV= ${CROSSENV} \