summaryrefslogtreecommitdiff
path: root/cross/cross-newlib/PKGBUILD
diff options
context:
space:
mode:
Diffstat (limited to 'cross/cross-newlib/PKGBUILD')
-rw-r--r--cross/cross-newlib/PKGBUILD152
1 files changed, 152 insertions, 0 deletions
diff --git a/cross/cross-newlib/PKGBUILD b/cross/cross-newlib/PKGBUILD
new file mode 100644
index 000000000..4c3372ed8
--- /dev/null
+++ b/cross/cross-newlib/PKGBUILD
@@ -0,0 +1,152 @@
+# Maintainer: David P. <megver83@parabola.nu>
+
+# toolchain build order: {kernel}-api-headers->glibc->binutils->gcc->binutils->glibc
+
+# toolchain (for cross-compiler) build order:
+# {kernel}-api-headers(host system)->glibc(host system)
+# ->binutils(host system)->gcc(host system)->binutils(host system)->glibc(host system)
+# ->binutils(cross)->gcc(cross)
+# ->kernel-api-headers(target system)->glibc(target system)
+# ->binutils(target system)->gcc(target system)->binutils(target system)
+# ->glibc(target system)
+
+# NOTE: libtool requires rebuilt with each new gcc version
+
+#--------------------------------------------------------------------------------
+# cross-compile table
+#--------------------------------------------------------------------------------
+
+# +-------------+-------------+-----------------------------------------------------------------------------------------------------+-----------+---------+
+# | -march | CARCH | CTARGET (_CTARGET) | Multilib | QEMU |
+# +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
+# | _march | CARCH | _arch | <machine> | _os_target (GNU/*) | _multilib | - |
+# +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
+# | x86_64 | x86_64 | x86_64 | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kdragonflybsd,kopensolaris}-gnu|elf | yes | bin/sys |
+# | i[3-7]86 | i[3-7]86 | i[3-7]86 | pc | gnu|{linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnu|elf | no | bin/sys |
+# | armv8-a | aarch64 | aarch64 | unknown | {linux,kfreebsd,knetbsd}-gnu|elf | no | bin/sys |
+# | armv8-a | aarch64_be | aarch64_be | unknown | {linux,kfreebsd,knetbsd}-gnu|elf | no | bin/sys |
+# | armv7-a | armv7h | armv7l | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnueabihf|elf | no | bin/sys |
+# | armv6 | armv6h | armv6l | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnueabihf|elf | no | bin/sys |
+# | armv5te | arm | armv5tel | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnueabi | no | bin/sys |
+# | * | arm | arm | unknown | eabi | no | bin/sys |
+# | arm | armeb | armeb | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnueabi|eabi | no | bin |
+# | mips64el | mips64el | mips64el | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
+# | mips64 | mips64 | mips64 | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
+# | * | mipsel | mipsel | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
+# | * | mips | mips | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
+#v| powerpc64 | powerpc64 | powerpc64 | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | bin/sys |x|eabi
+#x| powerpc64le | powerpc64le | powerpc64le | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | bin |
+# | powerpc | powerpc | powerpc | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | bin/sys |
+# | powerpcle | powerpcle | powerpcle | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | - |
+# | - | spu | spu | unknown | elf | no | - |
+# | - | sh64 | sh64 | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - |
+# | - | sh64le | sh64le | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - |
+# | - | sh4 | sh4 | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
+# | - | sh4le | sh4le | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
+# | - | sh | sh | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - @ |
+# | - | shle | shle | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - @ |
+# | - | m68k | m68k | unknown | gnu|{linux,knetbsd}-gnu|elf | no | bin/sys |
+# | - | avr | avr | unknown | linux-gnu|elf | no | - |
+# | - | xtensa | xtensa | unknown | linux-gnu|elf | no | sys |
+# | - | lm32 | lm32 | unknown | linux-gnu|elf | no | sys |
+# | - | or32 | or32 | unknown | linux-gnu|elf | no | bin/sys |x|linux-gnu
+# +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
+
+# For "Wine, Darling and DOSBox"
+# +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
+# | x86_64 | x86_64 | x86_64 | unknown | mingw64(Wine)|darwin | yes | bin/sys |
+# | i[3-7]86 | i[3-7]86 | i[3-7]86 | pc | mingw32(Wine)|msdosdjgpp(DOSBox)|darwin | no | bin/sys |
+# | armv7-a | armv7h | armv7l | unknown | mingw-arm(Wine)|darwin | no | bin/sys |
+# | powerpc | powerpc | powerpc | unknown | darwin | no | bin/sys |
+# +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
+
+# opt : Multilib is optional
+# * : Any supported by architecture.
+# - : None.
+# @ : bin/sys (Only sh4 and sh4l support)
+# < : experimental support. (future)
+
+#--------------------------------------------------------------------------------
+# Tips for build():
+#--------------------------------------------------------------------------------
+# * If builing without "--disable-multilib" make sure to have "--with-python-dir=share/gcc-$_target"
+
+# * When building using `make' instead of `make all-gcc' append "--with-sysroot=/usr/$_target" and
+# "--with-native-system-header-dir=/include". You'll also have to build and add a libc implementation
+# in makedepends as $_target-<libc> (e.g. $_target-newlib or $_target-glibc)
+
+# Toolchain triplet: <_arch>-<machine>-<_os_target>
+# <machine> is generally optional and uneeded
+_target=x86_64-pc-linux-gnu
+
+# This are some options for names. Change $_target_name in pkgdesc according to the target architecture
+case ${_target%%-*} in
+ arm*) _target_name=ARM
+ ;;
+ aarch64*) _target_name=ARM64
+ ;;
+ xtensa) _target_name=Xtensa
+ ;;
+ sh*) _target_name=SuperH
+ ;;
+ powerpc*) _target_name=PowerPC
+ ;;
+ riscv*) _target_name=RISC-V
+ ;;
+ mips*) _target_name=MIPS
+ ;;
+ i686) _target_name=x86
+ ;;
+ *) _target_name=${_target%%-*}
+ ;;
+esac
+
+pkgname=$_target-newlib
+pkgver=3.0.0
+pkgrel=1
+_upstream_ver=$pkgver
+pkgdesc="A C standard library implementation intended for use on embedded systems ($_target_name target)"
+arch=(any)
+url='http://www.sourceware.org/newlib/'
+license=(BSD)
+makedepends=($_target-gcc)
+options=(!emptydirs !strip)
+source=(ftp://sourceware.org/pub/newlib/newlib-$_upstream_ver.tar.gz
+ fix_build1.patch::'https://www.sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=patch;h=b8272e3b8df8337744423e4dd23e727cf963d528'
+ fix_build2.patch::'https://www.sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=patch;h=b7e0f286a2ecab3b687ec9b3f95f5a88b9f85310')
+sha256sums=('c8566335ee74e5fcaeb8595b4ebd0400c4b043d6acb3263ecb1314f8f5501332'
+ '2be98412600b8d62b4f1456e95ae4bc3b7a6810981d3fde49fad1f42df0c49da'
+ '641978987fcfc9fc5c529192f34771db44d3257f95bc682da16e8351356177cf')
+
+prepare() {
+ cd newlib-$_upstream_ver
+ patch -p1 < ../fix_build1.patch
+ patch -p1 < ../fix_build2.patch
+}
+
+build() {
+ rm -rf build-newlib
+ mkdir build-newlib
+
+ export CFLAGS_FOR_TARGET='-g -O2 -ffunction-sections -fdata-sections'
+ cd "$srcdir"/build-newlib
+ ../newlib-$_upstream_ver/configure \
+ --target=$_target \
+ --prefix=/usr \
+ --disable-newlib-supplied-syscalls \
+ --disable-nls \
+ --enable-newlib-io-long-long \
+ --enable-newlib-register-fini
+ make
+
+}
+
+package() {
+ cd "$srcdir"/build-newlib
+ make DESTDIR="$pkgdir" install
+
+ find "$pkgdir"/usr/$_target/lib \( -name "*.a" -or -name "*.o" \) -exec $_target-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc '{}' \;
+
+ install -d "$pkgdir"/usr/share/licenses/$pkgname/
+ install -m644 -t "$pkgdir"/usr/share/licenses/$pkgname/ "$srcdir"/newlib-$_upstream_ver/COPYING*
+}