mirror of
https://github.com/autc04/Retro68.git
synced 2025-02-18 02:30:48 +00:00
Add --prefix option to build-toolchain.bash
Some people might want to install the toolchain to a path like /usr/local/retro68.
This commit is contained in:
parent
e107fb0dfb
commit
06ebaee1f8
@ -20,7 +20,8 @@ set -e
|
|||||||
|
|
||||||
# Set up paths.
|
# Set up paths.
|
||||||
SRC=$(cd `dirname $0` && pwd -P)
|
SRC=$(cd `dirname $0` && pwd -P)
|
||||||
PREFIX=`pwd -P`/toolchain/
|
DEFAULT_PREFIX=`pwd -P`/toolchain/
|
||||||
|
PREFIX=$DEFAULT_PREFIX
|
||||||
BINUTILS=`pwd -P`/binutils-build
|
BINUTILS=`pwd -P`/binutils-build
|
||||||
|
|
||||||
##################### Command-line Options
|
##################### Command-line Options
|
||||||
@ -38,6 +39,7 @@ function usage()
|
|||||||
echo "Usage: $0 [options]"
|
echo "Usage: $0 [options]"
|
||||||
echo
|
echo
|
||||||
echo "Options: "
|
echo "Options: "
|
||||||
|
echo " --prefix the path to install the toolchain to"
|
||||||
echo " --skip-thirdparty do not rebuild gcc & third party libraries"
|
echo " --skip-thirdparty do not rebuild gcc & third party libraries"
|
||||||
echo " --no-68k disable support for 68K Macs"
|
echo " --no-68k disable support for 68K Macs"
|
||||||
echo " --no-ppc disable classic PowerPC CFM support"
|
echo " --no-ppc disable classic PowerPC CFM support"
|
||||||
@ -51,6 +53,9 @@ function usage()
|
|||||||
|
|
||||||
for ARG in $*; do
|
for ARG in $*; do
|
||||||
case $ARG in
|
case $ARG in
|
||||||
|
--prefix=*)
|
||||||
|
PREFIX="${ARG#*=}"
|
||||||
|
;;
|
||||||
--skip-thirdparty)
|
--skip-thirdparty)
|
||||||
SKIP_THIRDPARTY=true
|
SKIP_THIRDPARTY=true
|
||||||
;;
|
;;
|
||||||
@ -110,10 +115,20 @@ if [ `pwd -P` == "$SRC" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$PREFIX" != "$DEFAULT_PREFIX" -a -d "$PREFIX" -a $SKIP_THIRDPARTY != true ]; then
|
||||||
|
if [ ! -w "$PREFIX" ]; then
|
||||||
|
echo "$PREFIX is not writable, cannot install to there."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "`ls -A "$PREFIX"`" ]; then
|
||||||
|
echo "$PREFIX is not empty, cannot install to there."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $SKIP_THIRDPARTY != false ]; then
|
if [ $SKIP_THIRDPARTY != false ]; then
|
||||||
MISSING=false
|
MISSING=false
|
||||||
if [ ! -d toolchain ]; then MISSING=true; fi
|
if [ ! -d $PREFIX ]; then MISSING=true; fi
|
||||||
if [ $BUILD_68K != false ]; then
|
if [ $BUILD_68K != false ]; then
|
||||||
if [ ! -d binutils-build ]; then MISSING=true; fi
|
if [ ! -d binutils-build ]; then MISSING=true; fi
|
||||||
if [ ! -d gcc-build ]; then MISSING=true; fi
|
if [ ! -d gcc-build ]; then MISSING=true; fi
|
||||||
@ -303,9 +318,11 @@ fi
|
|||||||
|
|
||||||
if [ $SKIP_THIRDPARTY != true ]; then
|
if [ $SKIP_THIRDPARTY != true ]; then
|
||||||
|
|
||||||
# Remove old install tree
|
if [ "$PREFIX" = "$DEFAULT_PREFIX" ]; then
|
||||||
rm -rf toolchain
|
# Remove old install tree
|
||||||
mkdir -p toolchain
|
rm -rf $PREFIX
|
||||||
|
fi
|
||||||
|
mkdir -p $PREFIX
|
||||||
|
|
||||||
# Components needed for targeting 68K: binutils, gcc
|
# Components needed for targeting 68K: binutils, gcc
|
||||||
if [ $BUILD_68K != false ]; then
|
if [ $BUILD_68K != false ]; then
|
||||||
@ -435,7 +452,7 @@ fi # SKIP_THIRDPARTY
|
|||||||
echo "Building host-based tools..."
|
echo "Building host-based tools..."
|
||||||
|
|
||||||
# Copy PEFBinaryFormat.h from Universal Interfaces, needed by MakePEF & MakeImport
|
# Copy PEFBinaryFormat.h from Universal Interfaces, needed by MakePEF & MakeImport
|
||||||
(export LC_ALL=C; sed 's/\r$//' < "$CINCLUDES/PEFBinaryFormat.h" | tr '\r' '\n' > "toolchain/include/PEFBinaryFormat.h")
|
(export LC_ALL=C; sed 's/\r$//' < "$CINCLUDES/PEFBinaryFormat.h" | tr '\r' '\n' > "$PREFIX/include/PEFBinaryFormat.h")
|
||||||
|
|
||||||
mkdir -p build-host
|
mkdir -p build-host
|
||||||
cd build-host
|
cd build-host
|
||||||
@ -451,17 +468,17 @@ export PATH=$PREFIX/bin:$PATH
|
|||||||
##################### Setup Interfaces & Libraries
|
##################### Setup Interfaces & Libraries
|
||||||
|
|
||||||
echo "Preparing CIncludes..."
|
echo "Preparing CIncludes..."
|
||||||
rm -rf "toolchain/CIncludes"
|
rm -rf "$PREFIX/CIncludes"
|
||||||
mkdir "toolchain/CIncludes"
|
mkdir "$PREFIX/CIncludes"
|
||||||
sh "$SRC/prepare-headers.sh" "$CINCLUDES" "toolchain/CIncludes"
|
sh "$SRC/prepare-headers.sh" "$CINCLUDES" "$PREFIX/CIncludes"
|
||||||
|
|
||||||
echo "Preparing RIncludes..."
|
echo "Preparing RIncludes..."
|
||||||
rm -rf "toolchain/RIncludes"
|
rm -rf "$PREFIX/RIncludes"
|
||||||
mkdir "toolchain/RIncludes"
|
mkdir "$PREFIX/RIncludes"
|
||||||
sh "$SRC/prepare-rincludes.sh" "$RINCLUDES" "toolchain/RIncludes"
|
sh "$SRC/prepare-rincludes.sh" "$RINCLUDES" "$PREFIX/RIncludes"
|
||||||
|
|
||||||
# remove old symlinks in toolchain/*-apple-macos/include/
|
# remove old symlinks in $PREFIX/*-apple-macos/include/
|
||||||
# and link files from toolchain/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
|
||||||
@ -478,13 +495,13 @@ function linkheaders()
|
|||||||
echo "Creating Symlinks for CIncludes and RIncludes..."
|
echo "Creating Symlinks for CIncludes and RIncludes..."
|
||||||
|
|
||||||
if [ $BUILD_68K != false ]; then
|
if [ $BUILD_68K != false ]; then
|
||||||
ln -sf ../RIncludes toolchain/m68k-apple-macos/RIncludes
|
ln -sf ../RIncludes $PREFIX/m68k-apple-macos/RIncludes
|
||||||
linkheaders toolchain/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 toolchain/powerpc-apple-macos/RIncludes
|
ln -sf ../RIncludes $PREFIX/powerpc-apple-macos/RIncludes
|
||||||
linkheaders toolchain/powerpc-apple-macos/include
|
linkheaders $PREFIX/powerpc-apple-macos/include
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BUILD_68K != false ]; then
|
if [ $BUILD_68K != false ]; then
|
||||||
@ -494,8 +511,8 @@ if [ $BUILD_68K != false ]; then
|
|||||||
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
|
||||||
obj="toolchain/m68k-apple-macos/lib/$libname.o"
|
obj="$PREFIX/m68k-apple-macos/lib/$libname.o"
|
||||||
lib="toolchain/m68k-apple-macos/lib/lib${libname}.a"
|
lib="$PREFIX/m68k-apple-macos/lib/lib${libname}.a"
|
||||||
rm -f $lib
|
rm -f $lib
|
||||||
|
|
||||||
(ConvertObj "$macobj" | m68k-apple-macos-as - -o $obj) && m68k-apple-macos-ar cqs $lib $obj
|
(ConvertObj "$macobj" | m68k-apple-macos-as - -o $obj) && m68k-apple-macos-ar cqs $lib $obj
|
||||||
@ -509,7 +526,7 @@ if [ $BUILD_PPC != false ]; then
|
|||||||
echo "WARNING: Couldn't read resource fork for \"$INTERFACELIB\"."
|
echo "WARNING: Couldn't read resource fork for \"$INTERFACELIB\"."
|
||||||
echo " Falling back to included import libraries."
|
echo " Falling back to included import libraries."
|
||||||
echo "Copying readymade PowerPC import libraries..."
|
echo "Copying readymade PowerPC import libraries..."
|
||||||
cp $SRC/ImportLibraries/*.a toolchain/powerpc-apple-macos/lib/
|
cp $SRC/ImportLibraries/*.a $PREFIX/powerpc-apple-macos/lib/
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Building PowerPC import libraries..."
|
echo "Building PowerPC import libraries..."
|
||||||
@ -517,7 +534,7 @@ if [ $BUILD_PPC != false ]; then
|
|||||||
libname=`basename "$shlib"`
|
libname=`basename "$shlib"`
|
||||||
implib=lib${libname}.a
|
implib=lib${libname}.a
|
||||||
printf " %30s => %-30s\n" ${libname} ${implib}
|
printf " %30s => %-30s\n" ${libname} ${implib}
|
||||||
MakeImport "$shlib" "toolchain/powerpc-apple-macos/lib/$implib"
|
MakeImport "$shlib" "$PREFIX/powerpc-apple-macos/lib/$implib"
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -527,12 +544,12 @@ if [ $BUILD_PPC != false ]; then
|
|||||||
for obj in ${PPCLIBRARIES}/OpenT*.o ${PPCLIBRARIES}/CarbonAccessors.o ${PPCLIBRARIES}/CursorDevicesGlue.o; do
|
for obj in ${PPCLIBRARIES}/OpenT*.o ${PPCLIBRARIES}/CarbonAccessors.o ${PPCLIBRARIES}/CursorDevicesGlue.o; do
|
||||||
if [ -r $obj ]; then
|
if [ -r $obj ]; then
|
||||||
# copy the library:
|
# copy the library:
|
||||||
cp $obj toolchain/powerpc-apple-macos/lib/
|
cp $obj $PREFIX/powerpc-apple-macos/lib/
|
||||||
|
|
||||||
# and wrap it in a .a archive for convenience
|
# and wrap it in a .a archive for convenience
|
||||||
lib=toolchain/powerpc-apple-macos/lib/lib`basename "${obj%.o}"`.a
|
lib=$PREFIX/powerpc-apple-macos/lib/lib`basename "${obj%.o}"`.a
|
||||||
rm -f $lib
|
rm -f $lib
|
||||||
toolchain/bin/powerpc-apple-macos-ar cqs $lib $obj
|
$PREFIX/bin/powerpc-apple-macos-ar cqs $lib $obj
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user