619af00d535d4c97398e30101f282396410f44f0
[openwrt/staging/florian.git] / openwrt / scripts / rstrip.sh
1 #!/bin/sh
2
3 SELF=${0##*/}
4
5 [ -z "$STRIP" ] && {
6 echo "$SELF: strip command not defined (STRIP variable not set)"
7 exit 1
8 }
9
10 TARGETS=$*
11
12 [ -z "$TARGETS" ] && {
13 echo "$SELF: no directories / files specified"
14 echo "usage: $SELF [PATH...]"
15 exit 1
16 }
17
18 find $TARGETS -type f -a -exec file {} \; | \
19 sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.* stripped/\1:\2/p' | \
20 (
21 IFS=":"
22 while read F S; do
23 echo "$SELF: $F:$S"
24 [ "${F##*\.}" = "o" -o "${F##*\.}" = "ko" ] && \
25 eval "$STRIP_KMOD $F" || \
26 eval "$STRIP $F"
27 done
28 )