#!/bin/bash
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/cvsroot/gentoo-src/portage/bin/prepstrip,v 1.6 2003/02/22 16:59:08 carpaski Exp $

if [ -n "${DEBUGBUILD}" ] ; then
	exit 0
fi

for x in $@ ; do
	if [ -d "${D}${x}" ] ; then
		for y in `find "${D}${x}"/ -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 -or -name "*.so" -or -name "*.so.*" \) 2>/dev/null` ; do
			f="`file "${y}"`"
			if [ "${f/*SB executable*/1}" == "1"  ] ; then
				echo "${y}"
				strip "${y}"
			fi
			if [ "${f/*SB shared object*/1}" == "1" ] ; then
				echo "${y}"
				strip --strip-debug "${y}"
			fi
		done
	fi
done
