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