2019-02-16 05:20:14 +00:00
|
|
|
# Wrapper for the "crossdirect" compilation method.
|
|
|
|
# pmbootstrap mounts the native chroot in the foreign arch (e.g. armhf) chroot
|
|
|
|
# as /native. This package gets installed into the native chroot, and creates
|
|
|
|
# wrappers like:
|
|
|
|
#
|
|
|
|
# /native/usr/lib/crossdirect/armhf/gcc
|
|
|
|
# -> /native/usr/bin/armv6-alpine-linux-muslgnueabihf-gcc
|
|
|
|
#
|
|
|
|
# When building packages in the armhf chroot, PATH will get prepended with
|
|
|
|
# "/native/usr/lib/crossdirect/armhf". The end game is of course invoking the
|
|
|
|
# cross compiler from the native chroot, running at native speed, whenever
|
|
|
|
# calling the compiler from the foreign arch chroot. See crossdirect.c for
|
|
|
|
# implementation details (llvm, fakeroot, rpath).
|
|
|
|
|
|
|
|
pkgname=crossdirect
|
2019-04-03 18:45:16 +00:00
|
|
|
pkgver=2
|
2019-02-16 05:20:14 +00:00
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Wrappers to launch native cross compilers in foreign chroots"
|
|
|
|
url="https://postmarketOS.org"
|
|
|
|
arch="all"
|
|
|
|
license="MIT"
|
|
|
|
options=""
|
|
|
|
source="crossdirect.c"
|
|
|
|
|
|
|
|
build() {
|
|
|
|
cd "$srcdir"
|
|
|
|
# Architectures and binaries
|
|
|
|
_archs="x86_64 armhf armv7 aarch64"
|
|
|
|
for _arch in $_archs; do
|
|
|
|
[ "$_arch" == "$CARCH" ] && continue
|
|
|
|
_hostspec="$(arch_to_hostspec $_arch)"
|
2019-04-03 18:45:16 +00:00
|
|
|
|
|
|
|
# Build with -Werror, because we maintain this short program. (If
|
|
|
|
# upstream is elsewhere, having -Werror is usually not desired.)
|
|
|
|
$CC -o "crossdirect-$_arch" \
|
|
|
|
-static \
|
|
|
|
-Werror \
|
|
|
|
-DHOSTSPEC="\"$_hostspec\"" \
|
2019-02-16 05:20:14 +00:00
|
|
|
crossdirect.c
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
package() {
|
|
|
|
# Architectures and binaries
|
|
|
|
_archs="x86_64 armhf armv7 aarch64"
|
|
|
|
_bins="c++ cc cpp g++ gcc clang clang++"
|
|
|
|
|
|
|
|
# Iterate over architectures
|
|
|
|
for _arch in $_archs; do
|
|
|
|
[ "$_arch" == "$CARCH" ] && continue
|
|
|
|
|
|
|
|
# Put arch-specific crossdirect wrapper in arch-specific bin folder
|
|
|
|
_bindir="$pkgdir/usr/lib/crossdirect/$_arch"
|
|
|
|
_hostspec="$(arch_to_hostspec $_arch)"
|
|
|
|
mkdir -p "$_bindir"
|
|
|
|
cd "$_bindir"
|
|
|
|
cp "$srcdir/crossdirect-$_arch" "./"
|
|
|
|
|
|
|
|
# Create compiler symlinks
|
|
|
|
for _bin in $_bins; do
|
|
|
|
ln -s "crossdirect-$_arch" "$_bin"
|
|
|
|
ln -s "crossdirect-$_arch" "$_hostspec-$_bin"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
2019-04-03 18:45:16 +00:00
|
|
|
sha512sums="6a94a2e0842c95b8ca862b71a7b54f280d0fe9da40fe40691628ef6089a995159c1b53513fb006589af064110a9d2592b24c772264c02d27e7bac9871428f757 crossdirect.c"
|