recipe 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Build recipe for musl.
  2. #
  3. # Copyright (c) 2015-2018 Matias Fonzo, <selk@dragora.org>.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. program=musl
  17. version=1.1.19
  18. release=1
  19. tarname=${program}-${version}.tar.gz
  20. # Remote source(s)
  21. fetch=http://www.musl-libc.org/releases/$tarname
  22. description="
  23. A powerful standard C/POSIX library.
  24. Musl is a new standard library to power a new generation of Linux-based
  25. devices. Musl is lightweight, fast, simple, free, and strives to be
  26. correct in the sense of standards-conformance and safety.
  27. "
  28. homepage=http://www.musl-libc.org
  29. license=MIT
  30. # Source documentation
  31. docs="COPYRIGHT README VERSION WHATSNEW"
  32. docsdir="${docdir}/${program}-${version}"
  33. build()
  34. {
  35. set -e
  36. unpack "${tardir}/$tarname"
  37. cd "$srcdir"
  38. patch -Np0 -i "${worktree}/patches/musl/musl-utmp_path.diff"
  39. # Do not use the compiler runtime library from the temporary system,
  40. # the toolchain must be adjusted until the native GCC take place
  41. if cc -print-libgcc-file-name | grep -q '^/tools'
  42. then
  43. patch -Np1 -i "${worktree}/patches/musl/musl-nolibcc_stage1.diff"
  44. fi
  45. # Some tune options for i586, x86_64
  46. patch -Np1 -i "${worktree}/patches/musl/musl-tune.diff"
  47. ./configure $configure_args \
  48. --libdir=/usr/lib${libSuffix} \
  49. --syslibdir=/lib \
  50. --enable-shared \
  51. --enable-static \
  52. --enable-optimize=size
  53. make -j${jobs}
  54. make -j${jobs} install DESTDIR="$destdir"
  55. # To print shared library dependencies
  56. mkdir -p "${destdir}/usr/bin"
  57. ln -sf /usr/lib${libSuffix}/libc.so "${destdir}/usr/bin/ldd"
  58. # Create dynamic linker runtime file taking -$(ARCH) as reference
  59. for file in "${destdir}"/lib/ld-musl-*.so.1
  60. do
  61. if ls -1 "$file" > /dev/null
  62. then
  63. ld_path="${file##*/}" # Basename
  64. ld_path="${ld_path%%.*}.path" # Get the rid of .so.1
  65. break;
  66. fi
  67. done
  68. unset file
  69. if test -n "$ld_path"
  70. then
  71. mkdir -p "${destdir}/etc"
  72. cat << EOF > "${destdir}/etc/$ld_path"
  73. /lib
  74. /usr/local/lib
  75. /usr/lib
  76. /usr/$(cc -dumpmachine)/lib
  77. EOF
  78. chmod 644 "${destdir}/etc/$ld_path"
  79. touch "${destdir}/etc/.graft-config"
  80. fi
  81. # Copy documentation
  82. mkdir -p "${destdir}${docsdir}"
  83. cp -p $docs "${destdir}${docsdir}"
  84. }