Tue Jun 27 10:36:40 2023 UTC ()
bsd.prefs.mk: Define _CROSS_DESTDIR before platform/${OPSYS}.mk.

This way, platform/${OPSYS}.mk has the opportunity to refer to it to
query characteristics of the operating system that we're building
packages for.

Step on the way to cross-OS builds.


(riastradh)
diff -r1.433 -r1.434 pkgsrc/mk/bsd.prefs.mk

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

--- pkgsrc/mk/bsd.prefs.mk 2023/06/27 10:27:20 1.433
+++ pkgsrc/mk/bsd.prefs.mk 2023/06/27 10:36:40 1.434
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: bsd.prefs.mk,v 1.433 2023/06/27 10:27:20 riastradh Exp $ 1# $NetBSD: bsd.prefs.mk,v 1.434 2023/06/27 10:36:40 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.
@@ -440,26 +440,48 @@ _PKGSRC_TOPDIR= ${.CURDIR}/../.. @@ -440,26 +440,48 @@ _PKGSRC_TOPDIR= ${.CURDIR}/../..
440.include "${_PKGSRC_TOPDIR}/mk/defaults/mk.conf" 440.include "${_PKGSRC_TOPDIR}/mk/defaults/mk.conf"
441 441
442SHAREOWN?= ${DOCOWN} 442SHAREOWN?= ${DOCOWN}
443SHAREGRP?= ${DOCGRP} 443SHAREGRP?= ${DOCGRP}
444SHAREMODE?= ${DOCMODE} 444SHAREMODE?= ${DOCMODE}
445 445
446.if defined(PREFIX) && (${PREFIX} != ${__PREFIX_SET__}) 446.if defined(PREFIX) && (${PREFIX} != ${__PREFIX_SET__})
447.BEGIN: 447.BEGIN:
448 @${ECHO_MSG} "You CANNOT set PREFIX manually or in mk.conf. Set LOCALBASE or X11BASE" 448 @${ECHO_MSG} "You CANNOT set PREFIX manually or in mk.conf. Set LOCALBASE or X11BASE"
449 @${ECHO_MSG} "depending on your needs. See the pkg system documentation for more info." 449 @${ECHO_MSG} "depending on your needs. See the pkg system documentation for more info."
450 @${FALSE} 450 @${FALSE}
451.endif 451.endif
452 452
 453# When cross-compilation support is requested, the following options
 454# must be specified as well or guessable:
 455# - MACHINE_ARCH is set to TARGET_ARCH if set.
 456# - CROSS_DESTDIR is guessed from MAKEOBJDIR and MACHINE_ARCH.
 457# - PKG_DBDIR is expanded and prefixed with CROSS_DESTDIR
 458# - DESTDIR support is required
 459#
 460# _CROSS_DESTDIR is set for internal use to avoid conditionalising
 461# the use.
 462
 463.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
 464. if defined(TARGET_ARCH)
 465MACHINE_ARCH= ${TARGET_ARCH}
 466. endif
 467CROSS_DESTDIR?= ${MAKEOBJDIR}/destdir.${MACHINE_ARCH}
 468. if !exists(${CROSS_DESTDIR}/usr/include/stddef.h)
 469PKG_FAIL_REASON+= "The cross-compiling root ${CROSS_DESTDIR:Q} is incomplete"
 470. else
 471_CROSS_DESTDIR= ${CROSS_DESTDIR}
 472. endif
 473.endif
 474
453# Load the OS-specific definitions for program variables. Default to loading 475# Load the OS-specific definitions for program variables. Default to loading
454# the NetBSD ones if an OS-specific file doesn't exist. 476# the NetBSD ones if an OS-specific file doesn't exist.
455.if exists(${_PKGSRC_TOPDIR}/mk/platform/${OPSYS}.mk) 477.if exists(${_PKGSRC_TOPDIR}/mk/platform/${OPSYS}.mk)
456. include "${_PKGSRC_TOPDIR}/mk/platform/${OPSYS}.mk" 478. include "${_PKGSRC_TOPDIR}/mk/platform/${OPSYS}.mk"
457.else 479.else
458. include "${_PKGSRC_TOPDIR}/mk/platform/NetBSD.mk" 480. include "${_PKGSRC_TOPDIR}/mk/platform/NetBSD.mk"
459PKG_FAIL_REASON+= "missing mk/platform/${OPSYS}.mk" 481PKG_FAIL_REASON+= "missing mk/platform/${OPSYS}.mk"
460.endif 482.endif
461 483
462# Set default SHLIB_TYPE to the ${OPSYS}-specific shared library type. 484# Set default SHLIB_TYPE to the ${OPSYS}-specific shared library type.
463SHLIB_TYPE?= ${_OPSYS_SHLIB_TYPE} 485SHLIB_TYPE?= ${_OPSYS_SHLIB_TYPE}
464 486
465PKGDIRMODE?= 755 487PKGDIRMODE?= 755
@@ -519,48 +541,26 @@ _MAKE_INSTALL_AS_ROOT= no @@ -519,48 +541,26 @@ _MAKE_INSTALL_AS_ROOT= no
519# was yes) 541# was yes)
520_KEEP_BIN_PKGS?= no 542_KEEP_BIN_PKGS?= no
521.if !empty(PKGSRC_KEEP_BIN_PKGS:U:M[Yy][Ee][Ss]) 543.if !empty(PKGSRC_KEEP_BIN_PKGS:U:M[Yy][Ee][Ss])
522_KEEP_BIN_PKGS= yes 544_KEEP_BIN_PKGS= yes
523.endif 545.endif
524 546
525_MAKE_CLEAN_AS_ROOT?= no 547_MAKE_CLEAN_AS_ROOT?= no
526# Whether to run the clean target as root. 548# Whether to run the clean target as root.
527_MAKE_INSTALL_AS_ROOT?= yes 549_MAKE_INSTALL_AS_ROOT?= yes
528# Whether to run the install target as root. 550# Whether to run the install target as root.
529_MAKE_PACKAGE_AS_ROOT?= yes 551_MAKE_PACKAGE_AS_ROOT?= yes
530# Whether to run the package target as root. 552# Whether to run the package target as root.
531 553
532# When cross-compilation support is requested, the following options 
533# must be specified as well or guessable: 
534# - MACHINE_ARCH is set to TARGET_ARCH if set. 
535# - CROSS_DESTDIR is guessed from MAKEOBJDIR and MACHINE_ARCH. 
536# - PKG_DBDIR is expanded and prefixed with CROSS_DESTDIR 
537# - DESTDIR support is required 
538# 
539# _CROSS_DESTDIR is set for internal use to avoid conditionalising 
540# the use. 
541 
542.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) 
543. if defined(TARGET_ARCH) 
544MACHINE_ARCH= ${TARGET_ARCH} 
545. endif 
546CROSS_DESTDIR?= ${MAKEOBJDIR}/destdir.${MACHINE_ARCH} 
547. if !exists(${CROSS_DESTDIR}/usr/include/stddef.h) 
548PKG_FAIL_REASON+= "The cross-compiling root ${CROSS_DESTDIR:Q} is incomplete" 
549. else 
550_CROSS_DESTDIR= ${CROSS_DESTDIR} 
551. endif 
552.endif 
553 
554# TOOLS_CROSS_DESTDIR is used for the libtool build to make a wrapper 554# TOOLS_CROSS_DESTDIR is used for the libtool build to make a wrapper
555# that points at the cross-destdir as sysroot, without setting 555# that points at the cross-destdir as sysroot, without setting
556# _CROSS_DESTDIR because we're actually building a native package. 556# _CROSS_DESTDIR because we're actually building a native package.
557TOOLS_CROSS_DESTDIR= ${CROSS_DESTDIR} 557TOOLS_CROSS_DESTDIR= ${CROSS_DESTDIR}
558 558
559# Depends on MACHINE_ARCH override above 559# Depends on MACHINE_ARCH override above
560.if ${OPSYS} == "NetBSD" 560.if ${OPSYS} == "NetBSD"
561# XXX NATIVE_OBJECT_FMT is a cop-out -- but seriously, who is going to 561# XXX NATIVE_OBJECT_FMT is a cop-out -- but seriously, who is going to
562# do cross-builds on a NetBSD host that still uses a.out? 562# do cross-builds on a NetBSD host that still uses a.out?
563NATIVE_OBJECT_FMT?= ${OBJECT_FMT} 563NATIVE_OBJECT_FMT?= ${OBJECT_FMT}
564. if ${NATIVE_OBJECT_FMT} == "ELF" && \ 564. if ${NATIVE_OBJECT_FMT} == "ELF" && \
565 (!empty(NATIVE_MACHINE_ARCH:Mearm*) || \ 565 (!empty(NATIVE_MACHINE_ARCH:Mearm*) || \
566 ${NATIVE_MACHINE_GNU_ARCH} == "arm" || \ 566 ${NATIVE_MACHINE_GNU_ARCH} == "arm" || \