#!/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 doc-pdf.tar.gz MAKEDOCS=no # Set this to "no" if you want don't want to check for libgdb.a if [ "$CHECKLIBGDB" = "" ]; then CHECKLIBGDB=yes fi # avoid abort of script if FPCDIR isn't set FPCDIR=dummy unset FPCDIR # Goto the toplevel if necessary [ -d install ] || cd .. # Retrieve version from fpcsrc/Makefile.fpc FULLVERSION=`grep '^version' fpcsrc/Makefile.fpc | sed 's+[^=]*= *\(.*\)+\1+'` VERSION=`grep '^version' fpcsrc/Makefile.fpc | sed 's+[^=]*= *\([0-9\.]*\).*+\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 *freebsd*) MAKE=gmake EXTRAOPT="-Fl/usr/local/lib -Fl/usr/X11R6/lib -dFREEBSD5" ;; 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" # 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" = "" ]; then if [ "$CHECKLIBGDB" = "yes" ]; then if [ "$GDBLIBDIR" = "" ]; then GDBLIBDIR=fpcsrc/libgdb/$TARGETOS/$TARGETCPU fi if [ ! -e "$GDBLIBDIR/libgdb.a" ]; then echo "Libgdb ($GDBLIBDIR/libgdb.a) not found, aborting" exit 1 fi else NOGDB=1 fi fi # First check for doc-pdf.tar.gz before building anything if [ "$CROSS" = "" ]; then if [ ! -f doc-pdf.tar.gz ]; then if [ "$MAKEDOCS" != "yes" ]; then echo "No documentation available. Please copy the file doc-pdf.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 MAKEPACK=1 if [ $? != 0 ]; then echo "Failed to make demo source archive." exit 1 fi fi # check existence of binutils if cross packing if [ ! "$CROSS" = "" ]; then if [ ! -f binutils-${CROSSPREFIX}$FULLSOURCE.tar.gz ]; then echo "No cross binutils available: binutils-${CROSSPREFIX}$FULLSOURCE.tar.gz missing." exit 1 fi fi # Build everything using the makefiles ${MAKE} distclean CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS ${MAKE} ${CROSS}zipinstall CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS OPT="${EXTRAOPT}" FPC_VERSION=$VERSION if [ $? != 0 ]; then echo "Failed to make distribution archive." exit 1 fi # Files to be in the release RELFILES="install.sh" # install.sh echo "Copying install.sh" sed -e s+%version%+$VERSION+ -e s+%fullversion%+$FULLVERSION+ install/install.sh > install.sh chmod 755 install.sh # readme.txt cp install/doc/readme.txt . chmod 644 readme.txt # binary.*.tar BINARYTAR=${CROSSPREFIX}binary.$FULLSOURCE.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 # no cross packing # demo, docs RELFILES="$RELFILES demo.tar.gz doc-pdf.tar.gz" else # cross packing # add cross binutils RELFILES="$RELFILES binutils-${CROSSPREFIX}$FULLSOURCE.tar.gz" fi # Files to be added to the .tar DIRNAME=${CROSSPREFIX}fpc-$FULLVERSION.$FULLSOURCE TARNAME=${DIRNAME}.tar echo "Creating $TARNAME" mkdir $DIRNAME mv $RELFILES $DIRNAME tar cf $TARNAME $DIRNAME if [ $? != 0 ]; then echo "Failed to create $TARNAME" exit 1 fi