fpc/install/makepack
2005-02-10 21:32:42 +00:00

153 lines
3.4 KiB
Bash

#!/usr/bin/env bash
#
# Shell script to make a FPC .tar package for Linux
# Copyright 1996-2004 Michael Van Canneyt and Peter Vreman
#
set -e
# Set this to "yes" if you want to force making the documentation.
# if it is not equal to yes, the documentation is assumed present in a file docs.tar.gz
MAKEDOCS=no
# Set this to "no" if you want don't want to check for libgdb.a
CHECKLIBGDB=yes
unset FPCDIR
# Goto the toplevel if necessary
[ -d install ] || cd ..
# Retrieve version from compiler/Makefile.fpc
VERSION=`grep '^version' compiler/Makefile.fpc | sed 's+[^=]*= *\(.*\)+\1+'`
# Retrieve current system info by calling FPC. We need
# to use the | head -n1 to fix a bug in fpc 1.9.4 and earlier
# that uses exitcode 1 also when printing info resulting in
# fpc binary to print an error line (PFV)
SOURCECPU=`fpc -iSP | head -n1`
SOURCEOS=`fpc -iSO | head -n1`
# retrieve real OS.
HOSTOS=`uname -s | tr "[:upper:]" "[:lower:]"`
MAKE=make
case "$HOSTOS" in
*BSD*) MAKE=gmake
;;
*bsd*) MAKE=gmake
;;
esac
if [ $# -ne 0 ]; then
if [ $# -ne 1 ]; then
echo "Usage: makepack [<cpu>-<os>]"
exit 1
fi
TARGETCPU=`echo $1 | sed 's+\([^-]*\)-.*+\1+'`
TARGETOS=`echo $1 | sed 's+[^-]*-\(.*\)+\1+'`
else
TARGETCPU=$SOURCECPU
TARGETOS=$SOURCEOS
fi
FULLTARGET=$TARGETCPU-$TARGETOS
FULLSOURCE=$SOURCECPU-$SOURCEOS
echo "FPC Source: $FULLSOURCE"
echo "FPC Target: $FULLTARGET"
# Cross building
# - add prefix
# - no IDE
if [ "$FULLTARGET" != "$FULLSOURCE" ]; then
CROSS="cross"
CROSSPREFIX=$FULLTARGET-
IDE=
else
CROSS=
CROSSPREFIX=
IDE=ide
fi
# Check for libgdb.a
if [ ! "$CROSS" = "cross" ]; then
if [ "$CHECKLIBGDB" = "yes" ]; then
if [ "$GDBLIBDIR" = "" ]; then
GDBLIBDIR=libgdb/$TARGETOS/$TARGETCPU
fi
if [ ! -e "$GDBLIBDIR/libgdb.a" ]; then
echo "Libgdb ($GDBLIBDIR/libgdb.a) not found, aborting"
exit 1
fi
fi
fi
# Build everything using the makefiles
${MAKE} distclean CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS
${MAKE} ${CROSS}zipinstall CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS
if [ $? != 0 ]; then
echo "Failed to make distribution archive."
exit 1
fi
if [ "$CROSS" = "" ]; then
if [ ! -f docs.tar.gz ]; then
if [ "$MAKEDOCS" != "yes" ]; then
echo "No documentation available. Please copy the file docs.tar.gz to this directory."
exit 1
else
${MAKE} makepackdocs
if [ $? != 0 ]; then
echo "Failed to make documentation archive."
exit 1
fi
fi
fi
${MAKE} demozip CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS FPC_VERSION=$VERSION
if [ $? != 0 ]; then
echo "Failed to make demo source archive."
exit 1
fi
fi
# Files to be in the release
RELFILES="install.sh"
# install.sh
echo "Copying install.sh"
sed s+%version%+$VERSION+ install/install.sh > install.sh
chmod 755 install.sh
# binary.*.tar
BINARYTAR=${CROSSPREFIX}binary.$FULLTARGET.tar
echo "Creating $BINARYTAR"
BINPACKAGES="base $IDE units utils"
BINFILES=
for p in $BINPACKAGES; do
BINFILES="$BINFILES ${CROSSPREFIX}$p*.$FULLSOURCE.tar.gz"
done
tar cf $BINARYTAR $BINFILES
if [ $? != 0 ]; then
echo "Failed to create $BINARYTAR"
exit 1
fi
RELFILES="$RELFILES $BINARYTAR"
if [ "$CROSS" = "" ]; then
# demo, docs
RELFILES="$RELFILES demo.tar.gz docs.tar.gz"
fi
# Files to be added to the .tar
TARNAME=${CROSSPREFIX}fpc-$VERSION.$FULLSOURCE.tar
echo "Creating $TARNAME"
tar cf $TARNAME $RELFILES
if [ $? != 0 ]; then
echo "Failed to create $TARNAME"
exit 1
fi