universal interfaces from mpw3.5 from archive.org

This commit is contained in:
Wolfgang Thaller 2021-12-28 23:30:11 +01:00
parent 3fde20eed6
commit 78d5e46fd2
2 changed files with 107 additions and 62 deletions

View File

@ -268,6 +268,39 @@ let
""); "");
}; };
mpw_35_gm = with pkgs;
fetchurl {
url = "https://web.archive.org/web/20210309154524/https://staticky.com/mirrors/ftp.apple.com/developer/Tool_Chest/Core_Mac_OS_Tools/MPW_etc./MPW-GM_Images/MPW-GM.img.bin";
sha256 = "0wm8dwmm0cpp8px27in564ih27sn5vbydz3jqpzwh04qpfazmfwr";
};
universal = with pkgs;
stdenvNoCC.mkDerivation {
name = "retro68.universal";
src = retro68.mpw_35_gm;
nativeBuildInputs = with buildPackages.retro68; [tools hfsutils binutils_unwrapped];
buildCommand = ''
ConvertDiskImage $src decoded.dsk
export HOME=.
hmount decoded.dsk
mkdir -p CIncludes RIncludes lib68
hcopy -t 'MPW-GM:MPW-GM:Interfaces&Libraries:Interfaces:CIncludes:*.h' CIncludes/
hcopy -t 'MPW-GM:MPW-GM:Interfaces&Libraries:Interfaces:RIncludes:*.r' RIncludes/
mkdir -p $out/include $out/RIncludes
bash ${./prepare-headers.sh} CIncludes $out/include
bash ${./prepare-rincludes.sh} RIncludes $out/RIncludes
hcopy -r 'MPW-GM:MPW-GM:Interfaces&Libraries:Libraries:Libraries:*.o' lib68
. ${./interfaces-and-libraries.sh}
M68KLIBRARIES=lib68
setup68KLibraries $out/
mv $out/lib68k $out/lib
'';
};
import_libraries = with pkgs; import_libraries = with pkgs;
if stdenvNoCC.targetPlatform != retroPlatforms.m68k then if stdenvNoCC.targetPlatform != retroPlatforms.m68k then
stdenvNoCC.mkDerivation { stdenvNoCC.mkDerivation {

View File

@ -232,78 +232,90 @@ function unlinkInterfacesAndLibraries()
rm -f "$PREFIX/powerpc-apple-macos/RIncludes" rm -f "$PREFIX/powerpc-apple-macos/RIncludes"
} }
function setUpInterfacesAndLibraries() function setup68KLibraries()
{ {
rm -rf "$PREFIX/universal" DEST=${1:-"$PREFIX/universal"}
mkdir "$PREFIX/universal" echo "Converting 68K static libraries..."
mkdir -p "$DEST/lib68k"
for macobj in "${M68KLIBRARIES}/"*.o; do
if [ -r "$macobj" ]; then
libname=`basename "$macobj"`
libname=${libname%.o}
printf " %30s => %-30s\n" ${libname}.o lib${libname}.a
asm="$DEST/lib68k/$libname.s"
obj="$DEST/lib68k/$libname.o"
lib="$DEST/lib68k/lib${libname}.a"
echo "Preparing CIncludes..." rm -f $lib
mkdir "$PREFIX/universal/CIncludes"
sh "$SRC/prepare-headers.sh" "$CINCLUDES" "$PREFIX/universal/CIncludes"
echo "Preparing RIncludes..." if ConvertObj "$macobj" > "$asm"; then
mkdir "$PREFIX/universal/RIncludes" m68k-apple-macos-as "$asm" -o "$obj"
sh "$SRC/prepare-rincludes.sh" "$RINCLUDES" "$PREFIX/universal/RIncludes" m68k-apple-macos-ar cqs "$lib" "$obj"
fi
rm -f "$asm"
fi
done
}
if [ $BUILD_68K != false ]; then function setupPPCLibraries()
echo "Converting 68K static libraries..." {
mkdir -p "$PREFIX/universal/lib68k" mkdir -p "$DEST/libppc"
for macobj in "${M68KLIBRARIES}/"*.o; do case `ResInfo -n "$INTERFACELIB" 2> /dev/null || echo 0` in
if [ -r "$macobj" ]; then 0)
libname=`basename "$macobj"` if [ -n "$INTERFACELIB" ]; then
libname=${libname%.o} echo "WARNING: Couldn't read resource fork for \"$INTERFACELIB\"."
printf " %30s => %-30s\n" ${libname}.o lib${libname}.a echo " Falling back to included import libraries."
asm="$PREFIX/universal/lib68k/$libname.s" fi
obj="$PREFIX/universal/lib68k/$libname.o" echo "Copying readymade PowerPC import libraries..."
lib="$PREFIX/universal/lib68k/lib${libname}.a" cp $PREFIX/multiversal/libppc/*.a $DEST/libppc/
;;
*)
echo "Building PowerPC import libraries..."
for shlib in "${SHAREDLIBRARIES}/"*; do
libname=`basename "$shlib"`
implib=lib${libname}.a
printf " %30s => %-30s\n" ${libname} ${implib}
MakeImport "$shlib" "$DEST/libppc/$implib" || true
done
;;
esac
rm -f $lib if [ -d "${PPCLIBRARIES}" ]; then
echo "Copying static PPC libraries"
if ConvertObj "$macobj" > "$asm"; then for obj in "${PPCLIBRARIES}/"OpenT*.o "${PPCLIBRARIES}/CarbonAccessors.o" "${PPCLIBRARIES}/CursorDevicesGlue.o"; do
m68k-apple-macos-as "$asm" -o "$obj" if [ -r "$obj" ]; then
m68k-apple-macos-ar cqs "$lib" "$obj" # copy the library:
fi cp "$obj" "$DEST/libppc/"
rm -f "$asm" basename=`basename "${obj%.o}"`
# and wrap it in a .a archive for convenience
lib="$PREFIX"/universal/libppc/lib$basename.a
rm -f "$lib"
powerpc-apple-macos-ar cqs "$lib" "$obj"
fi fi
done done
fi fi
}
function setUpInterfacesAndLibraries()
{
DEST=${1:-"$PREFIX/universal"}
rm -rf "$DEST"
mkdir "$DEST"
echo "Preparing CIncludes..."
mkdir "$DEST/CIncludes"
sh "$SRC/prepare-headers.sh" "$CINCLUDES" "$DEST/CIncludes"
echo "Preparing RIncludes..."
mkdir "$DEST/RIncludes"
sh "$SRC/prepare-rincludes.sh" "$RINCLUDES" "$DEST/RIncludes"
if [ $BUILD_68K != false ]; then
setup68KLibraries "$DEST"
fi
if [ $BUILD_PPC != false ]; then if [ $BUILD_PPC != false ]; then
mkdir -p "$PREFIX/universal/libppc" setupPPCLibraries "$DEST"
case `ResInfo -n "$INTERFACELIB" 2> /dev/null || echo 0` in
0)
if [ -n "$INTERFACELIB" ]; then
echo "WARNING: Couldn't read resource fork for \"$INTERFACELIB\"."
echo " Falling back to included import libraries."
fi
echo "Copying readymade PowerPC import libraries..."
cp $PREFIX/multiversal/libppc/*.a $PREFIX/universal/libppc/
;;
*)
echo "Building PowerPC import libraries..."
for shlib in "${SHAREDLIBRARIES}/"*; do
libname=`basename "$shlib"`
implib=lib${libname}.a
printf " %30s => %-30s\n" ${libname} ${implib}
MakeImport "$shlib" "$PREFIX/universal/libppc/$implib" || true
done
;;
esac
if [ -d "${PPCLIBRARIES}" ]; then
echo "Copying static PPC libraries"
for obj in "${PPCLIBRARIES}/"OpenT*.o "${PPCLIBRARIES}/CarbonAccessors.o" "${PPCLIBRARIES}/CursorDevicesGlue.o"; do
if [ -r "$obj" ]; then
# copy the library:
cp "$obj" "$PREFIX/universal/libppc/"
basename=`basename "${obj%.o}"`
# and wrap it in a .a archive for convenience
lib="$PREFIX"/universal/libppc/lib$basename.a
rm -f "$lib"
powerpc-apple-macos-ar cqs "$lib" "$obj"
fi
done
fi
fi fi
} }