]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/buildfiles/copystrip/strip
Merge branch 'master' into divVerent/crypto2
[xonotic/xonotic.git] / misc / buildfiles / copystrip / strip
1 #!/bin/sh
2 #THIS-IS-COPYSTRIP
3
4 # locate original 'strip' utility
5
6 stripfile=$1
7
8 case "$COPYSTRIP_STRIP" in
9         */*)
10                 echo >&2 "Using $COPYSTRIP_STRIP..."
11                 cp "$stripfile" "$stripfile-withdebug"
12                 exec "$COPYSTRIP_STRIP" "$stripfile"
13                 ;;
14 esac
15
16 p=$PATH
17 while [ -n "$p" ]; do
18         item=${p%%:*}/${COPYSTRIP_STRIP:-strip}
19         if [ -x "$item" ]; then
20                 case "`sed -n 2p "$item"`" in
21                         \#THIS-IS-COPYSTRIP)
22                                 echo >&2 "Found myself in $item"
23                                 ;;
24                         *)
25                                 echo >&2 "Using $item..."
26                                 cp "$stripfile" "$stripfile-withdebug"
27                                 exec "$item" "$stripfile"
28                                 ;;
29                 esac
30         fi
31         case "$p" in
32                 *:*)
33                         p=${p#*:}
34                         ;;
35                 *)
36                         echo >&2 "No strip found in PATH."
37                         exit 1
38                         ;;
39         esac
40 done