buildlink3, mk/*.builtin.mk: Use TOOLS_CROSS_DESTDIR for file checks.

These are always about the target system, which during cross builds,
or native builds of cross-libtool-base, is relative to
TOOLS_CROSS_DESTDIR.

This is necessary for cross-libtool-base -- the one special package
that is built as a native package as if it were cross-compiled, so
_CROSS_DESTDIR is empty but TOOLS_CROSS_DESTDIR is the cross destdir
-- because cross-libtool-base uses buildlink3 and dlopen.builtin.mk.

No change to native builds because _CROSS_DESTDIR and
TOOLS_CROSS_DESTDIR are both empty in native builds.

XXX Perhaps almost every use of _CROSS_DESTDIR outside mk/pkgformat
should be replaced by TOOLS_CROSS_DESTDIR.
This commit is contained in:
riastradh 2024-01-13 20:26:47 +00:00
parent f5638d3cce
commit 9b589d50ab
12 changed files with 48 additions and 39 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.buildlink3.mk,v 1.262 2024/01/13 20:21:04 riastradh Exp $
# $NetBSD: bsd.buildlink3.mk,v 1.263 2024/01/13 20:26:47 riastradh Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
@ -346,12 +346,12 @@ _BLNK_PKG_DBDIR.${_pkg_}?= _BLNK_PKG_DBDIR.${_pkg_}_not_found
_BLNK_PKG_INFO.${_pkg_}?= ${TRUE}
BUILDLINK_PKGNAME.${_pkg_}?= ${_pkg_}
# Usual systems has builtin packages in /usr
. if exists(${_CROSS_DESTDIR:U}/usr)
. if exists(${TOOLS_CROSS_DESTDIR}/usr)
BUILDLINK_PREFIX.${_pkg_}?= /usr
# Haiku OS has posix packages in /boot/sytem/develop (or /boot/common)
. elif exists(${_CROSS_DESTDIR:U}/boot/system/develop)
. elif exists(${TOOLS_CROSS_DESTDIR}/boot/system/develop)
BUILDLINK_PREFIX.${_pkg_}?= /boot/system/develop
. elif exists(${_CROSS_DESTDIR:U}/boot/common)
. elif exists(${TOOLS_CROSS_DESTDIR}/boot/common)
BUILDLINK_PREFIX.${_pkg_}?= /boot/common
. else
# XXX: elsewhere?
@ -464,7 +464,7 @@ BUILDLINK_LIBS+= ${_flag_}
!empty(BUILDLINK_AUTO_DIRS.${_pkg_}:M[yY][eE][sS])
. if !empty(BUILDLINK_INCDIRS.${_pkg_})
. for _dir_ in ${BUILDLINK_INCDIRS.${_pkg_}:S/^/${BUILDLINK_PREFIX.${_pkg_}}\//}
. if exists(${_CROSS_DESTDIR:U}${_dir_})
. if exists(${TOOLS_CROSS_DESTDIR}${_dir_})
. if empty(BUILDLINK_CPPFLAGS:M-I${_dir_})
BUILDLINK_CPPFLAGS+= -I${_dir_}
. endif
@ -473,7 +473,7 @@ BUILDLINK_CPPFLAGS+= -I${_dir_}
. endif
. if !empty(BUILDLINK_LIBDIRS.${_pkg_})
. for _dir_ in ${BUILDLINK_LIBDIRS.${_pkg_}:S/^/${BUILDLINK_PREFIX.${_pkg_}}\//}
. if exists(${_CROSS_DESTDIR:U}${_dir_})
. if exists(${TOOLS_CROSS_DESTDIR}${_dir_})
. if empty(BUILDLINK_LDFLAGS:M-L${_dir_})
BUILDLINK_LDFLAGS+= -L${_dir_}
. endif
@ -482,7 +482,7 @@ BUILDLINK_LDFLAGS+= -L${_dir_}
. endif
. if !empty(BUILDLINK_RPATHDIRS.${_pkg_})
. for _dir_ in ${BUILDLINK_RPATHDIRS.${_pkg_}:S/^/${BUILDLINK_PREFIX.${_pkg_}}\//}
. if exists(${_CROSS_DESTDIR:U}${_dir_})
. if exists(${TOOLS_CROSS_DESTDIR}${_dir_})
. if empty(BUILDLINK_LDFLAGS:M${COMPILER_RPATH_FLAG}${_dir_})
BUILDLINK_LDFLAGS+= ${COMPILER_RPATH_FLAG}${_dir_}
. endif
@ -499,7 +499,7 @@ BUILDLINK_LDFLAGS+= ${COMPILER_RPATH_FLAG}${_dir_}
.for _pkg_ in ${_BLNK_PACKAGES}
. if !empty(BUILDLINK_RPATHDIRS.${_pkg_})
. for _dir_ in ${BUILDLINK_RPATHDIRS.${_pkg_}:S/^/${LOCALBASE}\//}
. if exists(${_CROSS_DESTDIR:U}${_dir_})
. if exists(${TOOLS_CROSS_DESTDIR}${_dir_})
. if empty(BUILDLINK_LDFLAGS:M${COMPILER_RPATH_FLAG}${_dir_})
BUILDLINK_LDFLAGS+= ${COMPILER_RPATH_FLAG}${_dir_}
. endif
@ -670,10 +670,10 @@ ${_BLNK_COOKIE.${_pkg_}}:
*) buildlink_dir="${BUILDLINK_DIR}" ;; \
esac; \
[ -z "${BUILDLINK_PREFIX.${_pkg_}:Q}" ] || \
cd ${_CROSS_DESTDIR}${BUILDLINK_PREFIX.${_pkg_}} && \
cd ${TOOLS_CROSS_DESTDIR}${BUILDLINK_PREFIX.${_pkg_}} && \
${_BLNK_FILES_CMD.${_pkg_}} | \
while read file; do \
src="${_CROSS_DESTDIR}${BUILDLINK_PREFIX.${_pkg_}}/$$file"; \
src="${TOOLS_CROSS_DESTDIR}${BUILDLINK_PREFIX.${_pkg_}}/$$file"; \
[ -f "$$src" ] || continue; \
dest="$$buildlink_dir/$$file"; \
if [ -n "${BUILDLINK_FNAME_TRANSFORM.${_pkg_}:Q}" ]; then \
@ -710,10 +710,10 @@ ${_BLNK_COOKIE.${_pkg_}}:
*) buildlink_dir="${BUILDLINK_DIR}" ;; \
esac; \
[ -z "${BUILDLINK_PREFIX.${_pkg_}:Q}" ] || \
cd ${_CROSS_DESTDIR}${BUILDLINK_PREFIX.${_pkg_}} && \
cd ${TOOLS_CROSS_DESTDIR}${BUILDLINK_PREFIX.${_pkg_}} && \
${_BLNK_FILES_CMD.${_pkg_}} | \
while read file; do \
src="${_CROSS_DESTDIR}${BUILDLINK_PREFIX.${_pkg_}}/$$file"; \
src="${TOOLS_CROSS_DESTDIR}${BUILDLINK_PREFIX.${_pkg_}}/$$file"; \
if [ ! -f "$$src" ]; then \
msg="$$src: not found"; \
else \
@ -881,7 +881,7 @@ _CWRAPPERS_TRANSFORM+= I:${_dir_}/:
.for _pkg_ in ${_BLNK_PACKAGES}
. if !empty(BUILDLINK_LIBDIRS.${_pkg_})
. for _dir_ in ${BUILDLINK_LIBDIRS.${_pkg_}}
. if exists(${_CROSS_DESTDIR:U}${BUILDLINK_PREFIX.${_pkg_}}/${_dir_})
. if exists(${TOOLS_CROSS_DESTDIR}${BUILDLINK_PREFIX.${_pkg_}}/${_dir_})
_BLNK_PASSTHRU_RPATHDIRS+= ${BUILDLINK_PREFIX.${_pkg_}}/${_dir_}
. endif
. endfor

View File

@ -1,4 +1,4 @@
# $NetBSD: find-files.mk,v 1.9 2018/08/22 20:48:36 maya Exp $
# $NetBSD: find-files.mk,v 1.10 2024/01/13 20:26:47 riastradh Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
@ -76,12 +76,14 @@ USE_TOOLS+= grep
. if !defined(${_var_})
${_var_}= __nonexistent__
. for _file_ in ${BUILTIN_FIND_FILES.${_var_}}
. if !empty(${_var_}:M__nonexistent__) && exists(${_file_})
. if !empty(${_var_}:M__nonexistent__) && \
exists(${TOOLS_CROSS_DESTDIR}${_file_})
. if !defined(BUILTIN_FIND_GREP.${_var_})
${_var_}= ${_file_}
. else
${_var_}!= \
if ${GREP} -q ${BUILTIN_FIND_GREP.${_var_}:Q} ${_file_:Q}; then \
if ${GREP} -q ${BUILTIN_FIND_GREP.${_var_}:Q} \
${TOOLS_CROSS_DESTDIR:Q}${_file_:Q}; then \
${ECHO} ${_file_:Q}; \
else \
${ECHO} __nonexistent__; \

View File

@ -1,4 +1,4 @@
# $NetBSD: find-headers.mk,v 1.5 2022/02/10 18:58:37 gutteridge Exp $
# $NetBSD: find-headers.mk,v 1.6 2024/01/13 20:26:47 riastradh Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
@ -80,12 +80,14 @@ BUILTIN_INCLUDE_DIRS?= ${COMPILER_INCLUDE_DIRS} ${"${X11_TYPE:Mnative}":?${X11BA
${_var_}= __nonexistent__
. for _file_ in ${BUILTIN_FIND_HEADERS.${_var_}}
. for _dir_ in ${BUILTIN_INCLUDE_DIRS}
. if !empty(${_var_}:M__nonexistent__) && exists(${_dir_}/${_file_})
. if !empty(${_var_}:M__nonexistent__) && \
exists(${TOOLS_CROSS_DESTDIR}${_dir_}/${_file_})
. if !defined(BUILTIN_FIND_GREP.${_var_})
${_var_}= ${_dir_}/${_file_}
. else
${_var_}!= \
if ${GREP} -q ${BUILTIN_FIND_GREP.${_var_}:Q} ${_dir_:Q}/${_file_:Q}; then \
if ${GREP} -q ${BUILTIN_FIND_GREP.${_var_}:Q} \
${TOOLS_CROSS_DESTDIR:Q}${_dir_:Q}/${_file_:Q}; then \
${ECHO} ${_dir_:Q}/${_file_:Q}; \
else \
${ECHO} __nonexistent__; \

View File

@ -1,4 +1,4 @@
# $NetBSD: find-libs.mk,v 1.12 2018/08/22 20:48:36 maya Exp $
# $NetBSD: find-libs.mk,v 1.13 2024/01/13 20:26:47 riastradh Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
@ -58,7 +58,8 @@ BUILTIN_LIB_FOUND.${_lib_}= no
. for _path_ in ${COMPILER_LIB_DIRS}
. if ${BUILTIN_LIB_FOUND.${_lib_}} == "no"
BUILTIN_LIB_FOUND.${_lib_}!= \
if ${TEST} "`${ECHO} ${_path_}/lib${_lib_}.*`" != "${_path_}/lib${_lib_}.*"; then \
if ${TEST} "`${ECHO} ${TOOLS_CROSS_DESTDIR}${_path_}/lib${_lib_}.*`" \
!= "${TOOLS_CROSS_DESTDIR}${_path_}/lib${_lib_}.*"; then \
${ECHO} yes; \
else \
${ECHO} no; \

View File

@ -1,4 +1,4 @@
# $NetBSD: find-pkgconfig-files.mk,v 1.4 2023/12/06 22:27:22 tnn Exp $
# $NetBSD: find-pkgconfig-files.mk,v 1.5 2024/01/13 20:26:47 riastradh Exp $
#
# Copyright (c) 2020 The NetBSD Foundation, Inc.
# All rights reserved.
@ -75,7 +75,8 @@ BUILTIN_PKGCONFIG_DIRS?= /usr/lib/pkgconfig \
${_var_}= __nonexistent__
. for _file_ in ${BUILTIN_FIND_PKGCONFIG_FILES.${_var_}}
. for _dir_ in ${BUILTIN_PKGCONFIG_DIRS}
. if !empty(${_var_}:M__nonexistent__) && exists(${_dir_}/${_file_})
. if !empty(${_var_}:M__nonexistent__) && \
exists(${TOOLS_CROSS_DESTDIR}${_dir_}/${_file_})
${_var_}= ${_dir_}/${_file_}
. endif
. endfor

View File

@ -1,4 +1,4 @@
# $NetBSD: pkgconfig-builtin.mk,v 1.7 2022/10/27 13:01:44 gdt Exp $
# $NetBSD: pkgconfig-builtin.mk,v 1.8 2024/01/13 20:26:47 riastradh Exp $
# This file is used to factor out a common pattern in builtin.mk files
# that use pkgconfig files to check for a built-in implementation.
@ -52,7 +52,7 @@ MAKEVARS:= ${MAKEVARS} IS_BUILTIN.${BUILTIN_PKG}
defined(BUILTIN_VERSION_SCRIPT.${BUILTIN_PKG})))
BUILTIN_VERSION_SCRIPT.${BUILTIN_PKG}?= ${SED} -n -e 's/Version: //p'
BUILTIN_VERSION.${BUILTIN_PKG}!= ${BUILTIN_VERSION_SCRIPT.${BUILTIN_PKG}} \
${FIND_FILES_${BUILTIN_PKG}}
${TOOLS_CROSS_DESTDIR}${FIND_FILES_${BUILTIN_PKG}}
BUILTIN_PKG.${BUILTIN_PKG}:= ${BUILTIN_PKG}-${BUILTIN_VERSION.${BUILTIN_PKG}}
.endif
MAKEVARS:= ${MAKEVARS} BUILTIN_PKG.${BUILTIN_PKG}

View File

@ -1,4 +1,4 @@
# $NetBSD: curses.builtin.mk,v 1.21 2022/06/06 01:24:11 gutteridge Exp $
# $NetBSD: curses.builtin.mk,v 1.22 2024/01/13 20:26:47 riastradh Exp $
BUILTIN_PKG:= curses
@ -36,7 +36,8 @@ BUILTIN_FIND_GREP.H_CURSES_${defn}= ${defn}
###
.if !defined(IS_BUILTIN.curses)
IS_BUILTIN.curses= no
. if empty(H_CURSES:M${LOCALBASE}/*) && exists(${H_CURSES})
. if empty(H_CURSES:M${LOCALBASE}/*) && \
exists(${TOOLS_CROSS_DESTDIR}${H_CURSES})
IS_BUILTIN.curses= yes
. endif
.endif
@ -125,7 +126,7 @@ CHECK_BUILTIN.curses?= no
.if !empty(CHECK_BUILTIN.curses:M[nN][oO])
. if !empty(USE_BUILTIN.curses:M[yY][eE][sS])
. if exists(${H_CURSES})
. if exists(${TOOLS_CROSS_DESTDIR}${H_CURSES})
BUILDLINK_INCDIRS.curses?= ${H_CURSES:H}
. endif
BUILDLINK_LIBNAME.curses= ${BUILTIN_LIBNAME.curses}

View File

@ -1,4 +1,4 @@
# $NetBSD: db1.builtin.mk,v 1.23 2013/11/23 09:10:14 obache Exp $
# $NetBSD: db1.builtin.mk,v 1.24 2024/01/13 20:26:47 riastradh Exp $
BUILTIN_PKG:= db1
@ -19,7 +19,7 @@ BUILTIN_FIND_GREP.H_DB= ^\#define.*HASHVERSION.*2$$
###
.if !defined(IS_BUILTIN.db1)
IS_BUILTIN.db1= no
. if empty(H_DB:M${LOCALBASE}/*) && exists(${H_DB})
. if empty(H_DB:M${LOCALBASE}/*) && exists(${TOOLS_CROSS_DESTDIR}${H_DB})
IS_BUILTIN.db1= yes
. endif
.endif
@ -65,7 +65,7 @@ CHECK_BUILTIN.db1?= no
. if !empty(USE_BUILTIN.db1:M[yY][eE][sS])
BUILDLINK_PREFIX.db1= /usr
. if exists(${H_DB})
. if exists(${TOOLS_CROSS_DESTDIR}${H_DB})
BUILDLINK_INCDIRS.db1?= ${H_DB:H:S/^${BUILDLINK_PREFIX.db1}\///}
. endif
. if !empty(BUILTIN_LIB_FOUND.db1:M[yY][eE][sS])

View File

@ -1,4 +1,4 @@
# $NetBSD: dlopen.builtin.mk,v 1.27 2013/11/23 09:10:14 obache Exp $
# $NetBSD: dlopen.builtin.mk,v 1.28 2024/01/13 20:26:47 riastradh Exp $
BUILTIN_PKG:= dl
@ -14,7 +14,7 @@ BUILTIN_FIND_HEADERS.H_DL= dlfcn.h
###
.if !defined(IS_BUILTIN.dl)
IS_BUILTIN.dl= no
. if empty(H_DL:M${LOCALBASE}/*) && exists(${H_DL})
. if empty(H_DL:M${LOCALBASE}/*) && exists(${TOOLS_CROSS_DESTDIR}${H_DL})
IS_BUILTIN.dl= yes
. endif
.endif

View File

@ -1,4 +1,4 @@
# $NetBSD: fuse.buildlink3.mk,v 1.25 2022/01/27 04:27:05 pho Exp $
# $NetBSD: fuse.buildlink3.mk,v 1.26 2024/01/13 20:26:47 riastradh Exp $
#
# Makefile fragment for packages using the FUSE framework.
#
@ -56,7 +56,7 @@ PKG_FAIL_REASON+= "Couldn't find fuse headers, please install libfuse."
. elif ${OPSYS} == "NetBSD" || ${OPSYS} == "Minix" || \
!empty(MACHINE_PLATFORM:MDragonFly-[3-9]*-*)
H_FUSE= /usr/include/fuse.h
. if !exists(${H_FUSE})
. if !exists(${TOOLS_CROSS_DESTDIR}${H_FUSE})
PKG_FAIL_REASON+= "Couldn't find fuse headers, please install librefuse."
. endif

View File

@ -1,4 +1,4 @@
# $NetBSD: pthread.builtin.mk,v 1.16 2019/06/30 21:28:28 rillig Exp $
# $NetBSD: pthread.builtin.mk,v 1.17 2024/01/13 20:26:47 riastradh Exp $
BUILTIN_PKG:= pthread
@ -14,7 +14,8 @@ BUILTIN_FIND_HEADERS.H_PTHREAD= pthread.h
###
.if !defined(IS_BUILTIN.pthread)
IS_BUILTIN.pthread= no
. if empty(H_PTHREAD:M${LOCALBASE}/*) && exists(${H_PTHREAD})
. if empty(H_PTHREAD:M${LOCALBASE}/*) && \
exists(${TOOLS_CROSS_DESTDIR}${H_PTHREAD})
IS_BUILTIN.pthread= yes
. endif
.endif

View File

@ -1,4 +1,4 @@
# $NetBSD: solaris-pam.builtin.mk,v 1.5 2013/11/23 09:10:14 obache Exp $
# $NetBSD: solaris-pam.builtin.mk,v 1.6 2024/01/13 20:26:47 riastradh Exp $
BUILTIN_PKG:= solaris-pam
@ -14,7 +14,8 @@ BUILTIN_FIND_GREP.H_SOLARIS_PAM= Copyright.*Sun Microsystems
###
.if !defined(IS_BUILTIN.solaris-pam)
IS_BUILTIN.solaris-pam= no
. if empty(H_SOLARIS_PAM:M${LOCALBASE}/*) && exists(${H_SOLARIS_PAM})
. if empty(H_SOLARIS_PAM:M${LOCALBASE}/*) && \
exists(${TOOLS_CROSS_DESTDIR}${H_SOLARIS_PAM})
IS_BUILTIN.solaris-pam= yes
. endif
.endif