From 756722c3c15cf69340575823c597c79e7c43edcb Mon Sep 17 00:00:00 2001 From: lukem Date: Tue, 23 Apr 2002 07:20:22 +0000 Subject: [PATCH] Overhaul how _SRC_TOP_ is determined, ensuring that it will be set to ${BSDSRCDIR} if make(1) is running outside of the NetBSD source tree. This should solve various issues, including building xsrc which uses ${BSDSRCDIR}/distrib/sets/maketars. --- share/mk/bsd.own.mk | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index e5e990638042..f7e49f37e3c3 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.own.mk,v 1.285 2002/04/12 05:08:53 lukem Exp $ +# $NetBSD: bsd.own.mk,v 1.286 2002/04/23 07:20:22 lukem Exp $ .if !defined(_BSD_OWN_MK_) _BSD_OWN_MK_=1 @@ -30,8 +30,19 @@ PRINTOBJDIR= ${MAKE} -V .OBJDIR PRINTOBJDIR= echo # prevent infinite recursion .endif +# Where the system object and source trees are kept; can be configurable +# by the user in case they want them in ~/foosrc and ~/fooobj (for example). +# +BSDSRCDIR?= /usr/src +BSDOBJDIR?= /usr/obj + +# Determine if running in the NetBSD source tree by checking for the +# existence of build.sh and tools/ in the current or a parent directory, +# and setting _SRC_TOP_ to the result. +# If no match is found, (e.g., make(1) is running outside of the NetBSD +# source tree), set _SRC_TOP_ to ${BSDSRCDIR}. +# .if !defined(_SRC_TOP_) -# Find the actual top of the source tree _SRC_TOP_!= cd ${.CURDIR}; while :; do \ here=`pwd`; \ [ -f build.sh ] && [ -d tools ] && { echo $$here; break; }; \ @@ -41,18 +52,26 @@ _SRC_TOP_!= cd ${.CURDIR}; while :; do \ .MAKEOVERRIDES+= _SRC_TOP_ .endif -.if !defined(_SRC_TOP_OBJ_) -.if ${_SRC_TOP_} != "" -_SRC_TOP_OBJ_!= cd ${_SRC_TOP_} && ${PRINTOBJDIR} -.MAKEOVERRIDES+= _SRC_TOP_OBJ_ -.endif -.endif +# (At this point, if not inside the NetBSD source tree, ${_SRC_TOP_} == ""). .if (${_SRC_TOP_} != "") && defined(USE_NEW_TOOLCHAIN) USETOOLS?= yes .endif USETOOLS?= no +.if (${_SRC_TOP_} == "") +_SRC_TOP_= ${BSDSRCDIR} # fall back to ${BSDSRCDIR} +.endif + +# End of logic to set _SRC_TOP_ +# + + +.if !defined(_SRC_TOP_OBJ_) +_SRC_TOP_OBJ_!= cd ${_SRC_TOP_} && ${PRINTOBJDIR} +.MAKEOVERRIDES+= _SRC_TOP_OBJ_ +.endif + .if ${MACHINE_ARCH} == "mips" || ${MACHINE_ARCH} == "sh3" .BEGIN: @echo "Must set MACHINE_ARCH to one of ${MACHINE_ARCH}eb or ${MACHINE_ARCH}el" @@ -76,7 +95,7 @@ HOST_OSTYPE:= ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH} # Provide a default for TOOLDIR. .if !defined(TOOLDIR) -_TOOLOBJ!= cd ${_SRC_TOP_:U${BSDSRCDIR}}/tools && ${PRINTOBJDIR} +_TOOLOBJ!= cd ${_SRC_TOP_}/tools && ${PRINTOBJDIR} TOOLDIR:= ${_TOOLOBJ}/tools.${HOST_OSTYPE} .MAKEOVERRIDES+= TOOLDIR .endif @@ -179,11 +198,6 @@ check_RELEASEDIR: .PHONY .NOTMAIN DESTDIR?= .endif -# where the system object and source trees are kept; can be configurable -# by the user in case they want them in ~/foosrc and ~/fooobj, for example -BSDSRCDIR?= /usr/src -BSDOBJDIR?= /usr/obj - BINGRP?= wheel BINOWN?= root BINMODE?= 555