summaryrefslogtreecommitdiffstats
path: root/src/util/makeshlib.sh
blob: f305e2df6a92fdb7b5b28baca18e677fb2d16469 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
#
# makeshlib: Make a shared library.....
# This script is used on platforms
# like AIX where making
# a shared library is somewhat more complex than just
# calling ld.
#
# Usage: makeshlib  <version> -o <library><objects> <otherstuff>

#

host=@HOST_TYPE@
CC="@CC@"
HAVE_GCC=@HAVE_GCC@

version=$1;shift
shift; # discard -o
library=$1; shift
for opt in $* ; do
	case $opt in
	    -*)
	    LDFLAGS="$LDFLAGS $opt"
	    ;;
	  *)
	    OBJS="$OBJS $opt"
	  ;;
	esac
done

case $host  in
*-*-aix*)
	echo rm $library 
	rm -f $library 2>/dev/null
	echo ar cq $library $OBJS
	ar cq $library $OBJS || exit $?
	dump -g $library | sed -e 's/^[ 	]*[0-9][0-9]*[ 	]*\([^ 	.][^ 	]*\)$/\1/p;d' | sort | uniq > ${library}.syms
	stat=$?
	if [ $stat -eq 0 ] ; then
	    if test "$HAVE_GCC" = "yes" ; then


		$CC -o shr.o.$version $library  -nostartfiles -Xlinker -bgcbypass:1 -Xlinker -bfilelist -Xlinker -bM:SRE -Xlinker -bE:${library}.syms   $LDFLAGS -lc
	    else
		# Pull in by explicit pathname so we don't get gnu ld if
		# installed (it could be even if we chose not to use gcc).
		# Better still would be to do this through $CC -- how do
		# we get crt0.o left out?
    echo	/bin/ld -o shr.o.$version $library -H512 -T512 -bM:SRE $LDFLAGS -bgcbypass:1 -bnodelcsect -bE:${library}.syms $libdirfl $liblist -lc
		/bin/ld -o shr.o.$version $library -H512 -T512 -bM:SRE $LDFLAGS -bgcbypass:1 -bnodelcsect -bE:${library}.syms  -lc
	    fi
	    stat=$?
	    if [ $stat -eq 0 ] ; then
		rm $library ${library}.syms
		ar cq $library shr.o.$version
		stat=$?
		rm shr.o.$version
	    else
		rm -f $library
	    fi
	fi
	;;

*)
	echo "Host type $host not supported!"
	exit 1
esac
exit $stat