PKGBUILD 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. # Maintainer: David P. <megver83@parabola.nu>
  2. # toolchain build order: {kernel}-api-headers->glibc->binutils->gcc->binutils->glibc
  3. # toolchain (for cross-compiler) build order:
  4. # {kernel}-api-headers(host system)->glibc(host system)
  5. # ->binutils(host system)->gcc(host system)->binutils(host system)->glibc(host system)
  6. # ->binutils(cross)->gcc(cross)
  7. # ->kernel-api-headers(target system)->glibc(target system)
  8. # ->binutils(target system)->gcc(target system)->binutils(target system)
  9. # ->glibc(target system)
  10. # NOTE: libtool requires rebuilt with each new gcc version
  11. #--------------------------------------------------------------------------------
  12. # cross-compile table
  13. #--------------------------------------------------------------------------------
  14. # +-------------+-------------+-----------------------------------------------------------------------------------------------------+-----------+---------+
  15. # | -march | CARCH | CTARGET (_CTARGET) | Multilib | QEMU |
  16. # +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
  17. # | _march | CARCH | _arch | <machine> | _os_target (GNU/*) | _multilib | - |
  18. # +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
  19. # | x86_64 | x86_64 | x86_64 | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kdragonflybsd,kopensolaris}-gnu|elf | yes | bin/sys |
  20. # | i[3-7]86 | i[3-7]86 | i[3-7]86 | pc | gnu|{linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnu|elf | no | bin/sys |
  21. # | armv8-a | aarch64 | aarch64 | unknown | {linux,kfreebsd,knetbsd}-gnu|elf | no | bin/sys |
  22. # | armv8-a | aarch64_be | aarch64_be | unknown | {linux,kfreebsd,knetbsd}-gnu|elf | no | bin/sys |
  23. # | armv7-a | armv7h | armv7l | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnueabihf|elf | no | bin/sys |
  24. # | armv6 | armv6h | armv6l | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnueabihf|elf | no | bin/sys |
  25. # | armv5te | arm | armv5tel | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnueabi | no | bin/sys |
  26. # | * | arm | arm | unknown | eabi | no | bin/sys |
  27. # | arm | armeb | armeb | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnueabi|eabi | no | bin |
  28. # | mips64el | mips64el | mips64el | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  29. # | mips64 | mips64 | mips64 | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  30. # | * | mipsel | mipsel | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  31. # | * | mips | mips | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  32. #v| powerpc64 | powerpc64 | powerpc64 | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | bin/sys |x|eabi
  33. #x| powerpc64le | powerpc64le | powerpc64le | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | bin |
  34. # | powerpc | powerpc | powerpc | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | bin/sys |
  35. # | powerpcle | powerpcle | powerpcle | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | - |
  36. # | - | spu | spu | unknown | elf | no | - |
  37. # | - | sh64 | sh64 | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - |
  38. # | - | sh64le | sh64le | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - |
  39. # | - | sh4 | sh4 | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  40. # | - | sh4le | sh4le | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  41. # | - | sh | sh | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - @ |
  42. # | - | shle | shle | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - @ |
  43. # | - | m68k | m68k | unknown | gnu|{linux,knetbsd}-gnu|elf | no | bin/sys |
  44. # | - | avr | avr | unknown | linux-gnu|elf | no | - |
  45. # | - | xtensa | xtensa | unknown | linux-gnu|elf | no | sys |
  46. # | - | lm32 | lm32 | unknown | linux-gnu|elf | no | sys |
  47. # | - | or32 | or32 | unknown | linux-gnu|elf | no | bin/sys |x|linux-gnu
  48. # +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
  49. # For "Wine, Darling and DOSBox"
  50. # +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
  51. # | x86_64 | x86_64 | x86_64 | unknown | mingw64(Wine)|darwin | yes | bin/sys |
  52. # | i[3-7]86 | i[3-7]86 | i[3-7]86 | pc | mingw32(Wine)|msdosdjgpp(DOSBox)|darwin | no | bin/sys |
  53. # | armv7-a | armv7h | armv7l | unknown | mingw-arm(Wine)|darwin | no | bin/sys |
  54. # | powerpc | powerpc | powerpc | unknown | darwin | no | bin/sys |
  55. # +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
  56. # opt : Multilib is optional
  57. # * : Any supported by architecture.
  58. # - : None.
  59. # @ : bin/sys (Only sh4 and sh4l support)
  60. # < : experimental support. (future)
  61. #--------------------------------------------------------------------------------
  62. # Choosing the correct pkgdesc
  63. #--------------------------------------------------------------------------------
  64. # You must know wether your toolchain is a bare-metal one, if it's specifically for big-endian or
  65. # little-endian order and know its full name, if possible. Here are some useful tips:
  66. #
  67. # * If the toolchain has no operating system (see the toolchain triplet, <_os_target>), then it's a
  68. # bare-metal toolchain, in which case you have to specify it in the pkgdesc
  69. #
  70. # * Do a bit of research in forums, wikis and documents about the target you plan to build, a good
  71. # idea is to see the description that other distros put (e.g. Debian) if they have the same toolchain
  72. #
  73. # Example: arm-linux-gnueabi-{gcc,binutils,$etc}
  74. # This toolchain has GNU/Linux as OS, so it's not a bare-metal one. It's for armel, which
  75. # stands for "ARM EABI little-endian", but the gnueabi part means it uses the GNU EABI. You can find
  76. # that info in Debian's gcc-arm-linux-gnueabi and a couple of FLOSS and programmers community forums.
  77. # Toolchain triplet: <_arch>-<machine>-<_os_target>
  78. # <machine> is generally optional and uneeded
  79. _target=x86_64-pc-linux-gnu
  80. # This are some options for names. Change $_target_name in pkgdesc according to the target architecture
  81. case ${_target%%-*} in
  82. arm*) _target_name=ARM
  83. ;;
  84. aarch64*) _target_name=ARM64
  85. ;;
  86. xtensa) _target_name=Xtensa
  87. ;;
  88. sh*) _target_name=SuperH
  89. ;;
  90. powerpc*) _target_name=PowerPC
  91. ;;
  92. riscv*) _target_name=RISC-V
  93. ;;
  94. mips*) _target_name=MIPS
  95. ;;
  96. i686) _target_name=x86
  97. ;;
  98. *) _target_name=${_target%%-*}
  99. ;;
  100. esac
  101. pkgname=$_target-newlib
  102. pkgver=3.3.0
  103. pkgrel=1
  104. _upstream_ver=$pkgver
  105. pkgdesc="A C standard library implementation intended for use on embedded systems ($_target_name target)"
  106. arch=(any)
  107. url='http://www.sourceware.org/newlib/'
  108. license=(BSD)
  109. makedepends=($_target-gcc)
  110. options=(!emptydirs !strip)
  111. source=(https://sourceware.org/pub/newlib/newlib-$_upstream_ver.tar.gz)
  112. sha256sums=('58dd9e3eaedf519360d92d84205c3deef0b3fc286685d1c562e245914ef72c66')
  113. build() {
  114. mkdir newlib-build
  115. export CFLAGS_FOR_TARGET='-g -O2 -ffunction-sections -fdata-sections'
  116. cd "$srcdir"/newlib-build
  117. ../newlib-$_upstream_ver/configure \
  118. --target=$_target \
  119. --prefix=/usr \
  120. --enable-newlib-io-long-long \
  121. --enable-newlib-io-c99-formats \
  122. --enable-newlib-register-fini \
  123. --enable-newlib-retargetable-locking \
  124. --disable-newlib-supplied-syscalls \
  125. --disable-nls
  126. make
  127. }
  128. package() {
  129. cd "$srcdir"/newlib-build
  130. make DESTDIR="$pkgdir" install -j1
  131. 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 '{}' \;
  132. install -d "$pkgdir"/usr/share/licenses/$pkgname/
  133. install -m644 -t "$pkgdir"/usr/share/licenses/$pkgname/ "$srcdir"/newlib-$_upstream_ver/COPYING*
  134. }