Fix Mac OS X 10.4 compatibility

This commit is contained in:
Wolfgang Thaller 2019-08-18 22:29:27 +02:00
parent 962b214833
commit 5dc8179b1c

View File

@ -137,17 +137,23 @@ function locateAndCheckInterfacesAndLibraries()
# remove old symlinks in $PREFIX/*-apple-macos/include/ # remove old symlinks in $PREFIX/*-apple-macos/include/
# and link files from $PREFIX/CIncludes # and link files from $PREFIX/CIncludes
function linkheaders() function linkHeaders()
{ {
# incompatible with Universal Interfaces on case-insensitive file systems # incompatible with Universal Interfaces on case-insensitive file systems
# (and does not currently work anyways) rm -f "$1"/threads.h # does not currently work anyways
rm -f "$1"/threads.h rm -f "$1"/memory.h # non-standard aliasof string.h
rm -f "$1"/strings.h # traditional bsd string functions
# the following command doesn't work on older Mac OS X versions. (cd "$1" && find "../../CIncludes" -name '*.h' -exec ln -s {} . \;)
# allow it to fail quietly, at worst we leave some dangling symlinks around }
# in the rare situation that headers are removed from the input directory
find "$1" -lname "../../CIncludes/*" -delete || true function unlinkHeaders()
(cd "$1" && find "../../CIncludes/" -name '*.h' -exec ln -s {} . \;) {
for file in "$1/"*; do
if [[ `readlink "$file"` == ../../CIncludes/* ]]; then
rm "$file"
fi
done
} }
function setupPEFBinaryFormat() function setupPEFBinaryFormat()
@ -171,12 +177,12 @@ function setUpInterfacesAndLibraries()
if [ $BUILD_68K != false ]; then if [ $BUILD_68K != false ]; then
ln -sf ../RIncludes $PREFIX/m68k-apple-macos/RIncludes ln -sf ../RIncludes $PREFIX/m68k-apple-macos/RIncludes
linkheaders $PREFIX/m68k-apple-macos/include linkHeaders $PREFIX/m68k-apple-macos/include
fi fi
if [ $BUILD_PPC != false ]; then if [ $BUILD_PPC != false ]; then
ln -sf ../RIncludes $PREFIX/powerpc-apple-macos/RIncludes ln -sf ../RIncludes $PREFIX/powerpc-apple-macos/RIncludes
linkheaders $PREFIX/powerpc-apple-macos/include linkHeaders $PREFIX/powerpc-apple-macos/include
fi fi
FILE_LIST="$PREFIX/apple-libraries.txt" FILE_LIST="$PREFIX/apple-libraries.txt"
@ -190,15 +196,19 @@ function setUpInterfacesAndLibraries()
libname=`basename "$macobj"` libname=`basename "$macobj"`
libname=${libname%.o} libname=${libname%.o}
printf " %30s => %-30s\n" ${libname}.o lib${libname}.a printf " %30s => %-30s\n" ${libname}.o lib${libname}.a
asm="$PREFIX/m68k-apple-macos/lib/$libname.s"
obj="$PREFIX/m68k-apple-macos/lib/$libname.o" obj="$PREFIX/m68k-apple-macos/lib/$libname.o"
lib="$PREFIX/m68k-apple-macos/lib/lib${libname}.a" lib="$PREFIX/m68k-apple-macos/lib/lib${libname}.a"
rm -f $lib rm -f $lib
set -o pipefail if ConvertObj "$macobj" > "$asm"; then
((ConvertObj "$macobj" | m68k-apple-macos-as - -o "$obj") || (rm "$obj" && false) ) \ m68k-apple-macos-as "$asm" -o "$obj"
&& m68k-apple-macos-ar cqs "$lib" "$obj" \ m68k-apple-macos-ar cqs "$lib" "$obj"
&& echo "m68k-apple-macos/lib/$libname.o" >> "$FILE_LIST" \ echo "m68k-apple-macos/lib/$libname.o" >> "$FILE_LIST"
&& echo "m68k-apple-macos/lib/lib${libname}.a" >> "$FILE_LIST" echo "m68k-apple-macos/lib/lib${libname}.a" >> "$FILE_LIST"
fi
rm -f "$asm"
fi fi
done done
fi fi
@ -250,8 +260,8 @@ function removeInterfacesAndLibraries()
for file in `cat "$FILE_LIST"`; do for file in `cat "$FILE_LIST"`; do
rm "$PREFIX/$file" rm "$PREFIX/$file"
done done
find "$PREFIX/m68k-apple-macos/include" -lname "../../CIncludes/*" -delete || true unlinkHeaders "$PREFIX/m68k-apple-macos/include"
find "$PREFIX/powerpc-apple-macos/include" -lname "../../CIncludes/*" -delete || true unlinkHeaders "$PREFIX/powerpc-apple-macos/include"
rm "$PREFIX/m68k-apple-macos/RIncludes" rm "$PREFIX/m68k-apple-macos/RIncludes"
rm "$PREFIX/powerpc-apple-macos/RIncludes" rm "$PREFIX/powerpc-apple-macos/RIncludes"
rm -rf "$PREFIX/CIncludes" rm -rf "$PREFIX/CIncludes"
@ -261,7 +271,10 @@ function removeInterfacesAndLibraries()
fi fi
} }
if [ "$0" = "$BASH_SOURCE" ]; then if (return 0 2>/dev/null); then
# We are being sourced from build-toolchain.sh
true
else
# We are being run directly # We are being run directly
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then