]> git.draconx.ca Git - dxcommon.git/blob - snippet/exported.sh.in
DX_C_ALIGNAS: Work around bash-5 parsing bug.
[dxcommon.git] / snippet / exported.sh.in
1 #!@SHELL@
2 #
3 # Copyright © 2011-2012, 2022 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 for arg
15 do
16   case $arg in
17   *.lo)
18     case $arg in /*) :;; *) arg=./$arg ;; esac
19
20     non_pic_object=
21     pic_object=
22     . "$arg"
23
24     dir=`expr "$arg" : '\(.*\)/'`
25     if test x"$pic_object" != x"none"; then
26       OBJS="$OBJS $dir/$pic_object"
27     fi
28     if test x"$non_pic_object" != x"none"; then
29       OBJS="$OBJS $dir/$non_pic_object"
30     fi
31     ;;
32   *)
33     OBJS="$OBJS $arg"
34     ;;
35   esac
36 done
37
38 set x $OBJS; shift
39 case $# in
40 0) : ;;
41 *)
42   exec 4>&1
43   eval_cmd=`exec 3>&1
44     { { @NM@ $OBJS; } 3>&-
45       echo "(exit $?) || exit $?" >&3
46     } | { { @GLOBAL_SYMBOL_PIPE@; } 3>&-
47       echo "(exit $?) || exit $?" >&3
48     } | { { @SED@ 's/^.* //'; } 3>&-
49       echo "(exit $?) || exit $?" >&3
50     } | { { LC_ALL=C sort -u; } 3>&-
51       echo "(exit $?) || exit $?" >&3
52     } >&4`
53   exec 4>&-
54   eval "$eval_cmd"
55 ;;
56 esac