|
|
598fb1 |
#!/bin/bash
|
|
|
598fb1 |
|
|
|
598fb1 |
# Date: April 2, 2014
|
|
|
598fb1 |
# by Aldy Hernandez
|
|
|
598fb1 |
|
|
|
598fb1 |
# Attempt to fix any "-m elf64ppc" linker checks in configure and
|
|
|
598fb1 |
# libtool.m4 files.
|
|
|
598fb1 |
#
|
|
|
598fb1 |
# This script is meant to run silently as part of rpm's %configure
|
|
|
598fb1 |
# macro. It either fixes the problem, or we silently ignore it, in
|
|
|
598fb1 |
# which case it is up to the package maintainer to add support for
|
|
|
598fb1 |
# ppc64le.
|
|
|
598fb1 |
|
|
|
598fb1 |
# Our two attempts at fixing the problem.
|
|
|
598fb1 |
PATCH1=/tmp/$$.patch1
|
|
|
598fb1 |
PATCH2=/tmp/$$.patch2
|
|
|
598fb1 |
|
|
|
598fb1 |
cleanup() {
|
|
|
598fb1 |
rm -f $PATCH1 $PATCH2
|
|
|
598fb1 |
}
|
|
|
598fb1 |
|
|
|
598fb1 |
trap cleanup 0 1 2 3 4 5 6 7 8 9 11 13 14 15
|
|
|
598fb1 |
|
|
|
598fb1 |
# There are two variants in RHEL7 so far. The first version, handled
|
|
|
598fb1 |
# with $PATCH1, currently handles all but 3 packages. The $PATCH2
|
|
|
598fb1 |
# version handles the remnant.
|
|
|
598fb1 |
#
|
|
|
598fb1 |
cat > $PATCH1 <
|
|
|
598fb1 |
--- configure.orig 2014-03-18 15:56:15.575070238 -0500
|
|
|
598fb1 |
+++ configure 2014-03-18 16:05:50.877861163 -0500
|
|
|
598fb1 |
@@ -7714,6 +7714,9 @@
|
|
|
598fb1 |
x86_64-*linux*)
|
|
|
598fb1 |
LD="\${LD-ld} -m elf_i386"
|
|
|
598fb1 |
;;
|
|
|
598fb1 |
+ ppc64le-*linux*|powerpc64le-*linux*)
|
|
|
598fb1 |
+ LD="\${LD-ld} -m elf32lppclinux"
|
|
|
598fb1 |
+ ;;
|
|
|
598fb1 |
ppc64-*linux*|powerpc64-*linux*)
|
|
|
598fb1 |
LD="\${LD-ld} -m elf32ppclinux"
|
|
|
598fb1 |
;;
|
|
|
598fb1 |
@@ -7733,6 +7736,9 @@
|
|
|
598fb1 |
x86_64-*linux*)
|
|
|
598fb1 |
LD="\${LD-ld} -m elf_x86_64"
|
|
|
598fb1 |
;;
|
|
|
598fb1 |
+ ppc*le-*linux*|powerpc*le-*linux*)
|
|
|
598fb1 |
+ LD="\${LD-ld} -m elf64lppc"
|
|
|
598fb1 |
+ ;;
|
|
|
598fb1 |
ppc*-*linux*|powerpc*-*linux*)
|
|
|
598fb1 |
LD="\${LD-ld} -m elf64ppc"
|
|
|
598fb1 |
;;
|
|
|
598fb1 |
EOF
|
|
|
598fb1 |
|
|
|
598fb1 |
cat > $PATCH2 <
|
|
|
598fb1 |
--- configure.orig 2014-03-18 16:35:28.942799967 -0500
|
|
|
598fb1 |
+++ configure 2014-03-18 16:34:35.608519090 -0500
|
|
|
598fb1 |
@@ -3798,6 +3798,9 @@
|
|
|
598fb1 |
x86_64-*linux*)
|
|
|
598fb1 |
LD="\${LD-ld} -m elf_i386"
|
|
|
598fb1 |
;;
|
|
|
598fb1 |
+ ppc64le-*linux*)
|
|
|
598fb1 |
+ LD="\${LD-ld} -m elf32lppclinux"
|
|
|
598fb1 |
+ ;;
|
|
|
598fb1 |
ppc64-*linux*)
|
|
|
598fb1 |
LD="\${LD-ld} -m elf32ppclinux"
|
|
|
598fb1 |
;;
|
|
|
598fb1 |
@@ -3814,6 +3817,9 @@
|
|
|
598fb1 |
x86_64-*linux*)
|
|
|
598fb1 |
LD="\${LD-ld} -m elf_x86_64"
|
|
|
598fb1 |
;;
|
|
|
598fb1 |
+ ppc*le-*linux*|powerpc*le-*linux*)
|
|
|
598fb1 |
+ LD="\${LD-ld} -m elf64lppc"
|
|
|
598fb1 |
+ ;;
|
|
|
598fb1 |
ppc*-*linux*|powerpc*-*linux*)
|
|
|
598fb1 |
LD="\${LD-ld} -m elf64ppc"
|
|
|
598fb1 |
;;
|
|
|
598fb1 |
EOF
|
|
|
598fb1 |
|
|
|
598fb1 |
|
|
|
598fb1 |
FILES=`find . -name configure -o -name libtool.m4`
|
|
|
598fb1 |
for f in $FILES; do
|
|
|
598fb1 |
# Filter out candidates that already handle ppc64le.
|
|
|
598fb1 |
if grep -s -e '-m elf64lppc' $f >/dev/null; then
|
|
|
598fb1 |
continue
|
|
|
598fb1 |
fi
|
|
|
598fb1 |
|
|
|
598fb1 |
# Filter out candidates that don't handle PPC.
|
|
|
598fb1 |
if ! grep -s -e '-m elf64ppc' $f >/dev/null; then
|
|
|
598fb1 |
continue
|
|
|
598fb1 |
fi
|
|
|
598fb1 |
|
|
|
598fb1 |
echo "Broken -m elf64ppc use in $f should handle elf64lppc."
|
|
|
598fb1 |
echo "Attempting automatic fix."
|
|
|
598fb1 |
|
|
|
598fb1 |
# Attempt to fix the offended file.
|
|
|
598fb1 |
basename=`basename $f`
|
|
|
598fb1 |
dirname=`dirname $f`
|
|
|
598fb1 |
for p in $PATCH1 $PATCH2; do
|
|
|
598fb1 |
# This is an all for nothing affair. The patch either
|
|
|
598fb1 |
# applies entirely clean, or we don't even try.
|
|
|
598fb1 |
#
|
|
|
598fb1 |
# Tentatively try either patch cleanly, and if we succeed then
|
|
|
598fb1 |
# do it for real.
|
|
|
598fb1 |
pushd $dirname 2>&1 > /dev/null
|
|
|
598fb1 |
if [ $basename = libtool.m4 ]; then
|
|
|
598fb1 |
sed s/configure/libtool.m4/ < $p | patch --dry-run --follow-symlinks -l 2>&1 >/dev/null
|
|
|
598fb1 |
else
|
|
|
598fb1 |
patch --dry-run --follow-symlinks -l < $p 2>&1 > /dev/null
|
|
|
598fb1 |
fi
|
|
|
598fb1 |
if [ $? != 0 ]; then
|
|
|
598fb1 |
echo -n "$p approach did not work for $dirname/$basename: "
|
|
|
598fb1 |
pwd
|
|
|
598fb1 |
# This approach didn't work, try the next one.
|
|
|
598fb1 |
popd 2>&1 > /dev/null
|
|
|
598fb1 |
continue
|
|
|
598fb1 |
fi
|
|
|
598fb1 |
|
|
|
598fb1 |
# Seriously now...
|
|
|
598fb1 |
if [ $basename = libtool.m4 ]; then
|
|
|
598fb1 |
# Save the timestamp.
|
|
|
598fb1 |
cp -p $basename /tmp/tmp.$$
|
|
|
598fb1 |
sed s/configure/libtool.m4/ < $p | patch --follow-symlinks -l -s 2>&1 > /dev/null
|
|
|
598fb1 |
# Use the old timestamp, to avoid anyone noticing changes
|
|
|
598fb1 |
# to libtool.m4.
|
|
|
598fb1 |
touch --reference=/tmp/tmp.$$ $basename
|
|
|
598fb1 |
rm -f /tmp/tmp.$$
|
|
|
598fb1 |
else
|
|
|
598fb1 |
patch --follow-symlinks -l -s < $p 2>&1 > /dev/null
|
|
|
598fb1 |
fi
|
|
|
598fb1 |
echo "Fixed $f for ld -m ppc64le support."
|
|
|
598fb1 |
popd 2>&1 > /dev/null
|
|
|
598fb1 |
break
|
|
|
598fb1 |
done
|
|
|
598fb1 |
done
|
|
|
598fb1 |
|
|
|
598fb1 |
rm -f $PATCH1 $PATCH2
|