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