local FPCDEST FPCDIR FPC_COMP FPC_MAKE                     &&
FPCDEST=${INSTALL_ROOT}/usr                                &&
FPCDIR=$FPCDEST/lib/fpc/${VERSION//-rc3}                           &&
FPC_COMP=$SOURCE_DIRECTORY/fpcsrc/compiler/ppc386                 &&
FPC_MAKE=$SOURCE_DIRECTORY/fpcsrc/utils/fpcm/fpcmake              &&
mkdir -p $FPCDIR                                         &&
chown pascal:pascal $FPCDIR                              &&

# optionally install source files, for use with Lazarus
if [ $FPC_SRC == "y" ];then
  message copying source files                             &&
  cd $SOURCE_DIRECTORY/fpcsrc                                     &&
  cp -r fcl packages rtl $FPCDIR                           &&
# do this manually, else there are two copies of the units
  cd compiler                                              &&
  make install PP=$FPC_COMP  INSTALL_PREFIX=$FPCDEST       &&
  cd ../utils                                              &&
  make install PP=$FPC_COMP  INSTALL_PREFIX=$FPCDEST FPCMAKE=$FPC_MAKE  &&
# link to the already installed units
  cd $FPCDIR                                               &&
  rm -r units                                              &&
  ln -s $FPCDIR/rtl/units
else
  make  install  PP=$FPC_COMP  INSTALL_PREFIX=$FPCDEST
fi                                                         &&
ln -sf $FPCDIR/ppc386 $FPCDEST/bin                       
