#! /bin/sh
#
# install-epocsdk-libs -- Copyright (c) 2001-2002 Eberhard Mattes
#
# This file is part of epocemx.
#
# epocemx is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# epocemx is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with epocemx; see the file COPYING.  If not, write to the
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#

usage()
{
  echo "Usage: $myname SOURCE_DIRECTORY DESTINATION_DIRECTORY"
  exit 1
}

die()
{
  echo "$*"
  exit 2
}

myname=$0
test $# = 2 || usage
test -d "$1" || die "$1: not a directory"
test -d "$2" || die "$2: not a directory"

for x in $1/*.[Ll][Ii][Bb]
do
  t=`basename $x|tr '[A-Z]' '[a-z]'|sed -n 's/\(.*\)\.lib$/lib\1.a/p'`
  d=$2/$t
  echo "Creating $d"
  emxobj -m1 -x remangle.explicit $x $d || die "emxobj failed"
  arm-epoc-pe-ranlib $d || die "ranlib failed"
done

for x in $1/*.[Oo]
do
  t=`basename $x|tr '[A-Z]' '[a-z]'`
  d=$2/$t
  echo "Creating $d"
  emxobj -m1 -x remangle.explicit $x $d || die "emxobj failed"
done
