252522bfaa1c718a2adeb5954400a05c1a0f80e5
[openwrt/svn-archive/archive.git] / scripts / rstrip.sh
1 #!/usr/bin/env bash
2 #
3 # Copyright (C) 2006 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9
10 SELF=${0##*/}
11
12 [ -z "$STRIP" ] && {
13 echo "$SELF: strip command not defined (STRIP variable not set)"
14 exit 1
15 }
16
17 TARGETS=$*
18
19 [ -z "$TARGETS" ] && {
20 echo "$SELF: no directories / files specified"
21 echo "usage: $SELF [PATH...]"
22 exit 1
23 }
24
25 find $TARGETS -type f -a -exec file {} \; | \
26 sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.* stripped/\1:\2/p' | \
27 (
28 IFS=":"
29 while read F S; do
30 echo "$SELF: $F:$S"
31 [ "${F##*\.}" = "o" -o "${F##*\.}" = "ko" ] && \
32 eval "$STRIP_KMOD $F" || \
33 eval "$STRIP $F"
34 done
35 true
36 )