fix-configure-powerpc64.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. # This is a script to find, and correct, a problem with old versions of
  3. # configure that affect powerpc64 and powerpc64le.
  4. # The issue causes configure to incorrectly determine that shared library
  5. # support is not present in the linker. This causes the package to build a
  6. # static library rather than a dynamic one and although the build will succeed,
  7. # it may cause packages that link with the static library it to fail due to
  8. # undefined symbols.
  9. # This script searches for files named 'configure' that appear to have this
  10. # issue (by searching for a known bad pattern) and patching them.
  11. set -e
  12. if [ $# -ne 1 ]; then
  13. echo "Usage: $0 <package build directory>"
  14. exit 2
  15. fi
  16. srcdir="$1"
  17. files=$(cd "$srcdir" && find . -name configure \
  18. -exec grep -qF 'Generated by GNU Autoconf' {} \; \
  19. -exec grep -qF 'ppc*-*linux*|powerpc*-*linux*)' {} \; -print)
  20. # --ignore-whitespace is needed because some packages have included
  21. # copies of configure scripts where tabs have been replaced with spaces.
  22. for c in $files; do
  23. patch --ignore-whitespace "$srcdir"/"$c" <<'EOF'
  24. --- a/configure 2016-11-16 15:31:46.097447271 +1100
  25. +++ b/configure 2008-07-21 12:17:23.000000000 +1000
  26. @@ -4433,7 +4433,10 @@
  27. x86_64-*linux*)
  28. LD="${LD-ld} -m elf_x86_64"
  29. ;;
  30. - ppc*-*linux*|powerpc*-*linux*)
  31. + powerpcle-*linux*)
  32. + LD="${LD-ld} -m elf64lppc"
  33. + ;;
  34. + powerpc-*linux*)
  35. LD="${LD-ld} -m elf64ppc"
  36. ;;
  37. s390*-*linux*)
  38. EOF
  39. done