pkgsrc/mk/tools/tools.FreeMiNT.mk
riastradh a1abd9761c 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.
2022-04-04 11:23:06 +00:00

110 lines
3.8 KiB
Makefile

# $NetBSD: tools.FreeMiNT.mk,v 1.5 2022/04/04 11:23:07 riastradh Exp $
#
# System-supplied tools for the FreeMiNT operating system.
TOOLS_PLATFORM.[?= [ # shell builtin
TOOLS_PLATFORM.awk?= /bin/awk
TOOLS_PLATFORM.basename?= /bin/basename
TOOLS_PLATFORM.byacc?= /usr/bin/yacc
TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
TOOLS_PLATFORM.bzip2?= /usr/bin/bzip2
TOOLS_PLATFORM.cat?= /bin/cat
TOOLS_PLATFORM.chgrp?= /bin/chgrp
TOOLS_PLATFORM.chmod?= /bin/chmod
TOOLS_PLATFORM.chown?= /bin/chown
TOOLS_PLATFORM.cmp?= /usr/bin/cmp
TOOLS_PLATFORM.cp?= /bin/cp
TOOLS_PLATFORM.cut?= /usr/bin/cut
TOOLS_PLATFORM.date?= /bin/date
TOOLS_PLATFORM.diff?= /usr/bin/diff
TOOLS_PLATFORM.diff3?= /usr/bin/diff3
TOOLS_PLATFORM.dirname?= /usr/bin/dirname
TOOLS_PLATFORM.echo?= echo # shell builtin
TOOLS_PLATFORM.egrep?= /bin/egrep
TOOLS_PLATFORM.env?= /usr/bin/env
TOOLS_PLATFORM.expr?= /usr/bin/expr
TOOLS_PLATFORM.false?= false # shell builtin
TOOLS_PLATFORM.fgrep?= /bin/fgrep
TOOLS_PLATFORM.find?= /usr/bin/find
TOOLS_PLATFORM.flex?= /usr/bin/lex
TOOLS_PLATFORM.grep?= /bin/grep
TOOLS_PLATFORM.groff?= /usr/bin/groff
TOOLS_PLATFORM.gsed?= ${TOOLS_PLATFORM.sed} # GNUish
TOOLS_PLATFORM.gsoelim?= ${TOOLS_PLATFORM.soelim} # GNUish
TOOLS_PLATFORM.gunzip?= /bin/gunzip -f
TOOLS_PLATFORM.gzcat?= /bin/gunzip -c
TOOLS_PLATFORM.gzip?= /usr/bin/gzip -nf ${GZIP}
TOOLS_PLATFORM.head?= /usr/bin/head
TOOLS_PLATFORM.hostname?= /bin/hostname
TOOLS_PLATFORM.id?= /usr/bin/id
.if empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS])
TOOLS_PLATFORM.install?= /usr/bin/install
.else
TOOLS_PLATFORM.install?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install
.endif
TOOLS_PLATFORM.install-info?= /sbin/install-info
TOOLS_PLATFORM.lex?= /usr/bin/lex
TOOLS_PLATFORM.ln?= /bin/ln
TOOLS_PLATFORM.ls?= /bin/ls
TOOLS_PLATFORM.m4?= /usr/bin/m4
TOOLS_PLATFORM.makeinfo?= /usr/bin/makeinfo
TOOLS_PLATFORM.mkdir?= /bin/mkdir -p
TOOLS_PLATFORM.mktemp?= /bin/mktemp
TOOLS_PLATFORM.msgfmt?= /usr/bin/msgfmt
TOOLS_PLATFORM.mv?= /bin/mv
TOOLS_PLATFORM.nice?= /bin/nice
TOOLS_PLATFORM.nroff?= /usr/bin/nroff
TOOLS_PLATFORM.openssl?= /usr/bin/openssl
TOOLS_PLATFORM.patch?= /usr/bin/patch
TOOLS_PLATFORM.printf?= /usr/bin/printf
TOOLS_PLATFORM.pwd?= /bin/pwd
.if empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS])
TOOLS_PLATFORM.readelf?= /usr/bin/readelf
.else
TOOLS_PLATFORM.readelf?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-readelf
.endif
TOOLS_PLATFORM.rm?= /bin/rm
TOOLS_PLATFORM.rmdir?= /bin/rmdir
TOOLS_PLATFORM.sdiff?= /usr/bin/sdiff
TOOLS_PLATFORM.sed?= /bin/sed
TOOLS_PLATFORM.sh?= /bin/sh
TOOLS_PLATFORM.sleep?= /bin/sleep
TOOLS_PLATFORM.soelim?= /usr/bin/soelim
TOOLS_PLATFORM.sort?= /bin/sort
.if empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS])
TOOLS_PLATFORM.strip?= /usr/bin/strip
.else
TOOLS_PLATFORM.strip?= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip
.endif
TOOLS_PLATFORM.tail?= /usr/bin/tail
TOOLS_PLATFORM.tar?= /bin/tar
TOOLS_PLATFORM.tbl?= /usr/bin/tbl
TOOLS_PLATFORM.tee?= /usr/bin/tee
TOOLS_PLATFORM.test?= test # shell builtin
TOOLS_PLATFORM.touch?= /bin/touch
TOOLS_PLATFORM.tr?= /usr/bin/tr
TOOLS_PLATFORM.true?= true # shell builtin
TOOLS_PLATFORM.tsort?= /usr/bin/tsort
TOOLS_PLATFORM.uniq?= /bin/uniq
TOOLS_PLATFORM.wc?= /usr/bin/wc
TOOLS_PLATFORM.xargs?= /usr/bin/xargs -r
TOOLS_PLATFORM.xgettext?= /usr/bin/xgettext
TOOLS_PLATFORM.yacc?= /usr/bin/yacc
.if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS])
. for _t_ in ar as ld nm 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
NATIVE_CC:= /usr/bin/cc
CC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
.endif