Wed Mar 20 15:59:54 2024 UTC (67d)
macOS: fix false positives from xcrun --find.

xcrun lately seems to include PATH in its search, which means programs
that aren't part of Apple's developer tools get matched:

    :; xcrun --find mutt
    /opt/pkg/bin/mutt

xcrun also has a cache, so this can produce even odder results:

    :; xcrun --find yacc
    /opt/pkg/bin/yacc

    :; env - xcrun --find yacc
    /opt/pkg/bin/yacc

    :; xcrun --no-cache --find yacc
    /opt/pkg/bin/yacc

    :; env - xcrun --no-cache --find yacc
    xcrun: error: unable to find utility "yacc", not a developer tool or in PATH

Since xcrun has had the "--no-cache" argument dating back to at least
the days of OS X 10.6.8 with gcc 4.2.1 and Apple clang 1.7, add it to
"xcrun --find" commands (along with an empty PATH) for more
deterministic results.


(schmonz)
diff -r1.64 -r1.65 pkgsrc/mk/tools/tools.Darwin.mk

cvs diff -r1.64 -r1.65 pkgsrc/mk/tools/tools.Darwin.mk (expand / switch to unified diff)

--- pkgsrc/mk/tools/tools.Darwin.mk 2024/03/11 14:11:24 1.64
+++ pkgsrc/mk/tools/tools.Darwin.mk 2024/03/20 15:59:54 1.65
@@ -1,33 +1,35 @@ @@ -1,33 +1,35 @@
1# $NetBSD: tools.Darwin.mk,v 1.64 2024/03/11 14:11:24 schmonz Exp $ 1# $NetBSD: tools.Darwin.mk,v 1.65 2024/03/20 15:59:54 schmonz Exp $
2# 2#
3# System-supplied tools for the Darwin (Mac OS X) operating system. 3# System-supplied tools for the Darwin (Mac OS X) operating system.
4 4
 5OSX_XCRUN= ${SETENV} PATH= /usr/bin/xcrun --no-cache
 6
5TOOLS_PLATFORM.[?= [ # shell builtin 7TOOLS_PLATFORM.[?= [ # shell builtin
6TOOLS_PLATFORM.awk?= /usr/bin/awk 8TOOLS_PLATFORM.awk?= /usr/bin/awk
7TOOLS_PLATFORM.basename?= /usr/bin/basename 9TOOLS_PLATFORM.basename?= /usr/bin/basename
8TOOLS_PLATFORM.bash?= /bin/bash 10TOOLS_PLATFORM.bash?= /bin/bash
9# Native bison (at least up to version 2.3 in OSX Lion) does not work 11# Native bison (at least up to version 2.3 in OSX Lion) does not work
10# well in the tools environment and cannot locate m4sugar.m4 without 12# well in the tools environment and cannot locate m4sugar.m4 without
11# BISON_PKGDATADIR being set. For now just pull in the pkgsrc tool. 13# BISON_PKGDATADIR being set. For now just pull in the pkgsrc tool.
12#TOOLS_PLATFORM.bison?= /usr/bin/bison 14#TOOLS_PLATFORM.bison?= /usr/bin/bison
13#TOOLS_PLATFORM.bison-yacc?= /usr/bin/bison -y 15#TOOLS_PLATFORM.bison-yacc?= /usr/bin/bison -y
14.if exists(/usr/bin/bsdtar) 16.if exists(/usr/bin/bsdtar)
15TOOLS_PLATFORM.bsdtar?= /usr/bin/bsdtar 17TOOLS_PLATFORM.bsdtar?= /usr/bin/bsdtar
16.endif 18.endif
17# CLT 15.3.0.0.1.1708646388 does not provide yacc. Check whether the 19# CLT 15.3.0.0.1.1708646388 does not provide yacc. Check whether the
18# /usr/bin/yacc xcode-select stub's target exists before defaulting to it. 20# /usr/bin/yacc xcode-select stub's target exists before defaulting to it.
19.if !defined(OSX_PATH_TO_YACC) 21.if !defined(OSX_PATH_TO_YACC)
20OSX_PATH_TO_YACC_cmd= /usr/bin/xcrun --find yacc 2>/dev/null | \ 22OSX_PATH_TO_YACC_cmd= ${OSX_XCRUN} --find yacc 2>/dev/null | \
21 sed -e 's|^/Library/Developer/CommandLineTools||' 23 sed -e 's|^/Library/Developer/CommandLineTools||'
22OSX_PATH_TO_YACC= ${OSX_PATH_TO_YACC_cmd:sh} 24OSX_PATH_TO_YACC= ${OSX_PATH_TO_YACC_cmd:sh}
23.endif 25.endif
24MAKEFLAGS+= OSX_PATH_TO_YACC=${OSX_PATH_TO_YACC:Q} 26MAKEFLAGS+= OSX_PATH_TO_YACC=${OSX_PATH_TO_YACC:Q}
25.if ${OSX_PATH_TO_YACC} != "" 27.if ${OSX_PATH_TO_YACC} != ""
26TOOLS_PLATFORM.byacc?= ${OSX_PATH_TO_YACC} 28TOOLS_PLATFORM.byacc?= ${OSX_PATH_TO_YACC}
27.endif 29.endif
28.if exists(/usr/bin/bzcat) 30.if exists(/usr/bin/bzcat)
29TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat 31TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
30.endif 32.endif
31.if exists(/usr/bin/bzip2) 33.if exists(/usr/bin/bzip2)
32TOOLS_PLATFORM.bzip2?= /usr/bin/bzip2 34TOOLS_PLATFORM.bzip2?= /usr/bin/bzip2
33.endif 35.endif
@@ -91,27 +93,27 @@ TOOLS_PLATFORM.ident?= /usr/bin/ident @@ -91,27 +93,27 @@ TOOLS_PLATFORM.ident?= /usr/bin/ident
91TOOLS_PLATFORM.install?= /usr/bin/install 93TOOLS_PLATFORM.install?= /usr/bin/install
92.if exists(/usr/bin/install-info) 94.if exists(/usr/bin/install-info)
93TOOLS_PLATFORM.install-info?= /usr/bin/install-info 95TOOLS_PLATFORM.install-info?= /usr/bin/install-info
94.endif 96.endif
95.if exists(/bin/ksh) 97.if exists(/bin/ksh)
96TOOLS_PLATFORM.ksh?= /bin/ksh 98TOOLS_PLATFORM.ksh?= /bin/ksh
97.endif 99.endif
98TOOLS_PLATFORM.lex?= /usr/bin/lex 100TOOLS_PLATFORM.lex?= /usr/bin/lex
99TOOLS_PLATFORM.ln?= /bin/ln 101TOOLS_PLATFORM.ln?= /bin/ln
100TOOLS_PLATFORM.ls?= /bin/ls 102TOOLS_PLATFORM.ls?= /bin/ls
101# CLT 15.3.0.0.1.1708646388 does not provide m4. Check whether the 103# CLT 15.3.0.0.1.1708646388 does not provide m4. Check whether the
102# /usr/bin/m4 xcode-select stub's target exists before defaulting to it. 104# /usr/bin/m4 xcode-select stub's target exists before defaulting to it.
103.if !defined(OSX_PATH_TO_M4) 105.if !defined(OSX_PATH_TO_M4)
104OSX_PATH_TO_M4_cmd= /usr/bin/xcrun --find m4 2>/dev/null | \ 106OSX_PATH_TO_M4_cmd= ${OSX_XCRUN} --find m4 2>/dev/null | \
105 sed -e 's|^/Library/Developer/CommandLineTools||' 107 sed -e 's|^/Library/Developer/CommandLineTools||'
106OSX_PATH_TO_M4= ${OSX_PATH_TO_M4_cmd:sh} 108OSX_PATH_TO_M4= ${OSX_PATH_TO_M4_cmd:sh}
107.endif 109.endif
108MAKEFLAGS+= OSX_PATH_TO_M4=${OSX_PATH_TO_M4:Q} 110MAKEFLAGS+= OSX_PATH_TO_M4=${OSX_PATH_TO_M4:Q}
109.if ${OSX_PATH_TO_M4} != "" 111.if ${OSX_PATH_TO_M4} != ""
110TOOLS_PLATFORM.m4?= ${OSX_PATH_TO_M4} 112TOOLS_PLATFORM.m4?= ${OSX_PATH_TO_M4}
111.endif 113.endif
112TOOLS_PLATFORM.mail?= /usr/bin/mail 114TOOLS_PLATFORM.mail?= /usr/bin/mail
113.if exists(/usr/bin/makeinfo) 115.if exists(/usr/bin/makeinfo)
114TOOLS_PLATFORM.makeinfo?= /usr/bin/makeinfo 116TOOLS_PLATFORM.makeinfo?= /usr/bin/makeinfo
115.endif 117.endif
116.if exists(/usr/bin/mandoc) 118.if exists(/usr/bin/mandoc)
117TOOLS_PLATFORM.mandoc?= /usr/bin/mandoc 119TOOLS_PLATFORM.mandoc?= /usr/bin/mandoc