#!/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 # Al 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. HOSTARCH=`uname -p | tr "[:upper:]" "[:lower:]"` 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 [-]" 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" if [ "$FULLTARGET" != "$FULLSOURCE" ]; then CROSS="cross" CROSSPREFIX=$FULLTARGET- else CROSS= CROSSPREFIX= 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 ${MAKE} makepackdocs if [ $? != 0 ]; then echo "Failed to make documentation archive." exit 1 fi ${MAKE} sourcezip if [ $? != 0 ]; then echo "Failed to make source archive." exit 1 fi ${MAKE} docsrc if [ $? != 0 ]; then echo "Failed to make documentation source archive." exit 1 fi ${MAKE} demozip if [ $? != 0 ]; then echo "Failed to make demo source archive." exit 1 fi fi # 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 # sources.tar echo "Creating sources.tar" tar cf sources.tar *.source.tar.gz if [ $? != 0 ]; then echo "Failed to create sources.tar" exit 1 fi # install.sh echo "Copying install.sh" sed s+%version%+$VERSION+ install/install.sh > install.sh chmod 755 install.sh # Files to be added to the .tar RELFILES="$BINARYTAR sources.tar demo.tar.gz docs.tar.gz install.sh" TARNAME=${CROSSPREFIX}fpc-$VERSION.$FULLSOURCE.tar echo "Creating $TARNAME" tar cf $TARNAME $RELFILES if [ $? != 0 ]; then echo "Failed to create $TARNAME" exit 1 fi