diff options
author | riastradh <riastradh@pkgsrc.org> | 2022-04-04 11:23:06 +0000 |
---|---|---|
committer | riastradh <riastradh@pkgsrc.org> | 2022-04-04 11:23:06 +0000 |
commit | 73c4eb1d0670b65afa7e80a35ffb56b7173c700b (patch) | |
tree | ce0871b7242b6bc4e15b7e30718de1a82186fe05 /mk/wrapper/bsd.wrapper.mk | |
parent | f59201716cdf618577c3e831414020db7e8d5974 (diff) | |
download | pkgsrc-73c4eb1d0670b65afa7e80a35ffb56b7173c700b.tar.gz |
mk: Cross-eyed hacks to support cross-libtool.
For a long time, when cross-building, say from native=amd64 to
target=powerpc, it was necessary to:
1. cross-build a _powerpc_ package called cross-libtool-base-powerpc,
and then
2. install the powerpc package _natively_ with `pkg_add -m x86_64' to
override the architecture check that normally forbids this kind of
shenanigans,
in order to cross-build anything that uses libtool as a tool.
This is partly because libtool doesn't follow the normal GNU
convention of `./configure --build=<native platform> --host=<platform
package will run on> --target=<platform package is configured to
operate on>' -- in this example, build=amd64, host=amd64,
target=powerpc.
Instead, libtool expects to be cross-built itself, even if it's going
to run as a tool. It's not as bonkers as it sounds at first: libtool
is just a shell script, and it caches various information about the
(cross-building!) toolchain it is built with so it can use that
information later when it is run as a tool itself to cross-compile
other software.
To make this work, we need to create the toolchain wrappers for
libtool _as if_ we were cross-building even if we are building a
native package. So mk/tools uses a new flag TOOLS_USE_CROSS_COMPILE
instead of USE_CROSS_COMPILE, and libtool internally sets
MACHINE_ARCH=${TARGET_ARCH} (in the example above, powerpc) to make
it look like we're cross-building. The new TOOLS_CROSS_DESTDIR is an
alias for the (defaulted) CROSS_DESTDIR, which must now be set
unconditionally in mk.conf in order for libtool to know where the
cross-destdir will be; _CROSS_DESTDIR remains empty when building any
native packages (including the native cross-libtool package).
Finally, we need to make the resulting package be a native package,
with MACHINE_ARCH set to the one that it will be installed on (in the
example above, amd64), so I added an indirection _BUILD_DEFS.${var}
to replace var on its own in the build definitions that get baked
into the package, shown by `pkg_info -B'. Setting
_BUILD_DEFS.MACHINE_ARCH=${NATIVE_MACHINE_ARCH} ensures that this
mutant hybrid cross-built libtool still produces a native package.
All of this logic is gated on setting USE_CROSS_COMPILE in mk.conf or
LIBTOOL_CROSS_COMPILE in the package makefile, so it should be safe
for non-cross-builds -- when USE_CROSS_COMPILE=no and you're not
building cross-libtool, everything is as before.
Diffstat (limited to 'mk/wrapper/bsd.wrapper.mk')
-rw-r--r-- | mk/wrapper/bsd.wrapper.mk | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mk/wrapper/bsd.wrapper.mk b/mk/wrapper/bsd.wrapper.mk index 9d9cf40d076..fe06414a204 100644 --- a/mk/wrapper/bsd.wrapper.mk +++ b/mk/wrapper/bsd.wrapper.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.wrapper.mk,v 1.104 2022/03/13 06:26:57 nia Exp $ +# $NetBSD: bsd.wrapper.mk,v 1.105 2022/04/04 11:23:07 riastradh Exp $ # # Copyright (c) 2005 The NetBSD Foundation, Inc. # All rights reserved. @@ -363,7 +363,7 @@ _WRAP_CMD_SINK.CXX= ${_WRAP_CMD_SINK.CC} _WRAP_CMD_SINK.LD= ${WRAPPER_TMPDIR}/cmd-sink-irix-ld .endif -.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) +.if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS]) _WRAP_CMD_SINK.CC= ${WRAPPER_TMPDIR}/cmd-sink-cross-gcc _WRAP_CMD_SINK.CPP= ${WRAPPER_TMPDIR}/cmd-sink-cross-cpp _WRAP_CMD_SINK.CXX= ${WRAPPER_TMPDIR}/cmd-sink-cross-gxx @@ -540,9 +540,9 @@ ${WRAPPER_TMPDIR}/${w}: ${WRAPPER_SRCDIR}/${w} ${RUN} ${CAT} ${.ALLSRC} | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET} .endfor -.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) +.if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS]) _WRAP_CROSS_GCC_FILTER+= ${SED} \ - -e "s|@CROSS_DESTDIR@|${_CROSS_DESTDIR:Q}|g" \ + -e "s|@CROSS_DESTDIR@|${TOOLS_CROSS_DESTDIR:Q}|g" \ -e "s|@PREFIX@|${PREFIX:Q}|g" ${WRAPPER_TMPDIR}/cmd-sink-cross-gcc: ${WRAPPER_SRCDIR}/cmd-sink-cross-gcc ${RUN} ${MKDIR} ${.TARGET:H} |