123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- #!/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
- 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 [<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
- # 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} sourcezip CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS FPC_VERSION=$VERSION
- if [ $? != 0 ]; then
- echo "Failed to make source archive."
- exit 1
- fi
- ${MAKE} docsrc CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS FPC_VERSION=$VERSION
- if [ $? != 0 ]; then
- echo "Failed to make documentation source archive."
- exit 1
- 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
- # 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
- RELFILES="$RELFILES sources.tar"
- # 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
|