#!/bin/sh

# $Id: diet,v 1.2 2000/09/14 23:20:51 taggart Exp $

# This script is used to shrink the size of directories containing
# executables/libraries targetting pa/linux.  It first uses 'linkem'
# to handle redundant files, then uses 'strip' (can be slow) to reduce
# (drastically in some cases) the sizes of pa/linux executables and
# archive libraries.

case "$#:$1" in
    0:*|*:-[h?]*)
	echo "Usage: $0 directories" >&2
	exit 2;;
esac

linkem $* | sh

find $* -type f -print |
    while read a
    do
	case $(file $a) in
	    *ELF\ 32*executable*PA-RISC*not\ stripped)
		hppa-linux-strip $a;;
	    *ELF\ 64*executable*PA-RISC*not\ stripped)
		hppa64-linux-strip $a;;
	    *ELF\ 32*executable*80386*not\ stripped)
		strip $a;;
	    *.a:\ current\ ar\ archive)
		hppa-linux-strip --strip-debug $a;;
	esac
    done
