Fri Jan 26 03:25:36 2024 UTC (122d)
bsd.prefs.mk: Set OBJECT_FMT for Darwin before cross variables.

This way it can be handled by the cross variable logic when the host
and target have misatched object formats, like building NetBSD
packages (ELF) on macOS (Mach-O).

This whole stanza can be removed when PR pkg/57837
(bootstrap-mk-files bsd.own.mk defines wrong OBJECT_FMT on macOS
(Darwin), https://gnats.NetBSD.org/57837) is fixed.

No functional change intended so far -- this just makes subsequent
patches easier to follow.


(riastradh)
diff -r1.437 -r1.438 pkgsrc/mk/bsd.prefs.mk

cvs diff -r1.437 -r1.438 pkgsrc/mk/bsd.prefs.mk (expand / switch to unified diff)

--- pkgsrc/mk/bsd.prefs.mk 2024/01/13 20:21:23 1.437
+++ pkgsrc/mk/bsd.prefs.mk 2024/01/26 03:25:36 1.438
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: bsd.prefs.mk,v 1.437 2024/01/13 20:21:23 riastradh Exp $ 1# $NetBSD: bsd.prefs.mk,v 1.438 2024/01/26 03:25:36 riastradh Exp $
2# 2#
3# This file includes the mk.conf file, which contains the user settings. 3# This file includes the mk.conf file, which contains the user settings.
4# 4#
5# Packages should include this file before any of the .if directives, as 5# Packages should include this file before any of the .if directives, as
6# well as before modifying variables like CFLAGS, LDFLAGS, and so on. 6# well as before modifying variables like CFLAGS, LDFLAGS, and so on.
7# Otherwise the behavior may be unexpected. 7# Otherwise the behavior may be unexpected.
8# 8#
9# When mk.conf is included by this file, the following variables are 9# When mk.conf is included by this file, the following variables are
10# defined: 10# defined:
11# 11#
12# ACCEPTABLE_LICENSES 12# ACCEPTABLE_LICENSES
13# This variable is set to the list of Open Source licenses. See 13# This variable is set to the list of Open Source licenses. See
14# mk/license.mk for details. 14# mk/license.mk for details.
@@ -331,26 +331,31 @@ LOWER_OPSYS:= ${OPSYS:tl} @@ -331,26 +331,31 @@ LOWER_OPSYS:= ${OPSYS:tl}
331# Now commit the version values computed above, eliding the :sh 331# Now commit the version values computed above, eliding the :sh
332OS_VERSION:= ${OS_VERSION} 332OS_VERSION:= ${OS_VERSION}
333 333
334MAKEFLAGS+= LOWER_OPSYS=${LOWER_OPSYS:Q} 334MAKEFLAGS+= LOWER_OPSYS=${LOWER_OPSYS:Q}
335 335
336LOWER_VENDOR?= # empty ("arch--opsys") 336LOWER_VENDOR?= # empty ("arch--opsys")
337 337
338NATIVE_MACHINE_ARCH:= ${MACHINE_ARCH} 338NATIVE_MACHINE_ARCH:= ${MACHINE_ARCH}
339NATIVE_MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${NATIVE_MACHINE_ARCH} 339NATIVE_MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${NATIVE_MACHINE_ARCH}
340MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${MACHINE_ARCH} 340MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${MACHINE_ARCH}
341NATIVE_MACHINE_GNU_PLATFORM?= ${NATIVE_MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${NATIVE_APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}${NATIVE_APPEND_ABI} 341NATIVE_MACHINE_GNU_PLATFORM?= ${NATIVE_MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${NATIVE_APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}${NATIVE_APPEND_ABI}
342MACHINE_GNU_PLATFORM?= ${MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}${APPEND_ABI} 342MACHINE_GNU_PLATFORM?= ${MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}${APPEND_ABI}
343 343
 344# Set this before <bsd.own.mk> does, since it doesn't know about Darwin
 345.if ${OPSYS} == "Darwin"
 346OBJECT_FMT?= Mach-O
 347.endif
 348
344# 349#
345# cross-libtool is special -- it is built as a native package, but it 350# cross-libtool is special -- it is built as a native package, but it
346# needs tools set up as if for a cross-compiled package because it 351# needs tools set up as if for a cross-compiled package because it
347# remembers the paths for use to later assist in cross-compiling other 352# remembers the paths for use to later assist in cross-compiling other
348# packages. 353# packages.
349# 354#
350# So normally TOOLS_USE_CROSS_COMPILE is the same as USE_CROSS_COMPILE, 355# So normally TOOLS_USE_CROSS_COMPILE is the same as USE_CROSS_COMPILE,
351# but for cross-libtool, we set TOOLS_USE_CROSS_COMPILE=yes while doing 356# but for cross-libtool, we set TOOLS_USE_CROSS_COMPILE=yes while doing
352# the rest of the native package build with USE_CROSS_COMPILE=no. 357# the rest of the native package build with USE_CROSS_COMPILE=no.
353# 358#
354# This can't live inside the cross-libtool makefile because the 359# This can't live inside the cross-libtool makefile because the
355# TARGET_ARCH / MACHINE_ARCH / NATIVE_MACHINE_ARCH switcheroo has to 360# TARGET_ARCH / MACHINE_ARCH / NATIVE_MACHINE_ARCH switcheroo has to
356# happen in the middle of this file -- after NATIVE_MACHINE_ARCH is 361# happen in the middle of this file -- after NATIVE_MACHINE_ARCH is
@@ -366,31 +371,26 @@ _BUILD_DEFS.MACHINE_GNU_ARCH= ${NATIVE_M @@ -366,31 +371,26 @@ _BUILD_DEFS.MACHINE_GNU_ARCH= ${NATIVE_M
366TOOLS_USE_CROSS_COMPILE= yes 371TOOLS_USE_CROSS_COMPILE= yes
367.else 372.else
368TOOLS_USE_CROSS_COMPILE= ${USE_CROSS_COMPILE:Uno} 373TOOLS_USE_CROSS_COMPILE= ${USE_CROSS_COMPILE:Uno}
369.endif 374.endif
370 375
371# Needed to prevent an "install:" target from being created in bsd.own.mk. 376# Needed to prevent an "install:" target from being created in bsd.own.mk.
372NEED_OWN_INSTALL_TARGET=no 377NEED_OWN_INSTALL_TARGET=no
373 378
374# This prevents default use of the cross-tool harness in the "src" tree, 379# This prevents default use of the cross-tool harness in the "src" tree,
375# in the odd possible case of someone extracting "pkgsrc" underneath "src". 380# in the odd possible case of someone extracting "pkgsrc" underneath "src".
376USETOOLS= no 381USETOOLS= no
377MAKE_ENV+= USETOOLS=no 382MAKE_ENV+= USETOOLS=no
378 383
379# Set this before <bsd.own.mk> does, since it doesn't know about Darwin 
380.if ${OPSYS} == "Darwin" 
381OBJECT_FMT?= Mach-O 
382.endif 
383 
384ACCEPTABLE_LICENSES?= ${DEFAULT_ACCEPTABLE_LICENSES} 384ACCEPTABLE_LICENSES?= ${DEFAULT_ACCEPTABLE_LICENSES}
385 385
386# Provide PKGPATH early on so that mk.conf can use it. 386# Provide PKGPATH early on so that mk.conf can use it.
387PKGPATH?= ${.CURDIR:C|.*/([^/]*/[^/]*)$|\1|} 387PKGPATH?= ${.CURDIR:C|.*/([^/]*/[^/]*)$|\1|}
388 388
389# Load the settings from MAKECONF, which is /etc/mk.conf by default. 389# Load the settings from MAKECONF, which is /etc/mk.conf by default.
390.include <bsd.own.mk> 390.include <bsd.own.mk>
391 391
392.if ${OPSYS} == "OpenBSD" 392.if ${OPSYS} == "OpenBSD"
393. if defined(ELF_TOOLCHAIN) && ${ELF_TOOLCHAIN} == "yes" 393. if defined(ELF_TOOLCHAIN) && ${ELF_TOOLCHAIN} == "yes"
394OBJECT_FMT?= ELF 394OBJECT_FMT?= ELF
395. else 395. else
396OBJECT_FMT?= a.out 396OBJECT_FMT?= a.out