From ff015b987229bcfdcf9d74db79b08ea064ff5c00 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 11 Jan 2024 23:31:30 +0000 Subject: [PATCH 01/27] */builtin.mk: Use ${_CROSS_DESTDIR:U} for build-time file checks. These are questions about the target system, whose files at build-time are all relative to ${_CROSS_DESTDIR} if it is defined, i.e., if USE_CROSS_COMPILE is set to yes. No change to native builds because ${_CROSS_DESTDIR:U} is empty in them. (Possible minor change by adding :Q to ${H_FOO} in command lines, but if this makes a difference it likely fixes problems.) --- archivers/bzip2/builtin.mk | 2 +- archivers/libarchive/builtin.mk | 2 +- archivers/xz/builtin.mk | 2 +- converters/libiconv/builtin.mk | 2 +- devel/gmp/builtin.mk | 3 ++- devel/libexecinfo/builtin.mk | 3 ++- devel/libuuid/builtin.mk | 3 ++- devel/ncurses/builtin.mk | 2 +- devel/ncursesw/builtin.mk | 2 +- devel/readline/builtin.mk | 2 +- devel/zlib/builtin.mk | 2 +- fonts/Xft2/builtin.mk | 2 +- fonts/fontconfig/builtin.mk | 2 +- graphics/MesaLib/builtin.mk | 3 ++- graphics/MesaLib/version.mk | 2 +- graphics/freetype2/builtin.mk | 2 +- graphics/glu/builtin.mk | 3 ++- math/mpfr/builtin.mk | 3 ++- net/net-snmp/builtin.mk | 2 +- security/openpam/builtin.mk | 2 +- security/openssl/builtin.mk | 10 +++++----- textproc/expat/builtin.mk | 2 +- x11/libXft/builtin.mk | 2 +- x11/xcursor/builtin.mk | 2 +- 24 files changed, 34 insertions(+), 28 deletions(-) diff --git a/archivers/bzip2/builtin.mk b/archivers/bzip2/builtin.mk index 6ddb569a2b90..53a3a54125e2 100644 --- a/archivers/bzip2/builtin.mk +++ b/archivers/bzip2/builtin.mk @@ -39,7 +39,7 @@ BUILTIN_VERSION.bzip2!= \ }; \ print vers; \ }; \ - ' ${H_BZIP2:Q} + ' ${_CROSS_DESTDIR:U:Q}${H_BZIP2:Q} BUILTIN_PKG.bzip2= bzip2-${BUILTIN_VERSION.bzip2} .endif diff --git a/archivers/libarchive/builtin.mk b/archivers/libarchive/builtin.mk index cb5aa0d250ce..e3aa04e66219 100644 --- a/archivers/libarchive/builtin.mk +++ b/archivers/libarchive/builtin.mk @@ -53,7 +53,7 @@ BUILTIN_VERSION.libarchive!= \ else if (found == 2) \ print vers_str; \ } \ - ' ${H_ARCHIVE:Q} + ' ${_CROSS_DESTDIR:U:Q}${H_ARCHIVE:Q} . if !empty(BUILTIN_VERSION.libarchive) BUILTIN_PKG.libarchive= libarchive-${BUILTIN_VERSION.libarchive} . else diff --git a/archivers/xz/builtin.mk b/archivers/xz/builtin.mk index a58876b17458..c4b44de97017 100644 --- a/archivers/xz/builtin.mk +++ b/archivers/xz/builtin.mk @@ -37,7 +37,7 @@ BUILTIN_VERSION.xz!= \ } \ } \ END { printf "%s%s%s%s\n", M, m, p, s} \ - ' ${H_LZMA_VERSION:Q} + ' ${_CROSS_DESTDIR:U:Q}${H_LZMA_VERSION:Q} BUILTIN_PKG.xz= xz-${BUILTIN_VERSION.xz} .endif diff --git a/converters/libiconv/builtin.mk b/converters/libiconv/builtin.mk index b058bc6d0175..d7595ac13191 100644 --- a/converters/libiconv/builtin.mk +++ b/converters/libiconv/builtin.mk @@ -53,7 +53,7 @@ BUILTIN_VERSION.iconv!= \ printf "%d.%d\n", M, m; \ exit 0; \ } \ - ' ${H_ICONV} + ' ${_CROSS_DESTDIR:U:Q}${H_ICONV:Q} # # If the native GNU iconv is ABI version 1.9, then treat it the same # as the latest version on the libiconv-1.9.x branch. diff --git a/devel/gmp/builtin.mk b/devel/gmp/builtin.mk index 175f9f4fb891..053a2395c582 100644 --- a/devel/gmp/builtin.mk +++ b/devel/gmp/builtin.mk @@ -33,7 +33,8 @@ MAKEVARS+= IS_BUILTIN.gmp .if !defined(BUILTIN_PKG.gmp) && \ ${IS_BUILTIN.gmp:tl} == yes && \ empty(H_GMP:M__nonexistent__) -BUILTIN_VERSION.gmp!= ${BUILTIN_VERSION_SCRIPT.gmp} ${H_GMP} +BUILTIN_VERSION.gmp!= \ + ${BUILTIN_VERSION_SCRIPT.gmp} ${_CROSS_DESTDIR:U:Q}${H_GMP:Q} BUILTIN_PKG.gmp= gmp-${BUILTIN_VERSION.gmp} .endif MAKEVARS+= BUILTIN_PKG.gmp diff --git a/devel/libexecinfo/builtin.mk b/devel/libexecinfo/builtin.mk index ccdbcacb9bd0..0a5adb0193e0 100644 --- a/devel/libexecinfo/builtin.mk +++ b/devel/libexecinfo/builtin.mk @@ -56,7 +56,8 @@ CHECK_BUILTIN.libexecinfo?= no . if !empty(USE_BUILTIN.libexecinfo:M[nN][oO]) _BLTN_LIBEXECINFO= -lexecinfo . else -. if exists(/usr/include/execinfo.h) && (${OPSYS} == "NetBSD" || ${OPSYS} == "FreeBSD") +. if exists(${_CROSS_DESTDIR:U}/usr/include/execinfo.h) && \ + (${OPSYS} == "NetBSD" || ${OPSYS} == "FreeBSD") _BLTN_LIBEXECINFO= -lexecinfo . else _BLTN_LIBEXECINFO= # empty diff --git a/devel/libuuid/builtin.mk b/devel/libuuid/builtin.mk index 244944ff27aa..c7391f3a002c 100644 --- a/devel/libuuid/builtin.mk +++ b/devel/libuuid/builtin.mk @@ -31,7 +31,8 @@ MAKEVARS+= IS_BUILTIN.libuuid .if !defined(BUILTIN_PKG.libuuid) && \ !empty(IS_BUILTIN.libuuid:M[yY][eE][sS]) . if empty(UUID_PC:M__nonexistent__) -BUILTIN_VERSION.libuuid!= ${SED} -n -e 's/Version: //p' ${UUID_PC} +BUILTIN_VERSION.libuuid!= \ + ${SED} -n -e 's/Version: //p' ${_CROSS_DESTDIR:U:Q}${UUID_PC:Q} BUILTIN_PKG.libuuid= libuuid-${BUILTIN_VERSION.libuuid} . else BUILTIN_PKG.libuuid= libuuid-2.18 # whatever, as long as it is big enough diff --git a/devel/ncurses/builtin.mk b/devel/ncurses/builtin.mk index 3a095ce04329..202bdd699ec2 100644 --- a/devel/ncurses/builtin.mk +++ b/devel/ncurses/builtin.mk @@ -47,7 +47,7 @@ BUILTIN_VERSION.ncurses!= \ gsub("\"", "", vers); \ print vers; \ } \ - ' ${H_NCURSES:Q} + ' ${_CROSS_DESTDIR:U:Q}${H_NCURSES:Q} BUILTIN_PKG.ncurses= ncurses-${BUILTIN_VERSION.ncurses} .endif MAKEVARS+= BUILTIN_PKG.ncurses diff --git a/devel/ncursesw/builtin.mk b/devel/ncursesw/builtin.mk index 6d5f9abc6b07..344b7f05e177 100644 --- a/devel/ncursesw/builtin.mk +++ b/devel/ncursesw/builtin.mk @@ -44,7 +44,7 @@ BUILTIN_VERSION.ncursesw!= \ gsub("\"", "", vers); \ print vers; \ } \ - ' ${H_NCURSESW:Q} + ' ${_CROSS_DESTDIR:U:Q}${H_NCURSESW:Q} BUILTIN_PKG.ncursesw= ncursesw-${BUILTIN_VERSION.ncursesw} .endif MAKEVARS+= BUILTIN_PKG.ncursesw diff --git a/devel/readline/builtin.mk b/devel/readline/builtin.mk index a0f76cda2f21..031bdcfd94f7 100644 --- a/devel/readline/builtin.mk +++ b/devel/readline/builtin.mk @@ -35,7 +35,7 @@ BUILTIN_VERSION.readline!= \ ${AWK} '/\#define[ ]*RL_VERSION_MAJOR/ { M = $$3 } \ /\#define[ ]*RL_VERSION_MINOR/ { m = "."$$3 } \ END { printf "%s%s\n", M, m } \ - ' ${H_READLINE:Q} + ' ${_CROSS_DESTDIR:U:Q}${H_READLINE:Q} BUILTIN_PKG.readline= readline-${BUILTIN_VERSION.readline} .endif MAKEVARS+= BUILTIN_PKG.readline diff --git a/devel/zlib/builtin.mk b/devel/zlib/builtin.mk index 339af7a13786..4d63e7b908e0 100644 --- a/devel/zlib/builtin.mk +++ b/devel/zlib/builtin.mk @@ -36,7 +36,7 @@ BUILTIN_VERSION.zlib!= \ gsub("\"", "", vers); \ print vers; \ } \ - ' ${H_ZLIB:Q} + ' ${_CROSS_DESTDIR:U:Q}${H_ZLIB:Q} BUILTIN_PKG.zlib= zlib-${BUILTIN_VERSION.zlib:C/-[A-Za-z]*//} .endif diff --git a/fonts/Xft2/builtin.mk b/fonts/Xft2/builtin.mk index cc222eafbfd2..dd0b166e2564 100644 --- a/fonts/Xft2/builtin.mk +++ b/fonts/Xft2/builtin.mk @@ -37,7 +37,7 @@ BUILTIN_VERSION.Xft2!= \ /\#define[ ]*XFT_MINOR/ { m = "."$$3 } \ /\#define[ ]*XFT_REVISION/ { r = "."$$3 } \ END { printf "%s%s%s\n", M, m, r }' \ - ${H_XFT2} + ${_CROSS_DESTDIR:U:Q}${H_XFT2:Q} BUILTIN_PKG.Xft2= Xft2-${BUILTIN_VERSION.Xft2} .endif MAKEVARS+= BUILTIN_PKG.Xft2 diff --git a/fonts/fontconfig/builtin.mk b/fonts/fontconfig/builtin.mk index 0c329f0bbc5e..d9aa48f00394 100644 --- a/fonts/fontconfig/builtin.mk +++ b/fonts/fontconfig/builtin.mk @@ -33,7 +33,7 @@ BUILTIN_VERSION.fontconfig!= \ /\#define[ ]*FC_MINOR/ { m = "."$$3 } \ /\#define[ ]*FC_REVISION/ { r = "."$$3 } \ END { printf "%s%s%s\n", M, m, r }' \ - ${H_FONTCONFIG} + ${_CROSS_DESTDIR:U:Q}${H_FONTCONFIG:Q} BUILTIN_PKG.fontconfig= fontconfig-${BUILTIN_VERSION.fontconfig} .endif MAKEVARS+= BUILTIN_PKG.fontconfig diff --git a/graphics/MesaLib/builtin.mk b/graphics/MesaLib/builtin.mk index b2c566d8e0c8..44f2654c1eb7 100644 --- a/graphics/MesaLib/builtin.mk +++ b/graphics/MesaLib/builtin.mk @@ -32,7 +32,8 @@ MAKEVARS+= IS_BUILTIN.MesaLib .if !defined(BUILTIN_PKG.MesaLib) && \ !empty(IS_BUILTIN.MesaLib:M[yY][eE][sS]) . if empty(PC_GL:M__nonexistent__) -BUILTIN_VERSION.Mesa!= ${SED} -n -e 's/Version: //p' ${PC_GL} +BUILTIN_VERSION.Mesa!= \ + ${SED} -n -e 's/Version: //p' ${_CROSS_DESTDIR:U:Q}${PC_GL:Q} . elif empty(H_MESALIB:M__nonexistent__) . include "version.mk" . else # ? diff --git a/graphics/MesaLib/version.mk b/graphics/MesaLib/version.mk index 7f8b9ab5ddd2..f014dff45a76 100644 --- a/graphics/MesaLib/version.mk +++ b/graphics/MesaLib/version.mk @@ -25,6 +25,6 @@ BUILTIN_VERSION.Mesa!= \ /\#define[ ]*GL_VERSION_1_4/ { v = "5.0" } \ /\#define[ ]*GL_VERSION_1_5/ { v = "6.0" } \ END { printf "%s\n", v }' \ - ${H_MESA} + ${_CROSS_DESTDIR:U:Q}${H_MESA:Q} .endif MAKEVARS+= BUILTIN_VERSION.Mesa diff --git a/graphics/freetype2/builtin.mk b/graphics/freetype2/builtin.mk index 744b9ac74688..03332c1a8acb 100644 --- a/graphics/freetype2/builtin.mk +++ b/graphics/freetype2/builtin.mk @@ -37,7 +37,7 @@ BUILTIN_VERSION.freetype2!= \ /\#define[ ]*FREETYPE_MINOR/ { m = "."$$3 } \ /\#define[ ]*FREETYPE_PATCH/ { p = "."$$3 } \ END { printf "%s%s%s\n", M, m, p }' \ - ${H_FREETYPE2} + ${_CROSS_DESTDIR:U:Q}${H_FREETYPE2:Q} BUILTIN_PKG.freetype2= freetype2-${BUILTIN_VERSION.freetype2} .endif MAKEVARS+= BUILTIN_PKG.freetype2 diff --git a/graphics/glu/builtin.mk b/graphics/glu/builtin.mk index 0438cde7ef5a..e8fbbf8ea0cb 100644 --- a/graphics/glu/builtin.mk +++ b/graphics/glu/builtin.mk @@ -30,7 +30,8 @@ MAKEVARS+= IS_BUILTIN.glu .if !defined(BUILTIN_PKG.glu) && \ ${IS_BUILTIN.glu:tl} == yes . if empty(PC_GLU:M__nonexistent__) -BUILTIN_VERSION.Mesa!= ${SED} -n -e 's/Version: //p' ${PC_GLU} +BUILTIN_VERSION.Mesa!= \ + ${SED} -n -e 's/Version: //p' ${_CROSS_DESTDIR:U:Q}${PC_GLU:Q} . elif empty(H_GLU:M__nonexistent__) . include "../../graphics/MesaLib/version.mk" . else # ? diff --git a/math/mpfr/builtin.mk b/math/mpfr/builtin.mk index 29ffcd8fbf2c..459b192b2910 100644 --- a/math/mpfr/builtin.mk +++ b/math/mpfr/builtin.mk @@ -31,7 +31,8 @@ MAKEVARS+= IS_BUILTIN.mpfr .if !defined(BUILTIN_PKG.mpfr) && \ ${IS_BUILTIN.mpfr:tl} == yes && \ empty(H_MPFR:M__nonexistent__) -BUILTIN_VERSION.mpfr!= ${BUILTIN_VERSION_SCRIPT.mpfr} ${H_MPFR} +BUILTIN_VERSION.mpfr!= \ + ${BUILTIN_VERSION_SCRIPT.mpfr} ${_CROSS_DESTDIR:U:Q}${H_MPFR:Q} BUILTIN_PKG.mpfr= mpfr-${BUILTIN_VERSION.mpfr} .endif MAKEVARS+= BUILTIN_PKG.mpfr diff --git a/net/net-snmp/builtin.mk b/net/net-snmp/builtin.mk index 8ee83886d276..c6e9fb8740a4 100644 --- a/net/net-snmp/builtin.mk +++ b/net/net-snmp/builtin.mk @@ -32,7 +32,7 @@ BUILTIN_VERSION.net-snmp!= \ gsub("\"", "", vers); \ print vers; \ } \ - ' ${H_NETSNMP:Q} + ' ${_CROSS_DESTDIR:U:Q}${H_NETSNMP:Q} BUILTIN_PKG.net-snmp= net-snmp-${BUILTIN_VERSION.net-snmp} .endif MAKEVARS+= BUILTIN_PKG.net-snmp diff --git a/security/openpam/builtin.mk b/security/openpam/builtin.mk index 22fc7c1f31b6..dfd1fb8e52cf 100644 --- a/security/openpam/builtin.mk +++ b/security/openpam/builtin.mk @@ -28,7 +28,7 @@ MAKEVARS+= IS_BUILTIN.openpam empty(H_OPENPAM:M__nonexistent__) BUILTIN_VERSION.openpam!= \ ${AWK} '/\#define[ ]*_?OPENPAM_VERSION[ ]/ {print $$3; }' \ - ${H_OPENPAM} + ${_CROSS_DESTDIR:U:Q}${H_OPENPAM:Q} BUILTIN_PKG.openpam= openpam-${BUILTIN_VERSION.openpam} .endif MAKEVARS+= BUILTIN_PKG.openpam diff --git a/security/openssl/builtin.mk b/security/openssl/builtin.mk index 2f2d63582942..e27081b7b0a7 100644 --- a/security/openssl/builtin.mk +++ b/security/openssl/builtin.mk @@ -58,7 +58,7 @@ BUILTIN_VERSION.openssl!= \ major, minor, teeny, patchlevel; \ exit 0; \ } \ - ' ${H_OPENSSLV} + ' ${_CROSS_DESTDIR:U:Q}${H_OPENSSLV:Q} BUILTIN_PKG.openssl= openssl-${BUILTIN_VERSION.openssl} .endif MAKEVARS+= BUILTIN_PKG.openssl @@ -72,7 +72,7 @@ BUILTIN_OPENSSL_HAS_THREADS!= \ /\#[ ]*define[ ]*OPENSSL_THREADS/ { ans= "yes" } \ /\#[ ]*define[ ]*THREADS/ { ans = "yes" } \ END { print ans; exit 0 } \ - ' ${H_OPENSSLCONF:Q} + ' ${_CROSS_DESTDIR:U:Q}${H_OPENSSLCONF:Q} .endif MAKEVARS+= BUILTIN_OPENSSL_HAS_THREADS @@ -143,7 +143,7 @@ SSLDIR= ${PKG_SYSCONFDIR.openssl} . if ${OPSYS} == "NetBSD" SSLDIR= /etc/openssl . elif ${OPSYS} == "Linux" -. if exists(/etc/pki/tls) +. if exists(${_CROSS_DESTDIR:U}/etc/pki/tls) # Some distributions have moved to /etc/pki/tls, with incomplete # symlinks from /etc/ssl. Prefer the new location if it exists SSLDIR= /etc/pki/tls @@ -151,7 +151,7 @@ SSLDIR= /etc/pki/tls SSLDIR= /etc/ssl # standard location . endif . elif ${OPSYS} == "Haiku" -. if exists(/boot/system/data/ssl) +. if exists(${_CROSS_DESTDIR:U}/boot/system/data/ssl) SSLDIR= /boot/system/data/ssl . else SSLDIR= /boot/common/data/ssl @@ -168,7 +168,7 @@ SSLCERTS= ${SSLDIR}/certs # Continue to define SSLCERTS because it's unclear if that's the # directory that has one file per cert, or the directory that contains # trust anchor config in some fortm. -. if exists(${SSLDIR}/certs/ca-bundle.crt) +. if exists(${_CROSS_DESTDIR:U}${SSLDIR}/certs/ca-bundle.crt) SSLCERTBUNDLE= ${SSLDIR}/certs/ca-bundle.crt . endif SSLKEYS= ${SSLDIR}/private diff --git a/textproc/expat/builtin.mk b/textproc/expat/builtin.mk index fd5569ad1472..541e3264446e 100644 --- a/textproc/expat/builtin.mk +++ b/textproc/expat/builtin.mk @@ -32,7 +32,7 @@ BUILTIN_VERSION.expat!= \ /\#define[ ]*XML_MINOR_VERSION/ { m = "."$$3 } \ /\#define[ ]*XML_MICRO_VERSION/ { u = "."$$3 } \ END { printf "%s%s%s\n", M, m, u }' \ - ${H_EXPAT} + ${_CROSS_DESTDIR:U:Q}${H_EXPAT:Q} BUILTIN_PKG.expat= expat-${BUILTIN_VERSION.expat} .endif MAKEVARS+= BUILTIN_PKG.expat diff --git a/x11/libXft/builtin.mk b/x11/libXft/builtin.mk index e41e294f2580..a1acd1c669bf 100644 --- a/x11/libXft/builtin.mk +++ b/x11/libXft/builtin.mk @@ -37,7 +37,7 @@ BUILTIN_VERSION.libXft!= \ /\#define[ ]*XFT_MINOR/ { m = "."$$3 } \ /\#define[ ]*XFT_REVISION/ { r = "."$$3 } \ END { printf "%s%s%s\n", M, m, r }' \ - ${H_XFT2} + ${_CROSS_DESTDIR:U:Q}${H_XFT2:Q} BUILTIN_PKG.libXft= libXft-${BUILTIN_VERSION.libXft} .endif MAKEVARS+= BUILTIN_PKG.libXft diff --git a/x11/xcursor/builtin.mk b/x11/xcursor/builtin.mk index 21a0521306db..2caa61b19193 100644 --- a/x11/xcursor/builtin.mk +++ b/x11/xcursor/builtin.mk @@ -32,7 +32,7 @@ BUILTIN_VERSION.xcursor!= \ /\#define[ ]*XCURSOR_(LIB_)?MINOR/ { m = "."$$3 } \ /\#define[ ]*XCURSOR_(LIB_)?REVISION/ { r = "."$$3 } \ END { printf "%s%s%s\n", M, m, r }' \ - ${H_XCURSOR} + ${_CROSS_DESTDIR:U:Q}${H_XCURSOR:Q} BUILTIN_PKG.xcursor= xcursor-${BUILTIN_VERSION.xcursor} .endif MAKEVARS+= BUILTIN_PKG.xcursor From b32607ae6992bbe93ce37cc30b9ebf3525b33139 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 11 Jan 2024 23:34:51 +0000 Subject: [PATCH 02/27] */builtin.mk: Disable for cross-build if executes target program. We can't run target programs during cross-build, so we either need to disable builtin detection or find another way to detect the target program's version. No change to native builds because this just makes some existing logic conditional on native builds. --- lang/openjdk8/builtin.mk | 7 ++++++- lang/oracle-jdk8/builtin.mk | 7 ++++++- lang/oracle-jre8/builtin.mk | 7 ++++++- lang/sun-jdk7/builtin.mk | 7 ++++++- lang/sun-jre7/builtin.mk | 7 ++++++- net/bind916/builtin.mk | 7 ++++++- net/bind918/builtin.mk | 7 ++++++- sysutils/file/builtin.mk | 7 ++++++- 8 files changed, 48 insertions(+), 8 deletions(-) diff --git a/lang/openjdk8/builtin.mk b/lang/openjdk8/builtin.mk index 27e67ad3875f..c895f6c3106e 100644 --- a/lang/openjdk8/builtin.mk +++ b/lang/openjdk8/builtin.mk @@ -26,7 +26,12 @@ MAKEVARS+= IS_BUILTIN.openjdk8 ### If there is a built-in implementation, then set BUILTIN_PKG. to ### a package name to represent the built-in package. ### -.if !defined(BUILTIN_PKG.openjdk8) && \ +### XXX This doesn't work for cross-compilation because we can't +### execute the target system's program. Can the version be discovered +### any other way? +### +.if ${USE_CROSS_COMPILE:tl} != "yes" && \ + !defined(BUILTIN_PKG.openjdk8) && \ ${IS_BUILTIN.openjdk8:tl} == yes BUILTIN_VERSION.openjdk8!= ${OJDK8} -version 2>&1 | ${SED} -Ee 's:^[^0-9]*([0-9._]+)$$:\1:' -e 's/_/./g' -e 's/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/\1.\2.\4/' BUILTIN_PKG.openjdk8= openjdk8-${BUILTIN_VERSION.openjdk8} diff --git a/lang/oracle-jdk8/builtin.mk b/lang/oracle-jdk8/builtin.mk index f6aa23a49354..8641613a564d 100644 --- a/lang/oracle-jdk8/builtin.mk +++ b/lang/oracle-jdk8/builtin.mk @@ -44,7 +44,12 @@ MAKEVARS+= IS_BUILTIN.oracle-jdk8 ### If there is a built-in implementation, then set BUILTIN_PKG. to ### a package name to represent the built-in package. ### -.if !defined(BUILTIN_PKG.oracle-jdk8) && \ +### XXX This doesn't work for cross-compilation because we can't +### execute the target system's program. Can the version be discovered +### any other way? +### +.if ${USE_CROSS_COMPILE:tl} != "yes" && \ + !defined(BUILTIN_PKG.oracle-jdk8) && \ !empty(IS_BUILTIN.oracle-jdk8:M[yY][eE][sS]) && \ empty(JDK8:M__nonexistent__) diff --git a/lang/oracle-jre8/builtin.mk b/lang/oracle-jre8/builtin.mk index 8d169ccacd48..96fec6b1d7d8 100644 --- a/lang/oracle-jre8/builtin.mk +++ b/lang/oracle-jre8/builtin.mk @@ -44,7 +44,12 @@ MAKEVARS+= IS_BUILTIN.oracle-jre8 ### If there is a built-in implementation, then set BUILTIN_PKG. to ### a package name to represent the built-in package. ### -.if !defined(BUILTIN_PKG.oracle-jre8) && \ +### XXX This doesn't work for cross-compilation because we can't +### execute the target system's program. Can the version be discovered +### any other way? +### +.if ${USE_CROSS_COMPILE:tl} != "yes" && \ + !defined(BUILTIN_PKG.oracle-jre8) && \ !empty(IS_BUILTIN.oracle-jre8:M[yY][eE][sS]) && \ empty(JAVAVM8:M__nonexistent__) diff --git a/lang/sun-jdk7/builtin.mk b/lang/sun-jdk7/builtin.mk index 4bbc1625851b..b94a111dd850 100644 --- a/lang/sun-jdk7/builtin.mk +++ b/lang/sun-jdk7/builtin.mk @@ -44,7 +44,12 @@ MAKEVARS+= IS_BUILTIN.sun-jdk7 ### If there is a built-in implementation, then set BUILTIN_PKG. to ### a package name to represent the built-in package. ### -.if !defined(BUILTIN_PKG.sun-jdk7) && \ +### XXX This doesn't work for cross-compilation because we can't +### execute the target system's program. Can the version be discovered +### any other way? +### +.if ${USE_CROSS_COMPILE:tl} != "yes" && \ + !defined(BUILTIN_PKG.sun-jdk7) && \ !empty(IS_BUILTIN.sun-jdk7:M[yY][eE][sS]) && \ empty(JDK7:M__nonexistent__) diff --git a/lang/sun-jre7/builtin.mk b/lang/sun-jre7/builtin.mk index 5c0f7f1f687e..9a1614def49e 100644 --- a/lang/sun-jre7/builtin.mk +++ b/lang/sun-jre7/builtin.mk @@ -44,7 +44,12 @@ MAKEVARS+= IS_BUILTIN.sun-jre7 ### If there is a built-in implementation, then set BUILTIN_PKG. to ### a package name to represent the built-in package. ### -.if !defined(BUILTIN_PKG.sun-jre7) && \ +### XXX This doesn't work for cross-compilation because we can't +### execute the target system's program. Can the version be discovered +### any other way? +### +.if ${USE_CROSS_COMPILE:tl} != "yes" && \ + !defined(BUILTIN_PKG.sun-jre7) && \ !empty(IS_BUILTIN.sun-jre7:M[yY][eE][sS]) && \ empty(JAVAVM7:M__nonexistent__) diff --git a/net/bind916/builtin.mk b/net/bind916/builtin.mk index a33e12d84270..63c4f38d4628 100644 --- a/net/bind916/builtin.mk +++ b/net/bind916/builtin.mk @@ -12,7 +12,12 @@ BUILTIN_FIND_LIBS:= bind ### Figure out the version of BIND if an ISC BIND named exists on the ### system. ### -.if !defined(BUILTIN_VERSION.bind) && \ +### XXX This doesn't work for cross-compilation because we can't +### execute the target system's program. Can the version be discovered +### any other way? +### +.if ${USE_CROSS_COMPILE:tl} != "yes" && \ + !defined(BUILTIN_VERSION.bind) && \ empty(EXE_NAMED:M__nonexistent__) && \ empty(EXE_NAMED:M${LOCALBASE}/*) BUILTIN_VERSION.bind!= \ diff --git a/net/bind918/builtin.mk b/net/bind918/builtin.mk index dc68b9043dd6..7ca49772fb6c 100644 --- a/net/bind918/builtin.mk +++ b/net/bind918/builtin.mk @@ -12,7 +12,12 @@ BUILTIN_FIND_LIBS:= bind ### Figure out the version of BIND if an ISC BIND named exists on the ### system. ### -.if !defined(BUILTIN_VERSION.bind) && \ +### XXX This doesn't work for cross-compilation because we can't +### execute the target system's program. Can the version be discovered +### any other way? +### +.if ${USE_CROSS_COMPILE:tl} != "yes" && \ + !defined(BUILTIN_VERSION.bind) && \ empty(EXE_NAMED:M__nonexistent__) && \ empty(EXE_NAMED:M${LOCALBASE}/*) BUILTIN_VERSION.bind!= \ diff --git a/sysutils/file/builtin.mk b/sysutils/file/builtin.mk index 2c0bbd9808e2..94673c0bf3c0 100644 --- a/sysutils/file/builtin.mk +++ b/sysutils/file/builtin.mk @@ -27,7 +27,12 @@ BUILTIN_CMD.file= file .endif MAKEVARS+= IS_BUILTIN.file -.if !defined(BUILTIN_PKG.file) && !empty(IS_BUILTIN.file:M[yY][eE][sS]) +### XXX This doesn't work for cross-compilation because we can't +### execute the target system's program. Can the version be discovered +### any other way? +.if ${USE_CROSS_COMPILE:tl} != "yes" && \ + !defined(BUILTIN_PKG.file) && \ + !empty(IS_BUILTIN.file:M[yY][eE][sS]) BUILTIN_VERSION.file!= ${BUILTIN_CMD.file} --version 2>&1 | ${GREP} 'file-' | ${SED} 's/file-//' BUILTIN_PKG.file= file-${BUILTIN_VERSION.file} .endif From e730bc7f81b50e93830fd078e69c6f0a42399bd6 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 11 Jan 2024 23:36:22 +0000 Subject: [PATCH 03/27] gnu-configure.mk: Don't use _OPSYS_MAX_CMDLEN_CMD in cross-builds. This is a command to be run in the target system, so it doesn't work to run it at build-time, which might be a different architecture and operating system altogether giving unrelated answers. No change to native builds because this just makes some existing logic conditional on native builds. --- mk/configure/gnu-configure.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mk/configure/gnu-configure.mk b/mk/configure/gnu-configure.mk index e5c9b4e207c3..4a1ab41ba888 100644 --- a/mk/configure/gnu-configure.mk +++ b/mk/configure/gnu-configure.mk @@ -51,7 +51,8 @@ CONFIGURE_ENV+= LIBS=${LIBS:M*:Q} CONFIGURE_ENV+= ac_given_INSTALL=${INSTALL:Q}\ -c\ -o\ ${BINOWN}\ -g\ ${BINGRP} .if (defined(USE_LIBTOOL) || !empty(PKGPATH:Mdevel/libtool-base)) && \ - defined(_OPSYS_MAX_CMDLEN_CMD) + defined(_OPSYS_MAX_CMDLEN_CMD) && \ + ${USE_CROSS_COMPILE:tl} != "yes" CONFIGURE_ENV+= lt_cv_sys_max_cmd_len=${_OPSYS_MAX_CMDLEN_CMD:sh} .endif From 8035eca6f9c2a8833f3a65e5dd85715704463b5f Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 11 Jan 2024 23:39:59 +0000 Subject: [PATCH 04/27] security/heimdal, security/mit-krb5: Do krb5-config in cross-destdir. Although this is an executable program, it's a very simple shell script which can be run in the build environment to describe the target environment. So qualify paths to it by ${_CROSS_DESTDIR:U}, where it lives during cross-builds. No change to native builds because ${_CROSS_DESTDIR:U} is empty in them. --- security/heimdal/builtin.mk | 9 +++++---- security/mit-krb5/builtin.mk | 15 ++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/security/heimdal/builtin.mk b/security/heimdal/builtin.mk index a2b397ed281e..07f524df70cc 100644 --- a/security/heimdal/builtin.mk +++ b/security/heimdal/builtin.mk @@ -30,8 +30,9 @@ MAKEVARS+= IS_BUILTIN.heimdal .if !defined(BUILTIN_PKG.heimdal) && \ ${IS_BUILTIN.heimdal:tl} == yes . if empty(SH_KRB5_CONFIG:M__nonexistent__) -BUILTIN_VERSION.heimdal!= ${SH_KRB5_CONFIG} --version | \ - ${AWK} '{ print $$2; exit }' +BUILTIN_VERSION.heimdal!= \ + ${_CROSS_DESTDIR:U:Q}${SH_KRB5_CONFIG:Q} --version | \ + ${AWK} '{ print $$2; exit }' . else # # heimdal<=0.6.x doesn't have a method of checking files to discover @@ -108,7 +109,7 @@ CHECK_BUILTIN.heimdal?= no . if ${USE_BUILTIN.heimdal:tl} == no BUILDLINK_API_DEPENDS.heimdal+= heimdal>=0.6 -KRB5_CONFIG?= ${BUILDLINK_PREFIX.heimdal}/bin/krb5-config +KRB5_CONFIG?= ${_CROSS_DESTDIR:U}${BUILDLINK_PREFIX.heimdal}/bin/krb5-config CONFIGURE_ENV+= KRB5_CONFIG=${KRB5_CONFIG:Q} MAKE_ENV+= KRB5_CONFIG=${KRB5_CONFIG:Q} . endif @@ -128,7 +129,7 @@ fake-krb5-config: KRB5_CONFIG?= ${BUILDLINK_DIR}/bin/krb5-config . else -KRB5_CONFIG?= ${SH_KRB5_CONFIG} +KRB5_CONFIG?= ${_CROSS_DESTDIR:U}${SH_KRB5_CONFIG} . endif CONFIGURE_ENV+= KRB5_CONFIG=${KRB5_CONFIG:Q} MAKE_ENV+= KRB5_CONFIG=${KRB5_CONFIG:Q} diff --git a/security/mit-krb5/builtin.mk b/security/mit-krb5/builtin.mk index ac460eaa09ce..0358c78c2937 100644 --- a/security/mit-krb5/builtin.mk +++ b/security/mit-krb5/builtin.mk @@ -43,8 +43,9 @@ MAKEVARS+= IS_BUILTIN.mit-krb5 .if !defined(BUILTIN_PKG.mit-krb5) && \ ${IS_BUILTIN.mit-krb5:tl} == yes . if empty(SH_KRB5_CONFIG:M__nonexistent__) -BUILTIN_VERSION.mit-krb5!= ${SH_KRB5_CONFIG} --version | \ - ${SED} -e 's/.*release //' -e 's/-.*//' -e 's/).*//' +BUILTIN_VERSION.mit-krb5!= \ + ${_CROSS_DESTDIR:U:Q}${SH_KRB5_CONFIG:Q} --version | \ + ${SED} -e 's/.*release //' -e 's/-.*//' -e 's/).*//' . endif BUILTIN_VERSION.mit-krb5?= 1.4.0 BUILTIN_PKG.mit-krb5= mit-krb5-${BUILTIN_VERSION.mit-krb5} @@ -85,11 +86,11 @@ MAKEVARS+= USE_BUILTIN.mit-krb5 CHECK_BUILTIN.mit-krb5?= no .if ${CHECK_BUILTIN.mit-krb5:tl} == no . if ${USE_BUILTIN.mit-krb5:tl} == yes -KRB5_CONFIG?= ${SH_KRB5_CONFIG} +KRB5_CONFIG?= ${_CROSS_DESTDIR:U}${SH_KRB5_CONFIG} ALL_ENV+= KRB5_CONFIG=${KRB5_CONFIG:Q} -BUILDLINK_CPPFLAGS.mit-krb5!= ${SH_KRB5_CONFIG} --cflags -BUILDLINK_LDFLAGS.mit-krb5!= ${SH_KRB5_CONFIG} --libs +BUILDLINK_CPPFLAGS.mit-krb5!= ${_CROSS_DESTDIR:U:Q}${SH_KRB5_CONFIG:Q} --cflags +BUILDLINK_LDFLAGS.mit-krb5!= ${_CROSS_DESTDIR:U:Q}${SH_KRB5_CONFIG:Q} --libs # # The SunOS builtin krb5-config does not support all of the arguments that the @@ -109,14 +110,14 @@ fake-krb5-config: if [ ! -f $${dst} ]; then \ ${ECHO_BUILDLINK_MSG} "Creating $${dst}"; \ ${ECHO} "#!${SH}" > $${dst}; \ - ${SED} -e "s,@KRB5_CONFIG@,${SH_KRB5_CONFIG:Q},g" \ + ${SED} -e s,@KRB5_CONFIG@,${_CROSS_DESTDIR:U:Q}${SH_KRB5_CONFIG:Q},g \ $${src} >> $${dst}; \ ${CHMOD} +x $${dst}; \ fi . endif . else -KRB5_CONFIG?= ${BUILDLINK_PREFIX.mit-krb5}/bin/krb5-config +KRB5_CONFIG?= ${_CROSS_DESTDIR:U}${BUILDLINK_PREFIX.mit-krb5}/bin/krb5-config CONFIGURE_ENV+= KRB5_CONFIG=${KRB5_CONFIG:Q} MAKE_ENV+= KRB5_CONFIG=${KRB5_CONFIG:Q} . endif From 0b5e0bca24399f67c536576ae9d6e10ec0c83f16 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 11 Jan 2024 23:42:19 +0000 Subject: [PATCH 05/27] pkg_install-20230629: Extend `-m' syntax to allow OPSYS too. - If there's no slash `/', take it all as ${MACHINE_ARCH}. - If there is a slash, then split it by `/' and ` ' into: ${OPSYS}/${MACHINE_ARCH} ${OPSYS_VERSION} For example: NetBSD/aarch64 10.0 All the variables are restricted to lie in a safe set [a-zA-Z0-9._-], so the notation can be extended later. No change to existing syntax (no MACHINE_ARCH has `/' in it, or anything outside the safe set), and `-m' is generally only used with cross builds anyway, so this shouldn't break existing cross builds and should have no impact on native builds. --- pkgtools/pkg_install/files/add/Makefile.in | 2 +- pkgtools/pkg_install/files/add/add.h | 4 + pkgtools/pkg_install/files/add/main.c | 5 +- pkgtools/pkg_install/files/add/parse_cross.c | 97 ++++++++++++++++++++ pkgtools/pkg_install/files/add/perform.c | 35 ++++--- pkgtools/pkg_install/files/lib/version.h | 2 +- 6 files changed, 129 insertions(+), 16 deletions(-) create mode 100644 pkgtools/pkg_install/files/add/parse_cross.c diff --git a/pkgtools/pkg_install/files/add/Makefile.in b/pkgtools/pkg_install/files/add/Makefile.in index 1bd11c421778..614dbaf5fdf6 100644 --- a/pkgtools/pkg_install/files/add/Makefile.in +++ b/pkgtools/pkg_install/files/add/Makefile.in @@ -37,7 +37,7 @@ INSTALL= @INSTALL@ PROG= pkg_add -OBJS= main.o perform.o +OBJS= main.o parse_cross.o perform.o all: $(PROG) diff --git a/pkgtools/pkg_install/files/add/add.h b/pkgtools/pkg_install/files/add/add.h index a55f40bb580f..e483f20e2c99 100644 --- a/pkgtools/pkg_install/files/add/add.h +++ b/pkgtools/pkg_install/files/add/add.h @@ -27,6 +27,8 @@ extern char *Destdir; extern char *OverrideMachine; +extern char *OverrideOpsys; +extern char *OverrideOSVersion; extern char *Prefix; extern char *View; extern char *Viewbase; @@ -42,6 +44,8 @@ extern int ReplaceSame; extern Boolean ForceDepends; extern Boolean ForceDepending; +void parse_cross(const char *, char **, char **, char **); + int make_hierarchy(char *); void apply_perms(char *, char **, int); diff --git a/pkgtools/pkg_install/files/add/main.c b/pkgtools/pkg_install/files/add/main.c index bec606923320..3c95260f3150 100644 --- a/pkgtools/pkg_install/files/add/main.c +++ b/pkgtools/pkg_install/files/add/main.c @@ -40,6 +40,8 @@ static char Options[] = "AC:DIK:P:RVfhm:np:t:Uuv"; char *Destdir = NULL; char *OverrideMachine = NULL; +char *OverrideOpsys = NULL; +char *OverrideOSVersion = NULL; char *Prefix = NULL; Boolean NoInstall = FALSE; Boolean NoRecord = FALSE; @@ -110,7 +112,8 @@ main(int argc, char **argv) break; case 'm': - OverrideMachine = optarg; + parse_cross(optarg, &OverrideMachine, &OverrideOpsys, + &OverrideOSVersion); break; case 'n': diff --git a/pkgtools/pkg_install/files/add/parse_cross.c b/pkgtools/pkg_install/files/add/parse_cross.c new file mode 100644 index 000000000000..1026ade8b4ba --- /dev/null +++ b/pkgtools/pkg_install/files/add/parse_cross.c @@ -0,0 +1,97 @@ +/* $NetBSD$ */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif +#include +#if HAVE_SYS_CDEFS_H +#include +#endif +__RCSID("$NetBSD$"); + +#include "lib.h" +#include "add.h" + +/* + * ${OPSYS}/${MACHINE_ARCH} ${OS_VERSION} + * + * or just + * + * ${MACHINE_ARCH} + */ +void +parse_cross(const char *text, char **machine_arch, char **opsys, + char **os_version) +{ + static const char safeset[] = /* XXX */ + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789" + "-._"; + char *copy = xstrdup(text); + char *p = copy, *q, *r; + + /* + * If there's no /, treat it as a single MACHINE_ARCH. + */ + if (*(q = strchr(p, '/')) == '\0') { + *machine_arch = copy; + *opsys = NULL; + *os_version = NULL; + } else { + /* + * NUL-terminate at the slash so p := text[0..slash) + * is the OPSYS. + */ + *q++ = '\0'; + + /* + * If there's no SPC, fail. + */ + if (*(r = strchr(q, ' ')) == '\0') { + goto fail; + } + + /* + * NUL-terminate at the space so + * + * q := text(slash..space) + * + * is the MACHINE_ARCH. + */ + *r++ = '\0'; + + /* + * The rest is already NUL-terminated, so + * + * r := text(space..NUL) + * + * is the OS_VERSION. + */ + *opsys = p; + *machine_arch = q; + *os_version = r; + } + + /* + * Verify that MACHINE_ARCH, and, if specified, OPSYS and + * OS_VERSION lie within the safe set, so we can reserve large + * amounts of the space of inputs for additional syntax. + * Ideally we would impose more constraints here with a + * regular expression to restrict the space even more, but + * this'll do for now. + */ + if ((*machine_arch)[strspn(*machine_arch, safeset)] != '\0') { + goto fail; + } + if (*opsys != NULL && (*opsys)[strspn(*opsys, safeset)] != '\0') { + goto fail; + } + if (*os_version != NULL && + (*os_version)[strspn(*os_version, safeset)] != '\0') { + goto fail; + } + return; + +fail: errx(1, "Invalid -m argument: ${OPSYS}/${MACHINE_ARCH} ${OS_VERSION}"); +} diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c index 65e20c554266..fb95ded6acc6 100644 --- a/pkgtools/pkg_install/files/add/perform.c +++ b/pkgtools/pkg_install/files/add/perform.c @@ -893,19 +893,28 @@ check_platform(struct pkg_task *pkg) { struct utsname host_uname; const char *effective_arch; + const char *effective_opsys; + const char *effective_os_version; int fatal; - if (uname(&host_uname) < 0) { - if (Force) { - warnx("uname() failed, continuing."); - return 0; - } else { - warnx("uname() failed, aborting."); - return -1; + if (OverrideOpsys != NULL && OverrideOSVersion != NULL) { + effective_opsys = OverrideOpsys; + effective_os_version = OverrideOSVersion; + } else { + if (uname(&host_uname) < 0) { + if (Force) { + warnx("uname() failed, continuing."); + return 0; + } else { + warnx("uname() failed, aborting."); + return -1; + } } - } - normalise_platform(&host_uname); + normalise_platform(&host_uname); + effective_opsys = OPSYS_NAME; + effective_os_version = host_uname.release; + } if (OverrideMachine != NULL) effective_arch = OverrideMachine; @@ -913,14 +922,14 @@ check_platform(struct pkg_task *pkg) effective_arch = PKGSRC_MACHINE_ARCH; /* If either the OS or arch are different, bomb */ - if (strcmp(OPSYS_NAME, pkg->buildinfo[BI_OPSYS]) || + if (strcmp(effective_opsys, pkg->buildinfo[BI_OPSYS]) || strcmp(effective_arch, pkg->buildinfo[BI_MACHINE_ARCH]) != 0) fatal = 1; else fatal = 0; if (fatal || - compatible_platform(OPSYS_NAME, host_uname.release, + compatible_platform(effective_opsys, effective_os_version, pkg->buildinfo[BI_OS_VERSION]) != 1) { warnx("Warning: package `%s' was built for a platform:", pkg->pkgname); @@ -928,9 +937,9 @@ check_platform(struct pkg_task *pkg) pkg->buildinfo[BI_OPSYS], pkg->buildinfo[BI_MACHINE_ARCH], pkg->buildinfo[BI_OS_VERSION], - OPSYS_NAME, + effective_opsys, effective_arch, - host_uname.release); + effective_os_version); if (!Force && fatal) return -1; } diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h index 9bd3ab0a0def..52ce96b5cc61 100644 --- a/pkgtools/pkg_install/files/lib/version.h +++ b/pkgtools/pkg_install/files/lib/version.h @@ -27,6 +27,6 @@ #ifndef _INST_LIB_VERSION_H_ #define _INST_LIB_VERSION_H_ -#define PKGTOOLS_VERSION 20211115 +#define PKGTOOLS_VERSION 20230629 #endif /* _INST_LIB_VERSION_H_ */ From 4c2c21affc3b9294fa3e440dc1df84059ba36311 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 11 Jan 2024 23:49:59 +0000 Subject: [PATCH 06/27] mk/pkgformat/pkg: Use extended `-m "OS/ARCH VER"' syntax. Requires pkg_install>=20230629. No change to native builds, not even the pkg_install requirement, because this is conditional on cross builds. --- mk/pkgformat/pkg/package.mk | 2 +- mk/pkgformat/pkg/pkgformat-vars.mk | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mk/pkgformat/pkg/package.mk b/mk/pkgformat/pkg/package.mk index c6be0267326a..924a82dbc499 100644 --- a/mk/pkgformat/pkg/package.mk +++ b/mk/pkgformat/pkg/package.mk @@ -150,7 +150,7 @@ su-real-package-install: @${PHASE_MSG} "Installing binary package of "${PKGNAME:Q} .if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) @${MKDIR} ${_CROSS_DESTDIR}${PREFIX} - ${SETENV} ${PKGTOOLS_ENV} ${PKG_ADD} -m ${MACHINE_ARCH} -I -p ${_CROSS_DESTDIR}${PREFIX} ${STAGE_PKGFILE} + ${SETENV} ${PKGTOOLS_ENV} ${PKG_ADD} -m ${OPSYS:Q}/${MACHINE_ARCH:Q}\ ${OS_VERSION:Q} -I -p ${_CROSS_DESTDIR}${PREFIX} ${STAGE_PKGFILE} @${ECHO} "Fixing recorded cwd..." @${SED} -e 's|@cwd ${_CROSS_DESTDIR}|@cwd |' ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS > ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp @${MV} ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS diff --git a/mk/pkgformat/pkg/pkgformat-vars.mk b/mk/pkgformat/pkg/pkgformat-vars.mk index 19a3020c1722..226c13e4e25d 100644 --- a/mk/pkgformat/pkg/pkgformat-vars.mk +++ b/mk/pkgformat/pkg/pkgformat-vars.mk @@ -40,7 +40,9 @@ NATIVE_PKG_INFO_CMD?= ${NATIVE_PKG_TOOLS_BIN}/pkg_info NATIVE_LINKFARM_CMD?= ${NATIVE_PKG_TOOLS_BIN}/linkfarm # Latest versions of tools required for correct pkgsrc operation. -.if !empty(USE_PKG_ADMIN_DIGEST:M[Yy][Ee][Ss]) +.if ${USE_CROSS_COMPILE:tl} == "yes" +PKGTOOLS_REQD= 20230629 +.elif !empty(USE_PKG_ADMIN_DIGEST:M[Yy][Ee][Ss]) PKGTOOLS_REQD= 20191008 .else PKGTOOLS_REQD= 20100914 From 3bea4e743c510e483c153184eeb21b268b9fe475 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 11 Jan 2024 23:55:05 +0000 Subject: [PATCH 07/27] mk/buildlink3: Use NATIVE_PKG_INFO_CMD for _BNK_PKG_INFO.${_pkg_}. This is executed at build-time, not baked into the target package to execute at run-time, so we need the native pkg_info command that can be executed at build-time. No change to native builds, where NATIVE_PKG_INFO_CMD is the same as PKG_INFO_CMD. (PKG_INFO, used above in _BLNK_PKG_DBDIR.${_pkg_}, is already defined in terms of NATIVE_PKG_INFO_CMD, so no need to change anything for _BLNK_PKG_DBDIR.${_pkg_}.) --- mk/buildlink3/bsd.buildlink3.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mk/buildlink3/bsd.buildlink3.mk b/mk/buildlink3/bsd.buildlink3.mk index ed398893b926..1beafbd8e77a 100644 --- a/mk/buildlink3/bsd.buildlink3.mk +++ b/mk/buildlink3/bsd.buildlink3.mk @@ -384,9 +384,9 @@ MAKEVARS+= _BLNK_PKG_DBDIR.${_pkg_} . endif . if empty(_BLNK_PKG_DBDIR.${_pkg_}:M*not_found) -_BLNK_PKG_INFO.${_pkg_}?= ${PKG_INFO_CMD} -K ${_BLNK_PKG_DBDIR.${_pkg_}:H} +_BLNK_PKG_INFO.${_pkg_}?= ${NATIVE_PKG_INFO_CMD} -K ${_BLNK_PKG_DBDIR.${_pkg_}:H} . else -_BLNK_PKG_INFO.${_pkg_}?= ${PKG_INFO_CMD} -K ${_PKG_DBDIR} +_BLNK_PKG_INFO.${_pkg_}?= ${NATIVE_PKG_INFO_CMD} -K ${_PKG_DBDIR} . endif BUILDLINK_PKGNAME.${_pkg_}?= ${_BLNK_PKG_DBDIR.${_pkg_}:T} From 4bf1e5d73fc57252ae860e7e6668ec34f1bccf31 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 04:32:34 +0000 Subject: [PATCH 08/27] bsd.prefs.mk: Unconditionally define TOOLS_CROSS_DESTDIR. - If we're cross-compiling or building cross-libtool-base, alias for CROSS_DESTDIR. - Otherwise, empty. This will be convenient for sprinkling TOOLS_CROSS_DESTDIR in various places throughout mk/ without worrying about disrupting native builds. No change to native builds here because all current references are conditional on USE_CROSS_COMPILE = yes. --- mk/bsd.prefs.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk index e5aaada0a6c7..f1161385fcea 100644 --- a/mk/bsd.prefs.mk +++ b/mk/bsd.prefs.mk @@ -554,7 +554,11 @@ _MAKE_PACKAGE_AS_ROOT?= yes # TOOLS_CROSS_DESTDIR is used for the libtool build to make a wrapper # that points at the cross-destdir as sysroot, without setting # _CROSS_DESTDIR because we're actually building a native package. +.if ${TOOLS_USE_CROSS_COMPILE:tl} == "yes" TOOLS_CROSS_DESTDIR= ${CROSS_DESTDIR} +.else +TOOLS_CROSS_DESTDIR= # empty +.endif # Depends on MACHINE_ARCH override above .if ${OPSYS} == "NetBSD" From 3ccf777ff917e01ce91c83dbac8bdd9880d2e133 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 04:34:47 +0000 Subject: [PATCH 09/27] 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. --- mk/buildlink3/bsd.buildlink3.mk | 24 ++++++++++++------------ mk/buildlink3/find-files.mk | 6 ++++-- mk/buildlink3/find-headers.mk | 6 ++++-- mk/buildlink3/find-libs.mk | 3 ++- mk/buildlink3/find-pkgconfig-files.mk | 3 ++- mk/buildlink3/pkgconfig-builtin.mk | 2 +- mk/curses.builtin.mk | 5 +++-- mk/db1.builtin.mk | 4 ++-- mk/dlopen.builtin.mk | 2 +- mk/fuse.buildlink3.mk | 2 +- mk/pthread.builtin.mk | 3 ++- mk/solaris-pam.builtin.mk | 3 ++- 12 files changed, 36 insertions(+), 27 deletions(-) diff --git a/mk/buildlink3/bsd.buildlink3.mk b/mk/buildlink3/bsd.buildlink3.mk index 1beafbd8e77a..010b88902ac1 100644 --- a/mk/buildlink3/bsd.buildlink3.mk +++ b/mk/buildlink3/bsd.buildlink3.mk @@ -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 diff --git a/mk/buildlink3/find-files.mk b/mk/buildlink3/find-files.mk index 865755b123be..597a20310e8f 100644 --- a/mk/buildlink3/find-files.mk +++ b/mk/buildlink3/find-files.mk @@ -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__; \ diff --git a/mk/buildlink3/find-headers.mk b/mk/buildlink3/find-headers.mk index da5ce75b1d38..306ad49eed24 100644 --- a/mk/buildlink3/find-headers.mk +++ b/mk/buildlink3/find-headers.mk @@ -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__; \ diff --git a/mk/buildlink3/find-libs.mk b/mk/buildlink3/find-libs.mk index 435d6fcad20d..62161a13e4db 100644 --- a/mk/buildlink3/find-libs.mk +++ b/mk/buildlink3/find-libs.mk @@ -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; \ diff --git a/mk/buildlink3/find-pkgconfig-files.mk b/mk/buildlink3/find-pkgconfig-files.mk index 30aa5f9c44aa..315951f40180 100644 --- a/mk/buildlink3/find-pkgconfig-files.mk +++ b/mk/buildlink3/find-pkgconfig-files.mk @@ -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 diff --git a/mk/buildlink3/pkgconfig-builtin.mk b/mk/buildlink3/pkgconfig-builtin.mk index ab9105c114fa..681ef36483b0 100644 --- a/mk/buildlink3/pkgconfig-builtin.mk +++ b/mk/buildlink3/pkgconfig-builtin.mk @@ -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} diff --git a/mk/curses.builtin.mk b/mk/curses.builtin.mk index 767cae750085..1fb9b379ba40 100644 --- a/mk/curses.builtin.mk +++ b/mk/curses.builtin.mk @@ -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} diff --git a/mk/db1.builtin.mk b/mk/db1.builtin.mk index 1aae17f498fc..b3779df2bd3b 100644 --- a/mk/db1.builtin.mk +++ b/mk/db1.builtin.mk @@ -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]) diff --git a/mk/dlopen.builtin.mk b/mk/dlopen.builtin.mk index 660a477447a9..8b32c2a1eb18 100644 --- a/mk/dlopen.builtin.mk +++ b/mk/dlopen.builtin.mk @@ -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 diff --git a/mk/fuse.buildlink3.mk b/mk/fuse.buildlink3.mk index f9a3d9ec52ff..3f8cbf545778 100644 --- a/mk/fuse.buildlink3.mk +++ b/mk/fuse.buildlink3.mk @@ -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 diff --git a/mk/pthread.builtin.mk b/mk/pthread.builtin.mk index 9b9183884418..4d094f5cb382 100644 --- a/mk/pthread.builtin.mk +++ b/mk/pthread.builtin.mk @@ -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 diff --git a/mk/solaris-pam.builtin.mk b/mk/solaris-pam.builtin.mk index 48e47f696c55..3d5c4d8f05f9 100644 --- a/mk/solaris-pam.builtin.mk +++ b/mk/solaris-pam.builtin.mk @@ -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 From 5443cd9f70d2ed27bed655d7774bbec09b1b459c Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 04:12:48 +0000 Subject: [PATCH 10/27] 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. --- mk/bsd.prefs.mk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk index f1161385fcea..87dbb29bd15a 100644 --- a/mk/bsd.prefs.mk +++ b/mk/bsd.prefs.mk @@ -341,6 +341,11 @@ MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${MACHINE_ARCH} NATIVE_MACHINE_GNU_PLATFORM?= ${NATIVE_MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${NATIVE_APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}${NATIVE_APPEND_ABI} MACHINE_GNU_PLATFORM?= ${MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}${APPEND_ABI} +# Set this before does, since it doesn't know about Darwin +.if ${OPSYS} == "Darwin" +OBJECT_FMT?= Mach-O +.endif + # # cross-libtool is special -- it is built as a native package, but it # needs tools set up as if for a cross-compiled package because it @@ -376,11 +381,6 @@ NEED_OWN_INSTALL_TARGET=no USETOOLS= no MAKE_ENV+= USETOOLS=no -# Set this before does, since it doesn't know about Darwin -.if ${OPSYS} == "Darwin" -OBJECT_FMT?= Mach-O -.endif - ACCEPTABLE_LICENSES?= ${DEFAULT_ACCEPTABLE_LICENSES} # Provide PKGPATH early on so that mk.conf can use it. From 9c1f642d7b25f21d31e02b3d532e07a131c6fb80 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 04:20:16 +0000 Subject: [PATCH 11/27] bsd.prefs.mk: Set cross MACHINE_ARCH/destdir right after bsd.own.mk. This puts it before defaults/mk.conf, which has no effect here -- there's no default TARGET_ARCH, MAKEOBJDIR, or CROSS_DESTDIR in defaults/mk.conf, and defaults/mk.conf is not affected by MACHINE_ARCH (immediately, anyway), CROSS_DESTDIR, or _CROSS_DESTDIR. Later we'll add more variables like MACHINE_ARCH here affected by a TARGET_* variable, including OBJECT_FMT. This will allow us to handle OBJECT_FMT via TARGET_OBJECT_FMT before the next stanza which provides OPSYS-based defaults for OBJECT_FMT. No change for native builds since this only moves around a block gated on USE_CROSS_COMPILE = yes. --- mk/bsd.prefs.mk | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk index 87dbb29bd15a..ad66a61cdec0 100644 --- a/mk/bsd.prefs.mk +++ b/mk/bsd.prefs.mk @@ -389,6 +389,28 @@ PKGPATH?= ${.CURDIR:C|.*/([^/]*/[^/]*)$|\1|} # Load the settings from MAKECONF, which is /etc/mk.conf by default. .include +# When cross-compilation support is requested, the following options +# must be specified as well or guessable: +# - MACHINE_ARCH is set to TARGET_ARCH if set. +# - CROSS_DESTDIR is guessed from MAKEOBJDIR and MACHINE_ARCH. +# - PKG_DBDIR is expanded and prefixed with CROSS_DESTDIR +# - DESTDIR support is required +# +# _CROSS_DESTDIR is set for internal use to avoid conditionalising +# the use. + +.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) +. if defined(TARGET_ARCH) +MACHINE_ARCH= ${TARGET_ARCH} +. endif +CROSS_DESTDIR?= ${MAKEOBJDIR}/destdir.${MACHINE_ARCH} +. if !exists(${CROSS_DESTDIR}/usr/include/stddef.h) +PKG_FAIL_REASON+= "The cross-compiling root ${CROSS_DESTDIR:Q} is incomplete" +. else +_CROSS_DESTDIR= ${CROSS_DESTDIR} +. endif +.endif + .if ${OPSYS} == "OpenBSD" . if defined(ELF_TOOLCHAIN) && ${ELF_TOOLCHAIN} == "yes" OBJECT_FMT?= ELF @@ -450,28 +472,6 @@ SHAREMODE?= ${DOCMODE} @${FALSE} .endif -# When cross-compilation support is requested, the following options -# must be specified as well or guessable: -# - MACHINE_ARCH is set to TARGET_ARCH if set. -# - CROSS_DESTDIR is guessed from MAKEOBJDIR and MACHINE_ARCH. -# - PKG_DBDIR is expanded and prefixed with CROSS_DESTDIR -# - DESTDIR support is required -# -# _CROSS_DESTDIR is set for internal use to avoid conditionalising -# the use. - -.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) -. if defined(TARGET_ARCH) -MACHINE_ARCH= ${TARGET_ARCH} -. endif -CROSS_DESTDIR?= ${MAKEOBJDIR}/destdir.${MACHINE_ARCH} -. if !exists(${CROSS_DESTDIR}/usr/include/stddef.h) -PKG_FAIL_REASON+= "The cross-compiling root ${CROSS_DESTDIR:Q} is incomplete" -. else -_CROSS_DESTDIR= ${CROSS_DESTDIR} -. endif -.endif - # Load the OS-specific definitions for program variables. Default to loading # the NetBSD ones if an OS-specific file doesn't exist. .if exists(${_PKGSRC_TOPDIR}/mk/platform/${OPSYS}.mk) From 74590dd2f9341e20e220c5fe6ca5e097ca5c1122 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 04:25:06 +0000 Subject: [PATCH 12/27] mk: New CROSS_* variable scheme for cross-compilation. This change brings in support for cross-OS-compilation. Caveat: Existing mk.conf files used for cross-compilation no longer work; they must be adapted to the new scheme. Under this new scheme, if an mk.conf variable X can be different for native and cross builds like OPSYS, MACHINE_ARCH, LOCALBASE, &c., you just define X in mk.conf to set it for native builds, and CROSS_X in mk.conf to set it for cross builds. Example: LOCALBASE= /home/riastradh/pkgsrc/cross/pkg CROSS_LOCALBASE= /opt/pkg CROSS_MACHINE_ARCH= powerpc For now, _all_ OS-related variables must be defined in cross-builds; none are filled in automatically. For NetBSD, this means: CROSS_OPSYS= NetBSD CROSS_OS_VERSION= 10.0 CROSS_OPSYS_VERSION= 100000 CROSS_LOWER_OPSYS= netbsd CROSS_LOWER_OPSYS_VERSUFFIX=# empty CROSS_LOWER_OS_VARIANT= # empty CROSS_LOWER_VARIANT_VERSION=# empty CROSS_LOWER_VENDOR= # empty XXX This new scheme is likely to substantially raise make(1) costs by making a lot of variables expand to conditionals rather than fixed strings. Need to think of a way to mitigate this. Unfortunately, there's a lot of moving parts so it's not trivial to just make it all conditional on USE_CROSS_COMPILE = yes, because that might not even be defined by the time we have to use some of the variables. --- doc/HOWTO-use-crosscompile | 33 ++-- mk/bsd.prefs.mk | 338 +++++++++++++++++++++---------------- mk/tools/cross.NetBSD.mk | 25 +++ mk/tools/defaults.mk | 13 +- mk/tools/tools.NetBSD.mk | 32 ---- 5 files changed, 247 insertions(+), 194 deletions(-) create mode 100644 mk/tools/cross.NetBSD.mk diff --git a/doc/HOWTO-use-crosscompile b/doc/HOWTO-use-crosscompile index c2f7fe7c659f..51fe453bc4dd 100644 --- a/doc/HOWTO-use-crosscompile +++ b/doc/HOWTO-use-crosscompile @@ -37,29 +37,27 @@ In addition to whatever else you want in your mk.conf for pkgsrc, add: # Cross-compile by default. # # XXX This currently can't be set to `yes' on the command line, - # which is a bug. + # which is a bug. But it can be set to `no' to build native + # packages. USE_CROSS_COMPILE?= yes # Point pkgsrc at the NetBSD tooldir and destdir. These are used # only for cross-builds. - # - # XXX There is no obvious variable that is set to amd64 so that we - # could use - # - # TOOLDIR= /usr/obj/tooldir.${OPSYS}-${OS_VERSION}-${NATIVE_xyz} - # - # MACHINE is amd64 but, since it's not NATIVE_xyz, it's wrong. - # NATIVE_MACHINE_ARCH is x86_64, not amd64. TOOLDIR= /usr/obj/tooldir.NetBSD-6.1-amd64 CROSS_DESTDIR= /usr/obj/destdir.evbppc # Specify the machine architecture of target packages. - # - # XXX This currently can't be set on the command line, which is a - # bug. - .if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) - MACHINE_ARCH= powerpc - .endif + CROSS_MACHINE_ARCH= powerpc + + # Specify the OS of target packages. + CROSS_OPSYS= NetBSD + CROSS_OS_VERSION= 10.0 + CROSS_OPSYS_VERSION= 100000 + CROSS_LOWER_OPSYS= netbsd + CROSS_LOWER_OPSYS_VERSUFFIX= # empty + CROSS_LOWER_OS_VARIANT= # empty + CROSS_LOWER_VARIANT_VERSION= # empty + CROSS_LOWER_VENDOR= # empty Optionally, you can set CROSS_LOCALBASE for cross-compiled packages separately from LOCALBASE for natively compiled packages. For example, @@ -69,6 +67,9 @@ will create packages which install to /opt/pkg: LOCALBASE= /home/user/cross/pkg CROSS_LOCALBASE= /opt/pkg +By default, CROSS_LOCALBASE will be /usr/pkg, meaning packages that are +being cross-compiled will see LOCALBASE=/usr/pkg. + ** Bootstrapped pkgsrc You can bootstrap pkgsrc or not; it shouldn't make a difference for @@ -83,7 +84,7 @@ cross-compilation. If you do: be left empty or undefined for earmv7hf cross-builds. So you might need: - .if empty(USE_CROSS_COMPILE:M[yY][eE][sS]) + .if ${USE_CROSS_COMPILE:tl} != "yes" ABI= 64 # set for native amd64 build .else ABI= # empty for earmv7hf cross-build diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk index ad66a61cdec0..47be8aee8479 100644 --- a/mk/bsd.prefs.mk +++ b/mk/bsd.prefs.mk @@ -87,23 +87,23 @@ UNAME=/run/current-system/sw/bin/uname UNAME=echo Unknown .endif -.if !defined(OPSYS) -OPSYS:= ${:!${UNAME} -s!:S/-//g:S/\///g:C/^CYGWIN_.*$/Cygwin/} -MAKEFLAGS+= OPSYS=${OPSYS:Q} +.if !defined(NATIVE_OPSYS) +NATIVE_OPSYS:= ${:!${UNAME} -s!:S/-//g:S/\///g:C/^CYGWIN_.*$/Cygwin/} +MAKEFLAGS+= NATIVE_OPSYS=${NATIVE_OPSYS:Q} .endif # OS_VARIANT is used to differentiate operating systems which have a common # basis but offer contrasting environments, for example Linux distributions # or illumos forks. -OS_VARIANT?= # empty +NATIVE_OS_VARIANT?= # empty # The _CMD indirection allows code below to modify these values # without executing the commands at all. Later, recursed make # invocations will skip these blocks entirely thanks to MAKEFLAGS. -.if !defined(OS_VERSION) -_OS_VERSION_CMD= ${UNAME} -r -OS_VERSION= ${_OS_VERSION_CMD:sh} -MAKEFLAGS+= OS_VERSION=${OS_VERSION:Q} +.if !defined(NATIVE_OS_VERSION) +_NATIVE_OS_VERSION_CMD= ${UNAME} -r +NATIVE_OS_VERSION= ${_NATIVE_OS_VERSION_CMD:sh} +MAKEFLAGS+= NATIVE_OS_VERSION=${NATIVE_OS_VERSION:Q} .endif # @@ -112,11 +112,11 @@ MAKEFLAGS+= OS_VERSION=${OS_VERSION:Q} # default command is likely correct for most OS, those that need to can set # it to a custom command in the later OPSYS-specific section. # -.if !defined(OPSYS_VERSION) -_OPSYS_VERSION_CMD= ${UNAME} -r | \ +.if !defined(NATIVE_OPSYS_VERSION) +_NATIVE_OPSYS_VERSION_CMD= ${UNAME} -r | \ awk -F. '{major=int($$1); minor=int($$2); if (minor>=100) minor=99; patch=int($$3); if (patch>=100) patch=99; printf "%02d%02d%02d", major, minor, patch}' -OPSYS_VERSION= ${_OPSYS_VERSION_CMD:sh} -MAKEFLAGS+= OPSYS_VERSION=${OPSYS_VERSION:Q} +NATIVE_OPSYS_VERSION= ${_NATIVE_OPSYS_VERSION_CMD:sh} +MAKEFLAGS+= NATIVE_OPSYS_VERSION=${NATIVE_OPSYS_VERSION:Q} .endif # Preload these for architectures not in all variations of bsd.own.mk, @@ -155,194 +155,231 @@ MACHINE_GNU_ARCH?= ${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}} ## If changes are made to how OS_VERSION is set below please keep ## "pkgsrc/pkgtools/osabi/INSTALL" in-sync. -.if ${OPSYS} == "NetBSD" -LOWER_OPSYS?= netbsd +.if ${NATIVE_OPSYS} == "NetBSD" +NATIVE_LOWER_OPSYS?= netbsd -.elif ${OPSYS} == "AIX" +.elif ${NATIVE_OPSYS} == "AIX" . if exists(/usr/bin/oslevel) -_OS_VERSION!= /usr/bin/oslevel +_NATIVE_OS_VERSION!= /usr/bin/oslevel . else -_OS_VERSION!= echo `${UNAME} -v`.`${UNAME} -r` +_NATIVE_OS_VERSION!= echo `${UNAME} -v`.`${UNAME} -r` . endif -OS_VERSION= ${_OS_VERSION:C/([0-9]*\.[0-9]*).*/\1/} -LOWER_OPSYS_VERSUFFIX= ${_OS_VERSION} -LOWER_OPSYS?= aix -LOWER_VENDOR?= ibm - -.elif ${OPSYS} == "BSDOS" -LOWER_OPSYS?= bsdi - -.elif ${OPSYS} == "Cygwin" -LOWER_OPSYS?= cygwin -LOWER_VENDOR?= pc -_OS_VERSION!= ${UNAME} -r -OS_VERSION= ${_OS_VERSION:C/\(.*\)//} -OS_VARIANT!= ${UNAME} -s - -.elif ${OPSYS} == "Darwin" -LOWER_OPSYS?= darwin -LOWER_OPSYS_VERSUFFIX= ${OS_VERSION:C/([0-9]*).*/\1/} -LOWER_VENDOR?= apple -_OPSYS_VERSION_CMD= sw_vers -productVersion | \ +NATIVE_OS_VERSION= ${_NATIVE_OS_VERSION:C/([0-9]*\.[0-9]*).*/\1/} +NATIVE_LOWER_OPSYS_VERSUFFIX= ${_NATIVE_OS_VERSION} +NATIVE_LOWER_OPSYS?= aix +NATIVE_LOWER_VENDOR?= ibm + +.elif ${NATIVE_OPSYS} == "BSDOS" +NATIVE_LOWER_OPSYS?= bsdi + +.elif ${NATIVE_OPSYS} == "Cygwin" +NATIVE_LOWER_OPSYS?= cygwin +NATIVE_LOWER_VENDOR?= pc +_NATIVE_OS_VERSION!= ${UNAME} -r +NATIVE_OS_VERSION= ${_NATIVE_OS_VERSION:C/\(.*\)//} +NATIVE_OS_VARIANT!= ${UNAME} -s + +.elif ${NATIVE_OPSYS} == "Darwin" +NATIVE_LOWER_OPSYS?= darwin +NATIVE_LOWER_OPSYS_VERSUFFIX= ${NATIVE_OS_VERSION:C/([0-9]*).*/\1/} +NATIVE_LOWER_VENDOR?= apple +_NATIVE_OPSYS_VERSION_CMD= sw_vers -productVersion | \ awk -F. '{major=int($$1); minor=int($$2); if (minor>=100) minor=99; patch=int($$3); if (patch>=100) patch=99; printf "%02d%02d%02d", major, minor, patch}' -.elif ${OPSYS} == "DragonFly" -OS_VERSION:= ${OS_VERSION:C/-.*$//} -LOWER_OPSYS?= dragonfly -LOWER_VENDOR?= pc +.elif ${NATIVE_OPSYS} == "DragonFly" +NATIVE_OS_VERSION:= ${NATIVE_OS_VERSION:C/-.*$//} +NATIVE_LOWER_OPSYS?= dragonfly +NATIVE_LOWER_VENDOR?= pc -.elif ${OPSYS} == "FreeBSD" -OS_VERSION:= ${OS_VERSION:C/-.*$//} -LOWER_OPSYS?= freebsd -LOWER_OPSYS_VERSUFFIX= ${OS_VERSION:C/([0-9]*).*/\1/} +.elif ${NATIVE_OPSYS} == "FreeBSD" +NATIVE_OS_VERSION:= ${OS_VERSION:C/-.*$//} +NATIVE_LOWER_OPSYS?= freebsd +NATIVE_LOWER_OPSYS_VERSUFFIX= ${OS_VERSION:C/([0-9]*).*/\1/} . if ${MACHINE_ARCH} == "i386" -LOWER_VENDOR?= pc +NATIVE_LOWER_VENDOR?= pc . endif -LOWER_VENDOR?= unknown +NATIVE_LOWER_VENDOR?= unknown -.elif ${OPSYS} == "Haiku" -LOWER_OPSYS?= haiku -. if ${MACHINE_ARCH} == "i386" -LOWER_VENDOR?= pc +.elif ${NATIVE_OPSYS} == "Haiku" +NATIVE_LOWER_OPSYS?= haiku +. if ${NATIVE_MACHINE_ARCH} == "i386" +NATIVE_LOWER_VENDOR?= pc . endif -.elif ${OPSYS} == "Interix" -LOWER_OPSYS?= interix -LOWER_VENDOR?= pc +.elif ${NATIVE_OPSYS} == "Interix" +NATIVE_LOWER_OPSYS?= interix +NATIVE_LOWER_VENDOR?= pc . if exists(/usr/lib/libc.so.5.2) || exists(/usr/lib/x86/libc.so.5.2) -LOWER_OPSYS_VERSUFFIX= ${OS_VERSION:C/([0-9]*).*/\1/} +NATIVE_LOWER_OPSYS_VERSUFFIX= ${NATIVE_OS_VERSION:C/([0-9]*).*/\1/} . else -LOWER_OPSYS_VERSUFFIX?= 3 +NATIVE_LOWER_OPSYS_VERSUFFIX?= 3 . if exists(/usr/lib/libc.so.3.5) -OS_VERSION= 3.5 +NATIVE_OS_VERSION= 3.5 . elif exists(/usr/lib/libc.so.3.1) -OS_VERSION= 3.1 +NATIVE_OS_VERSION= 3.1 . else -OS_VERSION= 3.0 +NATIVE_OS_VERSION= 3.0 . endif . endif -.elif ${OPSYS} == "MirBSD" -LOWER_OPSYS?= mirbsd -LOWER_OPSYS_VERSUFFIX= ${OS_VERSION} -LOWER_VENDOR?= unknown +.elif ${NATIVE_OPSYS} == "MirBSD" +NATIVE_LOWER_OPSYS?= mirbsd +NATIVE_LOWER_OPSYS_VERSUFFIX= ${NATIVE_OS_VERSION} +NATIVE_LOWER_VENDOR?= unknown -.elif !empty(OPSYS:MIRIX*) -LOWER_OPSYS?= irix -LOWER_OPSYS_VERSUFFIX?= ${OS_VERSION} -LOWER_VENDOR?= sgi +.elif !empty(NATIVE_OPSYS:MIRIX*) +NATIVE_LOWER_OPSYS?= irix +NATIVE_LOWER_OPSYS_VERSUFFIX?= ${NATIVE_OS_VERSION} +NATIVE_LOWER_VENDOR?= sgi -.elif ${OPSYS} == "Linux" -OS_VERSION:= ${OS_VERSION:C/-.*$//} -LOWER_OPSYS?= linux +.elif ${NATIVE_OPSYS} == "Linux" +NATIVE_OS_VERSION:= ${NATIVE_OS_VERSION:C/-.*$//} +NATIVE_LOWER_OPSYS?= linux . if exists(/etc/lsb-release) CHROMEOS_RELEASE_NAME!= awk -F = '$$1 == "CHROMEOS_RELEASE_NAME" { print $$2 }' /etc/lsb-release . endif . if exists(/etc/debian_version) -LOWER_VENDOR?= debian +NATIVE_LOWER_VENDOR?= debian . elif exists(/etc/mandrake-release) -LOWER_VENDOR?= mandrake +NATIVE_LOWER_VENDOR?= mandrake . elif exists(/etc/redhat-version) || exists(/etc/redhat-release) -LOWER_VENDOR?= redhat +NATIVE_LOWER_VENDOR?= redhat . elif exists(/etc/slackware-version) -LOWER_VENDOR?= slackware +NATIVE_LOWER_VENDOR?= slackware . elif exists(/etc/ssdlinux_version) -LOWER_VENDOR?= ssd +NATIVE_LOWER_VENDOR?= ssd . elif !empty(CHROMEOS_RELEASE_NAME) -LOWER_VENDOR?= chromeos -. elif ${MACHINE_ARCH} == "i386" -LOWER_VENDOR?= pc +NATIVE_LOWER_VENDOR?= chromeos +. elif ${NATIVE_MACHINE_ARCH} == "i386" +NATIVE_LOWER_VENDOR?= pc . endif -LOWER_VENDOR?= unknown -OS_VARIANT!= ${UNAME} -r -OS_VARIANT:= ${OS_VARIANT:C/^.*-//} -. if ${OS_VARIANT} != "Microsoft" -OS_VARIANT= ${LOWER_VENDOR} +NATIVE_LOWER_VENDOR?= unknown +NATIVE_OS_VARIANT!= ${UNAME} -r +NATIVE_OS_VARIANT:= ${NATIVE_OS_VARIANT:C/^.*-//} +. if ${NATIVE_OS_VARIANT} != "Microsoft" +NATIVE_OS_VARIANT= ${NATIVE_LOWER_VENDOR} . endif +# XXX NATIVE_HOST_MACHINE_ARCH? ??? . if !defined(HOST_MACHINE_ARCH) HOST_MACHINE_ARCH!= ${UNAME} -m MAKEFLAGS+= HOST_MACHINE_ARCH=${HOST_MACHINE_ARCH:Q} . endif -.elif ${OPSYS} == "OpenBSD" -LOWER_OPSYS?= openbsd - -.elif ${OPSYS} == "OSF1" -OS_VERSION:= ${OS_VERSION:C/^V//} -LOWER_OPSYS?= osf1 -LOWER_OPSYS_VERSUFFIX?= ${OS_VERSION} -LOWER_VENDOR?= dec - -.elif ${OPSYS} == "HPUX" -OS_VERSION:= ${OS_VERSION:C/^B.//} -LOWER_OPSYS?= hpux -LOWER_OPSYS_VERSUFFIX?= ${OS_VERSION} -LOWER_VENDOR?= hp - -.elif ${OPSYS} == "SunOS" -LOWER_VENDOR?= sun -LOWER_OPSYS?= solaris -LOWER_OPSYS_VERSUFFIX= 2.${OS_VERSION:C/5.//} +.elif ${NATIVE_OPSYS} == "OpenBSD" +NATIVE_LOWER_OPSYS?= openbsd + +.elif ${NATIVE_OPSYS} == "OSF1" +NATIVE_OS_VERSION:= ${NATIVE_OS_VERSION:C/^V//} +NATIVE_LOWER_OPSYS?= osf1 +NATIVE_LOWER_OPSYS_VERSUFFIX?= ${NATIVE_OS_VERSION} +NATIVE_LOWER_VENDOR?= dec + +.elif ${NATIVE_OPSYS} == "HPUX" +NATIVE_OS_VERSION:= ${NATIVE_OS_VERSION:C/^B.//} +NATIVE_LOWER_OPSYS?= hpux +NATIVE_LOWER_OPSYS_VERSUFFIX?= ${NATIVE_OS_VERSION} +NATIVE_LOWER_VENDOR?= hp + +.elif ${NATIVE_OPSYS} == "SunOS" +NATIVE_LOWER_VENDOR?= sun +NATIVE_LOWER_OPSYS?= solaris +NATIVE_LOWER_OPSYS_VERSUFFIX= 2.${NATIVE_OS_VERSION:C/5.//} . if !defined(_UNAME_V) _UNAME_V!= ${UNAME} -v MAKEFLAGS+= _UNAME_V=${_UNAME_V:Q} . endif . if !empty(_UNAME_V:Mjoyent_*) -OS_VARIANT= SmartOS -LOWER_VARIANT_VERSION= ${_UNAME_V:C/joyent_//} +NATIVE_OS_VARIANT= SmartOS +NATIVE_LOWER_VARIANT_VERSION= ${_UNAME_V:C/joyent_//} . elif !empty(_UNAME_V:Momnios-*) -OS_VARIANT= OmniOS -LOWER_VARIANT_VERSION!= /usr/bin/awk '{ print $$3; exit 0; }' /etc/release +NATIVE_OS_VARIANT= OmniOS +NATIVE_LOWER_VARIANT_VERSION!= /usr/bin/awk '{ print $$3; exit 0; }' /etc/release . elif !empty(_UNAME_V:Mtribblix-*) -OS_VARIANT= Tribblix -LOWER_VARIANT_VERSION!= /usr/bin/awk '{ print $$2; exit 0; }' /etc/release +NATIVE_OS_VARIANT= Tribblix +NATIVE_LOWER_VARIANT_VERSION!= /usr/bin/awk '{ print $$2; exit 0; }' /etc/release . else -OS_VARIANT= Solaris -LOWER_VARIANT_VERSION= ${_UNAME_V} +NATIVE_OS_VARIANT= Solaris +NATIVE_LOWER_VARIANT_VERSION= ${_UNAME_V} . endif .elif ${OPSYS} == "SCO_SV" -SCO_RELEASE!= ${UNAME} -r -SCO_VERSION!= ${UNAME} -v -LOWER_VENDOR?= pc -LOWER_OPSYS?= sco -LOWER_OPSYS_VERSUFFIX= ${SCO_RELEASE}v${SCO_VERSION} -_UNAME_V!= ${UNAME} -v +SCO_RELEASE!= ${UNAME} -r +SCO_VERSION!= ${UNAME} -v +NATIVE_LOWER_VENDOR?= pc +NATIVE_LOWER_OPSYS?= sco +NATIVE_LOWER_OPSYS_VERSUFFIX= ${SCO_RELEASE}v${SCO_VERSION} +_UNAME_V!= ${UNAME} -v . if !empty(_UNAME_V:M5.0*) -OS_VARIANT= SCOOSR5 +NATIVE_OS_VARIANT= SCOOSR5 . elif !empty(_UNAME_V:M6.0*) -OS_VARIANT= SCOOSR6 +NATIVE_OS_VARIANT= SCOOSR6 . endif -.elif ${OPSYS} == "UnixWare" -SCO_RELEASE?= sysv5${OPSYS} -SCO_VERSION!= ${UNAME} -v -LOWER_VENDOR?= unknown -LOWER_OPSYS_VERSUFFIX= ${SCO_RELEASE}${SCO_VERSION} +.elif ${NATIVE_OPSYS} == "UnixWare" +SCO_RELEASE?= sysv5${NATIVE_OPSYS} +SCO_VERSION!= ${UNAME} -v +NATIVE_LOWER_VENDOR?= unknown +NATIVE_LOWER_OPSYS_VERSUFFIX= ${SCO_RELEASE}${SCO_VERSION} -.elif ${OPSYS} == "Minix" -LOWER_VENDOR?= unknown -LOWER_OPSYS:= ${OPSYS:tl} +.elif ${NATIVE_OPSYS} == "Minix" +NATIVE_LOWER_VENDOR?= unknown +NATIVE_LOWER_OPSYS:= ${NATIVE_OPSYS:tl} -.elif !defined(LOWER_OPSYS) -LOWER_OPSYS:= ${OPSYS:tl} +.elif !defined(NATIVE_LOWER_OPSYS) +NATIVE_LOWER_OPSYS:= ${NATIVE_OPSYS:tl} .endif # Now commit the version values computed above, eliding the :sh -OS_VERSION:= ${OS_VERSION} - -MAKEFLAGS+= LOWER_OPSYS=${LOWER_OPSYS:Q} - -LOWER_VENDOR?= # empty ("arch--opsys") - +NATIVE_OS_VERSION:= ${NATIVE_OS_VERSION} + +MAKEFLAGS+= NATIVE_LOWER_OPSYS=${NATIVE_LOWER_OPSYS:Q} + +NATIVE_LOWER_VENDOR?= # empty ("arch--opsys") + +# List of variables that must be set to determine a cross-compilation +# target. +CROSSVARS?= # empty + +# Cross-compilation target settings. +CROSSVARS+= OPSYS +OPSYS= \ + ${"${USE_CROSS_COMPILE:U:tl}" == "yes":?${CROSS_OPSYS}:${NATIVE_OPSYS}} +CROSSVARS+= OS_VERSION +OS_VERSION= \ + ${"${USE_CROSS_COMPILE:U:tl}" == "yes":?${CROSS_OS_VERSION}:${NATIVE_OS_VERSION}} +CROSSVARS+= OPSYS_VERSION +OPSYS_VERSION= \ + ${"${USE_CROSS_COMPILE:U:tl}" == "yes":?${CROSS_OPSYS_VERSION}:${NATIVE_OPSYS_VERSION}} +CROSSVARS+= LOWER_OPSYS +LOWER_OPSYS= \ + ${"${USE_CROSS_COMPILE:U:tl}" == "yes":?${CROSS_LOWER_OPSYS}:${NATIVE_LOWER_OPSYS}} +CROSSVARS+= LOWER_OPSYS_VERSUFFIX +LOWER_OPSYS_VERSUFFIX= \ + ${"${USE_CROSS_COMPILE:U:tl}" == "yes":?${CROSS_LOWER_OPSYS_VERSUFFIX}:${NATIVE_LOWER_OPSYS_VERSUFFIX}} +CROSSVARS+= LOWER_VARIANT_VERSION +LOWER_VARIANT_VERSION= \ + ${"${USE_CROSS_COMPILE:U:tl}" == "yes":?${CROSS_LOWER_VARIANT_VERSION}:${NATIVE_LOWER_VARIANT_VERSION}} +CROSSVARS+= LOWER_VENDOR +LOWER_VENDOR= \ + ${"${USE_CROSS_COMPILE:U:tl}" == "yes":?${CROSS_LOWER_VENDOR}:${NATIVE_LOWER_VENDOR}} +CROSSVARS+= LOWER_OS_VARIANT +OS_VARIANT= \ + ${"${USE_CROSS_COMPILE:U:tl}" == "yes":?${CROSS_OS_VARIANT}:${NATIVE_OS_VARIANT}} + +# Remember the MACHINE_ARCH that make was built with before we override +# it with CROSS_MACHINE_ARCH if USE_CROSS_COMPILE is enabled. +CROSSVARS+= MACHINE_ARCH NATIVE_MACHINE_ARCH:= ${MACHINE_ARCH} + NATIVE_MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${NATIVE_MACHINE_ARCH} MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${MACHINE_ARCH} -NATIVE_MACHINE_GNU_PLATFORM?= ${NATIVE_MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${NATIVE_APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}${NATIVE_APPEND_ABI} +NATIVE_MACHINE_GNU_PLATFORM?= ${NATIVE_MACHINE_GNU_ARCH}-${NATIVE_LOWER_VENDOR}-${NATIVE_LOWER_OPSYS:C/[0-9]//g}${NATIVE_APPEND_ELF}${NATIVE_LOWER_OPSYS_VERSUFFIX}${NATIVE_APPEND_ABI} MACHINE_GNU_PLATFORM?= ${MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}${APPEND_ABI} # Set this before does, since it doesn't know about Darwin -.if ${OPSYS} == "Darwin" +# We will later set OBJECT_FMT to be conditional on USE_CROSS_COMPILE. +.if ${NATIVE_OPSYS} == "Darwin" +NATIVE_OBJECT_FMT?= Mach-O OBJECT_FMT?= Mach-O .endif @@ -368,6 +405,9 @@ PKG_FAIL_REASON+= "Must set TARGET_ARCH for cross-libtool." MACHINE_ARCH:= ${TARGET_ARCH} _BUILD_DEFS.MACHINE_ARCH= ${NATIVE_MACHINE_ARCH} _BUILD_DEFS.MACHINE_GNU_ARCH= ${NATIVE_MACHINE_GNU_ARCH} +_BUILD_DEFS.OBJECT_FMT= ${NATIVE_OBJECT_FMT} +_BUILD_DEFS.OPSYS= ${NATIVE_OPSYS} +_BUILD_DEFS.OS_VERSION= ${NATIVE_OS_VERSION} TOOLS_USE_CROSS_COMPILE= yes .else TOOLS_USE_CROSS_COMPILE= ${USE_CROSS_COMPILE:Uno} @@ -389,9 +429,17 @@ PKGPATH?= ${.CURDIR:C|.*/([^/]*/[^/]*)$|\1|} # Load the settings from MAKECONF, which is /etc/mk.conf by default. .include +# Save the OBJECT_FMT determined by bsd.own.mk, and turn OBJECT_FMT +# into a cross-compilation variable so it can be overridden by +# CROSS_OBJECT_FMT. +NATIVE_OBJECT_FMT:= ${OBJECT_FMT} +CROSSVARS+= OBJECT_FMT +OBJECT_FMT= \ + ${"${USE_CROSS_COMPILE:U:tl}" == "yes":?${CROSS_OBJECT_FMT}:${NATIVE_OBJECT_FMT}} + # When cross-compilation support is requested, the following options # must be specified as well or guessable: -# - MACHINE_ARCH is set to TARGET_ARCH if set. +# - Variables like MACHINE_ARCH are set to CROSS_MACHINE_ARCH. # - CROSS_DESTDIR is guessed from MAKEOBJDIR and MACHINE_ARCH. # - PKG_DBDIR is expanded and prefixed with CROSS_DESTDIR # - DESTDIR support is required @@ -399,9 +447,16 @@ PKGPATH?= ${.CURDIR:C|.*/([^/]*/[^/]*)$|\1|} # _CROSS_DESTDIR is set for internal use to avoid conditionalising # the use. -.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) -. if defined(TARGET_ARCH) -MACHINE_ARCH= ${TARGET_ARCH} +.if ${USE_CROSS_COMPILE:U:tl} == "yes" # defaults/mk.conf not yet loaded, so :U +. for _v_ in ${CROSSVARS} +. ifndef CROSS_${_v_} +MISSING_CROSSVARS= yes +. warning Missing CROSS_${_v_} setting +. endif +${_v_}:= ${CROSS_${_v_}} +. endfor +. ifdef MISSING_CROSSVARS +. error USE_CROSS_COMPILE=yes but missing cross variable settings . endif CROSS_DESTDIR?= ${MAKEOBJDIR}/destdir.${MACHINE_ARCH} . if !exists(${CROSS_DESTDIR}/usr/include/stddef.h) @@ -562,9 +617,6 @@ TOOLS_CROSS_DESTDIR= # empty # Depends on MACHINE_ARCH override above .if ${OPSYS} == "NetBSD" -# XXX NATIVE_OBJECT_FMT is a cop-out -- but seriously, who is going to -# do cross-builds on a NetBSD host that still uses a.out? -NATIVE_OBJECT_FMT?= ${OBJECT_FMT} . if ${NATIVE_OBJECT_FMT} == "ELF" && \ (!empty(NATIVE_MACHINE_ARCH:Mearm*) || \ ${NATIVE_MACHINE_GNU_ARCH} == "arm" || \ diff --git a/mk/tools/cross.NetBSD.mk b/mk/tools/cross.NetBSD.mk new file mode 100644 index 000000000000..df739ba84035 --- /dev/null +++ b/mk/tools/cross.NetBSD.mk @@ -0,0 +1,25 @@ +# $NetBSD$ +# +# Cross-compiler toolchain for the NetBSD operating system. Requires +# TOOLDIR to match build.sh for a NetBSD build. + +TOOLS_PLATFORM.install?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install +TOOLS_PLATFORM.readelf?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-readelf +TOOLS_PLATFORM.strip?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip + +.for _t_ in ar as ld nm objcopy objdump ranlib readelf strip +TOOLS_PATH.${MACHINE_GNU_PLATFORM}-${_t_}?= \ + ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-${_t_} +TOOLS_CREATE+= ${MACHINE_GNU_PLATFORM}-${_t_} +.endfor + +TOOLS_PATH.ar?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar +TOOLS_CREATE+= ar +TOOLS_PATH.ranlib?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib +TOOLS_CREATE+= ranlib +TOOLS_PATH.readelf?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-readelf +TOOLS_CREATE+= readelf + +CC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc +CXX= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g++ +LD= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld diff --git a/mk/tools/defaults.mk b/mk/tools/defaults.mk index 5b49c4224d72..51d956f1ae81 100644 --- a/mk/tools/defaults.mk +++ b/mk/tools/defaults.mk @@ -34,10 +34,17 @@ TOOLS_DEFAULTS_MK= defined # These are the platform-specific lists of system-supplied tools. # # XXX These should eventually just migrate over to the appropriate -# XXX pkgsrc/mk/platform/${OPSYS}.mk file. +# XXX pkgsrc/mk/platform/${NATIVE_OPSYS}.mk file. # -.if exists(${_PKGSRC_TOPDIR}/mk/tools/tools.${OPSYS}.mk) -. include "${_PKGSRC_TOPDIR}/mk/tools/tools.${OPSYS}.mk" +# XXX Use ${OPSYS} for :run tools, but ${NATIVE_OPSYS} for :build and +# XXX :bootstrap tools. +# +.if ${TOOLS_USE_CROSS_COMPILE:tl} == "yes" && \ + exists(${_PKGSRC_TOPDIR}/mk/tools/cross.${OPSYS}.mk) +. include "${_PKGSRC_TOPDIR}/mk/tools/cross.${OPSYS}.mk" +.endif +.if exists(${_PKGSRC_TOPDIR}/mk/tools/tools.${NATIVE_OPSYS}.mk) +. include "${_PKGSRC_TOPDIR}/mk/tools/tools.${NATIVE_OPSYS}.mk" .endif ###################################################################### diff --git a/mk/tools/tools.NetBSD.mk b/mk/tools/tools.NetBSD.mk index 2d4de5afe264..387367f36531 100644 --- a/mk/tools/tools.NetBSD.mk +++ b/mk/tools/tools.NetBSD.mk @@ -58,11 +58,7 @@ TOOLS_PLATFORM.head?= /usr/bin/head TOOLS_PLATFORM.hostname?= /bin/hostname TOOLS_PLATFORM.id?= /usr/bin/id TOOLS_PLATFORM.ident?= /usr/bin/ident -.if ${TOOLS_USE_CROSS_COMPILE:tl} != yes TOOLS_PLATFORM.install?= /usr/bin/install -.else -TOOLS_PLATFORM.install?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install -.endif .if exists(/usr/bin/install-info) TOOLS_PLATFORM.install-info?= /usr/bin/install-info .endif @@ -102,11 +98,7 @@ TOOLS_PLATFORM.paxctl?= /usr/sbin/paxctl .endif TOOLS_PLATFORM.printf?= /usr/bin/printf TOOLS_PLATFORM.pwd?= /bin/pwd -.if ${TOOLS_USE_CROSS_COMPILE:U:tl} != yes TOOLS_PLATFORM.readelf?= /usr/bin/readelf -.else -TOOLS_PLATFORM.readelf?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-readelf -.endif TOOLS_PLATFORM.readlink?= /usr/bin/readlink .if exists(/usr/bin/realpath) TOOLS_PLATFORM.realpath?= /usr/bin/realpath @@ -120,11 +112,7 @@ TOOLS_PLATFORM.shlock?= /usr/bin/shlock TOOLS_PLATFORM.sleep?= /bin/sleep TOOLS_PLATFORM.soelim?= /usr/bin/soelim TOOLS_PLATFORM.sort?= /usr/bin/sort -.if ${TOOLS_USE_CROSS_COMPILE:U:tl} != yes TOOLS_PLATFORM.strip?= /usr/bin/strip -.else -TOOLS_PLATFORM.strip?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip -.endif TOOLS_PLATFORM.tail?= /usr/bin/tail .if exists(/bin/tar) @@ -157,29 +145,9 @@ TOOLS_PLATFORM.xzcat?= /usr/bin/xzcat TOOLS_PLATFORM.yacc?= /usr/bin/yacc .if ${TOOLS_USE_CROSS_COMPILE:U:tl} == yes -. for _t_ in ar as ld nm objcopy objdump ranlib readelf strip -TOOLS_PATH.${MACHINE_GNU_PLATFORM}-${_t_}?= \ - ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-${_t_} -TOOLS_CREATE+= ${MACHINE_GNU_PLATFORM}-${_t_} -. endfor - -TOOLS_PATH.ar?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar -TOOLS_CREATE+= ar -TOOLS_PATH.ranlib?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib -TOOLS_CREATE+= ranlib -TOOLS_PATH.readelf?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-readelf -TOOLS_CREATE+= readelf - NATIVE_CC:= /usr/bin/cc -B /usr/libexec -B /usr/bin -CC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc - NATIVE_CXX:= /usr/bin/c++ -B /usr/libexec -B /usr/bin -CXX= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g++ - NATIVE_LD:= /usr/bin/ld -LD= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld - NATIVE_AR:= /usr/bin/ar NATIVE_RANLIB:= /usr/bin/ranlib - .endif From 52009a1f8beab24048212f472425865914b590d0 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 28 Jun 2023 23:53:26 +0000 Subject: [PATCH 13/27] mk: Pass through all CROSSVARS as TARGET_* for tool depends. Use this for cross-libtool-base. Name it cross-libtool-base-${MACHINE_PLATFORM} instead of cross-libtool-base-${MACHINE_ARCH}. MACHINE_GNU_PLATFORM isn't quite enough, because it doesn't reflect OS versions (e.g., aarch64--netbsd covers both NetBSD 9 and NetBSD 10). No functional change intended in native builds -- everything here is conditional on cross builds. The _DEPENDS_INSTALL_CMD shell fragment is changed in native builds, but only to move around some of the shell-based cross-build fragments (which could maybe be factored out to save a bit of shell execution in native builds, but that's for another day). XXX MACHINE_PLATFORM doesn't cover all the other little exotic OS knobs like LOWER_OPSYS_VERSUFFIX. Do we care? --- cross/cross-libtool-base/Makefile | 13 ++-- cross/cross-libtool-base/PLIST | 108 +++++++++++++++--------------- doc/HOWTO-dev-crosscompile | 46 +++++++------ mk/bsd.pkg.use.mk | 6 +- mk/bsd.prefs.mk | 42 ++++++++++-- mk/pkgformat/pkg/depends.mk | 18 +++-- 6 files changed, 138 insertions(+), 95 deletions(-) diff --git a/cross/cross-libtool-base/Makefile b/cross/cross-libtool-base/Makefile index c2b4abedd693..4fbeb7a2c165 100644 --- a/cross/cross-libtool-base/Makefile +++ b/cross/cross-libtool-base/Makefile @@ -37,7 +37,7 @@ LIBTOOL_CROSS_COMPILE= yes # XXX Tweaked for cross-compilation. #PKGNAME= ${DISTNAME:S/-/-base-/} -PKGNAME= ${DISTNAME:S/^libtool-/cross-libtool-base-${MACHINE_ARCH}-/} +PKGNAME= ${DISTNAME:S/^libtool-/cross-libtool-base-${MACHINE_PLATFORM}-/} PKGREVISION= 8 COMMENT= Generic shared library support script (the script itself) @@ -64,10 +64,11 @@ CFLAGS.SunOS+= ${_COMPILER_ABI_FLAG.${ABI}} # and Fortran compilers. # USE_LANGUAGES= c c++ -# XXX Added for cross-compilation. XXX Should be ${TARGET_ARCH}, but -# currently we have to fake-cross-compile libtool because it's broken -# upstream. -GNU_CONFIGURE_PREFIX= ${PREFIX}/cross-${MACHINE_ARCH} +# XXX Added for cross-compilation. XXX Should be +# ${TARGET_MACHINE_PLATFORM}, but currently we have to +# fake-cross-compile libtool because it's broken upstream. +GNU_CONFIGURE_PREFIX= ${PREFIX}/cross-${MACHINE_PLATFORM} +PLIST_SUBST+= MACHINE_PLATFORM=${MACHINE_PLATFORM:Q} CONFIGURE_ARGS+= --disable-ltdl-install CONFIGURE_ARGS+= F77=no FC=no @@ -96,7 +97,7 @@ post-build: ${FILESDIR}/shlibtool.in > ${WRKSRC}/shlibtool post-install: - ${INSTALL_SCRIPT} ${WRKSRC}/shlibtool ${DESTDIR}${PREFIX}/cross-${MACHINE_ARCH}/bin/shlibtool + ${INSTALL_SCRIPT} ${WRKSRC}/shlibtool ${DESTDIR}${PREFIX}/cross-${MACHINE_PLATFORM}/bin/shlibtool BUILDLINK_DEPMETHOD.dlcompat= build diff --git a/cross/cross-libtool-base/PLIST b/cross/cross-libtool-base/PLIST index a1db9768dde3..c78dfac0fcb5 100644 --- a/cross/cross-libtool-base/PLIST +++ b/cross/cross-libtool-base/PLIST @@ -1,55 +1,55 @@ @comment $NetBSD: PLIST,v 1.3 2019/07/09 15:45:25 riastradh Exp $ -cross-${MACHINE_ARCH}/bin/libtool -cross-${MACHINE_ARCH}/bin/libtoolize -cross-${MACHINE_ARCH}/bin/shlibtool -cross-${MACHINE_ARCH}/man/man1/libtool.1 -cross-${MACHINE_ARCH}/man/man1/libtoolize.1 -cross-${MACHINE_ARCH}/share/aclocal/libtool.m4 -cross-${MACHINE_ARCH}/share/aclocal/ltargz.m4 -cross-${MACHINE_ARCH}/share/aclocal/ltdl.m4 -cross-${MACHINE_ARCH}/share/aclocal/ltoptions.m4 -cross-${MACHINE_ARCH}/share/aclocal/ltsugar.m4 -cross-${MACHINE_ARCH}/share/aclocal/ltversion.m4 -cross-${MACHINE_ARCH}/share/aclocal/lt~obsolete.m4 -cross-${MACHINE_ARCH}/share/libtool/COPYING.LIB -cross-${MACHINE_ARCH}/share/libtool/Makefile.am -cross-${MACHINE_ARCH}/share/libtool/Makefile.in -cross-${MACHINE_ARCH}/share/libtool/README -cross-${MACHINE_ARCH}/share/libtool/aclocal.m4 -cross-${MACHINE_ARCH}/share/libtool/build-aux/compile -cross-${MACHINE_ARCH}/share/libtool/build-aux/config.guess -cross-${MACHINE_ARCH}/share/libtool/build-aux/config.sub -cross-${MACHINE_ARCH}/share/libtool/build-aux/depcomp -cross-${MACHINE_ARCH}/share/libtool/build-aux/install-sh -cross-${MACHINE_ARCH}/share/libtool/build-aux/ltmain.sh -cross-${MACHINE_ARCH}/share/libtool/build-aux/missing -cross-${MACHINE_ARCH}/share/libtool/config-h.in -cross-${MACHINE_ARCH}/share/libtool/configure -cross-${MACHINE_ARCH}/share/libtool/configure.ac -cross-${MACHINE_ARCH}/share/libtool/libltdl/lt__alloc.h -cross-${MACHINE_ARCH}/share/libtool/libltdl/lt__argz_.h -cross-${MACHINE_ARCH}/share/libtool/libltdl/lt__dirent.h -cross-${MACHINE_ARCH}/share/libtool/libltdl/lt__glibc.h -cross-${MACHINE_ARCH}/share/libtool/libltdl/lt__private.h -cross-${MACHINE_ARCH}/share/libtool/libltdl/lt__strl.h -cross-${MACHINE_ARCH}/share/libtool/libltdl/lt_dlloader.h -cross-${MACHINE_ARCH}/share/libtool/libltdl/lt_error.h -cross-${MACHINE_ARCH}/share/libtool/libltdl/lt_system.h -cross-${MACHINE_ARCH}/share/libtool/libltdl/slist.h -cross-${MACHINE_ARCH}/share/libtool/loaders/dld_link.c -cross-${MACHINE_ARCH}/share/libtool/loaders/dlopen.c -cross-${MACHINE_ARCH}/share/libtool/loaders/dyld.c -cross-${MACHINE_ARCH}/share/libtool/loaders/load_add_on.c -cross-${MACHINE_ARCH}/share/libtool/loaders/loadlibrary.c -cross-${MACHINE_ARCH}/share/libtool/loaders/preopen.c -cross-${MACHINE_ARCH}/share/libtool/loaders/shl_load.c -cross-${MACHINE_ARCH}/share/libtool/lt__alloc.c -cross-${MACHINE_ARCH}/share/libtool/lt__argz.c -cross-${MACHINE_ARCH}/share/libtool/lt__dirent.c -cross-${MACHINE_ARCH}/share/libtool/lt__strl.c -cross-${MACHINE_ARCH}/share/libtool/lt_dlloader.c -cross-${MACHINE_ARCH}/share/libtool/lt_error.c -cross-${MACHINE_ARCH}/share/libtool/ltdl.c -cross-${MACHINE_ARCH}/share/libtool/ltdl.h -cross-${MACHINE_ARCH}/share/libtool/ltdl.mk -cross-${MACHINE_ARCH}/share/libtool/slist.c +cross-${MACHINE_PLATFORM}/bin/libtool +cross-${MACHINE_PLATFORM}/bin/libtoolize +cross-${MACHINE_PLATFORM}/bin/shlibtool +cross-${MACHINE_PLATFORM}/man/man1/libtool.1 +cross-${MACHINE_PLATFORM}/man/man1/libtoolize.1 +cross-${MACHINE_PLATFORM}/share/aclocal/libtool.m4 +cross-${MACHINE_PLATFORM}/share/aclocal/ltargz.m4 +cross-${MACHINE_PLATFORM}/share/aclocal/ltdl.m4 +cross-${MACHINE_PLATFORM}/share/aclocal/ltoptions.m4 +cross-${MACHINE_PLATFORM}/share/aclocal/ltsugar.m4 +cross-${MACHINE_PLATFORM}/share/aclocal/ltversion.m4 +cross-${MACHINE_PLATFORM}/share/aclocal/lt~obsolete.m4 +cross-${MACHINE_PLATFORM}/share/libtool/COPYING.LIB +cross-${MACHINE_PLATFORM}/share/libtool/Makefile.am +cross-${MACHINE_PLATFORM}/share/libtool/Makefile.in +cross-${MACHINE_PLATFORM}/share/libtool/README +cross-${MACHINE_PLATFORM}/share/libtool/aclocal.m4 +cross-${MACHINE_PLATFORM}/share/libtool/build-aux/compile +cross-${MACHINE_PLATFORM}/share/libtool/build-aux/config.guess +cross-${MACHINE_PLATFORM}/share/libtool/build-aux/config.sub +cross-${MACHINE_PLATFORM}/share/libtool/build-aux/depcomp +cross-${MACHINE_PLATFORM}/share/libtool/build-aux/install-sh +cross-${MACHINE_PLATFORM}/share/libtool/build-aux/ltmain.sh +cross-${MACHINE_PLATFORM}/share/libtool/build-aux/missing +cross-${MACHINE_PLATFORM}/share/libtool/config-h.in +cross-${MACHINE_PLATFORM}/share/libtool/configure +cross-${MACHINE_PLATFORM}/share/libtool/configure.ac +cross-${MACHINE_PLATFORM}/share/libtool/libltdl/lt__alloc.h +cross-${MACHINE_PLATFORM}/share/libtool/libltdl/lt__argz_.h +cross-${MACHINE_PLATFORM}/share/libtool/libltdl/lt__dirent.h +cross-${MACHINE_PLATFORM}/share/libtool/libltdl/lt__glibc.h +cross-${MACHINE_PLATFORM}/share/libtool/libltdl/lt__private.h +cross-${MACHINE_PLATFORM}/share/libtool/libltdl/lt__strl.h +cross-${MACHINE_PLATFORM}/share/libtool/libltdl/lt_dlloader.h +cross-${MACHINE_PLATFORM}/share/libtool/libltdl/lt_error.h +cross-${MACHINE_PLATFORM}/share/libtool/libltdl/lt_system.h +cross-${MACHINE_PLATFORM}/share/libtool/libltdl/slist.h +cross-${MACHINE_PLATFORM}/share/libtool/loaders/dld_link.c +cross-${MACHINE_PLATFORM}/share/libtool/loaders/dlopen.c +cross-${MACHINE_PLATFORM}/share/libtool/loaders/dyld.c +cross-${MACHINE_PLATFORM}/share/libtool/loaders/load_add_on.c +cross-${MACHINE_PLATFORM}/share/libtool/loaders/loadlibrary.c +cross-${MACHINE_PLATFORM}/share/libtool/loaders/preopen.c +cross-${MACHINE_PLATFORM}/share/libtool/loaders/shl_load.c +cross-${MACHINE_PLATFORM}/share/libtool/lt__alloc.c +cross-${MACHINE_PLATFORM}/share/libtool/lt__argz.c +cross-${MACHINE_PLATFORM}/share/libtool/lt__dirent.c +cross-${MACHINE_PLATFORM}/share/libtool/lt__strl.c +cross-${MACHINE_PLATFORM}/share/libtool/lt_dlloader.c +cross-${MACHINE_PLATFORM}/share/libtool/lt_error.c +cross-${MACHINE_PLATFORM}/share/libtool/ltdl.c +cross-${MACHINE_PLATFORM}/share/libtool/ltdl.h +cross-${MACHINE_PLATFORM}/share/libtool/ltdl.mk +cross-${MACHINE_PLATFORM}/share/libtool/slist.c diff --git a/doc/HOWTO-dev-crosscompile b/doc/HOWTO-dev-crosscompile index e1cbd3c57f69..1de740a04eee 100644 --- a/doc/HOWTO-dev-crosscompile +++ b/doc/HOWTO-dev-crosscompile @@ -11,34 +11,42 @@ have ever thought of cross-compilation. * Native and target platform -When building a package, MACHINE_ARCH, MACHINE_GNU_PLATFORM, &c., -describe the platform for which the package is being built. If +When building a package, MACHINE_ARCH, OPSYS, &c., describe the +platform for which the package is being built. If USE_CROSS_COMPILE=no, this is the native platform; otherwise, if -USE_CROSS_COMPILE=yes, it is the target platform, and the additional -variables NATIVE_MACHINE_ARCH, NATIVE_MACHINE_GNU_PLATFORM, &c., -describe the native platform. +USE_CROSS_COMPILE=yes, it is the target platform. The additional +variables NATIVE_MACHINE_ARCH, NATIVE_OPSYS, &c., always describe the +native platform. When building a native package for cross-compilation, such as a -compiler for the target, the variable TARGET_ARCH describes the target -platform like MACHINE_ARCH. If the build product varies with the -choice of target, then TARGET_ARCH should be embedded into the PKGNAME +compiler for the target, the variables TARGET_MACHINE_ARCH, +TARGET_OPSYS, &c., describe the target platform. If the build product +varies with the choice of target, then TARGET_MACHINE_ARCH or +TARGET_OPSYS or whatever affects it should be embedded into the PKGNAME somewhere so that the different build products are distinguished by having different package names. -XXX This pattern is incompletely realized. We should probably replace -TARGET_ARCH by TARGET_MACHINE_ARCH, TARGET_MACHINE_GNU_PLATFORM, &c., -and perhaps decide which of those is the main switch that you set when -you want to select cross-compilation. Ideally, this switch should -also support cross-compilation to other operating systems. +XXX Missing: +XXX - TARGET_MACHINE_GNU_PLATFORM +XXX - TARGET_MACHINE_GNU_ARCH +XXX - probably other variables defined in terms of the CROSSVARS * Specifying the toolchain -Software built following GNU conventions can set GNU_CONFIGURE=yes so -that pkgsrc will automatically specify the right --build, --host, and ---target options for cross-compilation and point everything at the -right toolchain. +The following build systems should automagically handle +cross-compilation by passing through the architecture and OS +information: -XXX And software not built following GNU conventions...? +- GNU_CONFIGURE=yes +- .include "../../devel/meson/build.mk" (sets +- .include "../../devel/cmake/build.mk" (and legacy USE_CMAKE=yes) + +Additional tweaks are sometimes needed (but not always), conditional on +${USE_CROSS_COMPILE:tl} == "yes" (after including bsd.prefs.mk): + +- (pkg-config) ALL_ENV+= PKG_CONFIG_SYSROOT_DIR=${CROSS_DESTDIR:Q} +- (pkg-config) ALL_ENV+= PKG_CONFIG_FDO_SYSROOT_RULES=1 +- (cmake) CMAKE_ARGS+= -DCMAKE_SYSROOT:STRING=${CROSS_DESTDIR:Q} * Tool dependencies @@ -107,7 +115,7 @@ pre-answer the tests for autoconf: .include "../../bsd.prefs.mk" -.if ${USE_CROSS_COMPILE:U:tl} == "yes" +.if ${USE_CROSS_COMPILE:tl} == "yes" # Configure wants to check for /dev/random but can't. We know NetBSD # always has a /dev/random, so inform autoconf of the fact. CONFIGURE_ENV.NetBSD+= ac_cv_file__dev_random=yes diff --git a/mk/bsd.pkg.use.mk b/mk/bsd.pkg.use.mk index 03ee7cbf1323..30728ebc4bf7 100644 --- a/mk/bsd.pkg.use.mk +++ b/mk/bsd.pkg.use.mk @@ -91,8 +91,8 @@ TOOL_DEPENDS+= libtool-fortran>=${_OPSYS_LIBTOOL_REQD:U${LIBTOOL_REQD}}:../../d . endif .else . if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) -PKG_LIBTOOL?= ${TOOLBASE}/cross-${TARGET_ARCH:U${MACHINE_ARCH}}/bin/libtool -PKG_SHLIBTOOL?= ${TOOLBASE}/cross-${TARGET_ARCH:U${MACHINE_ARCH}}/bin/shlibtool +PKG_LIBTOOL?= ${TOOLBASE}/cross-${TARGET_MACHINE_PLATFORM:U${MACHINE_PLATFORM}}/bin/libtool +PKG_SHLIBTOOL?= ${TOOLBASE}/cross-${TARGET_MACHINE_PLATFORM:U${MACHINE_PLATFORM}}/bin/shlibtool . else PKG_LIBTOOL?= ${TOOLBASE}/bin/libtool PKG_SHLIBTOOL?= ${TOOLBASE}/bin/shlibtool @@ -103,7 +103,7 @@ SHLIBTOOL?= ${WRAPPER_BINDIR}/shlibtool .if defined(USE_LIBTOOL) LIBTOOL_REQD?= 2.4.2nb9 .if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) -TOOL_DEPENDS+= cross-libtool-base-${MACHINE_ARCH}>=${_OPSYS_LIBTOOL_REQD:U${LIBTOOL_REQD}}:../../cross/cross-libtool-base +TOOL_DEPENDS+= cross-libtool-base-${MACHINE_PLATFORM}>=${_OPSYS_LIBTOOL_REQD:U${LIBTOOL_REQD}}:../../cross/cross-libtool-base .else TOOL_DEPENDS+= libtool-base>=${_OPSYS_LIBTOOL_REQD:U${LIBTOOL_REQD}}:../../devel/libtool-base .endif diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk index 47be8aee8479..a1372eef505d 100644 --- a/mk/bsd.prefs.mk +++ b/mk/bsd.prefs.mk @@ -376,6 +376,12 @@ MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${MACHINE_ARCH} NATIVE_MACHINE_GNU_PLATFORM?= ${NATIVE_MACHINE_GNU_ARCH}-${NATIVE_LOWER_VENDOR}-${NATIVE_LOWER_OPSYS:C/[0-9]//g}${NATIVE_APPEND_ELF}${NATIVE_LOWER_OPSYS_VERSUFFIX}${NATIVE_APPEND_ABI} MACHINE_GNU_PLATFORM?= ${MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}${APPEND_ABI} +.ifdef TARGET_MACHINE_ARCH +TARGET_MACHINE_GNU_ARCH= ${GNU_ARCH.${TARGET_MACHINE_ARCH}:U${TARGET_MACHINE_ARCH}} +TARGET_MACHINE_GNU_PLATFORM= ${TARGET_MACHINE_GNU_ARCH}-${TARGET_LOWER_VENDOR}-${TARGET_LOWER_OPSYS:C/[0-9]//g}${TARGET_APPEND_ELF}${TARGET_LOWER_OPSYS_VERSUFFIX}${TARGET_APPEND_ABI} +TARGET_MACHINE_PLATFORM= ${TARGET_OPSYS}-${TARGET_OS_VERSION}-${TARGET_MACHINE_ARCH} +.endif + # Set this before does, since it doesn't know about Darwin # We will later set OBJECT_FMT to be conditional on USE_CROSS_COMPILE. .if ${NATIVE_OPSYS} == "Darwin" @@ -394,15 +400,18 @@ OBJECT_FMT?= Mach-O # the rest of the native package build with USE_CROSS_COMPILE=no. # # This can't live inside the cross-libtool makefile because the -# TARGET_ARCH / MACHINE_ARCH / NATIVE_MACHINE_ARCH switcheroo has to -# happen in the middle of this file -- after NATIVE_MACHINE_ARCH is -# determined, before MACHINE_ARCH is used for anything else. +# TARGET_MACHINE_ARCH / MACHINE_ARCH / NATIVE_MACHINE_ARCH switcheroo +# has to happen in the middle of this file -- after NATIVE_MACHINE_ARCH +# is determined, before MACHINE_ARCH is used for anything else. # -.if !empty(LIBTOOL_CROSS_COMPILE:M[yY][eE][sS]) -. if !defined(TARGET_ARCH) -PKG_FAIL_REASON+= "Must set TARGET_ARCH for cross-libtool." +.if ${LIBTOOL_CROSS_COMPILE:U:tl} == "yes" +. if !defined(TARGET_MACHINE_ARCH) +PKG_FAIL_REASON+= "Must set TARGET_MACHINE_ARCH for cross-libtool." . endif -MACHINE_ARCH:= ${TARGET_ARCH} +. for _v_ in ${CROSSVARS} +${_v_}= ${TARGET_${_v_}} +. endfor +# XXX Other CROSSVARS for _BUILD_DEFS? _BUILD_DEFS.MACHINE_ARCH= ${NATIVE_MACHINE_ARCH} _BUILD_DEFS.MACHINE_GNU_ARCH= ${NATIVE_MACHINE_GNU_ARCH} _BUILD_DEFS.OBJECT_FMT= ${NATIVE_OBJECT_FMT} @@ -617,6 +626,9 @@ TOOLS_CROSS_DESTDIR= # empty # Depends on MACHINE_ARCH override above .if ${OPSYS} == "NetBSD" +. ifdef TARGET_MACHINE_ARCH +TARGET_OBJECT_FMT?= ${OBJECT_FMT} # XXX +. endif . if ${NATIVE_OBJECT_FMT} == "ELF" && \ (!empty(NATIVE_MACHINE_ARCH:Mearm*) || \ ${NATIVE_MACHINE_GNU_ARCH} == "arm" || \ @@ -641,12 +653,28 @@ NATIVE_APPEND_ELF= elf ${MACHINE_ARCH} == "vax") APPEND_ELF= elf . endif +. if defined(TARGET_MACHINE_ARCH) && \ + ${TARGET_OBJECT_FMT} == "ELF" && \ + (!empty(TARGET_MACHINE_ARCH:Mearm*) || \ + ${TARGET_MACHINE_GNU_ARCH} == "arm" || \ + ${TARGET_MACHINE_ARCH} == "i386" || \ + ${TARGET_MACHINE_ARCH} == "m68k" || \ + ${TARGET_MACHINE_ARCH} == "m68000" || \ + ${TARGET_MACHINE_GNU_ARCH} == "sh" || \ + ${TARGET_MACHINE_GNU_ARCH} == "shle" || \ + ${TARGET_MACHINE_ARCH} == "sparc" || \ + ${TARGET_MACHINE_ARCH} == "vax") +TARGET_APPEND_ELF= elf +. endif . if !empty(NATIVE_MACHINE_ARCH:Mearm*) NATIVE_APPEND_ABI= -${NATIVE_MACHINE_ARCH:C/eb//:C/v[4-7]//:S/earm/eabi/} . endif . if !empty(MACHINE_ARCH:Mearm*) APPEND_ABI= -${MACHINE_ARCH:C/eb//:C/v[4-7]//:S/earm/eabi/} . endif +. if !empty(TARGET_MACHINE_ARCH:Mearm*) +TARGET_APPEND_ABI= -${TARGET_MACHINE_ARCH:C/eb//:C/v[4-7]//:S/earm/eabi/} +. endif .endif # if the system is IPv6-ready, compile with IPv6 support turned on. diff --git a/mk/pkgformat/pkg/depends.mk b/mk/pkgformat/pkg/depends.mk index ed4674e63279..57b873186116 100644 --- a/mk/pkgformat/pkg/depends.mk +++ b/mk/pkgformat/pkg/depends.mk @@ -90,6 +90,8 @@ _RESOLVE_DEPENDS_CMD= \ " "${BUILD_DEPENDS:Q} \ " "${DEPENDS:Q} +CROSSTARGETSETTINGS= ${CROSSVARS:@_v_@TARGET_${_v_}=${${_v_}}@} + # _DEPENDS_INSTALL_CMD checks whether the package $pattern is installed, # and installs it if necessary. # @@ -110,17 +112,20 @@ _DEPENDS_INSTALL_CMD= \ case $$type in \ bootstrap|tool) \ case "${USE_CROSS_COMPILE:Uno:tl}" in \ - yes) extradep="" ;; \ - *) extradep=" ${PKGNAME}" ;; \ + yes) extradep=""; \ + crosstargetsettings=${CROSSTARGETSETTINGS:Q}; \ + ;; \ + *) extradep=" ${PKGNAME}"; \ + crosstargetsettings=; \ + ;; \ esac; \ cross=no; \ - archopt=TARGET_ARCH=${MACHINE_ARCH}; \ pkg=`${_HOST_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`; \ ;; \ - build|test|full) \ + build|test|full) \ extradep=" ${PKGNAME}"; \ + crosstargetsettings=; \ cross=${USE_CROSS_COMPILE:Uno}; \ - archopt=; \ pkg=`${_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`; \ ;; \ esac; \ @@ -133,11 +138,12 @@ _DEPENDS_INSTALL_CMD= \ cd $$dir; \ unset _PKGSRC_BARRIER; \ unset MAKEFLAGS; \ + unset ${CROSSVARS:@_v_@TARGET_${_v_}@}; \ ${PKGSRC_SETENV} ${PKGSRC_MAKE_ENV} PATH=${_PATH_ORIG:Q}\ _PKGSRC_DEPS="$$extradep${_PKGSRC_DEPS}" \ PKGNAME_REQD="$$pattern" \ USE_CROSS_COMPILE=$$cross \ - $$archopt \ + $$crosstargetsettings \ ${MAKE} ${MAKEFLAGS} _AUTOMATIC=yes $$target; \ case $$type in \ bootstrap|tool) \ From 026167ef3d8a6633c1d14b52a11106b87ead14e2 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 29 Jun 2023 00:38:40 +0000 Subject: [PATCH 14/27] mk/configure/gnu-configure.mk: Set --target too if requested. No change to existing builds because nothing sets USE_GNU_CONFIGURE_TARGET yet. --- mk/configure/gnu-configure.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mk/configure/gnu-configure.mk b/mk/configure/gnu-configure.mk index 4a1ab41ba888..d13d3461ff0b 100644 --- a/mk/configure/gnu-configure.mk +++ b/mk/configure/gnu-configure.mk @@ -40,7 +40,7 @@ _PKG_VARS.gnu-configure= \ GNU_CONFIGURE_LIBDIR GNU_CONFIGURE_INFODIR GNU_CONFIGURE_MANDIR \ CONFIGURE_HAS_LIBDIR CONFIGURE_HAS_MANDIR CONFIGURE_HAS_INFODIR \ OVERRIDE_DIRDEPTH.configure \ - USE_GNU_CONFIGURE_HOST + USE_GNU_CONFIGURE_HOST USE_GNU_CONFIGURE_TARGET HAS_CONFIGURE= defined OVERRIDE_GNU_CONFIG_SCRIPTS= defined @@ -85,6 +85,7 @@ CONFIGURE_ARGS+= --libdir=${GNU_CONFIGURE_LIBDIR} .endif USE_GNU_CONFIGURE_HOST?= yes +USE_GNU_CONFIGURE_TARGET?= no # enable for toolchain packages .if !empty(USE_GNU_CONFIGURE_HOST:M[yY][eE][sS]) . if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS]) CONFIGURE_ARGS+= --build=${NATIVE_MACHINE_GNU_PLATFORM:Q} @@ -92,6 +93,9 @@ CONFIGURE_ARGS+= --build=${NATIVE_MACHINE_GNU_PLATFORM:Q} CONFIGURE_ARGS+= --build=${MACHINE_GNU_PLATFORM:Q} . endif CONFIGURE_ARGS+= --host=${MACHINE_GNU_PLATFORM:Q} +. if ${USE_GNU_CONFIGURE_TARGET:tl} == "yes" +CONFIGURE_ARGS+= --target=${TARGET_MACHINE_GNU_PLATFORM:Q} +. endif .endif # PKGINFODIR is the subdirectory of ${PREFIX} into which the info From 283d20208059968bb60758c4bc24801eb9071f39 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 29 Jun 2023 01:24:05 +0000 Subject: [PATCH 15/27] mk: Use MACHINE_PLATFORM, not MACHINE_ARCH, for work/packages. Fix bogus default PACKAGES setting -- this was shadowed by the one in mk/defaults/mk.conf, so it never took effect. No change to native builds because this logic is conditional on USE_CROSS_COMPILE = yes. --- mk/bsd.prefs.mk | 6 ++---- mk/defaults/mk.conf | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk index a1372eef505d..2bf979820a4e 100644 --- a/mk/bsd.prefs.mk +++ b/mk/bsd.prefs.mk @@ -811,12 +811,10 @@ MAKEFLAGS+= _PKGSRCDIR=${_PKGSRCDIR:Q} .endif PKGSRCDIR= ${_PKGSRCDIR} -.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) -_CROSSDIR_SUFFIX= .${MACHINE_ARCH} +.if ${USE_CROSS_COMPILE:tl} == "yes" +_CROSSDIR_SUFFIX= .${MACHINE_PLATFORM} .endif -DISTDIR?= ${PKGSRCDIR}/distfiles -PACKAGES?= ${PKGSRCDIR}/packages${_CROSSDIR_SUFFIX} TEMPLATES?= ${PKGSRCDIR}/templates PATCHDIR?= ${.CURDIR}/patches diff --git a/mk/defaults/mk.conf b/mk/defaults/mk.conf index ff620ee298b5..88207049159b 100644 --- a/mk/defaults/mk.conf +++ b/mk/defaults/mk.conf @@ -524,10 +524,11 @@ RCD_SCRIPTS_DIR?= ${SYSCONFBASE}/rc.d # Possible: any path you like # Default: ${SYSCONFBASE}/rc.d -PACKAGES?= ${PKGSRCDIR}/packages +PACKAGES?= ${PKGSRCDIR}/packages${${USE_CROSS_COMPILE:tl} == "yes":?.${MACHINE_PLATFORM}:} # Stores generated packages # Possible: any path you like -# Default: ${PKGSRCDIR}/packages +# Default: ${PKGSRCDIR}/packages, or ${PKGSRCDIR}/packages.${MACHINE_PLATFORM} +# if cross-compiling. #PASSIVE_FETCH= # Use ftp(1) in passive mode, for use behind filtering firewalls. From f8b746390ed350827814972ce0edba49d00e96c6 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 00:24:31 +0000 Subject: [PATCH 16/27] mk/pkgformat/pkg: Handle OBJECT_FMT mismatch in cross builds. No change to native builds because OBJECT_FMT = NATIVE_OBJECT_FMT in native builds. --- mk/pkgformat/pkg/depends.mk | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mk/pkgformat/pkg/depends.mk b/mk/pkgformat/pkg/depends.mk index 57b873186116..fe5b0f74914d 100644 --- a/mk/pkgformat/pkg/depends.mk +++ b/mk/pkgformat/pkg/depends.mk @@ -162,16 +162,18 @@ _DEPENDS_INSTALL_CMD= \ *) \ case $$type in \ bootstrap|tool) \ - objfmt=`${HOST_PKG_INFO} -Q OBJECT_FMT "$$pkg"`;; \ + objfmt=`${HOST_PKG_INFO} -Q OBJECT_FMT "$$pkg"`; \ + needobjfmt=${NATIVE_OBJECT_FMT:Q};; \ build|test|full) \ - objfmt=`${PKG_INFO} -Q OBJECT_FMT "$$pkg"`;; \ + objfmt=`${PKG_INFO} -Q OBJECT_FMT "$$pkg"`; \ + needobjfmt=${OBJECT_FMT:Q};; \ esac; \ case "$$objfmt" in \ "") ${WARNING_MSG} "[depends.mk] Unknown object format for installed package $$pkg" ;; \ - ${OBJECT_FMT}) ;; \ + $$needobjfmt) ;; \ *) ${ERROR_MSG} "[depends.mk] Installed package $$pkg has an"; \ - ${ERROR_MSG} " object format \`\`$$objfmt'' which differs from \`\`${OBJECT_FMT}''. Please"; \ - ${ERROR_MSG} " update the $$pkg package to ${OBJECT_FMT}."; \ + ${ERROR_MSG} " object format \`\`$$objfmt'' which differs from \`\`$$needobjfmt''. Please"; \ + ${ERROR_MSG} " update the $$pkg package to $$needobjfmt."; \ exit 1; \ ;; \ esac; \ From 875d4e58e31a4e2afd03581a9e5c5bc420824c05 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 00:24:47 +0000 Subject: [PATCH 17/27] mk/tools: Prohibit USE_TOOLS+=foo:run in cross-built packages. This just doesn't work yet, sorry! Makes the problem easier to identify up front. Eventually, these cases need to be converted to use TOOL_DEPENDS, but we also need to be able to split native and cross `tools' here. No change to native builds because the new failure is conditional on USE_CROSS_COMPILE = yes (and OPSYS != NATIVE_OPSYS). XXX Should also check for OS_VERSION != NATIVE_OS_VERSION, &c. --- mk/tools/replace.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mk/tools/replace.mk b/mk/tools/replace.mk index 133ad8ed54f4..25c1591f8450 100644 --- a/mk/tools/replace.mk +++ b/mk/tools/replace.mk @@ -133,6 +133,9 @@ _TOOLS_DEPMETHOD.${_t_:C/:.*//}= BOOTSTRAP_DEPENDS _TOOLS_DEPMETHOD.${_t_:C/:.*//}= TOOL_DEPENDS .endfor .for _t_ in ${USE_TOOLS:M*\:run} +. if ${USE_CROSS_COMPILE:tl} == "yes" && ${OPSYS} != ${NATIVE_OPSYS} +PKG_FAIL_REASON+= "USE_TOOLS+=${_t_} not supported in cross-compilation" +. endif _TOOLS_DEPMETHOD.${_t_:C/:.*//}= DEPENDS .endfor .for _t_ in ${USE_TOOLS:M*\:test} From a7ade210c3f2065b2ac62b0c68095e8aef2fc5f1 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 00:45:11 +0000 Subject: [PATCH 18/27] bsd.prefs.mk: New CROSS_VARBASE and CROSS_SYSCONFBASE. These default to /var and /etc, respectively. When cross-building packages, VARBASE and SYSCONFBASE are set to these instead of whatever they were set to in mk.conf. No change to native builds because use of these variables is conditional on USE_CROSS_COMPILE = yes. --- doc/HOWTO-use-crosscompile | 17 +++++++++++++---- mk/bsd.prefs.mk | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/HOWTO-use-crosscompile b/doc/HOWTO-use-crosscompile index 51fe453bc4dd..e2ba471eb357 100644 --- a/doc/HOWTO-use-crosscompile +++ b/doc/HOWTO-use-crosscompile @@ -59,16 +59,25 @@ In addition to whatever else you want in your mk.conf for pkgsrc, add: CROSS_LOWER_VARIANT_VERSION= # empty CROSS_LOWER_VENDOR= # empty -Optionally, you can set CROSS_LOCALBASE for cross-compiled packages -separately from LOCALBASE for natively compiled packages. For example, +Optionally, you can set CROSS_LOCALBASE, CROSS_SYSCONFBASE, and +CROSS_VARBASE for cross-compiled packages separately from LOCALBASE, +SYSCONFBASE, and VARBASE for natively compiled packages. For example, you can use an unprivileged pkgsrc build into /home/user/cross/pkg that will create packages which install to /opt/pkg: LOCALBASE= /home/user/cross/pkg CROSS_LOCALBASE= /opt/pkg -By default, CROSS_LOCALBASE will be /usr/pkg, meaning packages that are -being cross-compiled will see LOCALBASE=/usr/pkg. +By default, pkgsrc will assume: + + CROSS_LOCALBASE= /usr/pkg + CROSS_SYSCONFBASE= /etc + CROSS_VARBASE= /var + +That is, no matter what you set LOCALBASE, SYSCONFBASE, and VARBASE to +in mk.conf for native packages, like directores under /home/user, by +default cross-compiled packages will see LOCALBASE=/usr/pkg, +SYSCONFBASE=/etc, and VARBASE=/var. ** Bootstrapped pkgsrc diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk index 2bf979820a4e..e722b7f06b70 100644 --- a/mk/bsd.prefs.mk +++ b/mk/bsd.prefs.mk @@ -688,6 +688,8 @@ LOCALBASE?= /usr/pkg TOOLBASE:= ${LOCALBASE} .if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) LOCALBASE= ${CROSS_LOCALBASE:U/usr/pkg} +VARBASE= ${CROSS_VARBASE:U/var} +SYSCONFBASE= ${CROSS_SYSCONFBASE:U/etc} .endif X11_TYPE?= modular .if !empty(X11_TYPE:Mnative) From 7635bd8bbaea0a3beebb1bcb95b9f587d4185210 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 12:15:21 +0000 Subject: [PATCH 19/27] mk/pkgformat/pkg: Make default cross-built PKG_DBDIR nicer. `bootstrap --prefix /home/user/pkg' will create an mk.conf with PKG_DBDIR=/home/user/pkg/pkgdb, but if you are using that installation to cross-build packages, you likely want the default cross-built PKG_DBDIR to be /usr/pkg/pkgdb just like the default cross-built LOCALBASE is /usr/pkg. This change implements that. You can still override the cross-built PKG_DBDIR by setting CROSS_PKG_DBDIr in mk.conf. No change to native builds because the new logic is conditional on USE_CROSS_COMPILE = yes. --- mk/pkgformat/pkg/pkgformat-vars.mk | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mk/pkgformat/pkg/pkgformat-vars.mk b/mk/pkgformat/pkg/pkgformat-vars.mk index 226c13e4e25d..e222c57f6adb 100644 --- a/mk/pkgformat/pkg/pkgformat-vars.mk +++ b/mk/pkgformat/pkg/pkgformat-vars.mk @@ -16,7 +16,21 @@ USE_TOOLS+= date .endif # This is the package database directory for the default view. +.if ${USE_CROSS_COMPILE:tl} != "yes" PKG_DBDIR?= ${LOCALBASE}/pkgdb +.else +. ifndef HOST_PKG_DBDIR +# XXX This isn't quite right: if PKG_DBDIR is defined in terms of +# LOCALBASE, we really want to resolve it (`HOST_PKG_DBDIR:=') in +# bsd.prefs.mk before we switch LOCALBASE to CROSS_LOCALBASE. But +# there's no place there to put pkgformat-vars business. Fortunately, +# bootstrap just writes out the full path so this is only an issue if +# you explicitly write out `PKG_DBDIR= ...${LOCALBASE}...' in your +# mk.conf. +HOST_PKG_DBDIR:= ${PKG_DBDIR:U${TOOLBASE}/pkgdb} +. endif +PKG_DBDIR= ${CROSS_PKG_DBDIR:U${LOCALBASE}/pkgdb} +.endif # _PKG_DBDIR is the actual packages database directory where we register # packages. From 5bad69d28c5250d0876325e8f3fd0a9d0284dc67 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 12:19:01 +0000 Subject: [PATCH 20/27] mk/platform/NetBSD.mk: Make default cross-built PKG_TOOLS_BIN nicer. `bootstrap --prefix /home/user/pkg' will create an mk.conf with PKG_TOOLS_BIN=/home/user/pkg/sbin, but if you are using that installation to cross-build packages, you likely want the default cross-built PKG_TOOLS_BIN to be /usr/pkg/sbin just like the default cross-built LOCALBASE is /usr/pkg. This change implements that. You can still override the cross-built PKG_TOOLS_BIN by setting CROSS_PKG_TOOLS_BIN in mk.conf. No change to native builds because the changed part is conditional on USE_CROSS_COMPILE = yes. --- mk/platform/NetBSD.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mk/platform/NetBSD.mk b/mk/platform/NetBSD.mk index a5e8e48fb6e8..ba9c954a4f66 100644 --- a/mk/platform/NetBSD.mk +++ b/mk/platform/NetBSD.mk @@ -35,7 +35,11 @@ NOLOGIN?= /sbin/nologin # This must be lazy and using :? evaluation doesn't work due to a make bugs. NATIVE_PKG_TOOLS_BIN_cmd= if [ -x ${TOOLBASE}/sbin/pkg_info ]; then echo ${TOOLBASE}/sbin; else echo /usr/sbin; fi NATIVE_PKG_TOOLS_BIN?= ${NATIVE_PKG_TOOLS_BIN_cmd:sh} -PKG_TOOLS_BIN?= ${"${USE_CROSS_COMPILE:U:tl}" == "yes":?${CROSS_PKG_TOOLS_BIN:U/usr/sbin}:${NATIVE_PKG_TOOLS_BIN}} +.if ${USE_CROSS_COMPILE:tl} == "yes" +PKG_TOOLS_BIN= ${CROSS_PKG_TOOLS_BIN:U/usr/sbin} +.else +PKG_TOOLS_BIN?= ${NATIVE_PKG_TOOLS_BIN} +.endif ROOT_CMD?= ${SU} - root -c ROOT_USER?= root ROOT_GROUP?= wheel From 539140566f8240c29addbaffd059b82fecd0c78f Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 12:37:13 +0000 Subject: [PATCH 21/27] doc/HOWTO-use-crosscompile: `make USE_CROSS_COMPILE=yes' works now. At least, it seems to! Not sure what symptom I saw ages ago when I warned users against it. --- doc/HOWTO-use-crosscompile | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/doc/HOWTO-use-crosscompile b/doc/HOWTO-use-crosscompile index e2ba471eb357..d9800c7255b6 100644 --- a/doc/HOWTO-use-crosscompile +++ b/doc/HOWTO-use-crosscompile @@ -34,15 +34,15 @@ running NetBSD 6.1 on amd64. In addition to whatever else you want in your mk.conf for pkgsrc, add: - # Cross-compile by default. + # Cross-compile by default. (Alternatively, you can cross-build + # packages with `make package USE_CROSS_COMPILE=no'.) # - # XXX This currently can't be set to `yes' on the command line, - # which is a bug. But it can be set to `no' to build native - # packages. + # Note: This must use `?=' so it doesn't override pkgsrc's internal + # USE_CROSS_COMPILE=no when recursively building toolchain packages + # that have to run on the host. USE_CROSS_COMPILE?= yes - # Point pkgsrc at the NetBSD tooldir and destdir. These are used - # only for cross-builds. + # Point pkgsrc at the NetBSD tooldir and destdir for cross builds. TOOLDIR= /usr/obj/tooldir.NetBSD-6.1-amd64 CROSS_DESTDIR= /usr/obj/destdir.evbppc @@ -115,10 +115,6 @@ build a native package, you can run $ cd /usr/pkgsrc/net/isc-dhcpd4 && make package USE_CROSS_COMPILE=no -XXX Note that currently you cannot omit USE_CROSS_COMPILE?=yes from -your mk.conf and pass USE_CROSS_COMPILE=yes on the make command line. -This is a bug. - * Unprivileged notes I do all this stuff unprivileged in directories under my home From bf2ec9575e69bdc70a73ecd110a1e4e8bfaceb7d Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 22:21:10 +0000 Subject: [PATCH 22/27] bsd.prefs.mk: Use CROSS_ABI or nothing as ABI when cross-building. This way, when you use the mk.conf generated by bootstrap on amd64 to cross-build for other architectures, the ABI=64 setting that bootstrap put in mk.conf doesn't break it. No change to native builds because this is conditional on USE_CROSS_COMPILE = yes. --- mk/bsd.prefs.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk index e722b7f06b70..bd17a2e3e8f6 100644 --- a/mk/bsd.prefs.mk +++ b/mk/bsd.prefs.mk @@ -690,6 +690,11 @@ TOOLBASE:= ${LOCALBASE} LOCALBASE= ${CROSS_LOCALBASE:U/usr/pkg} VARBASE= ${CROSS_VARBASE:U/var} SYSCONFBASE= ${CROSS_SYSCONFBASE:U/etc} +. if defined(CROSS_ABI) +ABI= ${CROSS_ABI} +. else +. undef ABI +. endif .endif X11_TYPE?= modular .if !empty(X11_TYPE:Mnative) From 25dcd97a3c824a73721c3460485fbbf88cee8d81 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 12 Jan 2024 23:44:08 +0000 Subject: [PATCH 23/27] mk/pkgformat/pkg: When updating pkg_install, don't cross-build it. Also clear the same variables that are cleared on recursive package builds to avoid leakage. --- mk/pkgformat/pkg/depends.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mk/pkgformat/pkg/depends.mk b/mk/pkgformat/pkg/depends.mk index fe5b0f74914d..9acb74563b90 100644 --- a/mk/pkgformat/pkg/depends.mk +++ b/mk/pkgformat/pkg/depends.mk @@ -227,10 +227,12 @@ pkg_install-depends: ${PHASE_MSG} "Trying to handle out-dated pkg_install..."; \ cd ../../pkgtools/pkg_install && ${PKGSRC_SETENV} ${PKGSRC_MAKE_ENV} \ _PKGSRC_DEPS=" ${PKGNAME}${_PKGSRC_DEPS}" \ - ${MAKE} ${MAKEFLAGS} _AUTOMATIC=yes clean && \ + ${MAKE} ${MAKEFLAGS} _AUTOMATIC=yes USE_CROSS_COMPILE=no \ + clean && \ cd ../../pkgtools/pkg_install && ${PKGSRC_SETENV} ${PKGSRC_MAKE_ENV} \ _PKGSRC_DEPS=" ${PKGNAME}${_PKGSRC_DEPS}" \ - ${MAKE} ${MAKEFLAGS} _AUTOMATIC=yes ${DEPENDS_TARGET:Q}; \ + ${MAKE} ${MAKEFLAGS} _AUTOMATIC=yes USE_CROSS_COMPILE=no \ + ${DEPENDS_TARGET:Q}; \ fi ###################################################################### From d24dc39c74062f95099dc3cd24d4de512c017e59 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 14 Jun 2023 02:47:36 +0000 Subject: [PATCH 24/27] lang/rust: Need cmake as tool, not as buildlink. --- lang/rust/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/rust/Makefile b/lang/rust/Makefile index fe7a8b3d4a54..5777b11871a2 100644 --- a/lang/rust/Makefile +++ b/lang/rust/Makefile @@ -706,7 +706,7 @@ DEPENDS+= libatomic-links>=0:../../devel/libatomic-links .endif TOOL_DEPENDS+= cmake-[0-9]*:../../devel/cmake -.include "../../devel/cmake/buildlink3.mk" + .include "../../devel/zlib/buildlink3.mk" .include "../../lang/python/tool.mk" .include "../../mk/bsd.pkg.mk" From 4941144a66b1ffe078bb45a2cbebf0ab8ca19096 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Mon, 12 Jun 2023 14:26:26 +0000 Subject: [PATCH 25/27] WIP: lang/python: Make this compile on vax. --- lang/python310/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lang/python310/Makefile b/lang/python310/Makefile index daa6491fe259..4067681488e9 100644 --- a/lang/python310/Makefile +++ b/lang/python310/Makefile @@ -74,6 +74,9 @@ ALL_ENV+= \ _PYTHON_PROJECT_BASE=${WRKSRC:Q} ALL_ENV+= \ _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_${PY_PLATNAME:Q} +. if ${MACHINE_ARCH} == "vax" +CONFIGURE_ENV+= ax_cv_c_float_words_bigendian=no +. endif .endif # http://bugs.python.org/issue13241 From 391e796e5cf15579677419a16a7961c8a50eb150 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 17 Jun 2023 22:03:43 +0000 Subject: [PATCH 26/27] WIP: graphics/MesaLib: Make this cross-compile. Requires kludging up an `llvm-config' tool that runs at build-time. The lang/libLLVM package installs an llvm-config tool, but it's compiled to run on the target system, not on the build system, so it doesn't work in cross-compiling. --- graphics/MesaLib/Makefile | 8 ++++++ graphics/MesaLib/distinfo | 2 ++ graphics/MesaLib/options.mk | 27 +++++++++++++++++++ graphics/MesaLib/patches/patch-meson.build | 19 +++++++++++++ .../MesaLib/patches/patch-meson__options.txt | 17 ++++++++++++ mk/pkgformat/pkg/depends.mk | 3 +++ 6 files changed, 76 insertions(+) create mode 100644 graphics/MesaLib/patches/patch-meson.build create mode 100644 graphics/MesaLib/patches/patch-meson__options.txt diff --git a/graphics/MesaLib/Makefile b/graphics/MesaLib/Makefile index b83f5c7c33d8..245c4da2a9c7 100644 --- a/graphics/MesaLib/Makefile +++ b/graphics/MesaLib/Makefile @@ -176,6 +176,14 @@ PKGCONFIG_OVERRIDE+= output/meson-private/osmesa.pc PKGCONFIG_OVERRIDE+= output/meson-private/xatracker.pc PKGCONFIG_OVERRIDE+= output/meson-private/gl.pc +.include "../../mk/bsd.prefs.mk" + +.if ${USE_CROSS_COMPILE:tl} == "yes" +# wayland-protocols abuses pc_sysrootdir in its .pc files, causing the +# cross-destdir to be prefixed twice to paths. +ALL_ENV+= PKG_CONFIG_FDO_SYSROOT_RULES=1 +.endif + post-install: ${MV} ${DESTDIR}${PREFIX}/share/drirc.d/00-mesa-defaults.conf ${DESTDIR}${EGDIR} .if ${OPSYS} == "Darwin" diff --git a/graphics/MesaLib/distinfo b/graphics/MesaLib/distinfo index 42386fa71f7b..c55b00dd6d2d 100644 --- a/graphics/MesaLib/distinfo +++ b/graphics/MesaLib/distinfo @@ -3,6 +3,8 @@ $NetBSD: distinfo,v 1.166 2023/07/18 19:33:31 ryoon Exp $ BLAKE2s (mesa-21.3.9.tar.xz) = e948a37881a088c0df4df880e3d1218b874ed5a8cac951a109249b3648519472 SHA512 (mesa-21.3.9.tar.xz) = 4cec6f4f50f444fcd327f7c40f8899c2f265e348e121455262b540b1f890a1468bbea59965af0876c548fa97aa0a05a1b23fa6ca7d308bd60328cfdeab757684 Size (mesa-21.3.9.tar.xz) = 16607716 bytes +SHA1 (patch-meson.build) = acdbb73bde03a297a7c080c33edb317c8d838adc +SHA1 (patch-meson__options.txt) = af1cb551056b0f85cf12d1226b8cea368b0284de SHA1 (patch-src_compiler_builtin__type__macros.h) = e4868011711fb89a293580a12eb603b8e7162336 SHA1 (patch-src_drm-shim_drm__shim.c) = 6884d31dc3e9d47aac1785589ab289a601e64545 SHA1 (patch-src_egl_drivers_dri2_platform__drm.c) = 9230fbae2c04246ebca8437ecad694bbae857fbe diff --git a/graphics/MesaLib/options.mk b/graphics/MesaLib/options.mk index 746a6a01cb5d..5668212b82b0 100644 --- a/graphics/MesaLib/options.mk +++ b/graphics/MesaLib/options.mk @@ -81,6 +81,32 @@ GALLIUM_DRIVERS+= r600 PLIST.radeonsi= yes GALLIUM_DRIVERS+= radeonsi . endif + +. if ${USE_CROSS_COMPILE:tl} == "yes" +# XXX whattakludge +LIBLLVM_COMPONENTS= aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets amdgpu amdgpuasmparser amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgpuutils analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo cfguard codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker dwp engine executionengine extensions filecheck frontendopenacc frontendopenmp fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interfacestub interpreter ipo irreader jitlink lanai lanaiasmparser lanaicodegen lanaidesc lanaidisassembler lanaiinfo libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcjit orcshared orctargetprocess passes powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo runtimedyld scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target textapi transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo webassemblyutils windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info xcore xcorecodegen xcoredesc xcoredisassembler xcoreinfo xray +MESON_CROSS_BINARIES+= llvm-config +MESON_CROSS_BINARY.llvm-config= ${TOOLS_DIR}/bin/llvm-config +TOOLS_CREATE+= llvm-config +TOOLS_SCRIPT.llvm-config= \ + while [ $$\# -gt 0 ]; do \ + case $$1 in \ + --components) echo ${LIBLLVM_COMPONENTS};; \ + --cppflags) echo -I${BUILDLINK_PREFIX.libLLVM:Q}/include;; \ + --has-rtti) echo YES;; \ + --libdir) echo ${BUILDLINK_PREFIX.libLLVM:Q}/lib;; \ + --ldflags) echo -L${BUILDLINK_PREFIX.libLLVM:Q}/lib \ + ${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.libLLVM:Q}/lib;; \ + --libs) echo -lLLVM-13;; \ + --link-shared) ;; \ + --shared-mode) echo shared;; \ + --version) echo 13.0.2;; \ + --*) echo unknown option; exit 1;; \ + esac; \ + shift; \ + done +. endif + .else MESON_ARGS+= -Dllvm=disabled .endif @@ -140,6 +166,7 @@ MESON_ARGS+= -Dgallium-vdpau=false # .if !empty(PKG_OPTIONS:Mwayland) MESA_PLATFORMS+= wayland +TOOL_DEPENDS+= ${BUILDLINK_API_DEPENDS.wayland:=:../../devel/wayland} . include "../../devel/wayland/buildlink3.mk" . include "../../devel/wayland-protocols/buildlink3.mk" .endif diff --git a/graphics/MesaLib/patches/patch-meson.build b/graphics/MesaLib/patches/patch-meson.build new file mode 100644 index 000000000000..f4830c302d55 --- /dev/null +++ b/graphics/MesaLib/patches/patch-meson.build @@ -0,0 +1,19 @@ +$NetBSD$ + +Add a wayland-scanner option so we can pass the path through from the +Makefile for cross-builds. + +--- meson.build.orig 2022-06-08 18:13:35.000000000 +0000 ++++ meson.build +@@ -2004,7 +2004,11 @@ endif + + if with_platform_wayland + dep_wl_scanner = dependency('wayland-scanner', native: true) ++ if meson.is_cross_build() ++ prog_wl_scanner = find_program(get_option('wayland-scanner')) ++ else + prog_wl_scanner = find_program(dep_wl_scanner.get_pkgconfig_variable('wayland_scanner')) ++ endif + if dep_wl_scanner.version().version_compare('>= 1.15') + wl_scanner_arg = 'private-code' + else diff --git a/graphics/MesaLib/patches/patch-meson__options.txt b/graphics/MesaLib/patches/patch-meson__options.txt new file mode 100644 index 000000000000..e06c683047fd --- /dev/null +++ b/graphics/MesaLib/patches/patch-meson__options.txt @@ -0,0 +1,17 @@ +$NetBSD$ + +Add a wayland-scanner option so we can pass the path through from the +Makefile for cross-builds. + +--- meson_options.txt.orig 2022-06-08 18:13:35.000000000 +0000 ++++ meson_options.txt +@@ -539,3 +539,9 @@ option( + value : false, + description : 'Configure LTS build to coexist with Mesa >= 22.0' + ) ++option( ++ 'wayland-scanner', ++ type : 'string', ++ value : 'wayland-scanner', ++ description : 'Path to build-time wayland-scanner binary' ++) diff --git a/mk/pkgformat/pkg/depends.mk b/mk/pkgformat/pkg/depends.mk index 9acb74563b90..f2625433eebb 100644 --- a/mk/pkgformat/pkg/depends.mk +++ b/mk/pkgformat/pkg/depends.mk @@ -225,6 +225,9 @@ _pkgformat-post-install-dependencies: .PHONY ${_RDEPENDS_FILE} ${_RRDEPENDS_FILE pkg_install-depends: ${RUN}if [ `${PKG_INFO_CMD} -V 2>/dev/null || echo 20010302` -lt ${PKGTOOLS_REQD} ]; then \ ${PHASE_MSG} "Trying to handle out-dated pkg_install..."; \ + unset _PKGSRC_BARRIER; \ + unset MAKEFLAGS; \ + unset ${CROSSVARS:@_v_@TARGET_${_v_}@}; \ cd ../../pkgtools/pkg_install && ${PKGSRC_SETENV} ${PKGSRC_MAKE_ENV} \ _PKGSRC_DEPS=" ${PKGNAME}${_PKGSRC_DEPS}" \ ${MAKE} ${MAKEFLAGS} _AUTOMATIC=yes USE_CROSS_COMPILE=no \ From a430fde0fcfa46c789eb3277a1da6a804d877f23 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 13 Jan 2024 19:10:05 +0000 Subject: [PATCH 27/27] WIP: modular-xorg-server: Use ppc_video.c for NetBSD m68k, sh3, mips. As we do in xsrc. --- x11/modular-xorg-server/distinfo | 2 +- x11/modular-xorg-server/patches/patch-configure | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/x11/modular-xorg-server/distinfo b/x11/modular-xorg-server/distinfo index 3b63a1520465..e13baf864899 100644 --- a/x11/modular-xorg-server/distinfo +++ b/x11/modular-xorg-server/distinfo @@ -3,7 +3,7 @@ $NetBSD: distinfo,v 1.125 2023/12/13 07:45:07 wiz Exp $ BLAKE2s (xorg-server-21.1.10.tar.xz) = b7773fcdab7bd8ae649e35ca25e4238c0ff2915f46e2ad1bff6c3f49df4a2fae SHA512 (xorg-server-21.1.10.tar.xz) = 8135d9b7c0c71f427ba0a3b80741fee4f6ae195779399b73261a00858882f3516e367a08e2da1403734b04eacabae9aa231e5375eff23b57a3ff764e9caf8926 Size (xorg-server-21.1.10.tar.xz) = 4935984 bytes -SHA1 (patch-configure) = 8096805cb1ac6eb25e03fdbd1d3362b720f7354e +SHA1 (patch-configure) = 6c5b47aadd55e331600720dd39e170194b91c5de SHA1 (patch-hw_kdrive_ephyr_hostx.c) = b681ee28bc7af06774f10bc882d355d42ac965d3 SHA1 (patch-hw_xfree86_common_xf86AutoConfig.c) = 70adf85be9fc6222a335686e7e9e9f385aca02f9 SHA1 (patch-hw_xfree86_common_xf86sbusBus.h) = f56f87336b2f669413ebb1005a2b64568a111f92 diff --git a/x11/modular-xorg-server/patches/patch-configure b/x11/modular-xorg-server/patches/patch-configure index 4749de2c1ff9..48411dbb6bd0 100644 --- a/x11/modular-xorg-server/patches/patch-configure +++ b/x11/modular-xorg-server/patches/patch-configure @@ -5,9 +5,9 @@ Use USE_AMD64_IOPL (actually x86_64_iopl) on NetBSD/amd64. for netbsd, force pass pthread configure checks (pthread not needed) ---- configure.orig 2022-12-14 02:25:26.000000000 +0000 +--- configure.orig 2023-12-13 01:31:14.000000000 +0000 +++ configure -@@ -24606,7 +24606,7 @@ printf "%s\n" "#define USE_ALPHA_PIO 1" +@@ -24672,7 +24672,7 @@ printf "%s\n" "#define USE_ALPHA_PIO 1" esac GLX_ARCH_DEFINES="-D__GLX_ALIGN64 -mieee" ;; @@ -16,7 +16,16 @@ for netbsd, force pass pthread configure checks (pthread not needed) ARM_VIDEO=yes DEFAULT_INT10="stub" ;; -@@ -24648,7 +24648,8 @@ printf "%s\n" "#define USE_DEV_IO 1" >>c +@@ -24693,7 +24693,7 @@ printf "%s\n" "#define USE_ALPHA_PIO 1" + ;; + esac + ;; +- powerpc*) ++ powerpc*|m68k|sh3*|mips*) + PPC_VIDEO=yes + case $host_os in + *freebsd*) DEFAULT_INT10=stub ;; +@@ -24714,7 +24714,8 @@ printf "%s\n" "#define USE_DEV_IO 1" >>c printf "%s\n" "#define USE_DEV_IO 1" >>confdefs.h ;; *netbsd*) @@ -26,7 +35,7 @@ for netbsd, force pass pthread configure checks (pthread not needed) SYS_LIBS=-lx86_64 ;; -@@ -26523,7 +26524,8 @@ case ${host_os} in +@@ -26588,7 +26589,8 @@ case ${host_os} in netbsd*) # use libc stubs, don't link against libpthread, to allow # dynamic loading