#!/bin/sh

if [ $# -ne 2 -a $# -ne 3 ] ; then
  echo "Usage: $0 target_dir filelist [rm]"
  exit
fi

if [ ! -f $2 ] ; then
  echo Error: file list "'$2'" does not exist
  exit
fi

for file in `cat $2`
do
  if [ -L $1/$file -o -f $1/$file ]; then
    rm -f $1/$file
  fi
  if [ ! "$3" = "rm" ] ; then
    cp -a /opt/hardhat/devkit/ppc/8xx/target/$file $1/$file
    if [ ! -L $1/$file ]; then
      /opt/hardhat/devkit/ppc/8xx/bin/ppc_8xx-strip $1/$file
    fi
  fi
done

