]> git.draconx.ca Git - dxcommon.git/blob - snippet/exported.sh.in
exported.sh: Improve error handling.
[dxcommon.git] / snippet / exported.sh.in
1 #!@SHELL@
2 #
3 # Copyright © 2011-2012 Nick Bowler
4 #
5 # Determine the list of exported symbols from archives or (libtool) object
6 # files.
7 #
8 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
9 # This is free software: you are free to do what the fuck you want to.
10 # There is NO WARRANTY, to the extent permitted by law.
11
12 OBJS=
13
14 while test $# -gt 0
15 do
16         case $1 in
17         /*) arg=$1   ;;
18         *)  arg=./$1 ;;
19         esac
20
21         if expr "$arg" : '.*\.lo' >/dev/null; then
22                 non_pic_object=
23                 pic_object=
24                 . "$arg"
25
26                 dir=`expr "$arg" : '\(.*\)/'`
27                 if test x"$pic_object" != x"none"; then
28                         OBJS="$OBJS $dir/$pic_object"
29                 fi
30                 if test x"$non_pic_object" != x"none"; then
31                         OBJS="$OBJS $dir/$non_pic_object"
32                 fi
33         else
34                 OBJS="$OBJS $arg"
35         fi
36
37         shift
38 done
39
40 set x $OBJS; shift
41 case $# in
42 0) : ;;
43 *)
44         exec 4>&1
45         eval_cmd=`exec 3>&1
46                 { @NM@ $OBJS 3>&-
47                         echo "(exit $?) || exit $?" >&3
48                 } | { @GLOBAL_SYMBOL_PIPE@ 3>&-
49                         echo "(exit $?) || exit $?" >&3
50                 } | { @SED@ 's/^.* //' 3>&-
51                         echo "(exit $?) || exit $?" >&3
52                 } | { sort -u 3>&-
53                         echo "(exit $?) || exit $?" >&3
54                 } >&4`
55         exec 4>&-
56         eval "$eval_cmd"
57 ;;
58 esac